summaryrefslogtreecommitdiffstats
path: root/WebCore/platform
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-03 18:28:41 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-03 18:28:41 -0800
commit648161bb0edfc3d43db63caed5cc5213bc6cb78f (patch)
tree4b825dc642cb6eb9a060e54bf8d69288fbee4904 /WebCore/platform
parenta65af38181ac7d34544586bdb5cd004de93897ad (diff)
downloadexternal_webkit-648161bb0edfc3d43db63caed5cc5213bc6cb78f.zip
external_webkit-648161bb0edfc3d43db63caed5cc5213bc6cb78f.tar.gz
external_webkit-648161bb0edfc3d43db63caed5cc5213bc6cb78f.tar.bz2
auto import from //depot/cupcake/@135843
Diffstat (limited to 'WebCore/platform')
-rw-r--r--WebCore/platform/Arena.cpp282
-rw-r--r--WebCore/platform/Arena.h130
-rw-r--r--WebCore/platform/AutodrainedPool.h67
-rw-r--r--WebCore/platform/ColorData.gperf151
-rw-r--r--WebCore/platform/ContextMenu.cpp609
-rw-r--r--WebCore/platform/ContextMenu.h88
-rw-r--r--WebCore/platform/ContextMenuItem.h222
-rw-r--r--WebCore/platform/CookieJar.h47
-rw-r--r--WebCore/platform/Cursor.h153
-rw-r--r--WebCore/platform/DeprecatedPtrList.h113
-rw-r--r--WebCore/platform/DeprecatedPtrListImpl.cpp514
-rw-r--r--WebCore/platform/DeprecatedPtrListImpl.h122
-rw-r--r--WebCore/platform/DeprecatedPtrQueue.h49
-rw-r--r--WebCore/platform/DeprecatedValueList.h151
-rw-r--r--WebCore/platform/DeprecatedValueListImpl.cpp407
-rw-r--r--WebCore/platform/DeprecatedValueListImpl.h189
-rw-r--r--WebCore/platform/DragData.cpp42
-rw-r--r--WebCore/platform/DragData.h116
-rw-r--r--WebCore/platform/DragImage.cpp74
-rw-r--r--WebCore/platform/DragImage.h93
-rw-r--r--WebCore/platform/EventLoop.h49
-rw-r--r--WebCore/platform/FileChooser.cpp93
-rw-r--r--WebCore/platform/FileChooser.h80
-rw-r--r--WebCore/platform/FileSystem.h176
-rw-r--r--WebCore/platform/FloatConversion.h61
-rw-r--r--WebCore/platform/GeolocationService.cpp58
-rw-r--r--WebCore/platform/GeolocationService.h71
-rw-r--r--WebCore/platform/HostWindow.h62
-rw-r--r--WebCore/platform/KURL.cpp1577
-rw-r--r--WebCore/platform/KURL.h283
-rw-r--r--WebCore/platform/KURLHash.h61
-rw-r--r--WebCore/platform/Language.h37
-rw-r--r--WebCore/platform/Length.cpp151
-rw-r--r--WebCore/platform/Length.h197
-rw-r--r--WebCore/platform/LengthBox.h85
-rw-r--r--WebCore/platform/LengthSize.h58
-rw-r--r--WebCore/platform/LocalizedStrings.h123
-rw-r--r--WebCore/platform/Logging.cpp62
-rw-r--r--WebCore/platform/Logging.h62
-rw-r--r--WebCore/platform/MIMETypeRegistry.cpp366
-rw-r--r--WebCore/platform/MIMETypeRegistry.h77
-rw-r--r--WebCore/platform/NotImplemented.h68
-rw-r--r--WebCore/platform/Pasteboard.h135
-rw-r--r--WebCore/platform/PlatformKeyboardEvent.h205
-rw-r--r--WebCore/platform/PlatformMenuDescription.h67
-rw-r--r--WebCore/platform/PlatformMouseEvent.h167
-rw-r--r--WebCore/platform/PlatformScreen.h66
-rw-r--r--WebCore/platform/PlatformTouchEvent.h68
-rw-r--r--WebCore/platform/PlatformWheelEvent.h142
-rw-r--r--WebCore/platform/PopupMenu.h186
-rw-r--r--WebCore/platform/PopupMenuClient.h67
-rw-r--r--WebCore/platform/PopupMenuStyle.h58
-rw-r--r--WebCore/platform/SSLKeyGenerator.h41
-rw-r--r--WebCore/platform/ScrollTypes.h85
-rw-r--r--WebCore/platform/ScrollView.cpp878
-rw-r--r--WebCore/platform/ScrollView.h316
-rw-r--r--WebCore/platform/Scrollbar.cpp451
-rw-r--r--WebCore/platform/Scrollbar.h168
-rw-r--r--WebCore/platform/ScrollbarClient.h48
-rw-r--r--WebCore/platform/ScrollbarTheme.h94
-rw-r--r--WebCore/platform/ScrollbarThemeComposite.cpp302
-rw-r--r--WebCore/platform/ScrollbarThemeComposite.h70
-rw-r--r--WebCore/platform/SearchPopupMenu.h46
-rw-r--r--WebCore/platform/SharedBuffer.cpp119
-rw-r--r--WebCore/platform/SharedBuffer.h97
-rw-r--r--WebCore/platform/SharedTimer.h44
-rw-r--r--WebCore/platform/Sound.h35
-rw-r--r--WebCore/platform/StaticConstructors.h76
-rw-r--r--WebCore/platform/SystemTime.h43
-rw-r--r--WebCore/platform/Theme.cpp58
-rw-r--r--WebCore/platform/Theme.h122
-rw-r--r--WebCore/platform/ThemeTypes.h75
-rw-r--r--WebCore/platform/ThreadCheck.h44
-rw-r--r--WebCore/platform/Timer.cpp396
-rw-r--r--WebCore/platform/Timer.h112
-rw-r--r--WebCore/platform/TreeShared.h108
-rw-r--r--WebCore/platform/Widget.cpp121
-rw-r--r--WebCore/platform/Widget.h212
-rw-r--r--WebCore/platform/android/ClipboardAndroid.cpp105
-rw-r--r--WebCore/platform/android/ClipboardAndroid.h64
-rw-r--r--WebCore/platform/android/CursorAndroid.cpp295
-rw-r--r--WebCore/platform/android/DragDataAndroid.cpp96
-rw-r--r--WebCore/platform/android/EventLoopAndroid.cpp38
-rw-r--r--WebCore/platform/android/FileChooserAndroid.cpp59
-rw-r--r--WebCore/platform/android/FileSystemAndroid.cpp101
-rw-r--r--WebCore/platform/android/KeyEventAndroid.cpp267
-rw-r--r--WebCore/platform/android/KeyboardCodes.h545
-rw-r--r--WebCore/platform/android/LocalizedStringsAndroid.cpp54
-rw-r--r--WebCore/platform/android/PopupMenuAndroid.cpp58
-rw-r--r--WebCore/platform/android/RenderThemeAndroid.cpp318
-rw-r--r--WebCore/platform/android/RenderThemeAndroid.h105
-rw-r--r--WebCore/platform/android/ScreenAndroid.cpp134
-rw-r--r--WebCore/platform/android/ScrollViewAndroid.cpp105
-rw-r--r--WebCore/platform/android/SearchPopupMenuAndroid.cpp52
-rw-r--r--WebCore/platform/android/SharedTimerAndroid.cpp64
-rw-r--r--WebCore/platform/android/SystemTimeAndroid.cpp59
-rw-r--r--WebCore/platform/android/TemporaryLinkStubs.cpp965
-rw-r--r--WebCore/platform/android/TextBoundaries.cpp78
-rw-r--r--WebCore/platform/android/TextBreakIteratorInternalICU.cpp36
-rw-r--r--WebCore/platform/android/WidgetAndroid.cpp126
-rw-r--r--WebCore/platform/cf/FileSystemCF.cpp57
-rw-r--r--WebCore/platform/cf/KURLCFNet.cpp95
-rw-r--r--WebCore/platform/cf/SchedulePair.cpp52
-rw-r--r--WebCore/platform/cf/SchedulePair.h88
-rw-r--r--WebCore/platform/cf/SharedBufferCF.cpp84
-rw-r--r--WebCore/platform/graphics/AffineTransform.cpp194
-rw-r--r--WebCore/platform/graphics/AffineTransform.h140
-rw-r--r--WebCore/platform/graphics/BitmapImage.cpp438
-rw-r--r--WebCore/platform/graphics/BitmapImage.h258
-rw-r--r--WebCore/platform/graphics/Color.cpp306
-rw-r--r--WebCore/platform/graphics/Color.h156
-rw-r--r--WebCore/platform/graphics/DashArray.h39
-rw-r--r--WebCore/platform/graphics/FloatPoint.cpp52
-rw-r--r--WebCore/platform/graphics/FloatPoint.h151
-rw-r--r--WebCore/platform/graphics/FloatPoint3D.cpp85
-rw-r--r--WebCore/platform/graphics/FloatPoint3D.h55
-rw-r--r--WebCore/platform/graphics/FloatRect.cpp122
-rw-r--r--WebCore/platform/graphics/FloatRect.h184
-rw-r--r--WebCore/platform/graphics/FloatSize.cpp44
-rw-r--r--WebCore/platform/graphics/FloatSize.h125
-rw-r--r--WebCore/platform/graphics/Font.cpp626
-rw-r--r--WebCore/platform/graphics/Font.h210
-rw-r--r--WebCore/platform/graphics/FontCache.cpp425
-rw-r--r--WebCore/platform/graphics/FontCache.h95
-rw-r--r--WebCore/platform/graphics/FontData.cpp35
-rw-r--r--WebCore/platform/graphics/FontData.h60
-rw-r--r--WebCore/platform/graphics/FontDescription.cpp101
-rw-r--r--WebCore/platform/graphics/FontDescription.h139
-rw-r--r--WebCore/platform/graphics/FontFallbackList.cpp134
-rw-r--r--WebCore/platform/graphics/FontFallbackList.h79
-rw-r--r--WebCore/platform/graphics/FontFamily.cpp59
-rw-r--r--WebCore/platform/graphics/FontFamily.h88
-rw-r--r--WebCore/platform/graphics/FontRenderingMode.h37
-rw-r--r--WebCore/platform/graphics/FontSelector.h47
-rw-r--r--WebCore/platform/graphics/FontTraitsMask.h70
-rw-r--r--WebCore/platform/graphics/GeneratedImage.cpp68
-rw-r--r--WebCore/platform/graphics/GeneratedImage.h77
-rw-r--r--WebCore/platform/graphics/Generator.h45
-rw-r--r--WebCore/platform/graphics/GlyphBuffer.h182
-rw-r--r--WebCore/platform/graphics/GlyphPageTreeNode.cpp384
-rw-r--r--WebCore/platform/graphics/GlyphPageTreeNode.h177
-rw-r--r--WebCore/platform/graphics/GlyphWidthMap.cpp79
-rw-r--r--WebCore/platform/graphics/GlyphWidthMap.h74
-rw-r--r--WebCore/platform/graphics/Gradient.cpp149
-rw-r--r--WebCore/platform/graphics/Gradient.h121
-rw-r--r--WebCore/platform/graphics/GraphicsContext.cpp507
-rw-r--r--WebCore/platform/graphics/GraphicsContext.h381
-rw-r--r--WebCore/platform/graphics/GraphicsContextPrivate.h112
-rw-r--r--WebCore/platform/graphics/GraphicsTypes.cpp189
-rw-r--r--WebCore/platform/graphics/GraphicsTypes.h80
-rw-r--r--WebCore/platform/graphics/Icon.h86
-rw-r--r--WebCore/platform/graphics/Image.cpp198
-rw-r--r--WebCore/platform/graphics/Image.h186
-rw-r--r--WebCore/platform/graphics/ImageBuffer.h85
-rw-r--r--WebCore/platform/graphics/ImageObserver.h48
-rw-r--r--WebCore/platform/graphics/ImageSource.h127
-rw-r--r--WebCore/platform/graphics/IntPoint.h180
-rw-r--r--WebCore/platform/graphics/IntRect.cpp107
-rw-r--r--WebCore/platform/graphics/IntRect.h210
-rw-r--r--WebCore/platform/graphics/IntSize.h157
-rw-r--r--WebCore/platform/graphics/IntSizeHash.h46
-rw-r--r--WebCore/platform/graphics/MediaPlayer.cpp272
-rw-r--r--WebCore/platform/graphics/MediaPlayer.h137
-rw-r--r--WebCore/platform/graphics/Path.cpp276
-rw-r--r--WebCore/platform/graphics/Path.h135
-rw-r--r--WebCore/platform/graphics/PathTraversalState.cpp207
-rw-r--r--WebCore/platform/graphics/PathTraversalState.h72
-rw-r--r--WebCore/platform/graphics/Pattern.cpp46
-rw-r--r--WebCore/platform/graphics/Pattern.h82
-rw-r--r--WebCore/platform/graphics/Pen.cpp77
-rw-r--r--WebCore/platform/graphics/Pen.h72
-rw-r--r--WebCore/platform/graphics/SegmentedFontData.cpp79
-rw-r--r--WebCore/platform/graphics/SegmentedFontData.h75
-rw-r--r--WebCore/platform/graphics/SimpleFontData.cpp153
-rw-r--r--WebCore/platform/graphics/SimpleFontData.h202
-rw-r--r--WebCore/platform/graphics/StringTruncator.cpp198
-rw-r--r--WebCore/platform/graphics/StringTruncator.h46
-rw-r--r--WebCore/platform/graphics/TextRun.h126
-rw-r--r--WebCore/platform/graphics/UnitBezier.h123
-rw-r--r--WebCore/platform/graphics/WidthIterator.cpp234
-rw-r--r--WebCore/platform/graphics/WidthIterator.h56
-rw-r--r--WebCore/platform/graphics/android/AffineTransformAndroid.cpp218
-rw-r--r--WebCore/platform/graphics/android/FontAndroid.cpp208
-rw-r--r--WebCore/platform/graphics/android/FontCacheAndroid.cpp134
-rw-r--r--WebCore/platform/graphics/android/FontCustomPlatformData.cpp78
-rw-r--r--WebCore/platform/graphics/android/FontCustomPlatformData.h57
-rw-r--r--WebCore/platform/graphics/android/FontDataAndroid.cpp122
-rw-r--r--WebCore/platform/graphics/android/FontPlatformData.h72
-rw-r--r--WebCore/platform/graphics/android/FontPlatformDataAndroid.cpp176
-rw-r--r--WebCore/platform/graphics/android/GlyphMapAndroid.cpp70
-rw-r--r--WebCore/platform/graphics/android/GradientAndroid.cpp116
-rw-r--r--WebCore/platform/graphics/android/GraphicsContextAndroid.cpp1118
-rw-r--r--WebCore/platform/graphics/android/ImageAndroid.cpp297
-rw-r--r--WebCore/platform/graphics/android/ImageBufferAndroid.cpp216
-rw-r--r--WebCore/platform/graphics/android/ImageBufferData.h40
-rw-r--r--WebCore/platform/graphics/android/ImageSourceAndroid.cpp361
-rw-r--r--WebCore/platform/graphics/android/PathAndroid.cpp268
-rw-r--r--WebCore/platform/graphics/android/PatternAndroid.cpp54
-rw-r--r--WebCore/platform/graphics/android/PlatformGraphicsContext.cpp77
-rw-r--r--WebCore/platform/graphics/android/PlatformGraphicsContext.h169
-rw-r--r--WebCore/platform/graphics/android/SkBitmapRef.h62
-rw-r--r--WebCore/platform/graphics/android/android_graphics.cpp228
-rw-r--r--WebCore/platform/graphics/android/android_graphics.h89
-rw-r--r--WebCore/platform/graphics/cairo/AffineTransformCairo.cpp281
-rw-r--r--WebCore/platform/graphics/cairo/CairoPath.h45
-rw-r--r--WebCore/platform/graphics/cairo/FontCairo.cpp105
-rw-r--r--WebCore/platform/graphics/cairo/GradientCairo.cpp74
-rw-r--r--WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp1104
-rw-r--r--WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h101
-rw-r--r--WebCore/platform/graphics/cairo/ImageBufferCairo.cpp224
-rw-r--r--WebCore/platform/graphics/cairo/ImageBufferData.h44
-rw-r--r--WebCore/platform/graphics/cairo/ImageCairo.cpp187
-rw-r--r--WebCore/platform/graphics/cairo/ImageSourceCairo.cpp229
-rw-r--r--WebCore/platform/graphics/cairo/PathCairo.cpp285
-rw-r--r--WebCore/platform/graphics/cairo/PatternCairo.cpp50
-rw-r--r--WebCore/platform/graphics/cairo/rgb24-hacks.txt32
-rw-r--r--WebCore/platform/graphics/cairo/scale-removal.txt13
-rw-r--r--WebCore/platform/graphics/cg/AffineTransformCG.cpp216
-rw-r--r--WebCore/platform/graphics/cg/ColorCG.cpp96
-rw-r--r--WebCore/platform/graphics/cg/FloatPointCG.cpp47
-rw-r--r--WebCore/platform/graphics/cg/FloatRectCG.cpp47
-rw-r--r--WebCore/platform/graphics/cg/FloatSizeCG.cpp47
-rw-r--r--WebCore/platform/graphics/cg/GradientCG.cpp82
-rw-r--r--WebCore/platform/graphics/cg/GraphicsContextCG.cpp1144
-rw-r--r--WebCore/platform/graphics/cg/GraphicsContextPlatformPrivateCG.h83
-rw-r--r--WebCore/platform/graphics/cg/ImageBufferCG.cpp275
-rw-r--r--WebCore/platform/graphics/cg/ImageBufferData.h42
-rw-r--r--WebCore/platform/graphics/cg/ImageCG.cpp312
-rw-r--r--WebCore/platform/graphics/cg/ImageSourceCG.cpp225
-rw-r--r--WebCore/platform/graphics/cg/IntPointCG.cpp46
-rw-r--r--WebCore/platform/graphics/cg/IntRectCG.cpp51
-rw-r--r--WebCore/platform/graphics/cg/IntSizeCG.cpp46
-rw-r--r--WebCore/platform/graphics/cg/PDFDocumentImage.cpp179
-rw-r--r--WebCore/platform/graphics/cg/PDFDocumentImage.h75
-rw-r--r--WebCore/platform/graphics/cg/PathCG.cpp291
-rw-r--r--WebCore/platform/graphics/cg/PatternCG.cpp77
-rw-r--r--WebCore/platform/graphics/filters/FEBlend.cpp72
-rw-r--r--WebCore/platform/graphics/filters/FEBlend.h64
-rw-r--r--WebCore/platform/graphics/filters/FEColorMatrix.cpp72
-rw-r--r--WebCore/platform/graphics/filters/FEColorMatrix.h64
-rw-r--r--WebCore/platform/graphics/filters/FEComponentTransfer.cpp96
-rw-r--r--WebCore/platform/graphics/filters/FEComponentTransfer.h99
-rw-r--r--WebCore/platform/graphics/filters/FEComposite.cpp108
-rw-r--r--WebCore/platform/graphics/filters/FEComposite.h81
-rw-r--r--WebCore/platform/graphics/gtk/ColorGtk.cpp35
-rw-r--r--WebCore/platform/graphics/gtk/FontCacheGtk.cpp84
-rw-r--r--WebCore/platform/graphics/gtk/FontCustomPlatformData.cpp73
-rw-r--r--WebCore/platform/graphics/gtk/FontCustomPlatformData.h50
-rw-r--r--WebCore/platform/graphics/gtk/FontCustomPlatformDataPango.cpp49
-rw-r--r--WebCore/platform/graphics/gtk/FontGtk.cpp371
-rw-r--r--WebCore/platform/graphics/gtk/FontPlatformData.h132
-rw-r--r--WebCore/platform/graphics/gtk/FontPlatformDataGtk.cpp210
-rw-r--r--WebCore/platform/graphics/gtk/FontPlatformDataPango.cpp229
-rw-r--r--WebCore/platform/graphics/gtk/GlyphPageTreeNodeGtk.cpp65
-rw-r--r--WebCore/platform/graphics/gtk/GlyphPageTreeNodePango.cpp98
-rw-r--r--WebCore/platform/graphics/gtk/IconGtk.cpp125
-rw-r--r--WebCore/platform/graphics/gtk/ImageGtk.cpp52
-rw-r--r--WebCore/platform/graphics/gtk/IntPointGtk.cpp41
-rw-r--r--WebCore/platform/graphics/gtk/IntRectGtk.cpp41
-rw-r--r--WebCore/platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp622
-rw-r--r--WebCore/platform/graphics/gtk/MediaPlayerPrivateGStreamer.h135
-rw-r--r--WebCore/platform/graphics/gtk/SimpleFontDataGtk.cpp141
-rw-r--r--WebCore/platform/graphics/gtk/SimpleFontDataPango.cpp142
-rw-r--r--WebCore/platform/graphics/gtk/VideoSinkGStreamer.cpp312
-rw-r--r--WebCore/platform/graphics/gtk/VideoSinkGStreamer.h83
-rw-r--r--WebCore/platform/graphics/mac/ColorMac.h50
-rw-r--r--WebCore/platform/graphics/mac/ColorMac.mm169
-rw-r--r--WebCore/platform/graphics/mac/CoreTextController.cpp533
-rw-r--r--WebCore/platform/graphics/mac/CoreTextController.h114
-rw-r--r--WebCore/platform/graphics/mac/FloatPointMac.mm45
-rw-r--r--WebCore/platform/graphics/mac/FloatRectMac.mm45
-rw-r--r--WebCore/platform/graphics/mac/FloatSizeMac.mm45
-rw-r--r--WebCore/platform/graphics/mac/FontCacheMac.mm202
-rw-r--r--WebCore/platform/graphics/mac/FontCustomPlatformData.cpp84
-rw-r--r--WebCore/platform/graphics/mac/FontCustomPlatformData.h53
-rw-r--r--WebCore/platform/graphics/mac/FontMac.mm122
-rw-r--r--WebCore/platform/graphics/mac/FontMacATSUI.mm623
-rw-r--r--WebCore/platform/graphics/mac/FontMacCoreText.cpp102
-rw-r--r--WebCore/platform/graphics/mac/FontPlatformData.h126
-rw-r--r--WebCore/platform/graphics/mac/FontPlatformDataMac.mm107
-rw-r--r--WebCore/platform/graphics/mac/GlyphPageTreeNodeMac.cpp91
-rw-r--r--WebCore/platform/graphics/mac/GraphicsContextMac.mm165
-rw-r--r--WebCore/platform/graphics/mac/IconMac.mm84
-rw-r--r--WebCore/platform/graphics/mac/ImageMac.mm125
-rw-r--r--WebCore/platform/graphics/mac/IntPointMac.mm44
-rw-r--r--WebCore/platform/graphics/mac/IntRectMac.mm49
-rw-r--r--WebCore/platform/graphics/mac/IntSizeMac.mm44
-rw-r--r--WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h149
-rw-r--r--WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm1024
-rw-r--r--WebCore/platform/graphics/mac/SimpleFontDataMac.mm435
-rw-r--r--WebCore/platform/graphics/qt/AffineTransformQt.cpp202
-rw-r--r--WebCore/platform/graphics/qt/ColorQt.cpp48
-rw-r--r--WebCore/platform/graphics/qt/FloatPointQt.cpp48
-rw-r--r--WebCore/platform/graphics/qt/FloatRectQt.cpp49
-rw-r--r--WebCore/platform/graphics/qt/FontCacheQt.cpp56
-rw-r--r--WebCore/platform/graphics/qt/FontCustomPlatformData.cpp56
-rw-r--r--WebCore/platform/graphics/qt/FontCustomPlatformData.h45
-rw-r--r--WebCore/platform/graphics/qt/FontPlatformData.h37
-rw-r--r--WebCore/platform/graphics/qt/FontQt.cpp706
-rw-r--r--WebCore/platform/graphics/qt/GlyphPageTreeNodeQt.cpp31
-rw-r--r--WebCore/platform/graphics/qt/GradientQt.cpp77
-rw-r--r--WebCore/platform/graphics/qt/GraphicsContextQt.cpp1146
-rw-r--r--WebCore/platform/graphics/qt/IconQt.cpp68
-rw-r--r--WebCore/platform/graphics/qt/ImageBufferData.h48
-rw-r--r--WebCore/platform/graphics/qt/ImageBufferQt.cpp115
-rw-r--r--WebCore/platform/graphics/qt/ImageDecoderQt.cpp308
-rw-r--r--WebCore/platform/graphics/qt/ImageDecoderQt.h99
-rw-r--r--WebCore/platform/graphics/qt/ImageQt.cpp171
-rw-r--r--WebCore/platform/graphics/qt/ImageSourceQt.cpp174
-rw-r--r--WebCore/platform/graphics/qt/IntPointQt.cpp48
-rw-r--r--WebCore/platform/graphics/qt/IntRectQt.cpp48
-rw-r--r--WebCore/platform/graphics/qt/IntSizeQt.cpp49
-rw-r--r--WebCore/platform/graphics/qt/MediaPlayerPrivatePhonon.cpp533
-rw-r--r--WebCore/platform/graphics/qt/MediaPlayerPrivatePhonon.h159
-rw-r--r--WebCore/platform/graphics/qt/PathQt.cpp278
-rw-r--r--WebCore/platform/graphics/qt/PatternQt.cpp46
-rw-r--r--WebCore/platform/graphics/qt/SimpleFontDataQt.cpp55
-rw-r--r--WebCore/platform/graphics/qt/StillImageQt.cpp65
-rw-r--r--WebCore/platform/graphics/qt/StillImageQt.h59
-rw-r--r--WebCore/platform/graphics/win/ColorSafari.cpp71
-rw-r--r--WebCore/platform/graphics/win/FontCGWin.cpp361
-rw-r--r--WebCore/platform/graphics/win/FontCacheWin.cpp525
-rw-r--r--WebCore/platform/graphics/win/FontCustomPlatformData.cpp235
-rw-r--r--WebCore/platform/graphics/win/FontCustomPlatformData.h56
-rw-r--r--WebCore/platform/graphics/win/FontCustomPlatformDataCairo.cpp61
-rw-r--r--WebCore/platform/graphics/win/FontCustomPlatformDataCairo.h49
-rw-r--r--WebCore/platform/graphics/win/FontDatabase.cpp150
-rw-r--r--WebCore/platform/graphics/win/FontDatabase.h38
-rw-r--r--WebCore/platform/graphics/win/FontPlatformData.h147
-rw-r--r--WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp134
-rw-r--r--WebCore/platform/graphics/win/FontPlatformDataCairoWin.cpp89
-rw-r--r--WebCore/platform/graphics/win/FontPlatformDataWin.cpp92
-rw-r--r--WebCore/platform/graphics/win/FontWin.cpp101
-rw-r--r--WebCore/platform/graphics/win/GlyphPageTreeNodeCGWin.cpp59
-rw-r--r--WebCore/platform/graphics/win/GlyphPageTreeNodeCairoWin.cpp72
-rw-r--r--WebCore/platform/graphics/win/GraphicsContextCGWin.cpp366
-rw-r--r--WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp124
-rw-r--r--WebCore/platform/graphics/win/GraphicsContextWin.cpp126
-rw-r--r--WebCore/platform/graphics/win/IconWin.cpp84
-rw-r--r--WebCore/platform/graphics/win/ImageCGWin.cpp85
-rw-r--r--WebCore/platform/graphics/win/ImageCairoWin.cpp89
-rw-r--r--WebCore/platform/graphics/win/ImageWin.cpp58
-rw-r--r--WebCore/platform/graphics/win/IntPointWin.cpp56
-rw-r--r--WebCore/platform/graphics/win/IntRectWin.cpp43
-rw-r--r--WebCore/platform/graphics/win/IntSizeWin.cpp44
-rw-r--r--WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeWin.cpp483
-rw-r--r--WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeWin.h128
-rw-r--r--WebCore/platform/graphics/win/OpenTypeUtilities.cpp387
-rw-r--r--WebCore/platform/graphics/win/OpenTypeUtilities.h41
-rw-r--r--WebCore/platform/graphics/win/QTMovieWin.cpp875
-rw-r--r--WebCore/platform/graphics/win/QTMovieWin.h97
-rw-r--r--WebCore/platform/graphics/win/QTMovieWinTimer.cpp141
-rw-r--r--WebCore/platform/graphics/win/QTMovieWinTimer.h39
-rw-r--r--WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp141
-rw-r--r--WebCore/platform/graphics/win/SimpleFontDataCairoWin.cpp131
-rw-r--r--WebCore/platform/graphics/win/SimpleFontDataWin.cpp206
-rw-r--r--WebCore/platform/graphics/win/UniscribeController.cpp434
-rw-r--r--WebCore/platform/graphics/win/UniscribeController.h82
-rw-r--r--WebCore/platform/graphics/wx/AffineTransformWx.cpp251
-rw-r--r--WebCore/platform/graphics/wx/ColorWx.cpp44
-rw-r--r--WebCore/platform/graphics/wx/FloatRectWx.cpp47
-rwxr-xr-xWebCore/platform/graphics/wx/FontCacheWx.cpp72
-rw-r--r--WebCore/platform/graphics/wx/FontPlatformData.h111
-rwxr-xr-xWebCore/platform/graphics/wx/FontPlatformDataWx.cpp107
-rw-r--r--WebCore/platform/graphics/wx/FontWx.cpp78
-rwxr-xr-xWebCore/platform/graphics/wx/GlyphMapWx.cpp59
-rw-r--r--WebCore/platform/graphics/wx/GradientWx.cpp50
-rw-r--r--WebCore/platform/graphics/wx/GraphicsContextWx.cpp503
-rw-r--r--WebCore/platform/graphics/wx/ImageBufferData.h43
-rw-r--r--WebCore/platform/graphics/wx/ImageBufferWx.cpp79
-rw-r--r--WebCore/platform/graphics/wx/ImageSourceWx.cpp244
-rw-r--r--WebCore/platform/graphics/wx/ImageWx.cpp210
-rw-r--r--WebCore/platform/graphics/wx/IntPointWx.cpp45
-rw-r--r--WebCore/platform/graphics/wx/IntRectWx.cpp45
-rw-r--r--WebCore/platform/graphics/wx/PathWx.cpp180
-rw-r--r--WebCore/platform/graphics/wx/PenWx.cpp77
-rwxr-xr-xWebCore/platform/graphics/wx/SimpleFontDataWx.cpp96
-rw-r--r--WebCore/platform/gtk/ClipboardGtk.cpp127
-rw-r--r--WebCore/platform/gtk/ClipboardGtk.h69
-rw-r--r--WebCore/platform/gtk/ContextMenuGtk.cpp95
-rw-r--r--WebCore/platform/gtk/ContextMenuItemGtk.cpp253
-rw-r--r--WebCore/platform/gtk/CursorGtk.cpp341
-rw-r--r--WebCore/platform/gtk/CursorGtk.h221
-rw-r--r--WebCore/platform/gtk/DragDataGtk.cpp86
-rw-r--r--WebCore/platform/gtk/DragImageGtk.cpp54
-rw-r--r--WebCore/platform/gtk/EventLoopGtk.cpp32
-rw-r--r--WebCore/platform/gtk/FileChooserGtk.cpp70
-rw-r--r--WebCore/platform/gtk/FileSystemGtk.cpp267
-rw-r--r--WebCore/platform/gtk/KURLGtk.cpp40
-rw-r--r--WebCore/platform/gtk/KeyEventGtk.cpp550
-rw-r--r--WebCore/platform/gtk/KeyboardCodes.h543
-rw-r--r--WebCore/platform/gtk/Language.cpp60
-rw-r--r--WebCore/platform/gtk/LocalizedStringsGtk.cpp346
-rw-r--r--WebCore/platform/gtk/LoggingGtk.cpp32
-rw-r--r--WebCore/platform/gtk/MIMETypeRegistryGtk.cpp73
-rw-r--r--WebCore/platform/gtk/MouseEventGtk.cpp112
-rw-r--r--WebCore/platform/gtk/PasteboardGtk.cpp217
-rw-r--r--WebCore/platform/gtk/PasteboardHelper.h47
-rw-r--r--WebCore/platform/gtk/PlatformScreenGtk.cpp133
-rw-r--r--WebCore/platform/gtk/PopupMenuGtk.cpp160
-rw-r--r--WebCore/platform/gtk/RenderThemeGtk.cpp478
-rw-r--r--WebCore/platform/gtk/RenderThemeGtk.h128
-rw-r--r--WebCore/platform/gtk/ScrollViewGtk.cpp195
-rw-r--r--WebCore/platform/gtk/ScrollbarGtk.cpp150
-rw-r--r--WebCore/platform/gtk/ScrollbarGtk.h67
-rw-r--r--WebCore/platform/gtk/ScrollbarThemeGtk.cpp56
-rw-r--r--WebCore/platform/gtk/ScrollbarThemeGtk.h41
-rw-r--r--WebCore/platform/gtk/SearchPopupMenuGtk.cpp46
-rw-r--r--WebCore/platform/gtk/SharedBufferGtk.cpp53
-rw-r--r--WebCore/platform/gtk/SharedTimerGtk.cpp83
-rw-r--r--WebCore/platform/gtk/SoundGtk.cpp35
-rw-r--r--WebCore/platform/gtk/SystemTimeGtk.cpp32
-rw-r--r--WebCore/platform/gtk/SystemTimeLinux.cpp44
-rw-r--r--WebCore/platform/gtk/TemporaryLinkStubs.cpp68
-rw-r--r--WebCore/platform/gtk/WheelEventGtk.cpp79
-rw-r--r--WebCore/platform/gtk/WidgetGtk.cpp180
-rw-r--r--WebCore/platform/gtk/gtk2drawing.c3311
-rw-r--r--WebCore/platform/gtk/gtkdrawing.h428
-rw-r--r--WebCore/platform/gtk/guriescape.c219
-rw-r--r--WebCore/platform/gtk/guriescape.h44
-rw-r--r--WebCore/platform/image-decoders/ImageDecoder.h148
-rw-r--r--WebCore/platform/image-decoders/bmp/BMPImageDecoder.cpp46
-rw-r--r--WebCore/platform/image-decoders/bmp/BMPImageDecoder.h47
-rw-r--r--WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp416
-rw-r--r--WebCore/platform/image-decoders/gif/GIFImageDecoder.h88
-rw-r--r--WebCore/platform/image-decoders/gif/GIFImageReader.cpp943
-rw-r--r--WebCore/platform/image-decoders/gif/GIFImageReader.h214
-rw-r--r--WebCore/platform/image-decoders/ico/ICOImageDecoder.cpp46
-rw-r--r--WebCore/platform/image-decoders/ico/ICOImageDecoder.h47
-rw-r--r--WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp531
-rw-r--r--WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.h72
-rw-r--r--WebCore/platform/image-decoders/png/PNGImageDecoder.cpp403
-rw-r--r--WebCore/platform/image-decoders/png/PNGImageDecoder.h66
-rw-r--r--WebCore/platform/image-decoders/xbm/XBMImageDecoder.cpp46
-rw-r--r--WebCore/platform/image-decoders/xbm/XBMImageDecoder.h47
-rw-r--r--WebCore/platform/image-decoders/zlib/adler32.c149
-rw-r--r--WebCore/platform/image-decoders/zlib/compress.c79
-rw-r--r--WebCore/platform/image-decoders/zlib/crc32.c423
-rw-r--r--WebCore/platform/image-decoders/zlib/crc32.h441
-rw-r--r--WebCore/platform/image-decoders/zlib/deflate.c1736
-rw-r--r--WebCore/platform/image-decoders/zlib/deflate.h331
-rw-r--r--WebCore/platform/image-decoders/zlib/gzio.c1026
-rw-r--r--WebCore/platform/image-decoders/zlib/infback.c623
-rw-r--r--WebCore/platform/image-decoders/zlib/inffast.c318
-rw-r--r--WebCore/platform/image-decoders/zlib/inffast.h11
-rw-r--r--WebCore/platform/image-decoders/zlib/inffixed.h94
-rw-r--r--WebCore/platform/image-decoders/zlib/inflate.c1368
-rw-r--r--WebCore/platform/image-decoders/zlib/inflate.h115
-rw-r--r--WebCore/platform/image-decoders/zlib/inftrees.c329
-rw-r--r--WebCore/platform/image-decoders/zlib/inftrees.h55
-rw-r--r--WebCore/platform/image-decoders/zlib/mozzconf.h130
-rw-r--r--WebCore/platform/image-decoders/zlib/trees.c1219
-rw-r--r--WebCore/platform/image-decoders/zlib/trees.h128
-rw-r--r--WebCore/platform/image-decoders/zlib/uncompr.c61
-rw-r--r--WebCore/platform/image-decoders/zlib/zconf.h335
-rw-r--r--WebCore/platform/image-decoders/zlib/zlib.h1357
-rw-r--r--WebCore/platform/image-decoders/zlib/zutil.c318
-rw-r--r--WebCore/platform/image-decoders/zlib/zutil.h269
-rw-r--r--WebCore/platform/mac/AutodrainedPool.mm55
-rw-r--r--WebCore/platform/mac/BlockExceptions.h32
-rw-r--r--WebCore/platform/mac/BlockExceptions.mm38
-rw-r--r--WebCore/platform/mac/ClipboardMac.h88
-rw-r--r--WebCore/platform/mac/ClipboardMac.mm360
-rw-r--r--WebCore/platform/mac/ContextMenuItemMac.mm155
-rw-r--r--WebCore/platform/mac/ContextMenuMac.mm154
-rw-r--r--WebCore/platform/mac/CookieJar.mm94
-rw-r--r--WebCore/platform/mac/CursorMac.mm355
-rw-r--r--WebCore/platform/mac/DragDataMac.mm131
-rw-r--r--WebCore/platform/mac/DragImageMac.mm103
-rw-r--r--WebCore/platform/mac/EventLoopMac.mm39
-rw-r--r--WebCore/platform/mac/FileChooserMac.mm55
-rw-r--r--WebCore/platform/mac/FileSystemMac.mm40
-rw-r--r--WebCore/platform/mac/FoundationExtras.h72
-rw-r--r--WebCore/platform/mac/KURLMac.mm71
-rw-r--r--WebCore/platform/mac/KeyEventMac.mm876
-rw-r--r--WebCore/platform/mac/Language.mm43
-rw-r--r--WebCore/platform/mac/LocalCurrentGraphicsContext.h40
-rw-r--r--WebCore/platform/mac/LocalCurrentGraphicsContext.mm53
-rw-r--r--WebCore/platform/mac/LocalizedStringsMac.mm588
-rw-r--r--WebCore/platform/mac/LoggingMac.mm74
-rw-r--r--WebCore/platform/mac/MIMETypeRegistryMac.mm69
-rw-r--r--WebCore/platform/mac/PasteboardHelper.h60
-rw-r--r--WebCore/platform/mac/PasteboardMac.mm378
-rw-r--r--WebCore/platform/mac/PlatformMouseEventMac.mm177
-rw-r--r--WebCore/platform/mac/PlatformScreenMac.mm108
-rw-r--r--WebCore/platform/mac/PopupMenuMac.mm195
-rw-r--r--WebCore/platform/mac/SSLKeyGeneratorMac.mm49
-rw-r--r--WebCore/platform/mac/SchedulePairMac.mm43
-rw-r--r--WebCore/platform/mac/ScrollViewMac.mm215
-rw-r--r--WebCore/platform/mac/ScrollbarThemeMac.h70
-rw-r--r--WebCore/platform/mac/ScrollbarThemeMac.mm403
-rw-r--r--WebCore/platform/mac/SearchPopupMenuMac.mm74
-rw-r--r--WebCore/platform/mac/SharedBufferMac.mm128
-rw-r--r--WebCore/platform/mac/SharedTimerMac.mm117
-rw-r--r--WebCore/platform/mac/SoftLinking.h119
-rw-r--r--WebCore/platform/mac/SoundMac.mm33
-rw-r--r--WebCore/platform/mac/SystemTimeMac.cpp44
-rw-r--r--WebCore/platform/mac/ThemeMac.h56
-rw-r--r--WebCore/platform/mac/ThemeMac.mm544
-rw-r--r--WebCore/platform/mac/ThreadCheck.mm99
-rw-r--r--WebCore/platform/mac/WebCoreKeyGenerator.h32
-rw-r--r--WebCore/platform/mac/WebCoreKeyGenerator.m58
-rw-r--r--WebCore/platform/mac/WebCoreNSStringExtras.h41
-rw-r--r--WebCore/platform/mac/WebCoreNSStringExtras.mm62
-rw-r--r--WebCore/platform/mac/WebCoreObjCExtras.h43
-rw-r--r--WebCore/platform/mac/WebCoreObjCExtras.mm82
-rw-r--r--WebCore/platform/mac/WebCoreSystemInterface.h154
-rw-r--r--WebCore/platform/mac/WebCoreSystemInterface.mm99
-rw-r--r--WebCore/platform/mac/WebCoreTextRenderer.h40
-rw-r--r--WebCore/platform/mac/WebCoreTextRenderer.mm93
-rw-r--r--WebCore/platform/mac/WebCoreView.h28
-rw-r--r--WebCore/platform/mac/WebCoreView.m65
-rw-r--r--WebCore/platform/mac/WebFontCache.h34
-rw-r--r--WebCore/platform/mac/WebFontCache.mm301
-rw-r--r--WebCore/platform/mac/WheelEventMac.mm52
-rw-r--r--WebCore/platform/mac/WidgetMac.mm353
-rw-r--r--WebCore/platform/network/AuthenticationChallengeBase.cpp113
-rw-r--r--WebCore/platform/network/AuthenticationChallengeBase.h70
-rw-r--r--WebCore/platform/network/Credential.cpp80
-rw-r--r--WebCore/platform/network/Credential.h59
-rw-r--r--WebCore/platform/network/DNS.h36
-rw-r--r--WebCore/platform/network/FormData.cpp167
-rw-r--r--WebCore/platform/network/FormData.h109
-rw-r--r--WebCore/platform/network/HTTPHeaderMap.h38
-rw-r--r--WebCore/platform/network/HTTPParsers.cpp186
-rw-r--r--WebCore/platform/network/HTTPParsers.h42
-rw-r--r--WebCore/platform/network/NetworkStateNotifier.cpp47
-rw-r--r--WebCore/platform/network/NetworkStateNotifier.h103
-rw-r--r--WebCore/platform/network/ProtectionSpace.cpp119
-rw-r--r--WebCore/platform/network/ProtectionSpace.h79
-rw-r--r--WebCore/platform/network/ResourceErrorBase.cpp62
-rw-r--r--WebCore/platform/network/ResourceErrorBase.h88
-rw-r--r--WebCore/platform/network/ResourceHandle.cpp202
-rw-r--r--WebCore/platform/network/ResourceHandle.h194
-rw-r--r--WebCore/platform/network/ResourceHandleClient.h92
-rw-r--r--WebCore/platform/network/ResourceHandleInternal.h223
-rw-r--r--WebCore/platform/network/ResourceRequestBase.cpp272
-rw-r--r--WebCore/platform/network/ResourceRequestBase.h144
-rw-r--r--WebCore/platform/network/ResourceResponseBase.cpp236
-rw-r--r--WebCore/platform/network/ResourceResponseBase.h131
-rw-r--r--WebCore/platform/network/android/AuthenticationChallenge.h55
-rw-r--r--WebCore/platform/network/android/Cookie.cpp58
-rw-r--r--WebCore/platform/network/android/CookieClient.h47
-rw-r--r--WebCore/platform/network/android/NetworkStateNotifierAndroid.cpp42
-rw-r--r--WebCore/platform/network/android/ResourceError.h49
-rw-r--r--WebCore/platform/network/android/ResourceHandleAndroid.cpp157
-rw-r--r--WebCore/platform/network/android/ResourceRequest.h93
-rw-r--r--WebCore/platform/network/android/ResourceResponse.h60
-rw-r--r--WebCore/platform/network/cf/AuthenticationCF.cpp266
-rw-r--r--WebCore/platform/network/cf/AuthenticationCF.h49
-rw-r--r--WebCore/platform/network/cf/AuthenticationChallenge.h57
-rw-r--r--WebCore/platform/network/cf/DNSCFNet.cpp38
-rw-r--r--WebCore/platform/network/cf/FormDataStreamCFNet.cpp422
-rw-r--r--WebCore/platform/network/cf/FormDataStreamCFNet.h44
-rw-r--r--WebCore/platform/network/cf/ResourceError.h73
-rw-r--r--WebCore/platform/network/cf/ResourceErrorCF.cpp164
-rw-r--r--WebCore/platform/network/cf/ResourceHandleCFNet.cpp443
-rw-r--r--WebCore/platform/network/cf/ResourceRequest.h77
-rw-r--r--WebCore/platform/network/cf/ResourceRequestCFNet.cpp116
-rw-r--r--WebCore/platform/network/cf/ResourceRequestCFNet.h39
-rw-r--r--WebCore/platform/network/cf/ResourceResponse.h69
-rw-r--r--WebCore/platform/network/cf/ResourceResponseCFNet.cpp117
-rw-r--r--WebCore/platform/network/cf/ResourceResponseCFNet.h39
-rw-r--r--WebCore/platform/network/curl/AuthenticationChallenge.h54
-rw-r--r--WebCore/platform/network/curl/CookieJarCurl.cpp45
-rw-r--r--WebCore/platform/network/curl/DNSCurl.cpp38
-rw-r--r--WebCore/platform/network/curl/FormDataStreamCurl.cpp113
-rw-r--r--WebCore/platform/network/curl/FormDataStreamCurl.h63
-rw-r--r--WebCore/platform/network/curl/ResourceError.h48
-rw-r--r--WebCore/platform/network/curl/ResourceHandleCurl.cpp230
-rw-r--r--WebCore/platform/network/curl/ResourceHandleManager.cpp700
-rw-r--r--WebCore/platform/network/curl/ResourceHandleManager.h74
-rw-r--r--WebCore/platform/network/curl/ResourceRequest.h71
-rw-r--r--WebCore/platform/network/curl/ResourceResponse.h55
-rw-r--r--WebCore/platform/network/mac/AuthenticationChallenge.h59
-rw-r--r--WebCore/platform/network/mac/AuthenticationMac.h51
-rw-r--r--WebCore/platform/network/mac/AuthenticationMac.mm245
-rw-r--r--WebCore/platform/network/mac/FormDataStreamMac.h49
-rw-r--r--WebCore/platform/network/mac/FormDataStreamMac.mm390
-rw-r--r--WebCore/platform/network/mac/NetworkStateNotifierMac.cpp132
-rw-r--r--WebCore/platform/network/mac/ResourceError.h74
-rw-r--r--WebCore/platform/network/mac/ResourceErrorMac.mm85
-rw-r--r--WebCore/platform/network/mac/ResourceHandleMac.mm779
-rw-r--r--WebCore/platform/network/mac/ResourceRequest.h82
-rw-r--r--WebCore/platform/network/mac/ResourceRequestMac.mm110
-rw-r--r--WebCore/platform/network/mac/ResourceResponse.h74
-rw-r--r--WebCore/platform/network/mac/ResourceResponseMac.mm115
-rw-r--r--WebCore/platform/network/mac/WebCoreURLResponse.h34
-rw-r--r--WebCore/platform/network/mac/WebCoreURLResponse.mm221
-rw-r--r--WebCore/platform/network/qt/AuthenticationChallenge.h46
-rw-r--r--WebCore/platform/network/qt/QNetworkReplyHandler.cpp435
-rw-r--r--WebCore/platform/network/qt/QNetworkReplyHandler.h118
-rw-r--r--WebCore/platform/network/qt/ResourceError.h48
-rw-r--r--WebCore/platform/network/qt/ResourceHandleQt.cpp208
-rw-r--r--WebCore/platform/network/qt/ResourceRequest.h74
-rw-r--r--WebCore/platform/network/qt/ResourceRequestQt.cpp49
-rw-r--r--WebCore/platform/network/qt/ResourceResponse.h47
-rw-r--r--WebCore/platform/network/soup/AuthenticationChallenge.h46
-rw-r--r--WebCore/platform/network/soup/CookieJarSoup.cpp74
-rw-r--r--WebCore/platform/network/soup/DNSSoup.cpp38
-rw-r--r--WebCore/platform/network/soup/ResourceError.h48
-rw-r--r--WebCore/platform/network/soup/ResourceHandleSoup.cpp591
-rw-r--r--WebCore/platform/network/soup/ResourceRequest.h66
-rw-r--r--WebCore/platform/network/soup/ResourceResponse.h55
-rw-r--r--WebCore/platform/network/win/CookieJarCFNetWin.cpp106
-rw-r--r--WebCore/platform/network/win/CookieJarWin.cpp67
-rw-r--r--WebCore/platform/network/win/CookieStorageWin.cpp50
-rw-r--r--WebCore/platform/network/win/CookieStorageWin.h39
-rw-r--r--WebCore/platform/network/win/NetworkStateNotifierWin.cpp114
-rw-r--r--WebCore/platform/network/win/ResourceHandleWin.cpp457
-rw-r--r--WebCore/platform/network/win/ResourceHandleWin.h46
-rw-r--r--WebCore/platform/posix/FileSystemPOSIX.cpp193
-rw-r--r--WebCore/platform/qt/ClipboardQt.cpp305
-rw-r--r--WebCore/platform/qt/ClipboardQt.h87
-rw-r--r--WebCore/platform/qt/ContextMenuItemQt.cpp117
-rw-r--r--WebCore/platform/qt/ContextMenuQt.cpp82
-rw-r--r--WebCore/platform/qt/CookieJarQt.cpp119
-rw-r--r--WebCore/platform/qt/CursorQt.cpp372
-rw-r--r--WebCore/platform/qt/DragDataQt.cpp142
-rw-r--r--WebCore/platform/qt/DragImageQt.cpp63
-rw-r--r--WebCore/platform/qt/EventLoopQt.cpp32
-rw-r--r--WebCore/platform/qt/FileChooserQt.cpp37
-rw-r--r--WebCore/platform/qt/FileSystemQt.cpp175
-rw-r--r--WebCore/platform/qt/KURLQt.cpp102
-rw-r--r--WebCore/platform/qt/KeyboardCodes.h553
-rw-r--r--WebCore/platform/qt/Localizations.cpp352
-rw-r--r--WebCore/platform/qt/LoggingQt.cpp90
-rw-r--r--WebCore/platform/qt/MIMETypeRegistryQt.cpp82
-rw-r--r--WebCore/platform/qt/MenuEventProxy.h54
-rw-r--r--WebCore/platform/qt/PasteboardQt.cpp172
-rw-r--r--WebCore/platform/qt/PlatformKeyboardEventQt.cpp478
-rw-r--r--WebCore/platform/qt/PlatformMouseEventQt.cpp94
-rw-r--r--WebCore/platform/qt/PlatformScreenQt.cpp77
-rw-r--r--WebCore/platform/qt/PopupMenuQt.cpp122
-rw-r--r--WebCore/platform/qt/QWebPopup.cpp73
-rw-r--r--WebCore/platform/qt/QWebPopup.h49
-rw-r--r--WebCore/platform/qt/RenderThemeQt.cpp947
-rw-r--r--WebCore/platform/qt/RenderThemeQt.h174
-rw-r--r--WebCore/platform/qt/ScreenQt.cpp99
-rw-r--r--WebCore/platform/qt/ScrollViewQt.cpp62
-rw-r--r--WebCore/platform/qt/ScrollbarQt.cpp95
-rw-r--r--WebCore/platform/qt/ScrollbarThemeQt.cpp244
-rw-r--r--WebCore/platform/qt/ScrollbarThemeQt.h55
-rw-r--r--WebCore/platform/qt/SearchPopupMenuQt.cpp45
-rw-r--r--WebCore/platform/qt/SharedBufferQt.cpp52
-rw-r--r--WebCore/platform/qt/SharedTimerQt.cpp58
-rw-r--r--WebCore/platform/qt/SharedTimerQt.h91
-rw-r--r--WebCore/platform/qt/SoundQt.cpp43
-rw-r--r--WebCore/platform/qt/SystemTimeQt.cpp46
-rw-r--r--WebCore/platform/qt/TemporaryLinkStubs.cpp117
-rw-r--r--WebCore/platform/qt/WebCoreResources.qrc5
-rw-r--r--WebCore/platform/qt/WheelEventQt.cpp59
-rw-r--r--WebCore/platform/qt/WidgetQt.cpp112
-rw-r--r--WebCore/platform/qt/html4-adjustments-qt.css96
-rw-r--r--WebCore/platform/sql/SQLValue.cpp56
-rw-r--r--WebCore/platform/sql/SQLValue.h58
-rw-r--r--WebCore/platform/sql/SQLiteAuthorizer.cpp39
-rw-r--r--WebCore/platform/sql/SQLiteDatabase.cpp353
-rw-r--r--WebCore/platform/sql/SQLiteDatabase.h130
-rw-r--r--WebCore/platform/sql/SQLiteStatement.cpp453
-rw-r--r--WebCore/platform/sql/SQLiteStatement.h102
-rw-r--r--WebCore/platform/sql/SQLiteTransaction.cpp80
-rw-r--r--WebCore/platform/sql/SQLiteTransaction.h56
-rw-r--r--WebCore/platform/symbian/FloatPointSymbian.cpp53
-rw-r--r--WebCore/platform/symbian/FloatRectSymbian.cpp60
-rw-r--r--WebCore/platform/symbian/IntPointSymbian.cpp53
-rw-r--r--WebCore/platform/symbian/IntRectSymbian.cpp58
-rw-r--r--WebCore/platform/symbian/IntSizeSymbian.cpp53
-rw-r--r--WebCore/platform/text/AtomicString.cpp326
-rw-r--r--WebCore/platform/text/AtomicString.h159
-rw-r--r--WebCore/platform/text/AtomicStringHash.h64
-rw-r--r--WebCore/platform/text/AtomicStringImpl.h36
-rw-r--r--WebCore/platform/text/Base64.cpp184
-rw-r--r--WebCore/platform/text/Base64.h41
-rw-r--r--WebCore/platform/text/BidiContext.cpp38
-rw-r--r--WebCore/platform/text/BidiContext.h69
-rw-r--r--WebCore/platform/text/BidiResolver.h937
-rw-r--r--WebCore/platform/text/CString.cpp115
-rw-r--r--WebCore/platform/text/CString.h80
-rw-r--r--WebCore/platform/text/CharacterNames.h61
-rw-r--r--WebCore/platform/text/ParserUtilities.h54
-rw-r--r--WebCore/platform/text/PlatformString.h357
-rw-r--r--WebCore/platform/text/RegularExpression.cpp214
-rw-r--r--WebCore/platform/text/RegularExpression.h63
-rw-r--r--WebCore/platform/text/SegmentedString.cpp202
-rw-r--r--WebCore/platform/text/SegmentedString.h176
-rw-r--r--WebCore/platform/text/String.cpp831
-rw-r--r--WebCore/platform/text/StringBuffer.h77
-rw-r--r--WebCore/platform/text/StringBuilder.cpp97
-rw-r--r--WebCore/platform/text/StringBuilder.h57
-rw-r--r--WebCore/platform/text/StringHash.h242
-rw-r--r--WebCore/platform/text/StringImpl.cpp942
-rw-r--r--WebCore/platform/text/StringImpl.h278
-rw-r--r--WebCore/platform/text/TextBoundaries.h38
-rw-r--r--WebCore/platform/text/TextBoundariesICU.cpp76
-rw-r--r--WebCore/platform/text/TextBreakIterator.h48
-rw-r--r--WebCore/platform/text/TextBreakIteratorICU.cpp117
-rw-r--r--WebCore/platform/text/TextBreakIteratorInternalICU.h32
-rw-r--r--WebCore/platform/text/TextCodec.cpp58
-rw-r--r--WebCore/platform/text/TextCodec.h84
-rw-r--r--WebCore/platform/text/TextCodecICU.cpp467
-rw-r--r--WebCore/platform/text/TextCodecICU.h69
-rw-r--r--WebCore/platform/text/TextCodecLatin1.cpp199
-rw-r--r--WebCore/platform/text/TextCodecLatin1.h44
-rw-r--r--WebCore/platform/text/TextCodecUTF16.cpp139
-rw-r--r--WebCore/platform/text/TextCodecUTF16.h51
-rw-r--r--WebCore/platform/text/TextCodecUserDefined.cpp111
-rw-r--r--WebCore/platform/text/TextCodecUserDefined.h44
-rw-r--r--WebCore/platform/text/TextDecoder.cpp129
-rw-r--r--WebCore/platform/text/TextDecoder.h64
-rw-r--r--WebCore/platform/text/TextDirection.h35
-rw-r--r--WebCore/platform/text/TextEncoding.cpp213
-rw-r--r--WebCore/platform/text/TextEncoding.h76
-rw-r--r--WebCore/platform/text/TextEncodingRegistry.cpp244
-rw-r--r--WebCore/platform/text/TextEncodingRegistry.h53
-rw-r--r--WebCore/platform/text/TextStream.cpp114
-rw-r--r--WebCore/platform/text/TextStream.h59
-rw-r--r--WebCore/platform/text/UnicodeRange.cpp462
-rw-r--r--WebCore/platform/text/UnicodeRange.h120
-rw-r--r--WebCore/platform/text/cf/StringCF.cpp55
-rw-r--r--WebCore/platform/text/cf/StringImplCF.cpp37
-rw-r--r--WebCore/platform/text/gtk/TextBreakIteratorInternalICUGtk.cpp30
-rw-r--r--WebCore/platform/text/mac/CharsetData.h37
-rw-r--r--WebCore/platform/text/mac/ShapeArabic.c555
-rw-r--r--WebCore/platform/text/mac/ShapeArabic.h44
-rw-r--r--WebCore/platform/text/mac/StringImplMac.mm31
-rw-r--r--WebCore/platform/text/mac/StringMac.mm41
-rw-r--r--WebCore/platform/text/mac/TextBoundaries.mm54
-rw-r--r--WebCore/platform/text/mac/TextBreakIteratorInternalICUMac.mm72
-rw-r--r--WebCore/platform/text/mac/TextCodecMac.cpp321
-rw-r--r--WebCore/platform/text/mac/TextCodecMac.h65
-rw-r--r--WebCore/platform/text/mac/character-sets.txt1868
-rw-r--r--WebCore/platform/text/mac/mac-encodings.txt45
-rwxr-xr-xWebCore/platform/text/mac/make-charset-table.pl225
-rw-r--r--WebCore/platform/text/qt/StringQt.cpp56
-rw-r--r--WebCore/platform/text/qt/TextBoundaries.cpp125
-rw-r--r--WebCore/platform/text/qt/TextBreakIteratorQt.cpp297
-rw-r--r--WebCore/platform/text/qt/TextCodecQt.cpp121
-rw-r--r--WebCore/platform/text/qt/TextCodecQt.h54
-rw-r--r--WebCore/platform/text/symbian/StringImplSymbian.cpp53
-rw-r--r--WebCore/platform/text/symbian/StringSymbian.cpp50
-rw-r--r--WebCore/platform/text/win/TextBreakIteratorInternalICUWin.cpp31
-rw-r--r--WebCore/platform/text/wx/StringWx.cpp92
-rw-r--r--WebCore/platform/win/BString.cpp201
-rw-r--r--WebCore/platform/win/BString.h82
-rw-r--r--WebCore/platform/win/COMPtr.h217
-rw-r--r--WebCore/platform/win/ClipboardUtilitiesWin.cpp452
-rw-r--r--WebCore/platform/win/ClipboardUtilitiesWin.h70
-rw-r--r--WebCore/platform/win/ClipboardWin.cpp767
-rw-r--r--WebCore/platform/win/ClipboardWin.h88
-rw-r--r--WebCore/platform/win/ContextMenuItemWin.cpp193
-rw-r--r--WebCore/platform/win/ContextMenuWin.cpp157
-rw-r--r--WebCore/platform/win/CursorWin.cpp415
-rw-r--r--WebCore/platform/win/DragDataWin.cpp151
-rw-r--r--WebCore/platform/win/DragImageCGWin.cpp166
-rw-r--r--WebCore/platform/win/DragImageCairoWin.cpp53
-rw-r--r--WebCore/platform/win/DragImageWin.cpp65
-rw-r--r--WebCore/platform/win/EditorWin.cpp51
-rw-r--r--WebCore/platform/win/EventLoopWin.cpp43
-rw-r--r--WebCore/platform/win/FileChooserWin.cpp55
-rw-r--r--WebCore/platform/win/FileSystemWin.cpp307
-rw-r--r--WebCore/platform/win/GDIObjectCounter.cpp74
-rw-r--r--WebCore/platform/win/GDIObjectCounter.h63
-rw-r--r--WebCore/platform/win/KeyEventWin.cpp217
-rw-r--r--WebCore/platform/win/Language.cpp68
-rw-r--r--WebCore/platform/win/MIMETypeRegistryWin.cpp122
-rw-r--r--WebCore/platform/win/PasteboardWin.cpp327
-rw-r--r--WebCore/platform/win/PlatformMouseEventWin.cpp122
-rw-r--r--WebCore/platform/win/PlatformScreenWin.cpp93
-rw-r--r--WebCore/platform/win/PlatformScrollBar.h50
-rw-r--r--WebCore/platform/win/PlatformScrollBarWin.cpp43
-rw-r--r--WebCore/platform/win/PopupMenuWin.cpp834
-rw-r--r--WebCore/platform/win/ScrollbarThemeSafari.cpp257
-rw-r--r--WebCore/platform/win/ScrollbarThemeSafari.h63
-rw-r--r--WebCore/platform/win/ScrollbarThemeWin.cpp363
-rw-r--r--WebCore/platform/win/ScrollbarThemeWin.h61
-rw-r--r--WebCore/platform/win/SearchPopupMenuWin.cpp83
-rw-r--r--WebCore/platform/win/SharedBufferWin.cpp68
-rw-r--r--WebCore/platform/win/SharedTimerWin.cpp225
-rw-r--r--WebCore/platform/win/SoftLinking.h62
-rw-r--r--WebCore/platform/win/SoundWin.cpp36
-rw-r--r--WebCore/platform/win/SystemTimeWin.cpp56
-rw-r--r--WebCore/platform/win/TemporaryLinkStubs.cpp37
-rw-r--r--WebCore/platform/win/WCDataObject.cpp381
-rw-r--r--WebCore/platform/win/WCDataObject.h70
-rw-r--r--WebCore/platform/win/WebCoreTextRenderer.cpp128
-rw-r--r--WebCore/platform/win/WebCoreTextRenderer.h44
-rw-r--r--WebCore/platform/win/WheelEventWin.cpp94
-rw-r--r--WebCore/platform/win/WidgetWin.cpp99
-rw-r--r--WebCore/platform/win/WindowMessageBroadcaster.cpp130
-rw-r--r--WebCore/platform/win/WindowMessageBroadcaster.h69
-rw-r--r--WebCore/platform/win/WindowMessageListener.h46
-rw-r--r--WebCore/platform/wx/ClipboardWx.cpp128
-rw-r--r--WebCore/platform/wx/ClipboardWx.h69
-rw-r--r--WebCore/platform/wx/CursorWx.cpp301
-rw-r--r--WebCore/platform/wx/DragDataWx.cpp96
-rw-r--r--WebCore/platform/wx/DragImageWx.cpp63
-rw-r--r--WebCore/platform/wx/EventLoopWx.cpp44
-rw-r--r--WebCore/platform/wx/FileSystemWx.cpp131
-rw-r--r--WebCore/platform/wx/KeyEventWin.cpp157
-rw-r--r--WebCore/platform/wx/KeyboardCodes.h544
-rw-r--r--WebCore/platform/wx/KeyboardEventWx.cpp372
-rw-r--r--WebCore/platform/wx/LocalizedStringsWx.cpp321
-rw-r--r--WebCore/platform/wx/LoggingWx.cpp36
-rw-r--r--WebCore/platform/wx/MimeTypeRegistryWx.cpp72
-rw-r--r--WebCore/platform/wx/MouseEventWx.cpp75
-rw-r--r--WebCore/platform/wx/MouseWheelEventWx.cpp50
-rw-r--r--WebCore/platform/wx/PasteboardWx.cpp98
-rw-r--r--WebCore/platform/wx/PopupMenuWx.cpp113
-rw-r--r--WebCore/platform/wx/RenderThemeWx.cpp382
-rw-r--r--WebCore/platform/wx/ScreenWx.cpp98
-rw-r--r--WebCore/platform/wx/ScrollViewWx.cpp352
-rw-r--r--WebCore/platform/wx/SharedTimerWx.cpp114
-rw-r--r--WebCore/platform/wx/SoundWx.cpp44
-rw-r--r--WebCore/platform/wx/SystemTimeWx.cpp39
-rwxr-xr-xWebCore/platform/wx/TemporaryLinkStubs.cpp186
-rwxr-xr-xWebCore/platform/wx/WidgetWx.cpp94
-rw-r--r--WebCore/platform/wx/wxcode/fontprops.cpp35
-rw-r--r--WebCore/platform/wx/wxcode/fontprops.h49
-rw-r--r--WebCore/platform/wx/wxcode/gtk/fontprops.cpp126
-rw-r--r--WebCore/platform/wx/wxcode/gtk/non-kerned-drawing.cpp67
-rw-r--r--WebCore/platform/wx/wxcode/mac/carbon/fontprops.cpp174
-rw-r--r--WebCore/platform/wx/wxcode/mac/carbon/non-kerned-drawing.cpp66
-rw-r--r--WebCore/platform/wx/wxcode/non-kerned-drawing.h36
-rw-r--r--WebCore/platform/wx/wxcode/win/fontprops.cpp135
-rw-r--r--WebCore/platform/wx/wxcode/win/non-kerned-drawing.cpp125
826 files changed, 0 insertions, 138595 deletions
diff --git a/WebCore/platform/Arena.cpp b/WebCore/platform/Arena.cpp
deleted file mode 100644
index 90f850f..0000000
--- a/WebCore/platform/Arena.cpp
+++ /dev/null
@@ -1,282 +0,0 @@
-/*
- * Copyright (C) 1998-2000 Netscape Communications Corporation.
- * Copyright (C) 2003-6 Apple Computer
- *
- * Other contributors:
- * Nick Blievers <nickb@adacel.com.au>
- * Jeff Hostetler <jeff@nerdone.com>
- * Tom Rini <trini@kernel.crashing.org>
- * Raffaele Sena <raff@netwinder.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Alternatively, the contents of this file may be used under the terms
- * of either the Mozilla Public License Version 1.1, found at
- * http://www.mozilla.org/MPL/ (the "MPL") or the GNU General Public
- * License Version 2.0, found at http://www.fsf.org/copyleft/gpl.html
- * (the "GPL"), in which case the provisions of the MPL or the GPL are
- * applicable instead of those above. If you wish to allow use of your
- * version of this file only under the terms of one of those two
- * licenses (the MPL or the GPL) and not to allow others to use your
- * version of this file under the LGPL, indicate your decision by
- * deletingthe provisions above and replace them with the notice and
- * other provisions required by the MPL or the GPL, as the case may be.
- * If you do not delete the provisions above, a recipient may use your
- * version of this file under any of the LGPL, the MPL or the GPL.
- */
-
-/*
- * Lifetime-based fast allocation, inspired by much prior art, including
- * "Fast Allocation and Deallocation of Memory Based on Object Lifetimes"
- * David R. Hanson, Software -- Practice and Experience, Vol. 20(1).
- */
-
-#include "config.h"
-#include "Arena.h"
-
-#include <algorithm>
-#include <stdlib.h>
-#include <string.h>
-#include <wtf/Assertions.h>
-#include <wtf/FastMalloc.h>
-
-using namespace std;
-
-namespace WebCore {
-
-//#define DEBUG_ARENA_MALLOC
-#ifdef DEBUG_ARENA_MALLOC
-static int i = 0;
-#endif
-
-#define FREELIST_MAX 30
-static Arena *arena_freelist;
-static int freelist_count = 0;
-
-#define ARENA_DEFAULT_ALIGN sizeof(double)
-#define BIT(n) ((unsigned int)1 << (n))
-#define BITMASK(n) (BIT(n) - 1)
-#define CEILING_LOG2(_log2,_n) \
- unsigned int j_ = (unsigned int)(_n); \
- (_log2) = 0; \
- if ((j_) & ((j_)-1)) \
- (_log2) += 1; \
- if ((j_) >> 16) \
- (_log2) += 16, (j_) >>= 16; \
- if ((j_) >> 8) \
- (_log2) += 8, (j_) >>= 8; \
- if ((j_) >> 4) \
- (_log2) += 4, (j_) >>= 4; \
- if ((j_) >> 2) \
- (_log2) += 2, (j_) >>= 2; \
- if ((j_) >> 1) \
- (_log2) += 1;
-
-static int CeilingLog2(unsigned int i) {
- int log2;
- CEILING_LOG2(log2,i);
- return log2;
-}
-
-void InitArenaPool(ArenaPool *pool, const char *name,
- unsigned int size, unsigned int align)
-{
- if (align == 0)
- align = ARENA_DEFAULT_ALIGN;
- pool->mask = BITMASK(CeilingLog2(align));
- pool->first.next = NULL;
- pool->first.base = pool->first.avail = pool->first.limit =
- (uword)ARENA_ALIGN(pool, &pool->first + 1);
- pool->current = &pool->first;
- pool->arenasize = size;
-}
-
-
-/*
- ** ArenaAllocate() -- allocate space from an arena pool
- **
- ** Description: ArenaAllocate() allocates space from an arena
- ** pool.
- **
- ** First try to satisfy the request from arenas starting at
- ** pool->current.
- **
- ** If there is not enough space in the arena pool->current, try
- ** to claim an arena, on a first fit basis, from the global
- ** freelist (arena_freelist).
- **
- ** If no arena in arena_freelist is suitable, then try to
- ** allocate a new arena from the heap.
- **
- ** Returns: pointer to allocated space or NULL
- **
- */
-void* ArenaAllocate(ArenaPool *pool, unsigned int nb)
-{
- Arena *a;
- char *rp; /* returned pointer */
-
- ASSERT((nb & pool->mask) == 0);
-
- nb = (uword)ARENA_ALIGN(pool, nb); /* force alignment */
-
- /* attempt to allocate from arenas at pool->current */
- {
- a = pool->current;
- do {
- if ( a->avail +nb <= a->limit ) {
- pool->current = a;
- rp = (char *)a->avail;
- a->avail += nb;
- return rp;
- }
- } while( NULL != (a = a->next) );
- }
-
- /* attempt to allocate from arena_freelist */
- {
- Arena *p = NULL; /* previous pointer, for unlinking from freelist */
-
- for ( a = arena_freelist; a != NULL ; p = a, a = a->next ) {
- if ( a->base +nb <= a->limit ) {
- if ( p == NULL )
- arena_freelist = a->next;
- else
- p->next = a->next;
- a->avail = a->base;
- rp = (char *)a->avail;
- a->avail += nb;
- /* the newly allocated arena is linked after pool->current
- * and becomes pool->current */
- a->next = pool->current->next;
- pool->current->next = a;
- pool->current = a;
- if ( 0 == pool->first.next )
- pool->first.next = a;
- freelist_count--;
- return(rp);
- }
- }
- }
-
- /* attempt to allocate from the heap */
- {
- unsigned int sz = max(pool->arenasize, nb);
- sz += sizeof *a + pool->mask; /* header and alignment slop */
-#ifdef DEBUG_ARENA_MALLOC
- i++;
- printf("Malloc: %d\n", i);
-#endif
- a = (Arena*)fastMalloc(sz);
- // fastMalloc will abort() if it fails, so we are guaranteed that a is not 0.
- a->limit = (uword)a + sz;
- a->base = a->avail = (uword)ARENA_ALIGN(pool, a + 1);
- rp = (char *)a->avail;
- a->avail += nb;
- /* the newly allocated arena is linked after pool->current
- * and becomes pool->current */
- a->next = pool->current->next;
- pool->current->next = a;
- pool->current = a;
- if ( !pool->first.next )
- pool->first.next = a;
- return(rp);
- }
-} /* --- end ArenaAllocate() --- */
-
-void* ArenaGrow(ArenaPool *pool, void *p, unsigned int size, unsigned int incr)
-{
- void *newp;
-
- ARENA_ALLOCATE(newp, pool, size + incr);
- if (newp)
- memcpy(newp, p, size);
- return newp;
-}
-
-/*
- * Free tail arenas linked after head, which may not be the true list head.
- * Reset pool->current to point to head in case it pointed at a tail arena.
- */
-static void FreeArenaList(ArenaPool *pool, Arena *head, bool reallyFree)
-{
- Arena **ap, *a;
-
- ap = &head->next;
- a = *ap;
- if (!a)
- return;
-
-#ifdef DEBUG
- do {
- ASSERT(a->base <= a->avail && a->avail <= a->limit);
- a->avail = a->base;
- CLEAR_UNUSED(a);
- } while ((a = a->next) != 0);
- a = *ap;
-#endif
-
- if (freelist_count >= FREELIST_MAX)
- reallyFree = true;
-
- if (reallyFree) {
- do {
- *ap = a->next;
- CLEAR_ARENA(a);
-#ifdef DEBUG_ARENA_MALLOC
- if (a) {
- i--;
- printf("Free: %d\n", i);
- }
-#endif
- fastFree(a); a = 0;
- } while ((a = *ap) != 0);
- } else {
- /* Insert the whole arena chain at the front of the freelist. */
- do {
- ap = &(*ap)->next;
- freelist_count++;
- } while (*ap);
- *ap = arena_freelist;
- arena_freelist = a;
- head->next = 0;
- }
- pool->current = head;
-}
-
-void ArenaRelease(ArenaPool *pool, char *mark)
-{
- Arena *a;
-
- for (a = pool->first.next; a; a = a->next) {
- if (UPTRDIFF(mark, a->base) < UPTRDIFF(a->avail, a->base)) {
- a->avail = (uword)ARENA_ALIGN(pool, mark);
- FreeArenaList(pool, a, false);
- return;
- }
- }
-}
-
-void FreeArenaPool(ArenaPool *pool)
-{
- FreeArenaList(pool, &pool->first, false);
-}
-
-void FinishArenaPool(ArenaPool *pool)
-{
- FreeArenaList(pool, &pool->first, true);
-}
-
-}
diff --git a/WebCore/platform/Arena.h b/WebCore/platform/Arena.h
deleted file mode 100644
index b6f6931..0000000
--- a/WebCore/platform/Arena.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (C) 1998-2000 Netscape Communications Corporation.
- * Copyright (C) 2003-6 Apple Computer
- *
- * Other contributors:
- * Nick Blievers <nickb@adacel.com.au>
- * Jeff Hostetler <jeff@nerdone.com>
- * Tom Rini <trini@kernel.crashing.org>
- * Raffaele Sena <raff@netwinder.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Alternatively, the contents of this file may be used under the terms
- * of either the Mozilla Public License Version 1.1, found at
- * http://www.mozilla.org/MPL/ (the "MPL") or the GNU General Public
- * License Version 2.0, found at http://www.fsf.org/copyleft/gpl.html
- * (the "GPL"), in which case the provisions of the MPL or the GPL are
- * applicable instead of those above. If you wish to allow use of your
- * version of this file only under the terms of one of those two
- * licenses (the MPL or the GPL) and not to allow others to use your
- * version of this file under the LGPL, indicate your decision by
- * deletingthe provisions above and replace them with the notice and
- * other provisions required by the MPL or the GPL, as the case may be.
- * If you do not delete the provisions above, a recipient may use your
- * version of this file under any of the LGPL, the MPL or the GPL.
- */
-
-#ifndef Arena_h
-#define Arena_h
-
-#define ARENA_ALIGN_MASK 3
-
-namespace WebCore {
-
-typedef unsigned long uword;
-
-struct Arena {
- Arena* next; // next arena
- uword base; // aligned base address
- uword limit; // end of arena (1+last byte)
- uword avail; // points to next available byte in arena
-};
-
-struct ArenaPool {
- Arena first; // first arena in pool list.
- Arena* current; // current arena.
- unsigned int arenasize;
- uword mask; // Mask (power-of-2 - 1)
-};
-
-void InitArenaPool(ArenaPool *pool, const char *name,
- unsigned int size, unsigned int align);
-void FinishArenaPool(ArenaPool *pool);
-void FreeArenaPool(ArenaPool *pool);
-void* ArenaAllocate(ArenaPool *pool, unsigned int nb);
-
-#define ARENA_ALIGN(pool, n) (((uword)(n) + ARENA_ALIGN_MASK) & ~ARENA_ALIGN_MASK)
-#define INIT_ARENA_POOL(pool, name, size) \
- InitArenaPool(pool, name, size, ARENA_ALIGN_MASK + 1)
-
-#define ARENA_ALLOCATE(p, pool, nb) \
- Arena *_a = (pool)->current; \
- unsigned int _nb = ARENA_ALIGN(pool, nb); \
- uword _p = _a->avail; \
- uword _q = _p + _nb; \
- if (_q > _a->limit) \
- _p = (uword)ArenaAllocate(pool, _nb); \
- else \
- _a->avail = _q; \
- p = (void *)_p;
-
-#define ARENA_GROW(p, pool, size, incr) \
- Arena *_a = (pool)->current; \
- unsigned int _incr = ARENA_ALIGN(pool, incr); \
- uword _p = _a->avail; \
- uword _q = _p + _incr; \
- if (_p == (uword)(p) + ARENA_ALIGN(pool, size) && \
- _q <= _a->limit) { \
- _a->avail = _q; \
- } else { \
- p = ArenaGrow(pool, p, size, incr); \
- }
-
-#define ARENA_MARK(pool) ((void *) (pool)->current->avail)
-#define UPTRDIFF(p,q) ((uword)(p) - (uword)(q))
-
-#ifdef DEBUG
-#define FREE_PATTERN 0xDA
-#define CLEAR_UNUSED(a) ASSERT((a)->avail <= (a)->limit); \
- memset((void*)(a)->avail, FREE_PATTERN, \
- (a)->limit - (a)->avail)
-#define CLEAR_ARENA(a) memset((void*)(a), FREE_PATTERN, \
- (a)->limit - (uword)(a))
-#else
-#define CLEAR_UNUSED(a)
-#define CLEAR_ARENA(a)
-#endif
-
-#define ARENA_RELEASE(pool, mark) \
- char *_m = (char *)(mark); \
- Arena *_a = (pool)->current; \
- if (UPTRDIFF(_m, _a->base) <= UPTRDIFF(_a->avail, _a->base)) { \
- _a->avail = (uword)ARENA_ALIGN(pool, _m); \
- CLEAR_UNUSED(_a); \
- } else { \
- ArenaRelease(pool, _m); \
- }
-
-#define ARENA_DESTROY(pool, a, pnext) \
- if ((pool)->current == (a)) (pool)->current = &(pool)->first; \
- *(pnext) = (a)->next; \
- CLEAR_ARENA(a); \
- fastFree(a); \
- (a) = 0;
-
-}
-
-#endif
diff --git a/WebCore/platform/AutodrainedPool.h b/WebCore/platform/AutodrainedPool.h
deleted file mode 100644
index 1cbbec6..0000000
--- a/WebCore/platform/AutodrainedPool.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef AutodrainedPool_h
-#define AutodrainedPool_h
-
-#include <wtf/Noncopyable.h>
-
-#ifdef __OBJC__
-@class NSAutoreleasePool;
-#else
-class NSAutoreleasePool;
-#endif
-
-namespace WebCore {
-
-class AutodrainedPool : Noncopyable {
-public:
- AutodrainedPool(int iterationLimit = 1);
- ~AutodrainedPool();
-
- void cycle();
-
-private:
-#if PLATFORM(MAC)
- int m_iterationLimit;
- int m_iterationCount;
- NSAutoreleasePool* m_pool;
-#endif
-};
-
-#if !PLATFORM(MAC)
-inline AutodrainedPool::AutodrainedPool(int) { }
-inline AutodrainedPool::~AutodrainedPool() { }
-inline void AutodrainedPool::cycle() { }
-#endif
-
-} // namespace WebCore
-
-#endif
-
-
diff --git a/WebCore/platform/ColorData.gperf b/WebCore/platform/ColorData.gperf
deleted file mode 100644
index 8a54916..0000000
--- a/WebCore/platform/ColorData.gperf
+++ /dev/null
@@ -1,151 +0,0 @@
-struct NamedColor { const char *name; int RGBValue; };
-%%
-aliceblue, 0xf0f8ff
-antiquewhite, 0xfaebd7
-aqua, 0x00ffff
-aquamarine, 0x7fffd4
-azure, 0xf0ffff
-beige, 0xf5f5dc
-bisque, 0xffe4c4
-black, 0x000000
-blanchedalmond, 0xffebcd
-blue, 0x0000ff
-blueviolet, 0x8a2be2
-brown, 0xa52a2a
-burlywood, 0xdeb887
-cadetblue, 0x5f9ea0
-chartreuse, 0x7fff00
-chocolate, 0xd2691e
-coral, 0xff7f50
-cornflowerblue, 0x6495ed
-cornsilk, 0xfff8dc
-crimson, 0xdc143c
-cyan, 0x00ffff
-darkblue, 0x00008b
-darkcyan, 0x008b8b
-darkgoldenrod, 0xb8860b
-darkgray, 0xa9a9a9
-darkgrey, 0xa9a9a9
-darkgreen, 0x006400
-darkkhaki, 0xbdb76b
-darkmagenta, 0x8b008b
-darkolivegreen, 0x556b2f
-darkorange, 0xff8c00
-darkorchid, 0x9932cc
-darkred, 0x8b0000
-darksalmon, 0xe9967a
-darkseagreen, 0x8fbc8f
-darkslateblue, 0x483d8b
-darkslategray, 0x2f4f4f
-darkslategrey, 0x2f4f4f
-darkturquoise, 0x00ced1
-darkviolet, 0x9400d3
-deeppink, 0xff1493
-deepskyblue, 0x00bfff
-dimgray, 0x696969
-dimgrey, 0x696969
-dodgerblue, 0x1e90ff
-firebrick, 0xb22222
-floralwhite, 0xfffaf0
-forestgreen, 0x228b22
-fuchsia, 0xff00ff
-gainsboro, 0xdcdcdc
-ghostwhite, 0xf8f8ff
-gold, 0xffd700
-goldenrod, 0xdaa520
-gray, 0x808080
-grey, 0x808080
-green, 0x008000
-greenyellow, 0xadff2f
-honeydew, 0xf0fff0
-hotpink, 0xff69b4
-indianred, 0xcd5c5c
-indigo, 0x4b0082
-ivory, 0xfffff0
-khaki, 0xf0e68c
-lavender, 0xe6e6fa
-lavenderblush, 0xfff0f5
-lawngreen, 0x7cfc00
-lemonchiffon, 0xfffacd
-lightblue, 0xadd8e6
-lightcoral, 0xf08080
-lightcyan, 0xe0ffff
-lightgoldenrodyellow, 0xfafad2
-lightgray, 0xd3d3d3
-lightgrey, 0xd3d3d3
-lightgreen, 0x90ee90
-lightpink, 0xffb6c1
-lightsalmon, 0xffa07a
-lightseagreen, 0x20b2aa
-lightskyblue, 0x87cefa
-lightslateblue, 0x8470ff
-lightslategray, 0x778899
-lightslategrey, 0x778899
-lightsteelblue, 0xb0c4de
-lightyellow, 0xffffe0
-lime, 0x00ff00
-limegreen, 0x32cd32
-linen, 0xfaf0e6
-magenta, 0xff00ff
-maroon, 0x800000
-mediumaquamarine, 0x66cdaa
-mediumblue, 0x0000cd
-mediumorchid, 0xba55d3
-mediumpurple, 0x9370d8
-mediumseagreen, 0x3cb371
-mediumslateblue, 0x7b68ee
-mediumspringgreen, 0x00fa9a
-mediumturquoise, 0x48d1cc
-mediumvioletred, 0xc71585
-midnightblue, 0x191970
-mintcream, 0xf5fffa
-mistyrose, 0xffe4e1
-moccasin, 0xffe4b5
-navajowhite, 0xffdead
-navy, 0x000080
-oldlace, 0xfdf5e6
-olive, 0x808000
-olivedrab, 0x6b8e23
-orange, 0xffa500
-orangered, 0xff4500
-orchid, 0xda70d6
-palegoldenrod, 0xeee8aa
-palegreen, 0x98fb98
-paleturquoise, 0xafeeee
-palevioletred, 0xd87093
-papayawhip, 0xffefd5
-peachpuff, 0xffdab9
-peru, 0xcd853f
-pink, 0xffc0cb
-plum, 0xdda0dd
-powderblue, 0xb0e0e6
-purple, 0x800080
-red, 0xff0000
-rosybrown, 0xbc8f8f
-royalblue, 0x4169e1
-saddlebrown, 0x8b4513
-salmon, 0xfa8072
-sandybrown, 0xf4a460
-seagreen, 0x2e8b57
-seashell, 0xfff5ee
-sienna, 0xa0522d
-silver, 0xc0c0c0
-skyblue, 0x87ceeb
-slateblue, 0x6a5acd
-slategray, 0x708090
-slategrey, 0x708090
-snow, 0xfffafa
-springgreen, 0x00ff7f
-steelblue, 0x4682b4
-tan, 0xd2b48c
-teal, 0x008080
-thistle, 0xd8bfd8
-tomato, 0xff6347
-turquoise, 0x40e0d0
-violet, 0xee82ee
-violetred, 0xd02090
-wheat, 0xf5deb3
-white, 0xffffff
-whitesmoke, 0xf5f5f5
-yellow, 0xffff00
-yellowgreen, 0x9acd32
diff --git a/WebCore/platform/ContextMenu.cpp b/WebCore/platform/ContextMenu.cpp
deleted file mode 100644
index a9c64df..0000000
--- a/WebCore/platform/ContextMenu.cpp
+++ /dev/null
@@ -1,609 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2008 Christian Dywan <christian@imendio.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ContextMenu.h"
-
-#include "ContextMenuController.h"
-#include "CSSComputedStyleDeclaration.h"
-#include "CSSProperty.h"
-#include "CSSPropertyNames.h"
-#include "CString.h"
-#include "Document.h"
-#include "DocumentLoader.h"
-#include "Editor.h"
-#include "Frame.h"
-#include "FrameLoader.h"
-#include "KURL.h"
-#include "LocalizedStrings.h"
-#include "Node.h"
-#include "Page.h"
-#include "ResourceRequest.h"
-#include "SelectionController.h"
-#include "TextIterator.h"
-#include <memory>
-
-using namespace std;
-using namespace WTF;
-using namespace Unicode;
-
-namespace WebCore {
-
-ContextMenuController* ContextMenu::controller() const
-{
- if (Node* node = m_hitTestResult.innerNonSharedNode())
- if (Frame* frame = node->document()->frame())
- if (Page* page = frame->page())
- return page->contextMenuController();
- return 0;
-}
-
-static auto_ptr<ContextMenuItem> separatorItem()
-{
- return auto_ptr<ContextMenuItem>(new ContextMenuItem(SeparatorType, ContextMenuItemTagNoAction, String()));
-}
-
-static void createAndAppendFontSubMenu(const HitTestResult& result, ContextMenuItem& fontMenuItem)
-{
- ContextMenu fontMenu(result);
-
-#if PLATFORM(MAC)
- ContextMenuItem showFonts(ActionType, ContextMenuItemTagShowFonts, contextMenuItemTagShowFonts());
-#endif
- ContextMenuItem bold(CheckableActionType, ContextMenuItemTagBold, contextMenuItemTagBold());
- ContextMenuItem italic(CheckableActionType, ContextMenuItemTagItalic, contextMenuItemTagItalic());
- ContextMenuItem underline(CheckableActionType, ContextMenuItemTagUnderline, contextMenuItemTagUnderline());
- ContextMenuItem outline(ActionType, ContextMenuItemTagOutline, contextMenuItemTagOutline());
-#if PLATFORM(MAC)
- ContextMenuItem styles(ActionType, ContextMenuItemTagStyles, contextMenuItemTagStyles());
- ContextMenuItem showColors(ActionType, ContextMenuItemTagShowColors, contextMenuItemTagShowColors());
-#endif
-
-#if PLATFORM(MAC)
- fontMenu.appendItem(showFonts);
-#endif
- fontMenu.appendItem(bold);
- fontMenu.appendItem(italic);
- fontMenu.appendItem(underline);
- fontMenu.appendItem(outline);
-#if PLATFORM(MAC)
- fontMenu.appendItem(styles);
- fontMenu.appendItem(*separatorItem());
- fontMenu.appendItem(showColors);
-#endif
-
- fontMenuItem.setSubMenu(&fontMenu);
-}
-
-#ifndef BUILDING_ON_TIGER
-static void createAndAppendSpellingAndGrammarSubMenu(const HitTestResult& result, ContextMenuItem& spellingAndGrammarMenuItem)
-{
- ContextMenu spellingAndGrammarMenu(result);
-
- ContextMenuItem showSpellingPanel(ActionType, ContextMenuItemTagShowSpellingPanel,
- contextMenuItemTagShowSpellingPanel(true));
- ContextMenuItem checkSpelling(ActionType, ContextMenuItemTagCheckSpelling,
- contextMenuItemTagCheckSpelling());
- ContextMenuItem checkAsYouType(CheckableActionType, ContextMenuItemTagCheckSpellingWhileTyping,
- contextMenuItemTagCheckSpellingWhileTyping());
- ContextMenuItem grammarWithSpelling(CheckableActionType, ContextMenuItemTagCheckGrammarWithSpelling,
- contextMenuItemTagCheckGrammarWithSpelling());
-
- spellingAndGrammarMenu.appendItem(showSpellingPanel);
- spellingAndGrammarMenu.appendItem(checkSpelling);
- spellingAndGrammarMenu.appendItem(checkAsYouType);
- spellingAndGrammarMenu.appendItem(grammarWithSpelling);
-
- spellingAndGrammarMenuItem.setSubMenu(&spellingAndGrammarMenu);
-}
-#else
-
-static void createAndAppendSpellingSubMenu(const HitTestResult& result, ContextMenuItem& spellingMenuItem)
-{
- ContextMenu spellingMenu(result);
-
- ContextMenuItem showSpellingPanel(ActionType, ContextMenuItemTagShowSpellingPanel,
- contextMenuItemTagShowSpellingPanel(true));
- ContextMenuItem checkSpelling(ActionType, ContextMenuItemTagCheckSpelling,
- contextMenuItemTagCheckSpelling());
- ContextMenuItem checkAsYouType(CheckableActionType, ContextMenuItemTagCheckSpellingWhileTyping,
- contextMenuItemTagCheckSpellingWhileTyping());
-
- spellingMenu.appendItem(showSpellingPanel);
- spellingMenu.appendItem(checkSpelling);
- spellingMenu.appendItem(checkAsYouType);
-
- spellingMenuItem.setSubMenu(&spellingMenu);
-}
-#endif
-
-#if PLATFORM(MAC)
-static void createAndAppendSpeechSubMenu(const HitTestResult& result, ContextMenuItem& speechMenuItem)
-{
- ContextMenu speechMenu(result);
-
- ContextMenuItem start(ActionType, ContextMenuItemTagStartSpeaking, contextMenuItemTagStartSpeaking());
- ContextMenuItem stop(ActionType, ContextMenuItemTagStopSpeaking, contextMenuItemTagStopSpeaking());
-
- speechMenu.appendItem(start);
- speechMenu.appendItem(stop);
-
- speechMenuItem.setSubMenu(&speechMenu);
-}
-#endif
-
-#if !PLATFORM(GTK)
-static void createAndAppendWritingDirectionSubMenu(const HitTestResult& result, ContextMenuItem& writingDirectionMenuItem)
-{
- ContextMenu writingDirectionMenu(result);
-
- ContextMenuItem defaultItem(ActionType, ContextMenuItemTagDefaultDirection,
- contextMenuItemTagDefaultDirection());
- ContextMenuItem ltr(CheckableActionType, ContextMenuItemTagLeftToRight, contextMenuItemTagLeftToRight());
- ContextMenuItem rtl(CheckableActionType, ContextMenuItemTagRightToLeft, contextMenuItemTagRightToLeft());
-
- writingDirectionMenu.appendItem(defaultItem);
- writingDirectionMenu.appendItem(ltr);
- writingDirectionMenu.appendItem(rtl);
-
- writingDirectionMenuItem.setSubMenu(&writingDirectionMenu);
-}
-#endif
-
-static bool selectionContainsPossibleWord(Frame* frame)
-{
- // Current algorithm: look for a character that's not just a separator.
- for (TextIterator it(frame->selection()->toRange().get()); !it.atEnd(); it.advance()) {
- int length = it.length();
- const UChar* characters = it.characters();
- for (int i = 0; i < length; ++i)
- if (!(category(characters[i]) & (Separator_Space | Separator_Line | Separator_Paragraph)))
- return true;
- }
- return false;
-}
-
-void ContextMenu::populate()
-{
- ContextMenuItem OpenLinkItem(ActionType, ContextMenuItemTagOpenLink, contextMenuItemTagOpenLink());
- ContextMenuItem OpenLinkInNewWindowItem(ActionType, ContextMenuItemTagOpenLinkInNewWindow,
- contextMenuItemTagOpenLinkInNewWindow());
- ContextMenuItem DownloadFileItem(ActionType, ContextMenuItemTagDownloadLinkToDisk,
- contextMenuItemTagDownloadLinkToDisk());
- ContextMenuItem CopyLinkItem(ActionType, ContextMenuItemTagCopyLinkToClipboard,
- contextMenuItemTagCopyLinkToClipboard());
- ContextMenuItem OpenImageInNewWindowItem(ActionType, ContextMenuItemTagOpenImageInNewWindow,
- contextMenuItemTagOpenImageInNewWindow());
- ContextMenuItem DownloadImageItem(ActionType, ContextMenuItemTagDownloadImageToDisk,
- contextMenuItemTagDownloadImageToDisk());
- ContextMenuItem CopyImageItem(ActionType, ContextMenuItemTagCopyImageToClipboard,
- contextMenuItemTagCopyImageToClipboard());
-#if PLATFORM(MAC)
- ContextMenuItem SearchSpotlightItem(ActionType, ContextMenuItemTagSearchInSpotlight,
- contextMenuItemTagSearchInSpotlight());
- ContextMenuItem LookInDictionaryItem(ActionType, ContextMenuItemTagLookUpInDictionary,
- contextMenuItemTagLookUpInDictionary());
-#endif
- ContextMenuItem SearchWebItem(ActionType, ContextMenuItemTagSearchWeb, contextMenuItemTagSearchWeb());
- ContextMenuItem CopyItem(ActionType, ContextMenuItemTagCopy, contextMenuItemTagCopy());
- ContextMenuItem BackItem(ActionType, ContextMenuItemTagGoBack, contextMenuItemTagGoBack());
- ContextMenuItem ForwardItem(ActionType, ContextMenuItemTagGoForward, contextMenuItemTagGoForward());
- ContextMenuItem StopItem(ActionType, ContextMenuItemTagStop, contextMenuItemTagStop());
- ContextMenuItem ReloadItem(ActionType, ContextMenuItemTagReload, contextMenuItemTagReload());
- ContextMenuItem OpenFrameItem(ActionType, ContextMenuItemTagOpenFrameInNewWindow,
- contextMenuItemTagOpenFrameInNewWindow());
- ContextMenuItem NoGuessesItem(ActionType, ContextMenuItemTagNoGuessesFound,
- contextMenuItemTagNoGuessesFound());
- ContextMenuItem IgnoreSpellingItem(ActionType, ContextMenuItemTagIgnoreSpelling,
- contextMenuItemTagIgnoreSpelling());
- ContextMenuItem LearnSpellingItem(ActionType, ContextMenuItemTagLearnSpelling,
- contextMenuItemTagLearnSpelling());
- ContextMenuItem IgnoreGrammarItem(ActionType, ContextMenuItemTagIgnoreGrammar,
- contextMenuItemTagIgnoreGrammar());
- ContextMenuItem CutItem(ActionType, ContextMenuItemTagCut, contextMenuItemTagCut());
- ContextMenuItem PasteItem(ActionType, ContextMenuItemTagPaste, contextMenuItemTagPaste());
-#if PLATFORM(GTK)
- ContextMenuItem DeleteItem(ActionType, ContextMenuItemTagDelete, contextMenuItemTagDelete());
- ContextMenuItem SelectAllItem(ActionType, ContextMenuItemTagSelectAll, contextMenuItemTagSelectAll());
-#endif
-
- HitTestResult result = hitTestResult();
-
- Node* node = m_hitTestResult.innerNonSharedNode();
- if (!node)
- return;
-#if PLATFORM(GTK)
- if (!result.isContentEditable() && node->isControl())
- return;
-#endif
- Frame* frame = node->document()->frame();
- if (!frame)
- return;
-
- if (!result.isContentEditable()) {
- FrameLoader* loader = frame->loader();
- KURL linkURL = result.absoluteLinkURL();
- if (!linkURL.isEmpty()) {
- if (loader->canHandleRequest(ResourceRequest(linkURL))) {
- appendItem(OpenLinkItem);
- appendItem(OpenLinkInNewWindowItem);
- appendItem(DownloadFileItem);
- }
- appendItem(CopyLinkItem);
- }
-
- KURL imageURL = result.absoluteImageURL();
- if (!imageURL.isEmpty()) {
- if (!linkURL.isEmpty())
- appendItem(*separatorItem());
-
- appendItem(OpenImageInNewWindowItem);
- appendItem(DownloadImageItem);
- if (imageURL.isLocalFile() || m_hitTestResult.image())
- appendItem(CopyImageItem);
- }
-
- if (imageURL.isEmpty() && linkURL.isEmpty()) {
- if (result.isSelected()) {
- if (selectionContainsPossibleWord(frame)) {
-#if PLATFORM(MAC)
- appendItem(SearchSpotlightItem);
-#endif
- appendItem(SearchWebItem);
- appendItem(*separatorItem());
-#if PLATFORM(MAC)
- appendItem(LookInDictionaryItem);
- appendItem(*separatorItem());
-#endif
- }
- appendItem(CopyItem);
- } else {
-#if PLATFORM(GTK)
- appendItem(BackItem);
- appendItem(ForwardItem);
- appendItem(StopItem);
- appendItem(ReloadItem);
-#else
- if (loader->canGoBackOrForward(-1))
- appendItem(BackItem);
-
- if (loader->canGoBackOrForward(1))
- appendItem(ForwardItem);
-
- // use isLoadingInAPISense rather than isLoading because Stop/Reload are
- // intended to match WebKit's API, not WebCore's internal notion of loading status
- if (loader->documentLoader()->isLoadingInAPISense())
- appendItem(StopItem);
- else
- appendItem(ReloadItem);
-#endif
-
- if (frame->page() && frame != frame->page()->mainFrame())
- appendItem(OpenFrameItem);
- }
- }
- } else { // Make an editing context menu
- SelectionController* selection = frame->selection();
- bool inPasswordField = selection->isInPasswordField();
-
- if (!inPasswordField) {
- // Consider adding spelling-related or grammar-related context menu items (never both, since a single selected range
- // is never considered a misspelling and bad grammar at the same time)
- bool misspelling = frame->editor()->isSelectionMisspelled();
- bool badGrammar = !misspelling && (frame->editor()->isGrammarCheckingEnabled() && frame->editor()->isSelectionUngrammatical());
-
- if (misspelling || badGrammar) {
- Vector<String> guesses = misspelling ? frame->editor()->guessesForMisspelledSelection()
- : frame->editor()->guessesForUngrammaticalSelection();
- size_t size = guesses.size();
- if (size == 0) {
- // If there's bad grammar but no suggestions (e.g., repeated word), just leave off the suggestions
- // list and trailing separator rather than adding a "No Guesses Found" item (matches AppKit)
- if (misspelling) {
- appendItem(NoGuessesItem);
- appendItem(*separatorItem());
- }
- } else {
- for (unsigned i = 0; i < size; i++) {
- const String &guess = guesses[i];
- if (!guess.isEmpty()) {
- ContextMenuItem item(ActionType, ContextMenuItemTagSpellingGuess, guess);
- appendItem(item);
- }
- }
- appendItem(*separatorItem());
- }
-
- if (misspelling) {
- appendItem(IgnoreSpellingItem);
- appendItem(LearnSpellingItem);
- } else
- appendItem(IgnoreGrammarItem);
- appendItem(*separatorItem());
- }
- }
-
- FrameLoader* loader = frame->loader();
- KURL linkURL = result.absoluteLinkURL();
- if (!linkURL.isEmpty()) {
- if (loader->canHandleRequest(ResourceRequest(linkURL))) {
- appendItem(OpenLinkItem);
- appendItem(OpenLinkInNewWindowItem);
- appendItem(DownloadFileItem);
- }
- appendItem(CopyLinkItem);
- appendItem(*separatorItem());
- }
-
- if (result.isSelected() && !inPasswordField && selectionContainsPossibleWord(frame)) {
-#if PLATFORM(MAC)
- appendItem(SearchSpotlightItem);
-#endif
- appendItem(SearchWebItem);
- appendItem(*separatorItem());
-
-#if PLATFORM(MAC)
- appendItem(LookInDictionaryItem);
- appendItem(*separatorItem());
-#endif
- }
-
- appendItem(CutItem);
- appendItem(CopyItem);
- appendItem(PasteItem);
-#if PLATFORM(GTK)
- appendItem(DeleteItem);
- appendItem(*separatorItem());
- appendItem(SelectAllItem);
-#endif
-
- if (!inPasswordField) {
- appendItem(*separatorItem());
-#ifndef BUILDING_ON_TIGER
- ContextMenuItem SpellingAndGrammarMenuItem(SubmenuType, ContextMenuItemTagSpellingMenu,
- contextMenuItemTagSpellingMenu());
- createAndAppendSpellingAndGrammarSubMenu(m_hitTestResult, SpellingAndGrammarMenuItem);
- appendItem(SpellingAndGrammarMenuItem);
-#else
- ContextMenuItem SpellingMenuItem(SubmenuType, ContextMenuItemTagSpellingMenu,
- contextMenuItemTagSpellingMenu());
- createAndAppendSpellingSubMenu(m_hitTestResult, SpellingMenuItem);
- appendItem(SpellingMenuItem);
-#endif
- ContextMenuItem FontMenuItem(SubmenuType, ContextMenuItemTagFontMenu,
- contextMenuItemTagFontMenu());
- createAndAppendFontSubMenu(m_hitTestResult, FontMenuItem);
- appendItem(FontMenuItem);
-#if PLATFORM(MAC)
- ContextMenuItem SpeechMenuItem(SubmenuType, ContextMenuItemTagSpeechMenu,
- contextMenuItemTagSpeechMenu());
- createAndAppendSpeechSubMenu(m_hitTestResult, SpeechMenuItem);
- appendItem(SpeechMenuItem);
-#endif
-#if !PLATFORM(GTK)
- ContextMenuItem WritingDirectionMenuItem(SubmenuType, ContextMenuItemTagWritingDirectionMenu,
- contextMenuItemTagWritingDirectionMenu());
- createAndAppendWritingDirectionSubMenu(m_hitTestResult, WritingDirectionMenuItem);
- appendItem(WritingDirectionMenuItem);
-#endif
- }
- }
-}
-
-void ContextMenu::addInspectElementItem()
-{
- Node* node = m_hitTestResult.innerNonSharedNode();
- if (!node)
- return;
-
- Frame* frame = node->document()->frame();
- if (!frame)
- return;
-
- Page* page = frame->page();
- if (!page)
- return;
-
- if (!page->inspectorController())
- return;
-
- ContextMenuItem InspectElementItem(ActionType, ContextMenuItemTagInspectElement, contextMenuItemTagInspectElement());
- appendItem(*separatorItem());
- appendItem(InspectElementItem);
-}
-
-void ContextMenu::checkOrEnableIfNeeded(ContextMenuItem& item) const
-{
- if (item.type() == SeparatorType)
- return;
-
- Frame* frame = m_hitTestResult.innerNonSharedNode()->document()->frame();
- if (!frame)
- return;
-
- bool shouldEnable = true;
- bool shouldCheck = false;
-
- switch (item.action()) {
- case ContextMenuItemTagCheckSpelling:
- shouldEnable = frame->editor()->canEdit();
- break;
- case ContextMenuItemTagDefaultDirection:
- shouldCheck = false;
- shouldEnable = false;
- break;
- case ContextMenuItemTagLeftToRight:
- case ContextMenuItemTagRightToLeft: {
- ExceptionCode ec = 0;
- RefPtr<CSSStyleDeclaration> style = frame->document()->createCSSStyleDeclaration();
- String direction = item.action() == ContextMenuItemTagLeftToRight ? "ltr" : "rtl";
- style->setProperty(CSSPropertyDirection, direction, false, ec);
- shouldCheck = frame->editor()->selectionHasStyle(style.get()) != FalseTriState;
- shouldEnable = true;
- break;
- }
- case ContextMenuItemTagCopy:
- shouldEnable = frame->editor()->canDHTMLCopy() || frame->editor()->canCopy();
- break;
- case ContextMenuItemTagCut:
- shouldEnable = frame->editor()->canDHTMLCut() || frame->editor()->canCut();
- break;
- case ContextMenuItemTagIgnoreSpelling:
- case ContextMenuItemTagLearnSpelling:
- shouldEnable = frame->selection()->isRange();
- break;
- case ContextMenuItemTagPaste:
- shouldEnable = frame->editor()->canDHTMLPaste() || frame->editor()->canPaste();
- break;
-#if PLATFORM(GTK)
- case ContextMenuItemTagDelete:
- shouldEnable = frame->editor()->canDelete();
- break;
- case ContextMenuItemTagSelectAll:
- case ContextMenuItemTagInputMethods:
- case ContextMenuItemTagUnicode:
- shouldEnable = true;
- break;
-#endif
- case ContextMenuItemTagUnderline: {
- ExceptionCode ec = 0;
- RefPtr<CSSStyleDeclaration> style = frame->document()->createCSSStyleDeclaration();
- style->setProperty(CSSPropertyWebkitTextDecorationsInEffect, "underline", false, ec);
- shouldCheck = frame->editor()->selectionHasStyle(style.get()) != FalseTriState;
- shouldEnable = frame->editor()->canEditRichly();
- break;
- }
- case ContextMenuItemTagLookUpInDictionary:
- shouldEnable = frame->selection()->isRange();
- break;
- case ContextMenuItemTagCheckGrammarWithSpelling:
-#ifndef BUILDING_ON_TIGER
- if (frame->editor()->isGrammarCheckingEnabled())
- shouldCheck = true;
- shouldEnable = true;
-#endif
- break;
- case ContextMenuItemTagItalic: {
- ExceptionCode ec = 0;
- RefPtr<CSSStyleDeclaration> style = frame->document()->createCSSStyleDeclaration();
- style->setProperty(CSSPropertyFontStyle, "italic", false, ec);
- shouldCheck = frame->editor()->selectionHasStyle(style.get()) != FalseTriState;
- shouldEnable = frame->editor()->canEditRichly();
- break;
- }
- case ContextMenuItemTagBold: {
- ExceptionCode ec = 0;
- RefPtr<CSSStyleDeclaration> style = frame->document()->createCSSStyleDeclaration();
- style->setProperty(CSSPropertyFontWeight, "bold", false, ec);
- shouldCheck = frame->editor()->selectionHasStyle(style.get()) != FalseTriState;
- shouldEnable = frame->editor()->canEditRichly();
- break;
- }
- case ContextMenuItemTagOutline:
- shouldEnable = false;
- break;
- case ContextMenuItemTagShowSpellingPanel:
-#ifndef BUILDING_ON_TIGER
- if (frame->editor()->spellingPanelIsShowing())
- item.setTitle(contextMenuItemTagShowSpellingPanel(false));
- else
- item.setTitle(contextMenuItemTagShowSpellingPanel(true));
-#endif
- shouldEnable = frame->editor()->canEdit();
- break;
- case ContextMenuItemTagNoGuessesFound:
- shouldEnable = false;
- break;
- case ContextMenuItemTagCheckSpellingWhileTyping:
- shouldCheck = frame->editor()->isContinuousSpellCheckingEnabled();
- break;
-#if PLATFORM(GTK)
- case ContextMenuItemTagGoBack:
- shouldEnable = frame->loader()->canGoBackOrForward(-1);
- break;
- case ContextMenuItemTagGoForward:
- shouldEnable = frame->loader()->canGoBackOrForward(1);
- break;
- case ContextMenuItemTagStop:
- shouldEnable = frame->loader()->documentLoader()->isLoadingInAPISense();
- break;
- case ContextMenuItemTagReload:
- shouldEnable = !frame->loader()->documentLoader()->isLoadingInAPISense();
- break;
- case ContextMenuItemTagFontMenu:
- shouldEnable = frame->editor()->canEditRichly();
- break;
-#else
- case ContextMenuItemTagGoBack:
- case ContextMenuItemTagGoForward:
- case ContextMenuItemTagStop:
- case ContextMenuItemTagReload:
- case ContextMenuItemTagFontMenu:
-#endif
- case ContextMenuItemTagNoAction:
- case ContextMenuItemTagOpenLinkInNewWindow:
- case ContextMenuItemTagDownloadLinkToDisk:
- case ContextMenuItemTagCopyLinkToClipboard:
- case ContextMenuItemTagOpenImageInNewWindow:
- case ContextMenuItemTagDownloadImageToDisk:
- case ContextMenuItemTagCopyImageToClipboard:
- case ContextMenuItemTagOpenFrameInNewWindow:
- case ContextMenuItemTagSpellingGuess:
- case ContextMenuItemTagOther:
- case ContextMenuItemTagSearchInSpotlight:
- case ContextMenuItemTagSearchWeb:
- case ContextMenuItemTagOpenWithDefaultApplication:
- case ContextMenuItemPDFActualSize:
- case ContextMenuItemPDFZoomIn:
- case ContextMenuItemPDFZoomOut:
- case ContextMenuItemPDFAutoSize:
- case ContextMenuItemPDFSinglePage:
- case ContextMenuItemPDFFacingPages:
- case ContextMenuItemPDFContinuous:
- case ContextMenuItemPDFNextPage:
- case ContextMenuItemPDFPreviousPage:
- case ContextMenuItemTagOpenLink:
- case ContextMenuItemTagIgnoreGrammar:
- case ContextMenuItemTagSpellingMenu:
- case ContextMenuItemTagShowFonts:
- case ContextMenuItemTagStyles:
- case ContextMenuItemTagShowColors:
- case ContextMenuItemTagSpeechMenu:
- case ContextMenuItemTagStartSpeaking:
- case ContextMenuItemTagStopSpeaking:
- case ContextMenuItemTagWritingDirectionMenu:
- case ContextMenuItemTagPDFSinglePageScrolling:
- case ContextMenuItemTagPDFFacingPagesScrolling:
- case ContextMenuItemTagInspectElement:
- case ContextMenuItemBaseApplicationTag:
- break;
- }
-
- item.setChecked(shouldCheck);
- item.setEnabled(shouldEnable);
-}
-
-}
diff --git a/WebCore/platform/ContextMenu.h b/WebCore/platform/ContextMenu.h
deleted file mode 100644
index e10c762..0000000
--- a/WebCore/platform/ContextMenu.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ContextMenu_h
-#define ContextMenu_h
-
-#include <wtf/Noncopyable.h>
-
-#include "ContextMenuItem.h"
-#include "HitTestResult.h"
-#include "PlatformMenuDescription.h"
-#include "PlatformString.h"
-#if PLATFORM(MAC)
-#include <wtf/RetainPtr.h>
-#elif PLATFORM(QT)
-#include <QMenu>
-#endif
-
-namespace WebCore {
-class MenuEventProxy;
-
- class ContextMenuController;
-
- class ContextMenu : Noncopyable
- {
- public:
- ContextMenu(const HitTestResult&);
- ContextMenu(const HitTestResult&, const PlatformMenuDescription);
- ~ContextMenu();
-
- void populate();
- void addInspectElementItem();
- void checkOrEnableIfNeeded(ContextMenuItem&) const;
-
- void insertItem(unsigned position, ContextMenuItem&);
- void appendItem(ContextMenuItem&);
-
- ContextMenuItem* itemWithAction(unsigned);
- ContextMenuItem* itemAtIndex(unsigned, const PlatformMenuDescription);
-
- unsigned itemCount() const;
-
- HitTestResult hitTestResult() const { return m_hitTestResult; }
- ContextMenuController* controller() const;
-
- PlatformMenuDescription platformDescription() const;
- void setPlatformDescription(PlatformMenuDescription);
-
- PlatformMenuDescription releasePlatformDescription();
-
- private:
- HitTestResult m_hitTestResult;
-
-#if PLATFORM(MAC)
- // Keep this in sync with the PlatformMenuDescription typedef
- RetainPtr<NSMutableArray> m_platformDescription;
-#elif PLATFORM(QT)
- QList<ContextMenuItem> m_items;
-#else
- PlatformMenuDescription m_platformDescription;
-#endif
- };
-
-}
-
-#endif // ContextMenu_h
diff --git a/WebCore/platform/ContextMenuItem.h b/WebCore/platform/ContextMenuItem.h
deleted file mode 100644
index 5fb2681..0000000
--- a/WebCore/platform/ContextMenuItem.h
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ContextMenuItem_h
-#define ContextMenuItem_h
-
-#include "PlatformMenuDescription.h"
-#include "PlatformString.h"
-#include <wtf/OwnPtr.h>
-
-#if PLATFORM(MAC)
-#include <wtf/RetainPtr.h>
-
-#ifdef __OBJC__
-@class NSMenuItem;
-#else
-class NSMenuItem;
-#endif
-#elif PLATFORM(WIN)
-typedef struct tagMENUITEMINFOW* LPMENUITEMINFO;
-#elif PLATFORM(GTK)
-typedef struct _GtkMenuItem GtkMenuItem;
-#elif PLATFORM(QT)
-#include <QAction>
-#elif PLATFORM(WX)
-class wxMenuItem;
-#endif
-
-namespace WebCore {
-
- class ContextMenu;
-
- // This enum needs to be in sync with the WebMenuItemTag enum in WebUIDelegate.h and the
- // extra values in WebUIDelegatePrivate.h
- enum ContextMenuAction {
- ContextMenuItemTagNoAction=0, // This item is not actually in WebUIDelegate.h
- ContextMenuItemTagOpenLinkInNewWindow=1,
- ContextMenuItemTagDownloadLinkToDisk,
- ContextMenuItemTagCopyLinkToClipboard,
- ContextMenuItemTagOpenImageInNewWindow,
- ContextMenuItemTagDownloadImageToDisk,
- ContextMenuItemTagCopyImageToClipboard,
- ContextMenuItemTagOpenFrameInNewWindow,
- ContextMenuItemTagCopy,
- ContextMenuItemTagGoBack,
- ContextMenuItemTagGoForward,
- ContextMenuItemTagStop,
- ContextMenuItemTagReload,
- ContextMenuItemTagCut,
- ContextMenuItemTagPaste,
-#if PLATFORM(GTK)
- ContextMenuItemTagDelete,
- ContextMenuItemTagSelectAll,
- ContextMenuItemTagInputMethods,
- ContextMenuItemTagUnicode,
-#endif
- ContextMenuItemTagSpellingGuess,
- ContextMenuItemTagNoGuessesFound,
- ContextMenuItemTagIgnoreSpelling,
- ContextMenuItemTagLearnSpelling,
- ContextMenuItemTagOther,
- ContextMenuItemTagSearchInSpotlight,
- ContextMenuItemTagSearchWeb,
- ContextMenuItemTagLookUpInDictionary,
- ContextMenuItemTagOpenWithDefaultApplication,
- ContextMenuItemPDFActualSize,
- ContextMenuItemPDFZoomIn,
- ContextMenuItemPDFZoomOut,
- ContextMenuItemPDFAutoSize,
- ContextMenuItemPDFSinglePage,
- ContextMenuItemPDFFacingPages,
- ContextMenuItemPDFContinuous,
- ContextMenuItemPDFNextPage,
- ContextMenuItemPDFPreviousPage,
- // These are new tags! Not a part of API!!!!
- ContextMenuItemTagOpenLink = 2000,
- ContextMenuItemTagIgnoreGrammar,
- ContextMenuItemTagSpellingMenu, // Spelling or Spelling/Grammar sub-menu
- ContextMenuItemTagShowSpellingPanel,
- ContextMenuItemTagCheckSpelling,
- ContextMenuItemTagCheckSpellingWhileTyping,
- ContextMenuItemTagCheckGrammarWithSpelling,
- ContextMenuItemTagFontMenu, // Font sub-menu
- ContextMenuItemTagShowFonts,
- ContextMenuItemTagBold,
- ContextMenuItemTagItalic,
- ContextMenuItemTagUnderline,
- ContextMenuItemTagOutline,
- ContextMenuItemTagStyles,
- ContextMenuItemTagShowColors,
- ContextMenuItemTagSpeechMenu, // Speech sub-menu
- ContextMenuItemTagStartSpeaking,
- ContextMenuItemTagStopSpeaking,
- ContextMenuItemTagWritingDirectionMenu, // Writing Direction sub-menu
- ContextMenuItemTagDefaultDirection,
- ContextMenuItemTagLeftToRight,
- ContextMenuItemTagRightToLeft,
- ContextMenuItemTagPDFSinglePageScrolling,
- ContextMenuItemTagPDFFacingPagesScrolling,
- ContextMenuItemTagInspectElement,
- ContextMenuItemBaseApplicationTag = 10000
- };
-
- enum ContextMenuItemType {
- ActionType,
- CheckableActionType,
- SeparatorType,
- SubmenuType
- };
-
-#if PLATFORM(MAC)
- typedef NSMenuItem* PlatformMenuItemDescription;
-#elif PLATFORM(WIN)
- typedef LPMENUITEMINFO PlatformMenuItemDescription;
-#elif PLATFORM(QT)
- struct PlatformMenuItemDescription {
- PlatformMenuItemDescription()
- : type(ActionType),
- action(ContextMenuItemTagNoAction),
- checked(false),
- enabled(true)
- {}
-
- ContextMenuItemType type;
- ContextMenuAction action;
- String title;
- QList<ContextMenuItem> subMenuItems;
- bool checked;
- bool enabled;
- };
-#elif PLATFORM(GTK)
- struct PlatformMenuItemDescription {
- PlatformMenuItemDescription()
- : type(ActionType)
- , action(ContextMenuItemTagNoAction)
- , subMenu(0)
- , checked(false)
- , enabled(true)
- {}
-
- ContextMenuItemType type;
- ContextMenuAction action;
- String title;
- GtkMenu* subMenu;
- bool checked;
- bool enabled;
- };
-#elif defined ANDROID
- typedef void* PlatformMenuItemDescription;
-#elif PLATFORM(WX)
- typedef wxMenuItem* PlatformMenuItemDescription;
-#else
- typedef void* PlatformMenuItemDescription;
-#endif
-
- class ContextMenuItem {
- public:
- ContextMenuItem(PlatformMenuItemDescription);
- ContextMenuItem(ContextMenu* subMenu = 0);
- ContextMenuItem(ContextMenuItemType type, ContextMenuAction action, const String& title, ContextMenu* subMenu = 0);
-#if PLATFORM(GTK)
- ContextMenuItem(GtkMenuItem*);
-#endif
- ~ContextMenuItem();
-
- PlatformMenuItemDescription releasePlatformDescription();
-
- ContextMenuItemType type() const;
- void setType(ContextMenuItemType);
-
- ContextMenuAction action() const;
- void setAction(ContextMenuAction);
-
- String title() const;
- void setTitle(const String&);
-
- PlatformMenuDescription platformSubMenu() const;
- void setSubMenu(ContextMenu*);
-
- void setChecked(bool = true);
-
- void setEnabled(bool = true);
- bool enabled() const;
-
- // FIXME: Do we need a keyboard accelerator here?
-#if PLATFORM(GTK)
- static GtkMenuItem* createNativeMenuItem(const PlatformMenuItemDescription&);
-#endif
-
- private:
-#if PLATFORM(MAC)
- RetainPtr<NSMenuItem> m_platformDescription;
-#else
- PlatformMenuItemDescription m_platformDescription;
-#endif
- };
-
-}
-
-#endif // ContextMenuItem_h
diff --git a/WebCore/platform/CookieJar.h b/WebCore/platform/CookieJar.h
deleted file mode 100644
index 22627f2..0000000
--- a/WebCore/platform/CookieJar.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef CookieJar_h
-#define CookieJar_h
-
-#if USE(SOUP)
-#include <libsoup/soup.h>
-#endif
-
-namespace WebCore {
-
- class KURL;
- class String;
- class Document;
-
- String cookies(const Document* document, const KURL&);
- void setCookies(Document* document, const KURL&, const KURL& policyBaseURL, const String&);
- bool cookiesEnabled(const Document* document);
-#if USE(SOUP)
- SoupCookieJar* getCookieJar(void);
-#endif
-}
-
-#endif
diff --git a/WebCore/platform/Cursor.h b/WebCore/platform/Cursor.h
deleted file mode 100644
index 3ab694c..0000000
--- a/WebCore/platform/Cursor.h
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef Cursor_h
-#define Cursor_h
-
-#include <wtf/Platform.h>
-
-#if PLATFORM(WIN)
-typedef struct HICON__* HICON;
-typedef HICON HCURSOR;
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-#elif PLATFORM(GTK)
-typedef struct _GdkCursor GdkCursor;
-#elif PLATFORM(QT)
-#include <QCursor>
-#elif PLATFORM(CHROMIUM)
-#include "PlatformCursor.h"
-#endif
-
-#if PLATFORM(MAC)
-#ifdef __OBJC__
-@class NSCursor;
-#else
-class NSCursor;
-#endif
-#endif
-
-#if PLATFORM(WX)
-class wxCursor;
-#endif
-
-namespace WebCore {
-
- class Image;
- class IntPoint;
-
-#if PLATFORM(WIN)
- class SharedCursor : public RefCounted<SharedCursor> {
- public:
- static PassRefPtr<SharedCursor> create(HCURSOR nativeCursor) { return adoptRef(new SharedCursor(nativeCursor)); }
- ~SharedCursor() { DestroyIcon(m_nativeCursor); }
- HCURSOR nativeCursor() const { return m_nativeCursor; }
- private:
- SharedCursor(HCURSOR nativeCursor) : m_nativeCursor(nativeCursor) { }
- HCURSOR m_nativeCursor;
- };
- typedef RefPtr<SharedCursor> PlatformCursor;
-#elif PLATFORM(MAC)
- typedef NSCursor* PlatformCursor;
-#elif PLATFORM(GTK)
- typedef GdkCursor* PlatformCursor;
-#elif PLATFORM(QT) && !defined(QT_NO_CURSOR)
- typedef QCursor PlatformCursor;
-#elif PLATFORM(WX)
- typedef wxCursor* PlatformCursor;
-#elif PLATFORM(CHROMIUM)
- // See PlatformCursor.h
-#else
- typedef void* PlatformCursor;
-#endif
-
- class Cursor {
- public:
- Cursor()
-#if !PLATFORM(QT)
- : m_impl(0)
-#endif
- { }
-
- Cursor(Image*, const IntPoint& hotspot);
- Cursor(const Cursor&);
- ~Cursor();
- Cursor& operator=(const Cursor&);
-
- Cursor(PlatformCursor);
- PlatformCursor impl() const { return m_impl; }
-
- private:
- PlatformCursor m_impl;
- };
-
- const Cursor& pointerCursor();
- const Cursor& crossCursor();
- const Cursor& handCursor();
- const Cursor& moveCursor();
- const Cursor& iBeamCursor();
- const Cursor& waitCursor();
- const Cursor& helpCursor();
- const Cursor& eastResizeCursor();
- const Cursor& northResizeCursor();
- const Cursor& northEastResizeCursor();
- const Cursor& northWestResizeCursor();
- const Cursor& southResizeCursor();
- const Cursor& southEastResizeCursor();
- const Cursor& southWestResizeCursor();
- const Cursor& westResizeCursor();
- const Cursor& northSouthResizeCursor();
- const Cursor& eastWestResizeCursor();
- const Cursor& northEastSouthWestResizeCursor();
- const Cursor& northWestSouthEastResizeCursor();
- const Cursor& columnResizeCursor();
- const Cursor& rowResizeCursor();
- const Cursor& middlePanningCursor();
- const Cursor& eastPanningCursor();
- const Cursor& northPanningCursor();
- const Cursor& northEastPanningCursor();
- const Cursor& northWestPanningCursor();
- const Cursor& southPanningCursor();
- const Cursor& southEastPanningCursor();
- const Cursor& southWestPanningCursor();
- const Cursor& westPanningCursor();
- const Cursor& verticalTextCursor();
- const Cursor& cellCursor();
- const Cursor& contextMenuCursor();
- const Cursor& noDropCursor();
- const Cursor& notAllowedCursor();
- const Cursor& progressCursor();
- const Cursor& aliasCursor();
- const Cursor& zoomInCursor();
- const Cursor& zoomOutCursor();
- const Cursor& copyCursor();
- const Cursor& noneCursor();
- const Cursor& grabCursor();
- const Cursor& grabbingCursor();
-
-} // namespace WebCore
-
-#endif // Cursor_h
diff --git a/WebCore/platform/DeprecatedPtrList.h b/WebCore/platform/DeprecatedPtrList.h
deleted file mode 100644
index 67161af..0000000
--- a/WebCore/platform/DeprecatedPtrList.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (C) 2003 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef DeprecatedPtrList_h
-#define DeprecatedPtrList_h
-
-#include "DeprecatedPtrListImpl.h"
-
-namespace WebCore {
-
-template <class T> class DeprecatedPtrListIterator;
-
-template <class T> class DeprecatedPtrList {
-public:
- DeprecatedPtrList() : impl(deleteFunc), del_item(false) { }
- ~DeprecatedPtrList() { impl.clear(del_item); }
-
- DeprecatedPtrList(const DeprecatedPtrList& l) : impl(l.impl), del_item(false) { }
- DeprecatedPtrList& operator=(const DeprecatedPtrList &l) { impl.assign(l.impl, del_item); return *this; }
-
- bool isEmpty() const { return impl.isEmpty(); }
- unsigned count() const { return impl.count(); }
- void clear() { impl.clear(del_item); }
-
- T *at(unsigned n) { return (T *)impl.at(n); }
-
- bool insert(unsigned n, const T *item) { return impl.insert(n, item); }
- bool remove() { return impl.remove(del_item); }
- bool remove(unsigned n) { return impl.remove(n, del_item); }
- bool remove(const T *item) { return impl.removeRef(item, del_item); }
- bool removeFirst() { return impl.removeFirst(del_item); }
- bool removeLast() { return impl.removeLast(del_item); }
- bool removeRef(const T *item) { return impl.removeRef(item, del_item); }
-
- T *getFirst() const { return (T *)impl.getFirst(); }
- T *getLast() const { return (T *)impl.getLast(); }
- T *getNext() const { return (T *)impl.getNext(); }
- T *getPrev() const { return (T *)impl.getPrev(); }
- T *current() const { return (T *)impl.current(); }
- T *first() { return (T *)impl.first(); }
- T *last() { return (T *)impl.last(); }
- T *next() { return (T *)impl.next(); }
- T *prev() { return (T *)impl.prev(); }
- T *take(unsigned n) { return (T *)impl.take(n); }
- T *take() { return (T *)impl.take(); }
-
- void append(const T *item) { impl.append(item); }
- void prepend(const T *item) { impl.prepend(item); }
-
- unsigned containsRef(const T *item) const { return impl.containsRef(item); }
- int findRef(const T *item) { return impl.findRef(item); }
-
- typedef DeprecatedPtrListIterator<T> Iterator;
- typedef DeprecatedPtrListIterator<T> ConstIterator;
- ConstIterator begin() const { return ConstIterator(*this); }
- ConstIterator end() const { ConstIterator itr(*this); itr.toLast(); ++itr; return itr; }
-
- bool autoDelete() const { return del_item; }
- void setAutoDelete(bool autoDelete) { del_item = autoDelete; }
-
- private:
- static void deleteFunc(void *item) { delete (T *)item; }
-
- friend class DeprecatedPtrListIterator<T>;
-
- DeprecatedPtrListImpl impl;
- bool del_item;
-};
-
-template <class T> class DeprecatedPtrListIterator {
-public:
- DeprecatedPtrListIterator() { }
- DeprecatedPtrListIterator(const DeprecatedPtrList<T> &l) : impl(l.impl) { }
-
- unsigned count() const { return impl.count(); }
- T *toFirst() { return (T *)impl.toFirst(); }
- T *toLast() { return (T *)impl.toLast(); }
- T *current() const { return (T *)impl.current(); }
-
- operator T *() const { return (T *)impl.current(); }
- T *operator*() const { return (T *)impl.current(); }
- T *operator--() { return (T *)--impl; }
- T *operator++() { return (T *)++impl; }
-
-private:
- DeprecatedPtrListImplIterator impl;
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/DeprecatedPtrListImpl.cpp b/WebCore/platform/DeprecatedPtrListImpl.cpp
deleted file mode 100644
index b3badc2..0000000
--- a/WebCore/platform/DeprecatedPtrListImpl.cpp
+++ /dev/null
@@ -1,514 +0,0 @@
-/*
- * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "DeprecatedPtrListImpl.h"
-
-#include <cstddef>
-#include <algorithm>
-#include <wtf/Assertions.h>
-
-namespace WebCore {
-
-class DeprecatedListNode
-{
-public:
- DeprecatedListNode(void *d) : data(d), next(0), prev(0) { }
-
- void *data;
- DeprecatedListNode *next;
- DeprecatedListNode *prev;
-};
-
-
-static DeprecatedListNode *copyList(DeprecatedListNode *l, DeprecatedListNode *&tail)
-{
- DeprecatedListNode *node = l;
- DeprecatedListNode *copyHead = 0;
- DeprecatedListNode *last = 0;
-
- while (node != 0) {
- DeprecatedListNode *copy = new DeprecatedListNode(node->data);
- if (last != 0) {
- last->next = copy;
- } else {
- copyHead = copy;
- }
-
- copy->prev = last;
-
- last = copy;
- node = node->next;
- }
-
- tail = last;
- return copyHead;
-}
-
-
-DeprecatedPtrListImpl::DeprecatedPtrListImpl(void (*deleteFunc)(void *)) :
- head(0),
- tail(0),
- cur(0),
- nodeCount(0),
- deleteItem(deleteFunc),
- iterators(0)
-{
-}
-
-DeprecatedPtrListImpl::DeprecatedPtrListImpl(const DeprecatedPtrListImpl &impl) :
- cur(0),
- nodeCount(impl.nodeCount),
- deleteItem(impl.deleteItem),
- iterators(0)
-{
- head = copyList(impl.head, tail);
-}
-
-DeprecatedPtrListImpl::~DeprecatedPtrListImpl()
-{
- clear(false);
-
- DeprecatedPtrListImplIterator *next;
- for (DeprecatedPtrListImplIterator *it = iterators; it; it = next) {
- next = it->next;
- it->list = 0;
- ASSERT(!it->node);
- it->next = 0;
- it->prev = 0;
- }
-}
-
-void DeprecatedPtrListImpl::clear(bool deleteItems)
-{
- DeprecatedListNode *next;
-
- for (DeprecatedListNode *node = head; node; node = next) {
- next = node->next;
- if (deleteItems)
- deleteItem(node->data);
- delete node;
- }
-
- head = 0;
- tail = 0;
- cur = 0;
- nodeCount = 0;
-
- for (DeprecatedPtrListImplIterator *it = iterators; it; it = it->next)
- it->node = 0;
-}
-
-void *DeprecatedPtrListImpl::at(unsigned n)
-{
- DeprecatedListNode *node;
- if (n >= nodeCount - 1) {
- node = tail;
- } else {
- node = head;
- for (unsigned i = 0; i < n && node; i++) {
- node = node->next;
- }
- }
-
- cur = node;
- return node ? node->data : 0;
-}
-
-bool DeprecatedPtrListImpl::insert(unsigned n, const void *item)
-{
- if (n > nodeCount) {
- return false;
- }
-
- DeprecatedListNode *node = new DeprecatedListNode((void *)item);
-
- if (n == 0) {
- // inserting at head
- node->next = head;
- if (head) {
- head->prev = node;
- }
- head = node;
- if (tail == 0) {
- tail = node;
- }
- } else if (n == nodeCount) {
- // inserting at tail
- node->prev = tail;
- if (tail) {
- tail->next = node;
- }
- tail = node;
- } else {
- // general insertion
-
- // iterate to one node before the insertion point, can't be null
- // since we know n > 0 and n < nodeCount
- DeprecatedListNode *prevNode = head;
-
- for (unsigned i = 0; i < n - 1; i++) {
- prevNode = prevNode->next;
- }
- node->prev = prevNode;
- node->next = prevNode->next;
- if (node->next) {
- node->next->prev = node;
- }
- prevNode->next = node;
- }
-
- nodeCount++;
- cur = node;
- return true;
-}
-
-bool DeprecatedPtrListImpl::remove(bool shouldDeleteItem)
-{
- DeprecatedListNode *node = cur;
- if (node == 0) {
- return false;
- }
-
- if (node->prev == 0) {
- head = node->next;
- } else {
- node->prev->next = node->next;
- }
-
- if (node->next == 0) {
- tail = node->prev;
- } else {
- node->next->prev = node->prev;
- }
-
- if (node->next) {
- cur = node->next;
- } else {
- cur = node->prev;
- }
-
- for (DeprecatedPtrListImplIterator *it = iterators; it; it = it->next) {
- if (it->node == node) {
- it->node = cur;
- }
- }
-
- if (shouldDeleteItem) {
- deleteItem(node->data);
- }
- delete node;
-
- nodeCount--;
-
- return true;
-}
-
-bool DeprecatedPtrListImpl::remove(unsigned n, bool deleteItem)
-{
- if (n >= nodeCount) {
- return false;
- }
-
- at(n);
- return remove(deleteItem);
-}
-
-bool DeprecatedPtrListImpl::removeFirst(bool deleteItem)
-{
- return remove(0, deleteItem);
-}
-
-bool DeprecatedPtrListImpl::removeLast(bool deleteItem)
-{
- return remove(nodeCount - 1, deleteItem);
-}
-
-bool DeprecatedPtrListImpl::removeRef(const void *item, bool deleteItem)
-{
- DeprecatedListNode *node;
-
- node = head;
-
- while (node && item != node->data) {
- node = node->next;
- }
-
- if (node == 0) {
- return false;
- }
-
- cur = node;
-
- return remove(deleteItem);
-}
-
-void *DeprecatedPtrListImpl::getFirst() const
-{
- return head ? head->data : 0;
-}
-
-void *DeprecatedPtrListImpl::getLast() const
-{
- return tail ? tail->data : 0;
-}
-
-void *DeprecatedPtrListImpl::getNext() const
-{
- return cur && cur->next ? cur->next->data : 0;
-}
-
-void *DeprecatedPtrListImpl::getPrev() const
-{
- return cur && cur->prev ? cur->prev->data : 0;
-}
-
-void *DeprecatedPtrListImpl::current() const
-{
- if (cur) {
- return cur->data;
- } else {
- return 0;
- }
-}
-
-void *DeprecatedPtrListImpl::first()
-{
- cur = head;
- return current();
-}
-
-void *DeprecatedPtrListImpl::last()
-{
- cur = tail;
- return current();
-}
-
-void *DeprecatedPtrListImpl::next()
-{
- if (cur) {
- cur = cur->next;
- }
- return current();
-}
-
-void *DeprecatedPtrListImpl::prev()
-{
- if (cur) {
- cur = cur->prev;
- }
- return current();
-}
-
-void *DeprecatedPtrListImpl::take(unsigned n)
-{
- void *retval = at(n);
- remove(false);
- return retval;
-}
-
-void *DeprecatedPtrListImpl::take()
-{
- void *retval = current();
- remove(false);
- return retval;
-}
-
-void DeprecatedPtrListImpl::append(const void *item)
-{
- insert(nodeCount, item);
-}
-
-void DeprecatedPtrListImpl::prepend(const void *item)
-{
- insert(0, item);
-}
-
-unsigned DeprecatedPtrListImpl::containsRef(const void *item) const
-{
- unsigned count = 0;
-
- for (DeprecatedListNode *node = head; node; node = node->next) {
- if (item == node->data) {
- ++count;
- }
- }
-
- return count;
-}
-
-int DeprecatedPtrListImpl::findRef(const void *item)
-{
- DeprecatedListNode *node = head;
- int index = 0;
-
- while (node && item != node->data) {
- node = node->next;
- index++;
- }
-
- cur = node;
-
- if (node == 0) {
- return -1;
- }
-
- return index;
-}
-
-DeprecatedPtrListImpl &DeprecatedPtrListImpl::assign(const DeprecatedPtrListImpl &impl, bool deleteItems)
-{
- clear(deleteItems);
- DeprecatedPtrListImpl(impl).swap(*this);
- return *this;
-}
-
-void DeprecatedPtrListImpl::addIterator(DeprecatedPtrListImplIterator *iter) const
-{
- iter->next = iterators;
- iter->prev = 0;
-
- if (iterators) {
- iterators->prev = iter;
- }
- iterators = iter;
-}
-
-void DeprecatedPtrListImpl::removeIterator(DeprecatedPtrListImplIterator *iter) const
-{
- if (iter->prev == 0) {
- iterators = iter->next;
- } else {
- iter->prev->next = iter->next;
- }
-
- if (iter->next) {
- iter->next->prev = iter->prev;
- }
-}
-
-void DeprecatedPtrListImpl::swap(DeprecatedPtrListImpl &other)
-{
- using std::swap;
-
- ASSERT(iterators == 0);
- ASSERT(other.iterators == 0);
-
- swap(head, other.head);
- swap(tail, other.tail);
- swap(cur, other.cur);
- swap(nodeCount, other.nodeCount);
- swap(deleteItem, other.deleteItem);
-}
-
-
-DeprecatedPtrListImplIterator::DeprecatedPtrListImplIterator() :
- list(0),
- node(0)
-{
-}
-
-DeprecatedPtrListImplIterator::DeprecatedPtrListImplIterator(const DeprecatedPtrListImpl &impl) :
- list(&impl),
- node(impl.head)
-{
- impl.addIterator(this);
-}
-
-DeprecatedPtrListImplIterator::~DeprecatedPtrListImplIterator()
-{
- if (list) {
- list->removeIterator(this);
- }
-}
-
-DeprecatedPtrListImplIterator::DeprecatedPtrListImplIterator(const DeprecatedPtrListImplIterator &impl) :
- list(impl.list),
- node(impl.node)
-{
- if (list) {
- list->addIterator(this);
- }
-}
-
-unsigned DeprecatedPtrListImplIterator::count() const
-{
- return list == 0 ? 0 : list->count();
-}
-
-void *DeprecatedPtrListImplIterator::toFirst()
-{
- if (list) {
- node = list->head;
- }
- return current();
-}
-
-void *DeprecatedPtrListImplIterator::toLast()
-{
- if (list) {
- node = list->tail;
- }
- return current();
-}
-
-void *DeprecatedPtrListImplIterator::current() const
-{
- return node == 0 ? 0 : node->data;
-}
-
-void *DeprecatedPtrListImplIterator::operator--()
-{
- if (node) {
- node = node->prev;
- }
- return current();
-}
-
-void *DeprecatedPtrListImplIterator::operator++()
-{
- if (node) {
- node = node->next;
- }
- return current();
-}
-
-DeprecatedPtrListImplIterator &DeprecatedPtrListImplIterator::operator=(const DeprecatedPtrListImplIterator &impl)
-{
- if (list) {
- list->removeIterator(this);
- }
-
- list = impl.list;
- node = impl.node;
-
- if (list) {
- list->addIterator(this);
- }
-
- return *this;
-}
-
-}
diff --git a/WebCore/platform/DeprecatedPtrListImpl.h b/WebCore/platform/DeprecatedPtrListImpl.h
deleted file mode 100644
index 5e4121b..0000000
--- a/WebCore/platform/DeprecatedPtrListImpl.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (C) 2003 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef DeprecatedPtrListImpl_h
-#define DeprecatedPtrListImpl_h
-
-namespace WebCore {
-
-class DeprecatedListNode;
-class DeprecatedPtrListImplIterator;
-
-class DeprecatedPtrListImpl
-{
-public:
-
- DeprecatedPtrListImpl(void (*deleteFunc)(void *));
- DeprecatedPtrListImpl(const DeprecatedPtrListImpl &impl);
- ~DeprecatedPtrListImpl();
-
- bool isEmpty() const { return nodeCount == 0; }
- unsigned count() const { return nodeCount; }
- void clear(bool deleteItems);
-
- void *at(unsigned n);
-
- bool insert(unsigned n, const void *item);
- bool remove(bool deleteItem);
- bool remove(unsigned n, bool deleteItem);
- bool removeFirst(bool deleteItem);
- bool removeLast(bool deleteItem);
- bool removeRef(const void *item, bool deleteItem);
-
- void *getFirst() const;
- void *getLast() const;
- void *getNext() const;
- void *getPrev() const;
- void *current() const;
- void *first();
- void *last();
- void *next();
- void *prev();
- void *take(unsigned n);
- void *take();
-
- void append(const void *item);
- void prepend(const void *item);
-
- unsigned containsRef(const void *item) const;
- int findRef(const void *item);
-
- DeprecatedPtrListImpl &assign(const DeprecatedPtrListImpl &impl, bool deleteItems);
-
- private:
- DeprecatedPtrListImpl &operator =(const DeprecatedPtrListImpl &impl);
-
- void swap(DeprecatedPtrListImpl &impl);
-
- void addIterator(DeprecatedPtrListImplIterator *iter) const;
- void removeIterator(DeprecatedPtrListImplIterator *iter) const;
-
- DeprecatedListNode *head;
- DeprecatedListNode *tail;
- DeprecatedListNode *cur;
- unsigned nodeCount;
- void (*deleteItem)(void *);
- mutable DeprecatedPtrListImplIterator *iterators;
-
- friend class DeprecatedPtrListImplIterator;
-};
-
-
-class DeprecatedPtrListImplIterator {
-public:
- DeprecatedPtrListImplIterator();
- DeprecatedPtrListImplIterator(const DeprecatedPtrListImpl &impl);
- ~DeprecatedPtrListImplIterator();
-
- DeprecatedPtrListImplIterator(const DeprecatedPtrListImplIterator &impl);
- DeprecatedPtrListImplIterator &operator=(const DeprecatedPtrListImplIterator &impl);
-
- unsigned count() const;
- void *toFirst();
- void *toLast();
- void *current() const;
-
- void *operator--();
- void *operator++();
-
-private:
- const DeprecatedPtrListImpl *list;
- DeprecatedListNode *node;
- DeprecatedPtrListImplIterator *next;
- DeprecatedPtrListImplIterator *prev;
-
- friend class DeprecatedPtrListImpl;
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/DeprecatedPtrQueue.h b/WebCore/platform/DeprecatedPtrQueue.h
deleted file mode 100644
index 226cb18..0000000
--- a/WebCore/platform/DeprecatedPtrQueue.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2003 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef DeprecatedPtrQueue_h
-#define DeprecatedPtrQueue_h
-
-#include "DeprecatedPtrList.h"
-
-namespace WebCore {
-
-template<class T> class DeprecatedPtrQueue
-{
-public:
- bool isEmpty() const { return list.isEmpty(); }
- T *dequeue() { T *tmp = list.getFirst(); list.removeFirst(); return tmp; }
- void enqueue(const T *item) { list.append (item); }
- unsigned count() const { return list.count(); }
- T *head() const { return list.getFirst(); }
- DeprecatedPtrQueue<T> &operator=(const DeprecatedPtrQueue<T> &q) { list = q.list; return *this; }
-
- private:
- DeprecatedPtrList<T> list;
-};
-
-}
-
-#endif /* DeprecatedPtrQueue_h */
diff --git a/WebCore/platform/DeprecatedValueList.h b/WebCore/platform/DeprecatedValueList.h
deleted file mode 100644
index 8c00b4b..0000000
--- a/WebCore/platform/DeprecatedValueList.h
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright (C) 2004 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef DeprecatedValueList_h
-#define DeprecatedValueList_h
-
-#include "DeprecatedValueListImpl.h"
-
-namespace WebCore {
-
-template <class T> class DeprecatedValueList;
-template <class T> class DeprecatedValueListConstIterator;
-
-template<class T> class DeprecatedValueListNode : private DeprecatedValueListImplNode {
-public:
- DeprecatedValueListNode(const T &val) : value(val) { }
- T value;
- friend class DeprecatedValueList<T>;
-};
-
-template<class T> class DeprecatedValueListIterator {
-public:
- DeprecatedValueListIterator() { }
-
- T& operator*() const { return ((DeprecatedValueListNode<T> *)impl.node())->value; }
-
- DeprecatedValueListIterator &operator++() { ++impl; return *this; }
- DeprecatedValueListIterator &operator--() { --impl; return *this; }
- DeprecatedValueListIterator operator++(int) { return impl++; }
-
- bool operator==(const DeprecatedValueListIterator &other) { return impl == other.impl; }
- bool operator!=(const DeprecatedValueListIterator &other) { return impl != other.impl; }
-
-private:
- DeprecatedValueListIterator(const DeprecatedValueListImplIterator &pImp) : impl(pImp) { }
-
- DeprecatedValueListImplIterator impl;
-
- friend class DeprecatedValueList<T>;
- friend class DeprecatedValueListConstIterator<T>;
-};
-
-template<class T> class DeprecatedValueListConstIterator {
-public:
- DeprecatedValueListConstIterator() { }
- DeprecatedValueListConstIterator(const DeprecatedValueListIterator<T> &it) : impl(it.impl) { }
-
- const T& operator*() const { return ((const DeprecatedValueListNode<T> *)impl.node())->value; }
-
- DeprecatedValueListConstIterator &operator++() { ++impl; return *this; }
- DeprecatedValueListConstIterator &operator--() { --impl; return *this; }
- DeprecatedValueListConstIterator operator++(int) { return impl++; }
-
- bool operator==(const DeprecatedValueListConstIterator &other) { return impl == other.impl; }
- bool operator!=(const DeprecatedValueListConstIterator &other) { return impl != other.impl; }
-
-private:
- DeprecatedValueListConstIterator(const DeprecatedValueListImplIterator &pImp) : impl(pImp) { }
-
- DeprecatedValueListImplIterator impl;
-
- friend class DeprecatedValueList<T>;
-};
-
-template<class T> bool operator==(const DeprecatedValueList<T> &a, const DeprecatedValueList<T> &b);
-
-template <class T> class DeprecatedValueList {
-public:
- typedef DeprecatedValueListIterator<T> Iterator;
- typedef DeprecatedValueListIterator<T> iterator;
- typedef DeprecatedValueListConstIterator<T> ConstIterator;
- typedef DeprecatedValueListConstIterator<T> const_iterator;
-
- DeprecatedValueList() : impl(deleteNode, copyNode) { }
-
- void clear() { impl.clear(); }
- unsigned count() const { return impl.count(); }
- bool isEmpty() const { return impl.isEmpty(); }
-
- Iterator append(const T &val) { return impl.appendNode(new DeprecatedValueListNode<T>(val)); }
- Iterator prepend(const T &val) { return impl.prependNode(new DeprecatedValueListNode<T>(val)); }
- void remove(const T &val) { DeprecatedValueListNode<T> node(val); impl.removeEqualNodes(&node, nodesEqual); }
- unsigned contains(const T &val) const { DeprecatedValueListNode<T> node(val); return impl.containsEqualNodes(&node, nodesEqual); }
- Iterator find(const T &val) const { DeprecatedValueListNode<T> node(val); return impl.findEqualNode(&node, nodesEqual); }
-
- Iterator insert(Iterator iter, const T& val) { return impl.insert(iter.impl, new DeprecatedValueListNode<T>(val)); }
- Iterator remove(Iterator iter) { return impl.removeIterator(iter.impl); }
- Iterator fromLast() { return impl.fromLast(); }
-
- T& first() { return static_cast<DeprecatedValueListNode<T> *>(impl.firstNode())->value; }
- const T& first() const { return static_cast<DeprecatedValueListNode<T> *>(impl.firstNode())->value; }
- T& last() { return static_cast<DeprecatedValueListNode<T> *>(impl.lastNode())->value; }
- const T& last() const { return static_cast<DeprecatedValueListNode<T> *>(impl.lastNode())->value; }
-
- Iterator begin() { return impl.begin(); }
- Iterator end() { return impl.end(); }
-
- ConstIterator begin() const { return impl.begin(); }
- ConstIterator end() const { return impl.end(); }
- ConstIterator constBegin() const { return impl.begin(); }
- ConstIterator constEnd() const { return impl.end(); }
- ConstIterator fromLast() const { return impl.fromLast(); }
-
- T& operator[] (unsigned index) { return ((DeprecatedValueListNode<T> *)impl.nodeAt(index))->value; }
- const T& operator[] (unsigned index) const { return ((const DeprecatedValueListNode<T> *)impl.nodeAt(index))->value; }
- DeprecatedValueList &operator+=(const T &value) { impl.appendNode(new DeprecatedValueListNode<T>(value)); return *this; }
- DeprecatedValueList &operator<<(const T &value) { impl.appendNode(new DeprecatedValueListNode<T>(value)); return *this; }
-
- friend bool operator==<>(const DeprecatedValueList<T> &, const DeprecatedValueList<T> &);
-
-private:
- DeprecatedValueListImpl impl;
-
- static void deleteNode(DeprecatedValueListImplNode *node) { delete (DeprecatedValueListNode<T> *)node; }
- static bool nodesEqual(const DeprecatedValueListImplNode *a, const DeprecatedValueListImplNode *b)
- { return ((DeprecatedValueListNode<T> *)a)->value == ((DeprecatedValueListNode<T> *)b)->value; }
- static DeprecatedValueListImplNode *copyNode(DeprecatedValueListImplNode *node)
- { return new DeprecatedValueListNode<T>(((DeprecatedValueListNode<T> *)node)->value); }
-};
-
-template<class T>
-inline bool operator==(const DeprecatedValueList<T> &a, const DeprecatedValueList<T> &b)
-{
- return a.impl.isEqual(b.impl, DeprecatedValueList<T>::nodesEqual);
-}
-
-}
-
-#endif
diff --git a/WebCore/platform/DeprecatedValueListImpl.cpp b/WebCore/platform/DeprecatedValueListImpl.cpp
deleted file mode 100644
index dc8c660..0000000
--- a/WebCore/platform/DeprecatedValueListImpl.cpp
+++ /dev/null
@@ -1,407 +0,0 @@
-/*
- * Copyright (C) 2003, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "DeprecatedValueListImpl.h"
-
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <stdlib.h>
-
-namespace WebCore {
-
-class DeprecatedValueListImpl::Private : public RefCounted<DeprecatedValueListImpl::Private> {
-public:
- Private(void (*deleteFunc)(DeprecatedValueListImplNode *), DeprecatedValueListImplNode *(*copyFunc)(DeprecatedValueListImplNode *));
- Private(const Private &other);
-
- ~Private();
-
- void copyList(DeprecatedValueListImplNode *l, DeprecatedValueListImplNode *&head, DeprecatedValueListImplNode *&tail) const;
- void deleteList(DeprecatedValueListImplNode *l);
-
- DeprecatedValueListImplNode *head;
- DeprecatedValueListImplNode *tail;
-
- void (*deleteNode)(DeprecatedValueListImplNode *);
- DeprecatedValueListImplNode *(*copyNode)(DeprecatedValueListImplNode *);
- unsigned count;
-};
-
-inline DeprecatedValueListImpl::Private::Private(void (*deleteFunc)(DeprecatedValueListImplNode*),
- DeprecatedValueListImplNode* (*copyFunc)(DeprecatedValueListImplNode*))
- : head(NULL)
- , tail(NULL)
- , deleteNode(deleteFunc)
- , copyNode(copyFunc)
- , count(0)
-{
-}
-
-inline DeprecatedValueListImpl::Private::Private(const Private &other)
- : RefCounted<Private>()
- , deleteNode(other.deleteNode)
- , copyNode(other.copyNode)
- , count(other.count)
-{
- other.copyList(other.head, head, tail);
-}
-
-inline DeprecatedValueListImpl::Private::~Private()
-{
- deleteList(head);
-}
-
-void DeprecatedValueListImpl::Private::copyList(DeprecatedValueListImplNode *l, DeprecatedValueListImplNode *&head, DeprecatedValueListImplNode *&tail) const
-{
- DeprecatedValueListImplNode *prev = NULL;
- DeprecatedValueListImplNode *node = l;
-
- head = NULL;
-
- while (node != NULL) {
- DeprecatedValueListImplNode *copy = copyNode(node);
- if (prev == NULL) {
- head = copy;
- } else {
- prev->next = copy;
- }
-
- copy->prev = prev;
- copy->next = NULL;
-
- prev = copy;
- node = node->next;
- }
-
- tail = prev;
-}
-
-void DeprecatedValueListImpl::Private::deleteList(DeprecatedValueListImplNode *l)
-{
- DeprecatedValueListImplNode *p = l;
-
- while (p != NULL) {
- DeprecatedValueListImplNode *next = p->next;
- deleteNode(p);
- p = next;
- }
-}
-
-DeprecatedValueListImpl::DeprecatedValueListImpl(void (*deleteFunc)(DeprecatedValueListImplNode *), DeprecatedValueListImplNode *(*copyFunc)(DeprecatedValueListImplNode *)) :
- d(adoptRef(new Private(deleteFunc, copyFunc)))
-{
-}
-
-DeprecatedValueListImpl::DeprecatedValueListImpl(const DeprecatedValueListImpl &other) :
- d(other.d)
-{
-}
-
-DeprecatedValueListImpl::~DeprecatedValueListImpl()
-{
-}
-
-void DeprecatedValueListImpl::clear()
-{
- if (d->head) {
- copyOnWrite();
- d->deleteList(d->head);
- d->head = NULL;
- d->tail = NULL;
- d->count = 0;
- }
-}
-
-unsigned DeprecatedValueListImpl::count() const
-{
- return d->count;
-}
-
-bool DeprecatedValueListImpl::isEmpty() const
-{
- return d->count == 0;
-}
-
-DeprecatedValueListImplIterator DeprecatedValueListImpl::appendNode(DeprecatedValueListImplNode *node)
-{
- copyOnWrite();
-
- node->next = NULL;
- node->prev = d->tail;
- d->tail = node;
-
- if (d->head == NULL) {
- d->head = node;
- } else {
- node->prev->next = node;
- }
-
- d->count++;
-
- return node;
-}
-
-DeprecatedValueListImplIterator DeprecatedValueListImpl::prependNode(DeprecatedValueListImplNode *node)
-{
- copyOnWrite();
-
- node->next = d->head;
- node->prev = NULL;
- d->head = node;
-
- if (d->tail == NULL) {
- d->tail = node;
- } else {
- node->next->prev = node;
- }
-
- d->count++;
-
- return node;
-}
-
-void DeprecatedValueListImpl::removeEqualNodes(DeprecatedValueListImplNode *node, bool (*equalFunc)(const DeprecatedValueListImplNode *, const DeprecatedValueListImplNode *))
-{
- copyOnWrite();
-
- DeprecatedValueListImplNode *next;
- for (DeprecatedValueListImplNode *p = d->head; p != NULL; p = next) {
- next = p->next;
- if (equalFunc(node, p)) {
- if (p->next != NULL) {
- p->next->prev = p->prev;
- } else {
- d->tail = p->prev;
- }
-
- if (p->prev != NULL) {
- p->prev->next = p->next;
- } else {
- d->head = p->next;
- }
-
- d->deleteNode(p);
-
- d->count--;
- }
- }
-}
-
-unsigned DeprecatedValueListImpl::containsEqualNodes(DeprecatedValueListImplNode *node, bool (*equalFunc)(const DeprecatedValueListImplNode *, const DeprecatedValueListImplNode *)) const
-{
- unsigned contains = 0;
-
- for (DeprecatedValueListImplNode *p = d->head; p != NULL; p = p->next) {
- if (equalFunc(node, p)) {
- ++contains;
- }
- }
-
- return contains;
-}
-
-DeprecatedValueListImplIterator DeprecatedValueListImpl::findEqualNode(DeprecatedValueListImplNode *node, bool (*equalFunc)(const DeprecatedValueListImplNode *, const DeprecatedValueListImplNode *)) const
-{
- DeprecatedValueListImplIterator it = begin();
- DeprecatedValueListImplIterator endIt = end();
- while (it != endIt) {
- if (equalFunc(node, it.node())) {
- break;
- }
- it++;
- }
- return it;
-}
-
-DeprecatedValueListImplIterator DeprecatedValueListImpl::insert(const DeprecatedValueListImplIterator &iterator, DeprecatedValueListImplNode *node)
-{
- copyOnWrite();
-
- DeprecatedValueListImplNode *next = iterator.nodeImpl;
-
- if (next == NULL)
- return appendNode(node);
-
- if (next == d->head)
- return prependNode(node);
-
- DeprecatedValueListImplNode *prev = next->prev;
-
- node->next = next;
- node->prev = prev;
- next->prev = node;
- prev->next = node;
-
- d->count++;
-
- return node;
-}
-
-DeprecatedValueListImplIterator DeprecatedValueListImpl::removeIterator(DeprecatedValueListImplIterator &iterator)
-{
- copyOnWrite();
-
- if (iterator.nodeImpl == NULL) {
- return iterator;
- }
-
- DeprecatedValueListImplNode *next = iterator.nodeImpl->next;
-
- // detach node
- if (iterator.nodeImpl->next != NULL) {
- iterator.nodeImpl->next->prev = iterator.nodeImpl->prev;
- } else {
- d->tail = iterator.nodeImpl->prev;
- }
- if (iterator.nodeImpl->prev != NULL) {
- iterator.nodeImpl->prev->next = iterator.nodeImpl->next;
- } else {
- d->head = iterator.nodeImpl->next;
- }
-
- d->deleteNode(iterator.nodeImpl);
- d->count--;
-
- return DeprecatedValueListImplIterator(next);
-}
-
-DeprecatedValueListImplIterator DeprecatedValueListImpl::fromLast()
-{
- copyOnWrite();
- return DeprecatedValueListImplIterator(lastNode());
-}
-
-DeprecatedValueListImplNode *DeprecatedValueListImpl::firstNode()
-{
- copyOnWrite();
- return ((const DeprecatedValueListImpl *)this)->firstNode();
-}
-
-DeprecatedValueListImplNode *DeprecatedValueListImpl::lastNode()
-{
- copyOnWrite();
- return ((const DeprecatedValueListImpl *)this)->lastNode();
-}
-
-DeprecatedValueListImplNode *DeprecatedValueListImpl::firstNode() const
-{
- return d->head;
-}
-
-DeprecatedValueListImplNode *DeprecatedValueListImpl::lastNode() const
-{
- return d->tail;
-}
-
-DeprecatedValueListImplIterator DeprecatedValueListImpl::begin()
-{
- copyOnWrite();
- return ((const DeprecatedValueListImpl *)this)->begin();
-}
-
-DeprecatedValueListImplIterator DeprecatedValueListImpl::end()
-{
- copyOnWrite();
- return ((const DeprecatedValueListImpl *)this)->end();
-}
-
-
-DeprecatedValueListImplIterator DeprecatedValueListImpl::begin() const
-{
- return DeprecatedValueListImplIterator(firstNode());
-}
-
-DeprecatedValueListImplIterator DeprecatedValueListImpl::end() const
-{
- return DeprecatedValueListImplIterator(NULL);
-}
-
-DeprecatedValueListImplIterator DeprecatedValueListImpl::fromLast() const
-{
- return DeprecatedValueListImplIterator(lastNode());
-}
-
-DeprecatedValueListImplNode *DeprecatedValueListImpl::nodeAt(unsigned index)
-{
- copyOnWrite();
-
- if (d->count <= index) {
- return NULL;
- }
-
- DeprecatedValueListImplNode *p = d->head;
-
- for (unsigned i = 0; i < index; i++) {
- p = p->next;
- }
-
- return p;
-}
-
-DeprecatedValueListImplNode *DeprecatedValueListImpl::nodeAt(unsigned index) const
-{
- if (d->count <= index) {
- return NULL;
- }
-
- DeprecatedValueListImplNode *p = d->head;
-
- for (unsigned i = 0; i < index; i++) {
- p = p->next;
- }
-
- return p;
-}
-
-DeprecatedValueListImpl& DeprecatedValueListImpl::operator=(const DeprecatedValueListImpl &other)
-{
- DeprecatedValueListImpl tmp(other);
- RefPtr<Private> tmpD = tmp.d;
-
- tmp.d = d;
- d = tmpD;
-
- return *this;
-}
-
-void DeprecatedValueListImpl::copyOnWrite()
-{
- if (!d->hasOneRef())
- d = adoptRef(new Private(*d));
-}
-
-bool DeprecatedValueListImpl::isEqual(const DeprecatedValueListImpl &other, bool (*equalFunc)(const DeprecatedValueListImplNode *, const DeprecatedValueListImplNode *)) const
-{
- DeprecatedValueListImplNode *p, *q;
- for (p = d->head, q = other.d->head; p && q; p = p->next, q = q->next) {
- if (!equalFunc(p, q)) {
- return false;
- }
- }
- return !p && !q;
-}
-
-}
diff --git a/WebCore/platform/DeprecatedValueListImpl.h b/WebCore/platform/DeprecatedValueListImpl.h
deleted file mode 100644
index 108f008..0000000
--- a/WebCore/platform/DeprecatedValueListImpl.h
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Copyright (C) 2003 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef DeprecatedValueListImpl_h
-#define DeprecatedValueListImpl_h
-
-#include <wtf/RefPtr.h>
-
-namespace WebCore {
-
-class DeprecatedValueListImplNode;
-
-class DeprecatedValueListImplIterator
-{
-public:
- DeprecatedValueListImplIterator();
-
- bool operator==(const DeprecatedValueListImplIterator &other);
- bool operator!=(const DeprecatedValueListImplIterator &other);
-
- DeprecatedValueListImplNode *node();
- const DeprecatedValueListImplNode *node() const;
-
- DeprecatedValueListImplIterator& operator++();
- DeprecatedValueListImplIterator operator++(int);
- DeprecatedValueListImplIterator& operator--();
-
-private:
- DeprecatedValueListImplIterator(const DeprecatedValueListImplNode *n);
-
- DeprecatedValueListImplNode *nodeImpl;
-
- friend class DeprecatedValueListImpl;
-};
-
-class DeprecatedValueListImpl
-{
-public:
- DeprecatedValueListImpl(void (*deleteFunc)(DeprecatedValueListImplNode *), DeprecatedValueListImplNode *(*copyNode)(DeprecatedValueListImplNode *));
- ~DeprecatedValueListImpl();
-
- DeprecatedValueListImpl(const DeprecatedValueListImpl&);
- DeprecatedValueListImpl& operator=(const DeprecatedValueListImpl&);
-
- void clear();
- unsigned count() const;
- bool isEmpty() const;
-
- DeprecatedValueListImplIterator appendNode(DeprecatedValueListImplNode *node);
- DeprecatedValueListImplIterator prependNode(DeprecatedValueListImplNode *node);
- void removeEqualNodes(DeprecatedValueListImplNode *node, bool (*equalFunc)(const DeprecatedValueListImplNode *, const DeprecatedValueListImplNode *));
- unsigned containsEqualNodes(DeprecatedValueListImplNode *node, bool (*equalFunc)(const DeprecatedValueListImplNode *, const DeprecatedValueListImplNode *)) const;
-
- DeprecatedValueListImplIterator findEqualNode(DeprecatedValueListImplNode *node, bool (*equalFunc)(const DeprecatedValueListImplNode *, const DeprecatedValueListImplNode *)) const;
-
- DeprecatedValueListImplIterator insert(const DeprecatedValueListImplIterator &iterator, DeprecatedValueListImplNode* node);
- DeprecatedValueListImplIterator removeIterator(DeprecatedValueListImplIterator &iterator);
- DeprecatedValueListImplIterator fromLast();
-
- DeprecatedValueListImplNode *firstNode();
- DeprecatedValueListImplNode *lastNode();
-
- DeprecatedValueListImplNode *firstNode() const;
- DeprecatedValueListImplNode *lastNode() const;
-
- DeprecatedValueListImplIterator begin();
- DeprecatedValueListImplIterator end();
-
- DeprecatedValueListImplIterator begin() const;
- DeprecatedValueListImplIterator end() const;
- DeprecatedValueListImplIterator fromLast() const;
-
- DeprecatedValueListImplNode *nodeAt(unsigned index);
- DeprecatedValueListImplNode *nodeAt(unsigned index) const;
-
- bool isEqual(const DeprecatedValueListImpl &other, bool (*equalFunc)(const DeprecatedValueListImplNode *, const DeprecatedValueListImplNode *)) const;
-
-private:
- void copyOnWrite();
-
- class Private;
-
- RefPtr<Private> d;
-
- friend class DeprecatedValueListImplNode;
-};
-
-class DeprecatedValueListImplNode
-{
-protected:
- DeprecatedValueListImplNode();
-
-private:
- DeprecatedValueListImplNode *prev;
- DeprecatedValueListImplNode *next;
-
- friend class DeprecatedValueListImpl;
- friend class DeprecatedValueListImplIterator;
- friend class DeprecatedValueListImpl::Private;
-};
-
-inline DeprecatedValueListImplIterator::DeprecatedValueListImplIterator() :
- nodeImpl(NULL)
-{
-}
-
-inline bool DeprecatedValueListImplIterator::operator==(const DeprecatedValueListImplIterator &other)
-{
- return nodeImpl == other.nodeImpl;
-}
-
-inline bool DeprecatedValueListImplIterator::operator!=(const DeprecatedValueListImplIterator &other)
-{
- return nodeImpl != other.nodeImpl;
-}
-
-inline DeprecatedValueListImplNode *DeprecatedValueListImplIterator::node()
-{
- return nodeImpl;
-}
-
-inline const DeprecatedValueListImplNode *DeprecatedValueListImplIterator::node() const
-{
- return nodeImpl;
-}
-
-inline DeprecatedValueListImplIterator& DeprecatedValueListImplIterator::operator++()
-{
- if (nodeImpl != NULL) {
- nodeImpl = nodeImpl->next;
- }
- return *this;
-}
-
-inline DeprecatedValueListImplIterator DeprecatedValueListImplIterator::operator++(int)
-{
- DeprecatedValueListImplIterator tmp(*this);
-
- if (nodeImpl != NULL) {
- nodeImpl = nodeImpl->next;
- }
-
- return tmp;
-}
-
-inline DeprecatedValueListImplIterator& DeprecatedValueListImplIterator::operator--()
-{
- if (nodeImpl != NULL) {
- nodeImpl = nodeImpl->prev;
- }
- return *this;
-}
-
-inline DeprecatedValueListImplIterator::DeprecatedValueListImplIterator(const DeprecatedValueListImplNode *n) :
- nodeImpl((DeprecatedValueListImplNode *)n)
-{
-}
-
-inline DeprecatedValueListImplNode::DeprecatedValueListImplNode() :
- prev(NULL),
- next(NULL)
-{
-}
-
-}
-
-#endif
diff --git a/WebCore/platform/DragData.cpp b/WebCore/platform/DragData.cpp
deleted file mode 100644
index bf2275a..0000000
--- a/WebCore/platform/DragData.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "DragData.h"
-
-namespace WebCore {
-
-#if !PLATFORM(MAC)
-DragData::DragData(DragDataRef data, const IntPoint& clientPosition, const IntPoint& globalPosition,
- DragOperation sourceOperationMask)
- : m_clientPosition(clientPosition)
- , m_globalPosition(globalPosition)
- , m_platformDragData(data)
- , m_draggingSourceOperationMask(sourceOperationMask)
-{
-}
-#endif
-
-}
diff --git a/WebCore/platform/DragData.h b/WebCore/platform/DragData.h
deleted file mode 100644
index a1555e3..0000000
--- a/WebCore/platform/DragData.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef DragData_h
-#define DragData_h
-
-#include "ClipboardAccessPolicy.h"
-#include "Color.h"
-#include "DragActions.h"
-#include "IntPoint.h"
-
-#include <wtf/Forward.h>
-#include <wtf/Vector.h>
-
-#if PLATFORM(MAC)
-#ifdef __OBJC__
-#import <Foundation/Foundation.h>
-#import <AppKit/NSDragging.h>
-typedef id <NSDraggingInfo> DragDataRef;
-#else
-typedef void* DragDataRef;
-#endif
-#elif PLATFORM(QT)
-QT_BEGIN_NAMESPACE
-class QMimeData;
-QT_END_NAMESPACE
-typedef const QMimeData* DragDataRef;
-#elif PLATFORM(WIN)
-typedef struct IDataObject* DragDataRef;
-#elif PLATFORM(WX)
-typedef class wxDataObject* DragDataRef;
-#elif PLATFORM(GTK)
-// FIXME: this should probably be something gdk-specific
-typedef void* DragDataRef;
-#elif defined ANDROID
-typedef void* DragDataRef;
-#elif PLATFORM(CHROMIUM)
-#include "DragDataRef.h"
-#endif
-
-
-namespace WebCore {
-
- class Clipboard;
- class Document;
- class DocumentFragment;
- class KURL;
-
-#if PLATFORM(MAC)
- class PasteboardHelper;
-#endif
-
-
- class DragData {
- public:
-#if PLATFORM(MAC)
- //FIXME: In the future the WebKit functions provided by the helper class should be moved into WebCore,
- //after which this constructor should be removed
- DragData(DragDataRef data, const IntPoint& clientPosition, const IntPoint& globalPosition,
- DragOperation operation, PasteboardHelper*);
-#else
- //clientPosition is taken to be the position of the drag event within the target window, with (0,0) at the top left
- DragData(DragDataRef data, const IntPoint& clientPosition, const IntPoint& globalPosition, DragOperation operation);
-#endif
- const IntPoint& clientPosition() const { return m_clientPosition; }
- const IntPoint& globalPosition() const { return m_globalPosition; }
- DragDataRef platformData() const { return m_platformDragData; }
- DragOperation draggingSourceOperationMask() const { return m_draggingSourceOperationMask; }
- PassRefPtr<Clipboard> createClipboard(ClipboardAccessPolicy) const;
- bool containsURL() const;
- bool containsPlainText() const;
- bool containsCompatibleContent() const;
- String asURL(String* title = 0) const;
- String asPlainText() const;
- void asFilenames(Vector<String>&) const;
- Color asColor() const;
- PassRefPtr<DocumentFragment> asFragment(Document*) const;
- bool canSmartReplace() const;
- bool containsColor() const;
- bool containsFiles() const;
- private:
- IntPoint m_clientPosition;
- IntPoint m_globalPosition;
- DragDataRef m_platformDragData;
- DragOperation m_draggingSourceOperationMask;
-#if PLATFORM(MAC)
- PasteboardHelper* m_pasteboardHelper;
-#endif
-};
-
-} //namespace WebCore
-
-#endif //!DragData_h
-
diff --git a/WebCore/platform/DragImage.cpp b/WebCore/platform/DragImage.cpp
deleted file mode 100644
index adf9a57..0000000
--- a/WebCore/platform/DragImage.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "DragImage.h"
-#include "DragController.h"
-
-#include "Frame.h"
-
-namespace WebCore {
-
-DragImageRef fitDragImageToMaxSize(DragImageRef image, const IntSize& srcSize, const IntSize& size)
-{
- float heightResizeRatio = 0.0f;
- float widthResizeRatio = 0.0f;
- float resizeRatio = -1.0f;
- IntSize originalSize = dragImageSize(image);
-
- if (srcSize.width() > size.width()) {
- widthResizeRatio = size.width() / (float)srcSize.width();
- resizeRatio = widthResizeRatio;
- }
-
- if (srcSize.height() > size.height()) {
- heightResizeRatio = size.height() / (float)srcSize.height();
- if ((resizeRatio < 0.0f) || (resizeRatio > heightResizeRatio))
- resizeRatio = heightResizeRatio;
- }
-
- if (srcSize == originalSize)
- return resizeRatio > 0.0f ? scaleDragImage(image, FloatSize(resizeRatio, resizeRatio)) : image;
-
- // The image was scaled in the webpage so at minimum we must account for that scaling
- float scalex = srcSize.width() / (float)originalSize.width();
- float scaley = srcSize.height() / (float)originalSize.height();
- if (resizeRatio > 0.0f) {
- scalex *= resizeRatio;
- scaley *= resizeRatio;
- }
-
- return scaleDragImage(image, FloatSize(scalex, scaley));
-}
-
-DragImageRef createDragImageForSelection(Frame* frame)
-{
- DragImageRef image = frame->dragImageForSelection();
- if (image)
- dissolveDragImageToFraction(image, DragController::DragImageAlpha);
- return image;
-}
-
-}
diff --git a/WebCore/platform/DragImage.h b/WebCore/platform/DragImage.h
deleted file mode 100644
index de1def0..0000000
--- a/WebCore/platform/DragImage.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef DragImage_h
-#define DragImage_h
-
-#include "IntSize.h"
-#include "FloatSize.h"
-
-#if PLATFORM(MAC)
-#include <wtf/RetainPtr.h>
-#ifdef __OBJC__
-@class NSImage;
-#else
-class NSImage;
-#endif
-#elif PLATFORM(QT)
-QT_BEGIN_NAMESPACE
-class QPixmap;
-QT_END_NAMESPACE
-#elif PLATFORM(WIN)
-typedef struct HBITMAP__* HBITMAP;
-#elif PLATFORM(WX)
-class wxDragImage;
-#elif PLATFORM(CHROMIUM)
-#include "DragImageRef.h"
-#endif
-
-//We need to #define YOffset as it needs to be shared with WebKit
-#define DragLabelBorderYOffset 2
-
-namespace WebCore {
-
- class CachedImage;
- class Frame;
- class Image;
- class KURL;
- class Range;
- class String;
-
-#if PLATFORM(MAC)
- typedef RetainPtr<NSImage> DragImageRef;
-#elif PLATFORM(QT)
- typedef QPixmap* DragImageRef;
-#elif PLATFORM(WIN)
- typedef HBITMAP DragImageRef;
-#elif PLATFORM(WX)
- typedef wxDragImage* DragImageRef;
-#elif PLATFORM(GTK)
- typedef void* DragImageRef;
-#elif defined ANDROID
- typedef void* DragImageRef;
-#endif
-
- IntSize dragImageSize(DragImageRef);
-
- //These functions should be memory neutral, eg. if they return a newly allocated image,
- //they should release the input image. As a corollary these methods don't guarantee
- //the input image ref will still be valid after they have been called
- DragImageRef fitDragImageToMaxSize(DragImageRef image, const IntSize& srcSize, const IntSize& size);
- DragImageRef scaleDragImage(DragImageRef, FloatSize scale);
- DragImageRef dissolveDragImageToFraction(DragImageRef image, float delta);
-
- DragImageRef createDragImageFromImage(Image*);
- DragImageRef createDragImageForSelection(Frame*);
- DragImageRef createDragImageIconForCachedImage(CachedImage*);
- void deleteDragImage(DragImageRef);
-}
-
-
-#endif //!DragImage_h
diff --git a/WebCore/platform/EventLoop.h b/WebCore/platform/EventLoop.h
deleted file mode 100644
index 6687c23..0000000
--- a/WebCore/platform/EventLoop.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef EventLoop_h
-#define EventLoop_h
-
-#include <wtf/Noncopyable.h>
-
-namespace WebCore {
-
- class EventLoop : Noncopyable {
- public:
- EventLoop()
- : m_ended(false)
- {
- }
-
- void cycle();
- bool ended() const { return m_ended; }
-
- private:
- bool m_ended;
- };
-
-} // namespace WebCore
-
-#endif // EventLoop_h
diff --git a/WebCore/platform/FileChooser.cpp b/WebCore/platform/FileChooser.cpp
deleted file mode 100644
index 1aeefb9..0000000
--- a/WebCore/platform/FileChooser.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FileChooser.h"
-
-#include "Icon.h"
-
-namespace WebCore {
-
-FileChooserClient::~FileChooserClient()
-{
-}
-
-inline FileChooser::FileChooser(FileChooserClient* client, const String& filename)
- : m_client(client)
- , m_icon(chooseIcon(filename))
-{
- m_filenames.append(filename);
-}
-
-PassRefPtr<FileChooser> FileChooser::create(FileChooserClient* client, const String& filename)
-{
- return adoptRef(new FileChooser(client, filename));
-}
-
-FileChooser::~FileChooser()
-{
-}
-
-void FileChooser::clear()
-{
- m_filenames.clear();
- m_icon = 0;
-}
-
-void FileChooser::chooseFile(const String& filename)
-{
- if (m_filenames.size() == 1 && m_filenames[0] == filename)
- return;
- m_filenames.clear();
- m_filenames.append(filename);
- m_icon = chooseIcon(filename);
- if (m_client)
- m_client->valueChanged();
-}
-
-void FileChooser::chooseFiles(const Vector<String>& filenames)
-{
- m_filenames = filenames;
- m_icon = chooseIcon(filenames);
- if (m_client)
- m_client->valueChanged();
-}
-
-PassRefPtr<Icon> FileChooser::chooseIcon(const String& filename)
-{
- return Icon::createIconForFile(filename);
-}
-
-PassRefPtr<Icon> FileChooser::chooseIcon(Vector<String> filenames)
-{
- if (filenames.size() == 1)
- return Icon::createIconForFile(filenames[0]);
- return Icon::createIconForFiles(filenames);
-}
-
-}
diff --git a/WebCore/platform/FileChooser.h b/WebCore/platform/FileChooser.h
deleted file mode 100644
index 8192fe8..0000000
--- a/WebCore/platform/FileChooser.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#ifndef FileChooser_h
-#define FileChooser_h
-
-#include "PlatformString.h"
-#include <wtf/Vector.h>
-
-namespace WebCore {
-
-class Font;
-class Icon;
-
-class FileChooserClient {
-public:
- virtual void valueChanged() = 0;
- virtual bool allowsMultipleFiles() = 0;
- virtual ~FileChooserClient();
-};
-
-class FileChooser : public RefCounted<FileChooser> {
-public:
- static PassRefPtr<FileChooser> create(FileChooserClient*, const String& initialFilename);
- ~FileChooser();
-
- void disconnectClient() { m_client = 0; }
- bool disconnected() { return !m_client; }
-
- const Vector<String>& filenames() const { return m_filenames; }
- String basenameForWidth(const Font&, int width) const;
-
- Icon* icon() const { return m_icon.get(); }
-
- void clear(); // for use by client; does not call valueChanged
-
- void chooseFile(const String& path);
- void chooseFiles(const Vector<String>& paths);
-
- bool allowsMultipleFiles() const { return m_client ? m_client->allowsMultipleFiles() : false; }
-
-private:
- FileChooser(FileChooserClient*, const String& initialfilename);
- static PassRefPtr<Icon> chooseIcon(const String& filename);
- static PassRefPtr<Icon> chooseIcon(Vector<String> filenames);
-
- FileChooserClient* m_client;
- Vector<String> m_filenames;
- RefPtr<Icon> m_icon;
-};
-
-} // namespace WebCore
-
-#endif // FileChooser_h
diff --git a/WebCore/platform/FileSystem.h b/WebCore/platform/FileSystem.h
deleted file mode 100644
index a3d5d2d..0000000
--- a/WebCore/platform/FileSystem.h
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2008 Collabora, Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef FileSystem_h
-#define FileSystem_h
-
-#if PLATFORM(GTK)
-#include <gmodule.h>
-#endif
-#if PLATFORM(QT)
-#include <QFile>
-#include <QLibrary>
-#if defined(Q_OS_WIN32)
-#include <windows.h>
-#endif
-#endif
-
-#if PLATFORM(DARWIN)
-#include <CoreFoundation/CFBundle.h>
-#endif
-
-#include <time.h>
-
-#include <wtf/Platform.h>
-#include <wtf/Vector.h>
-
-#include "PlatformString.h"
-
-typedef const struct __CFData* CFDataRef;
-
-#if PLATFORM(WIN)
-// These are to avoid including <winbase.h> in a header for Chromium
-typedef void *HANDLE;
-// Assuming STRICT
-typedef struct HINSTANCE__* HINSTANCE;
-typedef HINSTANCE HMODULE;
-#endif
-
-namespace WebCore {
-
-class CString;
-
-#if PLATFORM(WIN)
-typedef HANDLE PlatformFileHandle;
-typedef HMODULE PlatformModule;
-// FIXME: -1 is INVALID_HANDLE_VALUE, defined in <winbase.h>. Chromium tries to
-// avoid using Windows headers in headers. We'd rather move this into the .cpp.
-const PlatformFileHandle invalidPlatformFileHandle = reinterpret_cast<HANDLE>(-1);
-
-struct PlatformModuleVersion {
- unsigned leastSig;
- unsigned mostSig;
-
- PlatformModuleVersion(unsigned)
- : leastSig(0)
- , mostSig(0)
- {
- }
-
- PlatformModuleVersion(unsigned lsb, unsigned msb)
- : leastSig(lsb)
- , mostSig(msb)
- {
- }
-
-};
-#elif PLATFORM(QT)
-
-typedef QFile* PlatformFileHandle;
-const PlatformFileHandle invalidPlatformFileHandle = 0;
-#if defined(Q_WS_MAC)
-typedef CFBundleRef PlatformModule;
-typedef unsigned PlatformModuleVersion;
-#elif defined(Q_WS_X11) || defined(Q_WS_QWS)
-typedef QLibrary* PlatformModule;
-typedef unsigned PlatformModuleVersion;
-#elif defined(Q_OS_WIN32)
-typedef HMODULE PlatformModule;
-struct PlatformModuleVersion {
- unsigned leastSig;
- unsigned mostSig;
-
- PlatformModuleVersion(unsigned)
- : leastSig(0)
- , mostSig(0)
- {
- }
-
- PlatformModuleVersion(unsigned lsb, unsigned msb)
- : leastSig(lsb)
- , mostSig(msb)
- {
- }
-
-};
-#endif
-
-#else
-typedef int PlatformFileHandle;
-#if PLATFORM(GTK)
-typedef GModule* PlatformModule;
-#else
-typedef void* PlatformModule;
-#endif
-const PlatformFileHandle invalidPlatformFileHandle = -1;
-
-typedef unsigned PlatformModuleVersion;
-#endif
-
-bool fileExists(const String&);
-bool deleteFile(const String&);
-bool deleteEmptyDirectory(const String&);
-bool getFileSize(const String&, long long& result);
-bool getFileModificationTime(const String&, time_t& result);
-String pathByAppendingComponent(const String& path, const String& component);
-bool makeAllDirectories(const String& path);
-String homeDirectoryPath();
-String pathGetFileName(const String&);
-String directoryName(const String&);
-
-Vector<String> listDirectory(const String& path, const String& filter = String());
-
-CString fileSystemRepresentation(const String&);
-
-inline bool isHandleValid(const PlatformFileHandle& handle) { return handle != invalidPlatformFileHandle; }
-
-// Prefix is what the filename should be prefixed with, not the full path.
-CString openTemporaryFile(const char* prefix, PlatformFileHandle&);
-void closeFile(PlatformFileHandle&);
-int writeToFile(PlatformFileHandle, const char* data, int length);
-
-// Methods for dealing with loadable modules
-bool unloadModule(PlatformModule);
-
-#if PLATFORM(WIN)
-String localUserSpecificStorageDirectory();
-String roamingUserSpecificStorageDirectory();
-
-bool safeCreateFile(const String&, CFDataRef);
-#endif
-
-#if PLATFORM(GTK)
-String filenameToString(const char*);
-char* filenameFromString(const String&);
-String filenameForDisplay(const String&);
-#endif
-
-} // namespace WebCore
-
-#endif // FileSystem_h
diff --git a/WebCore/platform/FloatConversion.h b/WebCore/platform/FloatConversion.h
deleted file mode 100644
index 9b26597..0000000
--- a/WebCore/platform/FloatConversion.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef FloatConversion_h
-#define FloatConversion_h
-
-#include <wtf/Platform.h>
-#if PLATFORM(CG)
-#include <CoreGraphics/CGBase.h>
-#endif
-
-namespace WebCore {
-
- template<typename T>
- float narrowPrecisionToFloat(T);
-
- template<>
- inline float narrowPrecisionToFloat(double number)
- {
- return static_cast<float>(number);
- }
-
-#if PLATFORM(CG)
- template<typename T>
- CGFloat narrowPrecisionToCGFloat(T);
-
- template<>
- inline CGFloat narrowPrecisionToCGFloat(double number)
- {
- return static_cast<CGFloat>(number);
- }
-#endif
-
-} // namespace WebCore
-
-#endif // FloatConversion_h
diff --git a/WebCore/platform/GeolocationService.cpp b/WebCore/platform/GeolocationService.cpp
deleted file mode 100644
index dfd5a5c..0000000
--- a/WebCore/platform/GeolocationService.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "GeolocationService.h"
-
-#include "Geoposition.h"
-#include "PositionError.h"
-#include "PositionOptions.h"
-
-namespace WebCore {
-
-#if !ENABLE(GEOLOCATION)
-GeolocationService* GeolocationService::create(GeolocationServiceClient*)
-{
- return 0;
-}
-#endif
-
-GeolocationService::GeolocationService(GeolocationServiceClient* client)
- : m_geolocationServiceClient(client)
-{
- ASSERT(m_geolocationServiceClient);
-}
-
-void GeolocationService::positionChanged()
-{
- m_geolocationServiceClient->geolocationServicePositionChanged(this);
-}
-
-void GeolocationService::errorOccurred()
-{
- m_geolocationServiceClient->geolocationServiceErrorOccurred(this);
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/GeolocationService.h b/WebCore/platform/GeolocationService.h
deleted file mode 100644
index 90d52eb..0000000
--- a/WebCore/platform/GeolocationService.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GeolocationService_h
-#define GeolocationService_h
-
-#include <wtf/Noncopyable.h>
-
-namespace WebCore {
-
-class GeolocationService;
-class Geoposition;
-class PositionError;
-class PositionOptions;
-
-class GeolocationServiceClient {
-public:
- virtual ~GeolocationServiceClient() { }
- virtual void geolocationServicePositionChanged(GeolocationService*) { }
- virtual void geolocationServiceErrorOccurred(GeolocationService*) { }
-};
-
-class GeolocationService : public Noncopyable {
-public:
- static GeolocationService* create(GeolocationServiceClient*);
- virtual ~GeolocationService() {}
-
- virtual bool startUpdating(PositionOptions*) { return false; }
- virtual void stopUpdating() {}
-
- virtual void suspend() { }
- virtual void resume() { }
-
- virtual Geoposition* lastPosition() const { return 0; }
- virtual PositionError* lastError() const { return 0; }
-
- void positionChanged();
- void errorOccurred();
-
-protected:
- GeolocationService(GeolocationServiceClient*);
-
-private:
- GeolocationServiceClient* m_geolocationServiceClient;
-};
-
-} // namespace WebCore
-
-#endif // GeolocationService_h
diff --git a/WebCore/platform/HostWindow.h b/WebCore/platform/HostWindow.h
deleted file mode 100644
index 761e3d7..0000000
--- a/WebCore/platform/HostWindow.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef HostWindow_h
-#define HostWindow_h
-
-#include <wtf/Noncopyable.h>
-#include "IntRect.h"
-#include "Widget.h"
-
-namespace WebCore {
-
-class IntPoint;
-class IntRect;
-
-class HostWindow : Noncopyable {
-public:
- HostWindow() {}
- virtual ~HostWindow() {}
-
- // The repaint method asks the host window to repaint a rect in the window's coordinate space. The
- // contentChanged boolean indicates whether or not the Web page content actually changed (or if a repaint
- // of unchanged content is being requested).
- virtual void repaint(const IntRect&, bool contentChanged, bool immediate = false, bool repaintContentOnly = false) = 0;
- virtual void scroll(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect) = 0;
-
- // The paint method just causes a synchronous update of the window to happen for platforms that need it (Windows).
- void paint() { repaint(IntRect(), false, true); }
-
- // Methods for doing coordinate conversions to and from screen coordinates.
- virtual IntPoint screenToWindow(const IntPoint&) const = 0;
- virtual IntRect windowToScreen(const IntRect&) const = 0;
-
- // Method for retrieving the native window.
- virtual PlatformWidget platformWindow() const = 0;
-};
-
-} // namespace WebCore
-
-#endif // HostWindow_h
diff --git a/WebCore/platform/KURL.cpp b/WebCore/platform/KURL.cpp
deleted file mode 100644
index 1f33297..0000000
--- a/WebCore/platform/KURL.cpp
+++ /dev/null
@@ -1,1577 +0,0 @@
-/*
- * Copyright (C) 2004, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "KURL.h"
-
-#include "CString.h"
-#include "PlatformString.h"
-#include "TextEncoding.h"
-
-#if USE(ICU_UNICODE)
-#include <unicode/uidna.h>
-#elif USE(QT4_UNICODE)
-#include <QUrl>
-#endif
-
-#include <stdio.h>
-
-using namespace std;
-using namespace WTF;
-
-namespace WebCore {
-
-typedef Vector<char, 512> CharBuffer;
-typedef Vector<UChar, 512> UCharBuffer;
-
-// FIXME: This file makes too much use of the + operator on String.
-// We either have to optimize that operator so it doesn't involve
-// so many allocations, or change this to use Vector<UChar> instead.
-
-enum URLCharacterClasses {
- // alpha
- SchemeFirstChar = 1 << 0,
-
- // ( alpha | digit | "+" | "-" | "." )
- SchemeChar = 1 << 1,
-
- // mark = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")"
- // unreserved = alphanum | mark
- // ( unreserved | escaped | ";" | ":" | "&" | "=" | "+" | "$" | "," )
- UserInfoChar = 1 << 2,
-
- // alnum | "." | "-" | "%"
- // The above is what the specification says, but we are lenient to
- // match existing practice and also allow:
- // "_"
- HostnameChar = 1 << 3,
-
- // hexdigit | ":" | "%"
- IPv6Char = 1 << 4,
-
- // "#" | "?" | "/" | nul
- PathSegmentEndChar = 1 << 5,
-
- // not allowed in path
- BadChar = 1 << 6
-};
-
-static const char hexDigits[17] = "0123456789ABCDEF";
-
-static const unsigned char characterClassTable[256] = {
- /* 0 nul */ PathSegmentEndChar, /* 1 soh */ BadChar,
- /* 2 stx */ BadChar, /* 3 etx */ BadChar,
- /* 4 eot */ BadChar, /* 5 enq */ BadChar, /* 6 ack */ BadChar, /* 7 bel */ BadChar,
- /* 8 bs */ BadChar, /* 9 ht */ BadChar, /* 10 nl */ BadChar, /* 11 vt */ BadChar,
- /* 12 np */ BadChar, /* 13 cr */ BadChar, /* 14 so */ BadChar, /* 15 si */ BadChar,
- /* 16 dle */ BadChar, /* 17 dc1 */ BadChar, /* 18 dc2 */ BadChar, /* 19 dc3 */ BadChar,
- /* 20 dc4 */ BadChar, /* 21 nak */ BadChar, /* 22 syn */ BadChar, /* 23 etb */ BadChar,
- /* 24 can */ BadChar, /* 25 em */ BadChar, /* 26 sub */ BadChar, /* 27 esc */ BadChar,
- /* 28 fs */ BadChar, /* 29 gs */ BadChar, /* 30 rs */ BadChar, /* 31 us */ BadChar,
- /* 32 sp */ BadChar, /* 33 ! */ UserInfoChar,
- /* 34 " */ BadChar, /* 35 # */ PathSegmentEndChar | BadChar,
- /* 36 $ */ UserInfoChar, /* 37 % */ UserInfoChar | HostnameChar | IPv6Char | BadChar,
- /* 38 & */ UserInfoChar, /* 39 ' */ UserInfoChar,
- /* 40 ( */ UserInfoChar, /* 41 ) */ UserInfoChar,
- /* 42 * */ UserInfoChar, /* 43 + */ SchemeChar | UserInfoChar,
- /* 44 , */ UserInfoChar,
- /* 45 - */ SchemeChar | UserInfoChar | HostnameChar,
- /* 46 . */ SchemeChar | UserInfoChar | HostnameChar,
- /* 47 / */ PathSegmentEndChar,
- /* 48 0 */ SchemeChar | UserInfoChar | HostnameChar | IPv6Char,
- /* 49 1 */ SchemeChar | UserInfoChar | HostnameChar | IPv6Char,
- /* 50 2 */ SchemeChar | UserInfoChar | HostnameChar | IPv6Char,
- /* 51 3 */ SchemeChar | UserInfoChar | HostnameChar | IPv6Char,
- /* 52 4 */ SchemeChar | UserInfoChar | HostnameChar | IPv6Char,
- /* 53 5 */ SchemeChar | UserInfoChar | HostnameChar | IPv6Char,
- /* 54 6 */ SchemeChar | UserInfoChar | HostnameChar | IPv6Char,
- /* 55 7 */ SchemeChar | UserInfoChar | HostnameChar | IPv6Char,
- /* 56 8 */ SchemeChar | UserInfoChar | HostnameChar | IPv6Char,
- /* 57 9 */ SchemeChar | UserInfoChar | HostnameChar | IPv6Char,
- /* 58 : */ UserInfoChar | IPv6Char, /* 59 ; */ UserInfoChar,
- /* 60 < */ BadChar, /* 61 = */ UserInfoChar,
- /* 62 > */ BadChar, /* 63 ? */ PathSegmentEndChar | BadChar,
- /* 64 @ */ 0,
- /* 65 A */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar | IPv6Char,
- /* 66 B */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar | IPv6Char,
- /* 67 C */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar | IPv6Char,
- /* 68 D */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar | IPv6Char,
- /* 69 E */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar | IPv6Char,
- /* 70 F */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar | IPv6Char,
- /* 71 G */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
- /* 72 H */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
- /* 73 I */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
- /* 74 J */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
- /* 75 K */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
- /* 76 L */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
- /* 77 M */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
- /* 78 N */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
- /* 79 O */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
- /* 80 P */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
- /* 81 Q */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
- /* 82 R */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
- /* 83 S */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
- /* 84 T */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
- /* 85 U */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
- /* 86 V */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
- /* 87 W */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
- /* 88 X */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
- /* 89 Y */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
- /* 90 Z */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
- /* 91 [ */ 0,
- /* 92 \ */ 0, /* 93 ] */ 0,
- /* 94 ^ */ 0,
- /* 95 _ */ UserInfoChar | HostnameChar,
- /* 96 ` */ 0,
- /* 97 a */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar | IPv6Char,
- /* 98 b */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar | IPv6Char,
- /* 99 c */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar | IPv6Char,
- /* 100 d */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar | IPv6Char,
- /* 101 e */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar | IPv6Char,
- /* 102 f */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar | IPv6Char,
- /* 103 g */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
- /* 104 h */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
- /* 105 i */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
- /* 106 j */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
- /* 107 k */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
- /* 108 l */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
- /* 109 m */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
- /* 110 n */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
- /* 111 o */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
- /* 112 p */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
- /* 113 q */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
- /* 114 r */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
- /* 115 s */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
- /* 116 t */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
- /* 117 u */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
- /* 118 v */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
- /* 119 w */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
- /* 120 x */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
- /* 121 y */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
- /* 122 z */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
- /* 123 { */ 0,
- /* 124 | */ 0, /* 125 } */ 0, /* 126 ~ */ UserInfoChar, /* 127 del */ BadChar,
- /* 128 */ BadChar, /* 129 */ BadChar, /* 130 */ BadChar, /* 131 */ BadChar,
- /* 132 */ BadChar, /* 133 */ BadChar, /* 134 */ BadChar, /* 135 */ BadChar,
- /* 136 */ BadChar, /* 137 */ BadChar, /* 138 */ BadChar, /* 139 */ BadChar,
- /* 140 */ BadChar, /* 141 */ BadChar, /* 142 */ BadChar, /* 143 */ BadChar,
- /* 144 */ BadChar, /* 145 */ BadChar, /* 146 */ BadChar, /* 147 */ BadChar,
- /* 148 */ BadChar, /* 149 */ BadChar, /* 150 */ BadChar, /* 151 */ BadChar,
- /* 152 */ BadChar, /* 153 */ BadChar, /* 154 */ BadChar, /* 155 */ BadChar,
- /* 156 */ BadChar, /* 157 */ BadChar, /* 158 */ BadChar, /* 159 */ BadChar,
- /* 160 */ BadChar, /* 161 */ BadChar, /* 162 */ BadChar, /* 163 */ BadChar,
- /* 164 */ BadChar, /* 165 */ BadChar, /* 166 */ BadChar, /* 167 */ BadChar,
- /* 168 */ BadChar, /* 169 */ BadChar, /* 170 */ BadChar, /* 171 */ BadChar,
- /* 172 */ BadChar, /* 173 */ BadChar, /* 174 */ BadChar, /* 175 */ BadChar,
- /* 176 */ BadChar, /* 177 */ BadChar, /* 178 */ BadChar, /* 179 */ BadChar,
- /* 180 */ BadChar, /* 181 */ BadChar, /* 182 */ BadChar, /* 183 */ BadChar,
- /* 184 */ BadChar, /* 185 */ BadChar, /* 186 */ BadChar, /* 187 */ BadChar,
- /* 188 */ BadChar, /* 189 */ BadChar, /* 190 */ BadChar, /* 191 */ BadChar,
- /* 192 */ BadChar, /* 193 */ BadChar, /* 194 */ BadChar, /* 195 */ BadChar,
- /* 196 */ BadChar, /* 197 */ BadChar, /* 198 */ BadChar, /* 199 */ BadChar,
- /* 200 */ BadChar, /* 201 */ BadChar, /* 202 */ BadChar, /* 203 */ BadChar,
- /* 204 */ BadChar, /* 205 */ BadChar, /* 206 */ BadChar, /* 207 */ BadChar,
- /* 208 */ BadChar, /* 209 */ BadChar, /* 210 */ BadChar, /* 211 */ BadChar,
- /* 212 */ BadChar, /* 213 */ BadChar, /* 214 */ BadChar, /* 215 */ BadChar,
- /* 216 */ BadChar, /* 217 */ BadChar, /* 218 */ BadChar, /* 219 */ BadChar,
- /* 220 */ BadChar, /* 221 */ BadChar, /* 222 */ BadChar, /* 223 */ BadChar,
- /* 224 */ BadChar, /* 225 */ BadChar, /* 226 */ BadChar, /* 227 */ BadChar,
- /* 228 */ BadChar, /* 229 */ BadChar, /* 230 */ BadChar, /* 231 */ BadChar,
- /* 232 */ BadChar, /* 233 */ BadChar, /* 234 */ BadChar, /* 235 */ BadChar,
- /* 236 */ BadChar, /* 237 */ BadChar, /* 238 */ BadChar, /* 239 */ BadChar,
- /* 240 */ BadChar, /* 241 */ BadChar, /* 242 */ BadChar, /* 243 */ BadChar,
- /* 244 */ BadChar, /* 245 */ BadChar, /* 246 */ BadChar, /* 247 */ BadChar,
- /* 248 */ BadChar, /* 249 */ BadChar, /* 250 */ BadChar, /* 251 */ BadChar,
- /* 252 */ BadChar, /* 253 */ BadChar, /* 254 */ BadChar, /* 255 */ BadChar
-};
-
-static int copyPathRemovingDots(char* dst, const char* src, int srcStart, int srcEnd);
-static void encodeRelativeString(const String& rel, const TextEncoding&, CharBuffer& ouput);
-static String substituteBackslashes(const String&);
-
-static inline bool isSchemeFirstChar(char c) { return characterClassTable[static_cast<unsigned char>(c)] & SchemeFirstChar; }
-static inline bool isSchemeFirstChar(UChar c) { return c <= 0xff && (characterClassTable[c] & SchemeFirstChar); }
-static inline bool isSchemeChar(char c) { return characterClassTable[static_cast<unsigned char>(c)] & SchemeChar; }
-static inline bool isSchemeChar(UChar c) { return c <= 0xff && (characterClassTable[c] & SchemeChar); }
-static inline bool isUserInfoChar(unsigned char c) { return characterClassTable[c] & UserInfoChar; }
-static inline bool isHostnameChar(unsigned char c) { return characterClassTable[c] & HostnameChar; }
-static inline bool isIPv6Char(unsigned char c) { return characterClassTable[c] & IPv6Char; }
-static inline bool isPathSegmentEndChar(char c) { return characterClassTable[static_cast<unsigned char>(c)] & PathSegmentEndChar; }
-static inline bool isPathSegmentEndChar(UChar c) { return c <= 0xff && (characterClassTable[c] & PathSegmentEndChar); }
-static inline bool isBadChar(unsigned char c) { return characterClassTable[c] & BadChar; }
-
-static inline int hexDigitValue(UChar c)
-{
- ASSERT(isASCIIHexDigit(c));
- if (c < 'A')
- return c - '0';
- return (c - 'A' + 10) & 0xF; // handle both upper and lower case without a branch
-}
-
-// Copies the source to the destination, assuming all the source characters are
-// ASCII. The destination buffer must be large enough. Null characters are allowed
-// in the source string, and no attempt is made to null-terminate the result.
-static void copyASCII(const UChar* src, int length, char* dest)
-{
- for (int i = 0; i < length; i++)
- dest[i] = static_cast<char>(src[i]);
-}
-
-// FIXME: Move to PlatformString.h eventually.
-// Returns the index of the first index in string |s| of any of the characters
-// in |toFind|. |toFind| should be a null-terminated string, all characters up
-// to the null will be searched. Returns int if not found.
-static int findFirstOf(const UChar* s, int sLen, int startPos, const char* toFind)
-{
- for (int i = startPos; i < sLen; i++) {
- const char* cur = toFind;
- while (*cur) {
- if (s[i] == *(cur++))
- return i;
- }
- }
- return -1;
-}
-
-inline bool KURL::protocolIs(const String& string, const char* protocol)
-{
- return WebCore::protocolIs(string, protocol);
-}
-
-void KURL::invalidate()
-{
- m_isValid = false;
- m_schemeEnd = 0;
- m_userStart = 0;
- m_userEnd = 0;
- m_passwordEnd = 0;
- m_hostEnd = 0;
- m_portEnd = 0;
- m_pathEnd = 0;
- m_pathAfterLastSlash = 0;
- m_queryEnd = 0;
- m_fragmentEnd = 0;
-}
-
-KURL::KURL(const char* url)
-{
- if (!url || url[0] != '/') {
- parse(url, 0);
- return;
- }
-
- size_t urlLength = strlen(url) + 1;
- CharBuffer buffer(urlLength + 5); // 5 for "file:".
- buffer[0] = 'f';
- buffer[1] = 'i';
- buffer[2] = 'l';
- buffer[3] = 'e';
- buffer[4] = ':';
- memcpy(&buffer[5], url, urlLength);
- parse(buffer.data(), 0);
-}
-
-KURL::KURL(const String& url)
-{
- if (url[0] != '/') {
- parse(url);
- return;
- }
-
- CharBuffer buffer(url.length() + 6); // 5 for "file:", 1 for terminator.
- buffer[0] = 'f';
- buffer[1] = 'i';
- buffer[2] = 'l';
- buffer[3] = 'e';
- buffer[4] = ':';
- copyASCII(url.characters(), url.length(), &buffer[5]);
- buffer[url.length() + 5] = '\0'; // Need null terminator.
-
- parse(buffer.data(), 0);
-}
-
-KURL::KURL(const KURL& base, const String& relative)
-{
- init(base, relative, UTF8Encoding());
-}
-
-KURL::KURL(const KURL& base, const String& relative, const TextEncoding& encoding)
-{
- init(base, relative, encoding);
-}
-
-void KURL::init(const KURL& base, const String& relative, const TextEncoding& encoding)
-{
- // Allow resolutions with a null or empty base URL, but not with any other invalid one.
- // FIXME: Is this a good rule?
- if (!base.m_isValid && !base.isEmpty()) {
- m_string = relative;
- invalidate();
- return;
- }
-
- // For compatibility with Win IE, treat backslashes as if they were slashes,
- // as long as we're not dealing with javascript: or data: URLs.
- String rel = relative;
- if (rel.contains('\\') && !(protocolIs(rel, "javascript") || protocolIs(rel, "data")))
- rel = substituteBackslashes(rel);
-
- String* originalString = &rel;
-
- bool allASCII = charactersAreAllASCII(rel.characters(), rel.length());
- CharBuffer strBuffer;
- char* str;
- size_t len;
- if (allASCII) {
- len = rel.length();
- strBuffer.resize(len + 1);
- copyASCII(rel.characters(), len, strBuffer.data());
- strBuffer[len] = 0;
- str = strBuffer.data();
- } else {
- originalString = 0;
- encodeRelativeString(rel, encoding, strBuffer);
- str = strBuffer.data();
- len = strlen(str);
- }
-
- // Get rid of leading whitespace.
- while (*str == ' ') {
- originalString = 0;
- str++;
- --len;
- }
-
- // Get rid of trailing whitespace.
- while (len && str[len - 1] == ' ') {
- originalString = 0;
- str[--len] = '\0';
- }
-
- // According to the RFC, the reference should be interpreted as an
- // absolute URI if possible, using the "leftmost, longest"
- // algorithm. If the URI reference is absolute it will have a
- // scheme, meaning that it will have a colon before the first
- // non-scheme element.
- bool absolute = false;
- char* p = str;
- if (isSchemeFirstChar(*p)) {
- ++p;
- while (isSchemeChar(*p)) {
- ++p;
- }
- if (*p == ':') {
- if (p[1] != '/' && equalIgnoringCase(base.protocol(), String(str, p - str)) && base.isHierarchical()) {
- str = p + 1;
- originalString = 0;
- } else
- absolute = true;
- }
- }
-
- if (absolute) {
- parse(str, originalString);
- } else {
- // If the base is empty or opaque (e.g. data: or javascript:), then the URL is invalid
- // unless the relative URL is a single fragment.
- if (!base.isHierarchical()) {
- if (str[0] == '#')
- parse(base.m_string.left(base.m_queryEnd) + (allASCII ? String(str) : String::fromUTF8(str)));
- else {
- m_string = relative;
- invalidate();
- }
- return;
- }
-
- switch (str[0]) {
- case '\0':
- // the reference must be empty - the RFC says this is a
- // reference to the same document
- *this = base;
- break;
- case '#':
- // must be fragment-only reference
- parse(base.m_string.left(base.m_queryEnd) + (allASCII ? String(str) : String::fromUTF8(str)));
- break;
- case '?':
- // query-only reference, special case needed for non-URL results
- parse(base.m_string.left(base.m_pathEnd) + (allASCII ? String(str) : String::fromUTF8(str)));
- break;
- case '/':
- // must be net-path or absolute-path reference
- if (str[1] == '/') {
- // net-path
- parse(base.m_string.left(base.m_schemeEnd + 1) + (allASCII ? String(str) : String::fromUTF8(str)));
- } else {
- // abs-path
- parse(base.m_string.left(base.m_portEnd) + (allASCII ? String(str) : String::fromUTF8(str)));
- }
- break;
- default:
- {
- // must be relative-path reference
-
- // Base part plus relative part plus one possible slash added in between plus terminating \0 byte.
- CharBuffer buffer(base.m_pathEnd + 1 + len + 1);
-
- char* bufferPos = buffer.data();
-
- // first copy everything before the path from the base
- unsigned baseLength = base.m_string.length();
- const UChar* baseCharacters = base.m_string.characters();
- CharBuffer baseStringBuffer(baseLength);
- for (unsigned i = 0; i < baseLength; ++i)
- baseStringBuffer[i] = static_cast<char>(baseCharacters[i]);
- const char* baseString = baseStringBuffer.data();
- const char* baseStringStart = baseString;
- const char* pathStart = baseStringStart + base.m_portEnd;
- while (baseStringStart < pathStart)
- *bufferPos++ = *baseStringStart++;
- char* bufferPathStart = bufferPos;
-
- // now copy the base path
- const char* baseStringEnd = baseString + base.m_pathEnd;
-
- // go back to the last slash
- while (baseStringEnd > baseStringStart && baseStringEnd[-1] != '/')
- baseStringEnd--;
-
- if (baseStringEnd == baseStringStart) {
- // no path in base, add a path separator if necessary
- if (base.m_schemeEnd + 1 != base.m_pathEnd && *str && *str != '?' && *str != '#')
- *bufferPos++ = '/';
- } else {
- bufferPos += copyPathRemovingDots(bufferPos, baseStringStart, 0, baseStringEnd - baseStringStart);
- }
-
- const char* relStringStart = str;
- const char* relStringPos = relStringStart;
-
- while (*relStringPos && *relStringPos != '?' && *relStringPos != '#') {
- if (relStringPos[0] == '.' && bufferPos[-1] == '/') {
- if (isPathSegmentEndChar(relStringPos[1])) {
- // skip over "." segment
- relStringPos += 1;
- if (relStringPos[0] == '/')
- relStringPos++;
- continue;
- } else if (relStringPos[1] == '.' && isPathSegmentEndChar(relStringPos[2])) {
- // skip over ".." segment and rewind the last segment
- // the RFC leaves it up to the app to decide what to do with excess
- // ".." segments - we choose to drop them since some web content
- // relies on this.
- relStringPos += 2;
- if (relStringPos[0] == '/')
- relStringPos++;
- if (bufferPos > bufferPathStart + 1)
- bufferPos--;
- while (bufferPos > bufferPathStart + 1 && bufferPos[-1] != '/')
- bufferPos--;
- continue;
- }
- }
-
- *bufferPos = *relStringPos;
- relStringPos++;
- bufferPos++;
- }
-
- // all done with the path work, now copy any remainder
- // of the relative reference; this will also add a null terminator
- strcpy(bufferPos, relStringPos);
-
- parse(buffer.data(), 0);
-
- ASSERT(strlen(buffer.data()) + 1 <= buffer.size());
- break;
- }
- }
- }
-}
-
-bool KURL::hasPath() const
-{
- return m_pathEnd != m_portEnd;
-}
-
-String KURL::lastPathComponent() const
-{
- if (!hasPath())
- return String();
-
- int end = m_pathEnd - 1;
- if (m_string[end] == '/')
- --end;
-
- int start = m_string.reverseFind('/', end);
- if (start < m_portEnd)
- return String();
- ++start;
-
- return m_string.substring(start, end - start + 1);
-}
-
-String KURL::protocol() const
-{
- return m_string.left(m_schemeEnd);
-}
-
-String KURL::host() const
-{
- int start = hostStart();
- return decodeURLEscapeSequences(m_string.substring(start, m_hostEnd - start));
-}
-
-unsigned short KURL::port() const
-{
- if (m_hostEnd == m_portEnd)
- return 0;
-
- int number = m_string.substring(m_hostEnd + 1, m_portEnd - m_hostEnd - 1).toInt();
- if (number < 0 || number > 0xFFFF)
- return 0;
- return number;
-}
-
-String KURL::pass() const
-{
- if (m_passwordEnd == m_userEnd)
- return String();
-
- return decodeURLEscapeSequences(m_string.substring(m_userEnd + 1, m_passwordEnd - m_userEnd - 1));
-}
-
-String KURL::user() const
-{
- return decodeURLEscapeSequences(m_string.substring(m_userStart, m_userEnd - m_userStart));
-}
-
-String KURL::ref() const
-{
- if (m_fragmentEnd == m_queryEnd)
- return String();
-
- return m_string.substring(m_queryEnd + 1, m_fragmentEnd - (m_queryEnd + 1));
-}
-
-bool KURL::hasRef() const
-{
- return m_fragmentEnd != m_queryEnd;
-}
-
-static inline void assertProtocolIsGood(const char* protocol)
-{
-#ifndef NDEBUG
- const char* p = protocol;
- while (*p) {
- ASSERT(*p > ' ' && *p < 0x7F && !(*p >= 'A' && *p <= 'Z'));
- ++p;
- }
-#endif
-}
-
-bool KURL::protocolIs(const char* protocol) const
-{
- // Do the comparison without making a new string object.
- assertProtocolIsGood(protocol);
- if (!m_isValid)
- return false;
- for (int i = 0; i < m_schemeEnd; ++i) {
- if (!protocol[i] || toASCIILower(m_string[i]) != protocol[i])
- return false;
- }
- return !protocol[m_schemeEnd]; // We should have consumed all characters in the argument.
-}
-
-String KURL::query() const
-{
- return m_string.substring(m_pathEnd, m_queryEnd - m_pathEnd);
-}
-
-String KURL::path() const
-{
- return decodeURLEscapeSequences(m_string.substring(m_portEnd, m_pathEnd - m_portEnd));
-}
-
-void KURL::setProtocol(const String& s)
-{
- if (!m_isValid) {
- parse(s + ":" + m_string);
- return;
- }
-
- parse(s + m_string.substring(m_schemeEnd));
-}
-
-void KURL::setHost(const String& s)
-{
- if (!m_isValid)
- return;
-
- bool slashSlashNeeded = m_userStart == m_schemeEnd + 1;
-
- parse(m_string.left(hostStart()) + (slashSlashNeeded ? "//" : "") + s + m_string.substring(m_hostEnd));
-}
-
-void KURL::setPort(unsigned short i)
-{
- if (!m_isValid)
- return;
-
- bool colonNeeded = m_portEnd == m_hostEnd;
- int portStart = (colonNeeded ? m_hostEnd : m_hostEnd + 1);
-
- parse(m_string.left(portStart) + (colonNeeded ? ":" : "") + String::number(i) + m_string.substring(m_portEnd));
-}
-
-void KURL::setHostAndPort(const String& hostAndPort)
-{
- if (!m_isValid)
- return;
-
- bool slashSlashNeeded = m_userStart == m_schemeEnd + 1;
-
- parse(m_string.left(hostStart()) + (slashSlashNeeded ? "//" : "") + hostAndPort + m_string.substring(m_portEnd));
-}
-
-void KURL::setUser(const String& user)
-{
- if (!m_isValid)
- return;
-
- String u;
- int end = m_userEnd;
- if (!user.isEmpty()) {
- u = user;
- if (m_userStart == m_schemeEnd + 1)
- u = "//" + u;
- // Add '@' if we didn't have one before.
- if (end == m_hostEnd || (end == m_passwordEnd && m_string[end] != '@'))
- u.append('@');
- } else {
- // Remove '@' if we now have neither user nor password.
- if (m_userEnd == m_passwordEnd && end != m_hostEnd && m_string[end] == '@')
- end += 1;
- }
- parse(m_string.left(m_userStart) + u + m_string.substring(end));
-}
-
-void KURL::setPass(const String& password)
-{
- if (!m_isValid)
- return;
-
- String p;
- int end = m_passwordEnd;
- if (!password.isEmpty()) {
- p = ":" + password + "@";
- if (m_userEnd == m_schemeEnd + 1)
- p = "//" + p;
- // Eat the existing '@' since we are going to add our own.
- if (end != m_hostEnd && m_string[end] == '@')
- end += 1;
- } else {
- // Remove '@' if we now have neither user nor password.
- if (m_userStart == m_userEnd && end != m_hostEnd && m_string[end] == '@')
- end += 1;
- }
- parse(m_string.left(m_userEnd) + p + m_string.substring(end));
-}
-
-void KURL::setRef(const String& s)
-{
- if (!m_isValid)
- return;
- parse(m_string.left(m_queryEnd) + (s.isNull() ? "" : "#" + s));
-}
-
-void KURL::removeRef()
-{
- if (!m_isValid)
- return;
- parse(m_string.left(m_queryEnd));
-}
-
-void KURL::setQuery(const String& query)
-{
- if (!m_isValid)
- return;
-
- if ((query.isEmpty() || query[0] != '?') && !query.isNull())
- parse(m_string.left(m_pathEnd) + "?" + query + m_string.substring(m_queryEnd));
- else
- parse(m_string.left(m_pathEnd) + query + m_string.substring(m_queryEnd));
-
-}
-
-void KURL::setPath(const String& s)
-{
- if (!m_isValid)
- return;
-
- parse(m_string.left(m_portEnd) + encodeWithURLEscapeSequences(s) + m_string.substring(m_pathEnd));
-}
-
-String KURL::prettyURL() const
-{
- if (!m_isValid)
- return m_string;
-
- Vector<UChar> result;
-
- append(result, protocol());
- result.append(':');
-
- Vector<UChar> authority;
-
- if (m_hostEnd != m_passwordEnd) {
- if (m_userEnd != m_userStart) {
- append(authority, user());
- authority.append('@');
- }
- append(authority, host());
- if (port() != 0) {
- authority.append(':');
- append(authority, String::number(port()));
- }
- }
-
- if (!authority.isEmpty()) {
- result.append('/');
- result.append('/');
- result.append(authority);
- } else if (protocolIs("file")) {
- result.append('/');
- result.append('/');
- }
-
- append(result, path());
- append(result, query());
-
- if (m_fragmentEnd != m_queryEnd) {
- result.append('#');
- append(result, ref());
- }
-
- return String::adopt(result);
-}
-
-String decodeURLEscapeSequences(const String& str)
-{
- return decodeURLEscapeSequences(str, UTF8Encoding());
-}
-
-String decodeURLEscapeSequences(const String& str, const TextEncoding& encoding)
-{
- Vector<UChar> result;
-
- CharBuffer buffer;
-
- int length = str.length();
- int decodedPosition = 0;
- int searchPosition = 0;
- int encodedRunPosition;
- while ((encodedRunPosition = str.find('%', searchPosition)) >= 0) {
- // Find the sequence of %-escape codes.
- int encodedRunEnd = encodedRunPosition;
- while (length - encodedRunEnd >= 3
- && str[encodedRunEnd] == '%'
- && isASCIIHexDigit(str[encodedRunEnd + 1])
- && isASCIIHexDigit(str[encodedRunEnd + 2]))
- encodedRunEnd += 3;
- if (encodedRunEnd == encodedRunPosition) {
- ++searchPosition;
- continue;
- }
- searchPosition = encodedRunEnd;
-
- // Decode the %-escapes into bytes.
- unsigned runLength = (encodedRunEnd - encodedRunPosition) / 3;
- buffer.resize(runLength);
- char* p = buffer.data();
- const UChar* q = str.characters() + encodedRunPosition;
- for (unsigned i = 0; i < runLength; ++i) {
- *p++ = (hexDigitValue(q[1]) << 4) | hexDigitValue(q[2]);
- q += 3;
- }
-
- // Decode the bytes into Unicode characters.
- String decoded = (encoding.isValid() ? encoding : UTF8Encoding()).decode(buffer.data(), p - buffer.data());
- if (decoded.isEmpty())
- continue;
-
- // Build up the string with what we just skipped and what we just decoded.
- result.append(str.characters() + decodedPosition, encodedRunPosition - decodedPosition);
- result.append(decoded.characters(), decoded.length());
- decodedPosition = encodedRunEnd;
- }
-
- result.append(str.characters() + decodedPosition, length - decodedPosition);
-
- return String::adopt(result);
-}
-
-bool KURL::isLocalFile() const
-{
- // Including feed here might be a bad idea since drag and drop uses this check
- // and including feed would allow feeds to potentially let someone's blog
- // read the contents of the clipboard on a drag, even without a drop.
- // Likewise with using the FrameLoader::shouldTreatURLAsLocal() function.
- return protocolIs("file");
-}
-
-static void appendEscapingBadChars(char*& buffer, const char* strStart, size_t length)
-{
- char* p = buffer;
-
- const char* str = strStart;
- const char* strEnd = strStart + length;
- while (str < strEnd) {
- unsigned char c = *str++;
- if (isBadChar(c)) {
- if (c == '%' || c == '?') {
- *p++ = c;
- } else if (c != 0x09 && c != 0x0a && c != 0x0d) {
- *p++ = '%';
- *p++ = hexDigits[c >> 4];
- *p++ = hexDigits[c & 0xF];
- }
- } else {
- *p++ = c;
- }
- }
-
- buffer = p;
-}
-
-// copy a path, accounting for "." and ".." segments
-static int copyPathRemovingDots(char* dst, const char* src, int srcStart, int srcEnd)
-{
- char* bufferPathStart = dst;
-
- // empty path is a special case, and need not have a leading slash
- if (srcStart != srcEnd) {
- const char* baseStringStart = src + srcStart;
- const char* baseStringEnd = src + srcEnd;
- const char* baseStringPos = baseStringStart;
-
- // this code is unprepared for paths that do not begin with a
- // slash and we should always have one in the source string
- ASSERT(baseStringPos[0] == '/');
-
- // copy the leading slash into the destination
- *dst = *baseStringPos;
- baseStringPos++;
- dst++;
-
- while (baseStringPos < baseStringEnd) {
- if (baseStringPos[0] == '.' && dst[-1] == '/') {
- if (baseStringPos[1] == '/' || baseStringPos + 1 == baseStringEnd) {
- // skip over "." segment
- baseStringPos += 2;
- continue;
- } else if (baseStringPos[1] == '.' && (baseStringPos[2] == '/' ||
- baseStringPos + 2 == baseStringEnd)) {
- // skip over ".." segment and rewind the last segment
- // the RFC leaves it up to the app to decide what to do with excess
- // ".." segments - we choose to drop them since some web content
- // relies on this.
- baseStringPos += 3;
- if (dst > bufferPathStart + 1)
- dst--;
- // Note that these two while blocks differ subtly.
- // The first helps to remove multiple adjoining slashes as we rewind.
- // The +1 to bufferPathStart in the first while block prevents eating a leading slash
- while (dst > bufferPathStart + 1 && dst[-1] == '/')
- dst--;
- while (dst > bufferPathStart && dst[-1] != '/')
- dst--;
- continue;
- }
- }
-
- *dst = *baseStringPos;
- baseStringPos++;
- dst++;
- }
- }
- *dst = '\0';
- return dst - bufferPathStart;
-}
-
-static inline bool hasSlashDotOrDotDot(const char* str)
-{
- const unsigned char* p = reinterpret_cast<const unsigned char*>(str);
- if (!*p)
- return false;
- unsigned char pc = *p;
- while (unsigned char c = *++p) {
- if (c == '.' && (pc == '/' || pc == '.'))
- return true;
- pc = c;
- }
- return false;
-}
-
-static inline bool matchLetter(char c, char lowercaseLetter)
-{
- return (c | 0x20) == lowercaseLetter;
-}
-
-void KURL::parse(const String& string)
-{
- CharBuffer buffer;
- encodeRelativeString(string, UTF8Encoding(), buffer);
- parse(buffer.data(), &string);
-}
-
-void KURL::parse(const char* url, const String* originalString)
-{
- if (!url || url[0] == '\0') {
- // valid URL must be non-empty
- m_string = originalString ? *originalString : url;
- invalidate();
- return;
- }
-
- if (!isSchemeFirstChar(url[0])) {
- // scheme must start with an alphabetic character
- m_string = originalString ? *originalString : url;
- invalidate();
- return;
- }
-
- int schemeEnd = 0;
- while (isSchemeChar(url[schemeEnd]))
- schemeEnd++;
-
- if (url[schemeEnd] != ':') {
- m_string = originalString ? *originalString : url;
- invalidate();
- return;
- }
-
- int userStart = schemeEnd + 1;
- int userEnd;
- int passwordStart;
- int passwordEnd;
- int hostStart;
- int hostEnd;
- int portStart;
- int portEnd;
-
- bool hierarchical = url[schemeEnd + 1] == '/';
-
- bool isFile = schemeEnd == 4
- && matchLetter(url[0], 'f')
- && matchLetter(url[1], 'i')
- && matchLetter(url[2], 'l')
- && matchLetter(url[3], 'e');
-
- bool isHTTPorHTTPS = matchLetter(url[0], 'h')
- && matchLetter(url[1], 't')
- && matchLetter(url[2], 't')
- && matchLetter(url[3], 'p')
- && (url[4] == ':' || (matchLetter(url[4], 's') && url[5] == ':'));
-
- if (hierarchical && url[schemeEnd + 2] == '/') {
- // The part after the scheme is either a net_path or an abs_path whose first path segment is empty.
- // Attempt to find an authority.
-
- // FIXME: Authority characters may be scanned twice, and it would be nice to be faster.
- userStart += 2;
- userEnd = userStart;
-
- int colonPos = 0;
- while (isUserInfoChar(url[userEnd])) {
- if (url[userEnd] == ':' && colonPos == 0)
- colonPos = userEnd;
- userEnd++;
- }
-
- if (url[userEnd] == '@') {
- // actual end of the userinfo, start on the host
- if (colonPos != 0) {
- passwordEnd = userEnd;
- userEnd = colonPos;
- passwordStart = colonPos + 1;
- } else
- passwordStart = passwordEnd = userEnd;
-
- hostStart = passwordEnd + 1;
- } else if (url[userEnd] == '[' || isPathSegmentEndChar(url[userEnd])) {
- // hit the end of the authority, must have been no user
- // or looks like an IPv6 hostname
- // either way, try to parse it as a hostname
- userEnd = userStart;
- passwordStart = passwordEnd = userEnd;
- hostStart = userStart;
- } else {
- // invalid character
- m_string = originalString ? *originalString : url;
- invalidate();
- return;
- }
-
- hostEnd = hostStart;
-
- // IPV6 IP address
- if (url[hostEnd] == '[') {
- hostEnd++;
- while (isIPv6Char(url[hostEnd]))
- hostEnd++;
- if (url[hostEnd] == ']')
- hostEnd++;
- else {
- // invalid character
- m_string = originalString ? *originalString : url;
- invalidate();
- return;
- }
- } else {
- while (isHostnameChar(url[hostEnd]))
- hostEnd++;
- }
-
- if (url[hostEnd] == ':') {
- portStart = portEnd = hostEnd + 1;
-
- // possible start of port
- portEnd = portStart;
- while (isASCIIDigit(url[portEnd]))
- portEnd++;
- } else
- portStart = portEnd = hostEnd;
-
- if (!isPathSegmentEndChar(url[portEnd])) {
- // invalid character
- m_string = originalString ? *originalString : url;
- invalidate();
- return;
- }
-
- if (userStart == portEnd && !isHTTPorHTTPS && !isFile) {
- // No authority found, which means that this is not a net_path, but rather an abs_path whose first two
- // path segments are empty. For file, http and https only, an empty authority is allowed.
- userStart -= 2;
- userEnd = userStart;
- passwordStart = userEnd;
- passwordEnd = passwordStart;
- hostStart = passwordEnd;
- hostEnd = hostStart;
- portStart = hostEnd;
- portEnd = hostEnd;
- }
- } else {
- // the part after the scheme must be an opaque_part or an abs_path
- userEnd = userStart;
- passwordStart = passwordEnd = userEnd;
- hostStart = hostEnd = passwordEnd;
- portStart = portEnd = hostEnd;
- }
-
- int pathStart = portEnd;
- int pathEnd = pathStart;
- while (url[pathEnd] && url[pathEnd] != '?' && url[pathEnd] != '#')
- pathEnd++;
-
- int queryStart = pathEnd;
- int queryEnd = queryStart;
- if (url[queryStart] == '?') {
- while (url[queryEnd] && url[queryEnd] != '#')
- queryEnd++;
- }
-
- int fragmentStart = queryEnd;
- int fragmentEnd = fragmentStart;
- if (url[fragmentStart] == '#') {
- fragmentStart++;
- fragmentEnd = fragmentStart;
- while (url[fragmentEnd])
- fragmentEnd++;
- }
-
- // assemble it all, remembering the real ranges
-
- Vector<char, 4096> buffer(fragmentEnd * 3 + 1);
-
- char *p = buffer.data();
- const char *strPtr = url;
-
- // copy in the scheme
- const char *schemeEndPtr = url + schemeEnd;
- while (strPtr < schemeEndPtr)
- *p++ = *strPtr++;
- m_schemeEnd = p - buffer.data();
-
- bool hostIsLocalHost = portEnd - userStart == 9
- && matchLetter(url[userStart], 'l')
- && matchLetter(url[userStart+1], 'o')
- && matchLetter(url[userStart+2], 'c')
- && matchLetter(url[userStart+3], 'a')
- && matchLetter(url[userStart+4], 'l')
- && matchLetter(url[userStart+5], 'h')
- && matchLetter(url[userStart+6], 'o')
- && matchLetter(url[userStart+7], 's')
- && matchLetter(url[userStart+8], 't');
-
- // File URLs need a host part unless it is just file:// or file://localhost
- bool degenFilePath = pathStart == pathEnd && (hostStart == hostEnd || hostIsLocalHost);
-
- bool haveNonHostAuthorityPart = userStart != userEnd || passwordStart != passwordEnd || portStart != portEnd;
-
- // add ":" after scheme
- *p++ = ':';
-
- // if we have at least one authority part or a file URL - add "//" and authority
- if (isFile ? !degenFilePath : (haveNonHostAuthorityPart || hostStart != hostEnd)) {
- *p++ = '/';
- *p++ = '/';
-
- m_userStart = p - buffer.data();
-
- // copy in the user
- strPtr = url + userStart;
- const char* userEndPtr = url + userEnd;
- while (strPtr < userEndPtr)
- *p++ = *strPtr++;
- m_userEnd = p - buffer.data();
-
- // copy in the password
- if (passwordEnd != passwordStart) {
- *p++ = ':';
- strPtr = url + passwordStart;
- const char* passwordEndPtr = url + passwordEnd;
- while (strPtr < passwordEndPtr)
- *p++ = *strPtr++;
- }
- m_passwordEnd = p - buffer.data();
-
- // If we had any user info, add "@"
- if (p - buffer.data() != m_userStart)
- *p++ = '@';
-
- // copy in the host, except in the case of a file URL with authority="localhost"
- if (!(isFile && hostIsLocalHost && !haveNonHostAuthorityPart)) {
- strPtr = url + hostStart;
- const char* hostEndPtr = url + hostEnd;
- while (strPtr < hostEndPtr)
- *p++ = *strPtr++;
- }
- m_hostEnd = p - buffer.data();
-
- // copy in the port
- if (hostEnd != portStart) {
- *p++ = ':';
- strPtr = url + portStart;
- const char *portEndPtr = url + portEnd;
- while (strPtr < portEndPtr)
- *p++ = *strPtr++;
- }
- m_portEnd = p - buffer.data();
- } else
- m_userStart = m_userEnd = m_passwordEnd = m_hostEnd = m_portEnd = p - buffer.data();
-
- // For canonicalization, ensure we have a '/' for no path.
- // Only do this for http and https.
- if (isHTTPorHTTPS && pathEnd - pathStart == 0)
- *p++ = '/';
-
- // add path, escaping bad characters
- if (!hierarchical || !hasSlashDotOrDotDot(url))
- appendEscapingBadChars(p, url + pathStart, pathEnd - pathStart);
- else {
- CharBuffer pathBuffer(pathEnd - pathStart + 1);
- size_t length = copyPathRemovingDots(pathBuffer.data(), url, pathStart, pathEnd);
- appendEscapingBadChars(p, pathBuffer.data(), length);
- }
-
- m_pathEnd = p - buffer.data();
-
- // Find the position after the last slash in the path, or
- // the position before the path if there are no slashes in it.
- int i;
- for (i = m_pathEnd; i > m_portEnd; --i) {
- if (buffer[i - 1] == '/')
- break;
- }
- m_pathAfterLastSlash = i;
-
- // add query, escaping bad characters
- appendEscapingBadChars(p, url + queryStart, queryEnd - queryStart);
- m_queryEnd = p - buffer.data();
-
- // add fragment, escaping bad characters
- if (fragmentEnd != queryEnd) {
- *p++ = '#';
- appendEscapingBadChars(p, url + fragmentStart, fragmentEnd - fragmentStart);
- }
- m_fragmentEnd = p - buffer.data();
-
- ASSERT(p - buffer.data() <= static_cast<int>(buffer.size()));
-
- // If we didn't end up actually changing the original string and
- // it was already in a String, reuse it to avoid extra allocation.
- if (originalString && strncmp(buffer.data(), url, m_fragmentEnd) == 0)
- m_string = *originalString;
- else
- m_string = String(buffer.data(), m_fragmentEnd);
-
- m_isValid = true;
-}
-
-bool equalIgnoringRef(const KURL& a, const KURL& b)
-{
- if (a.m_queryEnd != b.m_queryEnd)
- return false;
- unsigned queryLength = a.m_queryEnd;
- for (unsigned i = 0; i < queryLength; ++i)
- if (a.string()[i] != b.string()[i])
- return false;
- return true;
-}
-
-bool protocolHostAndPortAreEqual(const KURL& a, const KURL& b)
-{
- if (a.m_schemeEnd != b.m_schemeEnd)
- return false;
- int hostStartA = a.hostStart();
- int hostStartB = b.hostStart();
- if (a.m_hostEnd - hostStartA != b.m_hostEnd - hostStartB)
- return false;
-
- // Check the scheme
- for (int i = 0; i < a.m_schemeEnd; ++i)
- if (a.string()[i] != b.string()[i])
- return false;
-
- // And the host
- for (int i = hostStartA; i < a.m_hostEnd; ++i)
- if (a.string()[i] != b.string()[i])
- return false;
-
- if (a.port() != b.port())
- return false;
-
- return true;
-}
-
-
-String encodeWithURLEscapeSequences(const String& notEncodedString)
-{
- CString asUTF8 = notEncodedString.utf8();
-
- CharBuffer buffer(asUTF8.length() * 3 + 1);
- char* p = buffer.data();
-
- const char* str = asUTF8.data();
- const char* strEnd = str + asUTF8.length();
- while (str < strEnd) {
- unsigned char c = *str++;
- if (isBadChar(c)) {
- *p++ = '%';
- *p++ = hexDigits[c >> 4];
- *p++ = hexDigits[c & 0xF];
- } else
- *p++ = c;
- }
-
- ASSERT(p - buffer.data() <= static_cast<int>(buffer.size()));
-
- return String(buffer.data(), p - buffer.data());
-}
-
-// Appends the punycoded hostname identified by the given string and length to
-// the output buffer. The result will not be null terminated.
-static void appendEncodedHostname(UCharBuffer& buffer, const UChar* str, unsigned strLen)
-{
- // Needs to be big enough to hold an IDN-encoded name.
- // For host names bigger than this, we won't do IDN encoding, which is almost certainly OK.
- const unsigned hostnameBufferLength = 2048;
-
- if (strLen > hostnameBufferLength || charactersAreAllASCII(str, strLen)) {
- buffer.append(str, strLen);
- return;
- }
-
-#if USE(ICU_UNICODE)
- UChar hostnameBuffer[hostnameBufferLength];
- UErrorCode error = U_ZERO_ERROR;
- int32_t numCharactersConverted = uidna_IDNToASCII(str, strLen, hostnameBuffer,
- hostnameBufferLength, UIDNA_ALLOW_UNASSIGNED, 0, &error);
- if (error == U_ZERO_ERROR)
- buffer.append(hostnameBuffer, numCharactersConverted);
-#elif USE(QT4_UNICODE)
- QByteArray result = QUrl::toAce(String(str, strLen));
- buffer.append(result.constData(), result.length());
-#endif
-}
-
-static void findHostnamesInMailToURL(const UChar* str, int strLen, Vector<pair<int, int> >& nameRanges)
-{
- // In a mailto: URL, host names come after a '@' character and end with a '>' or ',' or '?' or end of string character.
- // Skip quoted strings so that characters in them don't confuse us.
- // When we find a '?' character, we are past the part of the URL that contains host names.
-
- nameRanges.clear();
-
- int p = 0;
- while (1) {
- // Find start of host name or of quoted string.
- int hostnameOrStringStart = findFirstOf(str, strLen, p, "\"@?");
- if (hostnameOrStringStart == -1)
- return;
- UChar c = str[hostnameOrStringStart];
- p = hostnameOrStringStart + 1;
-
- if (c == '?')
- return;
-
- if (c == '@') {
- // Find end of host name.
- int hostnameStart = p;
- int hostnameEnd = findFirstOf(str, strLen, p, ">,?");
- bool done;
- if (hostnameEnd == -1) {
- hostnameEnd = strLen;
- done = true;
- } else {
- p = hostnameEnd;
- done = false;
- }
-
- nameRanges.append(make_pair(hostnameStart, hostnameEnd));
-
- if (done)
- return;
- } else {
- // Skip quoted string.
- ASSERT(c == '"');
- while (1) {
- int escapedCharacterOrStringEnd = findFirstOf(str, strLen, p, "\"\\");
- if (escapedCharacterOrStringEnd == -1)
- return;
-
- c = str[escapedCharacterOrStringEnd];
- p = escapedCharacterOrStringEnd + 1;
-
- // If we are the end of the string, then break from the string loop back to the host name loop.
- if (c == '"')
- break;
-
- // Skip escaped character.
- ASSERT(c == '\\');
- if (p == strLen)
- return;
-
- ++p;
- }
- }
- }
-}
-
-static bool findHostnameInHierarchicalURL(const UChar* str, int strLen, int& startOffset, int& endOffset)
-{
- // Find the host name in a hierarchical URL.
- // It comes after a "://" sequence, with scheme characters preceding, and
- // this should be the first colon in the string.
- // It ends with the end of the string or a ":" or a path segment ending character.
- // If there is a "@" character, the host part is just the part after the "@".
- int separator = findFirstOf(str, strLen, 0, ":");
- if (separator == -1 || separator + 2 >= strLen ||
- str[separator + 1] != '/' || str[separator + 2] != '/')
- return false;
-
- // Check that all characters before the :// are valid scheme characters.
- if (!isSchemeFirstChar(str[0]))
- return false;
- for (int i = 1; i < separator; ++i) {
- if (!isSchemeChar(str[i]))
- return false;
- }
-
- // Start after the separator.
- int authorityStart = separator + 3;
-
- // Find terminating character.
- int hostnameEnd = strLen;
- for (int i = authorityStart; i < strLen; ++i) {
- UChar c = str[i];
- if (c == ':' || (isPathSegmentEndChar(c) && c != 0)) {
- hostnameEnd = i;
- break;
- }
- }
-
- // Find "@" for the start of the host name.
- int userInfoTerminator = findFirstOf(str, strLen, authorityStart, "@");
- int hostnameStart;
- if (userInfoTerminator == -1 || userInfoTerminator > hostnameEnd)
- hostnameStart = authorityStart;
- else
- hostnameStart = userInfoTerminator + 1;
-
- startOffset = hostnameStart;
- endOffset = hostnameEnd;
- return true;
-}
-
-// Converts all hostnames found in the given input to punycode, preserving the
-// rest of the URL unchanged. The output will NOT be null-terminated.
-static void encodeHostnames(const String& str, UCharBuffer& output)
-{
- output.clear();
-
- if (protocolIs(str, "mailto")) {
- Vector<pair<int, int> > hostnameRanges;
- findHostnamesInMailToURL(str.characters(), str.length(), hostnameRanges);
- int n = hostnameRanges.size();
- int p = 0;
- for (int i = 0; i < n; ++i) {
- const pair<int, int>& r = hostnameRanges[i];
- output.append(&str.characters()[p], r.first - p);
- appendEncodedHostname(output, &str.characters()[r.first], r.second - r.first);
- p = r.second;
- }
- // This will copy either everything after the last hostname, or the
- // whole thing if there is no hostname.
- output.append(&str.characters()[p], str.length() - p);
- } else {
- int hostStart, hostEnd;
- if (findHostnameInHierarchicalURL(str.characters(), str.length(), hostStart, hostEnd)) {
- output.append(str.characters(), hostStart); // Before hostname.
- appendEncodedHostname(output, &str.characters()[hostStart], hostEnd - hostStart);
- output.append(&str.characters()[hostEnd], str.length() - hostEnd); // After hostname.
- } else {
- // No hostname to encode, return the input.
- output.append(str.characters(), str.length());
- }
- }
-}
-
-static void encodeRelativeString(const String& rel, const TextEncoding& encoding, CharBuffer& output)
-{
- UCharBuffer s;
- encodeHostnames(rel, s);
-
- TextEncoding pathEncoding(UTF8Encoding()); // Path is always encoded as UTF-8; other parts may depend on the scheme.
-
- int pathEnd = -1;
- if (encoding != pathEncoding && encoding.isValid() && !protocolIs(rel, "mailto") && !protocolIs(rel, "data")) {
- // Find the first instance of either # or ?, keep pathEnd at -1 otherwise.
- pathEnd = findFirstOf(s.data(), s.size(), 0, "#?");
- }
-
- if (pathEnd == -1) {
- CString decoded = pathEncoding.encode(s.data(), s.size(), URLEncodedEntitiesForUnencodables);
- output.resize(decoded.length());
- memcpy(output.data(), decoded.data(), decoded.length());
- } else {
- CString pathDecoded = pathEncoding.encode(s.data(), pathEnd, URLEncodedEntitiesForUnencodables);
- // Unencodable characters in URLs are represented by converting
- // them to XML entities and escaping non-alphanumeric characters.
- CString otherDecoded = encoding.encode(s.data() + pathEnd, s.size() - pathEnd, URLEncodedEntitiesForUnencodables);
-
- output.resize(pathDecoded.length() + otherDecoded.length());
- memcpy(output.data(), pathDecoded.data(), pathDecoded.length());
- memcpy(output.data() + pathDecoded.length(), otherDecoded.data(), otherDecoded.length());
- }
- output.append('\0'); // null-terminate the output.
-}
-
-static String substituteBackslashes(const String& string)
-{
- int questionPos = string.find('?');
- int hashPos = string.find('#');
- int pathEnd;
-
- if (hashPos >= 0 && (questionPos < 0 || questionPos > hashPos))
- pathEnd = hashPos;
- else if (questionPos >= 0)
- pathEnd = questionPos;
- else
- pathEnd = string.length();
-
- return string.left(pathEnd).replace('\\','/') + string.substring(pathEnd);
-}
-
-bool KURL::isHierarchical() const
-{
- if (!m_isValid)
- return false;
- ASSERT(m_string[m_schemeEnd] == ':');
- return m_string[m_schemeEnd + 1] == '/';
-}
-
-void KURL::copyToBuffer(CharBuffer& buffer) const
-{
- // FIXME: This throws away the high bytes of all the characters in the string!
- // That's fine for a valid URL, which is all ASCII, but not for invalid URLs.
- buffer.resize(m_string.length());
- copyASCII(m_string.characters(), m_string.length(), buffer.data());
-}
-
-bool protocolIs(const String& url, const char* protocol)
-{
- // Do the comparison without making a new string object.
- assertProtocolIsGood(protocol);
- for (int i = 0; ; ++i) {
- if (!protocol[i])
- return url[i] == ':';
- if (toASCIILower(url[i]) != protocol[i])
- return false;
- }
-}
-
-String mimeTypeFromDataURL(const String& url)
-{
- ASSERT(protocolIs(url, "data"));
- int index = url.find(';');
- if (index == -1)
- index = url.find(',');
- if (index != -1) {
- int len = index - 5;
- if (len > 0)
- return url.substring(5, len);
- return "text/plain"; // Data URLs with no MIME type are considered text/plain.
- }
- return "";
-}
-
-const KURL& blankURL()
-{
- static KURL staticBlankURL("about:blank");
- return staticBlankURL;
-}
-
-#ifndef NDEBUG
-void KURL::print() const
-{
- printf("%s\n", m_string.utf8().data());
-}
-#endif
-
-}
diff --git a/WebCore/platform/KURL.h b/WebCore/platform/KURL.h
deleted file mode 100644
index f31c641..0000000
--- a/WebCore/platform/KURL.h
+++ /dev/null
@@ -1,283 +0,0 @@
-/*
- * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef KURL_h
-#define KURL_h
-
-#include "PlatformString.h"
-
-#if PLATFORM(CF)
-typedef const struct __CFURL* CFURLRef;
-#endif
-
-#if PLATFORM(MAC)
-#ifdef __OBJC__
-@class NSURL;
-#else
-class NSURL;
-#endif
-#endif
-
-#if PLATFORM(QT)
-QT_BEGIN_NAMESPACE
-class QUrl;
-QT_END_NAMESPACE
-#endif
-
-namespace WebCore {
-
-class TextEncoding;
-struct KURLHash;
-
-// FIXME: Our terminology here is a bit inconsistent. We refer to the part
-// after the "#" as the "fragment" in some places and the "ref" in others.
-// We should fix the terminology to match the URL and URI RFCs as closely
-// as possible to resolve this.
-
-class KURL {
-public:
- // Generates a URL which contains a null string.
- KURL() { invalidate(); }
-
- // The argument is an absolute URL string. The string is assumed to be
- // already encoded.
- // FIXME: This constructor has a special case for strings that start with
- // "/", prepending "file://" to such strings; it would be good to get
- // rid of that special case.
- explicit KURL(const char*);
-
- // The argument is an absolute URL string. The string is assumed to be
- // already encoded.
- // FIXME: For characters with codes other than 0000-00FF will be chopped
- // off, so this call is currently not safe to use with arbitrary strings.
- // FIXME: This constructor has a special case for strings that start with
- // "/", prepending "file://" to such strings; it would be good to get
- // rid of that special case.
- explicit KURL(const String&);
-
- // Resolves the relative URL with the given base URL. If provided, the
- // TextEncoding is used to encode non-ASCII characers. The base URL can be
- // null or empty, in which case the relative URL will be interpreted as
- // absolute.
- // FIXME: If the base URL is invalid, this always creates an invalid
- // URL. Instead I think it would be better to treat all invalid base URLs
- // the same way we treate null and empty base URLs.
- KURL(const KURL& base, const String& relative);
- KURL(const KURL& base, const String& relative, const TextEncoding&);
-
- // FIXME: The above functions should be harmonized so that passing a
- // base of null or the empty string gives the same result as the
- // standard String constructor.
-
- bool isNull() const { return m_string.isNull(); }
- bool isEmpty() const { return m_string.isEmpty(); }
-
- bool isValid() const { return m_isValid; }
-
- // Returns true if this URL has a path. Note that "http://foo.com/" has a
- // path of "/", so this function will return true. Only invalid or
- // non-hierarchical (like "javascript:") URLs will have no path.
- bool hasPath() const;
-
- const String& string() const { return m_string; }
-
- String protocol() const;
- String host() const;
- unsigned short port() const;
- String user() const;
- String pass() const;
- String path() const;
- String lastPathComponent() const;
- String query() const; // Includes the "?".
- String ref() const; // Does *not* include the "#".
- bool hasRef() const;
-
- String prettyURL() const;
- String fileSystemPath() const;
-
- // Returns true if the current URL's protocol is the same as the null-
- // terminated ASCII argument. The argument must be lower-case.
- bool protocolIs(const char*) const;
- bool isLocalFile() const;
-
- void setProtocol(const String&);
- void setHost(const String&);
-
- // Setting the port to 0 will clear any port from the URL.
- void setPort(unsigned short);
-
- // Input is like "foo.com" or "foo.com:8000".
- void setHostAndPort(const String&);
-
- void setUser(const String&);
- void setPass(const String&);
-
- // If you pass an empty path for HTTP or HTTPS URLs, the resulting path
- // will be "/".
- void setPath(const String&);
-
- // The query may begin with a question mark, or, if not, one will be added
- // for you. Setting the query to the empty string will leave a "?" in the
- // URL (with nothing after it). To clear the query, pass a null string.
- void setQuery(const String&);
-
- void setRef(const String&);
- void removeRef();
-
- friend bool equalIgnoringRef(const KURL&, const KURL&);
-
- friend bool protocolHostAndPortAreEqual(const KURL&, const KURL&);
-
- operator const String&() const { return m_string; }
- operator JSC::UString() const { return m_string; }
-
- unsigned hostStart() const { return (m_passwordEnd == m_userStart) ? m_passwordEnd : m_passwordEnd + 1; }
- unsigned hostEnd() const { return m_hostEnd; }
-
- unsigned pathStart() const { return m_portEnd; }
- unsigned pathEnd() const { return m_pathEnd; }
- unsigned pathAfterLastSlash() const { return m_pathAfterLastSlash; }
-
-#if PLATFORM(CF)
- KURL(CFURLRef);
- CFURLRef createCFURL() const;
-#endif
-
-#if PLATFORM(MAC)
- KURL(NSURL*);
- operator NSURL*() const;
-#endif
-#ifdef __OBJC__
- operator NSString*() const { return m_string; }
-#endif
-
-#if PLATFORM(QT)
- KURL(const QUrl&);
- operator QUrl() const;
-#endif
-
-#ifndef NDEBUG
- void print() const;
-#endif
-
-private:
- void invalidate();
- bool isHierarchical() const;
- void init(const KURL&, const String&, const TextEncoding&);
- static bool protocolIs(const String&, const char*);
- void copyToBuffer(Vector<char, 512>& buffer) const;
-
- // Parses the given URL. The originalString parameter allows for an
- // optimization: When the source is the same as the fixed-up string,
- // it will use the passed-in string instead of allocating a new one.
- void parse(const String&);
- void parse(const char* url, const String* originalString);
-
- String m_string;
- bool m_isValid;
- int m_schemeEnd;
- int m_userStart;
- int m_userEnd;
- int m_passwordEnd;
- int m_hostEnd;
- int m_portEnd;
- int m_pathAfterLastSlash;
- int m_pathEnd;
- int m_queryEnd;
- int m_fragmentEnd;
-};
-
-bool operator==(const KURL&, const KURL&);
-bool operator==(const KURL&, const String&);
-bool operator==(const String&, const KURL&);
-bool operator!=(const KURL&, const KURL&);
-bool operator!=(const KURL&, const String&);
-bool operator!=(const String&, const KURL&);
-
-bool equalIgnoringRef(const KURL&, const KURL&);
-bool protocolHostAndPortAreEqual(const KURL&, const KURL&);
-
-const KURL& blankURL();
-
-// Functions to do URL operations on strings.
-// These are operations that aren't faster on a parsed URL.
-
-bool protocolIs(const String& url, const char* protocol);
-
-String mimeTypeFromDataURL(const String& url);
-
-// Unescapes the given string using URL escaping rules, given an optional
-// encoding (defaulting to UTF-8 otherwise). DANGER: If the URL has "%00"
-// in it, the resulting string will have embedded null characters!
-String decodeURLEscapeSequences(const String&);
-String decodeURLEscapeSequences(const String&, const TextEncoding&);
-
-String encodeWithURLEscapeSequences(const String&);
-
-// Inlines.
-
-inline bool operator==(const KURL& a, const KURL& b)
-{
- return a.string() == b.string();
-}
-
-inline bool operator==(const KURL& a, const String& b)
-{
- return a.string() == b;
-}
-
-inline bool operator==(const String& a, const KURL& b)
-{
- return a == b.string();
-}
-
-inline bool operator!=(const KURL& a, const KURL& b)
-{
- return a.string() != b.string();
-}
-
-inline bool operator!=(const KURL& a, const String& b)
-{
- return a.string() != b;
-}
-
-inline bool operator!=(const String& a, const KURL& b)
-{
- return a != b.string();
-}
-
-} // namespace WebCore
-
-namespace WTF {
-
- // KURLHash is the default hash for String
- template<typename T> struct DefaultHash;
- template<> struct DefaultHash<WebCore::KURL> {
- typedef WebCore::KURLHash Hash;
- };
-
-} // namespace WTF
-
-#endif // KURL_h
diff --git a/WebCore/platform/KURLHash.h b/WebCore/platform/KURLHash.h
deleted file mode 100644
index 4deb078..0000000
--- a/WebCore/platform/KURLHash.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef KURLHash_h
-#define KURLHash_h
-
-#include "KURL.h"
-#include "PlatformString.h"
-#include "StringHash.h"
-
-namespace WebCore {
-
- struct KURLHash {
- static unsigned hash(const KURL& key)
- {
- return key.string().impl()->hash();
- }
-
- static bool equal(const KURL& a, const KURL& b)
- {
- return StringHash::equal(a.string(), b.string());
- }
-
- static const bool safeToCompareToEmptyOrDeleted = false;
- };
-
-} // namespace WebCore
-
-namespace WTF {
-
- template<> struct HashTraits<WebCore::KURL> : GenericHashTraits<WebCore::KURL> {
- static const bool emptyValueIsZero = true;
- static void constructDeletedValue(WebCore::KURL& slot) { new (&slot) WebCore::KURL(WebCore::String(HashTableDeletedValue)); }
- static bool isDeletedValue(const WebCore::KURL& slot) { return slot.string().isHashTableDeletedValue(); }
- };
-
-} // namespace WTF
-
-#endif // KURLHash_h
diff --git a/WebCore/platform/Language.h b/WebCore/platform/Language.h
deleted file mode 100644
index 1d59c21..0000000
--- a/WebCore/platform/Language.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef Language_h
-#define Language_h
-
-namespace WebCore {
-
- class String;
-
- String defaultLanguage();
-
-}
-
-#endif
diff --git a/WebCore/platform/Length.cpp b/WebCore/platform/Length.cpp
deleted file mode 100644
index 3757d92..0000000
--- a/WebCore/platform/Length.cpp
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
- * (C) 1999 Antti Koivisto (koivisto@kde.org)
- * (C) 2001 Dirk Mueller ( mueller@kde.org )
- * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "Length.h"
-
-#include "PlatformString.h"
-#include "StringBuffer.h"
-#include <wtf/ASCIICType.h>
-#include <wtf/Assertions.h>
-
-using namespace WTF;
-
-namespace WebCore {
-
-static Length parseLength(const UChar* data, unsigned length)
-{
- if (length == 0)
- return Length(1, Relative);
-
- unsigned i = 0;
- while (i < length && isSpaceOrNewline(data[i]))
- ++i;
- if (i < length && (data[i] == '+' || data[i] == '-'))
- ++i;
- while (i < length && isASCIIDigit(data[i]))
- ++i;
- unsigned intLength = i;
- while (i < length && (isASCIIDigit(data[i]) || data[i] == '.'))
- ++i;
- unsigned doubleLength = i;
-
- // IE quirk: Skip whitespace between the number and the % character (20 % => 20%).
- while (i < length && isSpaceOrNewline(data[i]))
- ++i;
-
- bool ok;
- UChar next = (i < length) ? data[i] : ' ';
- if (next == '%') {
- // IE quirk: accept decimal fractions for percentages.
- double r = charactersToDouble(data, doubleLength, &ok);
- if (ok)
- return Length(r, Percent);
- return Length(1, Relative);
- }
- int r = charactersToIntStrict(data, intLength, &ok);
- if (next == '*') {
- if (ok)
- return Length(r, Relative);
- return Length(1, Relative);
- }
- if (ok)
- return Length(r, Fixed);
- return Length(0, Relative);
-}
-
-static int countCharacter(const UChar* data, unsigned length, UChar character)
-{
- int count = 0;
- for (int i = 0; i < static_cast<int>(length); ++i)
- count += data[i] == character;
- return count;
-}
-
-Length* newCoordsArray(const String& string, int& len)
-{
- unsigned length = string.length();
- const UChar* data = string.characters();
- StringBuffer spacified(length);
- for (unsigned i = 0; i < length; i++) {
- UChar cc = data[i];
- if (cc > '9' || (cc < '0' && cc != '-' && cc != '*' && cc != '.'))
- spacified[i] = ' ';
- else
- spacified[i] = cc;
- }
- RefPtr<StringImpl> str = StringImpl::adopt(spacified);
-
- str = str->simplifyWhiteSpace();
-
- len = countCharacter(str->characters(), str->length(), ' ') + 1;
- Length* r = new Length[len];
-
- int i = 0;
- int pos = 0;
- int pos2;
-
- while ((pos2 = str->find(' ', pos)) != -1) {
- r[i++] = parseLength(str->characters() + pos, pos2 - pos);
- pos = pos2+1;
- }
- r[i] = parseLength(str->characters() + pos, str->length() - pos);
-
- ASSERT(i == len - 1);
-
- return r;
-}
-
-Length* newLengthArray(const String& string, int& len)
-{
- RefPtr<StringImpl> str = string.impl()->simplifyWhiteSpace();
- if (!str->length()) {
- len = 1;
- return 0;
- }
-
- len = countCharacter(str->characters(), str->length(), ',') + 1;
- Length* r = new Length[len];
-
- int i = 0;
- int pos = 0;
- int pos2;
-
- while ((pos2 = str->find(',', pos)) != -1) {
- r[i++] = parseLength(str->characters() + pos, pos2 - pos);
- pos = pos2+1;
- }
-
- ASSERT(i == len - 1);
-
- // IE Quirk: If the last comma is the last char skip it and reduce len by one.
- if (str->length()-pos > 0)
- r[i] = parseLength(str->characters() + pos, str->length() - pos);
- else
- len--;
-
- return r;
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/Length.h b/WebCore/platform/Length.h
deleted file mode 100644
index b4497b6..0000000
--- a/WebCore/platform/Length.h
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- Copyright (C) 1999 Lars Knoll (knoll@kde.org)
- Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#ifndef Length_h
-#define Length_h
-
-#include <wtf/Assertions.h>
-#include <wtf/MathExtras.h>
-
-namespace WebCore {
-
-class String;
-
-const int undefinedLength = -1;
-const int percentScaleFactor = 128;
-
-enum LengthType { Auto, Relative, Percent, Fixed, Static, Intrinsic, MinIntrinsic };
-
-struct Length {
- Length()
- : m_value(0)
- {
- }
-
- Length(LengthType t)
- : m_value(t)
- {
- }
-
- Length(int v, LengthType t, bool q = false)
- : m_value((v * 16) | (q << 3) | t) // FIXME: Doesn't work if the passed-in value is very large!
- {
- ASSERT(t != Percent);
- }
-
- Length(double v, LengthType t, bool q = false)
- : m_value(static_cast<int>(v * percentScaleFactor) * 16 | (q << 3) | t)
- {
- ASSERT(t == Percent);
- }
-
- bool operator==(const Length& o) const { return m_value == o.m_value; }
- bool operator!=(const Length& o) const { return m_value != o.m_value; }
-
- int value() const {
- ASSERT(type() != Percent);
- return rawValue();
- }
-
- int rawValue() const { return (m_value & ~0xF) / 16; }
-
- double percent() const
- {
- ASSERT(type() == Percent);
- return static_cast<double>(rawValue()) / percentScaleFactor;
- }
-
- LengthType type() const { return static_cast<LengthType>(m_value & 7); }
- bool quirk() const { return (m_value >> 3) & 1; }
-
- void setValue(LengthType t, int value)
- {
- ASSERT(t != Percent);
- setRawValue(t, value);
- }
-
- void setRawValue(LengthType t, int value) { m_value = value * 16 | (m_value & 0x8) | t; }
-
- void setValue(int value)
- {
- ASSERT(!value || type() != Percent);
- setRawValue(value);
- }
-
- void setRawValue(int value) { m_value = value * 16 | (m_value & 0xF); }
-
- void setValue(LengthType t, double value)
- {
- ASSERT(t == Percent);
- m_value = static_cast<int>(value * percentScaleFactor) * 16 | (m_value & 0x8) | t;
- }
-
- void setValue(double value)
- {
- ASSERT(type() == Percent);
- m_value = static_cast<int>(value * percentScaleFactor) * 16 | (m_value & 0xF);
- }
-
- // note: works only for certain types, returns undefinedLength otherwise
- int calcValue(int maxValue, bool roundPercentages = false) const
- {
- switch (type()) {
- case Fixed:
- return value();
- case Percent:
- if (roundPercentages)
- return static_cast<int>(round(maxValue * percent() / 100.0));
- return maxValue * rawValue() / (100 * percentScaleFactor);
- case Auto:
- return maxValue;
- default:
- return undefinedLength;
- }
- }
-
- int calcMinValue(int maxValue, bool roundPercentages = false) const
- {
- switch (type()) {
- case Fixed:
- return value();
- case Percent:
- if (roundPercentages)
- return static_cast<int>(round(maxValue * percent() / 100.0));
- return maxValue * rawValue() / (100 * percentScaleFactor);
- case Auto:
- default:
- return 0;
- }
- }
-
- float calcFloatValue(int maxValue) const
- {
- switch (type()) {
- case Fixed:
- return static_cast<float>(value());
- case Percent:
- return static_cast<float>(maxValue * percent() / 100.0);
- case Auto:
- return static_cast<float>(maxValue);
- default:
- return static_cast<float>(undefinedLength);
- }
- }
-
- bool isUndefined() const { return rawValue() == undefinedLength; }
- bool isZero() const { return !(m_value & ~0xF); }
- bool isPositive() const { return rawValue() > 0; }
- bool isNegative() const { return rawValue() < 0; }
-
- bool isAuto() const { return type() == Auto; }
- bool isRelative() const { return type() == Relative; }
- bool isPercent() const { return type() == Percent; }
- bool isFixed() const { return type() == Fixed; }
- bool isStatic() const { return type() == Static; }
- bool isIntrinsicOrAuto() const { return type() == Auto || type() == MinIntrinsic || type() == Intrinsic; }
-
- Length blend(const Length& from, double progress) const
- {
- // Blend two lengths to produce a new length that is in between them. Used for animation.
- if (!from.isZero() && !isZero() && from.type() != type())
- return *this;
-
- if (from.isZero() && isZero())
- return *this;
-
- LengthType resultType = type();
- if (isZero())
- resultType = from.type();
-
- if (resultType == Percent) {
- double fromPercent = from.isZero() ? 0. : from.percent();
- double toPercent = isZero() ? 0. : percent();
- return Length(fromPercent + (toPercent - fromPercent) * progress, Percent);
- }
-
- int fromValue = from.isZero() ? 0 : from.value();
- int toValue = isZero() ? 0 : value();
- return Length(int(fromValue + (toValue - fromValue) * progress), resultType);
- }
-
-private:
- int m_value;
-};
-
-Length* newCoordsArray(const String&, int& len);
-Length* newLengthArray(const String&, int& len);
-
-} // namespace WebCore
-
-#endif // Length_h
diff --git a/WebCore/platform/LengthBox.h b/WebCore/platform/LengthBox.h
deleted file mode 100644
index 7d7698d..0000000
--- a/WebCore/platform/LengthBox.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- Copyright (C) 1999 Lars Knoll (knoll@kde.org)
- Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#ifndef LengthBox_h
-#define LengthBox_h
-
-#include "Length.h"
-
-namespace WebCore {
-
-struct LengthBox {
- LengthBox()
- {
- }
-
- LengthBox(LengthType t)
- : m_left(t)
- , m_right(t)
- , m_top(t)
- , m_bottom(t)
- {
- }
-
- LengthBox(int v)
- : m_left(Length(v, Fixed))
- , m_right(Length(v, Fixed))
- , m_top(Length(v, Fixed))
- , m_bottom(Length(v, Fixed))
- {
- }
-
- LengthBox(int t, int r, int b, int l)
- : m_left(Length(l, Fixed))
- , m_right(Length(r, Fixed))
- , m_top(Length(t, Fixed))
- , m_bottom(Length(b, Fixed))
- {
- }
-
- Length left() const { return m_left; }
- Length right() const { return m_right; }
- Length top() const { return m_top; }
- Length bottom() const { return m_bottom; }
-
- bool operator==(const LengthBox& o) const
- {
- return m_left == o.m_left && m_right == o.m_right && m_top == o.m_top && m_bottom == o.m_bottom;
- }
-
- bool operator!=(const LengthBox& o) const
- {
- return !(*this == o);
- }
-
- bool nonZero() const
- {
- return !(m_left.isZero() && m_right.isZero() && m_top.isZero() && m_bottom.isZero());
- }
-
- Length m_left;
- Length m_right;
- Length m_top;
- Length m_bottom;
-};
-
-} // namespace WebCore
-
-#endif // LengthBox_h
diff --git a/WebCore/platform/LengthSize.h b/WebCore/platform/LengthSize.h
deleted file mode 100644
index dbcc83d..0000000
--- a/WebCore/platform/LengthSize.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- Copyright (C) 1999 Lars Knoll (knoll@kde.org)
- Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#ifndef LengthSize_h
-#define LengthSize_h
-
-#include "Length.h"
-
-namespace WebCore {
-
-struct LengthSize {
-public:
- LengthSize()
- {
- }
-
- LengthSize(Length width, Length height)
- : m_width(width)
- , m_height(height)
- {
- }
-
- bool operator==(const LengthSize& o) const
- {
- return m_width == o.m_width && m_height == o.m_height;
- }
-
- void setWidth(Length width) { m_width = width; }
- Length width() const { return m_width; }
-
- void setHeight(Length height) { m_height = height; }
- Length height() const { return m_height; }
-
-private:
- Length m_width;
- Length m_height;
-};
-
-} // namespace WebCore
-
-#endif // LengthSize_h
diff --git a/WebCore/platform/LocalizedStrings.h b/WebCore/platform/LocalizedStrings.h
deleted file mode 100644
index 9b11a92..0000000
--- a/WebCore/platform/LocalizedStrings.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LocalizedStrings_h
-#define LocalizedStrings_h
-
-namespace WebCore {
-
- class String;
- class IntSize;
-
- String inputElementAltText();
- String resetButtonDefaultLabel();
- String searchableIndexIntroduction();
- String submitButtonDefaultLabel();
- String fileButtonChooseFileLabel();
- String fileButtonNoFileSelectedLabel();
- String copyImageUnknownFileLabel();
- String contextMenuItemTagOpenLinkInNewWindow();
- String contextMenuItemTagDownloadLinkToDisk();
- String contextMenuItemTagCopyLinkToClipboard();
- String contextMenuItemTagOpenImageInNewWindow();
- String contextMenuItemTagDownloadImageToDisk();
- String contextMenuItemTagCopyImageToClipboard();
- String contextMenuItemTagOpenFrameInNewWindow();
- String contextMenuItemTagCopy();
- String contextMenuItemTagGoBack();
- String contextMenuItemTagGoForward();
- String contextMenuItemTagStop();
- String contextMenuItemTagReload();
- String contextMenuItemTagCut();
- String contextMenuItemTagPaste();
-#if PLATFORM(GTK)
- String contextMenuItemTagDelete();
- String contextMenuItemTagSelectAll();
- String contextMenuItemTagInputMethods();
- String contextMenuItemTagUnicode();
-#endif
- String contextMenuItemTagNoGuessesFound();
- String contextMenuItemTagIgnoreSpelling();
- String contextMenuItemTagLearnSpelling();
- String contextMenuItemTagSearchWeb();
- String contextMenuItemTagLookUpInDictionary();
- String contextMenuItemTagOpenLink();
- String contextMenuItemTagIgnoreGrammar();
- String contextMenuItemTagSpellingMenu();
- String contextMenuItemTagShowSpellingPanel(bool show);
- String contextMenuItemTagCheckSpelling();
- String contextMenuItemTagCheckSpellingWhileTyping();
- String contextMenuItemTagCheckGrammarWithSpelling();
- String contextMenuItemTagFontMenu();
- String contextMenuItemTagBold();
- String contextMenuItemTagItalic();
- String contextMenuItemTagUnderline();
- String contextMenuItemTagOutline();
- String contextMenuItemTagWritingDirectionMenu();
- String contextMenuItemTagDefaultDirection();
- String contextMenuItemTagLeftToRight();
- String contextMenuItemTagRightToLeft();
-#if PLATFORM(MAC)
- String contextMenuItemTagSearchInSpotlight();
- String contextMenuItemTagShowFonts();
- String contextMenuItemTagStyles();
- String contextMenuItemTagShowColors();
- String contextMenuItemTagSpeechMenu();
- String contextMenuItemTagStartSpeaking();
- String contextMenuItemTagStopSpeaking();
-#endif
- String contextMenuItemTagInspectElement();
-
- String searchMenuNoRecentSearchesText();
- String searchMenuRecentSearchesText();
- String searchMenuClearRecentSearchesText();
-
- String AXWebAreaText();
- String AXLinkText();
- String AXListMarkerText();
- String AXImageMapText();
- String AXHeadingText();
- String AXDefinitionListTermText();
- String AXDefinitionListDefinitionText();
-
- String AXButtonActionVerb();
- String AXRadioButtonActionVerb();
- String AXTextFieldActionVerb();
- String AXCheckedCheckBoxActionVerb();
- String AXUncheckedCheckBoxActionVerb();
- String AXLinkActionVerb();
-
- String multipleFileUploadText(unsigned numberOfFiles);
- String unknownFileSizeText();
-
-#if PLATFORM(WIN)
- String uploadFileText();
- String allFilesText();
-#endif
-
- String imageTitle(const String& filename, const IntSize& size);
-}
-
-#endif
diff --git a/WebCore/platform/Logging.cpp b/WebCore/platform/Logging.cpp
deleted file mode 100644
index a1aa3d6..0000000
--- a/WebCore/platform/Logging.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Logging.h"
-
-namespace WebCore {
-
-WTFLogChannel LogNotYetImplemented = { 0x00000001, "WebCoreLogLevel", WTFLogChannelOff };
-
-WTFLogChannel LogFrames = { 0x00000010, "WebCoreLogLevel", WTFLogChannelOff };
-WTFLogChannel LogLoading = { 0x00000020, "WebCoreLogLevel", WTFLogChannelOff };
-
-WTFLogChannel LogPopupBlocking = { 0x00000040, "WebCoreLogLevel", WTFLogChannelOff };
-
-WTFLogChannel LogEvents = { 0x00000080, "WebCoreLogLevel", WTFLogChannelOff };
-WTFLogChannel LogEditing = { 0x00000100, "WebCoreLogLevel", WTFLogChannelOff };
-WTFLogChannel LogTextConversion = { 0x00000200, "WebCoreLogLevel", WTFLogChannelOff };
-
-WTFLogChannel LogIconDatabase = { 0x00000400, "WebCoreLogLevel", WTFLogChannelOff };
-WTFLogChannel LogSQLDatabase = { 0x00000800, "WebCoreLogLevel", WTFLogChannelOff };
-
-WTFLogChannel LogSpellingAndGrammar ={ 0x00001000, "WebCoreLogLevel", WTFLogChannelOff };
-WTFLogChannel LogBackForward = { 0x00002000, "WebCoreLogLevel", WTFLogChannelOff };
-WTFLogChannel LogHistory = { 0x00004000, "WebCoreLogLevel", WTFLogChannelOff };
-WTFLogChannel LogPageCache = { 0x00008000, "WebCoreLogLevel", WTFLogChannelOff };
-
-WTFLogChannel LogPlatformLeaks = { 0x00010000, "WebCoreLogLevel", WTFLogChannelOff };
-
-WTFLogChannel LogNetwork = { 0x00100000, "WebCoreLogLevel", WTFLogChannelOff };
-WTFLogChannel LogFTP = { 0x00200000, "WebCoreLogLevel", WTFLogChannelOff };
-WTFLogChannel LogThreading = { 0x00400000, "WebCoreLogLevel", WTFLogChannelOff };
-WTFLogChannel LogStorageAPI = { 0x00800000, "WebCoreLogLevel", WTFLogChannelOff };
-
-WTFLogChannel LogMedia = { 0x01000000, "WebCoreLogLevel", WTFLogChannelOff };
-
-WTFLogChannel LogPlugin = { 0x02000000, "WebCoreLogLevel", WTFLogChannelOff };
-WTFLogChannel LogArchives = { 0x04000000, "WebCoreLogLevel", WTFLogChannelOff };
-
-}
diff --git a/WebCore/platform/Logging.h b/WebCore/platform/Logging.h
deleted file mode 100644
index 844ac3a..0000000
--- a/WebCore/platform/Logging.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef Logging_h
-#define Logging_h
-
-#include <wtf/Assertions.h>
-
-#ifndef LOG_CHANNEL_PREFIX
-#define LOG_CHANNEL_PREFIX Log
-#endif
-
-namespace WebCore {
-
- extern WTFLogChannel LogNotYetImplemented;
- extern WTFLogChannel LogFrames;
- extern WTFLogChannel LogLoading;
- extern WTFLogChannel LogPopupBlocking;
- extern WTFLogChannel LogEvents;
- extern WTFLogChannel LogEditing;
- extern WTFLogChannel LogTextConversion;
- extern WTFLogChannel LogIconDatabase;
- extern WTFLogChannel LogSQLDatabase;
- extern WTFLogChannel LogSpellingAndGrammar;
- extern WTFLogChannel LogBackForward;
- extern WTFLogChannel LogHistory;
- extern WTFLogChannel LogPageCache;
- extern WTFLogChannel LogPlatformLeaks;
- extern WTFLogChannel LogNetwork;
- extern WTFLogChannel LogFTP;
- extern WTFLogChannel LogThreading;
- extern WTFLogChannel LogStorageAPI;
- extern WTFLogChannel LogMedia;
- extern WTFLogChannel LogPlugin;
- extern WTFLogChannel LogArchives;
-
- void InitializeLoggingChannelsIfNecessary();
-}
-
-#endif // Logging_h
diff --git a/WebCore/platform/MIMETypeRegistry.cpp b/WebCore/platform/MIMETypeRegistry.cpp
deleted file mode 100644
index 70d953a..0000000
--- a/WebCore/platform/MIMETypeRegistry.cpp
+++ /dev/null
@@ -1,366 +0,0 @@
-/*
- * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "MIMETypeRegistry.h"
-
-#if ENABLE(ARCHIVE) // ANDROID extension: disabled to reduce code size
-#include "ArchiveFactory.h"
-#endif
-#include "MediaPlayer.h"
-#include "StringHash.h"
-#include <wtf/HashMap.h>
-#include <wtf/HashSet.h>
-
-#if PLATFORM(CG)
-#include <ApplicationServices/ApplicationServices.h>
-#include <wtf/RetainPtr.h>
-#endif
-#if PLATFORM(QT)
-#include <qimagereader.h>
-#include <qimagewriter.h>
-#endif
-
-namespace WebCore {
-
-static HashSet<String>* supportedImageResourceMIMETypes;
-static HashSet<String>* supportedImageMIMETypes;
-static HashSet<String>* supportedImageMIMETypesForEncoding;
-static HashSet<String>* supportedJavaScriptMIMETypes;
-static HashSet<String>* supportedNonImageMIMETypes;
-static HashSet<String>* supportedMediaMIMETypes;
-
-#if PLATFORM(CG)
-extern String getMIMETypeForUTI(const String& uti);
-#endif
-
-static void initializeSupportedImageMIMETypes()
-{
-#if PLATFORM(CG)
- RetainPtr<CFArrayRef> supportedTypes(AdoptCF, CGImageSourceCopyTypeIdentifiers());
- CFIndex count = CFArrayGetCount(supportedTypes.get());
- for (CFIndex i = 0; i < count; i++) {
- RetainPtr<CFStringRef> supportedType(AdoptCF, reinterpret_cast<CFStringRef>(CFArrayGetValueAtIndex(supportedTypes.get(), i)));
- String mimeType = getMIMETypeForUTI(supportedType.get());
- if (!mimeType.isEmpty()) {
- supportedImageMIMETypes->add(mimeType);
- supportedImageResourceMIMETypes->add(mimeType);
- }
- }
-
- // On Tiger and Leopard, com.microsoft.bmp doesn't have a MIME type in the registry.
- supportedImageMIMETypes->add("image/bmp");
- supportedImageResourceMIMETypes->add("image/bmp");
-
- // Favicons don't have a MIME type in the registry either.
- supportedImageMIMETypes->add("image/x-icon");
- supportedImageResourceMIMETypes->add("image/x-icon");
-
- // We only get one MIME type per UTI, hence our need to add these manually
- supportedImageMIMETypes->add("image/pjpeg");
- supportedImageResourceMIMETypes->add("image/pjpeg");
-
- // We don't want to try to treat all binary data as an image
- supportedImageMIMETypes->remove("application/octet-stream");
- supportedImageResourceMIMETypes->remove("application/octet-stream");
-
- // Don't treat pdf/postscript as images directly
- supportedImageMIMETypes->remove("application/pdf");
- supportedImageMIMETypes->remove("application/postscript");
-
-#elif PLATFORM(QT)
- QList<QByteArray> formats = QImageReader::supportedImageFormats();
- for (size_t i = 0; i < formats.size(); ++i) {
-#if ENABLE(SVG)
- /*
- * Qt has support for SVG, but we want to use KSVG2
- */
- if (formats.at(i).toLower().startsWith("svg"))
- continue;
-#endif
- String mimeType = MIMETypeRegistry::getMIMETypeForExtension(formats.at(i).constData());
- supportedImageMIMETypes->add(mimeType);
- supportedImageResourceMIMETypes->add(mimeType);
- }
-#elif PLATFORM(ANDROID)
- static const char* types[] = {
- "image/jpeg",
- "image/png",
- "image/gif",
- "image/bmp",
- "image/x-icon", // ico
- "image/ico",
- "image/x-xbitmap" // xbm
- };
- for (size_t i = 0; i < sizeof(types) / sizeof(types[0]); ++i) {
- supportedImageMIMETypes->add(types[i]);
- supportedImageResourceMIMETypes->add(types[i]);
- }
- // Checked Safari impl, it seems that the HTTP stack returns
- // multiple responses, the initial response, and then one for
- // multipart segment. Each response is sent to the same ResourceLoader
- // so for us to support this we would need to do the same.
- supportedNonImageMIMETypes->remove("multipart/x-mixed-replace");
-#if !ENABLE(XSLT)
- supportedNonImageMIMETypes->remove("text/xsl");
-#endif
-#else
- // assume that all implementations at least support the following standard
- // image types:
- static const char* types[] = {
- "image/jpeg",
- "image/png",
- "image/gif",
- "image/bmp",
- "image/x-icon", // ico
- "image/x-xbitmap" // xbm
- };
- for (size_t i = 0; i < sizeof(types) / sizeof(types[0]); ++i) {
- supportedImageMIMETypes->add(types[i]);
- supportedImageResourceMIMETypes->add(types[i]);
- }
-#endif
-}
-
-static void initializeSupportedImageMIMETypesForEncoding()
-{
- supportedImageMIMETypesForEncoding = new HashSet<String>;
-
-#if PLATFORM(CG)
-#if PLATFORM(MAC)
- RetainPtr<CFArrayRef> supportedTypes(AdoptCF, CGImageDestinationCopyTypeIdentifiers());
- CFIndex count = CFArrayGetCount(supportedTypes.get());
- for (CFIndex i = 0; i < count; i++) {
- RetainPtr<CFStringRef> supportedType(AdoptCF, reinterpret_cast<CFStringRef>(CFArrayGetValueAtIndex(supportedTypes.get(), i)));
- String mimeType = getMIMETypeForUTI(supportedType.get());
- if (!mimeType.isEmpty())
- supportedImageMIMETypesForEncoding->add(mimeType);
- }
-#else
- // FIXME: Add Windows support for all the supported UTI's when a way to convert from MIMEType to UTI reliably is found.
- // For now, only support PNG, JPEG and GIF. See <rdar://problem/6095286>.
- supportedImageMIMETypesForEncoding->add("image/png");
- supportedImageMIMETypesForEncoding->add("image/jpeg");
- supportedImageMIMETypesForEncoding->add("image/gif");
-#endif
-#elif PLATFORM(QT)
- QList<QByteArray> formats = QImageWriter::supportedImageFormats();
- for (size_t i = 0; i < formats.size(); ++i) {
- String mimeType = MIMETypeRegistry::getMIMETypeForExtension(formats.at(i).constData());
- supportedImageMIMETypesForEncoding->add(mimeType);
- }
-#elif PLATFORM(CAIRO)
- supportedImageMIMETypesForEncoding->add("image/png");
-#endif
-}
-
-static void initializeSupportedJavaScriptMIMETypes()
-{
- /*
- Mozilla 1.8 and WinIE 7 both accept text/javascript and text/ecmascript.
- Mozilla 1.8 accepts application/javascript, application/ecmascript, and application/x-javascript, but WinIE 7 doesn't.
- WinIE 7 accepts text/javascript1.1 - text/javascript1.3, text/jscript, and text/livescript, but Mozilla 1.8 doesn't.
- Mozilla 1.8 allows leading and trailing whitespace, but WinIE 7 doesn't.
- Mozilla 1.8 and WinIE 7 both accept the empty string, but neither accept a whitespace-only string.
- We want to accept all the values that either of these browsers accept, but not other values.
- */
- static const char* types[] = {
- "text/javascript",
- "text/ecmascript",
- "application/javascript",
- "application/ecmascript",
- "application/x-javascript",
- "text/javascript1.1",
- "text/javascript1.2",
- "text/javascript1.3",
- "text/jscript",
- "text/livescript",
- };
- for (size_t i = 0; i < sizeof(types) / sizeof(types[0]); ++i)
- supportedJavaScriptMIMETypes->add(types[i]);
-}
-
-static void initializeSupportedNonImageMimeTypes()
-{
- static const char* types[] = {
- "text/html",
- "text/xml",
- "text/xsl",
- "text/plain",
- "text/",
- "application/xml",
- "application/xhtml+xml",
- "application/rss+xml",
- "application/atom+xml",
-#if ENABLE(SVG)
- "image/svg+xml",
-#endif
-#if ENABLE(FTPDIR)
- "application/x-ftp-directory",
-#endif
- "multipart/x-mixed-replace"
- };
- for (size_t i = 0; i < sizeof(types)/sizeof(types[0]); ++i)
- supportedNonImageMIMETypes->add(types[i]);
-
-#if ENABLE(ARCHIVE) // ANDROID extension: disabled to reduce code size
- ArchiveFactory::registerKnownArchiveMIMETypes();
-#endif
-}
-
-static void initializeSupportedMediaMIMETypes()
-{
- supportedMediaMIMETypes = new HashSet<String>;
-#if ENABLE(VIDEO)
- MediaPlayer::getSupportedTypes(*supportedMediaMIMETypes);
-#endif
-}
-
-static void initializeMIMETypeRegistry()
-{
- supportedJavaScriptMIMETypes = new HashSet<String>;
- initializeSupportedJavaScriptMIMETypes();
-
- supportedNonImageMIMETypes = new HashSet<String>(*supportedJavaScriptMIMETypes);
- initializeSupportedNonImageMimeTypes();
-
- supportedImageResourceMIMETypes = new HashSet<String>;
- supportedImageMIMETypes = new HashSet<String>;
- initializeSupportedImageMIMETypes();
-}
-
-String MIMETypeRegistry::getMIMETypeForPath(const String& path)
-{
- int pos = path.reverseFind('.');
- if (pos >= 0) {
- String extension = path.substring(pos + 1);
- String result = getMIMETypeForExtension(extension);
- if (result.length())
- return result;
- }
- return "application/octet-stream";
-}
-
-bool MIMETypeRegistry::isSupportedImageMIMEType(const String& mimeType)
-{
- if (mimeType.isEmpty())
- return false;
- if (!supportedImageMIMETypes)
- initializeMIMETypeRegistry();
- return supportedImageMIMETypes->contains(mimeType);
-}
-
-bool MIMETypeRegistry::isSupportedImageResourceMIMEType(const String& mimeType)
-{
- if (mimeType.isEmpty())
- return false;
- if (!supportedImageResourceMIMETypes)
- initializeMIMETypeRegistry();
- return supportedImageResourceMIMETypes->contains(mimeType);
-}
-
-bool MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(const String& mimeType)
-{
- if (mimeType.isEmpty())
- return false;
- if (!supportedImageMIMETypesForEncoding)
- initializeSupportedImageMIMETypesForEncoding();
- return supportedImageMIMETypesForEncoding->contains(mimeType);
-}
-
-bool MIMETypeRegistry::isSupportedJavaScriptMIMEType(const String& mimeType)
-{
- if (mimeType.isEmpty())
- return false;
- if (!supportedJavaScriptMIMETypes)
- initializeMIMETypeRegistry();
- return supportedJavaScriptMIMETypes->contains(mimeType);
-}
-
-bool MIMETypeRegistry::isSupportedNonImageMIMEType(const String& mimeType)
-{
- if (mimeType.isEmpty())
- return false;
- if (!supportedNonImageMIMETypes)
- initializeMIMETypeRegistry();
- return supportedNonImageMIMETypes->contains(mimeType);
-}
-
-bool MIMETypeRegistry::isSupportedMediaMIMEType(const String& mimeType)
-{
- if (mimeType.isEmpty())
- return false;
- if (!supportedMediaMIMETypes)
- initializeSupportedMediaMIMETypes();
- return supportedMediaMIMETypes->contains(mimeType);
-}
-
-bool MIMETypeRegistry::isJavaAppletMIMEType(const String& mimeType)
-{
- // Since this set is very limited and is likely to remain so we won't bother with the overhead
- // of using a hash set.
- // Any of the MIME types below may be followed by any number of specific versions of the JVM,
- // which is why we use startsWith()
- return mimeType.startsWith("application/x-java-applet", false)
- || mimeType.startsWith("application/x-java-bean", false)
- || mimeType.startsWith("application/x-java-vm", false);
-}
-
-HashSet<String>& MIMETypeRegistry::getSupportedImageMIMETypes()
-{
- if (!supportedImageMIMETypes)
- initializeMIMETypeRegistry();
- return *supportedImageMIMETypes;
-}
-
-HashSet<String>& MIMETypeRegistry::getSupportedImageResourceMIMETypes()
-{
- if (!supportedImageResourceMIMETypes)
- initializeMIMETypeRegistry();
- return *supportedImageResourceMIMETypes;
-}
-
-HashSet<String>& MIMETypeRegistry::getSupportedImageMIMETypesForEncoding()
-{
- if (!supportedImageMIMETypesForEncoding)
- initializeSupportedImageMIMETypesForEncoding();
- return *supportedImageMIMETypesForEncoding;
-}
-
-HashSet<String>& MIMETypeRegistry::getSupportedNonImageMIMETypes()
-{
- if (!supportedNonImageMIMETypes)
- initializeMIMETypeRegistry();
- return *supportedNonImageMIMETypes;
-}
-
-HashSet<String>& MIMETypeRegistry::getSupportedMediaMIMETypes()
-{
- if (!supportedMediaMIMETypes)
- initializeSupportedMediaMIMETypes();
- return *supportedMediaMIMETypes;
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/MIMETypeRegistry.h b/WebCore/platform/MIMETypeRegistry.h
deleted file mode 100644
index be741a4..0000000
--- a/WebCore/platform/MIMETypeRegistry.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef MIMETypeRegistry_h
-#define MIMETypeRegistry_h
-
-#include "PlatformString.h"
-#include "StringHash.h"
-#include <wtf/HashSet.h>
-#include <wtf/Vector.h>
-
-namespace WebCore {
-
-class MIMETypeRegistry {
-public:
- static String getMIMETypeForExtension(const String& ext);
- static Vector<String> getExtensionsForMIMEType(const String& type);
- static String getPreferredExtensionForMIMEType(const String& type);
- static String getMIMETypeForPath(const String& path);
-
- // Check to see if a mime type is suitable for being loaded inline as an
- // image (e.g., <img> tags).
- static bool isSupportedImageMIMEType(const String& mimeType);
-
- // Check to see if a mime type is suitable for being loaded as an image
- // document in a frame.
- static bool isSupportedImageResourceMIMEType(const String& mimeType);
-
- // Check to see if a mime type is suitable for being encoded.
- static bool isSupportedImageMIMETypeForEncoding(const String& mimeType);
-
- // Check to see if a mime type is suitable for being loaded as a JavaScript
- // resource.
- static bool isSupportedJavaScriptMIMEType(const String& mimeType);
-
- // Check to see if a non-image mime type is suitable for being loaded as a
- // document in a frame. Includes supported JavaScript MIME types.
- static bool isSupportedNonImageMIMEType(const String& mimeType);
-
- // Check to see if a mime type is suitable for being loaded using <video> and <audio>
- static bool isSupportedMediaMIMEType(const String& mimeType);
-
- // Check to see if a mime type is a valid Java applet mime type
- static bool isJavaAppletMIMEType(const String& mimeType);
-
- static HashSet<String>& getSupportedImageMIMETypes();
- static HashSet<String>& getSupportedImageResourceMIMETypes();
- static HashSet<String>& getSupportedImageMIMETypesForEncoding();
- static HashSet<String>& getSupportedNonImageMIMETypes();
- static HashSet<String>& getSupportedMediaMIMETypes();
-};
-
-} // namespace WebCore
-
-#endif // MIMETypeRegistry_h
diff --git a/WebCore/platform/NotImplemented.h b/WebCore/platform/NotImplemented.h
deleted file mode 100644
index 862f111..0000000
--- a/WebCore/platform/NotImplemented.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef NotImplemented_h
-#define NotImplemented_h
-
-#include "Logging.h"
-#include <wtf/Assertions.h>
-
-#if PLATFORM(GTK)
- #define supressNotImplementedWarning() getenv("DISABLE_NI_WARNING")
-#elif PLATFORM(QT)
- #include <QByteArray>
- #define supressNotImplementedWarning() !qgetenv("DISABLE_NI_WARNING").isEmpty()
-#else
- #define supressNotImplementedWarning() false
-#endif
-
-#if defined ANDROID
-
- #if 1 && defined LOG_TAG
- #ifndef _LIBS_UTILS_LOG_H
- #undef LOG
- #include <utils/Log.h>
- #endif
- #define notImplemented() LOGV("%s: notImplemented\n", __PRETTY_FUNCTION__)
- #define lowPriority_notImplemented() //printf("%s\n", __PRETTY_FUNCTION__)
- #define verifiedOk() // not a problem that it's not implemented
- #else
- #define notImplemented() fprintf(stderr, "%s\n", __PRETTY_FUNCTION__)
- #endif
-#elif defined(NDEBUG)
- #define notImplemented() ((void)0)
-#else
-
-#define notImplemented() do { \
- static bool havePrinted = false; \
- if (!havePrinted && !supressNotImplementedWarning()) { \
- WTFLogVerbose(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, &LogNotYetImplemented, "UNIMPLEMENTED: "); \
- havePrinted = true; \
- } \
- } while (0)
-
-#endif // NDEBUG
-
-#endif // NotImplemented_h
diff --git a/WebCore/platform/Pasteboard.h b/WebCore/platform/Pasteboard.h
deleted file mode 100644
index f98683f..0000000
--- a/WebCore/platform/Pasteboard.h
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef Pasteboard_h
-#define Pasteboard_h
-
-#include <wtf/Forward.h>
-#include <wtf/HashSet.h>
-#include <wtf/Noncopyable.h>
-
-#if PLATFORM(MAC)
-#include <wtf/RetainPtr.h>
-#endif
-
-#if PLATFORM(GTK)
-#include <PasteboardHelper.h>
-#endif
-
-// FIXME: This class is too high-level to be in the platform directory, since it
-// uses the DOM and makes calls to Editor. It should either be divested of its
-// knowledge of the frame and editor or moved into the editing directory.
-
-#if PLATFORM(MAC)
-class NSFileWrapper;
-class NSPasteboard;
-class NSArray;
-#endif
-
-#if PLATFORM(WIN)
-#include <windows.h>
-typedef struct HWND__* HWND;
-#endif
-
-#if PLATFORM(CHROMIUM)
-#include "PasteboardPrivate.h"
-#endif
-
-namespace WebCore {
-
-#if PLATFORM(MAC)
-extern NSString *WebArchivePboardType;
-extern NSString *WebSmartPastePboardType;
-extern NSString *WebURLNamePboardType;
-extern NSString *WebURLPboardType;
-extern NSString *WebURLsWithTitlesPboardType;
-#endif
-
-class CString;
-class DocumentFragment;
-class Frame;
-class HitTestResult;
-class KURL;
-class Node;
-class Range;
-class String;
-
-class Pasteboard : Noncopyable {
-public:
-#if PLATFORM(MAC)
- //Helper functions to allow Clipboard to share code
- static void writeSelection(NSPasteboard* pasteboard, Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame);
- static void writeURL(NSPasteboard* pasteboard, NSArray* types, const KURL& url, const String& titleStr, Frame* frame);
-#endif
-
- static Pasteboard* generalPasteboard();
- void writeSelection(Range*, bool canSmartCopyOrDelete, Frame*);
- void writeURL(const KURL&, const String&, Frame* = 0);
- void writeImage(Node*, const KURL&, const String& title);
-#if PLATFORM(MAC)
- void writeFileWrapperAsRTFDAttachment(NSFileWrapper*);
-#endif
- void clear();
- bool canSmartReplace();
- PassRefPtr<DocumentFragment> documentFragment(Frame*, PassRefPtr<Range>, bool allowPlainText, bool& chosePlainText);
- String plainText(Frame* = 0);
-#if PLATFORM(QT)
- bool isSelectionMode() const;
- void setSelectionMode(bool selectionMode);
-#endif
-
-#if PLATFORM(GTK)
- void setHelper(PasteboardHelper*);
-#endif
-
-private:
- Pasteboard();
- ~Pasteboard();
-
-#if PLATFORM(MAC)
- Pasteboard(NSPasteboard *);
- RetainPtr<NSPasteboard> m_pasteboard;
-#endif
-
-#if PLATFORM(WIN)
- HWND m_owner;
-#endif
-
-#if PLATFORM(GTK)
- PasteboardHelper* m_helper;
-#endif
-
-#if PLATFORM(QT)
- bool m_selectionMode;
-#endif
-
-#if PLATFORM(CHROMIUM)
- PasteboardPrivate p;
-#endif
-};
-
-} // namespace WebCore
-
-#endif // Pasteboard_h
diff --git a/WebCore/platform/PlatformKeyboardEvent.h b/WebCore/platform/PlatformKeyboardEvent.h
deleted file mode 100644
index 34c05fe..0000000
--- a/WebCore/platform/PlatformKeyboardEvent.h
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2008 Collabora, Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef PlatformKeyboardEvent_h
-#define PlatformKeyboardEvent_h
-
-#include "PlatformString.h"
-#include <wtf/Platform.h>
-
-#if PLATFORM(MAC)
-#include <wtf/RetainPtr.h>
-#ifdef __OBJC__
-@class NSEvent;
-#else
-class NSEvent;
-#endif
-#endif
-
-#if PLATFORM(WIN)
-typedef struct HWND__ *HWND;
-typedef unsigned WPARAM;
-typedef long LPARAM;
-#endif
-
-#if PLATFORM(GTK)
-typedef struct _GdkEventKey GdkEventKey;
-#endif
-
-#if PLATFORM(QT)
-QT_BEGIN_NAMESPACE
-class QKeyEvent;
-QT_END_NAMESPACE
-#endif
-
-#if PLATFORM(WX)
-class wxKeyEvent;
-#endif
-
-namespace WebCore {
-
- class PlatformKeyboardEvent {
- public:
- enum Type {
- // KeyDown is sent by platforms such as Mac OS X, gtk and Qt, and has information about both physical pressed key, and its translation.
- // For DOM processing, it needs to be disambiguated as RawKeyDown or Char event.
- KeyDown,
-
- // KeyUp is sent by all platforms.
- KeyUp,
-
- // These events are sent by platforms such as Windows and wxWidgets. RawKeyDown only has information about a physical key, and Char
- // only has information about a character it was translated into.
- RawKeyDown,
- Char
- };
-
- enum ModifierKey {
- AltKey = 1 << 0,
- CtrlKey = 1 << 1,
- MetaKey = 1 << 2,
- ShiftKey = 1 << 3,
- };
-
- Type type() const { return m_type; }
- void disambiguateKeyDownEvent(Type, bool backwardCompatibilityMode = false); // Only used on platforms that need it, i.e. those that generate KeyDown events.
-
- // Text as as generated by processing a virtual key code with a keyboard layout
- // (in most cases, just a character code, but the layout can emit several
- // characters in a single keypress event on some platforms).
- // This may bear no resemblance to the ultimately inserted text if an input method
- // processes the input.
- // Will be null for KeyUp and RawKeyDown events.
- String text() const { return m_text; }
-
- // Text that would have been generated by the keyboard if no modifiers were pressed
- // (except for Shift); useful for shortcut (accelerator) key handling.
- // Otherwise, same as text().
- String unmodifiedText() const { return m_unmodifiedText; }
-
- // Most compatible Windows virtual key code associated with the event.
- // Zero for Char events.
- int windowsVirtualKeyCode() const { return m_windowsVirtualKeyCode; }
- void setWindowsVirtualKeyCode(int code) { m_windowsVirtualKeyCode = code; }
-
- int nativeVirtualKeyCode() const { return m_nativeVirtualKeyCode; }
- void setNativeVirtualKeyCode(int code) { m_nativeVirtualKeyCode = code; }
-
- String keyIdentifier() const { return m_keyIdentifier; }
- bool isAutoRepeat() const { return m_autoRepeat; }
- void setIsAutoRepeat(bool in) { m_autoRepeat = in; }
- bool isKeypad() const { return m_isKeypad; }
- bool shiftKey() const { return m_shiftKey; }
- bool ctrlKey() const { return m_ctrlKey; }
- bool altKey() const { return m_altKey; }
- bool metaKey() const { return m_metaKey; }
- unsigned modifiers() const {
- return (altKey() ? AltKey : 0)
- | (ctrlKey() ? CtrlKey : 0)
- | (metaKey() ? MetaKey : 0)
- | (shiftKey() ? ShiftKey : 0);
- }
-
- static bool currentCapsLockState();
-
-#if PLATFORM(MAC)
- PlatformKeyboardEvent(NSEvent*);
- NSEvent* macEvent() const { return m_macEvent.get(); }
-#endif
-
-#if PLATFORM(WIN)
- PlatformKeyboardEvent(HWND, WPARAM, LPARAM, Type, bool);
-#endif
-
-#if PLATFORM(GTK)
- PlatformKeyboardEvent(GdkEventKey*);
- GdkEventKey* gdkEventKey() const;
-#endif
-
-#if PLATFORM(ANDROID)
- PlatformKeyboardEvent(int keyCode, UChar32 unichar, Type,
- int repeatCount, ModifierKey);
- UChar32 unichar() const { return m_unichar; }
- int repeatCount() const { return m_repeatCount; }
-#endif
-
-#if PLATFORM(QT)
- PlatformKeyboardEvent(QKeyEvent*);
- QKeyEvent* qtEvent() const { return m_qtEvent; }
-#endif
-
-#if PLATFORM(WX)
- PlatformKeyboardEvent(wxKeyEvent&);
-#endif
-
-#if PLATFORM(WIN) || PLATFORM(CHROMIUM)
- bool isSystemKey() const { return m_isSystemKey; }
-#endif
-
- protected:
- Type m_type;
- String m_text;
- String m_unmodifiedText;
- String m_keyIdentifier;
- bool m_autoRepeat;
- int m_windowsVirtualKeyCode;
- int m_nativeVirtualKeyCode;
- bool m_isKeypad;
- bool m_shiftKey;
- bool m_ctrlKey;
- bool m_altKey;
- bool m_metaKey;
-
-#if PLATFORM(ANDROID)
- /* the actual repeatCount (as opposed to just a bool m_autoRepeat)
- 0 for initial down and up
- */
- int m_repeatCount;
- /* The originall unichar value. Sometimes the m_text/m_unmodifiedText
- fields are stripped (e.g. for RawKeyDown), so we record it also here
- in case someone (e.g. plugins) want to sniff it w/o waiting for a
- Char event type.
- */
- UChar32 m_unichar;
-#endif
-
-#if PLATFORM(MAC)
- RetainPtr<NSEvent> m_macEvent;
-#endif
-#if PLATFORM(WIN) || PLATFORM(CHROMIUM)
- bool m_isSystemKey;
-#endif
-#if PLATFORM(GTK)
- GdkEventKey* m_gdkEventKey;
-#endif
-#if PLATFORM(QT)
- QKeyEvent* m_qtEvent;
-#endif
- };
-
-} // namespace WebCore
-
-#endif // PlatformKeyboardEvent_h
diff --git a/WebCore/platform/PlatformMenuDescription.h b/WebCore/platform/PlatformMenuDescription.h
deleted file mode 100644
index ab71710..0000000
--- a/WebCore/platform/PlatformMenuDescription.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef PlatformMenuDescription_h
-#define PlatformMenuDescription_h
-
-#if PLATFORM(MAC)
-#ifdef __OBJC__
-@class NSMutableArray;
-#else
-class NSMutableArray;
-#endif
-#elif PLATFORM(WIN)
-typedef struct HMENU__* HMENU;
-#elif PLATFORM(QT)
-#include <qlist.h>
-#elif PLATFORM(GTK)
-typedef struct _GtkMenu GtkMenu;
-#elif PLATFORM(WX)
-class wxMenu;
-#endif
-
-namespace WebCore {
-
-#if PLATFORM(MAC)
- typedef NSMutableArray* PlatformMenuDescription;
-#elif PLATFORM(WIN)
- typedef HMENU PlatformMenuDescription;
-#elif PLATFORM(QT)
- class ContextMenuItem;
- typedef const QList<ContextMenuItem>* PlatformMenuDescription;
-#elif PLATFORM(GTK)
- typedef GtkMenu* PlatformMenuDescription;
-#elif defined ANDROID
-// Currently Android is not using this. Until its use is deemed necessary/desirable, typedef to void*.
- typedef void* PlatformMenuDescription;
-#elif PLATFORM(WX)
- typedef wxMenu* PlatformMenuDescription;
-#else
- typedef void* PlatformMenuDescription;
-#endif
-
-} // namespace
-
-#endif // PlatformMenuDescription_h
diff --git a/WebCore/platform/PlatformMouseEvent.h b/WebCore/platform/PlatformMouseEvent.h
deleted file mode 100644
index 9f6bea9..0000000
--- a/WebCore/platform/PlatformMouseEvent.h
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef PlatformMouseEvent_h
-#define PlatformMouseEvent_h
-
-#include "IntPoint.h"
-#include <wtf/Platform.h>
-
-#if PLATFORM(MAC)
-#ifdef __OBJC__
-@class NSEvent;
-@class NSScreen;
-@class NSWindow;
-#else
-class NSEvent;
-class NSScreen;
-class NSWindow;
-#endif
-#endif
-
-#if PLATFORM(WIN)
-typedef struct HWND__* HWND;
-typedef unsigned UINT;
-typedef unsigned WPARAM;
-typedef long LPARAM;
-#endif
-
-#if PLATFORM(GTK)
-typedef struct _GdkEventButton GdkEventButton;
-typedef struct _GdkEventMotion GdkEventMotion;
-#endif
-
-#if PLATFORM(QT)
-QT_BEGIN_NAMESPACE
-class QInputEvent;
-QT_END_NAMESPACE
-#endif
-
-#if PLATFORM(WX)
-class wxMouseEvent;
-#endif
-
-namespace WebCore {
-
- // These button numbers match the ones used in the DOM API, 0 through 2, except for NoButton which isn't specified.
- enum MouseButton { NoButton = -1, LeftButton, MiddleButton, RightButton };
- enum MouseEventType { MouseEventMoved, MouseEventPressed, MouseEventReleased, MouseEventScroll };
-
- class PlatformMouseEvent {
- public:
- PlatformMouseEvent()
- : m_button(NoButton)
- , m_eventType(MouseEventMoved)
- , m_clickCount(0)
- , m_shiftKey(false)
- , m_ctrlKey(false)
- , m_altKey(false)
- , m_metaKey(false)
- , m_timestamp(0)
- , m_modifierFlags(0)
- {
- }
-
- PlatformMouseEvent(const IntPoint& pos, const IntPoint& globalPos, MouseButton button, MouseEventType eventType,
- int clickCount, bool shift, bool ctrl, bool alt, bool meta, double timestamp)
- : m_position(pos), m_globalPosition(globalPos), m_button(button)
- , m_eventType(eventType)
- , m_clickCount(clickCount)
- , m_shiftKey(shift)
- , m_ctrlKey(ctrl)
- , m_altKey(alt)
- , m_metaKey(meta)
- , m_timestamp(timestamp)
- , m_modifierFlags(0)
- {
- }
-
- const IntPoint& pos() const { return m_position; }
- int x() const { return m_position.x(); }
- int y() const { return m_position.y(); }
- int globalX() const { return m_globalPosition.x(); }
- int globalY() const { return m_globalPosition.y(); }
- MouseButton button() const { return m_button; }
- MouseEventType eventType() const { return m_eventType; }
- int clickCount() const { return m_clickCount; }
- bool shiftKey() const { return m_shiftKey; }
- bool ctrlKey() const { return m_ctrlKey; }
- bool altKey() const { return m_altKey; }
- bool metaKey() const { return m_metaKey; }
- unsigned modifierFlags() const { return m_modifierFlags; }
-
- //time in seconds
- double timestamp() const { return m_timestamp; }
-
-#if PLATFORM(MAC)
- PlatformMouseEvent(NSEvent*);
- int eventNumber() const { return m_eventNumber; }
-#endif
-#if PLATFORM(WIN)
- PlatformMouseEvent(HWND, UINT, WPARAM, LPARAM, bool activatedWebView = false);
- void setClickCount(int count) { m_clickCount = count; }
- bool activatedWebView() const { return m_activatedWebView; }
-#endif
-#if PLATFORM(GTK)
- PlatformMouseEvent(GdkEventButton*);
- PlatformMouseEvent(GdkEventMotion*);
-#endif
-#if PLATFORM(QT)
- PlatformMouseEvent(QInputEvent*, int clickCount);
-#endif
-#if PLATFORM(WX)
- PlatformMouseEvent(const wxMouseEvent&, const wxPoint& globalPoint);
-#endif
-
-
- protected:
- IntPoint m_position;
- IntPoint m_globalPosition;
- MouseButton m_button;
- MouseEventType m_eventType;
- int m_clickCount;
- bool m_shiftKey;
- bool m_ctrlKey;
- bool m_altKey;
- bool m_metaKey;
- double m_timestamp; // unit: seconds
- unsigned m_modifierFlags;
-#if PLATFORM(MAC)
- int m_eventNumber;
-#endif
-#if PLATFORM(WIN)
- bool m_activatedWebView;
-#endif
- };
-
-#if PLATFORM(MAC)
- IntPoint globalPoint(const NSPoint& windowPoint, NSWindow *window);
- IntPoint pointForEvent(NSEvent *event);
- IntPoint globalPointForEvent(NSEvent *event);
-#endif
-
-} // namespace WebCore
-
-#endif // PlatformMouseEvent_h
diff --git a/WebCore/platform/PlatformScreen.h b/WebCore/platform/PlatformScreen.h
deleted file mode 100644
index 764fe02..0000000
--- a/WebCore/platform/PlatformScreen.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef PlatformScreen_h
-#define PlatformScreen_h
-
-#include "FloatRect.h"
-#include <wtf/Forward.h>
-#include <wtf/RefPtr.h>
-
-#if PLATFORM(MAC)
-#ifdef __OBJC__
- @class NSScreen;
- @class NSWindow;
-#else
- class NSScreen;
- class NSWindow;
-#endif
-#endif
-
-namespace WebCore {
-
- class FloatRect;
- class Widget;
-
- int screenDepth(Widget*);
- int screenDepthPerComponent(Widget*);
- bool screenIsMonochrome(Widget*);
-
- FloatRect screenRect(Widget*);
- FloatRect screenAvailableRect(Widget*);
-
-#if PLATFORM(MAC)
- NSScreen *screenForWindow(NSWindow *);
-
- FloatRect toUserSpace(const NSRect&, NSWindow *destination);
- NSRect toDeviceSpace(const FloatRect&, NSWindow *source);
-
- NSPoint flipScreenPoint(const NSPoint&, NSScreen *);
-#endif
-
-} // namespace WebCore
-
-#endif // PlatformScreen_h
diff --git a/WebCore/platform/PlatformTouchEvent.h b/WebCore/platform/PlatformTouchEvent.h
deleted file mode 100644
index 4f547b2..0000000
--- a/WebCore/platform/PlatformTouchEvent.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2008, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef PlatformTouchEvent_h
-#define PlatformTouchEvent_h
-
-#if ENABLE(TOUCH_EVENTS) // Android
-
-#include "IntPoint.h"
-
-namespace WebCore {
-
- enum TouchEventType {TouchEventStart, TouchEventMove, TouchEventEnd, TouchEventCancel};
-
- class PlatformTouchEvent {
- public:
- PlatformTouchEvent()
- : m_eventType(TouchEventCancel)
- {
- }
-
- PlatformTouchEvent(const IntPoint& pos, const IntPoint& globalPos, TouchEventType eventType)
- : m_position(pos)
- , m_globalPosition(globalPos)
- , m_eventType(eventType)
- {
- }
-
- const IntPoint& pos() const { return m_position; }
- int x() const { return m_position.x(); }
- int y() const { return m_position.y(); }
- int globalX() const { return m_globalPosition.x(); }
- int globalY() const { return m_globalPosition.y(); }
- TouchEventType eventType() const { return m_eventType; }
-
- private:
- IntPoint m_position;
- IntPoint m_globalPosition;
- TouchEventType m_eventType;
- };
-
-} // namespace WebCore
-
-#endif // ENABLE(TOUCH_EVENTS)
-
-#endif // PlatformTouchEvent_h
diff --git a/WebCore/platform/PlatformWheelEvent.h b/WebCore/platform/PlatformWheelEvent.h
deleted file mode 100644
index fc954ed..0000000
--- a/WebCore/platform/PlatformWheelEvent.h
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef PlatformWheelEvent_h
-#define PlatformWheelEvent_h
-
-#include "IntPoint.h"
-
-#if PLATFORM(MAC)
-#ifdef __OBJC__
-@class NSEvent;
-#else
-class NSEvent;
-#endif
-#endif
-
-#if PLATFORM(WIN)
-typedef struct HWND__* HWND;
-typedef unsigned WPARAM;
-typedef long LPARAM;
-#endif
-
-#if PLATFORM(GTK)
-typedef struct _GdkEventScroll GdkEventScroll;
-#endif
-
-#if PLATFORM(QT)
-QT_BEGIN_NAMESPACE
-class QWheelEvent;
-QT_END_NAMESPACE
-#endif
-
-#if PLATFORM(WX)
-class wxMouseEvent;
-class wxPoint;
-#endif
-
-namespace WebCore {
-
- // Wheel events come in three flavors:
- // The ScrollByPixelWheelEvent is a fine-grained event that specifies the precise number of pixels to scroll. It is sent by MacBook touchpads on OS X.
- // For ScrollByPixelWheelEvents, the delta values contain the precise number of pixels to scroll.
- // The ScrollByLineWheelEvent (the normal wheel event) sends a delta that can be corrected by a line multiplier to determine how many lines to scroll.
- // If the platform has configurable line sensitivity (Windows), then the number of lines to scroll is used in order to behave like the platform.
- // If the platform does not have configurable line sensitivity, then WebCore's default behavior is used (which scrolls 3 * the wheel line delta).
- // For ScrollByLineWheelEvents, the delta values represent the number of lines to scroll.
- // The ScrollByPageWheelEvent indicates that the wheel event should scroll an entire page instead. In this case WebCore's built in paging behavior is used to page
- // up and down (you get the same behavior as if the user was clicking in a scrollbar track to page up or page down). Page scrolling only works in the vertical direction.
- enum PlatformWheelEventGranularity { ScrollByLineWheelEvent, ScrollByPageWheelEvent, ScrollByPixelWheelEvent };
-
- // WebCore uses a line multiple of ~3 (40px per line step) when doing arrowing with a scrollbar or line stepping via the arrow keys. The delta for wheeling is expressed
- // as a # of actual lines (40 / 3 = 1 wheel line). We use the horizontalLineMultiplier and verticalLineMultiplier methods to incorporate the line multiplier into the deltas. On
- // platforms that do not support wheel sensitivity, we use this hardcoded constant value of 3 to ensure that wheeling by default matches the WebCore multiplier you
- // get when doing other kinds of line stepping.
- const int cLineMultiplier = 3;
-
- class PlatformWheelEvent {
- public:
- const IntPoint& pos() const { return m_position; } // PlatformWindow coordinates.
- const IntPoint& globalPos() const { return m_globalPosition; } // Screen coordinates.
-
- float deltaX() const { return m_deltaX; }
- float deltaY() const { return m_deltaY; }
-
- PlatformWheelEventGranularity granularity() const { return m_granularity; }
-
- bool isAccepted() const { return m_isAccepted; }
- bool shiftKey() const { return m_shiftKey; }
- bool ctrlKey() const { return m_ctrlKey; }
- bool altKey() const { return m_altKey; }
- bool metaKey() const { return m_metaKey; }
-
- int x() const { return m_position.x(); } // PlatformWindow coordinates.
- int y() const { return m_position.y(); }
- int globalX() const { return m_globalPosition.x(); } // Screen coordinates.
- int globalY() const { return m_globalPosition.y(); }
-
- void accept() { m_isAccepted = true; }
- void ignore() { m_isAccepted = false; }
-
-#if PLATFORM(MAC)
- PlatformWheelEvent(NSEvent*);
-#endif
-#if PLATFORM(WIN)
- PlatformWheelEvent(HWND, WPARAM, LPARAM, bool isHorizontal);
-#endif
-#if PLATFORM(GTK)
- PlatformWheelEvent(GdkEventScroll*);
-#endif
-#if PLATFORM(QT)
- PlatformWheelEvent(QWheelEvent*);
-#endif
-#if PLATFORM(WX)
- PlatformWheelEvent(const wxMouseEvent&, const wxPoint&);
-#endif
-
- protected:
-#if !PLATFORM(WIN)
- int horizontalLineMultiplier() const { return cLineMultiplier; }
- int verticalLineMultiplier() const { return cLineMultiplier; }
-#else
- int horizontalLineMultiplier() const;
- int verticalLineMultiplier() const;
-#endif
-
- IntPoint m_position;
- IntPoint m_globalPosition;
- float m_deltaX;
- float m_deltaY;
- PlatformWheelEventGranularity m_granularity;
- bool m_isAccepted;
- bool m_shiftKey;
- bool m_ctrlKey;
- bool m_altKey;
- bool m_metaKey;
- };
-
-} // namespace WebCore
-
-#endif // PlatformWheelEvent_h
diff --git a/WebCore/platform/PopupMenu.h b/WebCore/platform/PopupMenu.h
deleted file mode 100644
index fc85d60..0000000
--- a/WebCore/platform/PopupMenu.h
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef PopupMenu_h
-#define PopupMenu_h
-
-#include "IntRect.h"
-#include "PopupMenuClient.h"
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-
-#if PLATFORM(MAC)
-#include <wtf/RetainPtr.h>
-#ifdef __OBJC__
-@class NSPopUpButtonCell;
-#else
-class NSPopUpButtonCell;
-#endif
-#elif PLATFORM(WIN)
-#include "Scrollbar.h"
-#include "ScrollbarClient.h"
-#include <wtf/RefPtr.h>
-typedef struct HWND__* HWND;
-typedef struct HDC__* HDC;
-typedef struct HBITMAP__* HBITMAP;
-#elif PLATFORM(QT)
-namespace WebCore {
- class QWebPopup;
-}
-#elif PLATFORM(GTK)
-typedef struct _GtkMenu GtkMenu;
-typedef struct _GtkMenuItem GtkMenuItem;
-typedef struct _GtkWidget GtkWidget;
-#include <wtf/HashMap.h>
-#include <glib.h>
-#elif PLATFORM(WX)
-#ifdef __WXMSW__
-#include <wx/msw/winundef.h>
-#endif
-class wxMenu;
-#include <wx/defs.h>
-#include <wx/event.h>
-#elif PLATFORM(CHROMIUM)
-#include "PopupMenuPrivate.h"
-#endif
-
-namespace WebCore {
-
-class FrameView;
-class Scrollbar;
-
-class PopupMenu : public RefCounted<PopupMenu>
-#if PLATFORM(WIN)
- , private ScrollbarClient
-#endif
-#if PLATFORM(WX)
- , public wxEvtHandler
-#endif
-{
-public:
- static PassRefPtr<PopupMenu> create(PopupMenuClient* client) { return adoptRef(new PopupMenu(client)); }
- ~PopupMenu();
-
- void disconnectClient() { m_popupClient = 0; }
-
- void show(const IntRect&, FrameView*, int index);
- void hide();
-
- void updateFromElement();
-
- PopupMenuClient* client() const { return m_popupClient; }
-
- static bool itemWritingDirectionIsNatural();
-
-#if PLATFORM(WIN)
- Scrollbar* scrollbar() const { return m_scrollbar.get(); }
-
- bool up(unsigned lines = 1);
- bool down(unsigned lines = 1);
-
- int itemHeight() const { return m_itemHeight; }
- const IntRect& windowRect() const { return m_windowRect; }
- IntRect clientRect() const;
-
- int visibleItems() const;
-
- int listIndexAtPoint(const IntPoint&) const;
-
- bool setFocusedIndex(int index, bool hotTracking = false);
- int focusedIndex() const;
- void focusFirst();
- void focusLast();
-
- void paint(const IntRect& damageRect, HDC = 0);
-
- HWND popupHandle() const { return m_popup; }
-
- void setWasClicked(bool b = true) { m_wasClicked = b; }
- bool wasClicked() const { return m_wasClicked; }
-
- void setScrollOffset(int offset) { m_scrollOffset = offset; }
- int scrollOffset() const { return m_scrollOffset; }
-
- bool scrollToRevealSelection();
-
- void incrementWheelDelta(int delta);
- void reduceWheelDelta(int delta);
- int wheelDelta() const { return m_wheelDelta; }
-
- bool scrollbarCapturingMouse() const { return m_scrollbarCapturingMouse; }
- void setScrollbarCapturingMouse(bool b) { m_scrollbarCapturingMouse = b; }
-#endif
-
-protected:
- PopupMenu(PopupMenuClient*);
-
-private:
- PopupMenuClient* m_popupClient;
-
-#if PLATFORM(MAC)
- void clear();
- void populate();
-
- RetainPtr<NSPopUpButtonCell> m_popup;
-#elif PLATFORM(QT)
- void clear();
- void populate(const IntRect&);
- QWebPopup* m_popup;
-#elif PLATFORM(WIN)
- // ScrollBarClient
- virtual void valueChanged(Scrollbar*);
- virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&);
- virtual bool isActive() const { return true; }
- virtual bool scrollbarCornerPresent() const { return false; }
-
- void calculatePositionAndSize(const IntRect&, FrameView*);
- void invalidateItem(int index);
-
- RefPtr<Scrollbar> m_scrollbar;
- HWND m_popup;
- HDC m_DC;
- HBITMAP m_bmp;
- bool m_wasClicked;
- IntRect m_windowRect;
- int m_itemHeight;
- int m_scrollOffset;
- int m_wheelDelta;
- int m_focusedIndex;
- bool m_scrollbarCapturingMouse;
-#elif PLATFORM(GTK)
- IntPoint m_menuPosition;
- GtkMenu* m_popup;
- HashMap<GtkWidget*, int> m_indexMap;
- static void menuItemActivated(GtkMenuItem* item, PopupMenu*);
- static void menuUnmapped(GtkWidget*, PopupMenu*);
- static void menuPositionFunction(GtkMenu*, gint*, gint*, gboolean*, PopupMenu*);
- static void menuRemoveItem(GtkWidget*, PopupMenu*);
-#elif PLATFORM(WX)
- wxMenu* m_menu;
- void OnMenuItemSelected(wxCommandEvent&);
-#elif PLATFORM(CHROMIUM)
- PopupMenuPrivate p;
-#endif
-
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/PopupMenuClient.h b/WebCore/platform/PopupMenuClient.h
deleted file mode 100644
index 0718b8c..0000000
--- a/WebCore/platform/PopupMenuClient.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef PopupMenuClient_h
-#define PopupMenuClient_h
-
-#include "PopupMenuStyle.h"
-#include "ScrollTypes.h"
-
-namespace WebCore {
-
-class Color;
-class FontSelector;
-class HostWindow;
-class Scrollbar;
-class ScrollbarClient;
-class String;
-
-class PopupMenuClient {
-public:
- virtual ~PopupMenuClient() {}
- virtual void valueChanged(unsigned listIndex, bool fireEvents = true) = 0;
-
- virtual String itemText(unsigned listIndex) const = 0;
- virtual bool itemIsEnabled(unsigned listIndex) const = 0;
- virtual PopupMenuStyle itemStyle(unsigned listIndex) const = 0;
- virtual PopupMenuStyle menuStyle() const = 0;
- virtual int clientInsetLeft() const = 0;
- virtual int clientInsetRight() const = 0;
- virtual int clientPaddingLeft() const = 0;
- virtual int clientPaddingRight() const = 0;
- virtual int listSize() const = 0;
- virtual int selectedIndex() const = 0;
- virtual void hidePopup() = 0;
- virtual bool itemIsSeparator(unsigned listIndex) const = 0;
- virtual bool itemIsLabel(unsigned listIndex) const = 0;
- virtual bool itemIsSelected(unsigned listIndex) const = 0;
- virtual bool shouldPopOver() const = 0;
- virtual bool valueShouldChangeOnHotTrack() const = 0;
- virtual void setTextFromItem(unsigned listIndex) = 0;
-
- virtual FontSelector* fontSelector() const = 0;
- virtual HostWindow* hostWindow() const = 0;
-
- virtual PassRefPtr<Scrollbar> createScrollbar(ScrollbarClient*, ScrollbarOrientation, ScrollbarControlSize) = 0;
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/PopupMenuStyle.h b/WebCore/platform/PopupMenuStyle.h
deleted file mode 100644
index 89a7a74..0000000
--- a/WebCore/platform/PopupMenuStyle.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef PopupMenuStyle_h
-#define PopupMenuStyle_h
-
-#include "Color.h"
-#include "Font.h"
-
-namespace WebCore {
-
-class PopupMenuStyle {
-public:
- PopupMenuStyle(const Color& foreground, const Color& background, const Font& font, bool visible)
- : m_foregroundColor(foreground)
- , m_backgroundColor(background)
- , m_font(font)
- , m_visible(visible)
- {
- }
-
- const Color& foregroundColor() const { return m_foregroundColor; }
- const Color& backgroundColor() const { return m_backgroundColor; }
- const Font& font() const { return m_font; }
- bool isVisible() const { return m_visible; }
-
-private:
- Color m_foregroundColor;
- Color m_backgroundColor;
- Font m_font;
- bool m_visible;
-};
-
-} // namespace WebCore
-
-#endif // PopupMenuStyle_h
diff --git a/WebCore/platform/SSLKeyGenerator.h b/WebCore/platform/SSLKeyGenerator.h
deleted file mode 100644
index 398a009..0000000
--- a/WebCore/platform/SSLKeyGenerator.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef SSLKeyGenerator_h
-#define SSLKeyGenerator_h
-
-#include <wtf/Vector.h>
-#include "PlatformString.h"
-
-namespace WebCore {
-
- class KURL;
-
- void getSupportedKeySizes(Vector<String>&);
- String signedPublicKeyAndChallengeString(unsigned keySizeIndex, const String& challengeString, const KURL&);
-
-} // namespace WebCore
-
-#endif // SSLKeyGenerator_h
diff --git a/WebCore/platform/ScrollTypes.h b/WebCore/platform/ScrollTypes.h
deleted file mode 100644
index eba9055..0000000
--- a/WebCore/platform/ScrollTypes.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ScrollTypes_h
-#define ScrollTypes_h
-
-namespace WebCore {
-
- enum ScrollDirection {
- ScrollUp,
- ScrollDown,
- ScrollLeft,
- ScrollRight
- };
-
- enum ScrollGranularity {
- ScrollByLine,
- ScrollByPage,
- ScrollByDocument,
- ScrollByPixel
- };
-
- enum ScrollbarOrientation { HorizontalScrollbar, VerticalScrollbar };
-
- enum ScrollbarMode { ScrollbarAuto, ScrollbarAlwaysOff, ScrollbarAlwaysOn };
-
- enum ScrollbarControlSize { RegularScrollbar, SmallScrollbar };
-
- typedef unsigned ScrollbarControlState;
-
- enum ScrollbarControlStateMask {
- ActiveScrollbarState = 1,
- EnabledScrollbarState = 1 << 1,
- PressedScrollbarState = 1 << 2,
- };
-
- enum ScrollbarPart {
- NoPart = 0,
- BackButtonStartPart = 1,
- ForwardButtonStartPart = 1 << 1,
- BackTrackPart = 1 << 2,
- ThumbPart = 1 << 3,
- ForwardTrackPart = 1 << 4,
- BackButtonEndPart = 1 << 5,
- ForwardButtonEndPart = 1 << 6,
- ScrollbarBGPart = 1 << 7,
- TrackBGPart = 1 << 8,
- AllParts = 0xffffffff,
- };
-
- enum ScrollbarButtonsPlacement {
- ScrollbarButtonsNone,
- ScrollbarButtonsSingle,
- ScrollbarButtonsDoubleStart,
- ScrollbarButtonsDoubleEnd,
- ScrollbarButtonsDoubleBoth
- };
-
- typedef unsigned ScrollbarControlPartMask;
-
-}
-
-#endif
diff --git a/WebCore/platform/ScrollView.cpp b/WebCore/platform/ScrollView.cpp
deleted file mode 100644
index 9eb6ce7..0000000
--- a/WebCore/platform/ScrollView.cpp
+++ /dev/null
@@ -1,878 +0,0 @@
-
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ScrollView.h"
-
-#include "GraphicsContext.h"
-#include "HostWindow.h"
-#include "PlatformMouseEvent.h"
-#include "PlatformWheelEvent.h"
-#include "Scrollbar.h"
-#include "ScrollbarTheme.h"
-
-using std::max;
-
-namespace WebCore {
-
-ScrollView::ScrollView()
- : m_horizontalScrollbarMode(ScrollbarAuto)
- , m_verticalScrollbarMode(ScrollbarAuto)
- , m_prohibitsScrolling(false)
- , m_canBlitOnScroll(true)
- , m_scrollbarsAvoidingResizer(0)
- , m_scrollbarsSuppressed(false)
- , m_inUpdateScrollbars(false)
- , m_drawPanScrollIcon(false)
-{
- platformInit();
- if (platformWidget())
- platformSetCanBlitOnScroll();
-}
-
-ScrollView::~ScrollView()
-{
- platformDestroy();
-}
-
-void ScrollView::addChild(Widget* child)
-{
- ASSERT(child != this && !child->parent());
- child->setParent(this);
- m_children.add(child);
- if (child->platformWidget())
- platformAddChild(child);
-}
-
-void ScrollView::removeChild(Widget* child)
-{
- ASSERT(child->parent() == this);
- child->setParent(0);
- m_children.remove(child);
- if (child->platformWidget())
- platformRemoveChild(child);
-}
-
-void ScrollView::setHasHorizontalScrollbar(bool hasBar)
-{
- if (hasBar && !m_horizontalScrollbar && !platformHasHorizontalAdjustment()) {
- m_horizontalScrollbar = Scrollbar::createNativeScrollbar(this, HorizontalScrollbar, RegularScrollbar);
- addChild(m_horizontalScrollbar.get());
- } else if (!hasBar && m_horizontalScrollbar) {
- removeChild(m_horizontalScrollbar.get());
- m_horizontalScrollbar = 0;
- }
-}
-
-void ScrollView::setHasVerticalScrollbar(bool hasBar)
-{
- if (hasBar && !m_verticalScrollbar && !platformHasVerticalAdjustment()) {
- m_verticalScrollbar = Scrollbar::createNativeScrollbar(this, VerticalScrollbar, RegularScrollbar);
- addChild(m_verticalScrollbar.get());
- } else if (!hasBar && m_verticalScrollbar) {
- removeChild(m_verticalScrollbar.get());
- m_verticalScrollbar = 0;
- }
-}
-
-void ScrollView::setScrollbarModes(ScrollbarMode horizontalMode, ScrollbarMode verticalMode)
-{
- if (horizontalMode == horizontalScrollbarMode() && verticalMode == verticalScrollbarMode())
- return;
- m_horizontalScrollbarMode = horizontalMode;
- m_verticalScrollbarMode = verticalMode;
- if (platformWidget())
- platformSetScrollbarModes();
- else
- updateScrollbars(scrollOffset());
-}
-
-void ScrollView::scrollbarModes(ScrollbarMode& horizontalMode, ScrollbarMode& verticalMode) const
-{
- if (platformWidget()) {
- platformScrollbarModes(horizontalMode, verticalMode);
- return;
- }
- horizontalMode = m_horizontalScrollbarMode;
- verticalMode = m_verticalScrollbarMode;
-}
-
-void ScrollView::setCanHaveScrollbars(bool canScroll)
-{
- ScrollbarMode newHorizontalMode;
- ScrollbarMode newVerticalMode;
-
- scrollbarModes(newHorizontalMode, newVerticalMode);
-
- if (canScroll && newVerticalMode == ScrollbarAlwaysOff)
- newVerticalMode = ScrollbarAuto;
- else if (!canScroll)
- newVerticalMode = ScrollbarAlwaysOff;
-
- if (canScroll && newHorizontalMode == ScrollbarAlwaysOff)
- newHorizontalMode = ScrollbarAuto;
- else if (!canScroll)
- newHorizontalMode = ScrollbarAlwaysOff;
-
- setScrollbarModes(newHorizontalMode, newVerticalMode);
-}
-
-void ScrollView::setCanBlitOnScroll(bool b)
-{
- if (m_canBlitOnScroll == b)
- return;
- m_canBlitOnScroll = b;
- if (platformWidget())
- platformSetCanBlitOnScroll();
-}
-
-IntRect ScrollView::visibleContentRect(bool includeScrollbars) const
-{
- if (platformWidget())
- return platformVisibleContentRect(includeScrollbars);
- return IntRect(IntPoint(m_scrollOffset.width(), m_scrollOffset.height()),
- IntSize(max(0, width() - (verticalScrollbar() && !includeScrollbars ? verticalScrollbar()->width() : 0)),
- max(0, height() - (horizontalScrollbar() && !includeScrollbars ? horizontalScrollbar()->height() : 0))));
-}
-
-IntSize ScrollView::contentsSize() const
-{
- if (platformWidget())
- return platformContentsSize();
- return m_contentsSize;
-}
-
-void ScrollView::setContentsSize(const IntSize& newSize)
-{
- if (contentsSize() == newSize)
- return;
- m_contentsSize = newSize;
- if (platformWidget())
- platformSetContentsSize();
- else
- updateScrollbars(scrollOffset());
-}
-
-IntPoint ScrollView::maximumScrollPosition() const
-{
- IntSize maximumOffset = contentsSize() - visibleContentRect().size();
- maximumOffset.clampNegativeToZero();
- return IntPoint(maximumOffset.width(), maximumOffset.height());
-}
-
-void ScrollView::valueChanged(Scrollbar* scrollbar)
-{
- // Figure out if we really moved.
- IntSize newOffset = m_scrollOffset;
- if (scrollbar) {
- if (scrollbar == m_horizontalScrollbar)
- newOffset.setWidth(scrollbar->value());
- else if (scrollbar == m_verticalScrollbar)
- newOffset.setHeight(scrollbar->value());
- }
-
- IntSize scrollDelta = newOffset - m_scrollOffset;
- if (scrollDelta == IntSize())
- return;
- m_scrollOffset = newOffset;
-
- if (scrollbarsSuppressed())
- return;
-
- scrollContents(scrollDelta);
-}
-
-void ScrollView::scrollRectIntoViewRecursively(const IntRect& r)
-{
-#if PLATFORM(ANDROID)
- if (platformProhibitsScrolling())
- return;
-#endif
- if (prohibitsScrolling())
- return;
-
- IntPoint p(max(0, r.x()), max(0, r.y()));
- ScrollView* view = this;
- while (view) {
- view->setScrollPosition(p);
- p.move(view->x() - view->scrollOffset().width(), view->y() - view->scrollOffset().height());
- view = view->parent();
- }
-}
-
-void ScrollView::setScrollPosition(const IntPoint& scrollPoint)
-{
- if (prohibitsScrolling())
- return;
-
- if (platformWidget()) {
- platformSetScrollPosition(scrollPoint);
- return;
- }
-
- IntPoint newScrollPosition = scrollPoint.shrunkTo(maximumScrollPosition());
- newScrollPosition.clampNegativeToZero();
-
- if (newScrollPosition == scrollPosition())
- return;
-
- updateScrollbars(IntSize(newScrollPosition.x(), newScrollPosition.y()));
-}
-
-bool ScrollView::scroll(ScrollDirection direction, ScrollGranularity granularity)
-{
- if (platformWidget())
- return platformScroll(direction, granularity);
-
- if (direction == ScrollUp || direction == ScrollDown) {
- if (m_verticalScrollbar)
- return m_verticalScrollbar->scroll(direction, granularity);
- } else {
- if (m_horizontalScrollbar)
- return m_horizontalScrollbar->scroll(direction, granularity);
- }
- return false;
-}
-
-void ScrollView::updateScrollbars(const IntSize& desiredOffset)
-{
- // Don't allow re-entrancy into this function.
- if (m_inUpdateScrollbars || prohibitsScrolling() || platformWidget())
- return;
-
- m_inUpdateScrollbars = true;
-
- bool hasVerticalScrollbar = m_verticalScrollbar;
- bool hasHorizontalScrollbar = m_horizontalScrollbar;
- bool oldHasVertical = hasVerticalScrollbar;
- bool oldHasHorizontal = hasHorizontalScrollbar;
- ScrollbarMode hScroll = m_horizontalScrollbarMode;
- ScrollbarMode vScroll = m_verticalScrollbarMode;
-
- const int scrollbarThickness = ScrollbarTheme::nativeTheme()->scrollbarThickness();
-
- for (int pass = 0; pass < 2; pass++) {
- bool scrollsVertically;
- bool scrollsHorizontally;
-
- if (!m_scrollbarsSuppressed && (hScroll == ScrollbarAuto || vScroll == ScrollbarAuto)) {
- // Do a layout if pending before checking if scrollbars are needed.
- if (hasVerticalScrollbar != oldHasVertical || hasHorizontalScrollbar != oldHasHorizontal)
- visibleContentsResized();
-
- scrollsVertically = (vScroll == ScrollbarAlwaysOn) || (vScroll == ScrollbarAuto && contentsHeight() > height());
- if (scrollsVertically)
- scrollsHorizontally = (hScroll == ScrollbarAlwaysOn) || (hScroll == ScrollbarAuto && contentsWidth() + scrollbarThickness > width());
- else {
- scrollsHorizontally = (hScroll == ScrollbarAlwaysOn) || (hScroll == ScrollbarAuto && contentsWidth() > width());
- if (scrollsHorizontally)
- scrollsVertically = (vScroll == ScrollbarAlwaysOn) || (vScroll == ScrollbarAuto && contentsHeight() + scrollbarThickness > height());
- }
- } else {
- scrollsHorizontally = (hScroll == ScrollbarAuto) ? hasHorizontalScrollbar : (hScroll == ScrollbarAlwaysOn);
- scrollsVertically = (vScroll == ScrollbarAuto) ? hasVerticalScrollbar : (vScroll == ScrollbarAlwaysOn);
- }
-
- if (hasVerticalScrollbar != scrollsVertically) {
- setHasVerticalScrollbar(scrollsVertically);
- hasVerticalScrollbar = scrollsVertically;
- }
-
- if (hasHorizontalScrollbar != scrollsHorizontally) {
- setHasHorizontalScrollbar(scrollsHorizontally);
- hasHorizontalScrollbar = scrollsHorizontally;
- }
- }
-
- // Set up the range (and page step/line step).
- IntSize maxScrollPosition(contentsWidth() - visibleWidth(), contentsHeight() - visibleHeight());
- IntSize scroll = desiredOffset.shrunkTo(maxScrollPosition);
- scroll.clampNegativeToZero();
-
- if (!platformHandleHorizontalAdjustment(scroll) && m_horizontalScrollbar) {
- int clientWidth = visibleWidth();
- m_horizontalScrollbar->setEnabled(contentsWidth() > clientWidth);
- int pageStep = (clientWidth - cAmountToKeepWhenPaging);
- if (pageStep < 0)
- pageStep = clientWidth;
- IntRect oldRect(m_horizontalScrollbar->frameRect());
- IntRect hBarRect = IntRect(0,
- height() - m_horizontalScrollbar->height(),
- width() - (m_verticalScrollbar ? m_verticalScrollbar->width() : 0),
- m_horizontalScrollbar->height());
- m_horizontalScrollbar->setFrameRect(hBarRect);
- if (!m_scrollbarsSuppressed && oldRect != m_horizontalScrollbar->frameRect())
- m_horizontalScrollbar->invalidate();
-
- if (m_scrollbarsSuppressed)
- m_horizontalScrollbar->setSuppressInvalidation(true);
- m_horizontalScrollbar->setSteps(cScrollbarPixelsPerLineStep, pageStep);
- m_horizontalScrollbar->setProportion(clientWidth, contentsWidth());
- m_horizontalScrollbar->setValue(scroll.width());
- if (m_scrollbarsSuppressed)
- m_horizontalScrollbar->setSuppressInvalidation(false);
- }
-
- if (!platformHandleVerticalAdjustment(scroll) && m_verticalScrollbar) {
- int clientHeight = visibleHeight();
- m_verticalScrollbar->setEnabled(contentsHeight() > clientHeight);
- int pageStep = (clientHeight - cAmountToKeepWhenPaging);
- if (pageStep < 0)
- pageStep = clientHeight;
- IntRect oldRect(m_verticalScrollbar->frameRect());
- IntRect vBarRect = IntRect(width() - m_verticalScrollbar->width(),
- 0,
- m_verticalScrollbar->width(),
- height() - (m_horizontalScrollbar ? m_horizontalScrollbar->height() : 0));
- m_verticalScrollbar->setFrameRect(vBarRect);
- if (!m_scrollbarsSuppressed && oldRect != m_verticalScrollbar->frameRect())
- m_verticalScrollbar->invalidate();
-
- if (m_scrollbarsSuppressed)
- m_verticalScrollbar->setSuppressInvalidation(true);
- m_verticalScrollbar->setSteps(cScrollbarPixelsPerLineStep, pageStep);
- m_verticalScrollbar->setProportion(clientHeight, contentsHeight());
- m_verticalScrollbar->setValue(scroll.height());
- if (m_scrollbarsSuppressed)
- m_verticalScrollbar->setSuppressInvalidation(false);
- }
-
- if (oldHasVertical != (m_verticalScrollbar != 0) || oldHasHorizontal != (m_horizontalScrollbar != 0))
- frameRectsChanged();
-
- // See if our offset has changed in a situation where we might not have scrollbars.
- // This can happen when editing a body with overflow:hidden and scrolling to reveal selection.
- // It can also happen when maximizing a window that has scrollbars (but the new maximized result
- // does not).
- IntSize scrollDelta = scroll - m_scrollOffset;
- if (scrollDelta != IntSize()) {
- m_scrollOffset = scroll;
- scrollContents(scrollDelta);
- }
-
- m_inUpdateScrollbars = false;
-}
-
-const int panIconSizeLength = 20;
-
-void ScrollView::scrollContents(const IntSize& scrollDelta)
-{
- // Since scrolling is double buffered, we will be blitting the scroll view's intersection
- // with the clip rect every time to keep it smooth.
- IntRect clipRect = windowClipRect();
- IntRect scrollViewRect = convertToContainingWindow(IntRect(0, 0, visibleWidth(), visibleHeight()));
- IntRect updateRect = clipRect;
- updateRect.intersect(scrollViewRect);
-
- // Invalidate the window (not the backing store).
- hostWindow()->repaint(updateRect, false);
-
- if (m_drawPanScrollIcon) {
- int panIconDirtySquareSizeLength = 2 * (panIconSizeLength + max(abs(scrollDelta.width()), abs(scrollDelta.height()))); // We only want to repaint what's necessary
- IntPoint panIconDirtySquareLocation = IntPoint(m_panScrollIconPoint.x() - (panIconDirtySquareSizeLength / 2), m_panScrollIconPoint.y() - (panIconDirtySquareSizeLength / 2));
- IntRect panScrollIconDirtyRect = IntRect(panIconDirtySquareLocation , IntSize(panIconDirtySquareSizeLength, panIconDirtySquareSizeLength));
- panScrollIconDirtyRect.intersect(clipRect);
- hostWindow()->repaint(panScrollIconDirtyRect, true, true);
- }
-
- if (canBlitOnScroll() && !rootPreventsBlitting()) { // The main frame can just blit the WebView window
- // FIXME: Find a way to blit subframes without blitting overlapping content
- hostWindow()->scroll(-scrollDelta, scrollViewRect, clipRect);
- } else {
- // We need to go ahead and repaint the entire backing store. Do it now before moving the
- // plugins.
- hostWindow()->repaint(updateRect, true, false, true); // Invalidate the backing store and repaint it synchronously
- }
-
- // This call will move children with native widgets (plugins) and invalidate them as well.
- frameRectsChanged();
-
- // Now update the window (which should do nothing but a blit of the backing store's updateRect and so should
- // be very fast).
- hostWindow()->paint();
-}
-
-IntPoint ScrollView::windowToContents(const IntPoint& windowPoint) const
-{
- IntPoint viewPoint = convertFromContainingWindow(windowPoint);
- return viewPoint + scrollOffset();
-}
-
-IntPoint ScrollView::contentsToWindow(const IntPoint& contentsPoint) const
-{
- IntPoint viewPoint = contentsPoint - scrollOffset();
- return convertToContainingWindow(viewPoint);
-}
-
-IntRect ScrollView::windowToContents(const IntRect& windowRect) const
-{
- IntRect viewRect = convertFromContainingWindow(windowRect);
- viewRect.move(scrollOffset());
- return viewRect;
-}
-
-IntRect ScrollView::contentsToWindow(const IntRect& contentsRect) const
-{
- IntRect viewRect = contentsRect;
- viewRect.move(-scrollOffset());
- return convertToContainingWindow(viewRect);
-}
-
-IntRect ScrollView::contentsToScreen(const IntRect& rect) const
-{
- if (platformWidget())
- return platformContentsToScreen(rect);
- return hostWindow()->windowToScreen(contentsToWindow(rect));
-}
-
-IntPoint ScrollView::screenToContents(const IntPoint& point) const
-{
- if (platformWidget())
- return platformScreenToContents(point);
- return windowToContents(hostWindow()->screenToWindow(point));
-}
-
-bool ScrollView::containsScrollbarsAvoidingResizer() const
-{
- return !m_scrollbarsAvoidingResizer;
-}
-
-void ScrollView::adjustScrollbarsAvoidingResizerCount(int overlapDelta)
-{
- int oldCount = m_scrollbarsAvoidingResizer;
- m_scrollbarsAvoidingResizer += overlapDelta;
- if (parent())
- parent()->adjustScrollbarsAvoidingResizerCount(overlapDelta);
- else if (!scrollbarsSuppressed()) {
- // If we went from n to 0 or from 0 to n and we're the outermost view,
- // we need to invalidate the windowResizerRect(), since it will now need to paint
- // differently.
- if (oldCount > 0 && m_scrollbarsAvoidingResizer == 0 ||
- oldCount == 0 && m_scrollbarsAvoidingResizer > 0)
- invalidateRect(windowResizerRect());
- }
-}
-
-void ScrollView::setParent(ScrollView* parentView)
-{
- if (parentView == parent())
- return;
-
- if (m_scrollbarsAvoidingResizer && parent())
- parent()->adjustScrollbarsAvoidingResizerCount(-m_scrollbarsAvoidingResizer);
-
- Widget::setParent(parentView);
-
- if (m_scrollbarsAvoidingResizer && parent())
- parent()->adjustScrollbarsAvoidingResizerCount(m_scrollbarsAvoidingResizer);
-}
-
-void ScrollView::setScrollbarsSuppressed(bool suppressed, bool repaintOnUnsuppress)
-{
- if (suppressed == m_scrollbarsSuppressed)
- return;
-
- m_scrollbarsSuppressed = suppressed;
-
- if (platformWidget())
- platformSetScrollbarsSuppressed(repaintOnUnsuppress);
- else if (repaintOnUnsuppress && !suppressed) {
- if (m_horizontalScrollbar)
- m_horizontalScrollbar->invalidate();
- if (m_verticalScrollbar)
- m_verticalScrollbar->invalidate();
-
- // Invalidate the scroll corner too on unsuppress.
- IntRect hCorner;
- if (m_horizontalScrollbar && width() - m_horizontalScrollbar->width() > 0) {
- hCorner = IntRect(m_horizontalScrollbar->width(),
- height() - m_horizontalScrollbar->height(),
- width() - m_horizontalScrollbar->width(),
- m_horizontalScrollbar->height());
- invalidateRect(hCorner);
- }
-
- if (m_verticalScrollbar && height() - m_verticalScrollbar->height() > 0) {
- IntRect vCorner(width() - m_verticalScrollbar->width(),
- m_verticalScrollbar->height(),
- m_verticalScrollbar->width(),
- height() - m_verticalScrollbar->height());
- if (vCorner != hCorner)
- invalidateRect(vCorner);
- }
- }
-}
-
-Scrollbar* ScrollView::scrollbarUnderMouse(const PlatformMouseEvent& mouseEvent)
-{
- if (platformWidget())
- return 0;
-
- IntPoint viewPoint = convertFromContainingWindow(mouseEvent.pos());
- if (m_horizontalScrollbar && m_horizontalScrollbar->frameRect().contains(viewPoint))
- return m_horizontalScrollbar.get();
- if (m_verticalScrollbar && m_verticalScrollbar->frameRect().contains(viewPoint))
- return m_verticalScrollbar.get();
- return 0;
-}
-
-void ScrollView::wheelEvent(PlatformWheelEvent& e)
-{
- // We don't allow mouse wheeling to happen in a ScrollView that has had its scrollbars explicitly disabled.
- if (!canHaveScrollbars() || platformWidget())
- return;
-
- // Determine how much we want to scroll. If we can move at all, we will accept the event.
- IntSize maxScrollDelta = maximumScrollPosition() - scrollPosition();
- if ((e.deltaX() < 0 && maxScrollDelta.width() > 0) ||
- (e.deltaX() > 0 && scrollOffset().width() > 0) ||
- (e.deltaY() < 0 && maxScrollDelta.height() > 0) ||
- (e.deltaY() > 0 && scrollOffset().height() > 0)) {
- e.accept();
- float deltaX = e.deltaX();
- float deltaY = e.deltaY();
- if (e.granularity() == ScrollByLineWheelEvent) {
- deltaX *= cMouseWheelPixelsPerLineStep;
- deltaY *= cMouseWheelPixelsPerLineStep;
- } else if (e.granularity() == ScrollByPageWheelEvent) {
- ASSERT(deltaX == 0);
- bool negative = deltaY < 0;
- deltaY = max(0, visibleHeight() - cAmountToKeepWhenPaging);
- if (negative)
- deltaY = -deltaY;
- }
- scrollBy(IntSize(-deltaX, -deltaY));
- }
-}
-
-void ScrollView::setFrameRect(const IntRect& newRect)
-{
- IntRect oldRect = frameRect();
-
- if (newRect == oldRect)
- return;
-
- Widget::setFrameRect(newRect);
-
- if (platformWidget())
- return;
-
- if (newRect.width() != oldRect.width() || newRect.height() != oldRect.height()) {
- updateScrollbars(m_scrollOffset);
- contentsResized();
- }
-
- frameRectsChanged();
-}
-
-void ScrollView::frameRectsChanged() const
-{
- if (platformWidget())
- return;
-
- HashSet<Widget*>::const_iterator end = m_children.end();
- for (HashSet<Widget*>::const_iterator current = m_children.begin(); current != end; ++current)
- (*current)->frameRectsChanged();
-}
-
-void ScrollView::repaintContentRectangle(const IntRect& rect, bool now)
-{
- if (rect.isEmpty())
- return;
-
- if (platformWidget()) {
- platformRepaintContentRectangle(rect, now);
- return;
- }
-
- hostWindow()->repaint(contentsToWindow(rect), true, now);
-}
-
-void ScrollView::paint(GraphicsContext* context, const IntRect& rect)
-{
- if (platformWidget()) {
- Widget::paint(context, rect);
- return;
- }
-
- if (context->paintingDisabled() && !context->updatingControlTints())
- return;
-
- IntRect documentDirtyRect = rect;
- documentDirtyRect.intersect(frameRect());
-
- context->save();
-
- context->translate(x(), y());
- documentDirtyRect.move(-x(), -y());
-
- context->translate(-scrollX(), -scrollY());
- documentDirtyRect.move(scrollX(), scrollY());
-
- context->clip(visibleContentRect());
-
- paintContents(context, documentDirtyRect);
-
- context->restore();
-
- // Now paint the scrollbars.
- if (!m_scrollbarsSuppressed && (m_horizontalScrollbar || m_verticalScrollbar)) {
- context->save();
- IntRect scrollViewDirtyRect = rect;
- scrollViewDirtyRect.intersect(frameRect());
- context->translate(x(), y());
- scrollViewDirtyRect.move(-x(), -y());
- if (m_horizontalScrollbar)
- m_horizontalScrollbar->paint(context, scrollViewDirtyRect);
- if (m_verticalScrollbar)
- m_verticalScrollbar->paint(context, scrollViewDirtyRect);
-
- IntRect hCorner;
- if (m_horizontalScrollbar && width() - m_horizontalScrollbar->width() > 0) {
- hCorner = IntRect(m_horizontalScrollbar->width(),
- height() - m_horizontalScrollbar->height(),
- width() - m_horizontalScrollbar->width(),
- m_horizontalScrollbar->height());
- if (hCorner.intersects(scrollViewDirtyRect))
- ScrollbarTheme::nativeTheme()->paintScrollCorner(this, context, hCorner);
- }
-
- if (m_verticalScrollbar && height() - m_verticalScrollbar->height() > 0) {
- IntRect vCorner(width() - m_verticalScrollbar->width(),
- m_verticalScrollbar->height(),
- m_verticalScrollbar->width(),
- height() - m_verticalScrollbar->height());
- if (vCorner != hCorner && vCorner.intersects(scrollViewDirtyRect))
- ScrollbarTheme::nativeTheme()->paintScrollCorner(this, context, vCorner);
- }
-
- context->restore();
- }
-
- // Paint the panScroll Icon
- static RefPtr<Image> panScrollIcon;
- if (m_drawPanScrollIcon) {
- if (!panScrollIcon)
- panScrollIcon = Image::loadPlatformResource("panIcon");
- context->drawImage(panScrollIcon.get(), m_panScrollIconPoint);
- }
-}
-
-bool ScrollView::scrollbarCornerPresent() const
-{
- return (m_horizontalScrollbar && width() - m_horizontalScrollbar->width() > 0) ||
- (m_verticalScrollbar && height() - m_verticalScrollbar->height() > 0);
-}
-
-void ScrollView::setParentVisible(bool visible)
-{
- if (isParentVisible() == visible)
- return;
-
- Widget::setParentVisible(visible);
-
- if (!isVisible())
- return;
-
- HashSet<Widget*>::iterator end = m_children.end();
- for (HashSet<Widget*>::iterator it = m_children.begin(); it != end; ++it)
- (*it)->setParentVisible(visible);
-}
-
-void ScrollView::show()
-{
- if (!isSelfVisible()) {
- setSelfVisible(true);
- if (isParentVisible()) {
- HashSet<Widget*>::iterator end = m_children.end();
- for (HashSet<Widget*>::iterator it = m_children.begin(); it != end; ++it)
- (*it)->setParentVisible(true);
- }
- }
-
- Widget::show();
-}
-
-void ScrollView::hide()
-{
- if (isSelfVisible()) {
- if (isParentVisible()) {
- HashSet<Widget*>::iterator end = m_children.end();
- for (HashSet<Widget*>::iterator it = m_children.begin(); it != end; ++it)
- (*it)->setParentVisible(false);
- }
- setSelfVisible(false);
- }
-
- Widget::hide();
-}
-
-bool ScrollView::isOffscreen() const
-{
- if (platformWidget())
- return platformIsOffscreen();
-
- if (!isVisible())
- return true;
-
- // FIXME: Add a HostWindow::isOffscreen method here. Since only Mac implements this method
- // currently, we can add the method when the other platforms decide to implement this concept.
- return false;
-}
-
-
-void ScrollView::addPanScrollIcon(const IntPoint& iconPosition)
-{
- m_drawPanScrollIcon = true;
- m_panScrollIconPoint = IntPoint(iconPosition.x() - panIconSizeLength / 2 , iconPosition.y() - panIconSizeLength / 2) ;
- hostWindow()->repaint(IntRect(m_panScrollIconPoint, IntSize(panIconSizeLength,panIconSizeLength)), true, true);
-}
-
-void ScrollView::removePanScrollIcon()
-{
- m_drawPanScrollIcon = false;
- hostWindow()->repaint(IntRect(m_panScrollIconPoint, IntSize(panIconSizeLength, panIconSizeLength)), true, true);
-}
-
-#if !PLATFORM(WX) && !PLATFORM(GTK) && !PLATFORM(QT)
-void ScrollView::platformInit()
-{
-}
-
-void ScrollView::platformDestroy()
-{
-}
-#endif
-
-#if !PLATFORM(WX) && !PLATFORM(GTK) && !PLATFORM(QT) && !PLATFORM(MAC)
-void ScrollView::platformAddChild(Widget*)
-{
-}
-
-void ScrollView::platformRemoveChild(Widget*)
-{
-}
-#endif
-
-#if !PLATFORM(MAC)
-void ScrollView::platformSetCanBlitOnScroll()
-{
-}
-
-void ScrollView::platformSetScrollbarsSuppressed(bool repaintOnUnsuppress)
-{
-}
-#endif
-
-#if !PLATFORM(MAC) && !PLATFORM(WX)
-void ScrollView::platformSetScrollbarModes()
-{
-}
-
-#if !PLATFORM(ANDROID)
-void ScrollView::platformScrollbarModes(ScrollbarMode& horizontal, ScrollbarMode& vertical) const
-{
-}
-
-IntRect ScrollView::platformVisibleContentRect(bool) const
-{
- return IntRect();
-}
-
-IntSize ScrollView::platformContentsSize() const
-{
- return IntSize();
-}
-#endif
-
-void ScrollView::platformSetContentsSize()
-{
-}
-
-IntRect ScrollView::platformContentsToScreen(const IntRect& rect) const
-{
- return rect;
-}
-
-IntPoint ScrollView::platformScreenToContents(const IntPoint& point) const
-{
- return point;
-}
-
-#if !PLATFORM(ANDROID)
-void ScrollView::platformSetScrollPosition(const IntPoint&)
-{
-}
-#endif
-
-bool ScrollView::platformScroll(ScrollDirection, ScrollGranularity)
-{
- return true;
-}
-
-#if !PLATFORM(ANDROID)
-void ScrollView::platformRepaintContentRectangle(const IntRect&, bool now)
-{
-}
-
-#ifdef ANDROID_CAPTURE_OFFSCREEN_PAINTS
-void ScrollView::platformOffscreenContentRectangle(const IntRect& )
-{
-}
-#endif
-#endif
-
-bool ScrollView::platformIsOffscreen() const
-{
- return false;
-}
-#endif
-
-#if !PLATFORM(GTK)
-bool ScrollView::platformHandleHorizontalAdjustment(const IntSize&)
-{
- return false;
-}
-
-bool ScrollView::platformHandleVerticalAdjustment(const IntSize&)
-{
- return false;
-}
-
-bool ScrollView::platformHasHorizontalAdjustment() const
-{
- return false;
-}
-
-bool ScrollView::platformHasVerticalAdjustment() const
-{
- return false;
-}
-
-#endif
-
-}
-
diff --git a/WebCore/platform/ScrollView.h b/WebCore/platform/ScrollView.h
deleted file mode 100644
index acd3f85..0000000
--- a/WebCore/platform/ScrollView.h
+++ /dev/null
@@ -1,316 +0,0 @@
-/*
- * Copyright (C) 2004, 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ScrollView_h
-#define ScrollView_h
-
-#include "IntRect.h"
-#include "Scrollbar.h"
-#include "ScrollbarClient.h"
-#include "ScrollTypes.h"
-#include "Widget.h"
-
-#include <wtf/HashSet.h>
-
-#if PLATFORM(MAC) && defined __OBJC__
-@protocol WebCoreFrameScrollView;
-#endif
-
-#if PLATFORM(GTK)
-typedef struct _GtkAdjustment GtkAdjustment;
-#endif
-
-#if PLATFORM(WX)
-class wxScrollWinEvent;
-#endif
-
-// DANGER WILL ROBINSON! THIS FILE IS UNDERGOING HEAVY REFACTORING.
-// Everything is changing!
-// Port authors should wait until this refactoring is complete before attempting to implement this interface.
-namespace WebCore {
-
-class HostWindow;
-class PlatformWheelEvent;
-class Scrollbar;
-
-class ScrollView : public Widget, public ScrollbarClient {
-public:
- ScrollView();
- ~ScrollView();
-
- // ScrollbarClient method. FrameView overrides the other two.
- virtual void valueChanged(Scrollbar*);
-
- // The window thats hosts the ScrollView. The ScrollView will communicate scrolls and repaints to the
- // host window in the window's coordinate space.
- virtual HostWindow* hostWindow() const = 0;
-
- // Returns a clip rect in host window coordinates. Used to clip the blit on a scroll.
- virtual IntRect windowClipRect(bool clipToContents = true) const = 0;
-
- // Methods for child manipulation and inspection.
- const HashSet<Widget*>* children() const { return &m_children; }
- void addChild(Widget*);
- void removeChild(Widget*);
-
- // If the scroll view does not use a native widget, then it will have cross-platform Scrollbars. These methods
- // can be used to obtain those scrollbars.
- Scrollbar* horizontalScrollbar() const { return m_horizontalScrollbar.get(); }
- Scrollbar* verticalScrollbar() const { return m_verticalScrollbar.get(); }
- bool isScrollViewScrollbar(const Widget* child) const { return horizontalScrollbar() == child || verticalScrollbar() == child; }
-
- // Methods for setting and retrieving the scrolling mode in each axis (horizontal/vertical). The mode has values of
- // AlwaysOff, AlwaysOn, and Auto. AlwaysOff means never show a scrollbar, AlwaysOn means always show a scrollbar.
- // Auto means show a scrollbar only when one is needed.
- // Note that for platforms with native widgets, these modes are considered advisory. In other words the underlying native
- // widget may choose not to honor the requested modes.
- void setScrollbarModes(ScrollbarMode horizontalMode, ScrollbarMode verticalMode);
- void setHorizontalScrollbarMode(ScrollbarMode mode) { setScrollbarModes(mode, verticalScrollbarMode()); }
- void setVerticalScrollbarMode(ScrollbarMode mode) { setScrollbarModes(horizontalScrollbarMode(), mode); }
- void scrollbarModes(ScrollbarMode& horizontalMode, ScrollbarMode& verticalMode) const;
- ScrollbarMode horizontalScrollbarMode() const { ScrollbarMode horizontal, vertical; scrollbarModes(horizontal, vertical); return horizontal; }
- ScrollbarMode verticalScrollbarMode() const { ScrollbarMode horizontal, vertical; scrollbarModes(horizontal, vertical); return vertical; }
- virtual void setCanHaveScrollbars(bool flag);
- bool canHaveScrollbars() const { return horizontalScrollbarMode() != ScrollbarAlwaysOff || verticalScrollbarMode() != ScrollbarAlwaysOff; }
-
- // If the prohibits scrolling flag is set, then all scrolling in the view (even programmatic scrolling) is turned off.
- void setProhibitsScrolling(bool b) { m_prohibitsScrolling = b; }
- bool prohibitsScrolling() const { return m_prohibitsScrolling; }
-
- // Whether or not a scroll view will blit visible contents when it is scrolled. Blitting is disabled in situations
- // where it would cause rendering glitches (such as with fixed backgrounds or when the view is partially transparent).
- void setCanBlitOnScroll(bool);
- bool canBlitOnScroll() const { return m_canBlitOnScroll; }
-
- // The visible content rect has a location that is the scrolled offset of the document. The width and height are the viewport width
- // and height. By default the scrollbars themselves are excluded from this rectangle, but an optional boolean argument allows them to be
- // included.
- IntRect visibleContentRect(bool includeScrollbars = false) const;
- int visibleWidth() const { return visibleContentRect().width(); }
- int visibleHeight() const { return visibleContentRect().height(); }
-
- // Methods for getting/setting the size of the document contained inside the ScrollView (as an IntSize or as individual width and height
- // values).
- IntSize contentsSize() const;
- int contentsWidth() const { return contentsSize().width(); }
- int contentsHeight() const { return contentsSize().height(); }
- void setContentsSize(const IntSize&);
-
- // Methods for querying the current scrolled position (both as a point, a size, or as individual X and Y values).
- IntPoint scrollPosition() const { return visibleContentRect().location(); }
- IntSize scrollOffset() const { return visibleContentRect().location() - IntPoint(); } // Gets the scrolled position as an IntSize. Convenient for adding to other sizes.
- IntPoint maximumScrollPosition() const; // The maximum position we can be scrolled to.
- int scrollX() const { return scrollPosition().x(); }
- int scrollY() const { return scrollPosition().y(); }
-
- // Methods for scrolling the view. setScrollPosition is the only method that really scrolls the view. The other two methods are helper functions
- // that ultimately end up calling setScrollPosition.
- void setScrollPosition(const IntPoint&);
- void scrollBy(const IntSize& s) { return setScrollPosition(scrollPosition() + s); }
- void scrollRectIntoViewRecursively(const IntRect&);
-
- // This method scrolls by lines, pages or pixels.
- bool scroll(ScrollDirection, ScrollGranularity);
-
- // Scroll the actual contents of the view (either blitting or invalidating as needed).
- void scrollContents(const IntSize& scrollDelta);
-
- // This gives us a means of blocking painting on our scrollbars until the first layout has occurred.
- void setScrollbarsSuppressed(bool suppressed, bool repaintOnUnsuppress = false);
- bool scrollbarsSuppressed() const { return m_scrollbarsSuppressed; }
-
- // Event coordinates are assumed to be in the coordinate space of a window that contains
- // the entire widget hierarchy. It is up to the platform to decide what the precise definition
- // of containing window is. (For example on Mac it is the containing NSWindow.)
- IntPoint windowToContents(const IntPoint&) const;
- IntPoint contentsToWindow(const IntPoint&) const;
- IntRect windowToContents(const IntRect&) const;
- IntRect contentsToWindow(const IntRect&) const;
-
- // Methods for converting to and from screen coordinates.
- IntRect contentsToScreen(const IntRect&) const;
- IntPoint screenToContents(const IntPoint&) const;
-
- // The purpose of this method is to answer whether or not the scroll view is currently visible. Animations and painting updates can be suspended if
- // we know that we are either not in a window right now or if that window is not visible.
- bool isOffscreen() const;
-
- // These methods are used to enable scrollbars to avoid window resizer controls that overlap the scroll view. This happens on Mac
- // for example.
- virtual IntRect windowResizerRect() const { return IntRect(); }
- bool containsScrollbarsAvoidingResizer() const;
- void adjustScrollbarsAvoidingResizerCount(int overlapDelta);
- virtual void setParent(ScrollView*); // Overridden to update the overlapping scrollbar count.
-
- // Called when our frame rect changes (or the rect/scroll position of an ancestor changes).
- virtual void frameRectsChanged() const;
-
- // Widget override to update our scrollbars and notify our contents of the resize.
- virtual void setFrameRect(const IntRect&);
-
- // For platforms that need to hit test scrollbars from within the engine's event handlers (like Win32).
- Scrollbar* scrollbarUnderMouse(const PlatformMouseEvent& mouseEvent);
-
- // This method exists for scrollviews that need to handle wheel events manually.
- // On Mac the underlying NSScrollView just does the scrolling, but on other platforms
- // (like Windows), we need this method in order to do the scroll ourselves.
- void wheelEvent(PlatformWheelEvent&);
-
- IntPoint convertChildToSelf(const Widget* child, const IntPoint& point) const
- {
- IntPoint newPoint = point;
- if (!isScrollViewScrollbar(child))
- newPoint = point - scrollOffset();
- newPoint.move(child->x(), child->y());
- return newPoint;
- }
-
- IntPoint convertSelfToChild(const Widget* child, const IntPoint& point) const
- {
- IntPoint newPoint = point;
- if (!isScrollViewScrollbar(child))
- newPoint = point + scrollOffset();
- newPoint.move(-child->x(), -child->y());
- return newPoint;
- }
-
- // Widget override. Handles painting of the contents of the view as well as the scrollbars.
- virtual void paint(GraphicsContext*, const IntRect&);
-
- // Widget overrides to ensure that our children's visibility status is kept up to date when we get shown and hidden.
- virtual void show();
- virtual void hide();
- virtual void setParentVisible(bool);
-
- // Pan scrolling methods.
- void addPanScrollIcon(const IntPoint&);
- void removePanScrollIcon();
-
- virtual bool scrollbarCornerPresent() const;
-
-protected:
- virtual void repaintContentRectangle(const IntRect&, bool now = false);
- virtual void paintContents(GraphicsContext*, const IntRect& damageRect) = 0;
-
- virtual void contentsResized() = 0;
- virtual void visibleContentsResized() = 0;
-
- // These methods are used to create/destroy scrollbars.
- void setHasHorizontalScrollbar(bool);
- void setHasVerticalScrollbar(bool);
-
-private:
- RefPtr<Scrollbar> m_horizontalScrollbar;
- RefPtr<Scrollbar> m_verticalScrollbar;
- ScrollbarMode m_horizontalScrollbarMode;
- ScrollbarMode m_verticalScrollbarMode;
- bool m_prohibitsScrolling;
-
- HashSet<Widget*> m_children;
- bool m_canBlitOnScroll;
- IntSize m_scrollOffset; // FIXME: Would rather store this as a position, but we will wait to make this change until more code is shared.
- IntSize m_contentsSize;
-
- int m_scrollbarsAvoidingResizer;
- bool m_scrollbarsSuppressed;
-
- bool m_inUpdateScrollbars;
-
- IntPoint m_panScrollIconPoint;
- bool m_drawPanScrollIcon;
-
- void init();
- void destroy();
-
- // Called to update the scrollbars to accurately reflect the state of the view.
- void updateScrollbars(const IntSize& desiredOffset);
-
- void platformInit();
- void platformDestroy();
- void platformAddChild(Widget*);
- void platformRemoveChild(Widget*);
- void platformSetScrollbarModes();
- void platformScrollbarModes(ScrollbarMode& horizontal, ScrollbarMode& vertical) const;
- void platformSetCanBlitOnScroll();
- IntRect platformVisibleContentRect(bool includeScrollbars) const;
- IntSize platformContentsSize() const;
- void platformSetContentsSize();
- IntRect platformContentsToScreen(const IntRect&) const;
- IntPoint platformScreenToContents(const IntPoint&) const;
- void platformSetScrollPosition(const IntPoint&);
- bool platformScroll(ScrollDirection, ScrollGranularity);
- void platformSetScrollbarsSuppressed(bool repaintOnUnsuppress);
- void platformRepaintContentRectangle(const IntRect&, bool now);
- bool platformIsOffscreen() const;
- bool platformHandleHorizontalAdjustment(const IntSize&);
- bool platformHandleVerticalAdjustment(const IntSize&);
- bool platformHasHorizontalAdjustment() const;
- bool platformHasVerticalAdjustment() const;
-
-#if PLATFORM(MAC) && defined __OBJC__
-public:
- NSView* documentView() const;
-
-private:
- NSScrollView<WebCoreFrameScrollView>* scrollView() const;
-#endif
-
-#if PLATFORM(QT)
-private:
- bool rootPreventsBlitting() const { return root()->m_widgetsThatPreventBlitting > 0; }
- unsigned m_widgetsThatPreventBlitting;
-#else
- bool rootPreventsBlitting() const { return false; }
-#endif
-
-#if PLATFORM(GTK)
-public:
- void setGtkAdjustments(GtkAdjustment* hadj, GtkAdjustment* vadj);
- GtkAdjustment* m_horizontalAdjustment;
- GtkAdjustment* m_verticalAdjustment;
- void setScrollOffset(const IntSize& offset) { m_scrollOffset = offset; }
-#endif
-
-#if PLATFORM(WX)
-public:
- virtual void setPlatformWidget(wxWindow*);
- void adjustScrollbars(int x = -1, int y = -1, bool refresh = true);
-private:
- class ScrollViewPrivate;
- ScrollViewPrivate* m_data;
-#endif
-
-#if PLATFORM(ANDROID)
-public:
- bool platformProhibitsScrolling();
-#ifdef ANDROID_CAPTURE_OFFSCREEN_PAINTS
- void platformOffscreenContentRectangle(const IntRect& );
-#endif
-#endif
-}; // class ScrollView
-
-} // namespace WebCore
-
-#endif // ScrollView_h
diff --git a/WebCore/platform/Scrollbar.cpp b/WebCore/platform/Scrollbar.cpp
deleted file mode 100644
index 0c7d854..0000000
--- a/WebCore/platform/Scrollbar.cpp
+++ /dev/null
@@ -1,451 +0,0 @@
-/*
- * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Scrollbar.h"
-
-#include "EventHandler.h"
-#include "Frame.h"
-#include "FrameView.h"
-#include "GraphicsContext.h"
-#include "PlatformMouseEvent.h"
-#include "ScrollbarClient.h"
-#include "ScrollbarTheme.h"
-
-#include <algorithm>
-
-using std::max;
-using std::min;
-
-namespace WebCore {
-
-#if !PLATFORM(GTK)
-PassRefPtr<Scrollbar> Scrollbar::createNativeScrollbar(ScrollbarClient* client, ScrollbarOrientation orientation, ScrollbarControlSize size)
-{
- return adoptRef(new Scrollbar(client, orientation, size));
-}
-#endif
-
-Scrollbar::Scrollbar(ScrollbarClient* client, ScrollbarOrientation orientation, ScrollbarControlSize controlSize,
- ScrollbarTheme* theme)
- : m_client(client)
- , m_orientation(orientation)
- , m_controlSize(controlSize)
- , m_theme(theme)
- , m_visibleSize(0)
- , m_totalSize(0)
- , m_currentPos(0)
- , m_lineStep(0)
- , m_pageStep(0)
- , m_pixelStep(1)
- , m_hoveredPart(NoPart)
- , m_pressedPart(NoPart)
- , m_pressedPos(0)
- , m_enabled(true)
- , m_scrollTimer(this, &Scrollbar::autoscrollTimerFired)
- , m_overlapsResizer(false)
- , m_suppressInvalidation(false)
-{
- if (!m_theme)
- m_theme = ScrollbarTheme::nativeTheme();
-
- m_theme->registerScrollbar(this);
-
- // FIXME: This is ugly and would not be necessary if we fix cross-platform code to actually query for
- // scrollbar thickness and use it when sizing scrollbars (rather than leaving one dimension of the scrollbar
- // alone when sizing).
- int thickness = m_theme->scrollbarThickness(controlSize);
- Widget::setFrameRect(IntRect(0, 0, thickness, thickness));
-}
-
-Scrollbar::~Scrollbar()
-{
- stopTimerIfNeeded();
-
- m_theme->unregisterScrollbar(this);
-}
-
-bool Scrollbar::setValue(int v)
-{
- v = max(min(v, m_totalSize - m_visibleSize), 0);
- if (value() == v)
- return false; // Our value stayed the same.
- m_currentPos = v;
-
- updateThumbPosition();
-
- if (client())
- client()->valueChanged(this);
-
- return true;
-}
-
-void Scrollbar::setProportion(int visibleSize, int totalSize)
-{
- if (visibleSize == m_visibleSize && totalSize == m_totalSize)
- return;
-
- m_visibleSize = visibleSize;
- m_totalSize = totalSize;
-
- updateThumbProportion();
-}
-
-void Scrollbar::setSteps(int lineStep, int pageStep, int pixelsPerStep)
-{
- m_lineStep = lineStep;
- m_pageStep = pageStep;
- m_pixelStep = 1.0f / pixelsPerStep;
-}
-
-bool Scrollbar::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier)
-{
- float step = 0;
- if ((direction == ScrollUp && m_orientation == VerticalScrollbar) || (direction == ScrollLeft && m_orientation == HorizontalScrollbar))
- step = -1;
- else if ((direction == ScrollDown && m_orientation == VerticalScrollbar) || (direction == ScrollRight && m_orientation == HorizontalScrollbar))
- step = 1;
-
- if (granularity == ScrollByLine)
- step *= m_lineStep;
- else if (granularity == ScrollByPage)
- step *= m_pageStep;
- else if (granularity == ScrollByDocument)
- step *= m_totalSize;
- else if (granularity == ScrollByPixel)
- step *= m_pixelStep;
-
- float newPos = m_currentPos + step * multiplier;
- float maxPos = m_totalSize - m_visibleSize;
- newPos = max(min(newPos, maxPos), 0.0f);
-
- if (newPos == m_currentPos)
- return false;
-
- int oldValue = value();
- m_currentPos = newPos;
- updateThumbPosition();
-
- if (value() != oldValue && client())
- client()->valueChanged(this);
-
- // return true even if the integer value did not change so that scroll event gets eaten
- return true;
-}
-
-void Scrollbar::updateThumbPosition()
-{
- theme()->invalidateParts(this, ForwardTrackPart | BackTrackPart | ThumbPart);
-}
-
-void Scrollbar::updateThumbProportion()
-{
- theme()->invalidateParts(this, ForwardTrackPart | BackTrackPart | ThumbPart);
-}
-
-void Scrollbar::paint(GraphicsContext* context, const IntRect& damageRect)
-{
- if (context->updatingControlTints() && theme()->supportsControlTints()) {
- invalidate();
- return;
- }
-
- if (context->paintingDisabled() || !frameRect().intersects(damageRect))
- return;
-
- if (!theme()->paint(this, context, damageRect))
- Widget::paint(context, damageRect);
-}
-
-void Scrollbar::autoscrollTimerFired(Timer<Scrollbar>*)
-{
- autoscrollPressedPart(theme()->autoscrollTimerDelay());
-}
-
-static bool thumbUnderMouse(Scrollbar* scrollbar)
-{
- int thumbPos = scrollbar->theme()->trackPosition(scrollbar) + scrollbar->theme()->thumbPosition(scrollbar);
- int thumbLength = scrollbar->theme()->thumbLength(scrollbar);
- return scrollbar->pressedPos() >= thumbPos && scrollbar->pressedPos() < thumbPos + thumbLength;
-}
-
-void Scrollbar::autoscrollPressedPart(double delay)
-{
- // Don't do anything for the thumb or if nothing was pressed.
- if (m_pressedPart == ThumbPart || m_pressedPart == NoPart)
- return;
-
- // Handle the track.
- if ((m_pressedPart == BackTrackPart || m_pressedPart == ForwardTrackPart) && thumbUnderMouse(this)) {
- theme()->invalidatePart(this, m_pressedPart);
- setHoveredPart(ThumbPart);
- return;
- }
-
- // Handle the arrows and track.
- if (scroll(pressedPartScrollDirection(), pressedPartScrollGranularity()))
- startTimerIfNeeded(delay);
-}
-
-void Scrollbar::startTimerIfNeeded(double delay)
-{
- // Don't do anything for the thumb.
- if (m_pressedPart == ThumbPart)
- return;
-
- // Handle the track. We halt track scrolling once the thumb is level
- // with us.
- if ((m_pressedPart == BackTrackPart || m_pressedPart == ForwardTrackPart) && thumbUnderMouse(this)) {
- theme()->invalidatePart(this, m_pressedPart);
- setHoveredPart(ThumbPart);
- return;
- }
-
- // We can't scroll if we've hit the beginning or end.
- ScrollDirection dir = pressedPartScrollDirection();
- if (dir == ScrollUp || dir == ScrollLeft) {
- if (m_currentPos == 0)
- return;
- } else {
- if (m_currentPos == maximum())
- return;
- }
-
- m_scrollTimer.startOneShot(delay);
-}
-
-void Scrollbar::stopTimerIfNeeded()
-{
- if (m_scrollTimer.isActive())
- m_scrollTimer.stop();
-}
-
-ScrollDirection Scrollbar::pressedPartScrollDirection()
-{
- if (m_orientation == HorizontalScrollbar) {
- if (m_pressedPart == BackButtonStartPart || m_pressedPart == BackButtonEndPart || m_pressedPart == BackTrackPart)
- return ScrollLeft;
- return ScrollRight;
- } else {
- if (m_pressedPart == BackButtonStartPart || m_pressedPart == BackButtonEndPart || m_pressedPart == BackTrackPart)
- return ScrollUp;
- return ScrollDown;
- }
-}
-
-ScrollGranularity Scrollbar::pressedPartScrollGranularity()
-{
- if (m_pressedPart == BackButtonStartPart || m_pressedPart == BackButtonEndPart || m_pressedPart == ForwardButtonStartPart || m_pressedPart == ForwardButtonEndPart)
- return ScrollByLine;
- return ScrollByPage;
-}
-
-void Scrollbar::moveThumb(int pos)
-{
- // Drag the thumb.
- int thumbPos = theme()->thumbPosition(this);
- int thumbLen = theme()->thumbLength(this);
- int trackLen = theme()->trackLength(this);
- int maxPos = trackLen - thumbLen;
- int delta = pos - pressedPos();
- if (delta > 0)
- delta = min(maxPos - thumbPos, delta);
- else if (delta < 0)
- delta = max(-thumbPos, delta);
- if (delta) {
- setValue(static_cast<int>(static_cast<float>(thumbPos + delta) * maximum() / (trackLen - thumbLen)));
- setPressedPos(pressedPos() + theme()->thumbPosition(this) - thumbPos);
- }
-}
-
-void Scrollbar::setHoveredPart(ScrollbarPart part)
-{
- if (part == m_hoveredPart)
- return;
-
- if ((m_hoveredPart == NoPart || part == NoPart) && theme()->invalidateOnMouseEnterExit())
- invalidate(); // Just invalidate the whole scrollbar, since the buttons at either end change anyway.
- else if (m_pressedPart == NoPart) {
- theme()->invalidatePart(this, part);
- theme()->invalidatePart(this, m_hoveredPart);
- }
- m_hoveredPart = part;
-}
-
-void Scrollbar::setPressedPart(ScrollbarPart part)
-{
- if (m_pressedPart != NoPart)
- theme()->invalidatePart(this, m_pressedPart);
- m_pressedPart = part;
- if (m_pressedPart != NoPart)
- theme()->invalidatePart(this, m_pressedPart);
-}
-
-bool Scrollbar::mouseMoved(const PlatformMouseEvent& evt)
-{
- if (m_pressedPart == ThumbPart) {
- moveThumb(m_orientation == HorizontalScrollbar ?
- convertFromContainingWindow(evt.pos()).x() :
- convertFromContainingWindow(evt.pos()).y());
- return true;
- }
-
- if (m_pressedPart != NoPart)
- m_pressedPos = (orientation() == HorizontalScrollbar ? convertFromContainingWindow(evt.pos()).x() : convertFromContainingWindow(evt.pos()).y());
-
- ScrollbarPart part = theme()->hitTest(this, evt);
- if (part != m_hoveredPart) {
- if (m_pressedPart != NoPart) {
- if (part == m_pressedPart) {
- // The mouse is moving back over the pressed part. We
- // need to start up the timer action again.
- startTimerIfNeeded(theme()->autoscrollTimerDelay());
- theme()->invalidatePart(this, m_pressedPart);
- } else if (m_hoveredPart == m_pressedPart) {
- // The mouse is leaving the pressed part. Kill our timer
- // if needed.
- stopTimerIfNeeded();
- theme()->invalidatePart(this, m_pressedPart);
- }
- }
-
- setHoveredPart(part);
- }
-
- return true;
-}
-
-bool Scrollbar::mouseExited()
-{
- setHoveredPart(NoPart);
- return true;
-}
-
-bool Scrollbar::mouseUp()
-{
- setPressedPart(NoPart);
- m_pressedPos = 0;
- stopTimerIfNeeded();
-
- if (parent() && parent()->isFrameView())
- static_cast<FrameView*>(parent())->frame()->eventHandler()->setMousePressed(false);
-
- return true;
-}
-
-bool Scrollbar::mouseDown(const PlatformMouseEvent& evt)
-{
- // Early exit for right click
- if (evt.button() == RightButton)
- return true; // FIXME: Handled as context menu by Qt right now. Should just avoid even calling this method on a right click though.
-
- setPressedPart(theme()->hitTest(this, evt));
- int pressedPos = (orientation() == HorizontalScrollbar ? convertFromContainingWindow(evt.pos()).x() : convertFromContainingWindow(evt.pos()).y());
-
- if (theme()->shouldCenterOnThumb(this, evt)) {
- setHoveredPart(ThumbPart);
- setPressedPart(ThumbPart);
- int thumbLen = theme()->thumbLength(this);
- int desiredPos = pressedPos - thumbLen / 2;
- // Set the pressed position to the top of the thumb so that when we do the move, the delta
- // will be from the current pixel position of the thumb to the new desired position for the thumb.
- m_pressedPos = theme()->trackPosition(this) + theme()->thumbPosition(this);
- moveThumb(desiredPos);
- return true;
- }
-
- m_pressedPos = pressedPos;
-
- autoscrollPressedPart(theme()->initialAutoscrollTimerDelay());
- return true;
-}
-
-void Scrollbar::setFrameRect(const IntRect& rect)
-{
- // Get our window resizer rect and see if we overlap. Adjust to avoid the overlap
- // if necessary.
- IntRect adjustedRect(rect);
- if (parent()) {
- bool overlapsResizer = false;
- ScrollView* view = parent();
- IntRect resizerRect = view->convertFromContainingWindow(view->windowResizerRect());
- if (rect.intersects(resizerRect)) {
- if (orientation() == HorizontalScrollbar) {
- int overlap = rect.right() - resizerRect.x();
- if (overlap > 0 && resizerRect.right() >= rect.right()) {
- adjustedRect.setWidth(rect.width() - overlap);
- overlapsResizer = true;
- }
- } else {
- int overlap = rect.bottom() - resizerRect.y();
- if (overlap > 0 && resizerRect.bottom() >= rect.bottom()) {
- adjustedRect.setHeight(rect.height() - overlap);
- overlapsResizer = true;
- }
- }
- }
-
- if (overlapsResizer != m_overlapsResizer) {
- m_overlapsResizer = overlapsResizer;
- view->adjustScrollbarsAvoidingResizerCount(m_overlapsResizer ? 1 : -1);
- }
- }
-
- Widget::setFrameRect(adjustedRect);
-}
-
-void Scrollbar::setParent(ScrollView* parentView)
-{
- if (!parentView && m_overlapsResizer && parent())
- parent()->adjustScrollbarsAvoidingResizerCount(-1);
- Widget::setParent(parentView);
-}
-
-void Scrollbar::setEnabled(bool e)
-{
- if (m_enabled == e)
- return;
- m_enabled = e;
- invalidate();
-}
-
-bool Scrollbar::isWindowActive() const
-{
- return m_client->isActive();
-}
-
-void Scrollbar::invalidateRect(const IntRect& rect)
-{
- if (suppressInvalidation())
- return;
- m_client->invalidateScrollbarRect(this, rect);
-}
-
-PlatformMouseEvent Scrollbar::transformEvent(const PlatformMouseEvent& event)
-{
- return event;
-}
-
-}
diff --git a/WebCore/platform/Scrollbar.h b/WebCore/platform/Scrollbar.h
deleted file mode 100644
index 9238a77..0000000
--- a/WebCore/platform/Scrollbar.h
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef Scrollbar_h
-#define Scrollbar_h
-
-#include <wtf/RefCounted.h>
-#include "ScrollTypes.h"
-#include "Timer.h"
-#include "Widget.h"
-#include <wtf/MathExtras.h>
-#include <wtf/PassRefPtr.h>
-
-namespace WebCore {
-
-class GraphicsContext;
-class IntRect;
-class ScrollbarClient;
-class ScrollbarTheme;
-class PlatformMouseEvent;
-
-// These match the numbers we use over in WebKit (WebFrameView.m).
-const int cScrollbarPixelsPerLineStep = 40;
-const float cMouseWheelPixelsPerLineStep = 40.0f / 3.0f;
-const int cAmountToKeepWhenPaging = 40;
-
-class Scrollbar : public Widget, public RefCounted<Scrollbar> {
-protected:
- Scrollbar(ScrollbarClient*, ScrollbarOrientation, ScrollbarControlSize, ScrollbarTheme* = 0);
-
-public:
- virtual ~Scrollbar();
-
- // Must be implemented by platforms that can't simply use the Scrollbar base class. Right now the only platform that is not using the base class is GTK.
- static PassRefPtr<Scrollbar> createNativeScrollbar(ScrollbarClient* client, ScrollbarOrientation orientation, ScrollbarControlSize size);
-
- void setClient(ScrollbarClient* client) { m_client = client; }
- ScrollbarClient* client() const { return m_client; }
-
- ScrollbarOrientation orientation() const { return m_orientation; }
-
- int value() const { return lroundf(m_currentPos); }
- float currentPos() const { return m_currentPos; }
- int pressedPos() const { return m_pressedPos; }
- int visibleSize() const { return m_visibleSize; }
- int totalSize() const { return m_totalSize; }
- int maximum() const { return m_totalSize - m_visibleSize; }
- ScrollbarControlSize controlSize() const { return m_controlSize; }
-
- int lineStep() const { return m_lineStep; }
- int pageStep() const { return m_pageStep; }
- float pixelStep() const { return m_pixelStep; }
-
- ScrollbarPart pressedPart() const { return m_pressedPart; }
- ScrollbarPart hoveredPart() const { return m_hoveredPart; }
- virtual void setHoveredPart(ScrollbarPart);
- virtual void setPressedPart(ScrollbarPart);
-
- void setSteps(int lineStep, int pageStep, int pixelsPerStep = 1);
- bool setValue(int);
- void setProportion(int visibleSize, int totalSize);
- void setPressedPos(int p) { m_pressedPos = p; }
-
- bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1.0f);
-
- virtual void paint(GraphicsContext*, const IntRect& damageRect);
-
- bool enabled() const { return m_enabled; }
- virtual void setEnabled(bool e);
-
- bool isWindowActive() const;
-
- // These methods are used for platform scrollbars to give :hover feedback. They will not get called
- // when the mouse went down in a scrollbar, since it is assumed the scrollbar will start
- // grabbing all events in that case anyway.
- bool mouseMoved(const PlatformMouseEvent&);
- bool mouseExited();
-
- // Used by some platform scrollbars to know when they've been released from capture.
- bool mouseUp();
-
- bool mouseDown(const PlatformMouseEvent&);
-
-#if PLATFORM(QT)
- // For platforms that wish to handle context menu events.
- // FIXME: This is misplaced. Normal hit testing should be used to populate a correct
- // context menu. There's no reason why the scrollbar should have to do it.
- bool contextMenu(const PlatformMouseEvent& event);
-#endif
-
- // Takes an event and accounts for any transforms that might occur on the scrollbar. Returns
- // a new event that has had all of the transforms applied.
- PlatformMouseEvent transformEvent(const PlatformMouseEvent&);
-
- ScrollbarTheme* theme() const { return m_theme; }
-
- virtual void setParent(ScrollView*);
- virtual void setFrameRect(const IntRect&);
-
- virtual void invalidateRect(const IntRect&);
-
- bool suppressInvalidation() const { return m_suppressInvalidation; }
- void setSuppressInvalidation(bool s) { m_suppressInvalidation = s; }
-
- virtual void styleChanged() { }
-
-protected:
- virtual void updateThumbPosition();
- virtual void updateThumbProportion();
-
- void autoscrollTimerFired(Timer<Scrollbar>*);
- void startTimerIfNeeded(double delay);
- void stopTimerIfNeeded();
- void autoscrollPressedPart(double delay);
- ScrollDirection pressedPartScrollDirection();
- ScrollGranularity pressedPartScrollGranularity();
-
- void moveThumb(int pos);
-
- ScrollbarClient* m_client;
- ScrollbarOrientation m_orientation;
- ScrollbarControlSize m_controlSize;
- ScrollbarTheme* m_theme;
-
- int m_visibleSize;
- int m_totalSize;
- float m_currentPos;
- int m_lineStep;
- int m_pageStep;
- float m_pixelStep;
-
- ScrollbarPart m_hoveredPart;
- ScrollbarPart m_pressedPart;
- int m_pressedPos;
-
- bool m_enabled;
-
- Timer<Scrollbar> m_scrollTimer;
- bool m_overlapsResizer;
-
- bool m_suppressInvalidation;
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/ScrollbarClient.h b/WebCore/platform/ScrollbarClient.h
deleted file mode 100644
index ea35758..0000000
--- a/WebCore/platform/ScrollbarClient.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ScrollbarClient_h
-#define ScrollbarClient_h
-
-#include "IntRect.h"
-
-namespace WebCore {
-
-class Scrollbar;
-
-class ScrollbarClient {
-public:
- virtual ~ScrollbarClient() {}
- virtual void valueChanged(Scrollbar*) = 0;
-
- virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) = 0;
-
- virtual bool isActive() const = 0;
-
- virtual bool scrollbarCornerPresent() const = 0;
-};
-
-}
-#endif
diff --git a/WebCore/platform/ScrollbarTheme.h b/WebCore/platform/ScrollbarTheme.h
deleted file mode 100644
index 1fdb2b2..0000000
--- a/WebCore/platform/ScrollbarTheme.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ScrollbarTheme_h
-#define ScrollbarTheme_h
-
-#include "GraphicsContext.h"
-#include "IntRect.h"
-#include "ScrollTypes.h"
-
-namespace WebCore {
-
-class PlatformMouseEvent;
-class Scrollbar;
-class ScrollView;
-
-class ScrollbarTheme {
-public:
- virtual ~ScrollbarTheme() {};
-
- virtual bool paint(Scrollbar*, GraphicsContext*, const IntRect& damageRect) { return false; }
- virtual ScrollbarPart hitTest(Scrollbar*, const PlatformMouseEvent&) { return NoPart; }
-
- virtual int scrollbarThickness(ScrollbarControlSize = RegularScrollbar) { return 0; }
-
- virtual ScrollbarButtonsPlacement buttonsPlacement() const { return ScrollbarButtonsSingle; }
-
- virtual bool supportsControlTints() const { return false; }
-
- virtual void themeChanged() {}
-
- virtual bool invalidateOnMouseEnterExit() { return false; }
-
- void invalidateParts(Scrollbar* scrollbar, ScrollbarControlPartMask mask)
- {
- if (mask & BackButtonStartPart)
- invalidatePart(scrollbar, BackButtonStartPart);
- if (mask & ForwardButtonStartPart)
- invalidatePart(scrollbar, ForwardButtonStartPart);
- if (mask & BackTrackPart)
- invalidatePart(scrollbar, BackTrackPart);
- if (mask & ThumbPart)
- invalidatePart(scrollbar, ThumbPart);
- if (mask & ForwardTrackPart)
- invalidatePart(scrollbar, ForwardTrackPart);
- if (mask & BackButtonEndPart)
- invalidatePart(scrollbar, BackButtonEndPart);
- if (mask & ForwardButtonEndPart)
- invalidatePart(scrollbar, ForwardButtonEndPart);
- }
-
- virtual void invalidatePart(Scrollbar*, ScrollbarPart) {}
-
- virtual void paintScrollCorner(ScrollView*, GraphicsContext* context, const IntRect& cornerRect) { context->fillRect(cornerRect, Color::white); }
-
- virtual bool shouldCenterOnThumb(Scrollbar*, const PlatformMouseEvent&) { return false; }
- virtual int thumbPosition(Scrollbar*) { return 0; } // The position of the thumb relative to the track.
- virtual int thumbLength(Scrollbar*) { return 0; } // The length of the thumb along the axis of the scrollbar.
- virtual int trackPosition(Scrollbar*) { return 0; } // The position of the track relative to the scrollbar.
- virtual int trackLength(Scrollbar*) { return 0; } // The length of the track along the axis of the scrollbar.
-
- virtual double initialAutoscrollTimerDelay() { return 0.25; }
- virtual double autoscrollTimerDelay() { return 0.05; }
-
- virtual void registerScrollbar(Scrollbar*) {}
- virtual void unregisterScrollbar(Scrollbar*) {}
-
- static ScrollbarTheme* nativeTheme(); // Must be implemented to return the correct theme subclass.
-};
-
-}
-#endif
diff --git a/WebCore/platform/ScrollbarThemeComposite.cpp b/WebCore/platform/ScrollbarThemeComposite.cpp
deleted file mode 100644
index 4ea74fe..0000000
--- a/WebCore/platform/ScrollbarThemeComposite.cpp
+++ /dev/null
@@ -1,302 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ScrollbarThemeComposite.h"
-
-#include "ChromeClient.h"
-#include "Frame.h"
-#include "FrameView.h"
-#include "GraphicsContext.h"
-#include "Page.h"
-#include "PlatformMouseEvent.h"
-#include "Scrollbar.h"
-#include "ScrollbarClient.h"
-#include "Settings.h"
-
-namespace WebCore {
-
-#if PLATFORM(WIN)
-static Page* pageForScrollView(ScrollView* view)
-{
- if (!view)
- return 0;
- if (!view->isFrameView())
- return 0;
- FrameView* frameView = static_cast<FrameView*>(view);
- if (!frameView->frame())
- return 0;
- return frameView->frame()->page();
-}
-#endif
-
-bool ScrollbarThemeComposite::paint(Scrollbar* scrollbar, GraphicsContext* graphicsContext, const IntRect& damageRect)
-{
- // Create the ScrollbarControlPartMask based on the damageRect
- ScrollbarControlPartMask scrollMask = NoPart;
-
- IntRect backButtonStartPaintRect;
- IntRect backButtonEndPaintRect;
- IntRect forwardButtonStartPaintRect;
- IntRect forwardButtonEndPaintRect;
- if (hasButtons(scrollbar)) {
- backButtonStartPaintRect = backButtonRect(scrollbar, BackButtonStartPart, true);
- if (damageRect.intersects(backButtonStartPaintRect))
- scrollMask |= BackButtonStartPart;
- backButtonEndPaintRect = backButtonRect(scrollbar, BackButtonEndPart, true);
- if (damageRect.intersects(backButtonEndPaintRect))
- scrollMask |= BackButtonEndPart;
- forwardButtonStartPaintRect = forwardButtonRect(scrollbar, ForwardButtonStartPart, true);
- if (damageRect.intersects(forwardButtonStartPaintRect))
- scrollMask |= ForwardButtonStartPart;
- forwardButtonEndPaintRect = forwardButtonRect(scrollbar, ForwardButtonEndPart, true);
- if (damageRect.intersects(forwardButtonEndPaintRect))
- scrollMask |= ForwardButtonEndPart;
- }
-
- IntRect startTrackRect;
- IntRect thumbRect;
- IntRect endTrackRect;
- IntRect trackPaintRect = trackRect(scrollbar, true);
- if (damageRect.intersects(trackPaintRect))
- scrollMask |= TrackBGPart;
- bool thumbPresent = hasThumb(scrollbar);
- if (thumbPresent) {
- IntRect track = trackRect(scrollbar);
- splitTrack(scrollbar, track, startTrackRect, thumbRect, endTrackRect);
- if (damageRect.intersects(thumbRect))
- scrollMask |= ThumbPart;
- if (damageRect.intersects(startTrackRect))
- scrollMask |= BackTrackPart;
- if (damageRect.intersects(endTrackRect))
- scrollMask |= ForwardTrackPart;
- }
-
-#if PLATFORM(WIN)
- // FIXME: This API makes the assumption that the custom scrollbar's metrics will match
- // the theme's metrics. This is not a valid assumption. The ability for a client to paint
- // custom scrollbars should be removed once scrollbars can be styled via CSS.
- if (Page* page = pageForScrollView(scrollbar->parent())) {
- if (page->settings()->shouldPaintCustomScrollbars()) {
- float proportion = static_cast<float>(scrollbar->visibleSize()) / scrollbar->totalSize();
- float value = scrollbar->currentPos() / static_cast<float>(scrollbar->maximum());
- ScrollbarControlState s = 0;
- if (scrollbar->client()->isActive())
- s |= ActiveScrollbarState;
- if (scrollbar->enabled())
- s |= EnabledScrollbarState;
- if (scrollbar->pressedPart() != NoPart)
- s |= PressedScrollbarState;
- if (page->chrome()->client()->paintCustomScrollbar(graphicsContext,
- scrollbar->frameRect(),
- scrollbar->controlSize(),
- s,
- scrollbar->pressedPart(),
- scrollbar->orientation() == VerticalScrollbar,
- value,
- proportion,
- scrollMask))
- return true;
- }
- }
-#endif
-
- // Paint the scrollbar background (only used by custom CSS scrollbars).
- paintScrollbarBackground(graphicsContext, scrollbar);
-
- // Paint the back and forward buttons.
- if (scrollMask & BackButtonStartPart)
- paintButton(graphicsContext, scrollbar, backButtonStartPaintRect, BackButtonStartPart);
- if (scrollMask & BackButtonEndPart)
- paintButton(graphicsContext, scrollbar, backButtonEndPaintRect, BackButtonEndPart);
- if (scrollMask & ForwardButtonStartPart)
- paintButton(graphicsContext, scrollbar, forwardButtonStartPaintRect, ForwardButtonStartPart);
- if (scrollMask & ForwardButtonEndPart)
- paintButton(graphicsContext, scrollbar, forwardButtonEndPaintRect, ForwardButtonEndPart);
-
- if (scrollMask & TrackBGPart)
- paintTrackBackground(graphicsContext, scrollbar, trackPaintRect);
-
- if ((scrollMask & ForwardTrackPart) || (scrollMask & BackTrackPart)) {
- // Paint the track pieces above and below the thumb.
- if (scrollMask & BackTrackPart)
- paintTrackPiece(graphicsContext, scrollbar, startTrackRect, BackTrackPart);
- if (scrollMask & ForwardTrackPart)
- paintTrackPiece(graphicsContext, scrollbar, endTrackRect, ForwardTrackPart);
- }
-
- // Paint the thumb.
- if (scrollMask & ThumbPart)
- paintThumb(graphicsContext, scrollbar, thumbRect);
-
- return true;
-}
-
-ScrollbarPart ScrollbarThemeComposite::hitTest(Scrollbar* scrollbar, const PlatformMouseEvent& evt)
-{
- ScrollbarPart result = NoPart;
- if (!scrollbar->enabled())
- return result;
-
- IntPoint mousePosition = scrollbar->convertFromContainingWindow(evt.pos());
- mousePosition.move(scrollbar->x(), scrollbar->y());
-
- if (!scrollbar->frameRect().contains(mousePosition))
- return NoPart;
-
- result = ScrollbarBGPart;
-
- IntRect track = trackRect(scrollbar);
- if (track.contains(mousePosition)) {
- IntRect beforeThumbRect;
- IntRect thumbRect;
- IntRect afterThumbRect;
- splitTrack(scrollbar, track, beforeThumbRect, thumbRect, afterThumbRect);
- if (thumbRect.contains(mousePosition))
- result = ThumbPart;
- else if (beforeThumbRect.contains(mousePosition))
- result = BackTrackPart;
- else if (afterThumbRect.contains(mousePosition))
- result = ForwardTrackPart;
- else
- result = TrackBGPart;
- } else if (backButtonRect(scrollbar, BackButtonStartPart).contains(mousePosition))
- result = BackButtonStartPart;
- else if (backButtonRect(scrollbar, BackButtonEndPart).contains(mousePosition))
- result = BackButtonEndPart;
- else if (forwardButtonRect(scrollbar, ForwardButtonStartPart).contains(mousePosition))
- result = ForwardButtonStartPart;
- else if (forwardButtonRect(scrollbar, ForwardButtonEndPart).contains(mousePosition))
- result = ForwardButtonEndPart;
- return result;
-}
-
-void ScrollbarThemeComposite::invalidatePart(Scrollbar* scrollbar, ScrollbarPart part)
-{
- if (part == NoPart)
- return;
-
- IntRect result;
- switch (part) {
- case BackButtonStartPart:
- result = backButtonRect(scrollbar, BackButtonStartPart, true);
- break;
- case BackButtonEndPart:
- result = backButtonRect(scrollbar, BackButtonEndPart, true);
- break;
- case ForwardButtonStartPart:
- result = forwardButtonRect(scrollbar, ForwardButtonStartPart, true);
- break;
- case ForwardButtonEndPart:
- result = forwardButtonRect(scrollbar, ForwardButtonEndPart, true);
- break;
- case TrackBGPart:
- result = trackRect(scrollbar, true);
- break;
- case ScrollbarBGPart:
- result = scrollbar->frameRect();
- break;
- default: {
- IntRect beforeThumbRect, thumbRect, afterThumbRect;
- splitTrack(scrollbar, trackRect(scrollbar), beforeThumbRect, thumbRect, afterThumbRect);
- if (part == BackTrackPart)
- result = beforeThumbRect;
- else if (part == ForwardTrackPart)
- result = afterThumbRect;
- else
- result = thumbRect;
- }
- }
- result.move(-scrollbar->x(), -scrollbar->y());
- scrollbar->invalidateRect(result);
-}
-
-void ScrollbarThemeComposite::splitTrack(Scrollbar* scrollbar, const IntRect& unconstrainedTrackRect, IntRect& beforeThumbRect, IntRect& thumbRect, IntRect& afterThumbRect)
-{
- // This function won't even get called unless we're big enough to have some combination of these three rects where at least
- // one of them is non-empty.
- IntRect trackRect = constrainTrackRectToTrackPieces(scrollbar, unconstrainedTrackRect);
- int thickness = scrollbar->orientation() == HorizontalScrollbar ? scrollbar->height() : scrollbar->width();
- int thumbPos = thumbPosition(scrollbar);
- if (scrollbar->orientation() == HorizontalScrollbar) {
- thumbRect = IntRect(trackRect.x() + thumbPos, trackRect.y() + (trackRect.height() - thickness) / 2, thumbLength(scrollbar), thickness);
- beforeThumbRect = IntRect(trackRect.x(), trackRect.y(), thumbPos + thumbRect.width() / 2, trackRect.height());
- afterThumbRect = IntRect(trackRect.x() + beforeThumbRect.width(), trackRect.y(), trackRect.right() - beforeThumbRect.right(), trackRect.height());
- } else {
- thumbRect = IntRect(trackRect.x() + (trackRect.width() - thickness) / 2, trackRect.y() + thumbPos, thickness, thumbLength(scrollbar));
- beforeThumbRect = IntRect(trackRect.x(), trackRect.y(), trackRect.width(), thumbPos + thumbRect.height() / 2);
- afterThumbRect = IntRect(trackRect.x(), trackRect.y() + beforeThumbRect.height(), trackRect.width(), trackRect.bottom() - beforeThumbRect.bottom());
- }
-}
-
-int ScrollbarThemeComposite::thumbPosition(Scrollbar* scrollbar)
-{
- if (scrollbar->enabled())
- return scrollbar->currentPos() * (trackLength(scrollbar) - thumbLength(scrollbar)) / scrollbar->maximum();
- return 0;
-}
-
-int ScrollbarThemeComposite::thumbLength(Scrollbar* scrollbar)
-{
- if (!scrollbar->enabled())
- return 0;
-
- float proportion = (float)scrollbar->visibleSize() / scrollbar->totalSize();
- int trackLen = trackLength(scrollbar);
- int length = proportion * trackLen;
- length = max(length, minimumThumbLength(scrollbar));
- if (length > trackLen)
- length = 0; // Once the thumb is below the track length, it just goes away (to make more room for the track).
- return length;
-}
-
-int ScrollbarThemeComposite::minimumThumbLength(Scrollbar* scrollbar)
-{
- return scrollbarThickness(scrollbar->controlSize());
-}
-
-int ScrollbarThemeComposite::trackPosition(Scrollbar* scrollbar)
-{
- IntRect constrainedTrackRect = constrainTrackRectToTrackPieces(scrollbar, trackRect(scrollbar));
- return (scrollbar->orientation() == HorizontalScrollbar) ? constrainedTrackRect.x() - scrollbar->x() : constrainedTrackRect.y() - scrollbar->y();
-}
-
-int ScrollbarThemeComposite::trackLength(Scrollbar* scrollbar)
-{
- IntRect constrainedTrackRect = constrainTrackRectToTrackPieces(scrollbar, trackRect(scrollbar));
- return (scrollbar->orientation() == HorizontalScrollbar) ? constrainedTrackRect.width() : constrainedTrackRect.height();
-}
-
-void ScrollbarThemeComposite::paintScrollCorner(ScrollView* view, GraphicsContext* context, const IntRect& cornerRect)
-{
- FrameView* frameView = static_cast<FrameView*>(view);
- Page* page = frameView->frame() ? frameView->frame()->page() : 0;
- if (page && page->settings()->shouldPaintCustomScrollbars()) {
- if (!page->chrome()->client()->paintCustomScrollCorner(context, cornerRect))
- context->fillRect(cornerRect, Color::white);
- }
-}
-
-}
diff --git a/WebCore/platform/ScrollbarThemeComposite.h b/WebCore/platform/ScrollbarThemeComposite.h
deleted file mode 100644
index 7748251..0000000
--- a/WebCore/platform/ScrollbarThemeComposite.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ScrollbarThemeComposite_h
-#define ScrollbarThemeComposite_h
-
-#include "ScrollbarTheme.h"
-
-namespace WebCore {
-
-class ScrollbarThemeComposite : public ScrollbarTheme {
-public:
- virtual bool paint(Scrollbar*, GraphicsContext* context, const IntRect& damageRect);
-
- virtual ScrollbarPart hitTest(Scrollbar*, const PlatformMouseEvent&);
-
- virtual void invalidatePart(Scrollbar*, ScrollbarPart);
-
- virtual int thumbPosition(Scrollbar*);
- virtual int thumbLength(Scrollbar*);
- virtual int trackPosition(Scrollbar*);
- virtual int trackLength(Scrollbar*);
-
- virtual void paintScrollCorner(ScrollView*, GraphicsContext*, const IntRect& cornerRect);
-
-protected:
- virtual bool hasButtons(Scrollbar*) = 0;
- virtual bool hasThumb(Scrollbar*) = 0;
-
- virtual IntRect backButtonRect(Scrollbar*, ScrollbarPart, bool painting = false) = 0;
- virtual IntRect forwardButtonRect(Scrollbar*, ScrollbarPart, bool painting = false) = 0;
- virtual IntRect trackRect(Scrollbar*, bool painting = false) = 0;
-
- virtual void splitTrack(Scrollbar*, const IntRect& track, IntRect& startTrack, IntRect& thumb, IntRect& endTrack);
-
- virtual int minimumThumbLength(Scrollbar*);
-
- virtual void paintScrollbarBackground(GraphicsContext*, Scrollbar*) {}
- virtual void paintTrackBackground(GraphicsContext*, Scrollbar*, const IntRect&) {}
- virtual void paintTrackPiece(GraphicsContext*, Scrollbar*, const IntRect&, ScrollbarPart) {}
- virtual void paintButton(GraphicsContext*, Scrollbar*, const IntRect&, ScrollbarPart) {}
- virtual void paintThumb(GraphicsContext*, Scrollbar*, const IntRect&) {}
-
- virtual IntRect constrainTrackRectToTrackPieces(Scrollbar*, const IntRect& rect) { return rect; }
-};
-
-}
-#endif
diff --git a/WebCore/platform/SearchPopupMenu.h b/WebCore/platform/SearchPopupMenu.h
deleted file mode 100644
index 4285cdf..0000000
--- a/WebCore/platform/SearchPopupMenu.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef SearchPopupMenu_h
-#define SearchPopupMenu_h
-
-#include "PopupMenu.h"
-#include <wtf/Vector.h>
-
-namespace WebCore {
-
-class AtomicString;
-
-class SearchPopupMenu : public PopupMenu {
-public:
- static PassRefPtr<SearchPopupMenu> create(PopupMenuClient* client) { return adoptRef(new SearchPopupMenu(client)); }
-
- void saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems);
- void loadRecentSearches(const AtomicString& name, Vector<String>& searchItems);
-
- bool enabled();
-
-private:
- SearchPopupMenu(PopupMenuClient*);
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/SharedBuffer.cpp b/WebCore/platform/SharedBuffer.cpp
deleted file mode 100644
index e1e812b..0000000
--- a/WebCore/platform/SharedBuffer.cpp
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "SharedBuffer.h"
-
-namespace WebCore {
-
-SharedBuffer::SharedBuffer()
-{
-}
-
-SharedBuffer::SharedBuffer(const char* data, int size)
-{
- m_buffer.append(data, size);
-}
-
-SharedBuffer::SharedBuffer(const unsigned char* data, int size)
-{
- m_buffer.append(data, size);
-}
-
-PassRefPtr<SharedBuffer> SharedBuffer::adoptVector(Vector<char>& vector)
-{
- RefPtr<SharedBuffer> buffer = create();
- buffer->m_buffer.swap(vector);
- return buffer.release();
-}
-
-unsigned SharedBuffer::size() const
-{
- if (hasPlatformData())
- return platformDataSize();
-
- return m_buffer.size();
-}
-
-const char* SharedBuffer::data() const
-{
- if (hasPlatformData())
- return platformData();
-
- return m_buffer.data();
-}
-
-void SharedBuffer::append(const char* data, int len)
-{
- maybeTransferPlatformData();
-
- m_buffer.append(data, len);
-}
-
-void SharedBuffer::clear()
-{
- clearPlatformData();
-
- m_buffer.clear();
-}
-
-PassRefPtr<SharedBuffer> SharedBuffer::copy() const
-{
- return SharedBuffer::create(data(), size());
-}
-
-
-#if !PLATFORM(CF)
-
-inline void SharedBuffer::clearPlatformData()
-{
-}
-
-inline void SharedBuffer::maybeTransferPlatformData()
-{
-}
-
-inline bool SharedBuffer::hasPlatformData() const
-{
- return false;
-}
-
-inline const char* SharedBuffer::platformData() const
-{
- ASSERT_NOT_REACHED();
-
- return 0;
-}
-
-inline unsigned SharedBuffer::platformDataSize() const
-{
- ASSERT_NOT_REACHED();
-
- return 0;
-}
-
-#endif
-
-}
diff --git a/WebCore/platform/SharedBuffer.h b/WebCore/platform/SharedBuffer.h
deleted file mode 100644
index eb5c167..0000000
--- a/WebCore/platform/SharedBuffer.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef SharedBuffer_h
-#define SharedBuffer_h
-
-#include "PlatformString.h"
-#include <wtf/RefCounted.h>
-#include <wtf/Forward.h>
-#include <wtf/Vector.h>
-
-#if PLATFORM(CF)
-#include <wtf/RetainPtr.h>
-#endif
-
-#if PLATFORM(MAC)
-#ifdef __OBJC__
-@class NSData;
-#else
-class NSData;
-#endif
-
-#endif
-
-namespace WebCore {
-
-class SharedBuffer : public RefCounted<SharedBuffer> {
-public:
- static PassRefPtr<SharedBuffer> create() { return adoptRef(new SharedBuffer); }
- static PassRefPtr<SharedBuffer> create(const char* c, int i) { return adoptRef(new SharedBuffer(c, i)); }
- static PassRefPtr<SharedBuffer> create(const unsigned char* c, int i) { return adoptRef(new SharedBuffer(c, i)); }
-
- static PassRefPtr<SharedBuffer> createWithContentsOfFile(const String& filePath);
-
- static PassRefPtr<SharedBuffer> adoptVector(Vector<char>& vector);
-
-#if PLATFORM(MAC)
- NSData *createNSData();
- static PassRefPtr<SharedBuffer> wrapNSData(NSData *data);
-#endif
-#if PLATFORM(CF)
- CFDataRef createCFData();
-#endif
-
- const char* data() const;
- unsigned size() const;
- const Vector<char> &buffer() { return m_buffer; }
-
- bool isEmpty() const { return size() == 0; }
-
- void append(const char*, int);
- void clear();
- const char* platformData() const;
- unsigned platformDataSize() const;
-
- PassRefPtr<SharedBuffer> copy() const;
-
-private:
- SharedBuffer();
- SharedBuffer(const char*, int);
- SharedBuffer(const unsigned char*, int);
-
- void clearPlatformData();
- void maybeTransferPlatformData();
- bool hasPlatformData() const;
-
- Vector<char> m_buffer;
-#if PLATFORM(CF)
- SharedBuffer(CFDataRef);
- RetainPtr<CFDataRef> m_cfData;
-#endif
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/SharedTimer.h b/WebCore/platform/SharedTimer.h
deleted file mode 100644
index 4cc90a2..0000000
--- a/WebCore/platform/SharedTimer.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef SharedTimer_h
-#define SharedTimer_h
-
-namespace WebCore {
-
- // Single timer, shared to implement all the timers managed by the Timer class.
- // Not intended to be used directly; use the Timer class instead.
-
- void setSharedTimerFiredFunction(void (*)());
-
- // The fire time is relative to the classic POSIX epoch of January 1, 1970,
- // as the result of currentTime() is.
-
- void setSharedTimerFireTime(double fireTime);
- void stopSharedTimer();
-
-}
-
-#endif
diff --git a/WebCore/platform/Sound.h b/WebCore/platform/Sound.h
deleted file mode 100644
index 534129b..0000000
--- a/WebCore/platform/Sound.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef Sound_h
-#define Sound_h
-
-namespace WebCore {
-
- void systemBeep();
-
-} // namespace WebCore
-
-#endif // Sound_h
diff --git a/WebCore/platform/StaticConstructors.h b/WebCore/platform/StaticConstructors.h
deleted file mode 100644
index 26b44de..0000000
--- a/WebCore/platform/StaticConstructors.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * This file is part of the DOM implementation for KDE.
- *
- * Copyright (C) 2006 Apple Computer, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef StaticConstructors_h
-#define StaticConstructors_h
-
-// For WebCore we need to avoid having static constructors. We achieve this
-// with two separate methods for GCC and MSVC. Both methods prevent the static
-// initializers from being registered and called on program startup. On GCC, we
-// declare the global objects with a different type that can be POD default
-// initialized by the linker/loader. On MSVC we use a special compiler feature
-// to have the CRT ignore our static initializers. The constructors will never
-// be called and the objects will be left uninitialized.
-//
-// With both of these approaches, we must define and explicitly call an init
-// routine that uses placement new to create the objects and overwrite the
-// uninitialized placeholders.
-//
-// This is not completely portable, but is what we have for now without
-// changing how a lot of code accesses these global objects.
-
-#ifdef SKIP_STATIC_CONSTRUCTORS_ON_MSVC
-// - Assume that all includes of this header want ALL of their static
-// initializers ignored. This is currently the case. This means that if
-// a .cc includes this header (or it somehow gets included), all static
-// initializers after the include will not be executed.
-// - We do this with a pragma, so that all of the static initializer pointers
-// go into our own section, and the CRT won't call them. Eventually it would
-// be nice if the section was discarded, because we don't want the pointers.
-// See: http://msdn.microsoft.com/en-us/library/7977wcck(VS.80).aspx
-#pragma warning(disable:4075)
-#pragma init_seg(".unwantedstaticinits")
-#endif
-
-#ifndef SKIP_STATIC_CONSTRUCTORS_ON_GCC
- // Define an global in the normal way.
-#if COMPILER(MSVC7)
-#define DEFINE_GLOBAL(type, name) \
- const type name;
-#else
-#define DEFINE_GLOBAL(type, name, ...) \
- const type name;
-#endif
-
-#else
-// Define an correctly-sized array of pointers to avoid static initialization.
-// Use an array of pointers instead of an array of char in case there is some alignment issue.
-#if COMPILER(MSVC7)
-#define DEFINE_GLOBAL(type, name) \
- void * name[(sizeof(type) + sizeof(void *) - 1) / sizeof(void *)];
-#else
-#define DEFINE_GLOBAL(type, name, ...) \
- void * name[(sizeof(type) + sizeof(void *) - 1) / sizeof(void *)];
-#endif
-#endif
-
-#endif // StaticConstructors_h
diff --git a/WebCore/platform/SystemTime.h b/WebCore/platform/SystemTime.h
deleted file mode 100644
index 327b2c7..0000000
--- a/WebCore/platform/SystemTime.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef SystemTime_h
-#define SystemTime_h
-
-namespace WebCore {
-
- // Return the current system time in seconds, using the classic POSIX epoch of January 1, 1970.
- // Like time(0) from <time.h>, except with a wider range of values and higher precision.
- double currentTime();
-
- // Return the number of seconds since a user event has been generated
- float userIdleTime();
-
-#if PLATFORM(ANDROID)
- uint32_t get_thread_msec();
-#endif
-}
-
-#endif
diff --git a/WebCore/platform/Theme.cpp b/WebCore/platform/Theme.cpp
deleted file mode 100644
index 185c7ca..0000000
--- a/WebCore/platform/Theme.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Theme.h"
-
-namespace WebCore {
-
-LengthBox Theme::controlBorder(ControlPart part, const Font&, const LengthBox& zoomedBox, float zoomFactor) const
-{
- switch (part) {
- case PushButtonPart:
- case MenulistPart:
- case SearchFieldPart:
- case CheckboxPart:
- case RadioPart:
- return LengthBox(0);
- default:
- return zoomedBox;
- }
-}
-
-LengthBox Theme::controlPadding(ControlPart part, const Font&, const LengthBox& zoomedBox, float zoomFactor) const
-{
- switch (part) {
- case MenulistPart:
- case MenulistButtonPart:
- case CheckboxPart:
- case RadioPart:
- return LengthBox(0);
- default:
- return zoomedBox;
- }
-}
-
-}
diff --git a/WebCore/platform/Theme.h b/WebCore/platform/Theme.h
deleted file mode 100644
index 85c3f24..0000000
--- a/WebCore/platform/Theme.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef Theme_h
-#define Theme_h
-
-#include "Color.h"
-#include "Font.h"
-#include "IntRect.h"
-#include "LengthBox.h"
-#include "LengthSize.h"
-#include "PlatformString.h"
-#include "ThemeTypes.h"
-
-namespace WebCore {
-
-class GraphicsContext;
-class ScrollView;
-
-// Unlike other platform classes, Theme does extensively use virtual functions. This design allows a platform to switch between multiple themes at runtime.
-class Theme {
-public:
- Theme() { }
- virtual ~Theme() { }
-
- // A method to obtain the baseline position adjustment for a "leaf" control. This will only be used if a baseline
- // position cannot be determined by examining child content. Checkboxes and radio buttons are examples of
- // controls that need to do this. The adjustment is an offset that adds to the baseline, e.g., marginTop() + height() + |offset|.
- // The offset is not zoomed.
- virtual int baselinePositionAdjustment(ControlPart) const { return 0; }
-
- // A method asking if the control changes its appearance when the window is inactive.
- virtual bool controlHasInactiveAppearance(ControlPart) const { return false; }
-
- // General methods for whether or not any of the controls in the theme change appearance when the window is inactive or
- // when hovered over.
- virtual bool controlsCanHaveInactiveAppearance() const { return false; }
- virtual bool controlsCanHaveHoveredAppearance() const { return false; }
-
- // Used by RenderTheme::isControlStyled to figure out if the native look and feel should be turned off.
- virtual bool controlDrawsBorder(ControlPart) const { return true; }
- virtual bool controlDrawsBackground(ControlPart) const { return true; }
- virtual bool controlDrawsFocusOutline(ControlPart) const { return true; }
-
- // Methods for obtaining platform-specific colors.
- virtual Color selectionColor(ControlPart, ControlState, SelectionPart) const { return Color(); }
- virtual Color textSearchHighlightColor() const { return Color(); }
-
- // CSS system colors and fonts
- virtual Color systemColor(ThemeColor) const { return Color(); }
- virtual Font systemFont(ThemeFont, FontDescription&) const { return Font(); }
-
- // How fast the caret blinks in text fields.
- virtual double caretBlinkFrequency() const { return 0.5; }
-
- // Notification when the theme has changed
- virtual void themeChanged() { }
-
- // Methods used to adjust the RenderStyles of controls.
-
- // The font description result should have a zoomed font size.
- virtual FontDescription controlFont(ControlPart, const Font& font, float zoomFactor) const { return font.fontDescription(); }
-
- // The size here is in zoomed coordinates already. If a new size is returned, it also needs to be in zoomed coordinates.
- virtual LengthSize controlSize(ControlPart, const Font&, const LengthSize& zoomedSize, float zoomFactor) const { return zoomedSize; }
-
- // Returns the minimum size for a control in zoomed coordinates.
- virtual LengthSize minimumControlSize(ControlPart, const Font&, float zoomFactor) const { return LengthSize(Length(0, Fixed), Length(0, Fixed)); }
-
- // Allows the theme to modify the existing padding/border.
- virtual LengthBox controlPadding(ControlPart, const Font&, const LengthBox& zoomedBox, float zoomFactor) const;
- virtual LengthBox controlBorder(ControlPart, const Font&, const LengthBox& zoomedBox, float zoomFactor) const;
-
- // Whether or not whitespace: pre should be forced on always.
- virtual bool controlRequiresPreWhiteSpace(ControlPart) const { return false; }
-
- // Method for painting a control. The rect is in zoomed coordinates.
- virtual void paint(ControlPart, ControlStates, GraphicsContext*, const IntRect& zoomedRect, float zoomFactor, ScrollView*) const { };
-
- // Some controls may spill out of their containers (e.g., the check on an OS X checkbox). When these controls repaint,
- // the theme needs to communicate this inflated rect to the engine so that it can invalidate the whole control.
- // The rect passed in is in zoomed coordinates, so the inflation should take that into account and make sure the inflation
- // amount is also scaled by the zoomFactor.
- virtual void inflateControlPaintRect(ControlPart, ControlStates, IntRect& zoomedRect, float zoomFactor) const { }
-
- // This method is called once, from RenderTheme::adjustDefaultStyleSheet(), to let each platform adjust
- // the default CSS rules in html4.css.
- static String defaultStyleSheet();
-
-private:
- mutable Color m_activeSelectionColor;
- mutable Color m_inactiveSelectionColor;
-};
-
-// Function to obtain the theme. This is implemented in the platform-specific subclasses.
-Theme* platformTheme();
-
-} // namespace WebCore
-
-#endif // Theme_h
diff --git a/WebCore/platform/ThemeTypes.h b/WebCore/platform/ThemeTypes.h
deleted file mode 100644
index 8d73ea3..0000000
--- a/WebCore/platform/ThemeTypes.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ThemeTypes_h
-#define ThemeTypes_h
-
-namespace WebCore {
-
-enum ControlState {
- HoverState = 1,
- PressedState = 1 << 1,
- FocusState = 1 << 2,
- EnabledState = 1 << 3,
- CheckedState = 1 << 4,
- ReadOnlyState = 1 << 5,
- DefaultState = 1 << 6,
- WindowInactiveState = 1 << 7,
- IndeterminateState = 1 << 8,
- AllStates = 0xffffffff
-};
-
-typedef unsigned ControlStates;
-
-enum ControlPart {
- NoControlPart, CheckboxPart, RadioPart, PushButtonPart, SquareButtonPart, ButtonPart,
- ButtonBevelPart, DefaultButtonPart, ListboxPart, ListItemPart,
- MediaFullscreenButtonPart, MediaMuteButtonPart, MediaPlayButtonPart,
- MediaSeekBackButtonPart, MediaSeekForwardButtonPart, MediaSliderPart, MediaSliderThumbPart,
- MenulistPart, MenulistButtonPart, MenulistTextPart, MenulistTextFieldPart,
- SliderHorizontalPart, SliderVerticalPart, SliderThumbHorizontalPart,
- SliderThumbVerticalPart, CaretPart, SearchFieldPart, SearchFieldDecorationPart,
- SearchFieldResultsDecorationPart, SearchFieldResultsButtonPart,
- SearchFieldCancelButtonPart, TextFieldPart, TextAreaPart, CapsLockIndicatorPart
-};
-
-enum SelectionPart {
- SelectionBackground, SelectionForeground
-};
-
-enum ThemeFont {
- CaptionFont, IconFont, MenuFont, MessageBoxFont, SmallCaptionFont, StatusBarFont, MiniControlFont, SmallControlFont, ControlFont
-};
-
-enum ThemeColor {
- ActiveBorderColor, ActiveCaptionColor, AppWorkspaceColor, BackgroundColor, ButtonFaceColor, ButtonHighlightColor, ButtonShadowColor,
- ButtonTextColor, CaptionTextColor, GrayTextColor, HighlightColor, HighlightTextColor, InactiveBorderColor, InactiveCaptionColor,
- InactiveCaptionTextColor, InfoBackgroundColor, InfoTextColor, MatchColor, MenuTextColor, ScrollbarColor, ThreeDDarkDhasowColor,
- ThreeDFaceColor, ThreeDHighlightColor, ThreeDLightShadowColor, ThreeDShadowCLor, WindowColor, WindowFrameColor, WindowTextColor,
- FocusRingColor
-};
-
-}
-#endif
diff --git a/WebCore/platform/ThreadCheck.h b/WebCore/platform/ThreadCheck.h
deleted file mode 100644
index d1ff4a4..0000000
--- a/WebCore/platform/ThreadCheck.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ThreadCheck_h
-#define ThreadCheck_h
-
-namespace WebCore {
- enum ThreadViolationBehavior {
- NoThreadCheck,
- LogOnFirstThreadViolation,
- LogOnThreadViolation,
- RaiseExceptionOnThreadViolation
- };
- void setDefaultThreadViolationBehavior(ThreadViolationBehavior);
- void reportThreadViolation(const char* function);
-}
-
-extern "C" void WebCoreReportThreadViolation(const char* function);
-
-#define WebCoreThreadViolationCheck() ::WebCore::reportThreadViolation(WTF_PRETTY_FUNCTION)
-
-#endif
diff --git a/WebCore/platform/Timer.cpp b/WebCore/platform/Timer.cpp
deleted file mode 100644
index 94e2af8..0000000
--- a/WebCore/platform/Timer.cpp
+++ /dev/null
@@ -1,396 +0,0 @@
-/*
- * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Timer.h"
-
-#include "SharedTimer.h"
-#include "SystemTime.h"
-#include <limits.h>
-#include <limits>
-#include <math.h>
-#include <wtf/HashSet.h>
-#include <wtf/Vector.h>
-
-using namespace std;
-
-namespace WebCore {
-
-// Timers are stored in a heap data structure, used to implement a priority queue.
-// This allows us to efficiently determine which timer needs to fire the soonest.
-// Then we set a single shared system timer to fire at that time.
-//
-// When a timer's "next fire time" changes, we need to move it around in the priority queue.
-
-// ----------------
-
-static bool deferringTimers;
-static Vector<TimerBase*>* timerHeap;
-static HashSet<const TimerBase*>* timersReadyToFire;
-
-// ----------------
-
-// Class to represent elements in the heap when calling the standard library heap algorithms.
-// Maintains the m_heapIndex value in the timers themselves, which allows us to do efficient
-// modification of the heap.
-class TimerHeapElement {
-public:
- explicit TimerHeapElement(int i) : m_index(i), m_timer((*timerHeap)[m_index]) { checkConsistency(); }
-
- TimerHeapElement(const TimerHeapElement&);
- TimerHeapElement& operator=(const TimerHeapElement&);
-
- TimerBase* timer() const { return m_timer; }
-
- void checkConsistency() const {
- ASSERT(m_index >= 0);
- ASSERT(m_index < (timerHeap ? static_cast<int>(timerHeap->size()) : 0));
- }
-
-private:
- TimerHeapElement();
-
- int m_index;
- TimerBase* m_timer;
-};
-
-inline TimerHeapElement::TimerHeapElement(const TimerHeapElement& o)
- : m_index(-1), m_timer(o.timer())
-{
-}
-
-inline TimerHeapElement& TimerHeapElement::operator=(const TimerHeapElement& o)
-{
- TimerBase* t = o.timer();
- m_timer = t;
- if (m_index != -1) {
- checkConsistency();
- (*timerHeap)[m_index] = t;
- t->m_heapIndex = m_index;
- }
- return *this;
-}
-
-inline bool operator<(const TimerHeapElement& a, const TimerHeapElement& b)
-{
- // The comparisons below are "backwards" because the heap puts the largest
- // element first and we want the lowest time to be the first one in the heap.
- double aFireTime = a.timer()->m_nextFireTime;
- double bFireTime = b.timer()->m_nextFireTime;
- if (bFireTime != aFireTime)
- return bFireTime < aFireTime;
-
- // We need to look at the difference of the insertion orders instead of comparing the two
- // outright in case of overflow.
- unsigned difference = a.timer()->m_heapInsertionOrder - b.timer()->m_heapInsertionOrder;
- return difference < UINT_MAX / 2;
-}
-
-// ----------------
-
-// Class to represent iterators in the heap when calling the standard library heap algorithms.
-// Returns TimerHeapElement for elements in the heap rather than the TimerBase pointers themselves.
-class TimerHeapIterator : public iterator<random_access_iterator_tag, TimerHeapElement, int> {
-public:
- TimerHeapIterator() : m_index(-1) { }
- TimerHeapIterator(int i) : m_index(i) { checkConsistency(); }
-
- TimerHeapIterator& operator++() { checkConsistency(); ++m_index; checkConsistency(); return *this; }
- TimerHeapIterator operator++(int) { checkConsistency(); checkConsistency(1); return m_index++; }
-
- TimerHeapIterator& operator--() { checkConsistency(); --m_index; checkConsistency(); return *this; }
- TimerHeapIterator operator--(int) { checkConsistency(); checkConsistency(-1); return m_index--; }
-
- TimerHeapIterator& operator+=(int i) { checkConsistency(); m_index += i; checkConsistency(); return *this; }
- TimerHeapIterator& operator-=(int i) { checkConsistency(); m_index -= i; checkConsistency(); return *this; }
-
- TimerHeapElement operator*() const { return TimerHeapElement(m_index); }
- TimerHeapElement operator[](int i) const { return TimerHeapElement(m_index + i); }
-
- int index() const { return m_index; }
-
- void checkConsistency(int offset = 0) const {
- ASSERT(m_index + offset >= 0);
- ASSERT(m_index + offset <= (timerHeap ? static_cast<int>(timerHeap->size()) : 0));
- }
-
-private:
- int m_index;
-};
-
-inline bool operator==(TimerHeapIterator a, TimerHeapIterator b) { return a.index() == b.index(); }
-inline bool operator!=(TimerHeapIterator a, TimerHeapIterator b) { return a.index() != b.index(); }
-inline bool operator<(TimerHeapIterator a, TimerHeapIterator b) { return a.index() < b.index(); }
-
-inline TimerHeapIterator operator+(TimerHeapIterator a, int b) { return a.index() + b; }
-inline TimerHeapIterator operator+(int a, TimerHeapIterator b) { return a + b.index(); }
-
-inline TimerHeapIterator operator-(TimerHeapIterator a, int b) { return a.index() - b; }
-inline int operator-(TimerHeapIterator a, TimerHeapIterator b) { return a.index() - b.index(); }
-
-// ----------------
-
-void updateSharedTimer()
-{
- if (timersReadyToFire || deferringTimers || !timerHeap || timerHeap->isEmpty())
- stopSharedTimer();
- else
- setSharedTimerFireTime(timerHeap->first()->m_nextFireTime);
-}
-
-// ----------------
-
-TimerBase::TimerBase()
- : m_nextFireTime(0), m_repeatInterval(0), m_heapIndex(-1)
-{
- // We only need to do this once, but probably not worth trying to optimize it.
- setSharedTimerFiredFunction(sharedTimerFired);
-}
-
-TimerBase::~TimerBase()
-{
- stop();
-
- ASSERT(!inHeap());
-}
-
-void TimerBase::start(double nextFireInterval, double repeatInterval)
-{
- m_repeatInterval = repeatInterval;
- setNextFireTime(currentTime() + nextFireInterval);
-}
-
-void TimerBase::stop()
-{
- m_repeatInterval = 0;
- setNextFireTime(0);
-
- ASSERT(m_nextFireTime == 0);
- ASSERT(m_repeatInterval == 0);
- ASSERT(!inHeap());
-}
-
-bool TimerBase::isActive() const
-{
- return m_nextFireTime || (timersReadyToFire && timersReadyToFire->contains(this));
-}
-
-double TimerBase::nextFireInterval() const
-{
- ASSERT(isActive());
- double current = currentTime();
- if (m_nextFireTime < current)
- return 0;
- return m_nextFireTime - current;
-}
-
-inline void TimerBase::checkHeapIndex() const
-{
- ASSERT(timerHeap);
- ASSERT(!timerHeap->isEmpty());
- ASSERT(m_heapIndex >= 0);
- ASSERT(m_heapIndex < static_cast<int>(timerHeap->size()));
- ASSERT((*timerHeap)[m_heapIndex] == this);
-}
-
-inline void TimerBase::checkConsistency() const
-{
- // Timers should be in the heap if and only if they have a non-zero next fire time.
- ASSERT(inHeap() == (m_nextFireTime != 0));
- if (inHeap())
- checkHeapIndex();
-}
-
-void TimerBase::heapDecreaseKey()
-{
- ASSERT(m_nextFireTime != 0);
- checkHeapIndex();
- push_heap(TimerHeapIterator(0), TimerHeapIterator(m_heapIndex + 1));
- checkHeapIndex();
-}
-
-inline void TimerBase::heapDelete()
-{
- ASSERT(m_nextFireTime == 0);
- heapPop();
- timerHeap->removeLast();
- m_heapIndex = -1;
-}
-
-inline void TimerBase::heapDeleteMin()
-{
- ASSERT(m_nextFireTime == 0);
- heapPopMin();
- timerHeap->removeLast();
- m_heapIndex = -1;
-}
-
-inline void TimerBase::heapIncreaseKey()
-{
- ASSERT(m_nextFireTime != 0);
- heapPop();
- heapDecreaseKey();
-}
-
-inline void TimerBase::heapInsert()
-{
- ASSERT(!inHeap());
- if (!timerHeap)
- timerHeap = new Vector<TimerBase*>;
- timerHeap->append(this);
- m_heapIndex = timerHeap->size() - 1;
- heapDecreaseKey();
-}
-
-inline void TimerBase::heapPop()
-{
- // Temporarily force this timer to have the minimum key so we can pop it.
- double fireTime = m_nextFireTime;
- m_nextFireTime = -numeric_limits<double>::infinity();
- heapDecreaseKey();
- heapPopMin();
- m_nextFireTime = fireTime;
-}
-
-void TimerBase::heapPopMin()
-{
- ASSERT(this == timerHeap->first());
- checkHeapIndex();
- pop_heap(TimerHeapIterator(0), TimerHeapIterator(timerHeap->size()));
- checkHeapIndex();
- ASSERT(this == timerHeap->last());
-}
-
-void TimerBase::setNextFireTime(double newTime)
-{
- // Keep heap valid while changing the next-fire time.
-
- if (timersReadyToFire)
- timersReadyToFire->remove(this);
-
- double oldTime = m_nextFireTime;
- if (oldTime != newTime) {
- m_nextFireTime = newTime;
- static unsigned currentHeapInsertionOrder;
- m_heapInsertionOrder = currentHeapInsertionOrder++;
-
- bool wasFirstTimerInHeap = m_heapIndex == 0;
-
- if (oldTime == 0)
- heapInsert();
- else if (newTime == 0)
- heapDelete();
- else if (newTime < oldTime)
- heapDecreaseKey();
- else
- heapIncreaseKey();
-
- bool isFirstTimerInHeap = m_heapIndex == 0;
-
- if (wasFirstTimerInHeap || isFirstTimerInHeap)
- updateSharedTimer();
- }
-
- checkConsistency();
-}
-
-void TimerBase::collectFiringTimers(double fireTime, Vector<TimerBase*>& firingTimers)
-{
- while (!timerHeap->isEmpty() && timerHeap->first()->m_nextFireTime <= fireTime) {
- TimerBase* timer = timerHeap->first();
- firingTimers.append(timer);
- timersReadyToFire->add(timer);
- timer->m_nextFireTime = 0;
- timer->heapDeleteMin();
- }
-}
-
-void TimerBase::fireTimers(double fireTime, const Vector<TimerBase*>& firingTimers)
-{
- int size = firingTimers.size();
- for (int i = 0; i != size; ++i) {
- TimerBase* timer = firingTimers[i];
-
- // If not in the set, this timer has been deleted or re-scheduled in another timer's fired function.
- // So either we don't want to fire it at all or we will fire it next time the shared timer goes off.
- // It might even have been deleted; that's OK because we won't do anything else with the pointer.
- if (!timersReadyToFire->contains(timer))
- continue;
-
- // Setting the next fire time has a side effect of removing the timer from the firing timers set.
- double interval = timer->repeatInterval();
- timer->setNextFireTime(interval ? fireTime + interval : 0);
-
- // Once the timer has been fired, it may be deleted, so do nothing else with it after this point.
- timer->fired();
-
- // Catch the case where the timer asked timers to fire in a nested event loop.
- if (!timersReadyToFire)
- break;
- }
-}
-
-void TimerBase::sharedTimerFired()
-{
- // Do a re-entrancy check.
- if (timersReadyToFire)
- return;
-
- double fireTime = currentTime();
- Vector<TimerBase*> firingTimers;
- HashSet<const TimerBase*> firingTimersSet;
-
- timersReadyToFire = &firingTimersSet;
-
- collectFiringTimers(fireTime, firingTimers);
- fireTimers(fireTime, firingTimers);
-
- timersReadyToFire = 0;
-
- updateSharedTimer();
-}
-
-void TimerBase::fireTimersInNestedEventLoop()
-{
- timersReadyToFire = 0;
- updateSharedTimer();
-}
-
-// ----------------
-
-bool isDeferringTimers()
-{
- return deferringTimers;
-}
-
-void setDeferringTimers(bool shouldDefer)
-{
- if (shouldDefer == deferringTimers)
- return;
- deferringTimers = shouldDefer;
- updateSharedTimer();
-}
-
-}
diff --git a/WebCore/platform/Timer.h b/WebCore/platform/Timer.h
deleted file mode 100644
index ba98ec5..0000000
--- a/WebCore/platform/Timer.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef Timer_h
-#define Timer_h
-
-#include <wtf/Noncopyable.h>
-#include <wtf/Vector.h>
-
-namespace WebCore {
-
-// Time intervals are all in seconds.
-
-class TimerHeapElement;
-
-class TimerBase : Noncopyable {
-public:
- TimerBase();
- virtual ~TimerBase();
-
- void start(double nextFireInterval, double repeatInterval);
-
- void startRepeating(double repeatInterval) { start(repeatInterval, repeatInterval); }
- void startOneShot(double interval) { start(interval, 0); }
-
- void stop();
- bool isActive() const;
-
- double nextFireInterval() const;
- double repeatInterval() const { return m_repeatInterval; }
-
- void augmentRepeatInterval(double delta) { setNextFireTime(m_nextFireTime + delta); m_repeatInterval += delta; }
-
- static void fireTimersInNestedEventLoop();
-
-private:
- virtual void fired() = 0;
-
- void checkConsistency() const;
- void checkHeapIndex() const;
-
- void setNextFireTime(double);
-
- bool inHeap() const { return m_heapIndex != -1; }
-
- void heapDecreaseKey();
- void heapDelete();
- void heapDeleteMin();
- void heapIncreaseKey();
- void heapInsert();
- void heapPop();
- void heapPopMin();
-
- static void collectFiringTimers(double fireTime, Vector<TimerBase*>&);
- static void fireTimers(double fireTime, const Vector<TimerBase*>&);
- static void sharedTimerFired();
-
- double m_nextFireTime; // 0 if inactive
- double m_repeatInterval; // 0 if not repeating
- int m_heapIndex; // -1 if not in heap
- unsigned m_heapInsertionOrder; // Used to keep order among equal-fire-time timers
-
- friend void updateSharedTimer();
- friend void setDeferringTimers(bool);
- friend class TimerHeapElement;
- friend bool operator<(const TimerHeapElement&, const TimerHeapElement&);
-};
-
-template <typename TimerFiredClass> class Timer : public TimerBase {
-public:
- typedef void (TimerFiredClass::*TimerFiredFunction)(Timer*);
-
- Timer(TimerFiredClass* o, TimerFiredFunction f)
- : m_object(o), m_function(f) { }
-
-private:
- virtual void fired() { (m_object->*m_function)(this); }
-
- TimerFiredClass* m_object;
- TimerFiredFunction m_function;
-};
-
-// Set to true to prevent any timers from firing.
-// When set back to false, timers that were deferred will fire.
-bool isDeferringTimers();
-void setDeferringTimers(bool);
-
-}
-
-#endif
diff --git a/WebCore/platform/TreeShared.h b/WebCore/platform/TreeShared.h
deleted file mode 100644
index aaa26aa..0000000
--- a/WebCore/platform/TreeShared.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef TreeShared_h
-#define TreeShared_h
-
-#include <wtf/Assertions.h>
-#include <wtf/Noncopyable.h>
-
-namespace WebCore {
-
-template<class T> class TreeShared : Noncopyable {
-public:
- TreeShared()
- : m_refCount(0)
- , m_parent(0)
- {
-#ifndef NDEBUG
- m_deletionHasBegun = false;
- m_inRemovedLastRefFunction = false;
-#endif
- }
- TreeShared(T* parent)
- : m_refCount(0)
- , m_parent(0)
- {
-#ifndef NDEBUG
- m_deletionHasBegun = false;
- m_inRemovedLastRefFunction = false;
-#endif
- }
- virtual ~TreeShared()
- {
- ASSERT(m_deletionHasBegun);
- }
-
- void ref()
- {
- ASSERT(!m_deletionHasBegun);
- ASSERT(!m_inRemovedLastRefFunction);
- ++m_refCount;
- }
-
- void deref()
- {
- ASSERT(!m_deletionHasBegun);
- ASSERT(!m_inRemovedLastRefFunction);
- if (--m_refCount <= 0 && !m_parent) {
-#ifndef NDEBUG
- m_inRemovedLastRefFunction = true;
-#endif
- removedLastRef();
- }
- }
-
- bool hasOneRef() const
- {
- ASSERT(!m_deletionHasBegun);
- ASSERT(!m_inRemovedLastRefFunction);
- return m_refCount == 1;
- }
-
- int refCount() const
- {
- return m_refCount;
- }
-
- void setParent(T* parent) { m_parent = parent; }
- T* parent() const { return m_parent; }
-
-#ifndef NDEBUG
- bool m_deletionHasBegun;
- bool m_inRemovedLastRefFunction;
-#endif
-
-private:
- virtual void removedLastRef()
- {
-#ifndef NDEBUG
- m_deletionHasBegun = true;
-#endif
- delete this;
- }
-
- int m_refCount;
- T* m_parent;
-};
-
-}
-
-#endif // TreeShared.h
diff --git a/WebCore/platform/Widget.cpp b/WebCore/platform/Widget.cpp
deleted file mode 100644
index 56f72cf..0000000
--- a/WebCore/platform/Widget.cpp
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Widget.h"
-
-#include "IntRect.h"
-#include "ScrollView.h"
-
-#include <wtf/Assertions.h>
-
-namespace WebCore {
-
-void Widget::init(PlatformWidget widget)
-{
- m_parent = 0;
- m_selfVisible = false;
- m_parentVisible = false;
- m_widget = widget;
- if (m_widget)
- retainPlatformWidget();
-}
-
-void Widget::setParent(ScrollView* view)
-{
- ASSERT(!view || !m_parent);
- if (!view || !view->isVisible())
- setParentVisible(false);
- m_parent = view;
- if (view && view->isVisible())
- setParentVisible(true);
-}
-
-ScrollView* Widget::root() const
-{
- const Widget* top = this;
- while (top->parent())
- top = top->parent();
- if (top->isFrameView())
- return const_cast<ScrollView*>(static_cast<const ScrollView*>(top));
- return 0;
-}
-
-void Widget::removeFromParent()
-{
- if (parent())
- parent()->removeChild(this);
-}
-
-#if !PLATFORM(MAC)
-
-IntRect Widget::convertToContainingWindow(const IntRect& rect) const
-{
- IntRect convertedRect = rect;
- convertedRect.setLocation(convertToContainingWindow(convertedRect.location()));
- return convertedRect;
-}
-
-IntPoint Widget::convertToContainingWindow(const IntPoint& point) const
-{
- IntPoint windowPoint = point;
- const Widget* childWidget = this;
- for (const ScrollView* parentScrollView = parent();
- parentScrollView;
- childWidget = parentScrollView, parentScrollView = parentScrollView->parent())
- windowPoint = parentScrollView->convertChildToSelf(childWidget, windowPoint);
- return windowPoint;
-}
-
-IntPoint Widget::convertFromContainingWindow(const IntPoint& point) const
-{
- IntPoint widgetPoint = point;
- const Widget* childWidget = this;
- for (const ScrollView* parentScrollView = parent();
- parentScrollView;
- childWidget = parentScrollView, parentScrollView = parentScrollView->parent())
- widgetPoint = parentScrollView->convertSelfToChild(childWidget, widgetPoint);
- return widgetPoint;
-}
-
-IntRect Widget::convertFromContainingWindow(const IntRect& rect) const
-{
- IntRect result = rect;
- result.setLocation(convertFromContainingWindow(rect.location()));
- return result;
-}
-#endif
-
-#if !PLATFORM(MAC) && !PLATFORM(GTK) && !PLATFORM(ANDROID)
-void Widget::releasePlatformWidget()
-{
-}
-
-void Widget::retainPlatformWidget()
-{
-}
-#endif
-
-}
diff --git a/WebCore/platform/Widget.h b/WebCore/platform/Widget.h
deleted file mode 100644
index 1b82ab4..0000000
--- a/WebCore/platform/Widget.h
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2008 Collabora Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef Widget_h
-#define Widget_h
-
-#include <wtf/Platform.h>
-
-#if PLATFORM(MAC)
-#ifdef __OBJC__
-@class NSView;
-@class NSWindow;
-#else
-class NSView;
-class NSWindow;
-#endif
-typedef NSView* PlatformWidget;
-#endif
-
-#if PLATFORM(ANDROID)
-class WebCoreViewBridge;
-typedef WebCoreViewBridge* PlatformWidget;
-#endif
-
-#if PLATFORM(WIN)
-typedef struct HWND__* HWND;
-typedef HWND PlatformWidget;
-#endif
-
-#if PLATFORM(GTK)
-typedef struct _GdkDrawable GdkDrawable;
-typedef struct _GtkWidget GtkWidget;
-typedef struct _GtkContainer GtkContainer;
-typedef GtkWidget* PlatformWidget;
-#endif
-
-#if PLATFORM(QT)
-#include <qglobal.h>
-QT_BEGIN_NAMESPACE
-class QWidget;
-QT_END_NAMESPACE
-typedef QWidget* PlatformWidget;
-#endif
-
-#if PLATFORM(WX)
-class wxWindow;
-typedef wxWindow* PlatformWidget;
-#endif
-
-#if PLATFORM(CHROMIUM)
-#include "PlatformWidget.h"
-#endif
-
-#include "IntPoint.h"
-#include "IntRect.h"
-#include "IntSize.h"
-
-namespace WebCore {
-
-class Cursor;
-class Event;
-class Font;
-class GraphicsContext;
-class PlatformMouseEvent;
-class ScrollView;
-class WidgetClient;
-class WidgetPrivate;
-
-// The Widget class serves as a base class for three kinds of objects:
-// (1) Scrollable areas (ScrollView)
-// (2) Scrollbars (Scrollbar)
-// (3) Plugins (PluginView)
-//
-// A widget may or may not be backed by a platform-specific object (e.g., HWND on Windows, NSView on Mac, QWidget on Qt).
-//
-// Widgets are connected in a hierarchy, with the restriction that plugins and scrollbars are always leaves of the
-// tree. Only ScrollViews can have children (and therefore the Widget class has no concept of children).
-//
-// The rules right now for which widgets get platform-specific objects are as follows:
-// ScrollView - Mac
-// Scrollbar - Mac, Gtk
-// Plugin - Mac, Windows (windowed only), Qt (windowed only, widget is an HWND on windows), Gtk (windowed only)
-//
-class Widget {
-public:
- Widget(PlatformWidget = 0);
- virtual ~Widget();
-
- PlatformWidget platformWidget() const { return m_widget; }
- void setPlatformWidget(PlatformWidget widget)
- {
- if (widget != m_widget) {
- releasePlatformWidget();
- m_widget = widget;
- retainPlatformWidget();
- }
- }
-
- int x() const { return frameRect().x(); }
- int y() const { return frameRect().y(); }
- int width() const { return frameRect().width(); }
- int height() const { return frameRect().height(); }
- IntSize size() const { return frameRect().size(); }
- IntPoint pos() const { return frameRect().location(); }
-
- virtual void setFrameRect(const IntRect&);
- virtual IntRect frameRect() const;
- IntRect boundsRect() const { return IntRect(0, 0, width(), height()); }
-
- void resize(int w, int h) { setFrameRect(IntRect(x(), y(), w, h)); }
- void resize(const IntSize& s) { setFrameRect(IntRect(pos(), s)); }
- void move(int x, int y) { setFrameRect(IntRect(x, y, width(), height())); }
- void move(const IntPoint& p) { setFrameRect(IntRect(p, size())); }
-
- virtual void paint(GraphicsContext*, const IntRect&);
- void invalidate() { invalidateRect(boundsRect()); }
- virtual void invalidateRect(const IntRect&) = 0;
-
- virtual void setFocus();
-
- void setCursor(const Cursor&);
- Cursor cursor();
-
- virtual void show();
- virtual void hide();
- bool isSelfVisible() const { return m_selfVisible; } // Whether or not we have been explicitly marked as visible or not.
- bool isParentVisible() const { return m_parentVisible; } // Whether or not our parent is visible.
- bool isVisible() const { return m_selfVisible && m_parentVisible; } // Whether or not we are actually visible.
- virtual void setParentVisible(bool visible) { m_parentVisible = visible; }
- void setSelfVisible(bool v) { m_selfVisible = v; }
-
- void setIsSelected(bool);
-
- virtual bool isFrameView() const { return false; }
- virtual bool isPluginView() const { return false; }
-
- void removeFromParent();
- virtual void setParent(ScrollView* view);
- ScrollView* parent() const { return m_parent; }
- ScrollView* root() const;
-
- virtual void handleEvent(Event*) { }
-
- // It is important for cross-platform code to realize that Mac has flipped coordinates. Therefore any code
- // that tries to convert the location of a rect using the point-based convertFromContainingWindow will end
- // up with an inaccurate rect. Always make sure to use the rect-based convertFromContainingWindow method
- // when converting window rects.
- IntRect convertToContainingWindow(const IntRect&) const;
- IntPoint convertToContainingWindow(const IntPoint&) const;
- IntPoint convertFromContainingWindow(const IntPoint&) const; // See comment above about when not to use this method.
- IntRect convertFromContainingWindow(const IntRect&) const;
-
- virtual void frameRectsChanged() const {}
-
-#if PLATFORM(MAC)
- NSView* getOuterView() const;
-
- static void beforeMouseDown(NSView*, Widget*);
- static void afterMouseDown(NSView*, Widget*);
-
- void removeFromSuperview();
-#endif
-
-private:
- void init(PlatformWidget); // Must be called by all Widget constructors to initialize cross-platform data.
-
- void releasePlatformWidget();
- void retainPlatformWidget();
-
-private:
- ScrollView* m_parent;
- PlatformWidget m_widget;
- bool m_selfVisible;
- bool m_parentVisible;
-
- IntRect m_frame; // Not used when a native widget exists.
-
-#if PLATFORM(MAC) || PLATFORM(GTK)
- WidgetPrivate* m_data;
-#endif
-#if PLATFORM(ANDROID)
-public:
- int screenWidth() const;
-#endif
-};
-
-} // namespace WebCore
-
-#endif // Widget_h
diff --git a/WebCore/platform/android/ClipboardAndroid.cpp b/WebCore/platform/android/ClipboardAndroid.cpp
deleted file mode 100644
index 0322e01..0000000
--- a/WebCore/platform/android/ClipboardAndroid.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright 2009, The Android Open Source Project
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ClipboardAndroid.h"
-
-#include "CachedImage.h"
-#include "Element.h"
-#include "Frame.h"
-#include "Range.h"
-
-namespace WebCore {
-
-ClipboardAndroid::ClipboardAndroid(ClipboardAccessPolicy policy, bool isForDragging)
- : Clipboard(policy, isForDragging)
-{
-}
-
-ClipboardAndroid::~ClipboardAndroid()
-{
-}
-
-void ClipboardAndroid::clearData(const String&)
-{
- ASSERT(isForDragging());
-}
-
-void ClipboardAndroid::clearAllData()
-{
- ASSERT(isForDragging());
-}
-
-String ClipboardAndroid::getData(const String&, bool& success) const
-{
- success = false;
- return "";
-}
-
-bool ClipboardAndroid::setData(const String&, const String&)
-{
- ASSERT(isForDragging());
- return false;
-}
-
-// extensions beyond IE's API
-HashSet<String> ClipboardAndroid::types() const
-{
- return HashSet<String>();
-}
-
-void ClipboardAndroid::setDragImage(CachedImage*, const IntPoint&)
-{
-}
-
-void ClipboardAndroid::setDragImageElement(Node*, const IntPoint&)
-{
-}
-
-DragImageRef ClipboardAndroid::createDragImage(IntPoint&) const
-{
- return 0;
-}
-
-void ClipboardAndroid::declareAndWriteDragImage(Element*, const KURL&, const String&, Frame*)
-{
-}
-
-void ClipboardAndroid::writeURL(const KURL&, const String&, Frame*)
-{
-}
-
-void ClipboardAndroid::writeRange(Range* selectedRange, Frame*)
-{
- ASSERT(selectedRange);
-}
-
-bool ClipboardAndroid::hasData()
-{
- return false;
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/android/ClipboardAndroid.h b/WebCore/platform/android/ClipboardAndroid.h
deleted file mode 100644
index 987463f..0000000
--- a/WebCore/platform/android/ClipboardAndroid.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 2009, The Android Open Source Project
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ClipboardAndroid_h
-#define ClipboardAndroid_h
-
-#include "Clipboard.h"
-
-#include "CachedResourceClient.h"
-
-namespace WebCore {
-
- class CachedImage;
-
- class ClipboardAndroid : public Clipboard, public CachedResourceClient {
- public:
- ClipboardAndroid(ClipboardAccessPolicy policy, bool isForDragging);
- ~ClipboardAndroid();
-
- void clearData(const String&);
- void clearAllData();
- String getData(const String&, bool& success) const;
- bool setData(const String&, const String&);
-
- // extensions beyond IE's API
- HashSet<String> types() const;
-
- void setDragImage(CachedImage*, const IntPoint&);
- void setDragImageElement(Node*, const IntPoint&);
-
- virtual DragImageRef createDragImage(IntPoint&) const;
- virtual void declareAndWriteDragImage(Element*, const KURL&, const String&, Frame*);
- virtual void writeURL(const KURL&, const String&, Frame*);
- virtual void writeRange(Range*, Frame*);
-
- virtual bool hasData();
- };
-
-} // namespace WebCore
-
-#endif // ClipboardAndroid_h
diff --git a/WebCore/platform/android/CursorAndroid.cpp b/WebCore/platform/android/CursorAndroid.cpp
deleted file mode 100644
index 5c6e473..0000000
--- a/WebCore/platform/android/CursorAndroid.cpp
+++ /dev/null
@@ -1,295 +0,0 @@
-/*
- * Copyright 2009, The Android Open Source Project
- * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#define LOG_TAG "WebCore"
-
-#include "config.h"
-#include "Cursor.h"
-
-#include "NotImplemented.h"
-
-namespace WebCore {
-
-Cursor::Cursor(Image*, const IntPoint&)
-{
- notImplemented();
-}
-
-Cursor::Cursor(const Cursor&)
-{
- notImplemented();
-}
-
-Cursor::~Cursor()
-{
- notImplemented();
-}
-
-Cursor& Cursor::operator=(const Cursor&)
-{
- notImplemented();
- return *this;
-}
-
-static Cursor c;
-const Cursor& pointerCursor()
-{
- notImplemented();
- return c;
-}
-
-const Cursor& crossCursor()
-{
- notImplemented();
- return c;
-}
-
-const Cursor& handCursor()
-{
- notImplemented();
- return c;
-}
-
-const Cursor& moveCursor()
-{
- notImplemented();
- return c;
-}
-
-const Cursor& iBeamCursor()
-{
- notImplemented();
- return c;
-}
-
-const Cursor& waitCursor()
-{
- notImplemented();
- return c;
-}
-
-const Cursor& helpCursor()
-{
- notImplemented();
- return c;
-}
-
-const Cursor& eastResizeCursor()
-{
- notImplemented();
- return c;
-}
-
-const Cursor& northResizeCursor()
-{
- notImplemented();
- return c;
-}
-
-const Cursor& northEastResizeCursor()
-{
- notImplemented();
- return c;
-}
-
-const Cursor& northWestResizeCursor()
-{
- notImplemented();
- return c;
-}
-
-const Cursor& southResizeCursor()
-{
- notImplemented();
- return c;
-}
-
-const Cursor& southEastResizeCursor()
-{
- notImplemented();
- return c;
-}
-
-const Cursor& southWestResizeCursor()
-{
- notImplemented();
- return c;
-}
-
-const Cursor& westResizeCursor()
-{
- notImplemented();
- return c;
-}
-
-const Cursor& northSouthResizeCursor()
-{
- notImplemented();
- return c;
-}
-
-const Cursor& eastWestResizeCursor()
-{
- notImplemented();
- return c;
-}
-
-const Cursor& northEastSouthWestResizeCursor()
-{
- notImplemented();
- return c;
-}
-
-const Cursor& northWestSouthEastResizeCursor()
-{
- notImplemented();
- return c;
-}
-
-const Cursor& columnResizeCursor()
-{
- notImplemented();
- return c;
-}
-
-const Cursor& rowResizeCursor()
-{
- notImplemented();
- return c;
-}
-
-const Cursor& verticalTextCursor()
-{
- notImplemented();
- return c;
-}
-
-const Cursor& cellCursor()
-{
- notImplemented();
- return c;
-}
-
-const Cursor& contextMenuCursor()
-{
- notImplemented();
- return c;
-}
-
-const Cursor& noDropCursor()
-{
- notImplemented();
- return c;
-}
-
-const Cursor& copyCursor()
-{
- notImplemented();
- return c;
-}
-
-const Cursor& progressCursor()
-{
- notImplemented();
- return c;
-}
-
-const Cursor& aliasCursor()
-{
- notImplemented();
- return c;
-}
-
-const Cursor& noneCursor()
-{
- notImplemented();
- return c;
-}
-
-const Cursor& middlePanningCursor()
-{
- notImplemented();
- return c;
-}
-
-const Cursor& eastPanningCursor()
-{
- notImplemented();
- return c;
-}
-
-const Cursor& northPanningCursor()
-{
- notImplemented();
- return c;
-}
-
-const Cursor& northEastPanningCursor()
-{
- notImplemented();
- return c;
-}
-
-const Cursor& northWestPanningCursor()
-{
- notImplemented();
- return c;
-}
-
-const Cursor& southPanningCursor()
-{
- notImplemented();
- return c;
-}
-
-const Cursor& southEastPanningCursor()
-{
- notImplemented();
- return c;
-}
-
-const Cursor& southWestPanningCursor()
-{
- notImplemented();
- return c;
-}
-
-const Cursor& westPanningCursor()
-{
- notImplemented();
- return c;
-}
-
-const Cursor& grabCursor() {
- notImplemented();
- return c;
-}
-
-const Cursor& grabbingCursor() {
- notImplemented();
- return c;
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/android/DragDataAndroid.cpp b/WebCore/platform/android/DragDataAndroid.cpp
deleted file mode 100644
index 39b2963..0000000
--- a/WebCore/platform/android/DragDataAndroid.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright 2009, The Android Open Source Project
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "DragData.h"
-
-#include "Clipboard.h"
-#include "Document.h"
-#include "DocumentFragment.h"
-
-namespace WebCore {
-
-bool DragData::canSmartReplace() const
-{
- return false;
-}
-
-bool DragData::containsColor() const
-{
- return false;
-}
-
-bool DragData::containsPlainText() const
-{
- return false;
-}
-
-String DragData::asPlainText() const
-{
- return String();
-}
-
-Color DragData::asColor() const
-{
- return Color();
-}
-
-PassRefPtr<Clipboard> DragData::createClipboard(ClipboardAccessPolicy) const
-{
- return 0;
-}
-
-bool DragData::containsCompatibleContent() const
-{
- return false;
-}
-
-bool DragData::containsURL() const
-{
- return false;
-}
-
-String DragData::asURL(String*) const
-{
- return String();
-}
-
-
-PassRefPtr<DocumentFragment> DragData::asFragment(Document*) const
-{
- return 0;
-}
-
-void DragData::asFilenames(Vector<String>&) const
-{
-}
-
-bool DragData::containsFiles() const
-{
- return false;
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/android/EventLoopAndroid.cpp b/WebCore/platform/android/EventLoopAndroid.cpp
deleted file mode 100644
index 3a6d7ed..0000000
--- a/WebCore/platform/android/EventLoopAndroid.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2008, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "EventLoop.h"
-
-#include "NotImplemented.h"
-
-namespace WebCore {
-
-void EventLoop::cycle()
-{
- notImplemented();
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/android/FileChooserAndroid.cpp b/WebCore/platform/android/FileChooserAndroid.cpp
deleted file mode 100644
index 2c75373..0000000
--- a/WebCore/platform/android/FileChooserAndroid.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2006, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FileChooser.h"
-
-#include "Font.h"
-
-namespace WebCore {
-
-String FileChooser::basenameForWidth(const Font& font, int width) const
-{
- // FIXME: This could be a lot faster, but assuming the data will not
- // often be much longer than the provided width, this may be fast enough.
- String output = m_filenames[0].copy();
- while (font.width(TextRun(output.impl())) > width && output.length() > 4) {
- output = output.replace(output.length() - 4, 4, String("..."));
- }
- return output;
-}
-
-// The following two strings are used for File Upload form control, ie
-// <input type="file">. The first is the text that appears on the button
-// that when pressed, the user can browse for and select a file. The
-// second string is rendered on the screen when no file has been selected.
-String fileButtonChooseFileLabel()
-{
- return String("Uploads Disabled");
-}
-
-String fileButtonNoFileSelectedLabel()
-{
- return String("No file selected");
-}
-
-} // namesapce WebCore
-
diff --git a/WebCore/platform/android/FileSystemAndroid.cpp b/WebCore/platform/android/FileSystemAndroid.cpp
deleted file mode 100644
index b6d58bc..0000000
--- a/WebCore/platform/android/FileSystemAndroid.cpp
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright 2009, The Android Open Source Project
- * Copyright (C) 2007 Holger Hans Peter Freyther
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FileSystem.h"
-
-#include "CString.h"
-#include <dlfcn.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include "cutils/log.h"
-
-namespace WebCore {
-
-// Global static used to store the base to the plugin path.
-// This is set in WebSettings.cpp
-String sPluginPath;
-
-CString fileSystemRepresentation(const String& path) {
- return path.utf8();
-}
-
-CString openTemporaryFile(const char* prefix, PlatformFileHandle& handle)
-{
- int number = rand() % 10000 + 1;
- CString filename;
- do {
- String path = sPluginPath;
- path.append("/");
- path.append(prefix);
- path.append(String::number(number));
- filename = path.utf8();
- const char *fstr = filename.data();
- handle = open(filename.data(), O_WRONLY | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
- number++;
- } while (handle == -1 && errno == EEXIST);
-
- if (handle != -1) {
- return filename;
- }
- return CString();
-}
-
-bool unloadModule(PlatformModule module)
-{
- return dlclose(module) == 0;
-}
-
-void closeFile(PlatformFileHandle& handle)
-{
- if (isHandleValid(handle)) {
- close(handle);
- handle = invalidPlatformFileHandle;
- }
-}
-
-int writeToFile(PlatformFileHandle handle, const char* data, int length)
-{
- int totalBytesWritten = 0;
- while (totalBytesWritten < length) {
- int bytesWritten = write(handle, data, length - totalBytesWritten);
- if (bytesWritten < 0 && errno != EINTR)
- return -1;
- else if (bytesWritten > 0)
- totalBytesWritten += bytesWritten;
- }
-
- return totalBytesWritten;
-}
-
-// new as of SVN change 36269, Sept 8, 2008
-String homeDirectoryPath()
-{
- return sPluginPath;
-}
-
-}
diff --git a/WebCore/platform/android/KeyEventAndroid.cpp b/WebCore/platform/android/KeyEventAndroid.cpp
deleted file mode 100644
index 5496bbc..0000000
--- a/WebCore/platform/android/KeyEventAndroid.cpp
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * Copyright 2007, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "PlatformKeyboardEvent.h"
-
-#include "KeyboardCodes.h"
-#include "NotImplemented.h"
-#include <ui/KeycodeLabels.h>
-
-namespace WebCore {
-
-// compare to same function in gdk/KeyEventGdk.cpp
-static int windowsKeyCodeForKeyEvent(unsigned int keyCode) {
- // Does not provide all key codes, and does not handle all keys.
- switch(keyCode) {
- case kKeyCodeDel:
- return VK_BACK;
- case kKeyCodeTab:
- return VK_TAB;
- case kKeyCodeClear:
- return VK_CLEAR;
- case kKeyCodeDpadCenter:
- case kKeyCodeNewline:
- return VK_RETURN;
- case kKeyCodeShiftLeft:
- case kKeyCodeShiftRight:
- return VK_SHIFT;
- // back will serve as escape, although we probably do not have access to it
- case kKeyCodeBack:
- return VK_ESCAPE;
- case kKeyCodeSpace:
- return VK_SPACE;
- case kKeyCodeHome:
- return VK_HOME;
- case kKeyCodeDpadLeft:
- return VK_LEFT;
- case kKeyCodeDpadUp:
- return VK_UP;
- case kKeyCodeDpadRight:
- return VK_RIGHT;
- case kKeyCodeDpadDown:
- return VK_DOWN;
- case kKeyCode0:
- return VK_0;
- case kKeyCode1:
- return VK_1;
- case kKeyCode2:
- return VK_2;
- case kKeyCode3:
- return VK_3;
- case kKeyCode4:
- return VK_4;
- case kKeyCode5:
- return VK_5;
- case kKeyCode6:
- return VK_6;
- case kKeyCode7:
- return VK_7;
- case kKeyCode8:
- return VK_8;
- case kKeyCode9:
- return VK_9;
- case kKeyCodeA:
- return VK_A;
- case kKeyCodeB:
- return VK_B;
- case kKeyCodeC:
- return VK_C;
- case kKeyCodeD:
- return VK_D;
- case kKeyCodeE:
- return VK_E;
- case kKeyCodeF:
- return VK_F;
- case kKeyCodeG:
- return VK_G;
- case kKeyCodeH:
- return VK_H;
- case kKeyCodeI:
- return VK_I;
- case kKeyCodeJ:
- return VK_J;
- case kKeyCodeK:
- return VK_K;
- case kKeyCodeL:
- return VK_L;
- case kKeyCodeM:
- return VK_M;
- case kKeyCodeN:
- return VK_N;
- case kKeyCodeO:
- return VK_O;
- case kKeyCodeP:
- return VK_P;
- case kKeyCodeQ:
- return VK_Q;
- case kKeyCodeR:
- return VK_R;
- case kKeyCodeS:
- return VK_S;
- case kKeyCodeT:
- return VK_T;
- case kKeyCodeU:
- return VK_U;
- case kKeyCodeV:
- return VK_V;
- case kKeyCodeW:
- return VK_W;
- case kKeyCodeX:
- return VK_X;
- case kKeyCodeY:
- return VK_Y;
- case kKeyCodeZ:
- return VK_Z;
- // colon
- case kKeyCodeSemicolon:
- return VK_OEM_1;
- case kKeyCodeComma:
- return VK_OEM_COMMA;
- case kKeyCodeMinus:
- return VK_OEM_MINUS;
- case kKeyCodeEquals:
- return VK_OEM_PLUS;
- case kKeyCodePeriod:
- return VK_OEM_PERIOD;
- case kKeyCodeSlash:
- return VK_OEM_2;
- // maybe not the right choice
- case kKeyCodeLeftBracket:
- return VK_OEM_4;
- case kKeyCodeBackslash:
- return VK_OEM_5;
- case kKeyCodeRightBracket:
- return VK_OEM_6;
- default:
- return 0;
- }
-}
-
-static String keyIdentifierForAndroidKeyCode(int keyCode)
-{
- // Does not return all of the same key identifiers, and
- // does not handle all the keys.
- switch (keyCode) {
- case kKeyCodeClear:
- return "Clear";
- case kKeyCodeNewline:
- case kKeyCodeDpadCenter:
- return "Enter";
- case kKeyCodeHome:
- return "Home";
- case kKeyCodeDpadDown:
- return "Down";
- case kKeyCodeDpadLeft:
- return "Left";
- case kKeyCodeDpadRight:
- return "Right";
- case kKeyCodeDpadUp:
- return "Up";
- // Standard says that DEL becomes U+00007F.
- case kKeyCodeDel:
- return "U+00007F";
- default:
- char upper[16];
- sprintf(upper, "U+%06X", windowsKeyCodeForKeyEvent(keyCode));
- return String(upper);
- }
-}
-
-static inline String singleCharacterString(int c)
-{
- if (!c)
- return String();
- if (c > 0xffff) {
- UChar lead = U16_LEAD(c);
- UChar trail = U16_TRAIL(c);
- UChar utf16[2] = {lead, trail};
- return String(utf16, 2);
- }
- UChar n = (UChar)c;
- return String(&n, 1);
-}
-
-PlatformKeyboardEvent::PlatformKeyboardEvent(int keyCode, UChar32 unichar,
- Type type, int repeatCount,
- ModifierKey mods)
- : m_type(type)
- , m_text(singleCharacterString(unichar))
- , m_unmodifiedText(singleCharacterString(unichar))
- , m_keyIdentifier(keyIdentifierForAndroidKeyCode(keyCode))
- , m_autoRepeat(repeatCount > 0)
- , m_windowsVirtualKeyCode(windowsKeyCodeForKeyEvent(keyCode))
- , m_nativeVirtualKeyCode(keyCode)
- , m_isKeypad(false)
- , m_shiftKey((mods & ShiftKey) != 0)
- , m_ctrlKey((mods & CtrlKey) != 0)
- , m_altKey((mods & AltKey) != 0)
- , m_metaKey((mods & MetaKey) != 0)
- // added for android
- , m_repeatCount(repeatCount)
- , m_unichar(unichar)
-{
- // Copied from the mac port
- if (m_windowsVirtualKeyCode == '\r') {
- m_text = "\r";
- m_unmodifiedText = "\r";
- }
-
- if (m_text == "\x7F")
- m_text = "\x8";
- if (m_unmodifiedText == "\x7F")
- m_unmodifiedText = "\x8";
-
- if (m_windowsVirtualKeyCode == 9) {
- m_text = "\x9";
- m_unmodifiedText = "\x9";
- }
-}
-
-bool PlatformKeyboardEvent::currentCapsLockState()
-{
- notImplemented();
- return false;
-}
-
-void PlatformKeyboardEvent::disambiguateKeyDownEvent(Type type, bool backwardCompatibilityMode)
-{
- // Copied with modification from the mac port.
- ASSERT(m_type == KeyDown);
- ASSERT(type == RawKeyDown || type == Char);
- m_type = type;
- if (backwardCompatibilityMode)
- return;
-
- if (type == RawKeyDown) {
- m_text = String();
- m_unmodifiedText = String();
- } else {
- m_keyIdentifier = String();
- m_windowsVirtualKeyCode = 0;
- }
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/android/KeyboardCodes.h b/WebCore/platform/android/KeyboardCodes.h
deleted file mode 100644
index 321e9da..0000000
--- a/WebCore/platform/android/KeyboardCodes.h
+++ /dev/null
@@ -1,545 +0,0 @@
-/*
- * Copyright 2009, The Android Open Source Project
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef KeyboardCodes_H
-#define KeyboardCodes_H
-
-namespace WebCore {
-
-// VK_LBUTTON (01) Left mouse button
-// VK_RBUTTON (02) Right mouse button
-// VK_CANCEL (03) Control-break processing
-// VK_MBUTTON (04) Middle mouse button (three-button mouse)
-// VK_XBUTTON1 (05)
-// VK_XBUTTON2 (06)
-
-// VK_BACK (08) BACKSPACE key
-const int VK_BACK = 0x08;
-
-// VK_TAB (09) TAB key
-const int VK_TAB = 0x09;
-
-// VK_CLEAR (0C) CLEAR key
-const int VK_CLEAR = 0x0C;
-
-// VK_RETURN (0D)
-const int VK_RETURN = 0x0D;
-
-// VK_SHIFT (10) SHIFT key
-const int VK_SHIFT = 0x10;
-
-// VK_CONTROL (11) CTRL key
-const int VK_CONTROL = 0x11;
-
-// VK_MENU (12) ALT key
-const int VK_MENU = 0x12;
-
-// VK_PAUSE (13) PAUSE key
-const int VK_PAUSE = 0x13;
-
-// VK_CAPITAL (14) CAPS LOCK key
-const int VK_CAPITAL = 0x14;
-
-// VK_KANA (15) Input Method Editor (IME) Kana mode
-const int VK_KANA = 0x15;
-
-// VK_HANGUEL (15) IME Hanguel mode (maintained for compatibility; use VK_HANGUL)
-// VK_HANGUL (15) IME Hangul mode
-const int VK_HANGUL = 0x15;
-
-// VK_JUNJA (17) IME Junja mode
-const int VK_JUNJA = 0x17;
-
-// VK_FINAL (18) IME final mode
-const int VK_FINAL = 0x18;
-
-// VK_HANJA (19) IME Hanja mode
-const int VK_HANJA = 0x19;
-
-// VK_KANJI (19) IME Kanji mode
-const int VK_KANJI = 0x19;
-
-// VK_ESCAPE (1B) ESC key
-const int VK_ESCAPE = 0x1B;
-
-// VK_CONVERT (1C) IME convert
-const int VK_CONVERT = 0x1C;
-
-// VK_NONCONVERT (1D) IME nonconvert
-const int VK_NONCONVERT = 0x1D;
-
-// VK_ACCEPT (1E) IME accept
-const int VK_ACCEPT = 0x1E;
-
-// VK_MODECHANGE (1F) IME mode change request
-const int VK_MODECHANGE = 0x1F;
-
-// VK_SPACE (20) SPACEBAR
-const int VK_SPACE = 0x20;
-
-// VK_PRIOR (21) PAGE UP key
-const int VK_PRIOR = 0x21;
-
-// VK_NEXT (22) PAGE DOWN key
-const int VK_NEXT = 0x22;
-
-// VK_END (23) END key
-const int VK_END = 0x23;
-
-// VK_HOME (24) HOME key
-const int VK_HOME = 0x24;
-
-// VK_LEFT (25) LEFT ARROW key
-const int VK_LEFT = 0x25;
-
-// VK_UP (26) UP ARROW key
-const int VK_UP = 0x26;
-
-// VK_RIGHT (27) RIGHT ARROW key
-const int VK_RIGHT = 0x27;
-
-// VK_DOWN (28) DOWN ARROW key
-const int VK_DOWN = 0x28;
-
-// VK_SELECT (29) SELECT key
-const int VK_SELECT = 0x29;
-
-// VK_PRINT (2A) PRINT key
-const int VK_PRINT = 0x2A;
-
-// VK_EXECUTE (2B) EXECUTE key
-const int VK_EXECUTE = 0x2B;
-
-// VK_SNAPSHOT (2C) PRINT SCREEN key
-const int VK_SNAPSHOT = 0x2C;
-
-// VK_INSERT (2D) INS key
-const int VK_INSERT = 0x2D;
-
-// VK_DELETE (2E) DEL key
-const int VK_DELETE = 0x2E;
-
-// VK_HELP (2F) HELP key
-const int VK_HELP = 0x2F;
-
-// (30) 0 key
-const int VK_0 = 0x30;
-
-// (31) 1 key
-const int VK_1 = 0x31;
-
-// (32) 2 key
-const int VK_2 = 0x32;
-
-// (33) 3 key
-const int VK_3 = 0x33;
-
-// (34) 4 key
-const int VK_4 = 0x34;
-
-// (35) 5 key;
-
-const int VK_5 = 0x35;
-
-// (36) 6 key
-const int VK_6 = 0x36;
-
-// (37) 7 key
-const int VK_7 = 0x37;
-
-// (38) 8 key
-const int VK_8 = 0x38;
-
-// (39) 9 key
-const int VK_9 = 0x39;
-
-// (41) A key
-const int VK_A = 0x41;
-
-// (42) B key
-const int VK_B = 0x42;
-
-// (43) C key
-const int VK_C = 0x43;
-
-// (44) D key
-const int VK_D = 0x44;
-
-// (45) E key
-const int VK_E = 0x45;
-
-// (46) F key
-const int VK_F = 0x46;
-
-// (47) G key
-const int VK_G = 0x47;
-
-// (48) H key
-const int VK_H = 0x48;
-
-// (49) I key
-const int VK_I = 0x49;
-
-// (4A) J key
-const int VK_J = 0x4A;
-
-// (4B) K key
-const int VK_K = 0x4B;
-
-// (4C) L key
-const int VK_L = 0x4C;
-
-// (4D) M key
-const int VK_M = 0x4D;
-
-// (4E) N key
-const int VK_N = 0x4E;
-
-// (4F) O key
-const int VK_O = 0x4F;
-
-// (50) P key
-const int VK_P = 0x50;
-
-// (51) Q key
-const int VK_Q = 0x51;
-
-// (52) R key
-const int VK_R = 0x52;
-
-// (53) S key
-const int VK_S = 0x53;
-
-// (54) T key
-const int VK_T = 0x54;
-
-// (55) U key
-const int VK_U = 0x55;
-
-// (56) V key
-const int VK_V = 0x56;
-
-// (57) W key
-const int VK_W = 0x57;
-
-// (58) X key
-const int VK_X = 0x58;
-
-// (59) Y key
-const int VK_Y = 0x59;
-
-// (5A) Z key
-const int VK_Z = 0x5A;
-
-// VK_LWIN (5B) Left Windows key (Microsoft Natural keyboard)
-const int VK_LWIN = 0x5B;
-
-// VK_RWIN (5C) Right Windows key (Natural keyboard)
-const int VK_RWIN = 0x5C;
-
-// VK_APPS (5D) Applications key (Natural keyboard)
-const int VK_APPS = 0x5D;
-
-// VK_SLEEP (5F) Computer Sleep key
-const int VK_SLEEP = 0x5F;
-
-// VK_NUMPAD0 (60) Numeric keypad 0 key
-const int VK_NUMPAD0 = 0x60;
-
-// VK_NUMPAD1 (61) Numeric keypad 1 key
-const int VK_NUMPAD1 = 0x61;
-
-// VK_NUMPAD2 (62) Numeric keypad 2 key
-const int VK_NUMPAD2 = 0x62;
-
-// VK_NUMPAD3 (63) Numeric keypad 3 key
-const int VK_NUMPAD3 = 0x63;
-
-// VK_NUMPAD4 (64) Numeric keypad 4 key
-const int VK_NUMPAD4 = 0x64;
-
-// VK_NUMPAD5 (65) Numeric keypad 5 key
-const int VK_NUMPAD5 = 0x65;
-
-// VK_NUMPAD6 (66) Numeric keypad 6 key
-const int VK_NUMPAD6 = 0x66;
-
-// VK_NUMPAD7 (67) Numeric keypad 7 key
-const int VK_NUMPAD7 = 0x67;
-
-// VK_NUMPAD8 (68) Numeric keypad 8 key
-const int VK_NUMPAD8 = 0x68;
-
-// VK_NUMPAD9 (69) Numeric keypad 9 key
-const int VK_NUMPAD9 = 0x69;
-
-// VK_MULTIPLY (6A) Multiply key
-const int VK_MULTIPLY = 0x6A;
-
-// VK_ADD (6B) Add key
-const int VK_ADD = 0x6B;
-
-// VK_SEPARATOR (6C) Separator key
-const int VK_SEPARATOR = 0x6C;
-
-// VK_SUBTRACT (6D) Subtract key
-const int VK_SUBTRACT = 0x6D;
-
-// VK_DECIMAL (6E) Decimal key
-const int VK_DECIMAL = 0x6E;
-
-// VK_DIVIDE (6F) Divide key
-const int VK_DIVIDE = 0x6F;
-
-// VK_F1 (70) F1 key
-const int VK_F1 = 0x70;
-
-// VK_F2 (71) F2 key
-const int VK_F2 = 0x71;
-
-// VK_F3 (72) F3 key
-const int VK_F3 = 0x72;
-
-// VK_F4 (73) F4 key
-const int VK_F4 = 0x73;
-
-// VK_F5 (74) F5 key
-const int VK_F5 = 0x74;
-
-// VK_F6 (75) F6 key
-const int VK_F6 = 0x75;
-
-// VK_F7 (76) F7 key
-const int VK_F7 = 0x76;
-
-// VK_F8 (77) F8 key
-const int VK_F8 = 0x77;
-
-// VK_F9 (78) F9 key
-const int VK_F9 = 0x78;
-
-// VK_F10 (79) F10 key
-const int VK_F10 = 0x79;
-
-// VK_F11 (7A) F11 key
-const int VK_F11 = 0x7A;
-
-// VK_F12 (7B) F12 key
-const int VK_F12 = 0x7B;
-
-// VK_F13 (7C) F13 key
-const int VK_F13 = 0x7C;
-
-// VK_F14 (7D) F14 key
-const int VK_F14 = 0x7D;
-
-// VK_F15 (7E) F15 key
-const int VK_F15 = 0x7E;
-
-// VK_F16 (7F) F16 key
-const int VK_F16 = 0x7F;
-
-// VK_F17 (80H) F17 key
-const int VK_F17 = 0x80;
-
-// VK_F18 (81H) F18 key
-const int VK_F18 = 0x81;
-
-// VK_F19 (82H) F19 key
-const int VK_F19 = 0x82;
-
-// VK_F20 (83H) F20 key
-const int VK_F20 = 0x83;
-
-// VK_F21 (84H) F21 key
-const int VK_F21 = 0x84;
-
-// VK_F22 (85H) F22 key
-const int VK_F22 = 0x85;
-
-// VK_F23 (86H) F23 key
-const int VK_F23 = 0x86;
-
-// VK_F24 (87H) F24 key
-const int VK_F24 = 0x87;
-
-// VK_NUMLOCK (90) NUM LOCK key
-const int VK_NUMLOCK = 0x90;
-
-// VK_SCROLL (91) SCROLL LOCK key
-const int VK_SCROLL = 0x91;
-
-// VK_LSHIFT (A0) Left SHIFT key
-const int VK_LSHIFT = 0xA0;
-
-// VK_RSHIFT (A1) Right SHIFT key
-const int VK_RSHIFT = 0xA1;
-
-// VK_LCONTROL (A2) Left CONTROL key
-const int VK_LCONTROL = 0xA2;
-
-// VK_RCONTROL (A3) Right CONTROL key
-const int VK_RCONTROL = 0xA3;
-
-// VK_LMENU (A4) Left MENU key
-const int VK_LMENU = 0xA4;
-
-// VK_RMENU (A5) Right MENU key
-const int VK_RMENU = 0xA5;
-
-// VK_BROWSER_BACK (A6) Windows 2000/XP: Browser Back key
-const int VK_BROWSER_BACK = 0xA6;
-
-// VK_BROWSER_FORWARD (A7) Windows 2000/XP: Browser Forward key
-const int VK_BROWSER_FORWARD = 0xA7;
-
-// VK_BROWSER_REFRESH (A8) Windows 2000/XP: Browser Refresh key
-const int VK_BROWSER_REFRESH = 0xA8;
-
-// VK_BROWSER_STOP (A9) Windows 2000/XP: Browser Stop key
-const int VK_BROWSER_STOP = 0xA9;
-
-// VK_BROWSER_SEARCH (AA) Windows 2000/XP: Browser Search key
-const int VK_BROWSER_SEARCH = 0xAA;
-
-// VK_BROWSER_FAVORITES (AB) Windows 2000/XP: Browser Favorites key
-const int VK_BROWSER_FAVORITES = 0xAB;
-
-// VK_BROWSER_HOME (AC) Windows 2000/XP: Browser Start and Home key
-const int VK_BROWSER_HOME = 0xAC;
-
-// VK_VOLUME_MUTE (AD) Windows 2000/XP: Volume Mute key
-const int VK_VOLUME_MUTE = 0xAD;
-
-// VK_VOLUME_DOWN (AE) Windows 2000/XP: Volume Down key
-const int VK_VOLUME_DOWN = 0xAE;
-
-// VK_VOLUME_UP (AF) Windows 2000/XP: Volume Up key
-const int VK_VOLUME_UP = 0xAF;
-
-// VK_MEDIA_NEXT_TRACK (B0) Windows 2000/XP: Next Track key
-const int VK_MEDIA_NEXT_TRACK = 0xB0;
-
-// VK_MEDIA_PREV_TRACK (B1) Windows 2000/XP: Previous Track key
-const int VK_MEDIA_PREV_TRACK = 0xB1;
-
-// VK_MEDIA_STOP (B2) Windows 2000/XP: Stop Media key
-const int VK_MEDIA_STOP = 0xB2;
-
-// VK_MEDIA_PLAY_PAUSE (B3) Windows 2000/XP: Play/Pause Media key
-const int VK_MEDIA_PLAY_PAUSE = 0xB3;
-
-// VK_LAUNCH_MAIL (B4) Windows 2000/XP: Start Mail key
-const int VK_MEDIA_LAUNCH_MAIL = 0xB4;
-
-// VK_LAUNCH_MEDIA_SELECT (B5) Windows 2000/XP: Select Media key
-const int VK_MEDIA_LAUNCH_MEDIA_SELECT = 0xB5;
-
-// VK_LAUNCH_APP1 (B6) Windows 2000/XP: Start Application 1 key
-const int VK_MEDIA_LAUNCH_APP1 = 0xB6;
-
-// VK_LAUNCH_APP2 (B7) Windows 2000/XP: Start Application 2 key
-const int VK_MEDIA_LAUNCH_APP2 = 0xB7;
-
-// VK_OEM_1 (BA) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ';:' key
-const int VK_OEM_1 = 0xBA;
-
-// VK_OEM_PLUS (BB) Windows 2000/XP: For any country/region, the '+' key
-const int VK_OEM_PLUS = 0xBB;
-
-// VK_OEM_COMMA (BC) Windows 2000/XP: For any country/region, the ',' key
-const int VK_OEM_COMMA = 0xBC;
-
-// VK_OEM_MINUS (BD) Windows 2000/XP: For any country/region, the '-' key
-const int VK_OEM_MINUS = 0xBD;
-
-// VK_OEM_PERIOD (BE) Windows 2000/XP: For any country/region, the '.' key
-const int VK_OEM_PERIOD = 0xBE;
-
-// VK_OEM_2 (BF) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '/?' key
-const int VK_OEM_2 = 0xBF;
-
-// VK_OEM_3 (C0) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '`~' key
-const int VK_OEM_3 = 0xC0;
-
-// VK_OEM_4 (DB) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '[{' key
-const int VK_OEM_4 = 0xDB;
-
-// VK_OEM_5 (DC) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '\|' key
-const int VK_OEM_5 = 0xDC;
-
-// VK_OEM_6 (DD) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ']}' key
-const int VK_OEM_6 = 0xDD;
-
-// VK_OEM_7 (DE) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the 'single-quote/double-quote' key
-const int VK_OEM_7 = 0xDE;
-
-// VK_OEM_8 (DF) Used for miscellaneous characters; it can vary by keyboard.
-const int VK_OEM_8 = 0xDF;
-
-// VK_OEM_102 (E2) Windows 2000/XP: Either the angle bracket key or the backslash key on the RT 102-key keyboard
-const int VK_OEM_102 = 0xE2;
-
-// VK_PROCESSKEY (E5) Windows 95/98/Me, Windows NT 4.0, Windows 2000/XP: IME PROCESS key
-const int VK_PROCESSKEY = 0xE5;
-
-// VK_PACKET (E7) Windows 2000/XP: Used to pass Unicode characters as if they were keystrokes. The VK_PACKET key is the low word of a 32-bit Virtual Key value used for non-keyboard input methods. For more information, see Remark in KEYBDINPUT,SendInput, WM_KEYDOWN, and WM_KEYUP
-const int VK_PACKET = 0xE7;
-
-// VK_ATTN (F6) Attn key
-const int VK_ATTN = 0xF6;
-
-// VK_CRSEL (F7) CrSel key
-const int VK_CRSEL = 0xF7;
-
-// VK_EXSEL (F8) ExSel key
-const int VK_EXSEL = 0xF8;
-
-// VK_EREOF (F9) Erase EOF key
-const int VK_EREOF = 0xF9;
-
-// VK_PLAY (FA) Play key
-const int VK_PLAY = 0xFA;
-
-// VK_ZOOM (FB) Zoom key
-const int VK_ZOOM = 0xFB;
-
-// VK_NONAME (FC) Reserved for future use
-const int VK_NONAME = 0xFC;
-
-// VK_PA1 (FD) PA1 key
-const int VK_PA1 = 0xFD;
-
-// VK_OEM_CLEAR (FE) Clear key
-const int VK_OEM_CLEAR = 0xFE;
-
-const int VK_UNKNOWN = 0;
-
-}
-
-#endif // KeyboardCodes_h
diff --git a/WebCore/platform/android/LocalizedStringsAndroid.cpp b/WebCore/platform/android/LocalizedStringsAndroid.cpp
deleted file mode 100644
index 02f135f..0000000
--- a/WebCore/platform/android/LocalizedStringsAndroid.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2009, The Android Open Source Project
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
- * Copyright (C) 2007 Holger Hans Peter Freyther
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "LocalizedStrings.h"
-
-#include "NotImplemented.h"
-#include "PlatformString.h"
-
-namespace WebCore {
-
-String contextMenuItemTagInspectElement()
-{
- return String::fromUTF8("Inspect Element");
-}
-
-String unknownFileSizeText()
-{
- return String::fromUTF8("Unknown");
-}
-
-String imageTitle(const String& filename, const IntSize& size)
-{
- notImplemented();
- return String();
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/android/PopupMenuAndroid.cpp b/WebCore/platform/android/PopupMenuAndroid.cpp
deleted file mode 100644
index 4d1fe04..0000000
--- a/WebCore/platform/android/PopupMenuAndroid.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * This file is part of the popup menu implementation for <select> elements in WebCore.
- *
- * Copyright 2009, The Android Open Source Project
- * Copyright (C) 2006 Apple Computer, Inc.
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- */
-
-#include "config.h"
-#include "PopupMenu.h"
-
-namespace WebCore {
-
-// Now we handle all of this in WebViewCore.cpp.
-PopupMenu::PopupMenu(PopupMenuClient* menuList)
- : m_popupClient(menuList)
-{
-}
-
-PopupMenu::~PopupMenu()
-{
-}
-
-void PopupMenu::show(const IntRect&, FrameView*, int)
-{
-
-}
-
-void PopupMenu::hide()
-{
-}
-
-void PopupMenu::updateFromElement()
-{
-}
-
-bool PopupMenu::itemWritingDirectionIsNatural()
-{
- return false;
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/android/RenderThemeAndroid.cpp b/WebCore/platform/android/RenderThemeAndroid.cpp
deleted file mode 100644
index e104c8e..0000000
--- a/WebCore/platform/android/RenderThemeAndroid.cpp
+++ /dev/null
@@ -1,318 +0,0 @@
-/*
- * Copyright 2006, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "RenderThemeAndroid.h"
-
-#include "RenderSkinAndroid.h"
-#include "RenderSkinButton.h"
-#include "RenderSkinCombo.h"
-#include "RenderSkinRadio.h"
-
-#include "GraphicsContext.h"
-#include "PlatformGraphicsContext.h"
-
-#include "SkCanvas.h"
-
-#define MAX_COMBO_HEIGHT 20
-
-// Add a constant amount of padding to the textsize to get the final height of buttons,
-// so that our button images are large enough to properly fit the text.
-#define BUTTON_PADDING 18
-
-// Add padding to the fontSize of ListBoxes to get their maximum sizes.
-// Listboxes often have a specified size. Since we change them into dropdowns,
-// we want a much smaller height, which encompasses the text.
-#define LISTBOX_PADDING 5
-
-namespace WebCore {
-
-static SkCanvas* getCanvasFromInfo(const RenderObject::PaintInfo& info)
-{
- return info.context->platformContext()->mCanvas;
-}
-
-RenderTheme* theme()
-{
- static RenderThemeAndroid androidTheme;
- return &androidTheme;
-}
-
-RenderThemeAndroid::RenderThemeAndroid()
-{
-}
-
-RenderThemeAndroid::~RenderThemeAndroid()
-{
-}
-
-void RenderThemeAndroid::close()
-{
-}
-
-bool RenderThemeAndroid::stateChanged(RenderObject* o, ControlState state) const
-{
- if (CheckedState == state) {
- o->repaint();
- return true;
- }
- return false;
-}
-
-Color RenderThemeAndroid::platformActiveSelectionBackgroundColor() const
-{
- return Color(46, 251, 0);
-}
-
-Color RenderThemeAndroid::platformInactiveSelectionBackgroundColor() const
-{
- return Color(255, 255, 0, 255);
-}
-
-Color RenderThemeAndroid::platformActiveSelectionForegroundColor() const
-{
- return Color::black;
-}
-
-Color RenderThemeAndroid::platformInactiveSelectionForegroundColor() const
-{
- return Color::black;
-}
-
-Color RenderThemeAndroid::platformTextSearchHighlightColor() const
-{
- return Color(192, 192, 192);
-}
-
-int RenderThemeAndroid::baselinePosition(const RenderObject* obj) const
-{
- // From the description of this function in RenderTheme.h:
- // A method to obtain the baseline position for a "leaf" control. This will only be used if a baseline
- // position cannot be determined by examining child content. Checkboxes and radio buttons are examples of
- // controls that need to do this.
- //
- // Our checkboxes and radio buttons need to be offset to line up properly.
- return RenderTheme::baselinePosition(obj) - 5;
-}
-
-void RenderThemeAndroid::addIntrinsicMargins(RenderStyle* style) const
-{
- // Cut out the intrinsic margins completely if we end up using a small font size
- if (style->fontSize() < 11)
- return;
-
- // Intrinsic margin value.
- const int m = 2;
-
- // FIXME: Using width/height alone and not also dealing with min-width/max-width is flawed.
- if (style->width().isIntrinsicOrAuto()) {
- if (style->marginLeft().quirk())
- style->setMarginLeft(Length(m, Fixed));
- if (style->marginRight().quirk())
- style->setMarginRight(Length(m, Fixed));
- }
-
- if (style->height().isAuto()) {
- if (style->marginTop().quirk())
- style->setMarginTop(Length(m, Fixed));
- if (style->marginBottom().quirk())
- style->setMarginBottom(Length(m, Fixed));
- }
-}
-
-bool RenderThemeAndroid::supportsFocus(ControlPart appearance)
-{
- switch (appearance) {
- case PushButtonPart:
- case ButtonPart:
- case TextFieldPart:
- return true;
- default:
- return false;
- }
-
- return false;
-}
-
-void RenderThemeAndroid::adjustButtonStyle(CSSStyleSelector* selector, RenderStyle* style, WebCore::Element* e) const
-{
- // Padding code is taken from RenderThemeSafari.cpp
- // It makes sure we have enough space for the button text.
- const int padding = 8;
- style->setPaddingLeft(Length(padding, Fixed));
- style->setPaddingRight(Length(padding, Fixed));
- style->setMinHeight(Length(style->fontSize() + BUTTON_PADDING, Fixed));
-}
-
-bool RenderThemeAndroid::paintCheckbox(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& ir)
-{
- RenderSkinRadio::Draw(getCanvasFromInfo(i), o->element(), ir, true);
- return false;
-}
-
-bool RenderThemeAndroid::paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& ir)
-{
- // If it is a disabled button, simply paint it to the master picture.
- Node* element = o->element();
- if (!element->isEnabled()) {
- RenderSkinButton::Draw(getCanvasFromInfo(i), ir, RenderSkinAndroid::kDisabled);
- } else {
- // Store all the important information in the platform context.
- i.context->platformContext()->storeButtonInfo(element, ir);
- }
- // We always return false so we do not request to be redrawn.
- return false;
-}
-
-bool RenderThemeAndroid::paintRadio(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& ir)
-{
- RenderSkinRadio::Draw(getCanvasFromInfo(i), o->element(), ir, false);
- return false;
-}
-
-void RenderThemeAndroid::setCheckboxSize(RenderStyle* style) const
-{
- style->setWidth(Length(19, Fixed));
- style->setHeight(Length(19, Fixed));
-}
-
-void RenderThemeAndroid::setRadioSize(RenderStyle* style) const
-{
- // This is the same as checkboxes.
- setCheckboxSize(style);
-}
-
-void RenderThemeAndroid::adjustTextFieldStyle(CSSStyleSelector* selector, RenderStyle* style, WebCore::Element* e) const
-{
- addIntrinsicMargins(style);
-}
-
-bool RenderThemeAndroid::paintTextField(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& ir)
-{
- return true;
-}
-
-void RenderThemeAndroid::adjustTextAreaStyle(CSSStyleSelector* selector, RenderStyle* style, WebCore::Element* e) const
-{
- addIntrinsicMargins(style);
-}
-
-bool RenderThemeAndroid::paintTextArea(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& ir)
-{
- if (o->isMenuList()) {
- return paintCombo(o, i, ir);
- }
- return true;
-}
-
-void RenderThemeAndroid::adjustSearchFieldStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
-{
- addIntrinsicMargins(style);
-}
-
-bool RenderThemeAndroid::paintSearchField(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& ir)
-{
- return true;
-}
-
-void RenderThemeAndroid::adjustListboxStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
-{
- style->setPaddingRight(Length(RenderSkinCombo::extraWidth(), Fixed));
- style->setMaxHeight(Length(style->fontSize() + LISTBOX_PADDING, Fixed));
- addIntrinsicMargins(style);
-}
-
-void RenderThemeAndroid::adjustMenuListStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
-{
- style->setPaddingRight(Length(RenderSkinCombo::extraWidth(), Fixed));
- addIntrinsicMargins(style);
-}
-
-bool RenderThemeAndroid::paintCombo(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& ir)
-{
- if (o->style() && o->style()->backgroundColor().alpha() == 0)
- return true;
- Node* element = o->element();
- int height = ir.height();
- int y = ir.y();
- // If the combo box is too large, leave it at its max height, and center it.
- if (height > MAX_COMBO_HEIGHT) {
- y += (height - MAX_COMBO_HEIGHT) >> 1;
- height = MAX_COMBO_HEIGHT;
- }
- return RenderSkinCombo::Draw(getCanvasFromInfo(i), element, ir.x(), y,
- ir.width(), height);
-}
-
-bool RenderThemeAndroid::paintMenuList(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& ir)
-{
- return paintCombo(o, i, ir);
-}
-
-void RenderThemeAndroid::adjustMenuListButtonStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
-{
- // Copied from RenderThemeSafari.
- const float baseFontSize = 11.0f;
- const int baseBorderRadius = 5;
- float fontScale = style->fontSize() / baseFontSize;
-
- style->resetPadding();
- style->setBorderRadius(IntSize(int(baseBorderRadius + fontScale - 1), int(baseBorderRadius + fontScale - 1))); // FIXME: Round up?
-
- const int minHeight = 15;
- style->setMinHeight(Length(minHeight, Fixed));
-
- style->setLineHeight(RenderStyle::initialLineHeight());
- // Found these padding numbers by trial and error.
- const int padding = 4;
- style->setPaddingTop(Length(padding, Fixed));
- style->setPaddingLeft(Length(padding, Fixed));
- // Added to make room for our arrow.
- style->setPaddingRight(Length(RenderSkinCombo::extraWidth(), Fixed));
-}
-
-bool RenderThemeAndroid::paintMenuListButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& ir)
-{
- return paintCombo(o, i, ir);
-}
-
-bool RenderThemeAndroid::supportsFocusRing(const RenderStyle* style) const
-{
- return (style->opacity() > 0 && style->hasAppearance()
- && style->appearance() != TextFieldPart
- && style->appearance() != SearchFieldPart
- && style->appearance() != TextAreaPart
- && style->appearance() != CheckboxPart
- && style->appearance() != RadioPart
- && style->appearance() != PushButtonPart
- && style->appearance() != SquareButtonPart
- && style->appearance() != ButtonPart
- && style->appearance() != ButtonBevelPart
- && style->appearance() != MenulistPart
- && style->appearance() != MenulistButtonPart
- );
-}
-
-}
diff --git a/WebCore/platform/android/RenderThemeAndroid.h b/WebCore/platform/android/RenderThemeAndroid.h
deleted file mode 100644
index 3b6e9cb..0000000
--- a/WebCore/platform/android/RenderThemeAndroid.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright 2006, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef RenderThemeAndroid_h
-#define RenderThemeAndroid_h
-
-#include "RenderTheme.h"
-
-namespace WebCore {
-
-class RenderSkinButton;
-class RenderSkinRadio;
-class RenderSkinCombo;
-
-struct ThemeData {
- ThemeData() :m_part(0), m_state(0) {}
-
- unsigned m_part;
- unsigned m_state;
-};
-
-class RenderThemeAndroid : public RenderTheme {
-public:
- RenderThemeAndroid();
- ~RenderThemeAndroid();
-
- virtual bool stateChanged(RenderObject*, ControlState) const;
-
- virtual bool supportsFocusRing(const RenderStyle* style) const;
- // A method asking if the theme's controls actually care about redrawing when hovered.
- virtual bool supportsHover(const RenderStyle* style) const { return style->affectedByHoverRules(); }
-
- virtual int baselinePosition(const RenderObject*) const;
-
- virtual Color platformActiveSelectionBackgroundColor() const;
- virtual Color platformInactiveSelectionBackgroundColor() const;
- virtual Color platformActiveSelectionForegroundColor() const;
- virtual Color platformInactiveSelectionForegroundColor() const;
- virtual Color platformTextSearchHighlightColor() const;
-
- virtual void systemFont(int, WebCore::FontDescription&) const {}
-
- virtual int minimumMenuListSize(RenderStyle*) const { return 0; }
-
-protected:
- virtual bool paintCheckbox(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r);
- virtual void setCheckboxSize(RenderStyle* style) const;
-
- virtual bool paintRadio(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r);
- virtual void setRadioSize(RenderStyle* style) const;
-
- virtual void adjustButtonStyle(CSSStyleSelector* selector, RenderStyle* style, WebCore::Element* e) const;
- virtual bool paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r);
-
- virtual void adjustTextFieldStyle(CSSStyleSelector* selector, RenderStyle* style, WebCore::Element* e) const;
- virtual bool paintTextField(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r);
-
- virtual void adjustTextAreaStyle(CSSStyleSelector* selector, RenderStyle* style, WebCore::Element* e) const;
- virtual bool paintTextArea(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r);
-
- bool paintCombo(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& ir);
-
- virtual void adjustListboxStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const;
- virtual void adjustMenuListStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const;
- virtual bool paintMenuList(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r);
-
- virtual void adjustMenuListButtonStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const;
- virtual bool paintMenuListButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r);
-
- virtual void adjustSearchFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
- virtual bool paintSearchField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
-
-private:
- void addIntrinsicMargins(RenderStyle* style) const;
- void close();
-
- bool supportsFocus(ControlPart appearance);
-};
-
-} // namespace WebCore
-
-#endif // RenderThemeAndroid_h
-
diff --git a/WebCore/platform/android/ScreenAndroid.cpp b/WebCore/platform/android/ScreenAndroid.cpp
deleted file mode 100644
index c1e43b0..0000000
--- a/WebCore/platform/android/ScreenAndroid.cpp
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright 2009, The Android Open Source Project
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#define LOG_TAG "WebCore"
-
-#include "config.h"
-#include "Screen.h"
-
-#include "FloatRect.h"
-#include "Widget.h"
-
-#undef LOG // FIXME: Still have to do this to get the log to show up
-#include "utils/Log.h"
-
-#include "ui/SurfaceComposerClient.h"
-#include "ui/PixelFormat.h"
-#include "ui/DisplayInfo.h"
-
-namespace WebCore {
-
-int screenDepth(Widget* page)
-{
- android::DisplayInfo info;
- android::SurfaceComposerClient::getDisplayInfo(android::DisplayID(0), &info);
- return info.pixelFormatInfo.bitsPerPixel;
-}
-
-int screenDepthPerComponent(Widget* page)
-{
- android::DisplayInfo info;
- android::SurfaceComposerClient::getDisplayInfo(android::DisplayID(0), &info);
- return info.pixelFormatInfo.bitsPerPixel;
-}
-
-bool screenIsMonochrome(Widget* page)
-{
- return false;
-}
-
-#ifdef ANDROID_ORIENTATION_SUPPORT
-int Screen::orientation() const
-{
- android::DisplayInfo info;
- android::SurfaceComposerClient::getDisplayInfo(
- android::DisplayID(0), &info);
- // getDisplayInfo returns an enum describing the orientation. Map the enum
- // to the values described here
- // (http://developer.apple.com/documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/chapter_8_section_6.html)
- switch (info.orientation) {
- case android::ISurfaceComposer::eOrientationDefault:
- return 0;
- case android::ISurfaceComposer::eOrientation90:
- return 90;
- case android::ISurfaceComposer::eOrientation180:
- return 180;
- case android::ISurfaceComposer::eOrientation270:
- return -90;
- default:
- LOGE("Bad orientation returned from getDisplayIndo %d",
- info.orientation);
- return 0;
- }
-}
-#endif
-
-// The only place I have seen these values used is
-// positioning popup windows. If we support multiple windows
-// they will be most likely full screen. Therefore,
-// the accuracy of these number are not too important.
-FloatRect screenRect(Widget* page)
-{
- android::DisplayInfo info;
- android::SurfaceComposerClient::getDisplayInfo(android::DisplayID(0), &info);
- return FloatRect(0.0, 0.0, info.w, info.h);
-}
-
-/*
-Scale functions don't seem to be needed. There is no code that
-call them, and they seem to only exist in ports and not in the core
-WebKit code - davidc
-FloatRect usableScreenRect(Widget* page)
-{
- return FloatRect();;
-}
-
-FloatRect scaleScreenRectToPageCoordinates(const FloatRect&, Widget*)
-{
- return FloatRect();;
-}
-
-FloatRect scalePageRectToScreenCoordinates(const FloatRect&, Widget*)
-{
- return FloatRect();;
-}
-
-float scaleFactor(Widget*)
-{
- return 1.0f;
-}
-*/
-
-// Similar screenRect, this function is commonly used by javascripts
-// to position and resize windows (usually to full screen).
-FloatRect screenAvailableRect(Widget*)
-{
- android::DisplayInfo info;
- android::SurfaceComposerClient::getDisplayInfo(android::DisplayID(0), &info);
- return FloatRect(0.0, 0.0, info.w, info.h);
-}
-
-}
diff --git a/WebCore/platform/android/ScrollViewAndroid.cpp b/WebCore/platform/android/ScrollViewAndroid.cpp
deleted file mode 100644
index 5622d8b..0000000
--- a/WebCore/platform/android/ScrollViewAndroid.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright 2007, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#define LOG_TAG "WebCore"
-
-#include "config.h"
-#include "ScrollView.h"
-
-#include "FloatRect.h"
-#include "FrameView.h"
-#include "IntRect.h"
-#include "WebCoreFrameBridge.h"
-#include "WebCoreViewBridge.h"
-#include "WebViewCore.h"
-
-/*
- This class implementation does NOT actually emulate the Qt ScrollView.
- It does provide an implementation that khtml will use to interact with
- WebKit's WebFrameView documentView and our NSScrollView subclass.
-
- ScrollView's view is a NSScrollView (or subclass of NSScrollView)
- in most cases. That scrollview is a subview of an
- WebCoreFrameView. The WebCoreFrameView's documentView will also be
- the scroll view's documentView.
-
- The WebCoreFrameView's size is the frame size. The WebCoreFrameView's documentView
- corresponds to the frame content size. The scrollview itself is autosized to the
- WebCoreFrameView's size (see Widget::resize).
-*/
-
-namespace WebCore {
-
-IntRect ScrollView::platformVisibleContentRect(bool includeScrollbars) const
-{
- IntRect rect = platformWidget()->getBounds();
- // This makes subframes draw correctly, since subframes cannot scroll.
- if (parent())
- return IntRect(0, 0, rect.width(), rect.height());
- return rect;
-}
-
-IntSize ScrollView::platformContentsSize() const
-{
- return m_contentsSize;
-}
-
-void ScrollView::platformSetScrollPosition(const WebCore::IntPoint& pt)
-{
- if (parent()) // don't attempt to scroll subframes; they're fully visible
- return;
- android::WebViewCore::getWebViewCore(this)->scrollTo(pt.x(), pt.y());
-}
-
-void ScrollView::platformScrollbarModes(ScrollbarMode& h, ScrollbarMode& v) const
-{
- h = v = ScrollbarAlwaysOff;
-}
-
-bool ScrollView::platformProhibitsScrolling()
-{
- if (!isFrameView())
- return false;
- FrameView* view = static_cast<FrameView*>(this);
- // We want to ignore requests to scroll that were not initiated by the user. An
- // example of this is when text is inserted into a textfield/area, which results in
- // a scroll. We ignore this because we now how to do this ourselves in the UI thread.
- // An example of it being initiated by the user is if the user clicks an anchor
- // element which simply scrolls the page.
- return !android::WebFrame::getWebFrame(view->frame())->userInitiatedClick();
-}
-
-void ScrollView::platformRepaintContentRectangle(const IntRect &rect, bool now)
-{
- android::WebViewCore::getWebViewCore(this)->contentInvalidate(rect);
-}
-
-#ifdef ANDROID_CAPTURE_OFFSCREEN_PAINTS
-void ScrollView::platformOffscreenContentRectangle(const IntRect& rect)
-{
- android::WebViewCore::getWebViewCore(this)->offInvalidate(rect);
-}
-#endif
-
-}
diff --git a/WebCore/platform/android/SearchPopupMenuAndroid.cpp b/WebCore/platform/android/SearchPopupMenuAndroid.cpp
deleted file mode 100644
index fa976e7..0000000
--- a/WebCore/platform/android/SearchPopupMenuAndroid.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2006, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "SearchPopupMenu.h"
-
-namespace WebCore {
-
-// Save the past searches stored in 'searchItems' to a database associated with 'name'
-void SearchPopupMenu::saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems)
-{
- //ASSERT(0); //notImplemented();
-}
-
-// Load past searches associated with 'name' from the database to 'searchItems'
-void SearchPopupMenu::loadRecentSearches(const AtomicString& name, Vector<String>& searchItems)
-{
- //ASSERT(0); //notImplemented();
-}
-
-// Create a search popup menu - not sure what else we have to do here
-SearchPopupMenu::SearchPopupMenu(PopupMenuClient* client) : PopupMenu(client)
-{
- //ASSERT(0); //notImplemented();
-}
-
-// functions new to Jun-07 tip of tree merge:
-bool SearchPopupMenu::enabled() { return false; }
-
-} // namespace WebCore
diff --git a/WebCore/platform/android/SharedTimerAndroid.cpp b/WebCore/platform/android/SharedTimerAndroid.cpp
deleted file mode 100644
index d797cfb..0000000
--- a/WebCore/platform/android/SharedTimerAndroid.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 2007, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#define LOG_TAG "Timers"
-
-#include "config.h"
-#include "SharedTimer.h"
-
-#include "SystemTime.h"
-#include "JavaSharedClient.h"
-#include "TimerClient.h"
-#include <utils/Log.h>
-
-using namespace android;
-
-namespace WebCore {
-
-// Single timer, shared to implement all the timers managed by the Timer class.
-// Not intended to be used directly; use the Timer class instead.
-void setSharedTimerFiredFunction(void (*f)())
-{
- if (JavaSharedClient::GetTimerClient())
- JavaSharedClient::GetTimerClient()->setSharedTimerCallback(f);
-}
-
-// The fire time is relative to the classic POSIX epoch of January 1, 1970,
-// as the result of currentTime() is.
-void setSharedTimerFireTime(double fireTime)
-{
- long long timeInMS = (long long)((fireTime - currentTime()) * 1000);
-
- LOGV("setSharedTimerFireTime: in %ld millisec", timeInMS);
- if (JavaSharedClient::GetTimerClient())
- JavaSharedClient::GetTimerClient()->setSharedTimer(timeInMS);
-}
-
-void stopSharedTimer()
-{
- if (JavaSharedClient::GetTimerClient())
- JavaSharedClient::GetTimerClient()->stopSharedTimer();
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/android/SystemTimeAndroid.cpp b/WebCore/platform/android/SystemTimeAndroid.cpp
deleted file mode 100644
index 9ac32dc..0000000
--- a/WebCore/platform/android/SystemTimeAndroid.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2007, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "SystemTime.h"
-
-#include <sys/time.h>
-
-namespace WebCore {
-
-double currentTime()
-{
- struct timeval tv;
-
- gettimeofday(&tv, (struct timezone *) NULL);
- double now = tv.tv_sec + (tv.tv_usec / 1000000.0);
-
- return now;
-}
-
-uint32_t get_thread_msec()
-{
-#if defined(HAVE_POSIX_CLOCKS)
- struct timespec tm;
-
- clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tm);
-
- return tm.tv_sec * 1000LL + tm.tv_nsec / 1000000;
-#else
- struct timeval tv;
-
- gettimeofday(&tv, NULL);
- return tv.tv_sec * 1000LL + tv.tv_usec / 1000;
-#endif
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/android/TemporaryLinkStubs.cpp b/WebCore/platform/android/TemporaryLinkStubs.cpp
deleted file mode 100644
index 01789f4..0000000
--- a/WebCore/platform/android/TemporaryLinkStubs.cpp
+++ /dev/null
@@ -1,965 +0,0 @@
-/*
- * Copyright 2007, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#define LOG_TAG "WebCore"
-
-#include "config.h"
-
-#define ANDROID_COMPILE_HACK
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "AXObjectCache.h"
-#include "CachedPage.h"
-#include "CachedResource.h"
-#include "CookieJar.h"
-#include "Console.h"
-#include "ContextMenu.h"
-#include "ContextMenuItem.h"
-#include "Clipboard.h"
-#include "CString.h"
-#include "Cursor.h"
-#include "Database.h"
-//#include "DebuggerCallFrame.h"
-#include "DocumentFragment.h"
-#include "DocumentLoader.h"
-#include "EditCommand.h"
-#include "Editor.h"
-#include "File.h"
-#include "FileList.h"
-#include "Font.h"
-#include "Frame.h"
-#include "FrameLoader.h"
-#include "FrameLoadRequest.h"
-#include "FrameView.h"
-#include "GraphicsContext.h"
-#include "HTMLFrameOwnerElement.h"
-#include "HTMLKeygenElement.h"
-#include "History.h"
-#include "Icon.h"
-#include "IconDatabase.h"
-#include "IconLoader.h"
-#include "IntPoint.h"
-#include "JavaScriptCallFrame.h"
-#include "JavaScriptDebugServer.h"
-#include "API/JSClassRef.h"
-#include "JavaScriptCallFrame.h"
-#include "JavaScriptProfile.h"
-#include "jni_utility.h"
-#include "KURL.h"
-#include "Language.h"
-#include "loader.h"
-#include "LocalizedStrings.h"
-#include "MainResourceLoader.h"
-#include "MIMETypeRegistry.h"
-#include "Node.h"
-#include "NotImplemented.h"
-#include "PageCache.h"
-#include "Pasteboard.h"
-#include "Path.h"
-#include "PluginInfoStore.h"
-#include "ResourceError.h"
-#include "ResourceHandle.h"
-#include "ResourceLoader.h"
-#include "Screen.h"
-#include "Scrollbar.h"
-#include "ScrollbarTheme.h"
-#include "SmartReplace.h"
-#include "Widget.h"
-
-using namespace WebCore;
-
-// This function is called when the frame view has changed the state of it's border.
-// iFrames, which are have a FrameView, are drawn with a 1px left/right border and 2px top/bottom border
-// Check function _shouldDrawBorder in WebFrameView.mm
-// We don't draw borders unless css draws them.
-//void FrameView::updateBorder() { verifiedOk(); }
-//int WebCore::screenDepthPerComponent(Widget*) { ASSERT(0); notImplemented(); return 0; }
-//bool WebCore::screenIsMonochrome(Widget*) { ASSERT(0); notImplemented(); return false; }
-
-/********************************************************/
-/* Completely empty stubs (mostly to allow DRT to run): */
-/********************************************************/
-
-// This function is used by Javascript to find out what the default language
-// the user has selected. It is used by the JS object Navigator.language
-// I guess this information should be mapped with the Accept-Language: HTTP header.
-String WebCore::defaultLanguage()
-{
- verifiedOk();
- return "en";
-}
-
-namespace WebCore {
-
-#if !defined(ANDROID_PLUGINS)
-// If plugins support is turned on, don't use these stubs.
-
-// Except for supportsMIMEType(), these Plugin functions are used by javascript's
-// navigator.plugins[] object to provide the list of available plugins. This is most
-// often used with to check to see if the browser supports Flash or which video
-// codec to use.
-// The supportsMIMEType() is used by the Frame to determine if a full screen instance
-// of a plugin can be used to render a mimetype that is not native to the browser.
-PluginInfo* PluginInfoStore::createPluginInfoForPluginAtIndex(unsigned)
-{
- ASSERT(0);
- return 0;
-}
-
-unsigned PluginInfoStore::pluginCount() const
-{
- verifiedOk();
- return 0;
-}
-
-String PluginInfoStore::pluginNameForMIMEType(const String&)
-{
- notImplemented();
- return String();
-}
-
-bool PluginInfoStore::supportsMIMEType(const String&)
-{
- verifiedOk();
- return false;
-}
-
-void refreshPlugins(bool)
-{
- verifiedOk();
-}
-
-#endif // !defined(ANDROID_PLUGINS)
-
-// This function tells the bridge that a resource was loaded from the cache and thus
-// the app may update progress with the amount of data loaded.
-void CheckCacheObjectStatus(DocLoader*, CachedResource*)
-{
- ASSERT(0);
- notImplemented();
-}
-
-// This class is used in conjunction with the File Upload form element, and
-// therefore relates to the above. When a file has been selected, an icon
-// representing the file type can be rendered next to the filename on the
-// web page. The icon for the file is encapsulated within this class.
-Icon::~Icon() { }
-void Icon::paint(GraphicsContext*, const IntRect&) { }
-
-// *** The following strings should be localized *** //
-
-// The following functions are used to fetch localized text for HTML form
-// elements submit and reset. These strings are used when the page author
-// has not specified any text for these buttons.
-String submitButtonDefaultLabel()
-{
- verifiedOk();
- return "Submit";
-}
-
-String resetButtonDefaultLabel()
-{
- verifiedOk();
- return "Reset";
-}
-
-// The alt text for an input element is not used visually, but rather is
-// used for accessability - eg reading the web page. See
-// HTMLInputElement::altText() for more information.
-String inputElementAltText()
-{
- notImplemented();
- return String();
-}
-
-// This is the string that appears before an input box when the HTML element
-// <ISINDEX> is used. The returned string is used if no PROMPT attribute is
-// provided.
-// note: Safari and FireFox use (too long for us imho) "This is a searchable index. Enter search keywords:"
-String searchableIndexIntroduction()
-{
- verifiedOk();
- return String("Enter search:");
-}
-
-// This function provides the default value for the CSS property:
-// -webkit-focus-ring-color
-// It is also related to the CSS property outline-color:
-Color focusRingColor()
-{
- verifiedOk();
- return 0xFF0000FF;
-}
-
-// LocalizedStrings
-String contextMenuItemTagOpenLinkInNewWindow()
-{
- ASSERT(0);
- return String();
-}
-
-String contextMenuItemTagDownloadLinkToDisk()
-{
- ASSERT(0);
- return String();
-}
-
-String contextMenuItemTagCopyLinkToClipboard()
-{
- ASSERT(0);
- return String();
-}
-
-String contextMenuItemTagOpenImageInNewWindow()
-{
- ASSERT(0);
- return String();
-}
-
-String contextMenuItemTagDownloadImageToDisk()
-{
- ASSERT(0);
- return String();
-}
-
-String contextMenuItemTagCopyImageToClipboard()
-{
- ASSERT(0);
- return String();
-}
-
-String contextMenuItemTagOpenFrameInNewWindow()
-{
- ASSERT(0);
- return String();
-}
-
-String contextMenuItemTagCopy()
-{
- ASSERT(0);
- return String();
-}
-
-String contextMenuItemTagGoBack()
-{
- ASSERT(0);
- return String();
-}
-
-String contextMenuItemTagGoForward()
-{
- ASSERT(0);
- return String();
-}
-
-String contextMenuItemTagStop()
-{
- ASSERT(0);
- return String();
-}
-
-String contextMenuItemTagReload()
-{
- ASSERT(0);
- return String();
-}
-
-String contextMenuItemTagCut()
-{
- ASSERT(0);
- return String();
-}
-
-String contextMenuItemTagPaste()
-{
- ASSERT(0);
- return String();
-}
-
-String contextMenuItemTagNoGuessesFound()
-{
- ASSERT(0);
- return String();
-}
-
-String contextMenuItemTagIgnoreSpelling()
-{
- ASSERT(0);
- return String();
-}
-
-String contextMenuItemTagLearnSpelling()
-{
- ASSERT(0);
- return String();
-}
-
-String contextMenuItemTagSearchWeb()
-{
- ASSERT(0);
- return String();
-}
-
-String contextMenuItemTagLookUpInDictionary()
-{
- ASSERT(0);
- return String();
-}
-
-String contextMenuItemTagOpenLink()
-{
- ASSERT(0);
- return String();
-}
-
-String contextMenuItemTagIgnoreGrammar()
-{
- ASSERT(0);
- return String();
-}
-
-String contextMenuItemTagSpellingMenu()
-{
- ASSERT(0);
- return String();
-}
-
-String contextMenuItemTagShowSpellingPanel(bool)
-{
- ASSERT(0);
- return String();
-}
-
-String contextMenuItemTagCheckSpelling()
-{
- ASSERT(0);
- return String();
-}
-
-String contextMenuItemTagCheckSpellingWhileTyping()
-{
- ASSERT(0);
- return String();
-}
-
-String contextMenuItemTagCheckGrammarWithSpelling()
-{
- ASSERT(0);
- return String();
-}
-
-String contextMenuItemTagFontMenu()
-{
- ASSERT(0);
- return String();
-}
-
-String contextMenuItemTagBold()
-{
- ASSERT(0);
- return String();
-}
-
-String contextMenuItemTagItalic()
-{
- ASSERT(0);
- return String();
-}
-
-String contextMenuItemTagUnderline()
-{
- ASSERT(0);
- return String();
-}
-
-String contextMenuItemTagOutline()
-{
- ASSERT(0);
- return String();
-}
-
-String contextMenuItemTagWritingDirectionMenu()
-{
- ASSERT(0);
- return String();
-}
-
-String contextMenuItemTagDefaultDirection()
-{
- ASSERT(0);
- return String();
-}
-
-String contextMenuItemTagLeftToRight()
-{
- ASSERT(0);
- return String();
-}
-
-String contextMenuItemTagRightToLeft()
-{
- ASSERT(0);
- return String();
-}
-
-} // namespace WebCore
-
-// FIXME, no support for spelling yet.
-Pasteboard* Pasteboard::generalPasteboard()
-{
- return new Pasteboard();
-}
-
-void Pasteboard::writeSelection(Range*, bool, Frame*)
-{
- notImplemented();
-}
-
-void Pasteboard::writeURL(const KURL&, const String&, Frame*)
-{
- notImplemented();
-}
-
-void Pasteboard::clear()
-{
- notImplemented();
-}
-
-bool Pasteboard::canSmartReplace()
-{
- notImplemented();
- return false;
-}
-
-PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame*, PassRefPtr<Range>, bool, bool&)
-{
- notImplemented();
- return 0;
-}
-
-String Pasteboard::plainText(Frame*)
-{
- notImplemented();
- return String();
-}
-
-Pasteboard::Pasteboard()
-{
- notImplemented();
-}
-
-Pasteboard::~Pasteboard()
-{
- notImplemented();
-}
-
-
-ContextMenu::ContextMenu(const HitTestResult& result) : m_hitTestResult(result)
-{
- ASSERT(0);
- notImplemented();
-}
-
-ContextMenu::~ContextMenu()
-{
- ASSERT(0);
- notImplemented();
-}
-
-void ContextMenu::appendItem(ContextMenuItem&)
-{
- ASSERT(0);
- notImplemented();
-}
-
-void ContextMenu::setPlatformDescription(PlatformMenuDescription menu)
-{
- ASSERT(0);
- m_platformDescription = menu;
-}
-
-PlatformMenuDescription ContextMenu::platformDescription() const
-{
- ASSERT(0);
- return m_platformDescription;
-}
-
-ContextMenuItem::ContextMenuItem(PlatformMenuItemDescription)
-{
- ASSERT(0);
- notImplemented();
-}
-
-ContextMenuItem::ContextMenuItem(ContextMenu*)
-{
- ASSERT(0);
- notImplemented();
-}
-
-ContextMenuItem::ContextMenuItem(ContextMenuItemType, ContextMenuAction, const String&, ContextMenu*)
-{
- ASSERT(0);
- notImplemented();
-}
-
-ContextMenuItem::~ContextMenuItem()
-{
- ASSERT(0);
- notImplemented();
-}
-
-PlatformMenuItemDescription ContextMenuItem::releasePlatformDescription()
-{
- ASSERT(0);
- notImplemented();
- return m_platformDescription;
-}
-
-ContextMenuItemType ContextMenuItem::type() const
-{
- ASSERT(0);
- notImplemented();
- return ActionType;
-}
-
-void ContextMenuItem::setType(ContextMenuItemType)
-{
- ASSERT(0);
- notImplemented();
-}
-
-ContextMenuAction ContextMenuItem::action() const
-{
- ASSERT(0);
- notImplemented();
- return ContextMenuItemTagNoAction;
-}
-
-void ContextMenuItem::setAction(ContextMenuAction)
-{
- ASSERT(0);
- notImplemented();
-}
-
-String ContextMenuItem::title() const
-{
- ASSERT(0);
- notImplemented();
- return String();
-}
-
-void ContextMenuItem::setTitle(const String&)
-{
- ASSERT(0);
- notImplemented();
-}
-
-PlatformMenuDescription ContextMenuItem::platformSubMenu() const
-{
- ASSERT(0);
- notImplemented();
- return 0;
-}
-
-void ContextMenuItem::setSubMenu(ContextMenu*)
-{
- ASSERT(0);
- notImplemented();
-}
-
-void ContextMenuItem::setChecked(bool)
-{
- ASSERT(0);
- notImplemented();
-}
-
-void ContextMenuItem::setEnabled(bool)
-{
- ASSERT(0);
- notImplemented();
-}
-
-namespace WebCore {
-
-float userIdleTime()
-{
- notImplemented();
- return 0;
-}
-
-// systemBeep() is called by the Editor to indicate that there was nothing to copy, and may be called from
-// other places too.
-void systemBeep()
-{
- notImplemented();
-}
-
-}
-
-// functions new to Jun-07 tip of tree merge:
-
-// void WebCore::CachedPage::close() {}
-
-//void WebCore::Frame::print() {}
-// void WebCore::Frame::issueTransposeCommand() {}
-//void WebCore::Frame::cleanupPlatformScriptObjects() {}
-// void WebCore::Frame::dashboardRegionsChanged() {}
-//bool WebCore::Frame::isCharacterSmartReplaceExempt(unsigned short, bool) { return false; }
-
-void* WebCore::Frame::dragImageForSelection()
-{
- return 0;
-}
-
-
-WebCore::String WebCore::MIMETypeRegistry::getMIMETypeForExtension(WebCore::String const&)
-{
- return WebCore::String();
-}
-
-void WebCore::Pasteboard::writeImage(WebCore::Node*, WebCore::KURL const&, WebCore::String const&) {}
-
-namespace WebCore {
-
-IntSize dragImageSize(void*)
-{
- return IntSize(0, 0);
-}
-
-void deleteDragImage(void*) {}
-void* createDragImageFromImage(Image*)
-{
- return 0;
-}
-
-void* dissolveDragImageToFraction(void*, float)
-{
- return 0;
-}
-
-void* createDragImageIconForCachedImage(CachedImage*)
-{
- return 0;
-}
-
-Cursor dummyCursor;
-const Cursor& zoomInCursor()
-{
- return dummyCursor;
-}
-
-const Cursor& zoomOutCursor()
-{
- return dummyCursor;
-}
-
-const Cursor& notAllowedCursor()
-{
- return dummyCursor;
-}
-
-void* scaleDragImage(void*, FloatSize)
-{
- return 0;
-}
-
-String searchMenuRecentSearchesText()
-{
- return String();
-}
-
-String searchMenuNoRecentSearchesText()
-{
- return String();
-}
-
-String searchMenuClearRecentSearchesText()
-{
- return String();
-}
-
-Vector<String> supportedKeySizes()
-{
- notImplemented();
- return Vector<String>();
-}
-
-String signedPublicKeyAndChallengeString(unsigned int, String const&, WebCore::KURL const&)
-{
- return String();
-}
-
-} // namespace WebCore
-
-// added for Nov-16-07 ToT integration
-//namespace WebCore {
-//void Frame::clearPlatformScriptObjects() { notImplemented(); }
-
-//}
-
-// functions new to Feb-19 tip of tree merge:
-namespace WebCore {
-// isCharacterSmartReplaceExempt is defined in SmartReplaceICU.cpp; in theory, we could use that one
-// but we don't support all of the required icu functions
-bool isCharacterSmartReplaceExempt(UChar32, bool)
-{
- notImplemented();
- return false;
-}
-
-} // WebCore
-
-int MakeDataExecutable;
-
-// functions new to Mar-2 tip of tree merge:
-String KURL::fileSystemPath() const
-{
- notImplemented();
- return String();
-}
-
-
-// functions new to Jun-1 tip of tree merge:
-PassRefPtr<SharedBuffer> SharedBuffer::createWithContentsOfFile(const String&)
-{
- notImplemented();
- return 0;
-}
-
-
-namespace JSC { namespace Bindings {
-bool dispatchJNICall(ExecState*, void const*, _jobject*, bool, JNIType,
- _jmethodID*, jvalue*, jvalue&, char const*, JSValue*&)
-{
- notImplemented();
- return false;
-}
-
-} } // namespace JSC::Bindings
-
-char* dirname(const char*)
-{
- notImplemented();
- return 0;
-}
-
- // new as of SVN change 36269, Sept 8, 2008
-const String& Database::databaseInfoTableName()
-{
- notImplemented();
- static const String dummy;
- return dummy;
-}
-
- // new as of SVN change 38068, Nov 5, 2008
-namespace WebCore {
-void prefetchDNS(const String&)
-{
- notImplemented();
-}
-
-void getSupportedKeySizes(Vector<String>&)
-{
- notImplemented();
-}
-
-PassRefPtr<Icon> Icon::createIconForFile(const String&)
-{
- notImplemented();
- return 0;
-}
-
-PassRefPtr<Icon> Icon::createIconForFiles(const Vector<String>&)
-{
- notImplemented();
- return 0;
-}
-
-// ScrollbarTheme::nativeTheme() is called by RenderTextControl::calcPrefWidths()
-// like this: scrollbarSize = ScrollbarTheme::nativeTheme()->scrollbarThickness();
-// with this comment:
-// // FIXME: We should get the size of the scrollbar from the RenderTheme instead.
-// since our text control doesn't have scrollbars, the default size of 0 width should be
-// ok. notImplemented() is commented out below so that we can find other unresolved
-// unimplemented functions.
-ScrollbarTheme* ScrollbarTheme::nativeTheme()
-{
- /* notImplemented(); */
- static ScrollbarTheme theme;
- return &theme;
-}
-
-JSC::JSValue* toJS(JSC::ExecState*, JSC::Profile*)
-{
- notImplemented();
- return 0;
-}
-
-} // namespace WebCore
-
-FileList::FileList()
-{
- notImplemented();
-}
-
-File* FileList::item(unsigned index) const
-{
- notImplemented();
- return 0;
-}
-
-AXObjectCache::~AXObjectCache()
-{
- notImplemented();
-}
-
-// This value turns on or off the Mac specific Accessibility support.
-bool AXObjectCache::gAccessibilityEnabled = false;
-bool AXObjectCache::gAccessibilityEnhancedUserInterfaceEnabled = false;
-
-void AXObjectCache::childrenChanged(RenderObject*)
-{
- notImplemented();
-}
-
-void AXObjectCache::remove(RenderObject*)
-{
- notImplemented();
-}
-
-using namespace JSC;
-
-
-OpaqueJSClass::~OpaqueJSClass()
-{
- notImplemented();
-}
-
-OpaqueJSClassContextData::~OpaqueJSClassContextData()
-{
- notImplemented();
-}
-
-namespace WebCore {
-
-JSC::JSValue* JavaScriptCallFrame::evaluate(JSC::UString const&, JSC::JSValue*&) const
-{
- notImplemented();
- return 0;
-}
-
-const JSC::ScopeChainNode* JavaScriptCallFrame::scopeChain() const
-{
- notImplemented();
- return 0;
-}
-
-JSC::JSObject* JavaScriptCallFrame::thisObject() const
-{
- notImplemented();
- return 0;
-}
-
-JSC::DebuggerCallFrame::Type JavaScriptCallFrame::type() const
-{
- notImplemented();
- return (JSC::DebuggerCallFrame::Type) 0;
-}
-
-JavaScriptCallFrame* JavaScriptCallFrame::caller()
-{
- notImplemented();
- return 0;
-}
-
-String JavaScriptCallFrame::functionName() const
-{
- notImplemented();
- return String();
-}
-}
-
-JavaScriptDebugServer::JavaScriptDebugServer() :
- m_recompileTimer(this, 0)
-{
- notImplemented();
-}
-
-JavaScriptDebugServer::~JavaScriptDebugServer()
-{
- notImplemented();
-}
-
-JavaScriptDebugServer& JavaScriptDebugServer::shared()
-{
- static JavaScriptDebugServer server;
- notImplemented();
- return server;
-}
-
-void JavaScriptDebugServer::atStatement(const DebuggerCallFrame&, int, int)
-{
- notImplemented();
-}
-
-void JavaScriptDebugServer::callEvent(const DebuggerCallFrame&, int, int)
-{
- notImplemented();
-}
-
-void JavaScriptDebugServer::didExecuteProgram(const DebuggerCallFrame&, int, int)
-{
- notImplemented();
-}
-
-void JavaScriptDebugServer::didReachBreakpoint(const DebuggerCallFrame&, int, int)
-{
- notImplemented();
-}
-
-void JavaScriptDebugServer::exception(const DebuggerCallFrame&, int, int)
-{
- notImplemented();
-}
-
-void JavaScriptDebugServer::sourceParsed(ExecState*, const SourceCode&, int, const UString&)
-{
- notImplemented();
-}
-
-void JavaScriptDebugServer::pageCreated(Page*)
-{
- notImplemented();
-}
-
-void JavaScriptDebugServer::returnEvent(const DebuggerCallFrame&, int, int)
-{
- notImplemented();
-}
-
-void JavaScriptDebugServer::willExecuteProgram(const DebuggerCallFrame&, int, int)
-{
- notImplemented();
-}
diff --git a/WebCore/platform/android/TextBoundaries.cpp b/WebCore/platform/android/TextBoundaries.cpp
deleted file mode 100644
index 457a36e..0000000
--- a/WebCore/platform/android/TextBoundaries.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright 2009, The Android Open Source Project
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "TextBoundaries.h"
-
-#include <unicode/ubrk.h>
-
-#include "TextBreakIterator.h"
-
-namespace WebCore {
-
-int findNextWordFromIndex(const UChar* chars, int len, int position, bool forward)
-{
- UBreakIterator* it = wordBreakIterator(chars, len);
-
- int newPosition = position;
-
- if (forward) {
- position = ubrk_following(it, position);
- while (position != UBRK_DONE) {
- // We stop searching when the character preceeding the break
- // is alphanumeric.
- if (position < len && u_isalnum(chars[position - 1]))
- return position;
-
- position = ubrk_following(it, position);
- }
-
- return len;
- } else {
- position = ubrk_preceding(it, position);
- while (position != UBRK_DONE) {
- // We stop searching when the character following the break
- // is alphanumeric.
- if (position > 0 && u_isalnum(chars[position]))
- return position;
-
- position = ubrk_preceding(it, position);
- }
-
- return 0;
- }
-}
-
-void findWordBoundary(const UChar* chars, int len, int position, int* start, int* end)
-{
- UBreakIterator* it = wordBreakIterator(chars, len);
- *end = ubrk_following(it, position);
- if (*end < 0)
- *end = ubrk_last(it);
- *start = ubrk_previous(it);
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/android/TextBreakIteratorInternalICU.cpp b/WebCore/platform/android/TextBreakIteratorInternalICU.cpp
deleted file mode 100644
index 9bebe74..0000000
--- a/WebCore/platform/android/TextBreakIteratorInternalICU.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2007, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "TextBreakIteratorInternalICU.h"
-
-namespace WebCore {
-
-const char* currentTextBreakLocaleID()
-{
- return "en_us";
-}
-
-}
diff --git a/WebCore/platform/android/WidgetAndroid.cpp b/WebCore/platform/android/WidgetAndroid.cpp
deleted file mode 100644
index 84ab26c..0000000
--- a/WebCore/platform/android/WidgetAndroid.cpp
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright 2007, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Widget.h"
-
-#include "Font.h"
-#include "FrameView.h"
-#include "GraphicsContext.h"
-#include "NotImplemented.h"
-#include "WebCoreFrameBridge.h"
-#include "WebCoreViewBridge.h"
-#include "WebViewCore.h"
-
-namespace WebCore {
-
-Widget::Widget(PlatformWidget widget)
-{
- init(widget);
-}
-
-Widget::~Widget()
-{
- ASSERT(!parent());
- releasePlatformWidget();
-}
-
-IntRect Widget::frameRect() const
-{
- // FIXME: use m_frame instead?
- if (!platformWidget())
- return IntRect(0, 0, 0, 0);
- return platformWidget()->getBounds();
-}
-
-void Widget::setFocus()
-{
- notImplemented();
-}
-
-void Widget::paint(GraphicsContext* ctx, const IntRect& r)
-{
- // FIXME: in what case, will this be called for the top frame?
- if (!platformWidget())
- return;
- platformWidget()->draw(ctx, r);
-}
-
-void Widget::releasePlatformWidget()
-{
- Release(platformWidget());
-}
-
-void Widget::retainPlatformWidget()
-{
- Retain(platformWidget());
-}
-
-void Widget::setCursor(const Cursor& cursor)
-{
- notImplemented();
-}
-
-void Widget::show()
-{
- notImplemented();
-}
-
-void Widget::hide()
-{
- notImplemented();
-}
-
-void Widget::setFrameRect(const IntRect& rect)
-{
- // FIXME: set m_frame instead?
- // platformWidget() is NULL when called from Scrollbar
- if (!platformWidget())
- return;
- platformWidget()->setLocation(rect.x(), rect.y());
- platformWidget()->setSize(rect.width(), rect.height());
-}
-
-void Widget::setIsSelected(bool isSelected)
-{
- notImplemented();
-}
-
-int Widget::screenWidth() const
-{
- const Widget* widget = this;
- while (!widget->isFrameView()) {
- widget = widget->parent();
- if (!widget)
- break;
- }
- if (!widget)
- return 0;
-
- return android::WebViewCore::getWebViewCore(
- static_cast<const ScrollView*>(widget))->screenWidth();
-}
-
-} // WebCore namepsace
diff --git a/WebCore/platform/cf/FileSystemCF.cpp b/WebCore/platform/cf/FileSystemCF.cpp
deleted file mode 100644
index b6cc645..0000000
--- a/WebCore/platform/cf/FileSystemCF.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#import "config.h"
-#import "FileSystem.h"
-
-#import "CString.h"
-#import "PlatformString.h"
-#import <wtf/RetainPtr.h>
-
-namespace WebCore {
-
-CString fileSystemRepresentation(const String& path)
-{
- RetainPtr<CFStringRef> cfString(AdoptCF, path.createCFString());
-
- if (!cfString)
- return CString();
-
- CFIndex size = CFStringGetMaximumSizeOfFileSystemRepresentation(cfString.get());
-
- char* buffer;
- CString string = CString::newUninitialized(size, buffer);
-
- if (!CFStringGetFileSystemRepresentation(cfString.get(), buffer, size)) {
- LOG_ERROR("Failed to get filesystem representation to create CString from cfString");
- return CString();
- }
-
- return string;
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/cf/KURLCFNet.cpp b/WebCore/platform/cf/KURLCFNet.cpp
deleted file mode 100644
index f060b28..0000000
--- a/WebCore/platform/cf/KURLCFNet.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2004, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "KURL.h"
-
-#include <wtf/RetainPtr.h>
-#include <CoreFoundation/CFURL.h>
-
-using namespace std;
-
-namespace WebCore {
-
-KURL::KURL(CFURLRef url)
-{
- if (!url) {
- parse(0, 0);
- return;
- }
-
- CFIndex bytesLength = CFURLGetBytes(url, 0, 0);
- Vector<char, 512> buffer(bytesLength + 6); // 5 for "file:", 1 for null character to end C string
- char* bytes = &buffer[5];
- CFURLGetBytes(url, reinterpret_cast<UInt8*>(bytes), bytesLength);
- bytes[bytesLength] = '\0';
- if (bytes[0] != '/') {
- parse(bytes, 0);
- return;
- }
-
- buffer[0] = 'f';
- buffer[1] = 'i';
- buffer[2] = 'l';
- buffer[3] = 'e';
- buffer[4] = ':';
-
- parse(buffer.data(), 0);
-}
-
-CFURLRef KURL::createCFURL() const
-{
- // FIXME: What should this return for invalid URLs?
- // Currently it throws away the high bytes of the characters in the string in that case,
- // which is clearly wrong.
-
- Vector<char, 512> buffer;
- copyToBuffer(buffer);
-
- // NOTE: We use UTF-8 here since this encoding is used when computing strings when returning URL components
- // (e.g calls to NSURL -path). However, this function is not tolerant of illegal UTF-8 sequences, which
- // could either be a malformed string or bytes in a different encoding, like Shift-JIS, so we fall back
- // onto using ISO Latin-1 in those cases.
- CFURLRef result = CFURLCreateAbsoluteURLWithBytes(0, reinterpret_cast<const UInt8*>(buffer.data()), buffer.size(), kCFStringEncodingUTF8, 0, true);
- if (!result)
- result = CFURLCreateAbsoluteURLWithBytes(0, reinterpret_cast<const UInt8*>(buffer.data()), buffer.size(), kCFStringEncodingISOLatin1, 0, true);
- return result;
-}
-
-String KURL::fileSystemPath() const
-{
- RetainPtr<CFURLRef> cfURL(AdoptCF, createCFURL());
- if (!cfURL)
- return String();
-
-#if PLATFORM(WIN)
- CFURLPathStyle pathStyle = kCFURLWindowsPathStyle;
-#else
- CFURLPathStyle pathStyle = kCFURLPOSIXPathStyle;
-#endif
- return RetainPtr<CFStringRef>(AdoptCF, CFURLCopyFileSystemPath(cfURL.get(), pathStyle)).get();
-}
-
-}
diff --git a/WebCore/platform/cf/SchedulePair.cpp b/WebCore/platform/cf/SchedulePair.cpp
deleted file mode 100644
index ee5ae95..0000000
--- a/WebCore/platform/cf/SchedulePair.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "SchedulePair.h"
-
-namespace WebCore {
-
-SchedulePair::SchedulePair(CFRunLoopRef runLoop, CFStringRef mode)
- : m_runLoop(runLoop)
-{
- if (mode)
- m_mode.adoptCF(CFStringCreateCopy(0, mode));
-}
-
-bool SchedulePair::operator==(const SchedulePair& other) const
-{
- if (runLoop() != other.runLoop())
- return false;
- CFStringRef thisMode = mode();
- CFStringRef otherMode = other.mode();
- if (!thisMode || !otherMode)
- return thisMode == otherMode;
- return CFEqual(thisMode, otherMode);
-}
-
-} // namespace
diff --git a/WebCore/platform/cf/SchedulePair.h b/WebCore/platform/cf/SchedulePair.h
deleted file mode 100644
index ed58406..0000000
--- a/WebCore/platform/cf/SchedulePair.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef SchedulePair_h
-#define SchedulePair_h
-
-#include "PlatformString.h"
-#include <wtf/HashSet.h>
-#include <wtf/RetainPtr.h>
-
-#if PLATFORM(MAC)
-#ifdef __OBJC__
-@class NSRunLoop;
-#else
-class NSRunLoop;
-#endif
-#endif
-
-namespace WebCore {
-
-class SchedulePair : public RefCounted<SchedulePair> {
-public:
- static PassRefPtr<SchedulePair> create(CFRunLoopRef runLoop, CFStringRef mode) { return adoptRef(new SchedulePair(runLoop, mode)); }
-
-#if PLATFORM(MAC)
- static PassRefPtr<SchedulePair> create(NSRunLoop* runLoop, CFStringRef mode) { return adoptRef(new SchedulePair(runLoop, mode)); }
- NSRunLoop* nsRunLoop() const { return m_nsRunLoop.get(); }
-#endif
-
- CFRunLoopRef runLoop() const { return m_runLoop.get(); }
- CFStringRef mode() const { return m_mode.get(); }
-
- bool operator==(const SchedulePair& other) const;
-
-private:
- SchedulePair(CFRunLoopRef, CFStringRef);
-
-#if PLATFORM(MAC)
- SchedulePair(NSRunLoop*, CFStringRef);
- RetainPtr<NSRunLoop*> m_nsRunLoop;
-#endif
-
- RetainPtr<CFRunLoopRef> m_runLoop;
- RetainPtr<CFStringRef> m_mode;
-};
-
-struct SchedulePairHash {
- static unsigned hash(const RefPtr<SchedulePair>& pair)
- {
- uintptr_t hashCodes[2] = { reinterpret_cast<uintptr_t>(pair->runLoop()), pair->mode() ? CFHash(pair->mode()) : 0 };
- return StringImpl::computeHash(reinterpret_cast<UChar*>(hashCodes), sizeof(hashCodes) / sizeof(UChar));
- }
-
- static bool equal(const RefPtr<SchedulePair>& a, const RefPtr<SchedulePair>& b) { return a == b; }
-
- static const bool safeToCompareToEmptyOrDeleted = true;
-};
-
-typedef HashSet<RefPtr<SchedulePair>, SchedulePairHash> SchedulePairHashSet;
-
-} // namespace WebCore
-
-#endif
diff --git a/WebCore/platform/cf/SharedBufferCF.cpp b/WebCore/platform/cf/SharedBufferCF.cpp
deleted file mode 100644
index c0e471a..0000000
--- a/WebCore/platform/cf/SharedBufferCF.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "config.h"
-#include "SharedBuffer.h"
-
-namespace WebCore {
-
-SharedBuffer::SharedBuffer(CFDataRef cfData)
- : m_cfData(cfData)
-{
-}
-
-// Mac is a CF platform but has an even more efficient version of this method,
-// so only use this version for non-Mac
-#if !PLATFORM(MAC)
-CFDataRef SharedBuffer::createCFData()
-{
- if (m_cfData) {
- CFRetain(m_cfData.get());
- return m_cfData.get();
- }
-
- return CFDataCreate(0, reinterpret_cast<const UInt8*>(m_buffer.data()), m_buffer.size());
-}
-#endif
-
-bool SharedBuffer::hasPlatformData() const
-{
- return m_cfData;
-}
-
-const char* SharedBuffer::platformData() const
-{
- return (const char*)CFDataGetBytePtr(m_cfData.get());
-}
-
-unsigned SharedBuffer::platformDataSize() const
-{
- return CFDataGetLength(m_cfData.get());
-}
-
-void SharedBuffer::maybeTransferPlatformData()
-{
- if (!m_cfData)
- return;
-
- ASSERT(m_buffer.size() == 0);
-
- m_buffer.append((const char*)CFDataGetBytePtr(m_cfData.get()), CFDataGetLength(m_cfData.get()));
-
- m_cfData = 0;
-}
-
-void SharedBuffer::clearPlatformData()
-{
- m_cfData = 0;
-}
-
-}
diff --git a/WebCore/platform/graphics/AffineTransform.cpp b/WebCore/platform/graphics/AffineTransform.cpp
deleted file mode 100644
index fdeba44..0000000
--- a/WebCore/platform/graphics/AffineTransform.cpp
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "AffineTransform.h"
-
-#include "FloatRect.h"
-#include "IntRect.h"
-
-#include <wtf/MathExtras.h>
-
-namespace WebCore {
-
-static void affineTransformDecompose(const AffineTransform& matrix, double sr[9])
-{
- AffineTransform m(matrix);
-
- // Compute scaling factors
- double sx = sqrt(m.a() * m.a() + m.b() * m.b());
- double sy = sqrt(m.c() * m.c() + m.d() * m.d());
-
- /* Compute cross product of transformed unit vectors. If negative,
- one axis was flipped. */
-
- if (m.a() * m.d() - m.c() * m.b() < 0.0) {
- // Flip axis with minimum unit vector dot product
-
- if (m.a() < m.d())
- sx = -sx;
- else
- sy = -sy;
- }
-
- // Remove scale from matrix
-
- m.scale(1.0 / sx, 1.0 / sy);
-
- // Compute rotation
-
- double angle = atan2(m.b(), m.a());
-
- // Remove rotation from matrix
-
- m.rotate(rad2deg(-angle));
-
- // Return results
-
- sr[0] = sx; sr[1] = sy; sr[2] = angle;
- sr[3] = m.a(); sr[4] = m.b();
- sr[5] = m.c(); sr[6] = m.d();
- sr[7] = m.e(); sr[8] = m.f();
-}
-
-static void affineTransformCompose(AffineTransform& m, const double sr[9])
-{
- m.setA(sr[3]);
- m.setB(sr[4]);
- m.setC(sr[5]);
- m.setD(sr[6]);
- m.setE(sr[7]);
- m.setF(sr[8]);
- m.rotate(rad2deg(sr[2]));
- m.scale(sr[0], sr[1]);
-}
-
-bool AffineTransform::isInvertible() const
-{
- return det() != 0.0;
-}
-
-AffineTransform& AffineTransform::multiply(const AffineTransform& other)
-{
- return (*this) *= other;
-}
-
-AffineTransform& AffineTransform::scale(double s)
-{
- return scale(s, s);
-}
-
-AffineTransform& AffineTransform::scaleNonUniform(double sx, double sy)
-{
- return scale(sx, sy);
-}
-
-AffineTransform& AffineTransform::rotateFromVector(double x, double y)
-{
- return rotate(rad2deg(atan2(y, x)));
-}
-
-AffineTransform& AffineTransform::flipX()
-{
- return scale(-1.0f, 1.0f);
-}
-
-AffineTransform& AffineTransform::flipY()
-{
- return scale(1.0f, -1.0f);
-}
-
-AffineTransform& AffineTransform::skew(double angleX, double angleY)
-{
- return shear(tan(deg2rad(angleX)), tan(deg2rad(angleY)));
-}
-
-AffineTransform& AffineTransform::skewX(double angle)
-{
- return shear(tan(deg2rad(angle)), 0.0f);
-}
-
-AffineTransform& AffineTransform::skewY(double angle)
-{
- return shear(0.0f, tan(deg2rad(angle)));
-}
-
-AffineTransform makeMapBetweenRects(const FloatRect& source, const FloatRect& dest)
-{
- AffineTransform transform;
- transform.translate(dest.x() - source.x(), dest.y() - source.y());
- transform.scale(dest.width() / source.width(), dest.height() / source.height());
- return transform;
-}
-
-IntPoint AffineTransform::mapPoint(const IntPoint& point) const
-{
- double x2, y2;
- map(point.x(), point.y(), &x2, &y2);
-
- // Round the point.
- return IntPoint(lround(x2), lround(y2));
-}
-
-FloatPoint AffineTransform::mapPoint(const FloatPoint& point) const
-{
- double x2, y2;
- map(point.x(), point.y(), &x2, &y2);
-
- return FloatPoint(static_cast<float>(x2), static_cast<float>(y2));
-}
-
-void AffineTransform::blend(const AffineTransform& from, double progress)
-{
- double srA[9], srB[9];
-
- affineTransformDecompose(from, srA);
- affineTransformDecompose(*this, srB);
-
- // If x-axis of one is flipped, and y-axis of the other, convert to an unflipped rotation.
- if ((srA[0] < 0.0 && srB[1] < 0.0) || (srA[1] < 0.0 && srB[0] < 0.0)) {
- srA[0] = -srA[0];
- srA[1] = -srA[1];
- srA[2] += srA[2] < 0 ? piDouble : -piDouble;
- }
-
- // Don't rotate the long way around.
- srA[2] = fmod(srA[2], 2.0 * piDouble);
- srB[2] = fmod(srB[2], 2.0 * piDouble);
-
- if (fabs(srA[2] - srB[2]) > piDouble) {
- if (srA[2] > srB[2])
- srA[2] -= piDouble * 2.0;
- else
- srB[2] -= piDouble * 2.0;
- }
-
- for (int i = 0; i < 9; i++)
- srA[i] = srA[i] + progress * (srB[i] - srA[i]);
-
- affineTransformCompose(*this, srA);
-}
-
-}
diff --git a/WebCore/platform/graphics/AffineTransform.h b/WebCore/platform/graphics/AffineTransform.h
deleted file mode 100644
index 37c6033..0000000
--- a/WebCore/platform/graphics/AffineTransform.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef AffineTransform_h
-#define AffineTransform_h
-
-#if PLATFORM(CG)
-#include <CoreGraphics/CGAffineTransform.h>
-typedef CGAffineTransform PlatformAffineTransform;
-#elif PLATFORM(QT)
-#include <QMatrix>
-typedef QMatrix PlatformAffineTransform;
-#elif PLATFORM(CAIRO)
-#include <cairo.h>
-typedef cairo_matrix_t PlatformAffineTransform;
-#elif PLATFORM(SGL)
-#include "SkMatrix.h"
-typedef SkMatrix PlatformAffineTransform;
-#elif PLATFORM(SKIA)
-#include "SkMatrix.h"
-typedef SkMatrix PlatformAffineTransform;
-#elif PLATFORM(WX) && USE(WXGC)
-#include <wx/defs.h>
-#include <wx/graphics.h>
-typedef wxGraphicsMatrix PlatformAffineTransform;
-#endif
-
-namespace WebCore {
-
-class IntPoint;
-class IntRect;
-class FloatPoint;
-class FloatRect;
-
-class AffineTransform {
-public:
- AffineTransform();
- AffineTransform(double a, double b, double c, double d, double e, double f);
-#if !PLATFORM(WX) || USE(WXGC)
- AffineTransform(const PlatformAffineTransform&);
-#endif
-
- void setMatrix(double a, double b, double c, double d, double e, double f);
- void map(double x, double y, double *x2, double *y2) const;
-
- // Rounds the mapped point to the nearest integer value.
- IntPoint mapPoint(const IntPoint&) const;
-
- FloatPoint mapPoint(const FloatPoint&) const;
-
- // Rounds the resulting mapped rectangle out. This is helpful for bounding
- // box computations but may not be what is wanted in other contexts.
- IntRect mapRect(const IntRect&) const;
-
- FloatRect mapRect(const FloatRect&) const;
-
- bool isIdentity() const;
-
- double a() const;
- void setA(double a);
-
- double b() const;
- void setB(double b);
-
- double c() const;
- void setC(double c);
-
- double d() const;
- void setD(double d);
-
- double e() const;
- void setE(double e);
-
- double f() const;
- void setF(double f);
-
- void reset();
-
- AffineTransform& multiply(const AffineTransform&);
- AffineTransform& scale(double);
- AffineTransform& scale(double sx, double sy);
- AffineTransform& scaleNonUniform(double sx, double sy);
- AffineTransform& rotate(double d);
- AffineTransform& rotateFromVector(double x, double y);
- AffineTransform& translate(double tx, double ty);
- AffineTransform& shear(double sx, double sy);
- AffineTransform& flipX();
- AffineTransform& flipY();
- AffineTransform& skew(double angleX, double angleY);
- AffineTransform& skewX(double angle);
- AffineTransform& skewY(double angle);
-
- double det() const;
- bool isInvertible() const;
- AffineTransform inverse() const;
-
- void blend(const AffineTransform& from, double progress);
-
-#if !PLATFORM(WX) || USE(WXGC)
- operator PlatformAffineTransform() const;
-#endif
-
- bool operator==(const AffineTransform&) const;
- bool operator!=(const AffineTransform& other) const { return !(*this == other); }
- AffineTransform& operator*=(const AffineTransform&);
- AffineTransform operator*(const AffineTransform&);
-
-private:
-#if !PLATFORM(WX) || USE(WXGC)
- PlatformAffineTransform m_transform;
-#endif
-};
-
-AffineTransform makeMapBetweenRects(const FloatRect& source, const FloatRect& dest);
-
-} // namespace WebCore
-
-#endif // AffineTransform_h
diff --git a/WebCore/platform/graphics/BitmapImage.cpp b/WebCore/platform/graphics/BitmapImage.cpp
deleted file mode 100644
index 4b21de0..0000000
--- a/WebCore/platform/graphics/BitmapImage.cpp
+++ /dev/null
@@ -1,438 +0,0 @@
-/*
- * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
- * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "BitmapImage.h"
-
-#include "FloatRect.h"
-#include "ImageObserver.h"
-#include "IntRect.h"
-#include "PlatformString.h"
-#include "SystemTime.h"
-#include "Timer.h"
-#include <wtf/Vector.h>
-#include "MIMETypeRegistry.h"
-
-namespace WebCore {
-
-// Animated images >5MB are considered large enough that we'll only hang on to
-// one frame at a time.
-const unsigned cLargeAnimationCutoff = 5242880;
-
-// When an animated image is more than five minutes out of date, don't try to
-// resync on repaint, so we don't waste CPU cycles on an edge case the user
-// doesn't care about.
-const double cAnimationResyncCutoff = 5 * 60;
-
-BitmapImage::BitmapImage(ImageObserver* observer)
- : Image(observer)
- , m_currentFrame(0)
- , m_frames(0)
- , m_frameTimer(0)
- , m_repetitionCount(cAnimationNone)
- , m_repetitionCountStatus(Unknown)
- , m_repetitionsComplete(0)
- , m_desiredFrameStartTime(0)
- , m_isSolidColor(false)
- , m_animationFinished(false)
- , m_allDataReceived(false)
- , m_haveSize(false)
- , m_sizeAvailable(false)
- , m_hasUniformFrameSize(true)
- , m_decodedSize(0)
- , m_haveFrameCount(false)
- , m_frameCount(0)
-{
- initPlatformData();
-}
-
-BitmapImage::~BitmapImage()
-{
- invalidatePlatformData();
- stopAnimation();
-}
-
-void BitmapImage::destroyDecodedData(bool incremental, bool preserveNearbyFrames)
-{
- // Destroy the cached images and release them.
- if (m_frames.size()) {
- int sizeChange = 0;
- int frameSize = m_size.width() * m_size.height() * 4;
- const size_t nextFrame = (preserveNearbyFrames && frameCount()) ? ((m_currentFrame + 1) % frameCount()) : 0;
- for (unsigned i = incremental ? m_frames.size() - 1 : 0; i < m_frames.size(); i++) {
- if (m_frames[i].m_frame && (!preserveNearbyFrames || (i != m_currentFrame && i != nextFrame))) {
- sizeChange -= frameSize;
- m_frames[i].clear();
- }
- }
-
- // We just always invalidate our platform data, even in the incremental case.
- // This could be better, but it's not a big deal.
- m_isSolidColor = false;
- invalidatePlatformData();
-
- if (sizeChange) {
- m_decodedSize += sizeChange;
- if (imageObserver())
- imageObserver()->decodedSizeChanged(this, sizeChange);
- }
-
- if (!incremental) {
- // Reset the image source, since Image I/O has an underlying cache that it uses
- // while animating that it seems to never clear.
-#if !PLATFORM(SGL)
- m_source.clear();
- m_source.setData(m_data.get(), m_allDataReceived);
-#endif
- }
- }
-}
-
-void BitmapImage::cacheFrame(size_t index)
-{
- size_t numFrames = frameCount();
- ASSERT(m_decodedSize == 0 || numFrames > 1);
-
- if (m_frames.size() < numFrames)
- m_frames.grow(numFrames);
-
- m_frames[index].m_frame = m_source.createFrameAtIndex(index);
- if (numFrames == 1 && m_frames[index].m_frame)
- checkForSolidColor();
-
- m_frames[index].m_haveMetadata = true;
- m_frames[index].m_isComplete = m_source.frameIsCompleteAtIndex(index);
- if (repetitionCount(false) != cAnimationNone)
- m_frames[index].m_duration = m_source.frameDurationAtIndex(index);
- m_frames[index].m_hasAlpha = m_source.frameHasAlphaAtIndex(index);
-
- int sizeChange;
- if (index) {
- IntSize frameSize = m_source.frameSizeAtIndex(index);
- if (frameSize != m_size)
- m_hasUniformFrameSize = false;
- sizeChange = m_frames[index].m_frame ? frameSize.width() * frameSize.height() * 4 : 0;
- } else
- sizeChange = m_frames[index].m_frame ? m_size.width() * m_size.height() * 4 : 0;
-
- if (sizeChange) {
- m_decodedSize += sizeChange;
- if (imageObserver())
- imageObserver()->decodedSizeChanged(this, sizeChange);
- }
-}
-
-IntSize BitmapImage::size() const
-{
- if (m_sizeAvailable && !m_haveSize) {
- m_size = m_source.size();
- m_haveSize = true;
- }
- return m_size;
-}
-
-IntSize BitmapImage::currentFrameSize() const
-{
- if (!m_currentFrame || m_hasUniformFrameSize)
- return size();
- return m_source.frameSizeAtIndex(m_currentFrame);
-}
-
-bool BitmapImage::dataChanged(bool allDataReceived)
-{
- destroyDecodedData(true);
-
- // Feed all the data we've seen so far to the image decoder.
- m_allDataReceived = allDataReceived;
- m_source.setData(m_data.get(), allDataReceived);
-
- // Clear the frame count.
- m_haveFrameCount = false;
-
- m_hasUniformFrameSize = true;
-
- // Image properties will not be available until the first frame of the file
- // reaches kCGImageStatusIncomplete.
- return isSizeAvailable();
-}
-
-size_t BitmapImage::frameCount()
-{
- if (!m_haveFrameCount) {
- m_haveFrameCount = true;
- m_frameCount = m_source.frameCount();
- }
- return m_frameCount;
-}
-
-bool BitmapImage::isSizeAvailable()
-{
- if (m_sizeAvailable)
- return true;
-
- m_sizeAvailable = m_source.isSizeAvailable();
-
- return m_sizeAvailable;
-}
-
-NativeImagePtr BitmapImage::frameAtIndex(size_t index)
-{
- if (index >= frameCount())
- return 0;
-
- if (index >= m_frames.size() || !m_frames[index].m_frame)
- cacheFrame(index);
-
- return m_frames[index].m_frame;
-}
-
-bool BitmapImage::frameIsCompleteAtIndex(size_t index)
-{
- if (index >= frameCount())
- return true;
-
- if (index >= m_frames.size() || !m_frames[index].m_haveMetadata)
- cacheFrame(index);
-
- return m_frames[index].m_isComplete;
-}
-
-float BitmapImage::frameDurationAtIndex(size_t index)
-{
- if (index >= frameCount())
- return 0;
-
- if (index >= m_frames.size() || !m_frames[index].m_haveMetadata)
- cacheFrame(index);
-
- return m_frames[index].m_duration;
-}
-
-bool BitmapImage::frameHasAlphaAtIndex(size_t index)
-{
- if (index >= frameCount())
- return true;
-
- if (index >= m_frames.size() || !m_frames[index].m_haveMetadata)
- cacheFrame(index);
-
- return m_frames[index].m_hasAlpha;
-}
-
-int BitmapImage::repetitionCount(bool imageKnownToBeComplete)
-{
- if ((m_repetitionCountStatus == Unknown) || ((m_repetitionCountStatus == Uncertain) && imageKnownToBeComplete)) {
- // Snag the repetition count. If |imageKnownToBeComplete| is false, the
- // repetition count may not be accurate yet for GIFs; in this case the
- // decoder will default to cAnimationLoopOnce, and we'll try and read
- // the count again once the whole image is decoded.
- m_repetitionCount = m_source.repetitionCount();
- m_repetitionCountStatus = (imageKnownToBeComplete || m_repetitionCount == cAnimationNone) ? Certain : Uncertain;
- }
- return m_repetitionCount;
-}
-
-bool BitmapImage::shouldAnimate()
-{
- return (repetitionCount(false) != cAnimationNone && !m_animationFinished && imageObserver());
-}
-
-void BitmapImage::startAnimation(bool catchUpIfNecessary)
-{
- if (m_frameTimer || !shouldAnimate() || frameCount() <= 1)
- return;
-
- // Determine time for next frame to start. By ignoring paint and timer lag
- // in this calculation, we make the animation appear to run at its desired
- // rate regardless of how fast it's being repainted.
- const double currentDuration = frameDurationAtIndex(m_currentFrame);
- const double time = currentTime();
- if (m_desiredFrameStartTime == 0) {
- m_desiredFrameStartTime = time + currentDuration;
- } else {
- m_desiredFrameStartTime += currentDuration;
- // If we're too far behind, the user probably doesn't care about
- // resyncing and we could burn a lot of time looping through frames
- // below. Just reset the timings.
- if ((time - m_desiredFrameStartTime) > cAnimationResyncCutoff)
- m_desiredFrameStartTime = time + currentDuration;
- }
-
- // Don't advance the animation to an incomplete frame.
- size_t nextFrame = (m_currentFrame + 1) % frameCount();
- if (!frameIsCompleteAtIndex(nextFrame))
- return;
-
- // Don't advance past the last frame if we haven't decoded the whole image
- // yet and our repetition count is potentially unset. The repetition count
- // in a GIF can potentially come after all the rest of the image data, so
- // wait on it.
- if (!m_allDataReceived && repetitionCount(false) == cAnimationLoopOnce && m_currentFrame >= (frameCount() - 1))
- return;
-
- // The image may load more slowly than it's supposed to animate, so that by
- // the time we reach the end of the first repetition, we're well behind.
- // Clamp the desired frame start time in this case, so that we don't skip
- // frames (or whole iterations) trying to "catch up". This is a tradeoff:
- // It guarantees users see the whole animation the second time through and
- // don't miss any repetitions, and is closer to what other browsers do; on
- // the other hand, it makes animations "less accurate" for pages that try to
- // sync an image and some other resource (e.g. audio), especially if users
- // switch tabs (and thus stop drawing the animation, which will pause it)
- // during that initial loop, then switch back later.
- if (nextFrame == 0 && m_repetitionsComplete == 0 && m_desiredFrameStartTime < time)
- m_desiredFrameStartTime = time;
-
- if (!catchUpIfNecessary || time < m_desiredFrameStartTime) {
- // Haven't yet reached time for next frame to start; delay until then.
- m_frameTimer = new Timer<BitmapImage>(this, &BitmapImage::advanceAnimation);
- m_frameTimer->startOneShot(std::max(m_desiredFrameStartTime - time, 0.));
- } else {
- // We've already reached or passed the time for the next frame to start.
- // See if we've also passed the time for frames after that to start, in
- // case we need to skip some frames entirely. Remember not to advance
- // to an incomplete frame.
- for (size_t frameAfterNext = (nextFrame + 1) % frameCount(); frameIsCompleteAtIndex(frameAfterNext); frameAfterNext = (nextFrame + 1) % frameCount()) {
- // Should we skip the next frame?
- double frameAfterNextStartTime = m_desiredFrameStartTime + frameDurationAtIndex(nextFrame);
- if (time < frameAfterNextStartTime)
- break;
-
- // Yes; skip over it without notifying our observers.
- if (!internalAdvanceAnimation(true))
- return;
- m_desiredFrameStartTime = frameAfterNextStartTime;
- nextFrame = frameAfterNext;
- }
-
- // Draw the next frame immediately. Note that m_desiredFrameStartTime
- // may be in the past, meaning the next time through this function we'll
- // kick off the next advancement sooner than this frame's duration would
- // suggest.
- if (internalAdvanceAnimation(false)) {
- // The image region has been marked dirty, but once we return to our
- // caller, draw() will clear it, and nothing will cause the
- // animation to advance again. We need to start the timer for the
- // next frame running, or the animation can hang. (Compare this
- // with when advanceAnimation() is called, and the region is dirtied
- // while draw() is not in the callstack, meaning draw() gets called
- // to update the region and thus startAnimation() is reached again.)
- // NOTE: For large images with slow or heavily-loaded systems,
- // throwing away data as we go (see destroyDecodedData()) means we
- // can spend so much time re-decoding data above that by the time we
- // reach here we're behind again. If we let startAnimation() run
- // the catch-up code again, we can get long delays without painting
- // as we race the timer, or even infinite recursion. In this
- // situation the best we can do is to simply change frames as fast
- // as possible, so force startAnimation() to set a zero-delay timer
- // and bail out if we're not caught up.
- startAnimation(false);
- }
- }
-}
-
-void BitmapImage::stopAnimation()
-{
- // This timer is used to animate all occurrences of this image. Don't invalidate
- // the timer unless all renderers have stopped drawing.
- delete m_frameTimer;
- m_frameTimer = 0;
-}
-
-void BitmapImage::resetAnimation()
-{
- stopAnimation();
- m_currentFrame = 0;
- m_repetitionsComplete = 0;
- m_desiredFrameStartTime = 0;
- m_animationFinished = false;
- int frameSize = m_size.width() * m_size.height() * 4;
-
- // For extremely large animations, when the animation is reset, we just throw everything away.
- if (frameCount() * frameSize > cLargeAnimationCutoff)
- destroyDecodedData();
-}
-
-void BitmapImage::advanceAnimation(Timer<BitmapImage>* timer)
-{
- internalAdvanceAnimation(false);
- // At this point the image region has been marked dirty, and if it's
- // onscreen, we'll soon make a call to draw(), which will call
- // startAnimation() again to keep the animation moving.
-}
-
-bool BitmapImage::internalAdvanceAnimation(bool skippingFrames)
-{
- // Stop the animation.
- stopAnimation();
-
- // See if anyone is still paying attention to this animation. If not, we don't
- // advance and will remain suspended at the current frame until the animation is resumed.
- if (!skippingFrames && imageObserver()->shouldPauseAnimation(this))
- return false;
-
- m_currentFrame++;
- if (m_currentFrame >= frameCount()) {
- ++m_repetitionsComplete;
- // Get the repetition count again. If we weren't able to get a
- // repetition count before, we should have decoded the whole image by
- // now, so it should now be available.
- if (repetitionCount(true) && m_repetitionsComplete >= m_repetitionCount) {
- m_animationFinished = true;
- m_desiredFrameStartTime = 0;
- m_currentFrame--;
- if (skippingFrames) {
- // Uh oh. We tried to skip past the end of the animation. We'd
- // better draw this last frame.
- notifyObserverAndTrimDecodedData();
- }
- return false;
- }
- m_currentFrame = 0;
- }
-
- if (!skippingFrames)
- notifyObserverAndTrimDecodedData();
-
- return true;
-}
-
-void BitmapImage::notifyObserverAndTrimDecodedData()
-{
- // Notify our observer that the animation has advanced.
- imageObserver()->animationAdvanced(this);
-
- // For large animated images, go ahead and throw away frames as we go to
- // save footprint.
- int frameSize = m_size.width() * m_size.height() * 4;
- if (frameCount() * frameSize > cLargeAnimationCutoff) {
- // Destroy all of our frames and just redecode every time. We save the
- // current frame since we'll need it in draw() anyway.
- destroyDecodedData(false, true);
- }
-}
-
-}
diff --git a/WebCore/platform/graphics/BitmapImage.h b/WebCore/platform/graphics/BitmapImage.h
deleted file mode 100644
index c5f2a72..0000000
--- a/WebCore/platform/graphics/BitmapImage.h
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
- * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef BitmapImage_h
-#define BitmapImage_h
-
-#include "Image.h"
-#include "Color.h"
-#include "IntSize.h"
-
-#if PLATFORM(MAC)
-#include <wtf/RetainPtr.h>
-#ifdef __OBJC__
-@class NSImage;
-#else
-class NSImage;
-#endif
-#endif
-
-#if PLATFORM(WIN)
-typedef struct HBITMAP__ *HBITMAP;
-#endif
-
-#if PLATFORM(SGL)
-class SkBitmap;
-class SkBitmapRef;
-#endif
-
-namespace WebCore {
- struct FrameData;
-}
-
-// This complicated-looking declaration tells the FrameData Vector that it should copy without
-// invoking our constructor or destructor. This allows us to have a vector even for a struct
-// that's not copyable.
-namespace WTF {
- template<> class VectorTraits<WebCore::FrameData> : public SimpleClassVectorTraits {};
-}
-
-namespace WebCore {
-
-template <typename T> class Timer;
-
-// ================================================
-// FrameData Class
-// ================================================
-
-struct FrameData : Noncopyable {
- FrameData()
- : m_frame(0)
- , m_haveMetadata(false)
- , m_isComplete(false)
- , m_duration(0)
- , m_hasAlpha(true)
- {
- }
-
- ~FrameData()
- {
- clear();
- }
-
- void clear();
-
- NativeImagePtr m_frame;
- bool m_haveMetadata;
- bool m_isComplete;
- float m_duration;
- bool m_hasAlpha;
-};
-
-// =================================================
-// BitmapImage Class
-// =================================================
-
-class BitmapImage : public Image {
- friend class GeneratedImage;
- friend class GraphicsContext;
-public:
- static PassRefPtr<BitmapImage> create(NativeImagePtr nativeImage, ImageObserver* observer = 0)
- {
- return adoptRef(new BitmapImage(nativeImage, observer));
- }
- static PassRefPtr<BitmapImage> create(ImageObserver* observer = 0)
- {
- return adoptRef(new BitmapImage(observer));
- }
- ~BitmapImage();
-
- virtual bool isBitmapImage() const { return true; }
-
- virtual bool hasSingleSecurityOrigin() const { return true; }
-
- virtual IntSize size() const;
- IntSize currentFrameSize() const;
-
- virtual bool dataChanged(bool allDataReceived);
-
- // It may look unusual that there is no start animation call as public API. This is because
- // we start and stop animating lazily. Animation begins whenever someone draws the image. It will
- // automatically pause once all observers no longer want to render the image anywhere.
- virtual void stopAnimation();
- virtual void resetAnimation();
-
- virtual unsigned decodedSize() const { return m_decodedSize; }
-
-#if PLATFORM(MAC)
- // Accessors for native image formats.
- virtual NSImage* getNSImage();
- virtual CFDataRef getTIFFRepresentation();
-#endif
-
-#if PLATFORM(CG)
- virtual CGImageRef getCGImageRef();
-#endif
-
-#if PLATFORM(WIN)
- virtual bool getHBITMAP(HBITMAP);
- virtual bool getHBITMAPOfSize(HBITMAP, LPSIZE);
-#endif
-
-#if PLATFORM(SGL)
-// virtual SkBitmapRef* getBitmap();
- virtual void setURL(const String& str);
-#endif
-
- virtual NativeImagePtr nativeImageForCurrentFrame() { return frameAtIndex(currentFrame()); }
-
-protected:
- enum RepetitionCountStatus {
- Unknown, // We haven't checked the source's repetition count.
- Uncertain, // We have a repetition count, but it might be wrong (some GIFs have a count after the image data, and will report "loop once" until all data has been decoded).
- Certain, // The repetition count is known to be correct.
- };
-
- BitmapImage(NativeImagePtr, ImageObserver* = 0);
- BitmapImage(ImageObserver* = 0);
-
-#if PLATFORM(WIN)
- virtual void drawFrameMatchingSourceSize(GraphicsContext*, const FloatRect& dstRect, const IntSize& srcSize, CompositeOperator);
-#endif
- virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, CompositeOperator);
-#if PLATFORM(QT) || PLATFORM(WX)
- virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform,
- const FloatPoint& phase, CompositeOperator, const FloatRect& destRect);
-#endif
- size_t currentFrame() const { return m_currentFrame; }
- size_t frameCount();
- NativeImagePtr frameAtIndex(size_t);
- bool frameIsCompleteAtIndex(size_t);
- float frameDurationAtIndex(size_t);
- bool frameHasAlphaAtIndex(size_t);
-
- // Decodes and caches a frame. Never accessed except internally.
- void cacheFrame(size_t index);
-
- // Called to invalidate all our cached data. If an image is loading
- // incrementally, we only invalidate the last cached frame. For large
- // animated images, where we throw away the decoded data after every frame,
- // |preserveNearbyFrames| can be set to preserve the current frame's data
- // and eliminate some unnecessary duplicated decoding work. This also
- // preserves the next frame's data, if available. In most cases this has no
- // effect; either that frame isn't decoded yet, or it's already been
- // destroyed by a previous call. But when we fall behind on the very first
- // animation loop and startAnimation() needs to "catch up" one or more
- // frames, this briefly preserves some of that decoding work, to ease CPU
- // load and make it less likely that we'll keep falling behind.
- virtual void destroyDecodedData(bool incremental = false, bool preserveNearbyFrames = false);
-
- // Whether or not size is available yet.
- bool isSizeAvailable();
-
- // Animation.
- int repetitionCount(bool imageKnownToBeComplete); // |imageKnownToBeComplete| should be set if the caller knows the entire image has been decoded.
- bool shouldAnimate();
- virtual void startAnimation(bool catchUpIfNecessary = true);
- void advanceAnimation(Timer<BitmapImage>*);
-
- // Function that does the real work of advancing the animation. When
- // skippingFrames is true, we're in the middle of a loop trying to skip over
- // a bunch of animation frames, so we should not do things like decode each
- // one or notify our observers.
- // Returns whether the animation was advanced.
- bool internalAdvanceAnimation(bool skippingFrames);
-
- // Helper for internalAdvanceAnimation().
- void notifyObserverAndTrimDecodedData();
-
- // Handle platform-specific data
- void initPlatformData();
- void invalidatePlatformData();
-
- // Checks to see if the image is a 1x1 solid color. We optimize these images and just do a fill rect instead.
- void checkForSolidColor();
-
- virtual bool mayFillWithSolidColor() const { return m_isSolidColor && m_currentFrame == 0; }
- virtual Color solidColor() const { return m_solidColor; }
-
- ImageSource m_source;
- mutable IntSize m_size; // The size to use for the overall image (will just be the size of the first image).
-
- size_t m_currentFrame; // The index of the current frame of animation.
- Vector<FrameData> m_frames; // An array of the cached frames of the animation. We have to ref frames to pin them in the cache.
-
- Timer<BitmapImage>* m_frameTimer;
- int m_repetitionCount; // How many total animation loops we should do. This will be cAnimationNone if this image type is incapable of animation.
- RepetitionCountStatus m_repetitionCountStatus;
- int m_repetitionsComplete; // How many repetitions we've finished.
- double m_desiredFrameStartTime; // The system time at which we hope to see the next call to startAnimation().
-
-#if PLATFORM(MAC)
- mutable RetainPtr<NSImage> m_nsImage; // A cached NSImage of frame 0. Only built lazily if someone actually queries for one.
- mutable RetainPtr<CFDataRef> m_tiffRep; // Cached TIFF rep for frame 0. Only built lazily if someone queries for one.
-#endif
-
- Color m_solidColor; // If we're a 1x1 solid color, this is the color to use to fill.
- bool m_isSolidColor; // Whether or not we are a 1x1 solid image.
-
- bool m_animationFinished; // Whether or not we've completed the entire animation.
-
- bool m_allDataReceived; // Whether or not we've received all our data.
-
- mutable bool m_haveSize; // Whether or not our |m_size| member variable has the final overall image size yet.
- bool m_sizeAvailable; // Whether or not we can obtain the size of the first image frame yet from ImageIO.
- mutable bool m_hasUniformFrameSize;
-
- unsigned m_decodedSize; // The current size of all decoded frames.
-
- mutable bool m_haveFrameCount;
- size_t m_frameCount;
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/graphics/Color.cpp b/WebCore/platform/graphics/Color.cpp
deleted file mode 100644
index 3ff589d..0000000
--- a/WebCore/platform/graphics/Color.cpp
+++ /dev/null
@@ -1,306 +0,0 @@
-/*
- * Copyright (C) 2003, 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Color.h"
-
-#include "PlatformString.h"
-#include <math.h>
-#include <wtf/Assertions.h>
-#include <wtf/MathExtras.h>
-
-#include "ColorData.c"
-
-using namespace std;
-using namespace WTF;
-
-namespace WebCore {
-
-const RGBA32 lightenedBlack = 0xFF545454;
-const RGBA32 darkenedWhite = 0xFFABABAB;
-
-RGBA32 makeRGB(int r, int g, int b)
-{
- return 0xFF000000 | max(0, min(r, 255)) << 16 | max(0, min(g, 255)) << 8 | max(0, min(b, 255));
-}
-
-RGBA32 makeRGBA(int r, int g, int b, int a)
-{
- return max(0, min(a, 255)) << 24 | max(0, min(r, 255)) << 16 | max(0, min(g, 255)) << 8 | max(0, min(b, 255));
-}
-
-int colorFloatToRGBAByte(float f)
-{
- // We use lroundf and 255 instead of nextafterf(256, 0) to match CG's rounding
- return max(0, min(static_cast<int>(lroundf(255.0f * f)), 255));
-}
-
-RGBA32 makeRGBA32FromFloats(float r, float g, float b, float a)
-{
- return colorFloatToRGBAByte(a) << 24 | colorFloatToRGBAByte(r) << 16 | colorFloatToRGBAByte(g) << 8 | colorFloatToRGBAByte(b);
-}
-
-RGBA32 colorWithOverrideAlpha(RGBA32 color, float overrideAlpha)
-{
- RGBA32 rgbOnly = color & 0x00FFFFFF;
- RGBA32 rgba = rgbOnly | colorFloatToRGBAByte(overrideAlpha) << 24;
- return rgba;
-}
-
-static double calcHue(double temp1, double temp2, double hueVal)
-{
- if (hueVal < 0.0)
- hueVal++;
- else if (hueVal > 1.0)
- hueVal--;
- if (hueVal * 6.0 < 1.0)
- return temp1 + (temp2 - temp1) * hueVal * 6.0;
- if (hueVal * 2.0 < 1.0)
- return temp2;
- if (hueVal * 3.0 < 2.0)
- return temp1 + (temp2 - temp1) * (2.0 / 3.0 - hueVal) * 6.0;
- return temp1;
-}
-
-// Explanation of this algorithm can be found in the CSS3 Color Module
-// specification at http://www.w3.org/TR/css3-color/#hsl-color with further
-// explanation available at http://en.wikipedia.org/wiki/HSL_color_space
-
-// all values are in the range of 0 to 1.0
-RGBA32 makeRGBAFromHSLA(double hue, double saturation, double lightness, double alpha)
-{
- const double scaleFactor = nextafter(256.0, 0.0);
-
- if (!saturation) {
- int greyValue = static_cast<int>(lightness * scaleFactor);
- return makeRGBA(greyValue, greyValue, greyValue, static_cast<int>(alpha * scaleFactor));
- }
-
- double temp2 = lightness < 0.5 ? lightness * (1.0 + saturation) : lightness + saturation - lightness * saturation;
- double temp1 = 2.0 * lightness - temp2;
-
- return makeRGBA(static_cast<int>(calcHue(temp1, temp2, hue + 1.0 / 3.0) * scaleFactor),
- static_cast<int>(calcHue(temp1, temp2, hue) * scaleFactor),
- static_cast<int>(calcHue(temp1, temp2, hue - 1.0 / 3.0) * scaleFactor),
- static_cast<int>(alpha * scaleFactor));
-}
-
-// originally moved here from the CSS parser
-bool Color::parseHexColor(const String& name, RGBA32& rgb)
-{
- unsigned length = name.length();
- if (length != 3 && length != 6)
- return false;
- unsigned value = 0;
- for (unsigned i = 0; i < length; ++i) {
- if (!isASCIIHexDigit(name[i]))
- return false;
- value <<= 4;
- value |= toASCIIHexValue(name[i]);
- }
- if (length == 6) {
- rgb = 0xFF000000 | value;
- return true;
- }
- // #abc converts to #aabbcc
- rgb = 0xFF000000
- | (value & 0xF00) << 12 | (value & 0xF00) << 8
- | (value & 0xF0) << 8 | (value & 0xF0) << 4
- | (value & 0xF) << 4 | (value & 0xF);
- return true;
-}
-
-int differenceSquared(const Color& c1, const Color& c2)
-{
- int dR = c1.red() - c2.red();
- int dG = c1.green() - c2.green();
- int dB = c1.blue() - c2.blue();
- return dR * dR + dG * dG + dB * dB;
-}
-
-Color::Color(const String& name)
-{
- if (name.startsWith("#"))
- m_valid = parseHexColor(name.substring(1), m_color);
- else
- setNamedColor(name);
-}
-
-Color::Color(const char* name)
-{
- if (name[0] == '#')
- m_valid = parseHexColor(&name[1], m_color);
- else {
- const NamedColor* foundColor = findColor(name, strlen(name));
- m_color = foundColor ? foundColor->RGBValue : 0;
- m_color |= 0xFF000000;
- m_valid = foundColor;
- }
-}
-
-String Color::name() const
-{
- if (alpha() < 0xFF)
- return String::format("#%02X%02X%02X%02X", red(), green(), blue(), alpha());
- return String::format("#%02X%02X%02X", red(), green(), blue());
-}
-
-static inline const NamedColor* findNamedColor(const String& name)
-{
- char buffer[64]; // easily big enough for the longest color name
- unsigned length = name.length();
- if (length > sizeof(buffer) - 1)
- return 0;
- for (unsigned i = 0; i < length; ++i) {
- UChar c = name[i];
- if (!c || c > 0x7F)
- return 0;
- buffer[i] = toASCIILower(static_cast<char>(c));
- }
- buffer[length] = '\0';
- return findColor(buffer, length);
-}
-
-void Color::setNamedColor(const String& name)
-{
- const NamedColor* foundColor = findNamedColor(name);
- m_color = foundColor ? foundColor->RGBValue : 0;
- m_color |= 0xFF000000;
- m_valid = foundColor;
-}
-
-Color Color::light() const
-{
- // Hardcode this common case for speed.
- if (m_color == black)
- return lightenedBlack;
-
- const float scaleFactor = nextafterf(256.0f, 0.0f);
-
- float r, g, b, a;
- getRGBA(r, g, b, a);
-
- float v = max(r, max(g, b));
-
- if (v == 0.0f)
- // Lightened black with alpha.
- return Color(0x54, 0x54, 0x54, alpha());
-
- float multiplier = min(1.0f, v + 0.33f) / v;
-
- return Color(static_cast<int>(multiplier * r * scaleFactor),
- static_cast<int>(multiplier * g * scaleFactor),
- static_cast<int>(multiplier * b * scaleFactor),
- alpha());
-}
-
-Color Color::dark() const
-{
- // Hardcode this common case for speed.
- if (m_color == white)
- return darkenedWhite;
-
- const float scaleFactor = nextafterf(256.0f, 0.0f);
-
- float r, g, b, a;
- getRGBA(r, g, b, a);
-
- float v = max(r, max(g, b));
- float multiplier = max(0.0f, (v - 0.33f) / v);
-
- return Color(static_cast<int>(multiplier * r * scaleFactor),
- static_cast<int>(multiplier * g * scaleFactor),
- static_cast<int>(multiplier * b * scaleFactor),
- alpha());
-}
-
-static int blendComponent(int c, int a)
-{
- // We use white.
- float alpha = a / 255.0f;
- int whiteBlend = 255 - a;
- c -= whiteBlend;
- return static_cast<int>(c / alpha);
-}
-
-const int cStartAlpha = 153; // 60%
-const int cEndAlpha = 204; // 80%;
-const int cAlphaIncrement = 17; // Increments in between.
-
-Color Color::blend(const Color& source) const
-{
- if (!alpha() || !source.hasAlpha())
- return source;
-
- if (!source.alpha())
- return *this;
-
- int d = 255 * (alpha() + source.alpha()) - alpha() * source.alpha();
- int a = d / 255;
- int r = (red() * alpha() * (255 - source.alpha()) + 255 * source.alpha() * source.red()) / d;
- int g = (green() * alpha() * (255 - source.alpha()) + 255 * source.alpha() * source.green()) / d;
- int b = (blue() * alpha() * (255 - source.alpha()) + 255 * source.alpha() * source.blue()) / d;
- return Color(r, g, b, a);
-}
-
-Color Color::blendWithWhite() const
-{
- // If the color contains alpha already, we leave it alone.
- if (hasAlpha())
- return *this;
-
- Color newColor;
- for (int alpha = cStartAlpha; alpha <= cEndAlpha; alpha += cAlphaIncrement) {
- // We have a solid color. Convert to an equivalent color that looks the same when blended with white
- // at the current alpha. Try using less transparency if the numbers end up being negative.
- int r = blendComponent(red(), alpha);
- int g = blendComponent(green(), alpha);
- int b = blendComponent(blue(), alpha);
-
- newColor = Color(r, g, b, alpha);
-
- if (r >= 0 && g >= 0 && b >= 0)
- break;
- }
- return newColor;
-}
-
-void Color::getRGBA(float& r, float& g, float& b, float& a) const
-{
- r = red() / 255.0f;
- g = green() / 255.0f;
- b = blue() / 255.0f;
- a = alpha() / 255.0f;
-}
-
-void Color::getRGBA(double& r, double& g, double& b, double& a) const
-{
- r = red() / 255.0;
- g = green() / 255.0;
- b = blue() / 255.0;
- a = alpha() / 255.0;
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/graphics/Color.h b/WebCore/platform/graphics/Color.h
deleted file mode 100644
index 61fc74c..0000000
--- a/WebCore/platform/graphics/Color.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright (C) 2003-6 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef Color_h
-#define Color_h
-
-#include <wtf/Platform.h>
-
-#if PLATFORM(CG)
-typedef struct CGColor* CGColorRef;
-#endif
-
-#if PLATFORM(QT)
-#include <qglobal.h>
-QT_BEGIN_NAMESPACE
-class QColor;
-QT_END_NAMESPACE
-#endif
-
-#if PLATFORM(GTK)
-typedef struct _GdkColor GdkColor;
-#endif
-
-#if PLATFORM(WX)
-class wxColour;
-#endif
-
-namespace WebCore {
-
-class String;
-class Color;
-
-typedef unsigned RGBA32; // RGBA quadruplet
-
-RGBA32 makeRGB(int r, int g, int b);
-RGBA32 makeRGBA(int r, int g, int b, int a);
-
-RGBA32 colorWithOverrideAlpha(RGBA32 color, float overrideAlpha);
-RGBA32 makeRGBA32FromFloats(float r, float g, float b, float a);
-RGBA32 makeRGBAFromHSLA(double h, double s, double l, double a);
-
-int differenceSquared(const Color&, const Color&);
-
-class Color {
-public:
- Color() : m_color(0), m_valid(false) { }
- Color(RGBA32 col) : m_color(col), m_valid(true) { }
- Color(int r, int g, int b) : m_color(makeRGB(r, g, b)), m_valid(true) { }
- Color(int r, int g, int b, int a) : m_color(makeRGBA(r, g, b, a)), m_valid(true) { }
- // Color is currently limited to 32bit RGBA, perhaps some day we'll support better colors
- Color(float r, float g, float b, float a) : m_color(makeRGBA32FromFloats(r, g, b, a)), m_valid(true) { }
- explicit Color(const String&);
- explicit Color(const char*);
-
- String name() const;
- void setNamedColor(const String&);
-
- bool isValid() const { return m_valid; }
-
- bool hasAlpha() const { return alpha() < 255; }
-
- int red() const { return (m_color >> 16) & 0xFF; }
- int green() const { return (m_color >> 8) & 0xFF; }
- int blue() const { return m_color & 0xFF; }
- int alpha() const { return (m_color >> 24) & 0xFF; }
-
- RGBA32 rgb() const { return m_color; } // Preserve the alpha.
- void setRGB(int r, int g, int b) { m_color = makeRGB(r, g, b); m_valid = true; }
- void setRGB(RGBA32 rgb) { m_color = rgb; m_valid = true; }
- void getRGBA(float& r, float& g, float& b, float& a) const;
- void getRGBA(double& r, double& g, double& b, double& a) const;
-
- Color light() const;
- Color dark() const;
-
- Color blend(const Color&) const;
- Color blendWithWhite() const;
-
-#if PLATFORM(QT)
- Color(const QColor&);
- operator QColor() const;
-#endif
-
-#if PLATFORM(GTK)
- Color(const GdkColor&);
- // We can't sensibly go back to GdkColor without losing the alpha value
-#endif
-
-#if PLATFORM(WX)
- Color(const wxColour&);
- operator wxColour() const;
-#endif
-
-#if PLATFORM(CG)
- Color(CGColorRef);
-#endif
-
- static bool parseHexColor(const String& name, RGBA32& rgb);
-
- static const RGBA32 black = 0xFF000000;
- static const RGBA32 white = 0xFFFFFFFF;
- static const RGBA32 darkGray = 0xFF808080;
- static const RGBA32 gray = 0xFFA0A0A0;
- static const RGBA32 lightGray = 0xFFC0C0C0;
- static const RGBA32 transparent = 0x00000000;
-
-#ifdef ANDROID_CSS_TAP_HIGHLIGHT_COLOR
- static const RGBA32 tap = 0x4D1A1A1A;
-#endif
-
-private:
- RGBA32 m_color;
- bool m_valid;
-};
-
-inline bool operator==(const Color& a, const Color& b)
-{
- return a.rgb() == b.rgb() && a.isValid() == b.isValid();
-}
-
-inline bool operator!=(const Color& a, const Color& b)
-{
- return !(a == b);
-}
-
-Color focusRingColor();
-
-#if PLATFORM(CG)
-CGColorRef cgColor(const Color&);
-#endif
-
-} // namespace WebCore
-
-#endif // Color_h
diff --git a/WebCore/platform/graphics/DashArray.h b/WebCore/platform/graphics/DashArray.h
deleted file mode 100644
index 46b84a4..0000000
--- a/WebCore/platform/graphics/DashArray.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2008 Dirk Schulze <vbs85@gmx.de>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef DashArray_h
-#define DashArray_h
-
-#include <wtf/Vector.h>
-
-#if PLATFORM(CG)
-typedef Vector<CGFloat> DashArray;
-#elif PLATFORM(CAIRO)
-typedef Vector<double> DashArray;
-#else
-typedef Vector<float> DashArray;
-#endif
-
-#endif // DashArray_h
diff --git a/WebCore/platform/graphics/FloatPoint.cpp b/WebCore/platform/graphics/FloatPoint.cpp
deleted file mode 100644
index 3ca0361..0000000
--- a/WebCore/platform/graphics/FloatPoint.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2005 Nokia. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FloatPoint.h"
-
-#include "AffineTransform.h"
-#include "FloatConversion.h"
-#include "IntPoint.h"
-
-namespace WebCore {
-
-FloatPoint::FloatPoint(const IntPoint& p) : m_x(p.x()), m_y(p.y())
-{
-}
-
-FloatPoint FloatPoint::matrixTransform(const AffineTransform& transform) const
-{
- double newX, newY;
- transform.map(static_cast<double>(m_x), static_cast<double>(m_y), &newX, &newY);
- return narrowPrecision(newX, newY);
-}
-
-FloatPoint FloatPoint::narrowPrecision(double x, double y)
-{
- return FloatPoint(narrowPrecisionToFloat(x), narrowPrecisionToFloat(y));
-}
-
-}
diff --git a/WebCore/platform/graphics/FloatPoint.h b/WebCore/platform/graphics/FloatPoint.h
deleted file mode 100644
index 6b3c769..0000000
--- a/WebCore/platform/graphics/FloatPoint.h
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2005 Nokia. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef FloatPoint_h
-#define FloatPoint_h
-
-#include "FloatSize.h"
-#include <wtf/Platform.h>
-
-#if PLATFORM(CG)
-typedef struct CGPoint CGPoint;
-#endif
-
-#if PLATFORM(MAC)
-#ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
-typedef struct CGPoint NSPoint;
-#else
-typedef struct _NSPoint NSPoint;
-#endif
-#endif
-
-#if PLATFORM(QT)
-#include "qglobal.h"
-QT_BEGIN_NAMESPACE
-class QPointF;
-QT_END_NAMESPACE
-#endif
-
-#if PLATFORM(SYMBIAN)
-class TPoint;
-#endif
-
-#if PLATFORM(SKIA)
-struct SkPoint;
-#endif
-
-namespace WebCore {
-
-class AffineTransform;
-class IntPoint;
-
-class FloatPoint {
-public:
- FloatPoint() : m_x(0), m_y(0) { }
- FloatPoint(float x, float y) : m_x(x), m_y(y) { }
- FloatPoint(const IntPoint&);
-
- static FloatPoint narrowPrecision(double x, double y);
-
- float x() const { return m_x; }
- float y() const { return m_y; }
-
- void setX(float x) { m_x = x; }
- void setY(float y) { m_y = y; }
- void move(float dx, float dy) { m_x += dx; m_y += dy; }
-
-#if PLATFORM(CG)
- FloatPoint(const CGPoint&);
- operator CGPoint() const;
-#endif
-
-#if PLATFORM(MAC) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
- FloatPoint(const NSPoint&);
- operator NSPoint() const;
-#endif
-
-#if PLATFORM(QT)
- FloatPoint(const QPointF&);
- operator QPointF() const;
-#endif
-
-#if PLATFORM(SYMBIAN)
- operator TPoint() const;
- FloatPoint(const TPoint&);
-#endif
-
-#if PLATFORM(SKIA)
- operator SkPoint() const;
- FloatPoint(const SkPoint&);
-#endif
-
- FloatPoint matrixTransform(const AffineTransform&) const;
-
-private:
- float m_x, m_y;
-};
-
-
-inline FloatPoint& operator+=(FloatPoint& a, const FloatSize& b)
-{
- a.move(b.width(), b.height());
- return a;
-}
-
-inline FloatPoint& operator-=(FloatPoint& a, const FloatSize& b)
-{
- a.move(-b.width(), -b.height());
- return a;
-}
-
-inline FloatPoint operator+(const FloatPoint& a, const FloatSize& b)
-{
- return FloatPoint(a.x() + b.width(), a.y() + b.height());
-}
-
-inline FloatSize operator-(const FloatPoint& a, const FloatPoint& b)
-{
- return FloatSize(a.x() - b.x(), a.y() - b.y());
-}
-
-inline FloatPoint operator-(const FloatPoint& a, const FloatSize& b)
-{
- return FloatPoint(a.x() - b.width(), a.y() - b.height());
-}
-
-inline bool operator==(const FloatPoint& a, const FloatPoint& b)
-{
- return a.x() == b.x() && a.y() == b.y();
-}
-
-inline bool operator!=(const FloatPoint& a, const FloatPoint& b)
-{
- return a.x() != b.x() || a.y() != b.y();
-}
-
-}
-
-#endif
diff --git a/WebCore/platform/graphics/FloatPoint3D.cpp b/WebCore/platform/graphics/FloatPoint3D.cpp
deleted file mode 100644
index ec52d40..0000000
--- a/WebCore/platform/graphics/FloatPoint3D.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <wildfox@kde.org>
- 2004, 2005 Rob Buis <buis@kde.org>
- 2005 Eric Seidel <eric@webkit.org>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- aint with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include "config.h"
-
-#if ENABLE(SVG)
-#include <math.h>
-#include "FloatPoint3D.h"
-
-namespace WebCore {
-
-FloatPoint3D::FloatPoint3D()
- : m_x(0.f)
- , m_y(0.f)
- , m_z(0.f)
-{
-}
-
-FloatPoint3D::FloatPoint3D(float x, float y, float z)
- : m_x(x)
- , m_y(y)
- , m_z(z)
-{
-}
-
-float FloatPoint3D::x() const
-{
- return m_x;
-}
-
-void FloatPoint3D::setX(float x)
-{
- m_x = x;
-}
-
-float FloatPoint3D::y() const
-{
- return m_y;
-}
-
-void FloatPoint3D::setY(float y)
-{
- m_y = y;
-}
-
-float FloatPoint3D::z() const
-{
- return m_z;
-}
-
-void FloatPoint3D::setZ(float z)
-{
- m_z = z;
-}
-
-void FloatPoint3D::normalize()
-{
- float length = sqrtf(m_x * m_x + m_y * m_y + m_z * m_z);
-
- m_x /= length;
- m_y /= length;
- m_z /= length;
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(SVG)
diff --git a/WebCore/platform/graphics/FloatPoint3D.h b/WebCore/platform/graphics/FloatPoint3D.h
deleted file mode 100644
index 55f70e7..0000000
--- a/WebCore/platform/graphics/FloatPoint3D.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <wildfox@kde.org>
- 2004, 2005 Rob Buis <buis@kde.org>
- 2005 Eric Seidel <eric@webkit.org>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- aint with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#ifndef FloatPoint3D_h
-#define FloatPoint3D_h
-
-#if ENABLE(SVG)
-
-namespace WebCore {
-
-class FloatPoint3D {
-public:
- FloatPoint3D();
- FloatPoint3D(float x, float y, float z);
-
- float x() const;
- void setX(float x);
-
- float y() const;
- void setY(float y);
-
- float z() const;
- void setZ(float z);
-
- void normalize();
-
-private:
- float m_x;
- float m_y;
- float m_z;
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(SVG)
-
-#endif // FloatPoint3D_h
diff --git a/WebCore/platform/graphics/FloatRect.cpp b/WebCore/platform/graphics/FloatRect.cpp
deleted file mode 100644
index ec7b3fa..0000000
--- a/WebCore/platform/graphics/FloatRect.cpp
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2005 Nokia. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FloatRect.h"
-
-#include "FloatConversion.h"
-#include "IntRect.h"
-#include <algorithm>
-#include <math.h>
-
-using std::max;
-using std::min;
-
-namespace WebCore {
-
-FloatRect::FloatRect(const IntRect& r) : m_location(r.location()), m_size(r.size())
-{
-}
-
-FloatRect FloatRect::narrowPrecision(double x, double y, double width, double height)
-{
- return FloatRect(narrowPrecisionToFloat(x), narrowPrecisionToFloat(y), narrowPrecisionToFloat(width), narrowPrecisionToFloat(height));
-}
-
-bool FloatRect::intersects(const FloatRect& other) const
-{
- // Checking emptiness handles negative widths as well as zero.
- return !isEmpty() && !other.isEmpty()
- && x() < other.right() && other.x() < right()
- && y() < other.bottom() && other.y() < bottom();
-}
-
-bool FloatRect::contains(const FloatRect& other) const
-{
- return x() <= other.x() && right() >= other.right()
- && y() <= other.y() && bottom() >= other.bottom();
-}
-
-void FloatRect::intersect(const FloatRect& other)
-{
- float l = max(x(), other.x());
- float t = max(y(), other.y());
- float r = min(right(), other.right());
- float b = min(bottom(), other.bottom());
-
- // Return a clean empty rectangle for non-intersecting cases.
- if (l >= r || t >= b) {
- l = 0;
- t = 0;
- r = 0;
- b = 0;
- }
-
- m_location.setX(l);
- m_location.setY(t);
- m_size.setWidth(r - l);
- m_size.setHeight(b - t);
-}
-
-void FloatRect::unite(const FloatRect& other)
-{
- // Handle empty special cases first.
- if (other.isEmpty())
- return;
- if (isEmpty()) {
- *this = other;
- return;
- }
-
- float l = min(x(), other.x());
- float t = min(y(), other.y());
- float r = max(right(), other.right());
- float b = max(bottom(), other.bottom());
-
- m_location.setX(l);
- m_location.setY(t);
- m_size.setWidth(r - l);
- m_size.setHeight(b - t);
-}
-
-void FloatRect::scale(float s)
-{
- m_location.setX(x() * s);
- m_location.setY(y() * s);
- m_size.setWidth(width() * s);
- m_size.setHeight(height() * s);
-}
-
-IntRect enclosingIntRect(const FloatRect& rect)
-{
- int l = static_cast<int>(floorf(rect.x()));
- int t = static_cast<int>(floorf(rect.y()));
- int r = static_cast<int>(ceilf(rect.right()));
- int b = static_cast<int>(ceilf(rect.bottom()));
- return IntRect(l, t, r - l, b - t);
-}
-
-}
diff --git a/WebCore/platform/graphics/FloatRect.h b/WebCore/platform/graphics/FloatRect.h
deleted file mode 100644
index 11e3791..0000000
--- a/WebCore/platform/graphics/FloatRect.h
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2005 Nokia. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef FloatRect_h
-#define FloatRect_h
-
-#include "FloatPoint.h"
-
-#if PLATFORM(CG)
-typedef struct CGRect CGRect;
-#endif
-
-#if PLATFORM(MAC)
-#ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
-typedef struct CGRect NSRect;
-#else
-typedef struct _NSRect NSRect;
-#endif
-#endif
-
-#if PLATFORM(QT)
-QT_BEGIN_NAMESPACE
-class QRectF;
-QT_END_NAMESPACE
-#endif
-
-#if PLATFORM(WX) && USE(WXGC)
-class wxRect2DDouble;
-#endif
-
-#if PLATFORM(SKIA)
-struct SkRect;
-#endif
-
-namespace WebCore {
-
-class IntRect;
-
-class FloatRect {
-public:
- FloatRect() { }
- FloatRect(const FloatPoint& location, const FloatSize& size)
- : m_location(location), m_size(size) { }
- FloatRect(float x, float y, float width, float height)
- : m_location(FloatPoint(x, y)), m_size(FloatSize(width, height)) { }
- FloatRect(const IntRect&);
-
- static FloatRect narrowPrecision(double x, double y, double width, double height);
-
- FloatPoint location() const { return m_location; }
- FloatSize size() const { return m_size; }
-
- void setLocation(const FloatPoint& location) { m_location = location; }
- void setSize(const FloatSize& size) { m_size = size; }
-
- float x() const { return m_location.x(); }
- float y() const { return m_location.y(); }
- float width() const { return m_size.width(); }
- float height() const { return m_size.height(); }
-
- void setX(float x) { m_location.setX(x); }
- void setY(float y) { m_location.setY(y); }
- void setWidth(float width) { m_size.setWidth(width); }
- void setHeight(float height) { m_size.setHeight(height); }
-
- bool isEmpty() const { return m_size.isEmpty(); }
-
- float right() const { return x() + width(); }
- float bottom() const { return y() + height(); }
-
- void move(const FloatSize& delta) { m_location += delta; }
- void move(float dx, float dy) { m_location.move(dx, dy); }
-
- bool intersects(const FloatRect&) const;
- bool contains(const FloatRect&) const;
-
- void intersect(const FloatRect&);
- void unite(const FloatRect&);
-
- // Note, this doesn't match what IntRect::contains(IntPoint&) does; the int version
- // is really checking for containment of 1x1 rect, but that doesn't make sense with floats.
- bool contains(float px, float py) const
- { return px >= x() && px <= right() && py >= y() && py <= bottom(); }
- bool contains(const FloatPoint& point) const { return contains(point.x(), point.y()); }
-
-
- void inflateX(float dx) {
- m_location.setX(m_location.x() - dx);
- m_size.setWidth(m_size.width() + dx + dx);
- }
- void inflateY(float dy) {
- m_location.setY(m_location.y() - dy);
- m_size.setHeight(m_size.height() + dy + dy);
- }
- void inflate(float d) { inflateX(d); inflateY(d); }
- void scale(float s);
-
-#if PLATFORM(CG)
- FloatRect(const CGRect&);
- operator CGRect() const;
-#endif
-
-#if PLATFORM(MAC) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
- FloatRect(const NSRect&);
- operator NSRect() const;
-#endif
-
-#if PLATFORM(QT)
- FloatRect(const QRectF&);
- operator QRectF() const;
-#endif
-#if PLATFORM(SYMBIAN)
- FloatRect(const TRect&);
- operator TRect() const;
- TRect rect() const;
-#endif
-
-#if PLATFORM(WX) && USE(WXGC)
- FloatRect(const wxRect2DDouble&);
- operator wxRect2DDouble() const;
-#endif
-
-#if PLATFORM(SKIA)
- FloatRect(const SkRect&);
- operator SkRect() const;
-#endif
-
-private:
- FloatPoint m_location;
- FloatSize m_size;
-};
-
-inline FloatRect intersection(const FloatRect& a, const FloatRect& b)
-{
- FloatRect c = a;
- c.intersect(b);
- return c;
-}
-
-inline FloatRect unionRect(const FloatRect& a, const FloatRect& b)
-{
- FloatRect c = a;
- c.unite(b);
- return c;
-}
-
-inline bool operator==(const FloatRect& a, const FloatRect& b)
-{
- return a.location() == b.location() && a.size() == b.size();
-}
-
-inline bool operator!=(const FloatRect& a, const FloatRect& b)
-{
- return a.location() != b.location() || a.size() != b.size();
-}
-
-IntRect enclosingIntRect(const FloatRect&);
-
-}
-
-#endif
diff --git a/WebCore/platform/graphics/FloatSize.cpp b/WebCore/platform/graphics/FloatSize.cpp
deleted file mode 100644
index 86fa4c0..0000000
--- a/WebCore/platform/graphics/FloatSize.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2005 Nokia. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FloatSize.h"
-
-#include "FloatConversion.h"
-#include "IntSize.h"
-
-namespace WebCore {
-
-FloatSize::FloatSize(const IntSize& size) : m_width(size.width()), m_height(size.height())
-{
-}
-
-FloatSize FloatSize::narrowPrecision(double width, double height)
-{
- return FloatSize(narrowPrecisionToFloat(width), narrowPrecisionToFloat(height));
-}
-
-}
diff --git a/WebCore/platform/graphics/FloatSize.h b/WebCore/platform/graphics/FloatSize.h
deleted file mode 100644
index cf1e1c5..0000000
--- a/WebCore/platform/graphics/FloatSize.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2005 Nokia. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef FloatSize_h
-#define FloatSize_h
-
-#include <wtf/Platform.h>
-
-#if PLATFORM(CG)
-typedef struct CGSize CGSize;
-#endif
-
-#if PLATFORM(MAC)
-#ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
-typedef struct CGSize NSSize;
-#else
-typedef struct _NSSize NSSize;
-#endif
-#endif
-
-namespace WebCore {
-
-class IntSize;
-
-class FloatSize {
-public:
- FloatSize() : m_width(0), m_height(0) { }
- FloatSize(float width, float height) : m_width(width), m_height(height) { }
- FloatSize(const IntSize&);
-
- static FloatSize narrowPrecision(double width, double height);
-
- float width() const { return m_width; }
- float height() const { return m_height; }
-
- void setWidth(float width) { m_width = width; }
- void setHeight(float height) { m_height = height; }
-
- bool isEmpty() const { return m_width <= 0 || m_height <= 0; }
-
- FloatSize expandedTo(const FloatSize& other) const
- {
- return FloatSize(m_width > other.m_width ? m_width : other.m_width,
- m_height > other.m_height ? m_height : other.m_height);
- }
-
-#if PLATFORM(CG)
- explicit FloatSize(const CGSize&); // don't do this implicitly since it's lossy
- operator CGSize() const;
-#endif
-
-#if PLATFORM(MAC) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
- explicit FloatSize(const NSSize &); // don't do this implicitly since it's lossy
- operator NSSize() const;
-#endif
-
-private:
- float m_width, m_height;
-};
-
-inline FloatSize& operator+=(FloatSize& a, const FloatSize& b)
-{
- a.setWidth(a.width() + b.width());
- a.setHeight(a.height() + b.height());
- return a;
-}
-
-inline FloatSize& operator-=(FloatSize& a, const FloatSize& b)
-{
- a.setWidth(a.width() - b.width());
- a.setHeight(a.height() - b.height());
- return a;
-}
-
-inline FloatSize operator+(const FloatSize& a, const FloatSize& b)
-{
- return FloatSize(a.width() + b.width(), a.height() + b.height());
-}
-
-inline FloatSize operator-(const FloatSize& a, const FloatSize& b)
-{
- return FloatSize(a.width() - b.width(), a.height() - b.height());
-}
-
-inline FloatSize operator-(const FloatSize& size)
-{
- return FloatSize(-size.width(), -size.height());
-}
-
-inline bool operator==(const FloatSize& a, const FloatSize& b)
-{
- return a.width() == b.width() && a.height() == b.height();
-}
-
-inline bool operator!=(const FloatSize& a, const FloatSize& b)
-{
- return a.width() != b.width() || a.height() != b.height();
-}
-
-} // namespace WebCore
-
-#endif // FloatSize_h
diff --git a/WebCore/platform/graphics/Font.cpp b/WebCore/platform/graphics/Font.cpp
deleted file mode 100644
index 138e322..0000000
--- a/WebCore/platform/graphics/Font.cpp
+++ /dev/null
@@ -1,626 +0,0 @@
-/*
- * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
- * (C) 1999 Antti Koivisto (koivisto@kde.org)
- * (C) 2000 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2003, 2006 Apple Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "Font.h"
-
-#include "CharacterNames.h"
-#include "FloatRect.h"
-#include "FontCache.h"
-#include "FontFallbackList.h"
-#include "IntPoint.h"
-#include "GlyphBuffer.h"
-#include "WidthIterator.h"
-#include <wtf/MathExtras.h>
-
-using namespace WTF;
-using namespace Unicode;
-
-namespace WebCore {
-
-const uint8_t Font::gRoundingHackCharacterTable[256] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 /*\t*/, 1 /*\n*/, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 1 /*space*/, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 /*-*/, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 /*?*/,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 1 /*no-break space*/, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-};
-
-Font::CodePath Font::s_codePath = Auto;
-
-// ============================================================================================
-// Font Implementation (Cross-Platform Portion)
-// ============================================================================================
-
-Font::Font()
- : m_pageZero(0)
- , m_cachedPrimaryFont(0)
- , m_letterSpacing(0)
- , m_wordSpacing(0)
- , m_isPlatformFont(false)
-{
-}
-
-Font::Font(const FontDescription& fd, short letterSpacing, short wordSpacing)
- : m_fontDescription(fd)
- , m_pageZero(0)
- , m_cachedPrimaryFont(0)
- , m_letterSpacing(letterSpacing)
- , m_wordSpacing(wordSpacing)
- , m_isPlatformFont(false)
-{
-}
-
-Font::Font(const FontPlatformData& fontData, bool isPrinterFont)
- : m_fontList(FontFallbackList::create())
- , m_pageZero(0)
- , m_cachedPrimaryFont(0)
- , m_letterSpacing(0)
- , m_wordSpacing(0)
- , m_isPlatformFont(true)
-{
- m_fontDescription.setUsePrinterFont(isPrinterFont);
- m_fontList->setPlatformFont(fontData);
-}
-
-Font::Font(const Font& other)
- : m_fontDescription(other.m_fontDescription)
- , m_fontList(other.m_fontList)
- , m_pages(other.m_pages)
- , m_pageZero(other.m_pageZero)
- , m_cachedPrimaryFont(other.m_cachedPrimaryFont)
- , m_letterSpacing(other.m_letterSpacing)
- , m_wordSpacing(other.m_wordSpacing)
- , m_isPlatformFont(other.m_isPlatformFont)
-{
-}
-
-Font& Font::operator=(const Font& other)
-{
- m_fontDescription = other.m_fontDescription;
- m_fontList = other.m_fontList;
- m_pages = other.m_pages;
- m_pageZero = other.m_pageZero;
- m_cachedPrimaryFont = other.m_cachedPrimaryFont;
- m_letterSpacing = other.m_letterSpacing;
- m_wordSpacing = other.m_wordSpacing;
- m_isPlatformFont = other.m_isPlatformFont;
- return *this;
-}
-
-Font::~Font()
-{
-}
-
-bool Font::operator==(const Font& other) const
-{
- // Our FontData don't have to be checked, since checking the font description will be fine.
- // FIXME: This does not work if the font was made with the FontPlatformData constructor.
- if ((m_fontList && m_fontList->loadingCustomFonts()) ||
- (other.m_fontList && other.m_fontList->loadingCustomFonts()))
- return false;
-
- FontSelector* first = m_fontList ? m_fontList->fontSelector() : 0;
- FontSelector* second = other.m_fontList ? other.m_fontList->fontSelector() : 0;
-
- return first == second
- && m_fontDescription == other.m_fontDescription
- && m_letterSpacing == other.m_letterSpacing
- && m_wordSpacing == other.m_wordSpacing
- && (m_fontList ? m_fontList->generation() : 0) == (other.m_fontList ? other.m_fontList->generation() : 0);
-}
-
-const GlyphData& Font::glyphDataForCharacter(UChar32 c, bool mirror, bool forceSmallCaps) const
-{
- bool useSmallCapsFont = forceSmallCaps;
- if (m_fontDescription.smallCaps()) {
- UChar32 upperC = Unicode::toUpper(c);
- if (upperC != c) {
- c = upperC;
- useSmallCapsFont = true;
- }
- }
-
- if (mirror)
- c = mirroredChar(c);
-
- unsigned pageNumber = (c / GlyphPage::size);
-
- GlyphPageTreeNode* node = pageNumber ? m_pages.get(pageNumber) : m_pageZero;
- if (!node) {
- node = GlyphPageTreeNode::getRootChild(fontDataAt(0), pageNumber);
- if (pageNumber)
- m_pages.set(pageNumber, node);
- else
- m_pageZero = node;
- }
-
- GlyphPage* page;
- if (!useSmallCapsFont) {
- // Fastest loop, for the common case (not small caps).
- while (true) {
- page = node->page();
- if (page) {
- const GlyphData& data = page->glyphDataForCharacter(c);
- if (data.fontData)
- return data;
- if (node->isSystemFallback())
- break;
- }
-
- // Proceed with the fallback list.
- node = node->getChild(fontDataAt(node->level()), pageNumber);
- if (pageNumber)
- m_pages.set(pageNumber, node);
- else
- m_pageZero = node;
- }
- } else {
- while (true) {
- page = node->page();
- if (page) {
- const GlyphData& data = page->glyphDataForCharacter(c);
- if (data.fontData) {
- // The smallCapsFontData function should not normally return 0.
- // But if it does, we will just render the capital letter big.
- const SimpleFontData* smallCapsFontData = data.fontData->smallCapsFontData(m_fontDescription);
- if (!smallCapsFontData)
- return data;
-
- GlyphPageTreeNode* smallCapsNode = GlyphPageTreeNode::getRootChild(smallCapsFontData, pageNumber);
- const GlyphPage* smallCapsPage = smallCapsNode->page();
- if (smallCapsPage) {
- const GlyphData& data = smallCapsPage->glyphDataForCharacter(c);
- if (data.fontData)
- return data;
- }
-
- // Do not attempt system fallback off the smallCapsFontData. This is the very unlikely case that
- // a font has the lowercase character but the small caps font does not have its uppercase version.
- return smallCapsFontData->missingGlyphData();
- }
-
- if (node->isSystemFallback())
- break;
- }
-
- // Proceed with the fallback list.
- node = node->getChild(fontDataAt(node->level()), pageNumber);
- if (pageNumber)
- m_pages.set(pageNumber, node);
- else
- m_pageZero = node;
- }
- }
-
- ASSERT(page);
- ASSERT(node->isSystemFallback());
-
- // System fallback is character-dependent. When we get here, we
- // know that the character in question isn't in the system fallback
- // font's glyph page. Try to lazily create it here.
- UChar codeUnits[2];
- int codeUnitsLength;
- if (c <= 0xFFFF) {
- UChar c16 = c;
- if (Font::treatAsSpace(c16))
- codeUnits[0] = ' ';
- else if (Font::treatAsZeroWidthSpace(c16))
- codeUnits[0] = zeroWidthSpace;
- else
- codeUnits[0] = c16;
- codeUnitsLength = 1;
- } else {
- codeUnits[0] = U16_LEAD(c);
- codeUnits[1] = U16_TRAIL(c);
- codeUnitsLength = 2;
- }
- const SimpleFontData* characterFontData = FontCache::getFontDataForCharacters(*this, codeUnits, codeUnitsLength);
- if (useSmallCapsFont)
- characterFontData = characterFontData->smallCapsFontData(m_fontDescription);
- if (characterFontData) {
- // Got the fallback glyph and font.
- GlyphPage* fallbackPage = GlyphPageTreeNode::getRootChild(characterFontData, pageNumber)->page();
- const GlyphData& data = fallbackPage && fallbackPage->glyphDataForCharacter(c).fontData ? fallbackPage->glyphDataForCharacter(c) : characterFontData->missingGlyphData();
- // Cache it so we don't have to do system fallback again next time.
- if (!useSmallCapsFont)
- page->setGlyphDataForCharacter(c, data.glyph, data.fontData);
- return data;
- }
-
- // Even system fallback can fail; use the missing glyph in that case.
- // FIXME: It would be nicer to use the missing glyph from the last resort font instead.
- const GlyphData& data = primaryFont()->missingGlyphData();
- if (!useSmallCapsFont)
- page->setGlyphDataForCharacter(c, data.glyph, data.fontData);
- return data;
-}
-
-void Font::cachePrimaryFont() const
-{
- ASSERT(m_fontList);
- ASSERT(!m_cachedPrimaryFont);
- m_cachedPrimaryFont = m_fontList->primaryFont(this)->fontDataForCharacter(' ');
-}
-
-const FontData* Font::fontDataAt(unsigned index) const
-{
- ASSERT(m_fontList);
- return m_fontList->fontDataAt(this, index);
-}
-
-const FontData* Font::fontDataForCharacters(const UChar* characters, int length) const
-{
- ASSERT(m_fontList);
- return m_fontList->fontDataForCharacters(this, characters, length);
-}
-
-void Font::update(PassRefPtr<FontSelector> fontSelector) const
-{
- // FIXME: It is pretty crazy that we are willing to just poke into a RefPtr, but it ends up
- // being reasonably safe (because inherited fonts in the render tree pick up the new
- // style anyway. Other copies are transient, e.g., the state in the GraphicsContext, and
- // won't stick around long enough to get you in trouble). Still, this is pretty disgusting,
- // and could eventually be rectified by using RefPtrs for Fonts themselves.
- if (!m_fontList)
- m_fontList = FontFallbackList::create();
- m_fontList->invalidate(fontSelector);
- m_cachedPrimaryFont = 0;
- m_pageZero = 0;
- m_pages.clear();
-}
-
-int Font::width(const TextRun& run) const
-{
- return lroundf(floatWidth(run));
-}
-
-int Font::ascent() const
-{
- return primaryFont()->ascent();
-}
-
-int Font::descent() const
-{
- return primaryFont()->descent();
-}
-
-int Font::lineSpacing() const
-{
- return primaryFont()->lineSpacing();
-}
-
-int Font::lineGap() const
-{
- return primaryFont()->lineGap();
-}
-
-float Font::xHeight() const
-{
- return primaryFont()->xHeight();
-}
-
-unsigned Font::unitsPerEm() const
-{
- return primaryFont()->unitsPerEm();
-}
-
-int Font::spaceWidth() const
-{
- return (int)ceilf(primaryFont()->m_adjustedSpaceWidth + m_letterSpacing);
-}
-
-bool Font::isFixedPitch() const
-{
- ASSERT(m_fontList);
- return m_fontList->isFixedPitch(this);
-}
-
-void Font::setCodePath(CodePath p)
-{
- s_codePath = p;
-}
-
-Font::CodePath Font::codePath()
-{
- return s_codePath;
-}
-
-bool Font::canUseGlyphCache(const TextRun& run) const
-{
- switch (s_codePath) {
- case Auto:
- break;
- case Simple:
- return true;
- case Complex:
- return false;
- }
-
- // Start from 0 since drawing and highlighting also measure the characters before run->from
- for (int i = 0; i < run.length(); i++) {
- const UChar c = run[i];
- if (c < 0x300) // U+0300 through U+036F Combining diacritical marks
- continue;
- if (c <= 0x36F)
- return false;
-
- if (c < 0x0591 || c == 0x05BE) // U+0591 through U+05CF excluding U+05BE Hebrew combining marks, Hebrew punctuation Paseq, Sof Pasuq and Nun Hafukha
- continue;
- if (c <= 0x05CF)
- return false;
-
- if (c < 0x0600) // U+0600 through U+1059 Arabic, Syriac, Thaana, Devanagari, Bengali, Gurmukhi, Gujarati, Oriya, Tamil, Telugu, Kannada, Malayalam, Sinhala, Thai, Lao, Tibetan, Myanmar
- continue;
- if (c <= 0x1059)
- return false;
-
- if (c < 0x1100) // U+1100 through U+11FF Hangul Jamo (only Ancient Korean should be left here if you precompose; Modern Korean will be precomposed as a result of step A)
- continue;
- if (c <= 0x11FF)
- return false;
-
- if (c < 0x1780) // U+1780 through U+18AF Khmer, Mongolian
- continue;
- if (c <= 0x18AF)
- return false;
-
- if (c < 0x1900) // U+1900 through U+194F Limbu (Unicode 4.0)
- continue;
- if (c <= 0x194F)
- return false;
-
- if (c < 0x20D0) // U+20D0 through U+20FF Combining marks for symbols
- continue;
- if (c <= 0x20FF)
- return false;
-
- if (c < 0xFE20) // U+FE20 through U+FE2F Combining half marks
- continue;
- if (c <= 0xFE2F)
- return false;
- }
-
- return true;
-
-}
-
-void Font::drawSimpleText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const
-{
- // This glyph buffer holds our glyphs+advances+font data for each glyph.
- GlyphBuffer glyphBuffer;
-
- float startX = point.x();
- WidthIterator it(this, run);
- it.advance(from);
- float beforeWidth = it.m_runWidthSoFar;
- it.advance(to, &glyphBuffer);
-
- // We couldn't generate any glyphs for the run. Give up.
- if (glyphBuffer.isEmpty())
- return;
-
- float afterWidth = it.m_runWidthSoFar;
-
- if (run.rtl()) {
- float finalRoundingWidth = it.m_finalRoundingWidth;
- it.advance(run.length());
- startX += finalRoundingWidth + it.m_runWidthSoFar - afterWidth;
- } else
- startX += beforeWidth;
-
- // Swap the order of the glyphs if right-to-left.
- if (run.rtl())
- for (int i = 0, end = glyphBuffer.size() - 1; i < glyphBuffer.size() / 2; ++i, --end)
- glyphBuffer.swap(i, end);
-
- // Calculate the starting point of the glyphs to be displayed by adding
- // all the advances up to the first glyph.
- FloatPoint startPoint(startX, point.y());
- drawGlyphBuffer(context, glyphBuffer, run, startPoint);
-}
-
-void Font::drawGlyphBuffer(GraphicsContext* context, const GlyphBuffer& glyphBuffer,
- const TextRun& run, const FloatPoint& point) const
-{
- // Draw each contiguous run of glyphs that use the same font data.
- const SimpleFontData* fontData = glyphBuffer.fontDataAt(0);
- FloatSize offset = glyphBuffer.offsetAt(0);
- FloatPoint startPoint(point);
- float nextX = startPoint.x();
- int lastFrom = 0;
- int nextGlyph = 0;
- while (nextGlyph < glyphBuffer.size()) {
- const SimpleFontData* nextFontData = glyphBuffer.fontDataAt(nextGlyph);
- FloatSize nextOffset = glyphBuffer.offsetAt(nextGlyph);
- if (nextFontData != fontData || nextOffset != offset) {
- drawGlyphs(context, fontData, glyphBuffer, lastFrom, nextGlyph - lastFrom, startPoint);
-
- lastFrom = nextGlyph;
- fontData = nextFontData;
- offset = nextOffset;
- startPoint.setX(nextX);
- }
- nextX += glyphBuffer.advanceAt(nextGlyph);
- nextGlyph++;
- }
-
- drawGlyphs(context, fontData, glyphBuffer, lastFrom, nextGlyph - lastFrom, startPoint);
-}
-
-void Font::drawText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const
-{
- // Don't draw anything while we are using custom fonts that are in the process of loading.
- if (m_fontList && m_fontList->loadingCustomFonts())
- return;
-
- to = (to == -1 ? run.length() : to);
-
-#if ENABLE(SVG_FONTS)
- if (primaryFont()->isSVGFont()) {
- drawTextUsingSVGFont(context, run, point, from, to);
- return;
- }
-#endif
-
- if (canUseGlyphCache(run))
- drawSimpleText(context, run, point, from, to);
- else
- drawComplexText(context, run, point, from, to);
-}
-
-float Font::floatWidth(const TextRun& run) const
-{
-#if ENABLE(SVG_FONTS)
- if (primaryFont()->isSVGFont())
- return floatWidthUsingSVGFont(run);
-#endif
-
- if (canUseGlyphCache(run))
- return floatWidthForSimpleText(run, 0);
- return floatWidthForComplexText(run);
-}
-
-float Font::floatWidth(const TextRun& run, int extraCharsAvailable, int& charsConsumed, String& glyphName) const
-{
-#if ENABLE(SVG_FONTS)
- if (primaryFont()->isSVGFont())
- return floatWidthUsingSVGFont(run, extraCharsAvailable, charsConsumed, glyphName);
-#endif
-
- charsConsumed = run.length();
- glyphName = "";
- if (canUseGlyphCache(run))
- return floatWidthForSimpleText(run, 0);
- return floatWidthForComplexText(run);
-}
-
-float Font::floatWidthForSimpleText(const TextRun& run, GlyphBuffer* glyphBuffer) const
-{
- WidthIterator it(this, run);
- it.advance(run.length(), glyphBuffer);
- return it.m_runWidthSoFar;
-}
-
-FloatRect Font::selectionRectForText(const TextRun& run, const IntPoint& point, int h, int from, int to) const
-{
-#if ENABLE(SVG_FONTS)
- if (primaryFont()->isSVGFont())
- return selectionRectForTextUsingSVGFont(run, point, h, from, to);
-#endif
-
- to = (to == -1 ? run.length() : to);
- if (canUseGlyphCache(run))
- return selectionRectForSimpleText(run, point, h, from, to);
- return selectionRectForComplexText(run, point, h, from, to);
-}
-
-FloatRect Font::selectionRectForSimpleText(const TextRun& run, const IntPoint& point, int h, int from, int to) const
-{
- WidthIterator it(this, run);
- it.advance(from);
- float beforeWidth = it.m_runWidthSoFar;
- it.advance(to);
- float afterWidth = it.m_runWidthSoFar;
-
- // Using roundf() rather than ceilf() for the right edge as a compromise to ensure correct caret positioning
- if (run.rtl()) {
- it.advance(run.length());
- float totalWidth = it.m_runWidthSoFar;
- return FloatRect(point.x() + floorf(totalWidth - afterWidth), point.y(), roundf(totalWidth - beforeWidth) - floorf(totalWidth - afterWidth), h);
- } else {
- return FloatRect(point.x() + floorf(beforeWidth), point.y(), roundf(afterWidth) - floorf(beforeWidth), h);
- }
-}
-
-int Font::offsetForPosition(const TextRun& run, int x, bool includePartialGlyphs) const
-{
-#if ENABLE(SVG_FONTS)
- if (primaryFont()->isSVGFont())
- return offsetForPositionForTextUsingSVGFont(run, x, includePartialGlyphs);
-#endif
-
- if (canUseGlyphCache(run))
- return offsetForPositionForSimpleText(run, x, includePartialGlyphs);
- return offsetForPositionForComplexText(run, x, includePartialGlyphs);
-}
-
-int Font::offsetForPositionForSimpleText(const TextRun& run, int x, bool includePartialGlyphs) const
-{
- float delta = (float)x;
-
- WidthIterator it(this, run);
- GlyphBuffer localGlyphBuffer;
- unsigned offset;
- if (run.rtl()) {
- delta -= floatWidthForSimpleText(run, 0);
- while (1) {
- offset = it.m_currentCharacter;
- float w;
- if (!it.advanceOneCharacter(w, &localGlyphBuffer))
- break;
- delta += w;
- if (includePartialGlyphs) {
- if (delta - w / 2 >= 0)
- break;
- } else {
- if (delta >= 0)
- break;
- }
- }
- } else {
- while (1) {
- offset = it.m_currentCharacter;
- float w;
- if (!it.advanceOneCharacter(w, &localGlyphBuffer))
- break;
- delta -= w;
- if (includePartialGlyphs) {
- if (delta + w / 2 <= 0)
- break;
- } else {
- if (delta <= 0)
- break;
- }
- }
- }
-
- return offset;
-}
-
-#if ENABLE(SVG_FONTS)
-bool Font::isSVGFont() const
-{
- return primaryFont()->isSVGFont();
-}
-#endif
-
-FontSelector* Font::fontSelector() const
-{
- return m_fontList ? m_fontList->fontSelector() : 0;
-}
-
-}
diff --git a/WebCore/platform/graphics/Font.h b/WebCore/platform/graphics/Font.h
deleted file mode 100644
index a99ce12..0000000
--- a/WebCore/platform/graphics/Font.h
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
- * (C) 2000 Antti Koivisto (koivisto@kde.org)
- * (C) 2000 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2003, 2006, 2007 Apple Computer, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef Font_h
-#define Font_h
-
-#include "TextRun.h"
-#include "FontDescription.h"
-#include <wtf/HashMap.h>
-
-#if PLATFORM(QT)
-#include <QtGui/qfont.h>
-#include <QtGui/qfontmetrics.h>
-#endif
-
-namespace WebCore {
-
-class FloatPoint;
-class FloatRect;
-class FontData;
-class FontFallbackList;
-class FontPlatformData;
-class FontSelector;
-class GlyphBuffer;
-class GlyphPageTreeNode;
-class GraphicsContext;
-class IntPoint;
-class SimpleFontData;
-class SVGFontElement;
-
-struct GlyphData;
-
-class Font {
-public:
- Font();
- Font(const FontDescription&, short letterSpacing, short wordSpacing);
-#if !PLATFORM(QT)
- Font(const FontPlatformData&, bool isPrinting); // This constructor is only used if the platform wants to start with a native font.
-#endif
- ~Font();
-
- Font(const Font&);
- Font& operator=(const Font&);
-
- bool operator==(const Font& other) const;
- bool operator!=(const Font& other) const {
- return !(*this == other);
- }
-
- const FontDescription& fontDescription() const { return m_fontDescription; }
-
- int pixelSize() const { return fontDescription().computedPixelSize(); }
- float size() const { return fontDescription().computedSize(); }
-
- void update(PassRefPtr<FontSelector>) const;
-
- void drawText(GraphicsContext*, const TextRun&, const FloatPoint&, int from = 0, int to = -1) const;
-
- int width(const TextRun&) const;
- float floatWidth(const TextRun&) const;
- float floatWidth(const TextRun& run, int extraCharsAvailable, int& charsConsumed, String& glyphName) const;
-
- int offsetForPosition(const TextRun&, int position, bool includePartialGlyphs) const;
- FloatRect selectionRectForText(const TextRun&, const IntPoint&, int h, int from = 0, int to = -1) const;
-
- bool isSmallCaps() const { return m_fontDescription.smallCaps(); }
-
- short wordSpacing() const { return m_wordSpacing; }
- short letterSpacing() const { return m_letterSpacing; }
-#if !PLATFORM(QT)
- void setWordSpacing(short s) { m_wordSpacing = s; }
- void setLetterSpacing(short s) { m_letterSpacing = s; }
-#else
- void setWordSpacing(short s);
- void setLetterSpacing(short s);
-#endif
- bool isFixedPitch() const;
- bool isPrinterFont() const { return m_fontDescription.usePrinterFont(); }
-
- FontRenderingMode renderingMode() const { return m_fontDescription.renderingMode(); }
-
- FontFamily& firstFamily() { return m_fontDescription.firstFamily(); }
- const FontFamily& family() const { return m_fontDescription.family(); }
-
- bool italic() const { return m_fontDescription.italic(); }
- FontWeight weight() const { return m_fontDescription.weight(); }
-
-#if !PLATFORM(QT)
- bool isPlatformFont() const { return m_isPlatformFont; }
-#endif
-
-#if PLATFORM(QT)
- inline const QFont &font() const { return m_font; }
- inline const QFont &scFont() const { return m_scFont; }
-#endif
-
- // Metrics that we query the FontFallbackList for.
- int ascent() const;
- int descent() const;
- int height() const { return ascent() + descent(); }
- int lineSpacing() const;
- int lineGap() const;
- float xHeight() const;
- unsigned unitsPerEm() const;
- int spaceWidth() const;
- int tabWidth() const { return 8 * spaceWidth(); }
-
-#if !PLATFORM(QT)
- const SimpleFontData* primaryFont() const {
- if (!m_cachedPrimaryFont)
- cachePrimaryFont();
- return m_cachedPrimaryFont;
- }
-
- const FontData* fontDataAt(unsigned) const;
- const GlyphData& glyphDataForCharacter(UChar32, bool mirror, bool forceSmallCaps = false) const;
- // Used for complex text, and does not utilize the glyph map cache.
- const FontData* fontDataForCharacters(const UChar*, int length) const;
-
-private:
- bool canUseGlyphCache(const TextRun&) const;
- void drawSimpleText(GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const;
-#if ENABLE(SVG_FONTS)
- void drawTextUsingSVGFont(GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const;
- float floatWidthUsingSVGFont(const TextRun&) const;
- float floatWidthUsingSVGFont(const TextRun&, int extraCharsAvailable, int& charsConsumed, String& glyphName) const;
- FloatRect selectionRectForTextUsingSVGFont(const TextRun&, const IntPoint&, int h, int from, int to) const;
- int offsetForPositionForTextUsingSVGFont(const TextRun&, int position, bool includePartialGlyphs) const;
-#endif
- void drawGlyphs(GraphicsContext*, const SimpleFontData*, const GlyphBuffer&, int from, int to, const FloatPoint&) const;
- void drawGlyphBuffer(GraphicsContext*, const GlyphBuffer&, const TextRun&, const FloatPoint&) const;
- void drawComplexText(GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const;
- float floatWidthForSimpleText(const TextRun&, GlyphBuffer*) const;
- float floatWidthForComplexText(const TextRun&) const;
- int offsetForPositionForSimpleText(const TextRun&, int position, bool includePartialGlyphs) const;
- int offsetForPositionForComplexText(const TextRun&, int position, bool includePartialGlyphs) const;
- FloatRect selectionRectForSimpleText(const TextRun&, const IntPoint&, int h, int from, int to) const;
- FloatRect selectionRectForComplexText(const TextRun&, const IntPoint&, int h, int from, int to) const;
- void cachePrimaryFont() const;
-#endif
- friend struct WidthIterator;
-
-public:
-#if PLATFORM(QT)
- FontSelector* fontSelector() const { return 0; }
-#else
- // Useful for debugging the different font rendering code paths.
- enum CodePath { Auto, Simple, Complex };
- static void setCodePath(CodePath);
- static CodePath codePath();
- static CodePath s_codePath;
-
- static const uint8_t gRoundingHackCharacterTable[256];
- static bool isRoundingHackCharacter(UChar32 c)
- {
- return (((c & ~0xFF) == 0 && gRoundingHackCharacterTable[c]));
- }
-
- FontSelector* fontSelector() const;
-#endif
- static bool treatAsSpace(UChar c) { return c == ' ' || c == '\t' || c == '\n' || c == 0x00A0; }
- static bool treatAsZeroWidthSpace(UChar c) { return c < 0x20 || (c >= 0x7F && c < 0xA0) || c == 0x200e || c == 0x200f || (c >= 0x202a && c <= 0x202e) || c == 0xFFFC; }
-
-#if ENABLE(SVG_FONTS)
- bool isSVGFont() const;
- SVGFontElement* svgFont() const;
-#endif
-
-private:
- FontDescription m_fontDescription;
-#if !PLATFORM(QT)
- mutable RefPtr<FontFallbackList> m_fontList;
- mutable HashMap<int, GlyphPageTreeNode*> m_pages;
- mutable GlyphPageTreeNode* m_pageZero;
- mutable const SimpleFontData* m_cachedPrimaryFont;
-#endif
- short m_letterSpacing;
- short m_wordSpacing;
-#if !PLATFORM(QT)
- bool m_isPlatformFont;
-#else
- QFont m_font;
- QFont m_scFont;
- int m_spaceWidth;
-#endif
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/graphics/FontCache.cpp b/WebCore/platform/graphics/FontCache.cpp
deleted file mode 100644
index 1c5a987..0000000
--- a/WebCore/platform/graphics/FontCache.cpp
+++ /dev/null
@@ -1,425 +0,0 @@
-/*
- * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FontCache.h"
-
-#include "Font.h"
-#include "FontFallbackList.h"
-#include "FontPlatformData.h"
-#include "FontSelector.h"
-#include "StringHash.h"
-#include <wtf/HashMap.h>
-#include <wtf/ListHashSet.h>
-
-using namespace WTF;
-
-namespace WebCore {
-
-struct FontPlatformDataCacheKey {
- FontPlatformDataCacheKey(const AtomicString& family = AtomicString(), unsigned size = 0, unsigned weight = 0, bool italic = false,
- bool isPrinterFont = false, FontRenderingMode renderingMode = NormalRenderingMode)
- : m_family(family)
- , m_size(size)
- , m_weight(weight)
- , m_italic(italic)
- , m_printerFont(isPrinterFont)
- , m_renderingMode(renderingMode)
- {
- }
-
- FontPlatformDataCacheKey(HashTableDeletedValueType) : m_size(hashTableDeletedSize()) { }
- bool isHashTableDeletedValue() const { return m_size == hashTableDeletedSize(); }
-
- bool operator==(const FontPlatformDataCacheKey& other) const
- {
- return equalIgnoringCase(m_family, other.m_family) && m_size == other.m_size &&
- m_weight == other.m_weight && m_italic == other.m_italic && m_printerFont == other.m_printerFont &&
- m_renderingMode == other.m_renderingMode;
- }
-
- AtomicString m_family;
- unsigned m_size;
- unsigned m_weight;
- bool m_italic;
- bool m_printerFont;
- FontRenderingMode m_renderingMode;
-
-private:
- static unsigned hashTableDeletedSize() { return 0xFFFFFFFFU; }
-};
-
-inline unsigned computeHash(const FontPlatformDataCacheKey& fontKey)
-{
- unsigned hashCodes[4] = {
- CaseFoldingHash::hash(fontKey.m_family),
- fontKey.m_size,
- fontKey.m_weight,
- static_cast<unsigned>(fontKey.m_italic) << 2 | static_cast<unsigned>(fontKey.m_printerFont) << 1 | static_cast<unsigned>(fontKey.m_renderingMode)
- };
- return StringImpl::computeHash(reinterpret_cast<UChar*>(hashCodes), sizeof(hashCodes) / sizeof(UChar));
-}
-
-struct FontPlatformDataCacheKeyHash {
- static unsigned hash(const FontPlatformDataCacheKey& font)
- {
- return computeHash(font);
- }
-
- static bool equal(const FontPlatformDataCacheKey& a, const FontPlatformDataCacheKey& b)
- {
- return a == b;
- }
-
- static const bool safeToCompareToEmptyOrDeleted = true;
-};
-
-struct FontPlatformDataCacheKeyTraits : WTF::GenericHashTraits<FontPlatformDataCacheKey> {
- static const bool emptyValueIsZero = true;
- static const FontPlatformDataCacheKey& emptyValue()
- {
- static FontPlatformDataCacheKey key(nullAtom);
- return key;
- }
- static void constructDeletedValue(FontPlatformDataCacheKey& slot)
- {
- new (&slot) FontPlatformDataCacheKey(HashTableDeletedValue);
- }
- static bool isDeletedValue(const FontPlatformDataCacheKey& value)
- {
- return value.isHashTableDeletedValue();
- }
-};
-
-typedef HashMap<FontPlatformDataCacheKey, FontPlatformData*, FontPlatformDataCacheKeyHash, FontPlatformDataCacheKeyTraits> FontPlatformDataCache;
-
-static FontPlatformDataCache* gFontPlatformDataCache = 0;
-
-static const AtomicString& alternateFamilyName(const AtomicString& familyName)
-{
- // Alias Courier <-> Courier New
- static AtomicString courier("Courier"), courierNew("Courier New");
- if (equalIgnoringCase(familyName, courier))
- return courierNew;
- if (equalIgnoringCase(familyName, courierNew))
- return courier;
-
- // Alias Times and Times New Roman.
- static AtomicString times("Times"), timesNewRoman("Times New Roman");
- if (equalIgnoringCase(familyName, times))
- return timesNewRoman;
- if (equalIgnoringCase(familyName, timesNewRoman))
- return times;
-
- // Alias Arial and Helvetica
- static AtomicString arial("Arial"), helvetica("Helvetica");
- if (equalIgnoringCase(familyName, arial))
- return helvetica;
- if (equalIgnoringCase(familyName, helvetica))
- return arial;
-
- return emptyAtom;
-}
-
-FontPlatformData* FontCache::getCachedFontPlatformData(const FontDescription& fontDescription,
- const AtomicString& familyName,
- bool checkingAlternateName)
-{
- if (!gFontPlatformDataCache) {
- gFontPlatformDataCache = new FontPlatformDataCache;
- platformInit();
- }
-
- FontPlatformDataCacheKey key(familyName, fontDescription.computedPixelSize(), fontDescription.weight(), fontDescription.italic(),
- fontDescription.usePrinterFont(), fontDescription.renderingMode());
- FontPlatformData* result = 0;
- bool foundResult;
- FontPlatformDataCache::iterator it = gFontPlatformDataCache->find(key);
- if (it == gFontPlatformDataCache->end()) {
- result = createFontPlatformData(fontDescription, familyName);
- gFontPlatformDataCache->set(key, result);
- foundResult = result;
- } else {
- result = it->second;
- foundResult = true;
- }
-
- if (!foundResult && !checkingAlternateName) {
- // We were unable to find a font. We have a small set of fonts that we alias to other names,
- // e.g., Arial/Helvetica, Courier/Courier New, etc. Try looking up the font under the aliased name.
- const AtomicString& alternateName = alternateFamilyName(familyName);
- if (!alternateName.isEmpty())
- result = getCachedFontPlatformData(fontDescription, alternateName, true);
- if (result)
- gFontPlatformDataCache->set(key, new FontPlatformData(*result)); // Cache the result under the old name.
- }
-
- return result;
-}
-
-struct FontDataCacheKeyHash {
- static unsigned hash(const FontPlatformData& platformData)
- {
- return platformData.hash();
- }
-
- static bool equal(const FontPlatformData& a, const FontPlatformData& b)
- {
- return a == b;
- }
-
- static const bool safeToCompareToEmptyOrDeleted = true;
-};
-
-struct FontDataCacheKeyTraits : WTF::GenericHashTraits<FontPlatformData> {
- static const bool emptyValueIsZero = true;
- static const bool needsDestruction = true;
- static const FontPlatformData& emptyValue()
- {
- static FontPlatformData key;
- return key;
- }
- static void constructDeletedValue(FontPlatformData& slot)
- {
- new (&slot) FontPlatformData(HashTableDeletedValue);
- }
- static bool isDeletedValue(const FontPlatformData& value)
- {
- return value.isHashTableDeletedValue();
- }
-};
-
-typedef HashMap<FontPlatformData, pair<SimpleFontData*, unsigned>, FontDataCacheKeyHash, FontDataCacheKeyTraits> FontDataCache;
-
-static FontDataCache* gFontDataCache = 0;
-
-const int cMaxInactiveFontData = 120; // Pretty Low Threshold
-const float cTargetInactiveFontData = 100;
-static ListHashSet<const SimpleFontData*>* gInactiveFontData = 0;
-
-SimpleFontData* FontCache::getCachedFontData(const FontPlatformData* platformData)
-{
- if (!platformData)
- return 0;
-
- if (!gFontDataCache) {
- gFontDataCache = new FontDataCache;
- gInactiveFontData = new ListHashSet<const SimpleFontData*>;
- }
-
- FontDataCache::iterator result = gFontDataCache->find(*platformData);
- if (result == gFontDataCache->end()) {
- pair<SimpleFontData*, unsigned> newValue(new SimpleFontData(*platformData), 1);
- gFontDataCache->set(*platformData, newValue);
- return newValue.first;
- }
- if (!result.get()->second.second++) {
- ASSERT(gInactiveFontData->contains(result.get()->second.first));
- gInactiveFontData->remove(result.get()->second.first);
- }
-
- return result.get()->second.first;
-}
-
-void FontCache::releaseFontData(const SimpleFontData* fontData)
-{
- ASSERT(gFontDataCache);
- ASSERT(!fontData->isCustomFont());
-
- FontDataCache::iterator it = gFontDataCache->find(fontData->platformData());
- ASSERT(it != gFontDataCache->end());
-
- if (!--it->second.second) {
- gInactiveFontData->add(fontData);
- if (gInactiveFontData->size() > cMaxInactiveFontData)
- purgeInactiveFontData(gInactiveFontData->size() - cTargetInactiveFontData);
- }
-}
-
-void FontCache::purgeInactiveFontData(int count)
-{
- if (!gInactiveFontData)
- return;
-
- static bool isPurging; // Guard against reentry when e.g. a deleted FontData releases its small caps FontData.
- if (isPurging)
- return;
-
- isPurging = true;
-
- ListHashSet<const SimpleFontData*>::iterator end = gInactiveFontData->end();
- ListHashSet<const SimpleFontData*>::iterator it = gInactiveFontData->begin();
- for (int i = 0; i < count && it != end; ++it, ++i) {
- const SimpleFontData* fontData = *it.get();
- gFontDataCache->remove(fontData->platformData());
- delete fontData;
- }
-
- if (it == end) {
- // Removed everything
- gInactiveFontData->clear();
- } else {
- for (int i = 0; i < count; ++i)
- gInactiveFontData->remove(gInactiveFontData->begin());
- }
-
- Vector<FontPlatformDataCacheKey> keysToRemove;
- keysToRemove.reserveCapacity(gFontPlatformDataCache->size());
- FontPlatformDataCache::iterator platformDataEnd = gFontPlatformDataCache->end();
- for (FontPlatformDataCache::iterator platformData = gFontPlatformDataCache->begin(); platformData != platformDataEnd; ++platformData) {
- if (platformData->second && !gFontDataCache->contains(*platformData->second))
- keysToRemove.append(platformData->first);
- }
-
- size_t keysToRemoveCount = keysToRemove.size();
- for (size_t i = 0; i < keysToRemoveCount; ++i)
- delete gFontPlatformDataCache->take(keysToRemove[i]);
-
- isPurging = false;
-}
-
-size_t FontCache::fontDataCount()
-{
- if (gFontDataCache)
- return gFontDataCache->size();
- return 0;
-}
-
-size_t FontCache::inactiveFontDataCount()
-{
- if (gInactiveFontData)
- return gInactiveFontData->size();
- return 0;
-}
-
-const FontData* FontCache::getFontData(const Font& font, int& familyIndex, FontSelector* fontSelector)
-{
- FontPlatformData* result = 0;
-
- int startIndex = familyIndex;
- const FontFamily* startFamily = &font.fontDescription().family();
- for (int i = 0; startFamily && i < startIndex; i++)
- startFamily = startFamily->next();
- const FontFamily* currFamily = startFamily;
- while (currFamily && !result) {
- familyIndex++;
- if (currFamily->family().length()) {
- if (fontSelector) {
- FontData* data = fontSelector->getFontData(font.fontDescription(), currFamily->family());
- if (data)
- return data;
- }
- result = getCachedFontPlatformData(font.fontDescription(), currFamily->family());
- }
- currFamily = currFamily->next();
- }
-
- if (!currFamily)
- familyIndex = cAllFamiliesScanned;
-
- if (!result)
- // We didn't find a font. Try to find a similar font using our own specific knowledge about our platform.
- // For example on OS X, we know to map any families containing the words Arabic, Pashto, or Urdu to the
- // Geeza Pro font.
- result = getSimilarFontPlatformData(font);
-
- if (!result && startIndex == 0) {
- // If it's the primary font that we couldn't find, we try the following. In all other cases, we will
- // just use per-character system fallback.
-
- if (fontSelector) {
- // Try the user's preferred standard font.
- if (FontData* data = fontSelector->getFontData(font.fontDescription(), "-webkit-standard"))
- return data;
- }
-
- // Still no result. Hand back our last resort fallback font.
- result = getLastResortFallbackFont(font.fontDescription());
- }
-
- // Now that we have a result, we need to go from FontPlatformData -> FontData.
- return getCachedFontData(result);
-}
-
-static HashSet<FontSelector*>* gClients;
-
-void FontCache::addClient(FontSelector* client)
-{
- if (!gClients)
- gClients = new HashSet<FontSelector*>;
-
- ASSERT(!gClients->contains(client));
- gClients->add(client);
-}
-
-void FontCache::removeClient(FontSelector* client)
-{
- ASSERT(gClients);
- ASSERT(gClients->contains(client));
-
- gClients->remove(client);
-}
-
-static unsigned gGeneration = 0;
-
-unsigned FontCache::generation()
-{
- return gGeneration;
-}
-
-void FontCache::invalidate()
-{
- if (!gClients) {
- ASSERT(!gFontPlatformDataCache);
- return;
- }
-
- if (gFontPlatformDataCache) {
- deleteAllValues(*gFontPlatformDataCache);
- delete gFontPlatformDataCache;
- gFontPlatformDataCache = new FontPlatformDataCache;
- }
-
- gGeneration++;
-
- Vector<RefPtr<FontSelector> > clients;
- size_t numClients = gClients->size();
- clients.reserveCapacity(numClients);
- HashSet<FontSelector*>::iterator end = gClients->end();
- for (HashSet<FontSelector*>::iterator it = gClients->begin(); it != end; ++it)
- clients.append(*it);
-
- ASSERT(numClients == clients.size());
- for (size_t i = 0; i < numClients; ++i)
- clients[i]->fontCacheInvalidated();
-
- purgeInactiveFontData();
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/graphics/FontCache.h b/WebCore/platform/graphics/FontCache.h
deleted file mode 100644
index 816fe64..0000000
--- a/WebCore/platform/graphics/FontCache.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2006, 2008 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef FontCache_h
-#define FontCache_h
-
-#include <limits.h>
-#include <wtf/Vector.h>
-#include <wtf/unicode/Unicode.h>
-
-#if PLATFORM(WIN)
-#include <objidl.h>
-#include <mlang.h>
-#endif
-
-namespace WebCore
-{
-
-class AtomicString;
-class Font;
-class FontPlatformData;
-class FontData;
-class FontDescription;
-class FontSelector;
-class SimpleFontData;
-
-class FontCache {
-public:
- static const FontData* getFontData(const Font&, int& familyIndex, FontSelector*);
- static void releaseFontData(const SimpleFontData*);
-
- // This method is implemented by the platform.
- // FIXME: Font data returned by this method never go inactive because callers don't track and release them.
- static const SimpleFontData* getFontDataForCharacters(const Font&, const UChar* characters, int length);
-
- // Also implemented by the platform.
- static void platformInit();
-
-#if PLATFORM(WIN)
- static IMLangFontLink2* getFontLinkInterface();
-#endif
-
- static void getTraitsInFamily(const AtomicString&, Vector<unsigned>&);
-
- static FontPlatformData* getCachedFontPlatformData(const FontDescription&, const AtomicString& family, bool checkingAlternateName = false);
- static SimpleFontData* getCachedFontData(const FontPlatformData*);
- static FontPlatformData* getLastResortFallbackFont(const FontDescription&);
-
- static void addClient(FontSelector*);
- static void removeClient(FontSelector*);
-
- static unsigned generation();
- static void invalidate();
-
- static size_t fontDataCount();
- static size_t inactiveFontDataCount();
- static void purgeInactiveFontData(int count = INT_MAX);
-
-private:
- // These methods are implemented by each platform.
- static FontPlatformData* getSimilarFontPlatformData(const Font&);
- static FontPlatformData* createFontPlatformData(const FontDescription&, const AtomicString& family);
-
- friend class SimpleFontData;
- friend class FontFallbackList;
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/graphics/FontData.cpp b/WebCore/platform/graphics/FontData.cpp
deleted file mode 100644
index c40e13c..0000000
--- a/WebCore/platform/graphics/FontData.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FontData.h"
-
-namespace WebCore {
-
-FontData::~FontData()
-{
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/graphics/FontData.h b/WebCore/platform/graphics/FontData.h
deleted file mode 100644
index cb79919..0000000
--- a/WebCore/platform/graphics/FontData.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef FontData_h
-#define FontData_h
-
-#include <wtf/Noncopyable.h>
-#include <wtf/unicode/Unicode.h>
-
-namespace WebCore {
-
-class SimpleFontData;
-
-class FontData : Noncopyable {
-public:
- FontData()
- : m_maxGlyphPageTreeLevel(0)
- {
- }
-
- virtual ~FontData();
-
- virtual const SimpleFontData* fontDataForCharacter(UChar32) const = 0;
- virtual bool containsCharacters(const UChar*, int length) const = 0;
- virtual bool isCustomFont() const = 0;
- virtual bool isLoading() const = 0;
- virtual bool isSegmented() const = 0;
-
- void setMaxGlyphPageTreeLevel(unsigned level) const { m_maxGlyphPageTreeLevel = level; }
- unsigned maxGlyphPageTreeLevel() const { return m_maxGlyphPageTreeLevel; }
-
-private:
- mutable unsigned m_maxGlyphPageTreeLevel;
-};
-
-} // namespace WebCore
-
-#endif // FontData_h
diff --git a/WebCore/platform/graphics/FontDescription.cpp b/WebCore/platform/graphics/FontDescription.cpp
deleted file mode 100644
index 58ddf81..0000000
--- a/WebCore/platform/graphics/FontDescription.cpp
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (C) 2007 Nicholas Shanks <contact@nickshanks.com>
- * Copyright (C) 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FontDescription.h"
-
-namespace WebCore {
-
-FontWeight FontDescription::lighterWeight(void) const
-{
- // FIXME: Should actually return the CSS weight corresponding to next lightest
- // weight of the currently used font family.
- switch (m_weight) {
- case FontWeight100:
- case FontWeight200:
- return FontWeight100;
-
- case FontWeight300:
- return FontWeight200;
-
- case FontWeight400:
- case FontWeight500:
- return FontWeight300;
-
- case FontWeight600:
- case FontWeight700:
- return FontWeight400;
-
- case FontWeight800:
- return FontWeight500;
-
- case FontWeight900:
- return FontWeight700;
- }
- ASSERT_NOT_REACHED();
- return FontWeightNormal;
-}
-
-FontWeight FontDescription::bolderWeight(void) const
-{
- // FIXME: Should actually return the CSS weight corresponding to next heaviest
- // weight of the currently used font family.
- switch (m_weight) {
- case FontWeight100:
- case FontWeight200:
- return FontWeight300;
-
- case FontWeight300:
- return FontWeight400;
-
- case FontWeight400:
- case FontWeight500:
- return FontWeight700;
-
- case FontWeight600:
- case FontWeight700:
- return FontWeight800;
-
- case FontWeight800:
- case FontWeight900:
- return FontWeight900;
- }
- ASSERT_NOT_REACHED();
- return FontWeightNormal;
-}
-
-FontTraitsMask FontDescription::traitsMask() const
-{
- return static_cast<FontTraitsMask>((m_italic ? FontStyleItalicMask : FontStyleNormalMask)
- | (m_smallCaps ? FontVariantSmallCapsMask : FontVariantNormalMask)
- | (FontWeight100Mask << (m_weight - FontWeight100)));
-
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/graphics/FontDescription.h b/WebCore/platform/graphics/FontDescription.h
deleted file mode 100644
index d13e86a..0000000
--- a/WebCore/platform/graphics/FontDescription.h
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
- * (C) 2000 Antti Koivisto (koivisto@kde.org)
- * (C) 2000 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIother.m_ If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USm_
- *
- */
-
-#ifndef FontDescription_h
-#define FontDescription_h
-
-#include "FontFamily.h"
-#include "FontRenderingMode.h"
-#include "FontTraitsMask.h"
-
-namespace WebCore {
-
-enum FontWeight {
- FontWeight100,
- FontWeight200,
- FontWeight300,
- FontWeight400,
- FontWeight500,
- FontWeight600,
- FontWeight700,
- FontWeight800,
- FontWeight900,
- FontWeightNormal = FontWeight400,
- FontWeightBold = FontWeight700
-};
-
-class FontDescription {
-public:
- enum GenericFamilyType { NoFamily, StandardFamily, SerifFamily, SansSerifFamily,
- MonospaceFamily, CursiveFamily, FantasyFamily };
-
- FontDescription()
- : m_specifiedSize(0)
- , m_computedSize(0)
- , m_italic(false)
- , m_smallCaps(false)
- , m_isAbsoluteSize(false)
- , m_weight(FontWeightNormal)
- , m_genericFamily(NoFamily)
- , m_usePrinterFont(false)
- , m_renderingMode(NormalRenderingMode)
- , m_keywordSize(0)
- {
- }
-
- bool operator==(const FontDescription&) const;
- bool operator!=(const FontDescription& other) const { return !(*this == other); }
-
- const FontFamily& family() const { return m_familyList; }
- FontFamily& firstFamily() { return m_familyList; }
- float specifiedSize() const { return m_specifiedSize; }
- float computedSize() const { return m_computedSize; }
- bool italic() const { return m_italic; }
- int computedPixelSize() const { return int(m_computedSize + 0.5f); }
- bool smallCaps() const { return m_smallCaps; }
- bool isAbsoluteSize() const { return m_isAbsoluteSize; }
- FontWeight weight() const { return static_cast<FontWeight>(m_weight); }
- FontWeight lighterWeight() const;
- FontWeight bolderWeight() const;
- GenericFamilyType genericFamily() const { return static_cast<GenericFamilyType>(m_genericFamily); }
- bool usePrinterFont() const { return m_usePrinterFont; }
- FontRenderingMode renderingMode() const { return static_cast<FontRenderingMode>(m_renderingMode); }
- int keywordSize() const { return m_keywordSize; }
-
- FontTraitsMask traitsMask() const;
-
- void setFamily(const FontFamily& family) { m_familyList = family; }
- void setComputedSize(float s) { m_computedSize = s; }
- void setSpecifiedSize(float s) { m_specifiedSize = s; }
- void setItalic(bool i) { m_italic = i; }
- void setSmallCaps(bool c) { m_smallCaps = c; }
- void setIsAbsoluteSize(bool s) { m_isAbsoluteSize = s; }
- void setWeight(FontWeight w) { m_weight = w; }
- void setGenericFamily(GenericFamilyType genericFamily) { m_genericFamily = genericFamily; }
- void setUsePrinterFont(bool p) { m_usePrinterFont = p; }
- void setRenderingMode(FontRenderingMode mode) { m_renderingMode = mode; }
- void setKeywordSize(int s) { m_keywordSize = s; }
-
-private:
- FontFamily m_familyList; // The list of font families to be used.
-
- float m_specifiedSize; // Specified CSS value. Independent of rendering issues such as integer
- // rounding, minimum font sizes, and zooming.
- float m_computedSize; // Computed size adjusted for the minimum font size and the zoom factor.
-
- bool m_italic : 1;
- bool m_smallCaps : 1;
- bool m_isAbsoluteSize : 1; // Whether or not CSS specified an explicit size
- // (logical sizes like "medium" don't count).
- unsigned m_weight : 8; // FontWeight
- unsigned m_genericFamily : 3; // GenericFamilyType
- bool m_usePrinterFont : 1;
-
- unsigned m_renderingMode : 1; // Used to switch between CG and GDI text on Windows.
-
- int m_keywordSize : 4; // We cache whether or not a font is currently represented by a CSS keyword (e.g., medium). If so,
- // then we can accurately translate across different generic families to adjust for different preference settings
- // (e.g., 13px monospace vs. 16px everything else). Sizes are 1-8 (like the HTML size values for <font>).
-};
-
-inline bool FontDescription::operator==(const FontDescription& other) const
-{
- return m_familyList == other.m_familyList
- && m_specifiedSize == other.m_specifiedSize
- && m_computedSize == other.m_computedSize
- && m_italic == other.m_italic
- && m_smallCaps == other.m_smallCaps
- && m_isAbsoluteSize == other.m_isAbsoluteSize
- && m_weight == other.m_weight
- && m_genericFamily == other.m_genericFamily
- && m_usePrinterFont == other.m_usePrinterFont
- && m_renderingMode == other.m_renderingMode
- && m_keywordSize == other.m_keywordSize;
-}
-
-}
-
-#endif
diff --git a/WebCore/platform/graphics/FontFallbackList.cpp b/WebCore/platform/graphics/FontFallbackList.cpp
deleted file mode 100644
index ef59c2f..0000000
--- a/WebCore/platform/graphics/FontFallbackList.cpp
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FontFallbackList.h"
-
-#include "Font.h"
-#include "FontCache.h"
-#include "SegmentedFontData.h"
-
-namespace WebCore {
-
-FontFallbackList::FontFallbackList()
- : m_familyIndex(0)
- , m_pitch(UnknownPitch)
- , m_loadingCustomFonts(false)
- , m_fontSelector(0)
- , m_generation(FontCache::generation())
-{
-}
-
-void FontFallbackList::invalidate(PassRefPtr<FontSelector> fontSelector)
-{
- releaseFontData();
- m_fontList.clear();
- m_familyIndex = 0;
- m_pitch = UnknownPitch;
- m_loadingCustomFonts = false;
- m_fontSelector = fontSelector;
- m_generation = FontCache::generation();
-}
-
-void FontFallbackList::releaseFontData()
-{
- unsigned numFonts = m_fontList.size();
- for (unsigned i = 0; i < numFonts; ++i) {
- if (!m_fontList[i].second) {
- ASSERT(!m_fontList[i].first->isSegmented());
- FontCache::releaseFontData(static_cast<const SimpleFontData*>(m_fontList[i].first));
- }
- }
-}
-
-void FontFallbackList::determinePitch(const Font* font) const
-{
- const FontData* fontData = primaryFont(font);
- if (!fontData->isSegmented())
- m_pitch = static_cast<const SimpleFontData*>(fontData)->pitch();
- else {
- const SegmentedFontData* segmentedFontData = static_cast<const SegmentedFontData*>(fontData);
- unsigned numRanges = segmentedFontData->numRanges();
- if (numRanges == 1)
- m_pitch = segmentedFontData->rangeAt(0).fontData()->pitch();
- else
- m_pitch = VariablePitch;
- }
-}
-
-const FontData* FontFallbackList::fontDataAt(const Font* font, unsigned realizedFontIndex) const
-{
- if (realizedFontIndex < m_fontList.size())
- return m_fontList[realizedFontIndex].first; // This fallback font is already in our list.
-
- // Make sure we're not passing in some crazy value here.
- ASSERT(realizedFontIndex == m_fontList.size());
-
- if (m_familyIndex == cAllFamiliesScanned)
- return 0;
-
- // Ask the font cache for the font data.
- // We are obtaining this font for the first time. We keep track of the families we've looked at before
- // in |m_familyIndex|, so that we never scan the same spot in the list twice. getFontData will adjust our
- // |m_familyIndex| as it scans for the right font to make.
- ASSERT(FontCache::generation() == m_generation);
- const FontData* result = FontCache::getFontData(*font, m_familyIndex, m_fontSelector.get());
- if (result) {
- m_fontList.append(pair<const FontData*, bool>(result, result->isCustomFont()));
- if (result->isLoading())
- m_loadingCustomFonts = true;
- }
- return result;
-}
-
-const FontData* FontFallbackList::fontDataForCharacters(const Font* font, const UChar* characters, int length) const
-{
- // This method is only called when the primary font does not contain the characters we need.
- // Begin our search at position 1.
- unsigned realizedFontIndex = 1;
- const FontData* fontData = fontDataAt(font, realizedFontIndex);
- while (fontData && !fontData->containsCharacters(characters, length))
- fontData = fontDataAt(font, ++realizedFontIndex);
-
- if (!fontData) {
- ASSERT(FontCache::generation() == m_generation);
- fontData = FontCache::getFontDataForCharacters(*font, characters, length);
- }
-
- return fontData;
-}
-
-void FontFallbackList::setPlatformFont(const FontPlatformData& platformData)
-{
- m_familyIndex = cAllFamiliesScanned;
- ASSERT(FontCache::generation() == m_generation);
- const FontData* fontData = FontCache::getCachedFontData(&platformData);
- m_fontList.append(pair<const FontData*, bool>(fontData, fontData->isCustomFont()));
-}
-
-}
diff --git a/WebCore/platform/graphics/FontFallbackList.h b/WebCore/platform/graphics/FontFallbackList.h
deleted file mode 100644
index a23b32c..0000000
--- a/WebCore/platform/graphics/FontFallbackList.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * This file is part of the internal font implementation. It should not be included by anyone other than
- * FontMac.cpp, FontWin.cpp and Font.cpp.
- *
- * Copyright (C) 2006 Apple Computer, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-// This file has no guards on purpose in order to detect redundant includes. This is a private header
-// and so this may catch someone trying to include this file in public cpp files.
-
-#include "FontSelector.h"
-#include "SimpleFontData.h"
-#include <wtf/Forward.h>
-
-namespace WebCore {
-
-class Font;
-class GraphicsContext;
-class IntRect;
-class FontDescription;
-class FontPlatformData;
-class FontSelector;
-
-const int cAllFamiliesScanned = -1;
-
-class FontFallbackList : public RefCounted<FontFallbackList> {
-public:
- static PassRefPtr<FontFallbackList> create() { return adoptRef(new FontFallbackList()); }
-
- ~FontFallbackList() { releaseFontData(); }
- void invalidate(PassRefPtr<FontSelector>);
-
- bool isFixedPitch(const Font* f) const { if (m_pitch == UnknownPitch) determinePitch(f); return m_pitch == FixedPitch; };
- void determinePitch(const Font*) const;
-
- bool loadingCustomFonts() const { return m_loadingCustomFonts; }
-
- FontSelector* fontSelector() const { return m_fontSelector.get(); }
- unsigned generation() const { return m_generation; }
-
-private:
- FontFallbackList();
-
- const FontData* primaryFont(const Font* f) const { return fontDataAt(f, 0); }
- const FontData* fontDataAt(const Font*, unsigned index) const;
- const FontData* fontDataForCharacters(const Font*, const UChar*, int length) const;
-
- void setPlatformFont(const FontPlatformData&);
-
- void releaseFontData();
-
- mutable Vector<pair<const FontData*, bool>, 1> m_fontList;
- mutable int m_familyIndex;
- mutable Pitch m_pitch;
- mutable bool m_loadingCustomFonts;
- RefPtr<FontSelector> m_fontSelector;
- unsigned m_generation;
-
- friend class Font;
-};
-
-}
-
diff --git a/WebCore/platform/graphics/FontFamily.cpp b/WebCore/platform/graphics/FontFamily.cpp
deleted file mode 100644
index 12b59a4..0000000
--- a/WebCore/platform/graphics/FontFamily.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2004, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FontFamily.h"
-
-namespace WebCore {
-
-FontFamily::FontFamily(const FontFamily& other)
- : m_family(other.m_family)
- , m_next(other.m_next)
-{
-}
-
-FontFamily& FontFamily::operator=(const FontFamily& other)
-{
- m_family = other.m_family;
- m_next = other.m_next;
- return *this;
-}
-
-bool operator==(const FontFamily& a, const FontFamily& b)
-{
- if (a.family() != b.family())
- return false;
- const FontFamily* ap;
- const FontFamily* bp;
- for (ap = a.next(), bp = b.next(); ap != bp; ap = ap->next(), bp = bp->next()) {
- if (!ap || !bp)
- return false;
- if (ap->family() != bp->family())
- return false;
- }
- return true;
-}
-
-}
diff --git a/WebCore/platform/graphics/FontFamily.h b/WebCore/platform/graphics/FontFamily.h
deleted file mode 100644
index 126bd83..0000000
--- a/WebCore/platform/graphics/FontFamily.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2003, 2006, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef FontFamily_h
-#define FontFamily_h
-
-#include "AtomicString.h"
-#include <wtf/RefCounted.h>
-#include <wtf/ListRefPtr.h>
-
-namespace WebCore {
-
-class SharedFontFamily;
-
-class FontFamily {
-public:
- FontFamily() { }
- FontFamily(const FontFamily&);
- FontFamily& operator=(const FontFamily&);
-
- void setFamily(const AtomicString& family) { m_family = family; }
- const AtomicString& family() const { return m_family; }
- bool familyIsEmpty() const { return m_family.isEmpty(); }
-
- const FontFamily* next() const;
-
- void appendFamily(PassRefPtr<SharedFontFamily>);
- PassRefPtr<SharedFontFamily> releaseNext();
-
-private:
- AtomicString m_family;
- ListRefPtr<SharedFontFamily> m_next;
-};
-
-class SharedFontFamily : public FontFamily, public RefCounted<SharedFontFamily> {
-public:
- static PassRefPtr<SharedFontFamily> create()
- {
- return adoptRef(new SharedFontFamily);
- }
-
-private:
- SharedFontFamily() { }
-};
-
-bool operator==(const FontFamily&, const FontFamily&);
-inline bool operator!=(const FontFamily& a, const FontFamily& b) { return !(a == b); }
-
-inline const FontFamily* FontFamily::next() const
-{
- return m_next.get();
-}
-
-inline void FontFamily::appendFamily(PassRefPtr<SharedFontFamily> family)
-{
- m_next = family;
-}
-
-inline PassRefPtr<SharedFontFamily> FontFamily::releaseNext()
-{
- return m_next.release();
-}
-
-}
-
-#endif
diff --git a/WebCore/platform/graphics/FontRenderingMode.h b/WebCore/platform/graphics/FontRenderingMode.h
deleted file mode 100644
index c1ce497..0000000
--- a/WebCore/platform/graphics/FontRenderingMode.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef FontRenderingMode_h
-#define FontRenderingMode_h
-
-namespace WebCore {
-
-// This setting is used to provide ways of switching between multiple rendering modes that may have different
-// metrics. It is used to switch between CG and GDI text on Windows.
-enum FontRenderingMode { NormalRenderingMode, AlternateRenderingMode };
-
-} // namespace WebCore
-
-#endif // FontRenderingMode_h
diff --git a/WebCore/platform/graphics/FontSelector.h b/WebCore/platform/graphics/FontSelector.h
deleted file mode 100644
index 9b520b9..0000000
--- a/WebCore/platform/graphics/FontSelector.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef FontSelector_h
-#define FontSelector_h
-
-#include <wtf/RefCounted.h>
-
-namespace WebCore {
-
-class AtomicString;
-class FontData;
-class FontDescription;
-
-class FontSelector : public RefCounted<FontSelector> {
-public:
- virtual ~FontSelector() { }
- virtual FontData* getFontData(const FontDescription&, const AtomicString& familyName) = 0;
-
- virtual void fontCacheInvalidated() { }
-};
-
-} // namespace WebCore
-
-#endif // FontSelector_h
diff --git a/WebCore/platform/graphics/FontTraitsMask.h b/WebCore/platform/graphics/FontTraitsMask.h
deleted file mode 100644
index 686c30c..0000000
--- a/WebCore/platform/graphics/FontTraitsMask.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef FontTraitsMask_h
-#define FontTraitsMask_h
-
-namespace WebCore {
-
- enum {
- FontStyleNormalBit = 0,
- FontStyleItalicBit,
- FontVariantNormalBit,
- FontVariantSmallCapsBit,
- FontWeight100Bit,
- FontWeight200Bit,
- FontWeight300Bit,
- FontWeight400Bit,
- FontWeight500Bit,
- FontWeight600Bit,
- FontWeight700Bit,
- FontWeight800Bit,
- FontWeight900Bit,
- FontTraitsMaskWidth
- };
-
- enum FontTraitsMask {
- FontStyleNormalMask = 1 << FontStyleNormalBit,
- FontStyleItalicMask = 1 << FontStyleItalicBit,
- FontStyleMask = FontStyleNormalMask | FontStyleItalicMask,
-
- FontVariantNormalMask = 1 << FontVariantNormalBit,
- FontVariantSmallCapsMask = 1 << FontVariantSmallCapsBit,
- FontVariantMask = FontVariantNormalMask | FontVariantSmallCapsMask,
-
- FontWeight100Mask = 1 << FontWeight100Bit,
- FontWeight200Mask = 1 << FontWeight200Bit,
- FontWeight300Mask = 1 << FontWeight300Bit,
- FontWeight400Mask = 1 << FontWeight400Bit,
- FontWeight500Mask = 1 << FontWeight500Bit,
- FontWeight600Mask = 1 << FontWeight600Bit,
- FontWeight700Mask = 1 << FontWeight700Bit,
- FontWeight800Mask = 1 << FontWeight800Bit,
- FontWeight900Mask = 1 << FontWeight900Bit,
- FontWeightMask = FontWeight100Mask | FontWeight200Mask | FontWeight300Mask | FontWeight400Mask | FontWeight500Mask | FontWeight600Mask | FontWeight700Mask | FontWeight800Mask | FontWeight900Mask
- };
-
-} // namespace WebCore
-#endif // FontTraitsMask_h
diff --git a/WebCore/platform/graphics/GeneratedImage.cpp b/WebCore/platform/graphics/GeneratedImage.cpp
deleted file mode 100644
index 5e50959..0000000
--- a/WebCore/platform/graphics/GeneratedImage.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "GeneratedImage.h"
-
-#include "FloatRect.h"
-#include "GraphicsContext.h"
-#include "ImageBuffer.h"
-
-using namespace std;
-
-namespace WebCore {
-
-void GeneratedImage::draw(GraphicsContext* context, const FloatRect& dstRect, const FloatRect& srcRect, CompositeOperator compositeOp)
-{
- context->save();
- context->setCompositeOperation(compositeOp);
- context->clip(dstRect);
- context->translate(dstRect.x(), dstRect.y());
- if (dstRect.size() != srcRect.size())
- context->scale(FloatSize(dstRect.width() / srcRect.width(), dstRect.height() / srcRect.height()));
- context->translate(-srcRect.x(), -srcRect.y());
- context->fillRect(FloatRect(FloatPoint(), m_size), *m_generator.get());
- context->restore();
-}
-
-void GeneratedImage::drawPattern(GraphicsContext* context, const FloatRect& srcRect, const AffineTransform& patternTransform,
- const FloatPoint& phase, CompositeOperator compositeOp, const FloatRect& destRect)
-{
- // Create a BitmapImage and call drawPattern on it.
- auto_ptr<ImageBuffer> imageBuffer = ImageBuffer::create(m_size, false);
- ASSERT(imageBuffer.get());
-
- // Fill with the gradient.
- GraphicsContext* graphicsContext = imageBuffer->context();
- graphicsContext->fillRect(FloatRect(FloatPoint(), m_size), *m_generator.get());
-
- // Grab the final image from the image buffer.
- Image* bitmap = imageBuffer->image();
-
- // Now just call drawTiled on that image.
- bitmap->drawPattern(context, srcRect, patternTransform, phase, compositeOp, destRect);
-}
-
-}
diff --git a/WebCore/platform/graphics/GeneratedImage.h b/WebCore/platform/graphics/GeneratedImage.h
deleted file mode 100644
index fb0661b..0000000
--- a/WebCore/platform/graphics/GeneratedImage.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GeneratedImage_h
-#define GeneratedImage_h
-
-#include "Image.h"
-
-#include "Generator.h"
-#include "IntSize.h"
-#include <wtf/RefPtr.h>
-
-namespace WebCore {
-
-class GeneratedImage : public Image {
-public:
- static PassRefPtr<GeneratedImage> create(PassRefPtr<Generator> generator, const IntSize& size)
- {
- return adoptRef(new GeneratedImage(generator, size));
- }
- virtual ~GeneratedImage() {}
-
- virtual bool hasSingleSecurityOrigin() const { return true; }
-
- // These are only used for SVGGeneratedImage right now
- virtual void setContainerSize(const IntSize& size) { m_size = size; }
- virtual bool usesContainerSize() const { return true; }
- virtual bool hasRelativeWidth() const { return true; }
- virtual bool hasRelativeHeight() const { return true; }
-
- virtual IntSize size() const { return m_size; }
-
- // Assume that generated content has no decoded data we need to worry about
- virtual void destroyDecodedData(bool incremental = false, bool preserveNearbyFrames = false) { }
- virtual unsigned decodedSize() const { return 0; }
-
-protected:
- virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, CompositeOperator);
- virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform,
- const FloatPoint& phase, CompositeOperator, const FloatRect& destRect);
-
-protected:
- GeneratedImage(PassRefPtr<Generator> generator, const IntSize& size)
- : m_generator(generator)
- , m_size(size)
- {
- }
-
- RefPtr<Generator> m_generator;
- IntSize m_size;
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/graphics/Generator.h b/WebCore/platform/graphics/Generator.h
deleted file mode 100644
index a0af689..0000000
--- a/WebCore/platform/graphics/Generator.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef Generator_h
-#define Generator_h
-
-#include <wtf/RefCounted.h>
-
-namespace WebCore {
-
-class FloatRect;
-class GraphicsContext;
-
-class Generator : public RefCounted<Generator> {
-public:
- virtual ~Generator() {};
-
- virtual void fill(GraphicsContext*, const FloatRect&) = 0;
-};
-
-} //namespace
-
-#endif
diff --git a/WebCore/platform/graphics/GlyphBuffer.h b/WebCore/platform/graphics/GlyphBuffer.h
deleted file mode 100644
index 18957d5..0000000
--- a/WebCore/platform/graphics/GlyphBuffer.h
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GlyphBuffer_h
-#define GlyphBuffer_h
-
-#include "FloatSize.h"
-
-#if PLATFORM(CG)
-#include <ApplicationServices/ApplicationServices.h>
-#elif PLATFORM(CAIRO)
-#include <cairo.h>
-#endif
-
-#include <wtf/Vector.h>
-
-namespace WebCore {
-
-typedef unsigned short Glyph;
-class SimpleFontData;
-
-#if PLATFORM(CAIRO)
-// FIXME: Why does Cairo use such a huge struct instead of just an offset into an array?
-typedef cairo_glyph_t GlyphBufferGlyph;
-#else
-typedef Glyph GlyphBufferGlyph;
-#endif
-
-// CG uses CGSize instead of FloatSize so that the result of advances()
-// can be passed directly to CGContextShowGlyphsWithAdvances in FontMac.mm
-#if PLATFORM(CG)
-typedef CGSize GlyphBufferAdvance;
-#else
-typedef FloatSize GlyphBufferAdvance;
-#endif
-
-class GlyphBuffer {
-public:
- bool isEmpty() const { return m_fontData.isEmpty(); }
- int size() const { return m_fontData.size(); }
-
- void clear()
- {
- m_fontData.clear();
- m_glyphs.clear();
- m_advances.clear();
-#if PLATFORM(WIN)
- m_offsets.clear();
-#endif
- }
-
- GlyphBufferGlyph* glyphs(int from) { return m_glyphs.data() + from; }
- GlyphBufferAdvance* advances(int from) { return m_advances.data() + from; }
- const GlyphBufferGlyph* glyphs(int from) const { return m_glyphs.data() + from; }
- const GlyphBufferAdvance* advances(int from) const { return m_advances.data() + from; }
-
- const SimpleFontData* fontDataAt(int index) const { return m_fontData[index]; }
-
- void swap(int index1, int index2)
- {
- const SimpleFontData* f = m_fontData[index1];
- m_fontData[index1] = m_fontData[index2];
- m_fontData[index2] = f;
-
- GlyphBufferGlyph g = m_glyphs[index1];
- m_glyphs[index1] = m_glyphs[index2];
- m_glyphs[index2] = g;
-
- GlyphBufferAdvance s = m_advances[index1];
- m_advances[index1] = m_advances[index2];
- m_advances[index2] = s;
-
-#if PLATFORM(WIN)
- FloatSize offset = m_offsets[index1];
- m_offsets[index1] = m_offsets[index2];
- m_offsets[index2] = offset;
-#endif
- }
-
- Glyph glyphAt(int index) const
- {
-#if PLATFORM(CAIRO)
- return m_glyphs[index].index;
-#else
- return m_glyphs[index];
-#endif
- }
-
- float advanceAt(int index) const
- {
-#if PLATFORM(CG)
- return m_advances[index].width;
-#else
- return m_advances[index].width();
-#endif
- }
-
- FloatSize offsetAt(int index) const
- {
-#if PLATFORM(WIN)
- return m_offsets[index];
-#else
- return FloatSize();
-#endif
- }
-
- void add(Glyph glyph, const SimpleFontData* font, float width, const FloatSize* offset = 0)
- {
- m_fontData.append(font);
-#if PLATFORM(CAIRO)
- cairo_glyph_t cairoGlyph;
- cairoGlyph.index = glyph;
- m_glyphs.append(cairoGlyph);
-#else
- m_glyphs.append(glyph);
-#endif
-
-#if PLATFORM(CG)
- CGSize advance = { width, 0 };
- m_advances.append(advance);
-#else
- m_advances.append(FloatSize(width, 0));
-#endif
-
-#if PLATFORM(WIN)
- if (offset)
- m_offsets.append(*offset);
- else
- m_offsets.append(FloatSize());
-#endif
- }
-
- void add(Glyph glyph, const SimpleFontData* font, GlyphBufferAdvance advance)
- {
- m_fontData.append(font);
-#if PLATFORM(CAIRO)
- cairo_glyph_t cairoGlyph;
- cairoGlyph.index = glyph;
- m_glyphs.append(cairoGlyph);
-#else
- m_glyphs.append(glyph);
-#endif
-
- m_advances.append(advance);
- }
-
-private:
- Vector<const SimpleFontData*, 2048> m_fontData;
- Vector<GlyphBufferGlyph, 2048> m_glyphs;
- Vector<GlyphBufferAdvance, 2048> m_advances;
-#if PLATFORM(WIN)
- Vector<FloatSize, 2048> m_offsets;
-#endif
-};
-
-}
-#endif
diff --git a/WebCore/platform/graphics/GlyphPageTreeNode.cpp b/WebCore/platform/graphics/GlyphPageTreeNode.cpp
deleted file mode 100644
index 6b9d23d..0000000
--- a/WebCore/platform/graphics/GlyphPageTreeNode.cpp
+++ /dev/null
@@ -1,384 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "GlyphPageTreeNode.h"
-
-#include "CharacterNames.h"
-#include "SegmentedFontData.h"
-#include "SimpleFontData.h"
-#include <wtf/unicode/Unicode.h>
-
-namespace WebCore {
-
-using std::max;
-using std::min;
-
-HashMap<int, GlyphPageTreeNode*>* GlyphPageTreeNode::roots = 0;
-GlyphPageTreeNode* GlyphPageTreeNode::pageZeroRoot = 0;
-
-GlyphPageTreeNode* GlyphPageTreeNode::getRoot(unsigned pageNumber)
-{
- static bool initialized;
- if (!initialized) {
- initialized = true;
- roots = new HashMap<int, GlyphPageTreeNode*>;
- pageZeroRoot = new GlyphPageTreeNode;
- }
-
- GlyphPageTreeNode* node = pageNumber ? roots->get(pageNumber) : pageZeroRoot;
- if (!node) {
- node = new GlyphPageTreeNode;
-#ifndef NDEBUG
- node->m_pageNumber = pageNumber;
-#endif
- if (pageNumber)
- roots->set(pageNumber, node);
- else
- pageZeroRoot = node;
- }
- return node;
-}
-
-size_t GlyphPageTreeNode::treeGlyphPageCount()
-{
- size_t count = 0;
- if (roots) {
- HashMap<int, GlyphPageTreeNode*>::iterator end = roots->end();
- for (HashMap<int, GlyphPageTreeNode*>::iterator it = roots->begin(); it != end; ++it)
- count += it->second->pageCount();
- }
-
- if (pageZeroRoot)
- count += pageZeroRoot->pageCount();
-
- return count;
-}
-
-size_t GlyphPageTreeNode::pageCount() const
-{
- size_t count = m_page && m_page->owner() == this ? 1 : 0;
- HashMap<const FontData*, GlyphPageTreeNode*>::const_iterator end = m_children.end();
- for (HashMap<const FontData*, GlyphPageTreeNode*>::const_iterator it = m_children.begin(); it != end; ++it)
- count += it->second->pageCount();
-
- return count;
-}
-
-void GlyphPageTreeNode::pruneTreeCustomFontData(const FontData* fontData)
-{
- // Enumerate all the roots and prune any tree that contains our custom font data.
- if (roots) {
- HashMap<int, GlyphPageTreeNode*>::iterator end = roots->end();
- for (HashMap<int, GlyphPageTreeNode*>::iterator it = roots->begin(); it != end; ++it)
- it->second->pruneCustomFontData(fontData);
- }
-
- if (pageZeroRoot)
- pageZeroRoot->pruneCustomFontData(fontData);
-}
-
-void GlyphPageTreeNode::pruneTreeFontData(const SimpleFontData* fontData)
-{
- if (roots) {
- HashMap<int, GlyphPageTreeNode*>::iterator end = roots->end();
- for (HashMap<int, GlyphPageTreeNode*>::iterator it = roots->begin(); it != end; ++it)
- it->second->pruneFontData(fontData);
- }
-
- if (pageZeroRoot)
- pageZeroRoot->pruneFontData(fontData);
-}
-
-GlyphPageTreeNode::~GlyphPageTreeNode()
-{
- deleteAllValues(m_children);
- delete m_systemFallbackChild;
-}
-
-void GlyphPageTreeNode::initializePage(const FontData* fontData, unsigned pageNumber)
-{
- ASSERT(!m_page);
-
- // This function must not be called for the root of the tree, because that
- // level does not contain any glyphs.
- ASSERT(m_level > 0 && m_parent);
-
- // The parent's page will be 0 if we are level one or the parent's font data
- // did not contain any glyphs for that page.
- GlyphPage* parentPage = m_parent->page();
-
- // NULL FontData means we're being asked for the system fallback font.
- if (fontData) {
- if (m_level == 1) {
- // Children of the root hold pure pages. These will cover only one
- // font data's glyphs, and will have glyph index 0 if the font data does not
- // contain the glyph.
- unsigned start = pageNumber * GlyphPage::size;
- UChar buffer[GlyphPage::size * 2 + 2];
- unsigned bufferLength;
- unsigned i;
-
- // Fill in a buffer with the entire "page" of characters that we want to look up glyphs for.
- if (start < 0x10000) {
- bufferLength = GlyphPage::size;
- for (i = 0; i < GlyphPage::size; i++)
- buffer[i] = start + i;
-
- if (start == 0) {
- // Control characters must not render at all.
- for (i = 0; i < 0x20; ++i)
- buffer[i] = zeroWidthSpace;
- for (i = 0x7F; i < 0xA0; i++)
- buffer[i] = zeroWidthSpace;
-
- // \n, \t, and nonbreaking space must render as a space.
- buffer[(int)'\n'] = ' ';
- buffer[(int)'\t'] = ' ';
- buffer[noBreakSpace] = ' ';
- } else if (start == (leftToRightMark & ~(GlyphPage::size - 1))) {
- // LRM, RLM, LRE, RLE and PDF must not render at all.
- buffer[leftToRightMark - start] = zeroWidthSpace;
- buffer[rightToLeftMark - start] = zeroWidthSpace;
- buffer[leftToRightEmbed - start] = zeroWidthSpace;
- buffer[rightToLeftEmbed - start] = zeroWidthSpace;
- buffer[leftToRightOverride - start] = zeroWidthSpace;
- buffer[rightToLeftOverride - start] = zeroWidthSpace;
- buffer[popDirectionalFormatting - start] = zeroWidthSpace;
- } else if (start == (objectReplacementCharacter & ~(GlyphPage::size - 1))) {
- // Object replacement character must not render at all.
- buffer[objectReplacementCharacter - start] = zeroWidthSpace;
- }
- } else {
- bufferLength = GlyphPage::size * 2;
- for (i = 0; i < GlyphPage::size; i++) {
- int c = i + start;
- buffer[i * 2] = U16_LEAD(c);
- buffer[i * 2 + 1] = U16_TRAIL(c);
- }
- }
-
- m_page = GlyphPage::create(this);
-
- // Now that we have a buffer full of characters, we want to get back an array
- // of glyph indices. This part involves calling into the platform-specific
- // routine of our glyph map for actually filling in the page with the glyphs.
- // Success is not guaranteed. For example, Times fails to fill page 260, giving glyph data
- // for only 128 out of 256 characters.
- bool haveGlyphs;
- if (fontData->isSegmented()) {
- haveGlyphs = false;
-
- const SegmentedFontData* segmentedFontData = static_cast<const SegmentedFontData*>(fontData);
- unsigned numRanges = segmentedFontData->numRanges();
- bool zeroFilled = false;
- RefPtr<GlyphPage> scratchPage;
- GlyphPage* pageToFill = m_page.get();
- for (unsigned i = 0; i < numRanges; i++) {
- const FontDataRange& range = segmentedFontData->rangeAt(i);
- int from = max(0, range.from() - static_cast<int>(start));
- int to = 1 + min(range.to() - static_cast<int>(start), static_cast<int>(GlyphPage::size) - 1);
- if (from < static_cast<int>(GlyphPage::size) && to > 0) {
- if (haveGlyphs && !scratchPage) {
- scratchPage = GlyphPage::create(this);
- pageToFill = scratchPage.get();
- }
-
- if (!zeroFilled) {
- if (from > 0 || to < static_cast<int>(GlyphPage::size)) {
- for (unsigned i = 0; i < GlyphPage::size; i++)
- pageToFill->setGlyphDataForIndex(i, 0, 0);
- }
- zeroFilled = true;
- }
- haveGlyphs |= pageToFill->fill(from, to - from, buffer + from * (start < 0x10000 ? 1 : 2), (to - from) * (start < 0x10000 ? 1 : 2), range.fontData());
- if (scratchPage) {
- for (int j = from; j < to; j++) {
- if (!m_page->m_glyphs[j].glyph && pageToFill->m_glyphs[j].glyph)
- m_page->m_glyphs[j] = pageToFill->m_glyphs[j];
- }
- }
- }
- }
- } else
- haveGlyphs = m_page->fill(0, GlyphPage::size, buffer, bufferLength, static_cast<const SimpleFontData*>(fontData));
-
- if (!haveGlyphs)
- m_page = 0;
- } else if (parentPage && parentPage->owner() != m_parent) {
- // The page we're overriding may not be owned by our parent node.
- // This happens when our parent node provides no useful overrides
- // and just copies the pointer to an already-existing page (see
- // below).
- //
- // We want our override to be shared by all nodes that reference
- // that page to avoid duplication, and so standardize on having the
- // page's owner collect all the overrides. Call getChild on the
- // page owner with the desired font data (this will populate
- // the page) and then reference it.
- m_page = parentPage->owner()->getChild(fontData, pageNumber)->page();
- } else {
- // Get the pure page for the fallback font (at level 1 with no
- // overrides). getRootChild will always create a page if one
- // doesn't exist, but the page doesn't necessarily have glyphs
- // (this pointer may be 0).
- GlyphPage* fallbackPage = getRootChild(fontData, pageNumber)->page();
- if (!parentPage) {
- // When the parent has no glyphs for this page, we can easily
- // override it just by supplying the glyphs from our font.
- m_page = fallbackPage;
- } else if (!fallbackPage) {
- // When our font has no glyphs for this page, we can just reference the
- // parent page.
- m_page = parentPage;
- } else {
- // Combine the parent's glyphs and ours to form a new more complete page.
- m_page = GlyphPage::create(this);
-
- // Overlay the parent page on the fallback page. Check if the fallback font
- // has added anything.
- bool newGlyphs = false;
- for (unsigned i = 0; i < GlyphPage::size; i++) {
- if (parentPage->m_glyphs[i].glyph)
- m_page->m_glyphs[i] = parentPage->m_glyphs[i];
- else if (fallbackPage->m_glyphs[i].glyph) {
- m_page->m_glyphs[i] = fallbackPage->m_glyphs[i];
- newGlyphs = true;
- } else {
- const GlyphData data = { 0, 0 };
- m_page->m_glyphs[i] = data;
- }
- }
-
- if (!newGlyphs)
- // We didn't override anything, so our override is just the parent page.
- m_page = parentPage;
- }
- }
- } else {
- m_page = GlyphPage::create(this);
- // System fallback. Initialized with the parent's page here, as individual
- // entries may use different fonts depending on character. If the Font
- // ever finds it needs a glyph out of the system fallback page, it will
- // ask the system for the best font to use and fill that glyph in for us.
- if (parentPage)
- memcpy(m_page->m_glyphs, parentPage->m_glyphs, GlyphPage::size * sizeof(m_page->m_glyphs[0]));
- else {
- const GlyphData data = { 0, 0 };
- for (unsigned i = 0; i < GlyphPage::size; i++)
- m_page->m_glyphs[i] = data;
- }
- }
-}
-
-GlyphPageTreeNode* GlyphPageTreeNode::getChild(const FontData* fontData, unsigned pageNumber)
-{
- ASSERT(fontData || !m_isSystemFallback);
- ASSERT(pageNumber == m_pageNumber);
-
- GlyphPageTreeNode* child = fontData ? m_children.get(fontData) : m_systemFallbackChild;
- if (!child) {
- child = new GlyphPageTreeNode;
- child->m_parent = this;
- child->m_level = m_level + 1;
- if (fontData && fontData->isCustomFont()) {
- for (GlyphPageTreeNode* curr = this; curr; curr = curr->m_parent)
- curr->m_customFontCount++;
- }
-
-#ifndef NDEBUG
- child->m_pageNumber = m_pageNumber;
-#endif
- if (fontData) {
- m_children.set(fontData, child);
- fontData->setMaxGlyphPageTreeLevel(max(fontData->maxGlyphPageTreeLevel(), child->m_level));
- } else {
- m_systemFallbackChild = child;
- child->m_isSystemFallback = true;
- }
- child->initializePage(fontData, pageNumber);
- }
- return child;
-}
-
-void GlyphPageTreeNode::pruneCustomFontData(const FontData* fontData)
-{
- if (!fontData || !m_customFontCount)
- return;
-
- // Prune any branch that contains this FontData.
- GlyphPageTreeNode* node = m_children.get(fontData);
- if (node) {
- m_children.remove(fontData);
- unsigned fontCount = node->m_customFontCount + 1;
- delete node;
- for (GlyphPageTreeNode* curr = this; curr; curr = curr->m_parent)
- curr->m_customFontCount -= fontCount;
- }
-
- // Check any branches that remain that still have custom fonts underneath them.
- if (!m_customFontCount)
- return;
- HashMap<const FontData*, GlyphPageTreeNode*>::iterator end = m_children.end();
- for (HashMap<const FontData*, GlyphPageTreeNode*>::iterator it = m_children.begin(); it != end; ++it)
- it->second->pruneCustomFontData(fontData);
-}
-
-void GlyphPageTreeNode::pruneFontData(const SimpleFontData* fontData, unsigned level)
-{
- ASSERT(fontData);
- if (!fontData)
- return;
-
- // Prune any branch that contains this FontData.
- HashMap<const FontData*, GlyphPageTreeNode*>::iterator child = m_children.find(fontData);
- if (child == m_children.end()) {
- // If there is no level-1 node for fontData, then there is no deeper node for it in this tree.
- if (!level)
- return;
- } else {
- GlyphPageTreeNode* node = child->second;
- m_children.remove(fontData);
- unsigned customFontCount = node->m_customFontCount;
- delete node;
- if (customFontCount) {
- for (GlyphPageTreeNode* curr = this; curr; curr = curr->m_parent)
- curr->m_customFontCount -= customFontCount;
- }
- }
-
- level++;
- if (level > fontData->maxGlyphPageTreeLevel())
- return;
-
- HashMap<const FontData*, GlyphPageTreeNode*>::iterator end = m_children.end();
- for (HashMap<const FontData*, GlyphPageTreeNode*>::iterator it = m_children.begin(); it != end; ++it)
- it->second->pruneFontData(fontData, level);
-}
-
-}
diff --git a/WebCore/platform/graphics/GlyphPageTreeNode.h b/WebCore/platform/graphics/GlyphPageTreeNode.h
deleted file mode 100644
index 240b492..0000000
--- a/WebCore/platform/graphics/GlyphPageTreeNode.h
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GlyphPageTreeNode_h
-#define GlyphPageTreeNode_h
-
-#include <wtf/HashMap.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/unicode/Unicode.h>
-
-namespace WebCore {
-
-class FontData;
-class GlyphPageTreeNode;
-class SimpleFontData;
-
-typedef unsigned short Glyph;
-
-// Holds the glyph index and the corresponding SimpleFontData information for a given
-// character.
-struct GlyphData {
- Glyph glyph;
- const SimpleFontData* fontData;
-};
-
-// A GlyphPage contains a fixed-size set of GlyphData mappings for a contiguous
-// range of characters in the Unicode code space. GlyphPages are indexed
-// starting from 0 and incrementing for each 256 glyphs.
-//
-// One page may actually include glyphs from other fonts if the characters are
-// missing in the parimary font. It is owned by exactly one GlyphPageTreeNode,
-// although multiple nodes may reference it as their "page" if they are supposed
-// to be overriding the parent's node, but provide no additional information.
-struct GlyphPage : public RefCounted<GlyphPage> {
- static PassRefPtr<GlyphPage> create(GlyphPageTreeNode* owner)
- {
- return adoptRef(new GlyphPage(owner));
- }
-
- static const size_t size = 256; // Covers Latin-1 in a single page.
- GlyphData m_glyphs[size];
- GlyphPageTreeNode* m_owner;
-
- const GlyphData& glyphDataForCharacter(UChar32 c) const { return m_glyphs[c % size]; }
- void setGlyphDataForCharacter(UChar32 c, Glyph g, const SimpleFontData* f)
- {
- setGlyphDataForIndex(c % size, g, f);
- }
- void setGlyphDataForIndex(unsigned index, Glyph g, const SimpleFontData* f)
- {
- ASSERT(index < size);
- m_glyphs[index].glyph = g;
- m_glyphs[index].fontData = f;
- }
- GlyphPageTreeNode* owner() const { return m_owner; }
-
- // Implemented by the platform.
- bool fill(unsigned offset, unsigned length, UChar* characterBuffer, unsigned bufferLength, const SimpleFontData*);
-
-private:
- GlyphPage(GlyphPageTreeNode* owner)
- : m_owner(owner)
- {
- }
-};
-
-// The glyph page tree is a data structure that maps (FontData, glyph page number)
-// to a GlyphPage. Level 0 (the "root") is special. There is one root
-// GlyphPageTreeNode for each glyph page number. The roots do not have a
-// GlyphPage associated with them, and their initializePage() function is never
-// called to fill the glyphs.
-//
-// Each root node maps a FontData pointer to another GlyphPageTreeNode at
-// level 1 (the "root child") that stores the actual glyphs for a specific font data.
-// These nodes will only have a GlyphPage if they have glyphs for that range.
-//
-// Levels greater than one correspond to subsequent levels of the fallback list
-// for that font. These levels override their parent's page of glyphs by
-// filling in holes with the new font (thus making a more complete page).
-//
-// A NULL FontData pointer corresponds to the system fallback
-// font. It is tracked separately from the regular pages and overrides so that
-// the glyph pages do not get polluted with these last-resort glyphs. The
-// system fallback page is not populated at construction like the other pages,
-// but on demand for each glyph, because the system may need to use different
-// fallback fonts for each. This lazy population is done by the Font.
-class GlyphPageTreeNode {
-public:
- GlyphPageTreeNode()
- : m_parent(0)
- , m_level(0)
- , m_isSystemFallback(false)
- , m_systemFallbackChild(0)
- , m_customFontCount(0)
-#ifndef NDEBUG
- , m_pageNumber(0)
-#endif
- {
- }
-
- ~GlyphPageTreeNode();
-
- static HashMap<int, GlyphPageTreeNode*>* roots;
- static GlyphPageTreeNode* pageZeroRoot;
-
- static GlyphPageTreeNode* getRootChild(const FontData* fontData, unsigned pageNumber)
- {
- return getRoot(pageNumber)->getChild(fontData, pageNumber);
- }
-
- static void pruneTreeCustomFontData(const FontData*);
- static void pruneTreeFontData(const SimpleFontData*);
-
- void pruneCustomFontData(const FontData*);
- void pruneFontData(const SimpleFontData*, unsigned level = 0);
-
- GlyphPageTreeNode* parent() const { return m_parent; }
- GlyphPageTreeNode* getChild(const FontData*, unsigned pageNumber);
-
- // Returns a page of glyphs (or NULL if there are no glyphs in this page's character range).
- GlyphPage* page() const { return m_page.get(); }
-
- // Returns the level of this node. See class-level comment.
- unsigned level() const { return m_level; }
-
- // The system fallback font has special rules (see above).
- bool isSystemFallback() const { return m_isSystemFallback; }
-
- static size_t treeGlyphPageCount();
- size_t pageCount() const;
-
-private:
- static GlyphPageTreeNode* getRoot(unsigned pageNumber);
- void initializePage(const FontData*, unsigned pageNumber);
-
- GlyphPageTreeNode* m_parent;
- RefPtr<GlyphPage> m_page;
- unsigned m_level;
- bool m_isSystemFallback;
- HashMap<const FontData*, GlyphPageTreeNode*> m_children;
- GlyphPageTreeNode* m_systemFallbackChild;
- unsigned m_customFontCount;
-
-#ifndef NDEBUG
- unsigned m_pageNumber;
-#endif
-};
-
-} // namespace WebCore
-
-#endif // GlyphPageTreeNode_h
diff --git a/WebCore/platform/graphics/GlyphWidthMap.cpp b/WebCore/platform/graphics/GlyphWidthMap.cpp
deleted file mode 100644
index 6e8d68d..0000000
--- a/WebCore/platform/graphics/GlyphWidthMap.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "GlyphWidthMap.h"
-
-namespace WebCore
-{
-
-float GlyphWidthMap::widthForGlyph(Glyph g)
-{
- unsigned pageNumber = (g / GlyphWidthPage::size);
- GlyphWidthPage* page = locatePage(pageNumber);
- if (page)
- return page->widthForGlyph(g);
- return cGlyphWidthUnknown;
-}
-
-void GlyphWidthMap::setWidthForGlyph(Glyph glyph, float width)
-{
- unsigned pageNumber = (glyph / GlyphWidthPage::size);
- GlyphWidthPage* page = locatePage(pageNumber);
- if (page)
- page->setWidthForGlyph(glyph, width);
-}
-
-inline GlyphWidthMap::GlyphWidthPage* GlyphWidthMap::locatePage(unsigned pageNumber)
-{
- GlyphWidthPage* page;
- if (pageNumber == 0) {
- if (m_filledPrimaryPage)
- return &m_primaryPage;
- page = &m_primaryPage;
- m_filledPrimaryPage = true;
- } else {
- if (m_pages) {
- GlyphWidthPage* result = m_pages->get(pageNumber);
- if (result)
- return result;
- }
- page = new GlyphWidthPage;
- if (!m_pages)
- m_pages = new HashMap<int, GlyphWidthPage*>;
- m_pages->set(pageNumber, page);
- }
-
- // Fill in the whole page with the unknown glyph width value.
- for (unsigned i = 0; i < GlyphWidthPage::size; i++)
- page->setWidthForIndex(i, cGlyphWidthUnknown);
-
- return page;
-}
-
-}
diff --git a/WebCore/platform/graphics/GlyphWidthMap.h b/WebCore/platform/graphics/GlyphWidthMap.h
deleted file mode 100644
index 1633769..0000000
--- a/WebCore/platform/graphics/GlyphWidthMap.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GlyphWidthMap_h
-#define GlyphWidthMap_h
-
-#include <wtf/unicode/Unicode.h>
-#include <wtf/Noncopyable.h>
-#include <wtf/HashMap.h>
-
-namespace WebCore {
-
-typedef unsigned short Glyph;
-
-const float cGlyphWidthUnknown = -1;
-
-class GlyphWidthMap : Noncopyable {
-public:
- GlyphWidthMap() : m_filledPrimaryPage(false), m_pages(0) {}
- ~GlyphWidthMap() { if (m_pages) { deleteAllValues(*m_pages); delete m_pages; } }
-
- float widthForGlyph(Glyph);
- void setWidthForGlyph(Glyph, float);
-
-private:
- struct GlyphWidthPage {
- static const size_t size = 256; // Usually covers Latin-1 in a single page.
- float m_widths[size];
-
- float widthForGlyph(Glyph g) const { return m_widths[g % size]; }
- void setWidthForGlyph(Glyph g, float w)
- {
- setWidthForIndex(g % size, w);
- }
- void setWidthForIndex(unsigned index, float w)
- {
- m_widths[index] = w;
- }
- };
-
- GlyphWidthPage* locatePage(unsigned page);
-
- bool m_filledPrimaryPage;
- GlyphWidthPage m_primaryPage; // We optimize for the page that contains glyph indices 0-255.
- HashMap<int, GlyphWidthPage*>* m_pages;
-};
-
-}
-#endif
diff --git a/WebCore/platform/graphics/Gradient.cpp b/WebCore/platform/graphics/Gradient.cpp
deleted file mode 100644
index 2e6a5d2..0000000
--- a/WebCore/platform/graphics/Gradient.cpp
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2007 Alp Toker <alp@atoker.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Gradient.h"
-
-#include "Color.h"
-
-namespace WebCore {
-
-Gradient::Gradient(const FloatPoint& p0, const FloatPoint& p1)
- : m_radial(false)
- , m_p0(p0)
- , m_p1(p1)
- , m_r0(0)
- , m_r1(0)
- , m_stopsSorted(false)
- , m_lastStop(0)
-{
- platformInit();
-}
-
-Gradient::Gradient(const FloatPoint& p0, float r0, const FloatPoint& p1, float r1)
- : m_radial(true)
- , m_p0(p0)
- , m_p1(p1)
- , m_r0(r0)
- , m_r1(r1)
- , m_stopsSorted(false)
- , m_lastStop(0)
-{
- platformInit();
-}
-
-Gradient::~Gradient()
-{
- platformDestroy();
-}
-
-void Gradient::addColorStop(float value, const Color& color)
-{
- float r;
- float g;
- float b;
- float a;
- color.getRGBA(r, g, b, a);
- m_stops.append(ColorStop(value, r, g, b, a));
-
- m_stopsSorted = false;
-
- platformDestroy();
-}
-
-static inline bool compareStops(const Gradient::ColorStop& a, const Gradient::ColorStop& b)
-{
- return a.stop < b.stop;
-}
-
-void Gradient::getColor(float value, float* r, float* g, float* b, float* a) const
-{
- ASSERT(value >= 0);
- ASSERT(value <= 1);
-
- if (m_stops.isEmpty()) {
- *r = 0;
- *g = 0;
- *b = 0;
- *a = 0;
- return;
- }
- if (!m_stopsSorted) {
- if (m_stops.size())
- std::stable_sort(m_stops.begin(), m_stops.end(), compareStops);
- m_stopsSorted = true;
- }
- if (value <= 0 || value <= m_stops.first().stop) {
- *r = m_stops.first().red;
- *g = m_stops.first().green;
- *b = m_stops.first().blue;
- *a = m_stops.first().alpha;
- return;
- }
- if (value >= 1 || value >= m_stops.last().stop) {
- *r = m_stops.last().red;
- *g = m_stops.last().green;
- *b = m_stops.last().blue;
- *a = m_stops.last().alpha;
- return;
- }
-
- // Find stop before and stop after and interpolate.
- int stop = findStop(value);
- const ColorStop& lastStop = m_stops[stop];
- const ColorStop& nextStop = m_stops[stop + 1];
- float stopFraction = (value - lastStop.stop) / (nextStop.stop - lastStop.stop);
- *r = lastStop.red + (nextStop.red - lastStop.red) * stopFraction;
- *g = lastStop.green + (nextStop.green - lastStop.green) * stopFraction;
- *b = lastStop.blue + (nextStop.blue - lastStop.blue) * stopFraction;
- *a = lastStop.alpha + (nextStop.alpha - lastStop.alpha) * stopFraction;
-}
-
-int Gradient::findStop(float value) const
-{
- ASSERT(value >= 0);
- ASSERT(value <= 1);
- ASSERT(m_stopsSorted);
-
- int numStops = m_stops.size();
- ASSERT(numStops >= 2);
- ASSERT(m_lastStop < numStops - 1);
-
- int i = m_lastStop;
- if (value < m_stops[i].stop)
- i = 1;
- else
- i = m_lastStop + 1;
-
- for (; i < numStops - 1; ++i)
- if (value < m_stops[i].stop)
- break;
-
- m_lastStop = i - 1;
- return m_lastStop;
-}
-
-} //namespace
diff --git a/WebCore/platform/graphics/Gradient.h b/WebCore/platform/graphics/Gradient.h
deleted file mode 100644
index 00ef2b6..0000000
--- a/WebCore/platform/graphics/Gradient.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2007 Alp Toker <alp@atoker.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef Gradient_h
-#define Gradient_h
-
-#include "FloatPoint.h"
-#include "Generator.h"
-#include <wtf/PassRefPtr.h>
-#include <wtf/Vector.h>
-
-#if PLATFORM(CG)
-typedef struct CGShading* CGShadingRef;
-typedef CGShadingRef PlatformGradient;
-#elif PLATFORM(QT)
-QT_BEGIN_NAMESPACE
-class QGradient;
-QT_END_NAMESPACE
-typedef QGradient* PlatformGradient;
-#elif PLATFORM(CAIRO)
-typedef struct _cairo_pattern cairo_pattern_t;
-typedef cairo_pattern_t* PlatformGradient;
-#elif PLATFORM(SGL)
-#include "SkShader.h"
-typedef class PlatformGradientRec* PlatformGradient;
-#elif PLATFORM(SKIA)
-class SkShader;
-typedef class SkShader* PlatformGradient;
-typedef class SkShader* PlatformPattern;
-#else
-typedef void* PlatformGradient;
-#endif
-
-namespace WebCore {
-
- class Color;
-
- class Gradient : public Generator {
- public:
- static PassRefPtr<Gradient> create(const FloatPoint& p0, const FloatPoint& p1)
- {
- return adoptRef(new Gradient(p0, p1));
- }
- static PassRefPtr<Gradient> create(const FloatPoint& p0, float r0, const FloatPoint& p1, float r1)
- {
- return adoptRef(new Gradient(p0, r0, p1, r1));
- }
- virtual ~Gradient();
-
- void addColorStop(float, const Color&);
-
- void getColor(float value, float* r, float* g, float* b, float* a) const;
-
-#if PLATFORM(SGL)
- SkShader* getShader(SkShader::TileMode);
-#else
- PlatformGradient platformGradient();
-#endif
-
- struct ColorStop {
- float stop;
- float red;
- float green;
- float blue;
- float alpha;
-
- ColorStop() : stop(0), red(0), green(0), blue(0), alpha(0) { }
- ColorStop(float s, float r, float g, float b, float a) : stop(s), red(r), green(g), blue(b), alpha(a) { }
- };
-
- void setStopsSorted(bool s) { m_stopsSorted = s; }
-
- virtual void fill(GraphicsContext*, const FloatRect&);
-
- private:
- Gradient(const FloatPoint& p0, const FloatPoint& p1);
- Gradient(const FloatPoint& p0, float r0, const FloatPoint& p1, float r1);
-
- void platformInit() { m_gradient = 0; }
- void platformDestroy();
-
- int findStop(float value) const;
-
- bool m_radial;
- FloatPoint m_p0;
- FloatPoint m_p1;
- float m_r0;
- float m_r1;
- mutable Vector<ColorStop> m_stops;
- mutable bool m_stopsSorted;
- mutable int m_lastStop;
-
- PlatformGradient m_gradient;
- };
-
-} //namespace
-
-#endif
diff --git a/WebCore/platform/graphics/GraphicsContext.cpp b/WebCore/platform/graphics/GraphicsContext.cpp
deleted file mode 100644
index 9cd2969..0000000
--- a/WebCore/platform/graphics/GraphicsContext.cpp
+++ /dev/null
@@ -1,507 +0,0 @@
-/*
- * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "GraphicsContext.h"
-
-#include "BidiResolver.h"
-#include "Generator.h"
-#include "GraphicsContextPrivate.h"
-#include "Font.h"
-#include "NotImplemented.h"
-
-using namespace std;
-
-namespace WebCore {
-
-class TextRunIterator {
-public:
- TextRunIterator()
- : m_textRun(0)
- , m_offset(0)
- {
- }
-
- TextRunIterator(const TextRun* textRun, unsigned offset)
- : m_textRun(textRun)
- , m_offset(offset)
- {
- }
-
- TextRunIterator(const TextRunIterator& other)
- : m_textRun(other.m_textRun)
- , m_offset(other.m_offset)
- {
- }
-
- unsigned offset() const { return m_offset; }
- void increment() { m_offset++; }
- bool atEnd() const { return !m_textRun || m_offset >= m_textRun->length(); }
- UChar current() const { return (*m_textRun)[m_offset]; }
- WTF::Unicode::Direction direction() const { return atEnd() ? WTF::Unicode::OtherNeutral : WTF::Unicode::direction(current()); }
-
- bool operator==(const TextRunIterator& other)
- {
- return m_offset == other.m_offset && m_textRun == other.m_textRun;
- }
-
- bool operator!=(const TextRunIterator& other) { return !operator==(other); }
-
-private:
- const TextRun* m_textRun;
- int m_offset;
-};
-
-GraphicsContextPrivate* GraphicsContext::createGraphicsContextPrivate()
-{
- return new GraphicsContextPrivate;
-}
-
-void GraphicsContext::destroyGraphicsContextPrivate(GraphicsContextPrivate* deleteMe)
-{
- delete deleteMe;
-}
-
-void GraphicsContext::save()
-{
- if (paintingDisabled())
- return;
-
- m_common->stack.append(m_common->state);
-
- savePlatformState();
-}
-
-void GraphicsContext::restore()
-{
- if (paintingDisabled())
- return;
-
- if (m_common->stack.isEmpty()) {
- LOG_ERROR("ERROR void GraphicsContext::restore() stack is empty");
- return;
- }
- m_common->state = m_common->stack.last();
- m_common->stack.removeLast();
-
- restorePlatformState();
-}
-
-const Font& GraphicsContext::font() const
-{
- return m_common->state.font;
-}
-
-void GraphicsContext::setFont(const Font& aFont)
-{
- m_common->state.font = aFont;
- setPlatformFont(aFont);
-}
-
-void GraphicsContext::setStrokeThickness(float thickness)
-{
- m_common->state.strokeThickness = thickness;
- setPlatformStrokeThickness(thickness);
-}
-
-void GraphicsContext::setStrokeStyle(const StrokeStyle& style)
-{
- m_common->state.strokeStyle = style;
- setPlatformStrokeStyle(style);
-}
-
-void GraphicsContext::setStrokeColor(const Color& color)
-{
- m_common->state.strokeColorSpace = SolidColorSpace;
- m_common->state.strokeColor = color;
- setPlatformStrokeColor(color);
-}
-
-void GraphicsContext::setShadow(const IntSize& size, int blur, const Color& color)
-{
- m_common->state.shadowSize = size;
- m_common->state.shadowBlur = blur;
- m_common->state.shadowColor = color;
- setPlatformShadow(size, blur, color);
-}
-
-void GraphicsContext::clearShadow()
-{
- m_common->state.shadowSize = IntSize();
- m_common->state.shadowBlur = 0;
- m_common->state.shadowColor = Color();
- clearPlatformShadow();
-}
-
-bool GraphicsContext::getShadow(IntSize& size, int& blur, Color& color) const
-{
- size = m_common->state.shadowSize;
- blur = m_common->state.shadowBlur;
- color = m_common->state.shadowColor;
-
- return color.isValid() && color.alpha() && (blur || size.width() || size.height());
-}
-
-float GraphicsContext::strokeThickness() const
-{
- return m_common->state.strokeThickness;
-}
-
-StrokeStyle GraphicsContext::strokeStyle() const
-{
- return m_common->state.strokeStyle;
-}
-
-Color GraphicsContext::strokeColor() const
-{
- return m_common->state.strokeColor;
-}
-
-WindRule GraphicsContext::fillRule() const
-{
- return m_common->state.fillRule;
-}
-
-void GraphicsContext::setFillRule(WindRule fillRule)
-{
- m_common->state.fillRule = fillRule;
-}
-
-GradientSpreadMethod GraphicsContext::spreadMethod() const
-{
- return m_common->state.spreadMethod;
-}
-
-void GraphicsContext::setSpreadMethod(GradientSpreadMethod spreadMethod)
-{
- m_common->state.spreadMethod = spreadMethod;
-}
-
-void GraphicsContext::setFillColor(const Color& color)
-{
- m_common->state.fillColorSpace = SolidColorSpace;
- m_common->state.fillColor = color;
- setPlatformFillColor(color);
-}
-
-Color GraphicsContext::fillColor() const
-{
- return m_common->state.fillColor;
-}
-
-void GraphicsContext::setStrokePattern(PassRefPtr<Pattern> pattern)
-{
- ASSERT(pattern);
- if (!pattern) {
- setStrokeColor(Color::black);
- return;
- }
- m_common->state.strokeColorSpace = PatternColorSpace;
- m_common->state.strokePattern = pattern;
-}
-
-void GraphicsContext::setFillPattern(PassRefPtr<Pattern> pattern)
-{
- ASSERT(pattern);
- if (!pattern) {
- setFillColor(Color::black);
- return;
- }
- m_common->state.fillColorSpace = PatternColorSpace;
- m_common->state.fillPattern = pattern;
-}
-
-void GraphicsContext::setStrokeGradient(PassRefPtr<Gradient> gradient)
-{
- ASSERT(gradient);
- if (!gradient) {
- setStrokeColor(Color::black);
- return;
- }
- m_common->state.strokeColorSpace = GradientColorSpace;
- m_common->state.strokeGradient = gradient;
-}
-
-void GraphicsContext::setFillGradient(PassRefPtr<Gradient> gradient)
-{
- ASSERT(gradient);
- if (!gradient) {
- setFillColor(Color::black);
- return;
- }
- m_common->state.fillColorSpace = GradientColorSpace;
- m_common->state.fillGradient = gradient;
-}
-
-bool GraphicsContext::updatingControlTints() const
-{
- return m_common->m_updatingControlTints;
-}
-
-void GraphicsContext::setUpdatingControlTints(bool b)
-{
- setPaintingDisabled(b);
- m_common->m_updatingControlTints = b;
-}
-
-void GraphicsContext::setPaintingDisabled(bool f)
-{
- m_common->state.paintingDisabled = f;
-}
-
-bool GraphicsContext::paintingDisabled() const
-{
- return m_common->state.paintingDisabled;
-}
-
-void GraphicsContext::drawImage(Image* image, const IntPoint& p, CompositeOperator op)
-{
- drawImage(image, p, IntRect(0, 0, -1, -1), op);
-}
-
-void GraphicsContext::drawImage(Image* image, const IntRect& r, CompositeOperator op, bool useLowQualityScale)
-{
- drawImage(image, r, IntRect(0, 0, -1, -1), op, useLowQualityScale);
-}
-
-void GraphicsContext::drawImage(Image* image, const IntPoint& dest, const IntRect& srcRect, CompositeOperator op)
-{
- drawImage(image, IntRect(dest, srcRect.size()), srcRect, op);
-}
-
-void GraphicsContext::drawImage(Image* image, const IntRect& dest, const IntRect& srcRect, CompositeOperator op, bool useLowQualityScale)
-{
- drawImage(image, FloatRect(dest), srcRect, op, useLowQualityScale);
-}
-
-void GraphicsContext::drawText(const TextRun& run, const IntPoint& point, int from, int to)
-{
- if (paintingDisabled())
- return;
-
- font().drawText(this, run, point, from, to);
-}
-
-void GraphicsContext::drawBidiText(const TextRun& run, const FloatPoint& point)
-{
- if (paintingDisabled())
- return;
-
- BidiResolver<TextRunIterator, BidiCharacterRun> bidiResolver;
- WTF::Unicode::Direction paragraphDirection = run.ltr() ? WTF::Unicode::LeftToRight : WTF::Unicode::RightToLeft;
-
- bidiResolver.setStatus(BidiStatus(paragraphDirection, paragraphDirection, paragraphDirection, new BidiContext(run.ltr() ? 0 : 1, paragraphDirection, run.directionalOverride())));
-
- bidiResolver.setPosition(TextRunIterator(&run, 0));
- bidiResolver.createBidiRunsForLine(TextRunIterator(&run, run.length()));
-
- if (!bidiResolver.runCount())
- return;
-
- FloatPoint currPoint = point;
- BidiCharacterRun* bidiRun = bidiResolver.firstRun();
- while (bidiRun) {
-
- TextRun subrun = run;
- subrun.setText(run.data(bidiRun->start()), bidiRun->stop() - bidiRun->start());
- subrun.setRTL(bidiRun->level() % 2);
- subrun.setDirectionalOverride(bidiRun->dirOverride(false));
-
- font().drawText(this, subrun, currPoint);
-
- bidiRun = bidiRun->next();
- // FIXME: Have Font::drawText return the width of what it drew so that we don't have to re-measure here.
- if (bidiRun)
- currPoint.move(font().floatWidth(subrun), 0.f);
- }
-
- bidiResolver.deleteRuns();
-}
-
-void GraphicsContext::drawHighlightForText(const TextRun& run, const IntPoint& point, int h, const Color& backgroundColor, int from, int to)
-{
- if (paintingDisabled())
- return;
-
- fillRect(font().selectionRectForText(run, point, h, from, to), backgroundColor);
-}
-
-void GraphicsContext::initFocusRing(int width, int offset)
-{
- if (paintingDisabled())
- return;
- clearFocusRing();
-
- m_common->m_focusRingWidth = width;
- m_common->m_focusRingOffset = offset;
-}
-
-void GraphicsContext::clearFocusRing()
-{
- m_common->m_focusRingRects.clear();
-}
-
-IntRect GraphicsContext::focusRingBoundingRect()
-{
- IntRect result = IntRect(0, 0, 0, 0);
-
- const Vector<IntRect>& rects = focusRingRects();
- unsigned rectCount = rects.size();
- for (unsigned i = 0; i < rectCount; i++)
- result.unite(rects[i]);
-
- return result;
-}
-
-void GraphicsContext::addFocusRingRect(const IntRect& rect)
-{
- if (paintingDisabled() || rect.isEmpty())
- return;
- m_common->m_focusRingRects.append(rect);
-}
-
-int GraphicsContext::focusRingWidth() const
-{
- return m_common->m_focusRingWidth;
-}
-
-int GraphicsContext::focusRingOffset() const
-{
- return m_common->m_focusRingOffset;
-}
-
-const Vector<IntRect>& GraphicsContext::focusRingRects() const
-{
- return m_common->m_focusRingRects;
-}
-
-void GraphicsContext::drawImage(Image* image, const FloatRect& dest, const FloatRect& src, CompositeOperator op, bool useLowQualityScale)
-{
- if (paintingDisabled() || !image)
- return;
-
- float tsw = src.width();
- float tsh = src.height();
- float tw = dest.width();
- float th = dest.height();
-
- if (tsw == -1)
- tsw = image->width();
- if (tsh == -1)
- tsh = image->height();
-
- if (tw == -1)
- tw = image->width();
- if (th == -1)
- th = image->height();
-
- if (useLowQualityScale) {
- save();
- setImageInterpolationQuality(InterpolationNone);
- }
- image->draw(this, FloatRect(dest.location(), FloatSize(tw, th)), FloatRect(src.location(), FloatSize(tsw, tsh)), op);
- if (useLowQualityScale)
- restore();
-}
-
-void GraphicsContext::drawTiledImage(Image* image, const IntRect& rect, const IntPoint& srcPoint, const IntSize& tileSize, CompositeOperator op)
-{
- if (paintingDisabled() || !image)
- return;
-
- image->drawTiled(this, rect, srcPoint, tileSize, op);
-}
-
-void GraphicsContext::drawTiledImage(Image* image, const IntRect& dest, const IntRect& srcRect, Image::TileRule hRule, Image::TileRule vRule, CompositeOperator op)
-{
- if (paintingDisabled() || !image)
- return;
-
- if (hRule == Image::StretchTile && vRule == Image::StretchTile)
- // Just do a scale.
- return drawImage(image, dest, srcRect, op);
-
- image->drawTiled(this, dest, srcRect, hRule, vRule, op);
-}
-
-void GraphicsContext::addRoundedRectClip(const IntRect& rect, const IntSize& topLeft, const IntSize& topRight,
- const IntSize& bottomLeft, const IntSize& bottomRight)
-{
- if (paintingDisabled())
- return;
-
- clip(Path::createRoundedRectangle(rect, topLeft, topRight, bottomLeft, bottomRight));
-}
-
-void GraphicsContext::clipOutRoundedRect(const IntRect& rect, const IntSize& topLeft, const IntSize& topRight,
- const IntSize& bottomLeft, const IntSize& bottomRight)
-{
- if (paintingDisabled())
- return;
-
- clipOut(Path::createRoundedRectangle(rect, topLeft, topRight, bottomLeft, bottomRight));
-}
-
-int GraphicsContext::textDrawingMode()
-{
- return m_common->state.textDrawingMode;
-}
-
-void GraphicsContext::setTextDrawingMode(int mode)
-{
- m_common->state.textDrawingMode = mode;
- if (paintingDisabled())
- return;
- setPlatformTextDrawingMode(mode);
-}
-
-void GraphicsContext::fillRect(const FloatRect& rect, Generator& generator)
-{
- if (paintingDisabled())
- return;
- generator.fill(this, rect);
-}
-
-#if !PLATFORM(CG) && !PLATFORM(SKIA)
-// Implement this if you want to go ahead and push the drawing mode into your native context
-// immediately.
-void GraphicsContext::setPlatformTextDrawingMode(int mode)
-{
-}
-#endif
-
-#if !PLATFORM(QT) && !PLATFORM(CAIRO) && !PLATFORM(SKIA)
-void GraphicsContext::setPlatformStrokeStyle(const StrokeStyle&)
-{
-}
-#endif
-
-#if !PLATFORM(QT)
-void GraphicsContext::setPlatformFont(const Font&)
-{
-}
-#endif
-
-}
diff --git a/WebCore/platform/graphics/GraphicsContext.h b/WebCore/platform/graphics/GraphicsContext.h
deleted file mode 100644
index 95bdc90..0000000
--- a/WebCore/platform/graphics/GraphicsContext.h
+++ /dev/null
@@ -1,381 +0,0 @@
-/*
- * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GraphicsContext_h
-#define GraphicsContext_h
-
-#include "DashArray.h"
-#include "FloatRect.h"
-#include "Image.h"
-#include "IntRect.h"
-#include "Path.h"
-#include "TextDirection.h"
-#include <wtf/Noncopyable.h>
-#include <wtf/Platform.h>
-
-#if PLATFORM(CG)
-typedef struct CGContext PlatformGraphicsContext;
-#elif PLATFORM(CAIRO)
-typedef struct _cairo PlatformGraphicsContext;
-#elif PLATFORM(QT)
-QT_BEGIN_NAMESPACE
-class QPainter;
-QT_END_NAMESPACE
-typedef QPainter PlatformGraphicsContext;
-#elif PLATFORM(SGL)
-namespace WebCore {
-class PlatformGraphicsContext;
-}
-class SkPaint;
-struct SkPoint;
-#elif PLATFORM(WX)
-class wxGCDC;
-class wxWindowDC;
-
-// wxGraphicsContext allows us to support Path, etc.
-// but on some platforms, e.g. Linux, it requires fairly
-// new software.
-#if USE(WXGC)
-// On OS X, wxGCDC is just a typedef for wxDC, so use wxDC explicitly to make
-// the linker happy.
-#ifdef __APPLE__
- class wxDC;
- typedef wxDC PlatformGraphicsContext;
-#else
- typedef wxGCDC PlatformGraphicsContext;
-#endif
-#else
- typedef wxWindowDC PlatformGraphicsContext;
-#endif
-#elif PLATFORM(SKIA)
-typedef class PlatformContextSkia PlatformGraphicsContext;
-#else
-typedef void PlatformGraphicsContext;
-#endif
-
-#if PLATFORM(GTK)
-typedef struct _GdkDrawable GdkDrawable;
-typedef struct _GdkEventExpose GdkEventExpose;
-#endif
-
-#if PLATFORM(WIN)
-typedef struct HDC__* HDC;
-#if !PLATFORM(CG)
-// UInt8 is defined in CoreFoundation/CFBase.h
-typedef unsigned char UInt8;
-#endif
-#endif
-
-#if PLATFORM(QT) && defined(Q_WS_WIN)
-#include <windows.h>
-#endif
-
-namespace WebCore {
-
- const int cMisspellingLineThickness = 3;
- const int cMisspellingLinePatternWidth = 4;
- const int cMisspellingLinePatternGapWidth = 1;
-
- class AffineTransform;
- class Font;
- class Generator;
- class Gradient;
- class GraphicsContextPrivate;
- class GraphicsContextPlatformPrivate;
- class ImageBuffer;
- class KURL;
- class Path;
- class Pattern;
- class TextRun;
-
- // These bits can be ORed together for a total of 8 possible text drawing modes.
- const int cTextInvisible = 0;
- const int cTextFill = 1;
- const int cTextStroke = 2;
- const int cTextClip = 4;
-
- enum StrokeStyle {
- NoStroke,
- SolidStroke,
- DottedStroke,
- DashedStroke
- };
-
- enum InterpolationQuality {
- InterpolationDefault,
- InterpolationNone,
- InterpolationLow,
- InterpolationMedium,
- InterpolationHigh
- };
-
- // FIXME: Currently these constants have to match the values used in the SVG
- // DOM API. That's a mistake. We need to make cut that dependency.
- enum GradientSpreadMethod {
- SpreadMethodPad = 1,
- SpreadMethodReflect = 2,
- SpreadMethodRepeat = 3
- };
-
- class GraphicsContext : Noncopyable {
- public:
- GraphicsContext(PlatformGraphicsContext*);
- ~GraphicsContext();
-
- PlatformGraphicsContext* platformContext() const;
-
- const Font& font() const;
- void setFont(const Font&);
-
- float strokeThickness() const;
- void setStrokeThickness(float);
- StrokeStyle strokeStyle() const;
- void setStrokeStyle(const StrokeStyle& style);
- Color strokeColor() const;
- void setStrokeColor(const Color&);
- void setStrokePattern(PassRefPtr<Pattern>);
- void setStrokeGradient(PassRefPtr<Gradient>);
-
- WindRule fillRule() const;
- void setFillRule(WindRule);
- GradientSpreadMethod spreadMethod() const;
- void setSpreadMethod(GradientSpreadMethod);
- Color fillColor() const;
- void setFillColor(const Color&);
- void setFillPattern(PassRefPtr<Pattern>);
- void setFillGradient(PassRefPtr<Gradient>);
-
-#if PLATFORM(SGL)
- /* these should be pused to apple. needed for CanvasStyle.cpp */
- void setCMYKAFillColor(float c, float m, float y, float k, float a);
- void setCMYKAStrokeColor(float c, float m, float y, float k, float a);
-
- // initialize a paint for filling
- void setupFillPaint(SkPaint*);
- // initialize a paint for stroking
- void setupStrokePaint(SkPaint*);
- // initialize a paint for a shadow, or if false is returned, the
- // parameters are left untouched
- bool setupShadowPaint(SkPaint* paint, SkPoint* offset);
- // returns true if there is a valid (non-transparent) fill color
- bool willFill() const;
- // returns true if there is a valid (non-transparent) stroke color
- bool willStroke() const;
-
- /** platform-specific factory method to return a bitmap graphicscontext,
- called by <canvas> when we need to draw offscreen. Caller is responsible for
- deleting the context. Use drawOffscreenContext() to draw the context's image
- onto another graphics context.
- */
- static GraphicsContext* createOffscreenContext(int width, int height);
-#endif
-
- void save();
- void restore();
-
- // These draw methods will do both stroking and filling.
- void drawRect(const IntRect&);
- void drawLine(const IntPoint&, const IntPoint&);
- void drawEllipse(const IntRect&);
- void drawConvexPolygon(size_t numPoints, const FloatPoint*, bool shouldAntialias = false);
-
- void drawPath();
- void fillPath();
- void strokePath();
-
- // Arc drawing (used by border-radius in CSS) just supports stroking at the moment.
- void strokeArc(const IntRect&, int startAngle, int angleSpan);
-
- void fillRect(const FloatRect&);
- void fillRect(const FloatRect&, const Color&);
- void fillRect(const FloatRect&, Generator&);
- void fillRoundedRect(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color&);
-
- void clearRect(const FloatRect&);
-
- void strokeRect(const FloatRect&);
- void strokeRect(const FloatRect&, float lineWidth);
-
- void drawImage(Image*, const IntPoint&, CompositeOperator = CompositeSourceOver);
- void drawImage(Image*, const IntRect&, CompositeOperator = CompositeSourceOver, bool useLowQualityScale = false);
- void drawImage(Image*, const IntPoint& destPoint, const IntRect& srcRect, CompositeOperator = CompositeSourceOver);
- void drawImage(Image*, const IntRect& destRect, const IntRect& srcRect, CompositeOperator = CompositeSourceOver, bool useLowQualityScale = false);
- void drawImage(Image*, const FloatRect& destRect, const FloatRect& srcRect = FloatRect(0, 0, -1, -1),
- CompositeOperator = CompositeSourceOver, bool useLowQualityScale = false);
- void drawTiledImage(Image*, const IntRect& destRect, const IntPoint& srcPoint, const IntSize& tileSize,
- CompositeOperator = CompositeSourceOver);
- void drawTiledImage(Image*, const IntRect& destRect, const IntRect& srcRect,
- Image::TileRule hRule = Image::StretchTile, Image::TileRule vRule = Image::StretchTile,
- CompositeOperator = CompositeSourceOver);
-
- void setImageInterpolationQuality(InterpolationQuality);
- InterpolationQuality imageInterpolationQuality() const;
-
- void clip(const FloatRect&);
- void addRoundedRectClip(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight);
- void addInnerRoundedRectClip(const IntRect&, int thickness);
- void clipOut(const IntRect&);
- void clipOutEllipseInRect(const IntRect&);
- void clipOutRoundedRect(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight);
- void clipToImageBuffer(const FloatRect&, const ImageBuffer*);
-
- int textDrawingMode();
- void setTextDrawingMode(int);
-
- void drawText(const TextRun&, const IntPoint&, int from = 0, int to = -1);
- void drawBidiText(const TextRun&, const FloatPoint&);
- void drawHighlightForText(const TextRun&, const IntPoint&, int h, const Color& backgroundColor, int from = 0, int to = -1);
-
- FloatRect roundToDevicePixels(const FloatRect&);
-
- void drawLineForText(const IntPoint&, int width, bool printing);
- void drawLineForMisspellingOrBadGrammar(const IntPoint&, int width, bool grammar);
-
- bool paintingDisabled() const;
- void setPaintingDisabled(bool);
-
- bool updatingControlTints() const;
- void setUpdatingControlTints(bool);
-
- void beginTransparencyLayer(float opacity);
- void endTransparencyLayer();
-
- void setShadow(const IntSize&, int blur, const Color&);
- bool getShadow(IntSize&, int&, Color&) const;
- void clearShadow();
-
- void initFocusRing(int width, int offset);
- void addFocusRingRect(const IntRect&);
- void drawFocusRing(const Color&);
- void clearFocusRing();
- IntRect focusRingBoundingRect();
-
- void setLineCap(LineCap);
- void setLineDash(const DashArray&, float dashOffset);
- void setLineJoin(LineJoin);
- void setMiterLimit(float);
-
- void setAlpha(float);
-#if PLATFORM(CAIRO)
- float getAlpha();
-#endif
-
- void setCompositeOperation(CompositeOperator);
-
- void beginPath();
- void addPath(const Path&);
-
- void clip(const Path&);
- void clipOut(const Path&);
-
- void scale(const FloatSize&);
- void rotate(float angleInRadians);
- void translate(float x, float y);
- IntPoint origin();
-
- void setURLForRect(const KURL&, const IntRect&);
-
- void concatCTM(const AffineTransform&);
- AffineTransform getCTM() const;
-
- void setUseAntialiasing(bool = true);
-
-#if PLATFORM(WIN)
- GraphicsContext(HDC, bool hasAlpha = false); // FIXME: To be removed.
- bool inTransparencyLayer() const;
- HDC getWindowsContext(const IntRect&, bool supportAlphaBlend = true, bool mayCreateBitmap = true); // The passed in rect is used to create a bitmap for compositing inside transparency layers.
- void releaseWindowsContext(HDC, const IntRect&, bool supportAlphaBlend = true, bool mayCreateBitmap = true); // The passed in HDC should be the one handed back by getWindowsContext.
-
- class WindowsBitmap : public Noncopyable {
- public:
- WindowsBitmap(HDC, IntSize);
- ~WindowsBitmap();
-
- HDC hdc() const { return m_hdc; }
- UInt8* buffer() const { return m_bitmapBuffer; }
- unsigned bufferLength() const { return m_bitmapBufferLength; }
- IntSize size() const { return m_size; }
- unsigned bytesPerRow() const { return m_bytesPerRow; }
-
- private:
- HDC m_hdc;
- HBITMAP m_bitmap;
- UInt8* m_bitmapBuffer;
- unsigned m_bitmapBufferLength;
- IntSize m_size;
- unsigned m_bytesPerRow;
- };
-
- WindowsBitmap* createWindowsBitmap(IntSize);
- // The bitmap should be non-premultiplied.
- void drawWindowsBitmap(WindowsBitmap*, const IntPoint&);
-#endif
-
-#if PLATFORM(QT) && defined(Q_WS_WIN)
- HDC getWindowsContext(const IntRect&, bool supportAlphaBlend = true, bool mayCreateBitmap = true);
- void releaseWindowsContext(HDC, const IntRect&, bool supportAlphaBlend = true, bool mayCreateBitmap = true);
-#endif
-
-#if PLATFORM(QT)
- bool inTransparencyLayer() const;
- PlatformPath* currentPath();
-#endif
-
-#if PLATFORM(GTK)
- void setGdkExposeEvent(GdkEventExpose*);
- GdkDrawable* gdkDrawable() const;
- GdkEventExpose* gdkExposeEvent() const;
-#endif
-
- private:
- void savePlatformState();
- void restorePlatformState();
-
- void setPlatformTextDrawingMode(int);
- void setPlatformFont(const Font& font);
-
- void setPlatformStrokeColor(const Color&);
- void setPlatformStrokeStyle(const StrokeStyle&);
- void setPlatformStrokeThickness(float);
-
- void setPlatformFillColor(const Color&);
-
- void setPlatformShadow(const IntSize&, int blur, const Color&);
- void clearPlatformShadow();
-
- int focusRingWidth() const;
- int focusRingOffset() const;
- const Vector<IntRect>& focusRingRects() const;
-
- static GraphicsContextPrivate* createGraphicsContextPrivate();
- static void destroyGraphicsContextPrivate(GraphicsContextPrivate*);
-
- GraphicsContextPrivate* m_common;
- GraphicsContextPlatformPrivate* m_data; // Deprecated; m_commmon can just be downcasted. To be removed.
- };
-
-} // namespace WebCore
-
-#endif // GraphicsContext_h
diff --git a/WebCore/platform/graphics/GraphicsContextPrivate.h b/WebCore/platform/graphics/GraphicsContextPrivate.h
deleted file mode 100644
index de94527..0000000
--- a/WebCore/platform/graphics/GraphicsContextPrivate.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GraphicsContextPrivate_h
-#define GraphicsContextPrivate_h
-
-#include "Font.h"
-#include "Gradient.h"
-#include "GraphicsContext.h"
-#include "Pattern.h"
-
-namespace WebCore {
-
-// FIXME: This is a place-holder until we decide to add
-// real color space support to WebCore. At that time, ColorSpace will be a
-// class and instances will be held off of Colors. There will be
-// special singleton Gradient and Pattern color spaces to mark when
-// a fill or stroke is using a gradient or pattern instead of a solid color.
-// https://bugs.webkit.org/show_bug.cgi?id=20558
- enum ColorSpace {
- SolidColorSpace,
- PatternColorSpace,
- GradientColorSpace
- };
-
- struct GraphicsContextState {
- GraphicsContextState()
- : textDrawingMode(cTextFill)
- , strokeStyle(SolidStroke)
- , strokeThickness(0)
-#if PLATFORM(CAIRO)
- , globalAlpha(1.0f)
-#endif
- , strokeColorSpace(SolidColorSpace)
- , strokeColor(Color::black)
- , fillRule(RULE_NONZERO)
- , fillColorSpace(SolidColorSpace)
- , fillColor(Color::black)
- , paintingDisabled(false)
- , shadowBlur(0)
- {
- }
-
- Font font;
- int textDrawingMode;
-
- StrokeStyle strokeStyle;
- float strokeThickness;
-#if PLATFORM(CAIRO)
- float globalAlpha;
-#endif
- ColorSpace strokeColorSpace;
- Color strokeColor;
- RefPtr<Gradient> strokeGradient;
- RefPtr<Pattern> strokePattern;
-
- WindRule fillRule;
- GradientSpreadMethod spreadMethod;
- ColorSpace fillColorSpace;
- Color fillColor;
- RefPtr<Gradient> fillGradient;
- RefPtr<Pattern> fillPattern;
-
- bool paintingDisabled;
-
- IntSize shadowSize;
- unsigned shadowBlur;
- Color shadowColor;
- };
-
- class GraphicsContextPrivate {
- public:
- GraphicsContextPrivate()
- : m_focusRingWidth(0)
- , m_focusRingOffset(0)
- , m_updatingControlTints(false)
- {
- }
-
- GraphicsContextState state;
- Vector<GraphicsContextState> stack;
- Vector<IntRect> m_focusRingRects;
- int m_focusRingWidth;
- int m_focusRingOffset;
- bool m_updatingControlTints;
- };
-
-} // namespace WebCore
-
-#endif // GraphicsContextPrivate_h
diff --git a/WebCore/platform/graphics/GraphicsTypes.cpp b/WebCore/platform/graphics/GraphicsTypes.cpp
deleted file mode 100644
index 761bf40..0000000
--- a/WebCore/platform/graphics/GraphicsTypes.cpp
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "GraphicsTypes.h"
-
-#include "PlatformString.h"
-#include <wtf/Assertions.h>
-
-namespace WebCore {
-
-static const char* const compositeOperatorNames[] = {
- "clear",
- "copy",
- "source-over",
- "source-in",
- "source-out",
- "source-atop",
- "destination-over",
- "destination-in",
- "destination-out",
- "destination-atop",
- "xor",
- "darker",
- "highlight",
- "lighter"
-};
-const int numCompositeOperatorNames = sizeof(compositeOperatorNames) / sizeof(compositeOperatorNames[0]);
-
-bool parseCompositeOperator(const String& s, CompositeOperator& op)
-{
- for (int i = 0; i < numCompositeOperatorNames; i++)
- if (s == compositeOperatorNames[i]) {
- op = static_cast<CompositeOperator>(i);
- return true;
- }
- return false;
-}
-
-String compositeOperatorName(CompositeOperator op)
-{
- ASSERT(op >= 0);
- ASSERT(op < numCompositeOperatorNames);
- return compositeOperatorNames[op];
-}
-
-bool parseLineCap(const String& s, LineCap& cap)
-{
- if (s == "butt") {
- cap = ButtCap;
- return true;
- }
- if (s == "round") {
- cap = RoundCap;
- return true;
- }
- if (s == "square") {
- cap = SquareCap;
- return true;
- }
- return false;
-}
-
-String lineCapName(LineCap cap)
-{
- ASSERT(cap >= 0);
- ASSERT(cap < 3);
- const char* const names[3] = { "butt", "round", "square" };
- return names[cap];
-}
-
-bool parseLineJoin(const String& s, LineJoin& join)
-{
- if (s == "miter") {
- join = MiterJoin;
- return true;
- }
- if (s == "round") {
- join = RoundJoin;
- return true;
- }
- if (s == "bevel") {
- join = BevelJoin;
- return true;
- }
- return false;
-}
-
-String lineJoinName(LineJoin join)
-{
- ASSERT(join >= 0);
- ASSERT(join < 3);
- const char* const names[3] = { "miter", "round", "bevel" };
- return names[join];
-}
-
-String textAlignName(TextAlign align)
-{
- ASSERT(align >= 0);
- ASSERT(align < 5);
- const char* const names[5] = { "start", "end", "left", "center", "right" };
- return names[align];
-}
-
-bool parseTextAlign(const String& s, TextAlign& align)
-{
- if (s == "start") {
- align = StartTextAlign;
- return true;
- }
- if (s == "end") {
- align = EndTextAlign;
- return true;
- }
- if (s == "left") {
- align = LeftTextAlign;
- return true;
- }
- if (s == "center") {
- align = CenterTextAlign;
- return true;
- }
- if (s == "right") {
- align = RightTextAlign;
- return true;
- }
- return false;
-}
-
-String textBaselineName(TextBaseline baseline)
-{
- ASSERT(baseline >= 0);
- ASSERT(baseline < 6);
- const char* const names[6] = { "alphabetic", "top", "middle", "bottom", "ideographic", "hanging" };
- return names[baseline];
-}
-
-bool parseTextBaseline(const String& s, TextBaseline& baseline)
-{
- if (s == "alphabetic") {
- baseline = AlphabeticTextBaseline;
- return true;
- }
- if (s == "top") {
- baseline = TopTextBaseline;
- return true;
- }
- if (s == "middle") {
- baseline = MiddleTextBaseline;
- return true;
- }
- if (s == "bottom") {
- baseline = BottomTextBaseline;
- return true;
- }
- if (s == "ideographic") {
- baseline = IdeographicTextBaseline;
- return true;
- }
- if (s == "hanging") {
- baseline = HangingTextBaseline;
- return true;
- }
- return false;
-}
-
-}
diff --git a/WebCore/platform/graphics/GraphicsTypes.h b/WebCore/platform/graphics/GraphicsTypes.h
deleted file mode 100644
index cdf5e31..0000000
--- a/WebCore/platform/graphics/GraphicsTypes.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GraphicsTypes_h
-#define GraphicsTypes_h
-
-namespace WebCore {
-
- class String;
-
- // Note: These constants exactly match the NSCompositeOperator constants of
- // AppKit on Mac OS X Tiger. If these ever change, we'll need to change the
- // Mac OS X Tiger platform code to map one to the other.
- enum CompositeOperator {
- CompositeClear,
- CompositeCopy,
- CompositeSourceOver,
- CompositeSourceIn,
- CompositeSourceOut,
- CompositeSourceAtop,
- CompositeDestinationOver,
- CompositeDestinationIn,
- CompositeDestinationOut,
- CompositeDestinationAtop,
- CompositeXOR,
- CompositePlusDarker,
- CompositeHighlight,
- CompositePlusLighter
- };
-
- enum LineCap { ButtCap, RoundCap, SquareCap };
-
- enum LineJoin { MiterJoin, RoundJoin, BevelJoin };
-
- enum HorizontalAlignment { AlignLeft, AlignRight, AlignHCenter };
-
- enum TextBaseline { AlphabeticTextBaseline, TopTextBaseline, MiddleTextBaseline, BottomTextBaseline, IdeographicTextBaseline, HangingTextBaseline };
-
- enum TextAlign { StartTextAlign, EndTextAlign, LeftTextAlign, CenterTextAlign, RightTextAlign };
-
- String compositeOperatorName(CompositeOperator);
- bool parseCompositeOperator(const String&, CompositeOperator&);
-
- String lineCapName(LineCap);
- bool parseLineCap(const String&, LineCap&);
-
- String lineJoinName(LineJoin);
- bool parseLineJoin(const String&, LineJoin&);
-
- String textAlignName(TextAlign);
- bool parseTextAlign(const String&, TextAlign&);
-
- String textBaselineName(TextBaseline);
- bool parseTextBaseline(const String&, TextBaseline&);
-
-} // namespace WebCore
-
-#endif
diff --git a/WebCore/platform/graphics/Icon.h b/WebCore/platform/graphics/Icon.h
deleted file mode 100644
index 444c67c..0000000
--- a/WebCore/platform/graphics/Icon.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef Icon_h
-#define Icon_h
-
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/Forward.h>
-#include <wtf/Vector.h>
-
-#if PLATFORM(MAC)
-#include <wtf/RetainPtr.h>
-#ifdef __OBJC__
-@class NSImage;
-#else
-class NSImage;
-#endif
-#elif PLATFORM(WIN)
-typedef struct HICON__* HICON;
-#elif PLATFORM(QT)
-#include <QIcon>
-#elif PLATFORM(GTK)
-typedef struct _GdkPixbuf GdkPixbuf;
-#elif PLATFORM(CHROMIUM)
-#include "PlatformIcon.h"
-#endif
-
-namespace WebCore {
-
-class GraphicsContext;
-class IntRect;
-class String;
-
-class Icon : public RefCounted<Icon> {
-public:
- static PassRefPtr<Icon> createIconForFile(const String& filename);
- static PassRefPtr<Icon> createIconForFiles(const Vector<String>& filenames);
-
- ~Icon();
-
- void paint(GraphicsContext*, const IntRect&);
-
-#if PLATFORM(WIN)
- static PassRefPtr<Icon> create(HICON hIcon) { return adoptRef(new Icon(hIcon)); }
-#endif
-
-private:
-#if PLATFORM(MAC)
- Icon(NSImage*);
- RetainPtr<NSImage> m_nsImage;
-#elif PLATFORM(WIN)
- Icon(HICON);
- HICON m_hIcon;
-#elif PLATFORM(QT)
- Icon();
- QIcon m_icon;
-#elif PLATFORM(GTK)
- Icon();
- GdkPixbuf* m_icon;
-#elif PLATFORM(CHROMIUM)
- Icon(const PlatformIcon&);
- PlatformIcon m_icon;
-#endif
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/graphics/Image.cpp b/WebCore/platform/graphics/Image.cpp
deleted file mode 100644
index ca6954e..0000000
--- a/WebCore/platform/graphics/Image.cpp
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
- * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Image.h"
-
-#include "AffineTransform.h"
-#include "BitmapImage.h"
-#include "GraphicsContext.h"
-#include "IntRect.h"
-#include "MIMETypeRegistry.h"
-
-#include <math.h>
-
-#if PLATFORM(CG)
-#include <CoreFoundation/CoreFoundation.h>
-#endif
-
-namespace WebCore {
-
-Image::Image(ImageObserver* observer)
- : m_imageObserver(observer)
-{
-}
-
-Image::~Image()
-{
-}
-
-Image* Image::nullImage()
-{
- static RefPtr<Image> nullImage = BitmapImage::create();
- return nullImage.get();
-}
-
-bool Image::supportsType(const String& type)
-{
- return MIMETypeRegistry::isSupportedImageResourceMIMEType(type);
-}
-
-bool Image::isNull() const
-{
- return size().isEmpty();
-}
-
-bool Image::setData(PassRefPtr<SharedBuffer> data, bool allDataReceived)
-{
- m_data = data;
- if (!m_data.get())
- return true;
-
- int length = m_data->size();
- if (!length)
- return true;
-
- return dataChanged(allDataReceived);
-}
-
-IntRect Image::rect() const
-{
- return IntRect(IntPoint(), size());
-}
-
-int Image::width() const
-{
- return size().width();
-}
-
-int Image::height() const
-{
- return size().height();
-}
-
-void Image::fillWithSolidColor(GraphicsContext* ctxt, const FloatRect& dstRect, const Color& color, CompositeOperator op)
-{
- if (color.alpha() <= 0)
- return;
-
- ctxt->save();
- ctxt->setCompositeOperation(!color.hasAlpha() && op == CompositeSourceOver ? CompositeCopy : op);
- ctxt->fillRect(dstRect, color);
- ctxt->restore();
-}
-
-static inline FloatSize calculatePatternScale(const FloatRect& dstRect, const FloatRect& srcRect, Image::TileRule hRule, Image::TileRule vRule)
-{
- float scaleX = 1.0f, scaleY = 1.0f;
-
- if (hRule == Image::StretchTile)
- scaleX = dstRect.width() / srcRect.width();
- if (vRule == Image::StretchTile)
- scaleY = dstRect.height() / srcRect.height();
-
- if (hRule == Image::RepeatTile)
- scaleX = scaleY;
- if (vRule == Image::RepeatTile)
- scaleY = scaleX;
-
- return FloatSize(scaleX, scaleY);
-}
-
-
-void Image::drawTiled(GraphicsContext* ctxt, const FloatRect& destRect, const FloatPoint& srcPoint, const FloatSize& scaledTileSize, CompositeOperator op)
-{
- if (mayFillWithSolidColor()) {
- fillWithSolidColor(ctxt, destRect, solidColor(), op);
- return;
- }
-
- FloatSize intrinsicTileSize = size();
- if (hasRelativeWidth())
- intrinsicTileSize.setWidth(scaledTileSize.width());
- if (hasRelativeHeight())
- intrinsicTileSize.setHeight(scaledTileSize.height());
-
- FloatSize scale(scaledTileSize.width() / intrinsicTileSize.width(),
- scaledTileSize.height() / intrinsicTileSize.height());
- AffineTransform patternTransform = AffineTransform().scale(scale.width(), scale.height());
-
- FloatRect oneTileRect;
- oneTileRect.setX(destRect.x() + fmodf(fmodf(-srcPoint.x(), scaledTileSize.width()) - scaledTileSize.width(), scaledTileSize.width()));
- oneTileRect.setY(destRect.y() + fmodf(fmodf(-srcPoint.y(), scaledTileSize.height()) - scaledTileSize.height(), scaledTileSize.height()));
- oneTileRect.setSize(scaledTileSize);
-
- // Check and see if a single draw of the image can cover the entire area we are supposed to tile.
- if (oneTileRect.contains(destRect)) {
- FloatRect visibleSrcRect;
- visibleSrcRect.setX((destRect.x() - oneTileRect.x()) / scale.width());
- visibleSrcRect.setY((destRect.y() - oneTileRect.y()) / scale.height());
- visibleSrcRect.setWidth(destRect.width() / scale.width());
- visibleSrcRect.setHeight(destRect.height() / scale.height());
- draw(ctxt, destRect, visibleSrcRect, op);
- return;
- }
-
- FloatRect tileRect(FloatPoint(), intrinsicTileSize);
- drawPattern(ctxt, tileRect, patternTransform, oneTileRect.location(), op, destRect);
-
- startAnimation();
-}
-
-// FIXME: Merge with the other drawTiled eventually, since we need a combination of both for some things.
-void Image::drawTiled(GraphicsContext* ctxt, const FloatRect& dstRect, const FloatRect& srcRect, TileRule hRule, TileRule vRule, CompositeOperator op)
-{
- if (mayFillWithSolidColor()) {
- fillWithSolidColor(ctxt, dstRect, solidColor(), op);
- return;
- }
-
- // FIXME: We do not support 'round' yet. For now just map it to 'repeat'.
- if (hRule == RoundTile)
- hRule = RepeatTile;
- if (vRule == RoundTile)
- vRule = RepeatTile;
-
- FloatSize scale = calculatePatternScale(dstRect, srcRect, hRule, vRule);
- AffineTransform patternTransform = AffineTransform().scale(scale.width(), scale.height());
-
- // We want to construct the phase such that the pattern is centered (when stretch is not
- // set for a particular rule).
- float hPhase = scale.width() * srcRect.x();
- float vPhase = scale.height() * srcRect.y();
- if (hRule == Image::RepeatTile)
- hPhase -= fmodf(dstRect.width(), scale.width() * srcRect.width()) / 2.0f;
- if (vRule == Image::RepeatTile)
- vPhase -= fmodf(dstRect.height(), scale.height() * srcRect.height()) / 2.0f;
- FloatPoint patternPhase(dstRect.x() - hPhase, dstRect.y() - vPhase);
-
- drawPattern(ctxt, srcRect, patternTransform, patternPhase, op, dstRect);
-
- startAnimation();
-}
-
-
-}
diff --git a/WebCore/platform/graphics/Image.h b/WebCore/platform/graphics/Image.h
deleted file mode 100644
index 1419b2d..0000000
--- a/WebCore/platform/graphics/Image.h
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
- * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef Image_h
-#define Image_h
-
-#include "Color.h"
-#include "GraphicsTypes.h"
-#include "ImageSource.h"
-#include <wtf/RefPtr.h>
-#include <wtf/PassRefPtr.h>
-#include "SharedBuffer.h"
-
-#if PLATFORM(MAC)
-#ifdef __OBJC__
-@class NSImage;
-#else
-class NSImage;
-#endif
-#endif
-
-#if PLATFORM(CG)
-struct CGContext;
-#endif
-
-#if PLATFORM(WIN)
-typedef struct tagSIZE SIZE;
-typedef SIZE* LPSIZE;
-typedef struct HBITMAP__ *HBITMAP;
-#endif
-
-#if PLATFORM(SKIA)
-class NativeImageSkia;
-#endif
-
-#if PLATFORM(QT)
-#include <QPixmap>
-#endif
-
-#if PLATFORM(SGL)
-class SkBitmapRef;
-#endif
-
-namespace WebCore {
-
-class AffineTransform;
-class FloatPoint;
-class FloatRect;
-class FloatSize;
-class GraphicsContext;
-class IntRect;
-class IntSize;
-class SharedBuffer;
-class String;
-
-// This class gets notified when an image creates or destroys decoded frames and when it advances animation frames.
-class ImageObserver;
-
-class Image : public RefCounted<Image> {
- friend class GeneratedImage;
- friend class GraphicsContext;
-public:
- virtual ~Image();
-
- static PassRefPtr<Image> create(ImageObserver* = 0);
- static PassRefPtr<Image> loadPlatformResource(const char* name);
- static bool supportsType(const String&);
-
- virtual bool isBitmapImage() const { return false; }
-
- // Derived classes should override this if they can assure that
- // the image contains only resources from its own security origin.
- virtual bool hasSingleSecurityOrigin() const { return false; }
-
- static Image* nullImage();
- bool isNull() const;
-
- // These are only used for SVGImage right now
- virtual void setContainerSize(const IntSize&) { }
- virtual bool usesContainerSize() const { return false; }
- virtual bool hasRelativeWidth() const { return false; }
- virtual bool hasRelativeHeight() const { return false; }
-
- virtual IntSize size() const = 0;
- IntRect rect() const;
- int width() const;
- int height() const;
-
- bool setData(PassRefPtr<SharedBuffer> data, bool allDataReceived);
- virtual bool dataChanged(bool allDataReceived) { return false; }
-
- virtual void destroyDecodedData(bool incremental = false, bool preserveNearbyFrames = false) = 0;
- virtual unsigned decodedSize() const = 0;
-
- SharedBuffer* data() { return m_data.get(); }
-
- // It may look unusual that there is no start animation call as public API. This is because
- // we start and stop animating lazily. Animation begins whenever someone draws the image. It will
- // automatically pause once all observers no longer want to render the image anywhere.
- virtual void stopAnimation() {}
- virtual void resetAnimation() {}
-
- // Typically the CachedImage that owns us.
- ImageObserver* imageObserver() const { return m_imageObserver; }
-
- enum TileRule { StretchTile, RoundTile, RepeatTile };
-
- virtual NativeImagePtr nativeImageForCurrentFrame() { return 0; }
-
-#if PLATFORM(MAC)
- // Accessors for native image formats.
- virtual NSImage* getNSImage() { return 0; }
- virtual CFDataRef getTIFFRepresentation() { return 0; }
-#endif
-
-#if PLATFORM(CG)
- virtual CGImageRef getCGImageRef() { return 0; }
-#endif
-
-#if PLATFORM(WIN)
- virtual bool getHBITMAP(HBITMAP) { return false; }
- virtual bool getHBITMAPOfSize(HBITMAP, LPSIZE) { return false; }
-#endif
-
-#if PLATFORM(SGL)
- virtual SkBitmapRef* getBitmap() { return 0; }
- virtual void setURL(const String& str) {}
-#endif
-
-protected:
- Image(ImageObserver* = 0);
-
- static void fillWithSolidColor(GraphicsContext* ctxt, const FloatRect& dstRect, const Color& color, CompositeOperator op);
-
-#if PLATFORM(WIN)
- virtual void drawFrameMatchingSourceSize(GraphicsContext*, const FloatRect& dstRect, const IntSize& srcSize, CompositeOperator) { }
-#endif
- virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, CompositeOperator) = 0;
- void drawTiled(GraphicsContext*, const FloatRect& dstRect, const FloatPoint& srcPoint, const FloatSize& tileSize, CompositeOperator);
- void drawTiled(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, TileRule hRule, TileRule vRule, CompositeOperator);
-
- // Supporting tiled drawing
- virtual bool mayFillWithSolidColor() const { return false; }
- virtual Color solidColor() const { return Color(); }
-
- virtual void startAnimation() { }
-
- virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform,
- const FloatPoint& phase, CompositeOperator, const FloatRect& destRect);
-#if PLATFORM(CG)
- // These are private to CG. Ideally they would be only in the .cpp file, but the callback requires access
- // to the private function nativeImageForCurrentFrame()
- static void drawPatternCallback(void* info, CGContext*);
-#endif
-
-protected:
- RefPtr<SharedBuffer> m_data; // The encoded raw data for the image.
- ImageObserver* m_imageObserver;
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/graphics/ImageBuffer.h b/WebCore/platform/graphics/ImageBuffer.h
deleted file mode 100644
index 7c68fc8..0000000
--- a/WebCore/platform/graphics/ImageBuffer.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ImageBuffer_h
-#define ImageBuffer_h
-
-#include "Image.h"
-#include "IntSize.h"
-#include "ImageBufferData.h"
-#include <wtf/OwnPtr.h>
-#include <wtf/PassRefPtr.h>
-#include <memory>
-
-namespace WebCore {
-
- class GraphicsContext;
- class ImageData;
- class IntPoint;
- class IntRect;
- class String;
-
- class ImageBuffer : Noncopyable {
- public:
- // Will return a null pointer on allocation failure.
- static std::auto_ptr<ImageBuffer> create(const IntSize& size, bool grayScale)
- {
- bool success = false;
- std::auto_ptr<ImageBuffer> buf(new ImageBuffer(size, grayScale, success));
- if (success)
- return buf;
- return std::auto_ptr<ImageBuffer>();
- }
-
- ~ImageBuffer();
-
- const IntSize& size() const { return m_size; }
- GraphicsContext* context() const;
-
- Image* image() const;
-
- void clearImage() { m_image.clear(); }
-
- PassRefPtr<ImageData> getImageData(const IntRect& rect) const;
- void putImageData(ImageData* source, const IntRect& sourceRect, const IntPoint& destPoint);
-
- String toDataURL(const String& mimeType) const;
-
- private:
- ImageBufferData m_data;
-
- IntSize m_size;
- OwnPtr<GraphicsContext> m_context;
- mutable RefPtr<Image> m_image;
-
- // This constructor will place its succes into the given out-variable
- // so that create() knows when it should return failure.
- ImageBuffer(const IntSize&, bool grayScale, bool& success);
- };
-
-} // namespace WebCore
-
-#endif // ImageBuffer_h
diff --git a/WebCore/platform/graphics/ImageObserver.h b/WebCore/platform/graphics/ImageObserver.h
deleted file mode 100644
index 4be83bd..0000000
--- a/WebCore/platform/graphics/ImageObserver.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ImageObserver_h
-#define ImageObserver_h
-
-namespace WebCore {
-
-class Image;
-
-// Interface for notification about changes to an image, including decoding,
-// drawing, and animating.
-class ImageObserver {
-protected:
- virtual ~ImageObserver() {}
-public:
- virtual void decodedSizeChanged(const Image*, int delta) = 0;
- virtual void didDraw(const Image*) = 0;
-
- virtual bool shouldPauseAnimation(const Image*) = 0;
- virtual void animationAdvanced(const Image*) = 0;
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/graphics/ImageSource.h b/WebCore/platform/graphics/ImageSource.h
deleted file mode 100644
index a9f346d..0000000
--- a/WebCore/platform/graphics/ImageSource.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ImageSource_h
-#define ImageSource_h
-
-#include <wtf/Noncopyable.h>
-#include <wtf/Vector.h>
-
-#if PLATFORM(WX)
-class wxBitmap;
-#elif PLATFORM(CG)
-typedef struct CGImageSource* CGImageSourceRef;
-typedef struct CGImage* CGImageRef;
-typedef const struct __CFData* CFDataRef;
-#elif PLATFORM(QT)
-#include <qglobal.h>
-QT_BEGIN_NAMESPACE
-class QPixmap;
-QT_END_NAMESPACE
-#elif PLATFORM(CAIRO)
-struct _cairo_surface;
-typedef struct _cairo_surface cairo_surface_t;
-#elif PLATFORM(SGL)
-#include "SkString.h"
-class SkBitmapRef;
-class PrivateAndroidImageSourceRec;
-#elif PLATFORM(SKIA)
-class NativeImageSkia;
-#endif
-
-namespace WebCore {
-
-class IntSize;
-class SharedBuffer;
-
-#if PLATFORM(WX)
-class ImageDecoder;
-typedef ImageDecoder* NativeImageSourcePtr;
-typedef const Vector<char>* NativeBytePtr;
-typedef wxBitmap* NativeImagePtr;
-#elif PLATFORM(CG)
-typedef CGImageSourceRef NativeImageSourcePtr;
-typedef CGImageRef NativeImagePtr;
-#elif PLATFORM(QT)
-class ImageDecoderQt;
-typedef ImageDecoderQt* NativeImageSourcePtr;
-typedef QPixmap* NativeImagePtr;
-#elif PLATFORM(SGL)
-class String;
-struct NativeImageSourcePtr {
- SkString m_url;
- PrivateAndroidImageSourceRec* m_image;
-};
-typedef const Vector<char>* NativeBytePtr;
-typedef SkBitmapRef* NativeImagePtr;
-#elif PLATFORM(CAIRO)
-class ImageDecoder;
-typedef ImageDecoder* NativeImageSourcePtr;
-typedef cairo_surface_t* NativeImagePtr;
-#elif PLATFORM(SKIA)
-class ImageDecoder;
-typedef ImageDecoder* NativeImageSourcePtr;
-typedef NativeImageSkia* NativeImagePtr;
-#endif
-
-const int cAnimationLoopOnce = -1;
-const int cAnimationNone = -2;
-
-class ImageSource : Noncopyable {
-public:
- ImageSource();
- ~ImageSource();
-
- void clear();
-
- bool initialized() const;
-
- void setData(SharedBuffer* data, bool allDataReceived);
-
- bool isSizeAvailable();
- IntSize size() const;
- IntSize frameSizeAtIndex(size_t) const;
-
- int repetitionCount();
-
- size_t frameCount() const;
-
- NativeImagePtr createFrameAtIndex(size_t);
-
- float frameDurationAtIndex(size_t);
- bool frameHasAlphaAtIndex(size_t); // Whether or not the frame actually used any alpha.
- bool frameIsCompleteAtIndex(size_t); // Whether or not the frame is completely decoded.
-
-#if PLATFORM(SGL)
- void clearURL();
- void setURL(const String& url);
-#endif
-private:
- NativeImageSourcePtr m_decoder;
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/graphics/IntPoint.h b/WebCore/platform/graphics/IntPoint.h
deleted file mode 100644
index cb24b4e..0000000
--- a/WebCore/platform/graphics/IntPoint.h
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef IntPoint_h
-#define IntPoint_h
-
-#include "IntSize.h"
-#include <wtf/Platform.h>
-
-#if PLATFORM(CG)
-typedef struct CGPoint CGPoint;
-#endif
-
-#if PLATFORM(MAC)
-#ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
-typedef struct CGPoint NSPoint;
-#else
-typedef struct _NSPoint NSPoint;
-#endif
-#endif
-
-#if PLATFORM(WIN)
-typedef struct tagPOINT POINT;
-typedef struct tagPOINTS POINTS;
-#elif PLATFORM(QT)
-QT_BEGIN_NAMESPACE
-class QPoint;
-QT_END_NAMESPACE
-#elif PLATFORM(GTK)
-typedef struct _GdkPoint GdkPoint;
-#endif
-#if PLATFORM(SYMBIAN)
-class TPoint;
-#endif
-
-#if PLATFORM(WX)
-class wxPoint;
-#endif
-
-#if PLATFORM(SKIA)
-struct SkPoint;
-struct SkIPoint;
-#endif
-
-namespace WebCore {
-
-class IntPoint {
-public:
- IntPoint() : m_x(0), m_y(0) { }
- IntPoint(int x, int y) : m_x(x), m_y(y) { }
-
- int x() const { return m_x; }
- int y() const { return m_y; }
-
- void setX(int x) { m_x = x; }
- void setY(int y) { m_y = y; }
-
- void move(int dx, int dy) { m_x += dx; m_y += dy; }
-
- IntPoint expandedTo(const IntPoint& other) const
- {
- return IntPoint(m_x > other.m_x ? m_x : other.m_x,
- m_y > other.m_y ? m_y : other.m_y);
- }
-
- IntPoint shrunkTo(const IntPoint& other) const
- {
- return IntPoint(m_x < other.m_x ? m_x : other.m_x,
- m_y < other.m_y ? m_y : other.m_y);
- }
-
- void clampNegativeToZero()
- {
- *this = expandedTo(IntPoint());
- }
-
-#if PLATFORM(CG)
- explicit IntPoint(const CGPoint&); // don't do this implicitly since it's lossy
- operator CGPoint() const;
-#endif
-
-#if PLATFORM(MAC) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
- explicit IntPoint(const NSPoint&); // don't do this implicitly since it's lossy
- operator NSPoint() const;
-#endif
-
-#if PLATFORM(WIN)
- IntPoint(const POINT&);
- operator POINT() const;
- IntPoint(const POINTS&);
- operator POINTS() const;
-#elif PLATFORM(QT)
- IntPoint(const QPoint&);
- operator QPoint() const;
-#elif PLATFORM(GTK)
- IntPoint(const GdkPoint&);
- operator GdkPoint() const;
-#endif
-#if PLATFORM(SYMBIAN)
- IntPoint(const TPoint&);
- operator TPoint() const;
-#endif
-
-#if PLATFORM(WX)
- IntPoint(const wxPoint&);
- operator wxPoint() const;
-#endif
-
-#if PLATFORM(SKIA)
- IntPoint(const SkIPoint&);
- operator SkIPoint() const;
- operator SkPoint() const;
-#endif
-
-private:
- int m_x, m_y;
-};
-
-inline IntPoint& operator+=(IntPoint& a, const IntSize& b)
-{
- a.move(b.width(), b.height());
- return a;
-}
-
-inline IntPoint& operator-=(IntPoint& a, const IntSize& b)
-{
- a.move(-b.width(), -b.height());
- return a;
-}
-
-inline IntPoint operator+(const IntPoint& a, const IntSize& b)
-{
- return IntPoint(a.x() + b.width(), a.y() + b.height());
-}
-
-inline IntSize operator-(const IntPoint& a, const IntPoint& b)
-{
- return IntSize(a.x() - b.x(), a.y() - b.y());
-}
-
-inline IntPoint operator-(const IntPoint& a, const IntSize& b)
-{
- return IntPoint(a.x() - b.width(), a.y() - b.height());
-}
-
-inline bool operator==(const IntPoint& a, const IntPoint& b)
-{
- return a.x() == b.x() && a.y() == b.y();
-}
-
-inline bool operator!=(const IntPoint& a, const IntPoint& b)
-{
- return a.x() != b.x() || a.y() != b.y();
-}
-
-} // namespace WebCore
-
-#endif // IntPoint_h
diff --git a/WebCore/platform/graphics/IntRect.cpp b/WebCore/platform/graphics/IntRect.cpp
deleted file mode 100644
index 622e525..0000000
--- a/WebCore/platform/graphics/IntRect.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "IntRect.h"
-
-#include "FloatRect.h"
-#include <algorithm>
-
-using std::max;
-using std::min;
-
-namespace WebCore {
-
-IntRect::IntRect(const FloatRect& r)
- : m_location(IntPoint(static_cast<int>(r.x()), static_cast<int>(r.y())))
- , m_size(IntSize(static_cast<int>(r.width()), static_cast<int>(r.height())))
-{
-}
-
-bool IntRect::intersects(const IntRect& other) const
-{
- // Checking emptiness handles negative widths as well as zero.
- return !isEmpty() && !other.isEmpty()
- && x() < other.right() && other.x() < right()
- && y() < other.bottom() && other.y() < bottom();
-}
-
-bool IntRect::contains(const IntRect& other) const
-{
- return x() <= other.x() && right() >= other.right()
- && y() <= other.y() && bottom() >= other.bottom();
-}
-
-void IntRect::intersect(const IntRect& other)
-{
- int l = max(x(), other.x());
- int t = max(y(), other.y());
- int r = min(right(), other.right());
- int b = min(bottom(), other.bottom());
-
- // Return a clean empty rectangle for non-intersecting cases.
- if (l >= r || t >= b) {
- l = 0;
- t = 0;
- r = 0;
- b = 0;
- }
-
- m_location.setX(l);
- m_location.setY(t);
- m_size.setWidth(r - l);
- m_size.setHeight(b - t);
-}
-
-void IntRect::unite(const IntRect& other)
-{
- // Handle empty special cases first.
- if (other.isEmpty())
- return;
- if (isEmpty()) {
- *this = other;
- return;
- }
-
- int l = min(x(), other.x());
- int t = min(y(), other.y());
- int r = max(right(), other.right());
- int b = max(bottom(), other.bottom());
-
- m_location.setX(l);
- m_location.setY(t);
- m_size.setWidth(r - l);
- m_size.setHeight(b - t);
-}
-
-void IntRect::scale(float s)
-{
- m_location.setX((int)(x() * s));
- m_location.setY((int)(y() * s));
- m_size.setWidth((int)(width() * s));
- m_size.setHeight((int)(height() * s));
-}
-
-}
diff --git a/WebCore/platform/graphics/IntRect.h b/WebCore/platform/graphics/IntRect.h
deleted file mode 100644
index 03784a3..0000000
--- a/WebCore/platform/graphics/IntRect.h
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef IntRect_h
-#define IntRect_h
-
-#include "IntPoint.h"
-#include <wtf/Platform.h>
-
-#if PLATFORM(CG)
-typedef struct CGRect CGRect;
-#endif
-
-#if PLATFORM(MAC)
-#ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
-typedef struct CGRect NSRect;
-#else
-typedef struct _NSRect NSRect;
-#endif
-#endif
-
-#if PLATFORM(WIN)
-typedef struct tagRECT RECT;
-#elif PLATFORM(QT)
-QT_BEGIN_NAMESPACE
-class QRect;
-QT_END_NAMESPACE
-#elif PLATFORM(GTK)
-typedef struct _GdkRectangle GdkRectangle;
-#endif
-#if PLATFORM(SYMBIAN)
-class TRect;
-#endif
-
-#if PLATFORM(WX)
-class wxRect;
-#endif
-
-#if PLATFORM(SKIA)
-struct SkRect;
-struct SkIRect;
-#endif
-
-namespace WebCore {
-
-class FloatRect;
-
-class IntRect {
-public:
- IntRect() { }
- IntRect(const IntPoint& location, const IntSize& size)
- : m_location(location), m_size(size) { }
- IntRect(int x, int y, int width, int height)
- : m_location(IntPoint(x, y)), m_size(IntSize(width, height)) { }
-
- explicit IntRect(const FloatRect& rect); // don't do this implicitly since it's lossy
-
- IntPoint location() const { return m_location; }
- IntSize size() const { return m_size; }
-
- void setLocation(const IntPoint& location) { m_location = location; }
- void setSize(const IntSize& size) { m_size = size; }
-
- int x() const { return m_location.x(); }
- int y() const { return m_location.y(); }
- int width() const { return m_size.width(); }
- int height() const { return m_size.height(); }
-
- void setX(int x) { m_location.setX(x); }
- void setY(int y) { m_location.setY(y); }
- void setWidth(int width) { m_size.setWidth(width); }
- void setHeight(int height) { m_size.setHeight(height); }
-
- // Be careful with these functions. The point is considered to be to the right and below. These are not
- // substitutes for right() and bottom().
- IntPoint topLeft() const { return m_location; }
- IntPoint topRight() const { return IntPoint(right() - 1, y()); }
- IntPoint bottomLeft() const { return IntPoint(x(), bottom() - 1); }
- IntPoint bottomRight() const { return IntPoint(right() - 1, bottom() - 1); }
-
- bool isEmpty() const { return m_size.isEmpty(); }
-
- int right() const { return x() + width(); }
- int bottom() const { return y() + height(); }
-
- void move(const IntSize& s) { m_location += s; }
- void move(int dx, int dy) { m_location.move(dx, dy); }
-
- bool intersects(const IntRect&) const;
- bool contains(const IntRect&) const;
-
- // This checks to see if the rect contains x,y in the traditional sense.
- // Equivalent to checking if the rect contains a 1x1 rect below and to the right of (px,py).
- bool contains(int px, int py) const
- { return px >= x() && px < right() && py >= y() && py < bottom(); }
- bool contains(const IntPoint& point) const { return contains(point.x(), point.y()); }
-
- void intersect(const IntRect&);
- void unite(const IntRect&);
-
- void inflateX(int dx)
- {
- m_location.setX(m_location.x() - dx);
- m_size.setWidth(m_size.width() + dx + dx);
- }
- 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 PLATFORM(WX)
- IntRect(const wxRect&);
- operator wxRect() const;
-#endif
-
-#if PLATFORM(WIN)
- IntRect(const RECT&);
- operator RECT() const;
-#elif PLATFORM(QT)
- IntRect(const QRect&);
- operator QRect() const;
-#elif PLATFORM(GTK)
- IntRect(const GdkRectangle&);
- operator GdkRectangle() const;
-#endif
-#if PLATFORM(SYMBIAN)
- IntRect(const TRect&);
- operator TRect() const;
- TRect Rect() const;
-#endif
-
-#if PLATFORM(CG)
- operator CGRect() const;
-#endif
-
-#if PLATFORM(SKIA)
- IntRect(const SkIRect&);
- operator SkRect() const;
- operator SkIRect() const;
-#endif
-
-#if PLATFORM(MAC) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
- operator NSRect() const;
-#endif
-
-private:
- IntPoint m_location;
- IntSize m_size;
-};
-
-inline IntRect intersection(const IntRect& a, const IntRect& b)
-{
- IntRect c = a;
- c.intersect(b);
- return c;
-}
-
-inline IntRect unionRect(const IntRect& a, const IntRect& b)
-{
- IntRect c = a;
- c.unite(b);
- return c;
-}
-
-inline bool operator==(const IntRect& a, const IntRect& b)
-{
- return a.location() == b.location() && a.size() == b.size();
-}
-
-inline bool operator!=(const IntRect& a, const IntRect& b)
-{
- return a.location() != b.location() || a.size() != b.size();
-}
-
-#if PLATFORM(CG)
-IntRect enclosingIntRect(const CGRect&);
-#endif
-
-#if PLATFORM(MAC) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
-IntRect enclosingIntRect(const NSRect&);
-#endif
-
-} // namespace WebCore
-
-#endif // IntRect_h
diff --git a/WebCore/platform/graphics/IntSize.h b/WebCore/platform/graphics/IntSize.h
deleted file mode 100644
index 7245408..0000000
--- a/WebCore/platform/graphics/IntSize.h
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef IntSize_h
-#define IntSize_h
-
-#include <wtf/Platform.h>
-
-#if PLATFORM(CG)
-typedef struct CGSize CGSize;
-#endif
-
-#if PLATFORM(MAC)
-#ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
-typedef struct CGSize NSSize;
-#else
-typedef struct _NSSize NSSize;
-#endif
-#endif
-
-#if PLATFORM(WIN)
-typedef struct tagSIZE SIZE;
-#elif PLATFORM(QT)
-#include <qglobal.h>
-QT_BEGIN_NAMESPACE
-class QSize;
-QT_END_NAMESPACE
-#endif
-#if PLATFORM(SYMBIAN)
-class TSize;
-#endif
-
-namespace WebCore {
-
-class IntSize {
-public:
- IntSize() : m_width(0), m_height(0) { }
- IntSize(int width, int height) : m_width(width), m_height(height) { }
-
- int width() const { return m_width; }
- int height() const { return m_height; }
-
- void setWidth(int width) { m_width = width; }
- void setHeight(int height) { m_height = height; }
-
- bool isEmpty() const { return m_width <= 0 || m_height <= 0; }
-
- IntSize expandedTo(const IntSize& other) const
- {
- return IntSize(m_width > other.m_width ? m_width : other.m_width,
- m_height > other.m_height ? m_height : other.m_height);
- }
-
- IntSize shrunkTo(const IntSize& other) const
- {
- return IntSize(m_width < other.m_width ? m_width : other.m_width,
- m_height < other.m_height ? m_height : other.m_height);
- }
-
- void clampNegativeToZero()
- {
- *this = expandedTo(IntSize());
- }
-
-#if PLATFORM(CG)
- explicit IntSize(const CGSize&); // don't do this implicitly since it's lossy
- operator CGSize() const;
-#endif
-
-#if PLATFORM(MAC) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
- explicit IntSize(const NSSize &); // don't do this implicitly since it's lossy
- operator NSSize() const;
-#endif
-
-#if PLATFORM(WIN)
- IntSize(const SIZE&);
- operator SIZE() const;
-#endif
-
-#if PLATFORM(QT)
- IntSize(const QSize&);
- operator QSize() const;
-#endif
-#if PLATFORM(SYMBIAN)
- IntSize(const TSize&);
- operator TSize() const;
-#endif
-
-
-private:
- int m_width, m_height;
-};
-
-inline IntSize& operator+=(IntSize& a, const IntSize& b)
-{
- a.setWidth(a.width() + b.width());
- a.setHeight(a.height() + b.height());
- return a;
-}
-
-inline IntSize& operator-=(IntSize& a, const IntSize& b)
-{
- a.setWidth(a.width() - b.width());
- a.setHeight(a.height() - b.height());
- return a;
-}
-
-inline IntSize operator+(const IntSize& a, const IntSize& b)
-{
- return IntSize(a.width() + b.width(), a.height() + b.height());
-}
-
-inline IntSize operator-(const IntSize& a, const IntSize& b)
-{
- return IntSize(a.width() - b.width(), a.height() - b.height());
-}
-
-inline IntSize operator-(const IntSize& size)
-{
- return IntSize(-size.width(), -size.height());
-}
-
-inline bool operator==(const IntSize& a, const IntSize& b)
-{
- return a.width() == b.width() && a.height() == b.height();
-}
-
-inline bool operator!=(const IntSize& a, const IntSize& b)
-{
- return a.width() != b.width() || a.height() != b.height();
-}
-
-} // namespace WebCore
-
-#endif // IntSize_h
diff --git a/WebCore/platform/graphics/IntSizeHash.h b/WebCore/platform/graphics/IntSizeHash.h
deleted file mode 100644
index ad6eac3..0000000
--- a/WebCore/platform/graphics/IntSizeHash.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-#ifndef IntSizeHash_h
-#define IntSizeHash_h
-
-#include "IntSize.h"
-#include <wtf/HashMap.h>
-#include <wtf/HashSet.h>
-
-using WebCore::IntSize;
-
-namespace WTF {
-
- template<> struct IntHash<IntSize> {
- static unsigned hash(const IntSize& key) { return intHash((static_cast<uint64_t>(key.width()) << 32 | key.height())); }
- static bool equal(const IntSize& a, const IntSize& b) { return a == b; }
- static const bool safeToCompareToEmptyOrDeleted = true;
- };
- template<> struct DefaultHash<IntSize> { typedef IntHash<IntSize> Hash; };
-
- template<> struct HashTraits<IntSize> : GenericHashTraits<IntSize> {
- static const bool emptyValueIsZero = true;
- static const bool needsDestruction = false;
- static void constructDeletedValue(IntSize& slot) { new (&slot) IntSize(-1, -1); }
- static bool isDeletedValue(const IntSize& value) { return value.width() == -1 && value.height() == -1; }
- };
-} // namespace WTF
-
-#endif
diff --git a/WebCore/platform/graphics/MediaPlayer.cpp b/WebCore/platform/graphics/MediaPlayer.cpp
deleted file mode 100644
index 21e31fc..0000000
--- a/WebCore/platform/graphics/MediaPlayer.cpp
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if ENABLE(VIDEO)
-#include "MediaPlayer.h"
-
-#include "IntRect.h"
-#include "MIMETypeRegistry.h"
-#include "FrameView.h"
-#include "Frame.h"
-#include "Document.h"
-
-#if PLATFORM(MAC)
-#include "MediaPlayerPrivateQTKit.h"
-#elif PLATFORM(WIN)
-#include "MediaPlayerPrivateQuickTimeWin.h"
-#elif PLATFORM(GTK)
-#include "MediaPlayerPrivateGStreamer.h"
-#elif PLATFORM(QT)
-#include "MediaPlayerPrivatePhonon.h"
-#elif PLATFORM(CHROMIUM)
-#include "MediaPlayerPrivateChromium.h"
-#endif
-
-namespace WebCore {
-
- MediaPlayer::MediaPlayer(MediaPlayerClient* client)
- : m_mediaPlayerClient(client)
- , m_private(new MediaPlayerPrivate(this))
- , m_frameView(0)
- , m_visible(false)
- , m_rate(1.0f)
- , m_volume(1.0f)
-{
-}
-
-MediaPlayer::~MediaPlayer()
-{
- delete m_private;
-}
-
-void MediaPlayer::load(const String& url)
-{
- m_private->load(url);
-}
-
-void MediaPlayer::cancelLoad()
-{
- m_private->cancelLoad();
-}
-
-void MediaPlayer::play()
-{
- m_private->play();
-}
-
-void MediaPlayer::pause()
-{
- m_private->pause();
-}
-
-float MediaPlayer::duration() const
-{
- return m_private->duration();
-}
-
-float MediaPlayer::currentTime() const
-{
- return m_private->currentTime();
-}
-
-void MediaPlayer::seek(float time)
-{
- m_private->seek(time);
-}
-
-bool MediaPlayer::paused() const
-{
- return m_private->paused();
-}
-
-bool MediaPlayer::seeking() const
-{
- return m_private->seeking();
-}
-
-IntSize MediaPlayer::naturalSize()
-{
- return m_private->naturalSize();
-}
-
-bool MediaPlayer::hasVideo()
-{
- return m_private->hasVideo();
-}
-
-bool MediaPlayer::inMediaDocument()
-{
- Frame* frame = m_frameView ? m_frameView->frame() : 0;
- Document* document = frame ? frame->document() : 0;
-
- return document && document->isMediaDocument();
-}
-
-MediaPlayer::NetworkState MediaPlayer::networkState()
-{
- return m_private->networkState();
-}
-
-MediaPlayer::ReadyState MediaPlayer::readyState()
-{
- return m_private->readyState();
-}
-
-float MediaPlayer::volume() const
-{
- return m_volume;
-}
-
-void MediaPlayer::setVolume(float volume)
-{
- m_volume = volume;
- m_private->setVolume(volume);
-}
-
-float MediaPlayer::rate() const
-{
- return m_rate;
-}
-
-void MediaPlayer::setRate(float rate)
-{
- m_rate = rate;
- m_private->setRate(rate);
-}
-
-int MediaPlayer::dataRate() const
-{
- return m_private->dataRate();
-}
-
-void MediaPlayer::setEndTime(float time)
-{
- m_private->setEndTime(time);
-}
-
-float MediaPlayer::maxTimeBuffered()
-{
- return m_private->maxTimeBuffered();
-}
-
-float MediaPlayer::maxTimeSeekable()
-{
- return m_private->maxTimeSeekable();
-}
-
-unsigned MediaPlayer::bytesLoaded()
-{
- return m_private->bytesLoaded();
-}
-
-bool MediaPlayer::totalBytesKnown()
-{
- return m_private->totalBytesKnown();
-}
-
-unsigned MediaPlayer::totalBytes()
-{
- return m_private->totalBytes();
-}
-
-void MediaPlayer::setRect(const IntRect& r)
-{
- m_rect = r;
- m_private->setRect(r);
-}
-
-bool MediaPlayer::visible() const
-{
- return m_visible;
-}
-
-void MediaPlayer::setVisible(bool b)
-{
- m_visible = b;
- m_private->setVisible(b);
-}
-
-void MediaPlayer::paint(GraphicsContext* p, const IntRect& r)
-{
- m_private->paint(p, r);
-}
-
-bool MediaPlayer::supportsType(const String& type)
-{
- HashSet<String> types;
- getSupportedTypes(types);
- return MIMETypeRegistry::isSupportedMediaMIMEType(type) && types.contains(type);
-}
-
-void MediaPlayer::getSupportedTypes(HashSet<String>& types)
-{
- MediaPlayerPrivate::getSupportedTypes(types);
-}
-
-bool MediaPlayer::isAvailable()
-{
- static bool availabityKnown = false;
- static bool isAvailable;
- if (!availabityKnown) {
- isAvailable = MediaPlayerPrivate::isAvailable();
- availabityKnown = true;
- }
- return isAvailable;
-}
-
-void MediaPlayer::networkStateChanged()
-{
- if (m_mediaPlayerClient)
- m_mediaPlayerClient->mediaPlayerNetworkStateChanged(this);
-}
-
-void MediaPlayer::readyStateChanged()
-{
- if (m_mediaPlayerClient)
- m_mediaPlayerClient->mediaPlayerReadyStateChanged(this);
-}
-
-void MediaPlayer::volumeChanged()
-{
- if (m_mediaPlayerClient)
- m_mediaPlayerClient->mediaPlayerVolumeChanged(this);
-}
-
-void MediaPlayer::timeChanged()
-{
- if (m_mediaPlayerClient)
- m_mediaPlayerClient->mediaPlayerTimeChanged(this);
-}
-
-void MediaPlayer::repaint()
-{
- if (m_mediaPlayerClient)
- m_mediaPlayerClient->mediaPlayerRepaint(this);
-}
-
-}
-#endif
diff --git a/WebCore/platform/graphics/MediaPlayer.h b/WebCore/platform/graphics/MediaPlayer.h
deleted file mode 100644
index 1beab95..0000000
--- a/WebCore/platform/graphics/MediaPlayer.h
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef MediaPlayer_h
-#define MediaPlayer_h
-
-#if ENABLE(VIDEO)
-
-#include "IntRect.h"
-#include "StringHash.h"
-#include <wtf/HashSet.h>
-#include <wtf/Noncopyable.h>
-
-namespace WebCore {
-
-class FrameView;
-class GraphicsContext;
-class IntSize;
-class MediaPlayer;
-class MediaPlayerPrivate;
-class String;
-
-class MediaPlayerClient {
-public:
- virtual ~MediaPlayerClient() { }
- virtual void mediaPlayerNetworkStateChanged(MediaPlayer*) { }
- virtual void mediaPlayerReadyStateChanged(MediaPlayer*) { }
- virtual void mediaPlayerVolumeChanged(MediaPlayer*) { }
- virtual void mediaPlayerTimeChanged(MediaPlayer*) { }
- virtual void mediaPlayerRepaint(MediaPlayer*) { }
-};
-
-class MediaPlayer : Noncopyable {
-public:
- MediaPlayer(MediaPlayerClient*);
- virtual ~MediaPlayer();
-
- static bool isAvailable();
- static bool supportsType(const String&);
- static void getSupportedTypes(HashSet<String>&);
-
- IntSize naturalSize();
- bool hasVideo();
-
- void setFrameView(FrameView* frameView) { m_frameView = frameView; }
- bool inMediaDocument();
-
- IntRect rect() const { return m_rect; }
- void setRect(const IntRect& r);
-
- void load(const String& url);
- void cancelLoad();
-
- bool visible() const;
- void setVisible(bool);
-
- void play();
- void pause();
-
- bool paused() const;
- bool seeking() const;
-
- float duration() const;
- float currentTime() const;
- void seek(float time);
-
- void setEndTime(float time);
-
- float rate() const;
- void setRate(float);
-
- float maxTimeBuffered();
- float maxTimeSeekable();
-
- unsigned bytesLoaded();
- bool totalBytesKnown();
- unsigned totalBytes();
-
- float volume() const;
- void setVolume(float);
-
- int dataRate() const;
-
- void paint(GraphicsContext*, const IntRect&);
-
- enum NetworkState { Empty, LoadFailed, Loading, LoadedMetaData, LoadedFirstFrame, Loaded };
- NetworkState networkState();
-
- enum ReadyState { DataUnavailable, CanShowCurrentFrame, CanPlay, CanPlayThrough };
- ReadyState readyState();
-
- void networkStateChanged();
- void readyStateChanged();
- void volumeChanged();
- void timeChanged();
-
- void repaint();
-
-private:
-
- friend class MediaPlayerPrivate;
-
- MediaPlayerClient* m_mediaPlayerClient;
- MediaPlayerPrivate* m_private;
- FrameView* m_frameView;
- IntRect m_rect;
- bool m_visible;
- float m_rate;
- float m_volume;
-};
-
-}
-
-#endif
-#endif
diff --git a/WebCore/platform/graphics/Path.cpp b/WebCore/platform/graphics/Path.cpp
deleted file mode 100644
index f3450be..0000000
--- a/WebCore/platform/graphics/Path.cpp
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
- * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
- * 2006 Rob Buis <buis@kde.org>
- * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-
-#include "config.h"
-#include "Path.h"
-
-#include "FloatPoint.h"
-#include "FloatRect.h"
-#include "PathTraversalState.h"
-#include <math.h>
-#include <wtf/MathExtras.h>
-
-const float QUARTER = 0.552f; // approximation of control point positions on a bezier
- // to simulate a quarter of a circle.
-namespace WebCore {
-
-static void pathLengthApplierFunction(void* info, const PathElement* element)
-{
- PathTraversalState& traversalState = *static_cast<PathTraversalState*>(info);
- if (traversalState.m_success)
- return;
- traversalState.m_previous = traversalState.m_current;
- FloatPoint* points = element->points;
- float segmentLength = 0.0f;
- switch (element->type) {
- case PathElementMoveToPoint:
- segmentLength = traversalState.moveTo(points[0]);
- break;
- case PathElementAddLineToPoint:
- segmentLength = traversalState.lineTo(points[0]);
- break;
- case PathElementAddQuadCurveToPoint:
- segmentLength = traversalState.quadraticBezierTo(points[0], points[1]);
- break;
- case PathElementAddCurveToPoint:
- segmentLength = traversalState.cubicBezierTo(points[0], points[1], points[2]);
- break;
- case PathElementCloseSubpath:
- segmentLength = traversalState.closeSubpath();
- break;
- }
- traversalState.m_totalLength += segmentLength;
- if ((traversalState.m_action == PathTraversalState::TraversalPointAtLength ||
- traversalState.m_action == PathTraversalState::TraversalNormalAngleAtLength) &&
- (traversalState.m_totalLength >= traversalState.m_desiredLength)) {
- FloatSize change = traversalState.m_current - traversalState.m_previous;
- float slope = atan2f(change.height(), change.width());
-
- if (traversalState.m_action == PathTraversalState::TraversalPointAtLength) {
- float offset = traversalState.m_desiredLength - traversalState.m_totalLength;
- traversalState.m_current.move(offset * cosf(slope), offset * sinf(slope));
- } else {
- static const float rad2deg = 180.0f / piFloat;
- traversalState.m_normalAngle = slope * rad2deg;
- }
-
- traversalState.m_success = true;
- }
-}
-
-float Path::length()
-{
- PathTraversalState traversalState(PathTraversalState::TraversalTotalLength);
- apply(&traversalState, pathLengthApplierFunction);
- return traversalState.m_totalLength;
-}
-
-FloatPoint Path::pointAtLength(float length, bool& ok)
-{
- PathTraversalState traversalState(PathTraversalState::TraversalPointAtLength);
- traversalState.m_desiredLength = length;
- apply(&traversalState, pathLengthApplierFunction);
- ok = traversalState.m_success;
- return traversalState.m_current;
-}
-
-float Path::normalAngleAtLength(float length, bool& ok)
-{
- PathTraversalState traversalState(PathTraversalState::TraversalNormalAngleAtLength);
- traversalState.m_desiredLength = length;
- apply(&traversalState, pathLengthApplierFunction);
- ok = traversalState.m_success;
- return traversalState.m_normalAngle;
-}
-
-Path Path::createRoundedRectangle(const FloatRect& rectangle, const FloatSize& roundingRadii)
-{
- Path path;
- float x = rectangle.x();
- float y = rectangle.y();
- float width = rectangle.width();
- float height = rectangle.height();
- float rx = roundingRadii.width();
- float ry = roundingRadii.height();
- if (width <= 0.0f || height <= 0.0f)
- return path;
-
- float dx = rx, dy = ry;
- // If rx is greater than half of the width of the rectangle
- // then set rx to half of the width (required in SVG spec)
- if (dx > width * 0.5f)
- dx = width * 0.5f;
-
- // If ry is greater than half of the height of the rectangle
- // then set ry to half of the height (required in SVG spec)
- if (dy > height * 0.5f)
- dy = height * 0.5f;
-
- path.moveTo(FloatPoint(x + dx, y));
-
- if (dx < width * 0.5f)
- path.addLineTo(FloatPoint(x + width - rx, y));
-
- path.addBezierCurveTo(FloatPoint(x + width - dx * (1 - QUARTER), y), FloatPoint(x + width, y + dy * (1 - QUARTER)), FloatPoint(x + width, y + dy));
-
- if (dy < height * 0.5)
- path.addLineTo(FloatPoint(x + width, y + height - dy));
-
- path.addBezierCurveTo(FloatPoint(x + width, y + height - dy * (1 - QUARTER)), FloatPoint(x + width - dx * (1 - QUARTER), y + height), FloatPoint(x + width - dx, y + height));
-
- if (dx < width * 0.5)
- path.addLineTo(FloatPoint(x + dx, y + height));
-
- path.addBezierCurveTo(FloatPoint(x + dx * (1 - QUARTER), y + height), FloatPoint(x, y + height - dy * (1 - QUARTER)), FloatPoint(x, y + height - dy));
-
- if (dy < height * 0.5)
- path.addLineTo(FloatPoint(x, y + dy));
-
- path.addBezierCurveTo(FloatPoint(x, y + dy * (1 - QUARTER)), FloatPoint(x + dx * (1 - QUARTER), y), FloatPoint(x + dx, y));
-
- path.closeSubpath();
-
- return path;
-}
-
-Path Path::createRoundedRectangle(const FloatRect& rectangle, const FloatSize& topLeftRadius, const FloatSize& topRightRadius, const FloatSize& bottomLeftRadius, const FloatSize& bottomRightRadius)
-{
- Path path;
-
- float width = rectangle.width();
- float height = rectangle.height();
- if (width <= 0.0 || height <= 0.0)
- return path;
-
- if (width < topLeftRadius.width() + topRightRadius.width()
- || width < bottomLeftRadius.width() + bottomRightRadius.width()
- || height < topLeftRadius.height() + bottomLeftRadius.height()
- || height < topRightRadius.height() + bottomRightRadius.height())
- // If all the radii cannot be accommodated, return a rect.
- return createRectangle(rectangle);
-
- float x = rectangle.x();
- float y = rectangle.y();
-
- path.moveTo(FloatPoint(x + topLeftRadius.width(), y));
-
- path.addLineTo(FloatPoint(x + width - topRightRadius.width(), y));
-
- path.addBezierCurveTo(FloatPoint(x + width - topRightRadius.width() * (1 - QUARTER), y), FloatPoint(x + width, y + topRightRadius.height() * (1 - QUARTER)), FloatPoint(x + width, y + topRightRadius.height()));
-
- path.addLineTo(FloatPoint(x + width, y + height - bottomRightRadius.height()));
-
- path.addBezierCurveTo(FloatPoint(x + width, y + height - bottomRightRadius.height() * (1 - QUARTER)), FloatPoint(x + width - bottomRightRadius.width() * (1 - QUARTER), y + height), FloatPoint(x + width - bottomRightRadius.width(), y + height));
-
- path.addLineTo(FloatPoint(x + bottomLeftRadius.width(), y + height));
-
- path.addBezierCurveTo(FloatPoint(x + bottomLeftRadius.width() * (1 - QUARTER), y + height), FloatPoint(x, y + height - bottomLeftRadius.height() * (1 - QUARTER)), FloatPoint(x, y + height - bottomLeftRadius.height()));
-
- path.addLineTo(FloatPoint(x, y + topLeftRadius.height()));
-
- path.addBezierCurveTo(FloatPoint(x, y + topLeftRadius.height() * (1 - QUARTER)), FloatPoint(x + topLeftRadius.width() * (1 - QUARTER), y), FloatPoint(x + topLeftRadius.width(), y));
-
- path.closeSubpath();
-
- return path;
-}
-
-Path Path::createRectangle(const FloatRect& rectangle)
-{
- Path path;
- float x = rectangle.x();
- float y = rectangle.y();
- float width = rectangle.width();
- float height = rectangle.height();
- if (width <= 0.0f || height <= 0.0f)
- return path;
-
- path.moveTo(FloatPoint(x, y));
- path.addLineTo(FloatPoint(x + width, y));
- path.addLineTo(FloatPoint(x + width, y + height));
- path.addLineTo(FloatPoint(x, y + height));
- path.closeSubpath();
-
- return path;
-}
-
-Path Path::createEllipse(const FloatPoint& center, float rx, float ry)
-{
- float cx = center.x();
- float cy = center.y();
- Path path;
- if (rx <= 0.0f || ry <= 0.0f)
- return path;
-
- float x = cx;
- float y = cy;
-
- unsigned step = 0, num = 100;
- bool running = true;
- while (running)
- {
- if (step == num)
- {
- running = false;
- break;
- }
-
- float angle = static_cast<float>(step) / static_cast<float>(num) * 2.0f * piFloat;
- x = cx + cosf(angle) * rx;
- y = cy + sinf(angle) * ry;
-
- step++;
- if (step == 1)
- path.moveTo(FloatPoint(x, y));
- else
- path.addLineTo(FloatPoint(x, y));
- }
-
- path.closeSubpath();
-
- return path;
-}
-
-Path Path::createCircle(const FloatPoint& center, float r)
-{
- return createEllipse(center, r, r);
-}
-
-Path Path::createLine(const FloatPoint& start, const FloatPoint& end)
-{
- Path path;
- if (start.x() == end.x() && start.y() == end.y())
- return path;
-
- path.moveTo(start);
- path.addLineTo(end);
-
- return path;
-}
-
-}
diff --git a/WebCore/platform/graphics/Path.h b/WebCore/platform/graphics/Path.h
deleted file mode 100644
index 06e6ee4..0000000
--- a/WebCore/platform/graphics/Path.h
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
- * 2006 Rob Buis <buis@kde.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef Path_h
-#define Path_h
-
-#if PLATFORM(CG)
-typedef struct CGPath PlatformPath;
-#elif PLATFORM(QT)
-#include <qglobal.h>
-QT_BEGIN_NAMESPACE
-class QPainterPath;
-QT_END_NAMESPACE
-typedef QPainterPath PlatformPath;
-#elif PLATFORM(SGL)
-class SkPath;
-typedef SkPath PlatformPath;
-#elif PLATFORM(WX) && USE(WXGC)
-class wxGraphicsPath;
-typedef wxGraphicsPath PlatformPath;
-#elif PLATFORM(CAIRO)
-namespace WebCore {
- struct CairoPath;
-}
-typedef WebCore::CairoPath PlatformPath;
-#elif PLATFORM(SKIA)
-class SkPath;
-typedef SkPath PlatformPath;
-#else
-typedef void PlatformPath;
-#endif
-
-namespace WebCore {
-
- class AffineTransform;
- class FloatPoint;
- class FloatSize;
- class FloatRect;
- class String;
-
- enum WindRule {
- RULE_NONZERO = 0,
- RULE_EVENODD = 1
- };
-
- enum PathElementType {
- PathElementMoveToPoint,
- PathElementAddLineToPoint,
- PathElementAddQuadCurveToPoint,
- PathElementAddCurveToPoint,
- PathElementCloseSubpath
- };
-
- struct PathElement {
- PathElementType type;
- FloatPoint* points;
- };
-
- typedef void (*PathApplierFunction) (void* info, const PathElement*);
-
- class Path {
- public:
- Path();
- ~Path();
-
- Path(const Path&);
- Path& operator=(const Path&);
-
- bool contains(const FloatPoint&, WindRule rule = RULE_NONZERO) const;
- FloatRect boundingRect() const;
-
- float length();
- FloatPoint pointAtLength(float length, bool& ok);
- float normalAngleAtLength(float length, bool& ok);
-
- void clear();
- bool isEmpty() const;
-
- void moveTo(const FloatPoint&);
- void addLineTo(const FloatPoint&);
- void addQuadCurveTo(const FloatPoint& controlPoint, const FloatPoint& endPoint);
- void addBezierCurveTo(const FloatPoint& controlPoint1, const FloatPoint& controlPoint2, const FloatPoint& endPoint);
- void addArcTo(const FloatPoint&, const FloatPoint&, float radius);
- void closeSubpath();
-
- void addArc(const FloatPoint&, float radius, float startAngle, float endAngle, bool anticlockwise);
- void addRect(const FloatRect&);
- void addEllipse(const FloatRect&);
-
- void translate(const FloatSize&);
-
- String debugString() const;
-
- PlatformPath* platformPath() const { return m_path; }
-
- static Path createRoundedRectangle(const FloatRect&, const FloatSize& roundingRadii);
- static Path createRoundedRectangle(const FloatRect&, const FloatSize& topLeftRadius, const FloatSize& topRightRadius, const FloatSize& bottomLeftRadius, const FloatSize& bottomRightRadius);
- static Path createRectangle(const FloatRect&);
- static Path createEllipse(const FloatPoint& center, float rx, float ry);
- static Path createCircle(const FloatPoint& center, float r);
- static Path createLine(const FloatPoint&, const FloatPoint&);
-
- void apply(void* info, PathApplierFunction) const;
- void transform(const AffineTransform&);
-
- private:
- PlatformPath* m_path;
- };
-
-}
-
-#endif
diff --git a/WebCore/platform/graphics/PathTraversalState.cpp b/WebCore/platform/graphics/PathTraversalState.cpp
deleted file mode 100644
index d202649..0000000
--- a/WebCore/platform/graphics/PathTraversalState.cpp
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * This file is part of the WebKit open source project.
- *
- * Copyright (C) 2006, 2007 Eric Seidel (eric@webkit.org)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-#include "PathTraversalState.h"
-
-#include "Path.h"
-
-#include <math.h>
-
-namespace WebCore {
-
-static const float kPathSegmentLengthTolerance = 0.00001f;
-
-static inline FloatPoint midPoint(const FloatPoint& first, const FloatPoint& second)
-{
- return FloatPoint((first.x() + second.x()) / 2.0f, (first.y() + second.y()) / 2.0f);
-}
-
-static inline float distanceLine(const FloatPoint& start, const FloatPoint& end)
-{
- return sqrtf((end.x() - start.x()) * (end.x() - start.x()) + (end.y() - start.y()) * (end.y() - start.y()));
-}
-
-struct QuadraticBezier {
- QuadraticBezier() { }
- QuadraticBezier(const FloatPoint& s, const FloatPoint& c, const FloatPoint& e)
- : start(s)
- , control(c)
- , end(e)
- {
- }
-
- float approximateDistance() const
- {
- return distanceLine(start, control) + distanceLine(control, end);
- }
-
- void split(QuadraticBezier& left, QuadraticBezier& right) const
- {
- left.control = midPoint(start, control);
- right.control = midPoint(control, end);
-
- FloatPoint leftControlToRightControl = midPoint(left.control, right.control);
- left.end = leftControlToRightControl;
- right.start = leftControlToRightControl;
-
- left.start = start;
- right.end = end;
- }
-
- FloatPoint start;
- FloatPoint control;
- FloatPoint end;
-};
-
-struct CubicBezier {
- CubicBezier() { }
- CubicBezier(const FloatPoint& s, const FloatPoint& c1, const FloatPoint& c2, const FloatPoint& e)
- : start(s)
- , control1(c1)
- , control2(c2)
- , end(e)
- {
- }
-
- float approximateDistance() const
- {
- return distanceLine(start, control1) + distanceLine(control1, control2) + distanceLine(control2, end);
- }
-
- void split(CubicBezier& left, CubicBezier& right) const
- {
- FloatPoint startToControl1 = midPoint(control1, control2);
-
- left.start = start;
- left.control1 = midPoint(start, control1);
- left.control2 = midPoint(left.control1, startToControl1);
-
- right.control2 = midPoint(control2, end);
- right.control1 = midPoint(right.control2, startToControl1);
- right.end = end;
-
- FloatPoint leftControl2ToRightControl1 = midPoint(left.control2, right.control1);
- left.end = leftControl2ToRightControl1;
- right.start = leftControl2ToRightControl1;
- }
-
- FloatPoint start;
- FloatPoint control1;
- FloatPoint control2;
- FloatPoint end;
-};
-
-// FIXME: This function is possibly very slow due to the ifs required for proper path measuring
-// A simple speed-up would be to use an additional boolean template parameter to control whether
-// to use the "fast" version of this function with no PathTraversalState updating, vs. the slow
-// version which does update the PathTraversalState. We'll have to shark it to see if that's necessary.
-// Another check which is possible up-front (to send us down the fast path) would be to check if
-// approximateDistance() + current total distance > desired distance
-template<class CurveType>
-static float curveLength(PathTraversalState& traversalState, CurveType curve)
-{
- Vector<CurveType> curveStack;
- curveStack.append(curve);
-
- float totalLength = 0.0f;
- do {
- float length = curve.approximateDistance();
- if ((length - distanceLine(curve.start, curve.end)) > kPathSegmentLengthTolerance) {
- CurveType left, right;
- curve.split(left, right);
- curve = left;
- curveStack.append(right);
- } else {
- totalLength += length;
- if (traversalState.m_action == PathTraversalState::TraversalPointAtLength
- || traversalState.m_action == PathTraversalState::TraversalNormalAngleAtLength) {
- traversalState.m_previous = curve.start;
- traversalState.m_current = curve.end;
- if (traversalState.m_totalLength + totalLength > traversalState.m_desiredLength)
- return totalLength;
- }
- curve = curveStack.last();
- curveStack.removeLast();
- }
- } while (!curveStack.isEmpty());
-
- return totalLength;
-}
-
-PathTraversalState::PathTraversalState(PathTraversalAction action)
- : m_action(action)
- , m_success(false)
- , m_totalLength(0.0f)
- , m_segmentIndex(0)
- , m_desiredLength(0.0f)
- , m_normalAngle(0.0f)
-{
-}
-
-float PathTraversalState::closeSubpath()
-{
- float distance = distanceLine(m_current, m_start);
- m_start = m_control1 = m_control2 = m_current;
- return distance;
-}
-
-float PathTraversalState::moveTo(const FloatPoint& point)
-{
- m_current = m_start = m_control1 = m_control2 = point;
- return 0.0f;
-}
-
-float PathTraversalState::lineTo(const FloatPoint& point)
-{
- float distance = distanceLine(m_current, point);
- m_current = m_control1 = m_control2 = point;
- return distance;
-}
-
-float PathTraversalState::quadraticBezierTo(const FloatPoint& newControl, const FloatPoint& newEnd)
-{
- float distance = curveLength<QuadraticBezier>(*this, QuadraticBezier(m_current, newControl, newEnd));
-
- m_control1 = newControl;
- m_control2 = newEnd;
-
- if (m_action != TraversalPointAtLength && m_action != TraversalNormalAngleAtLength)
- m_current = newEnd;
-
- return distance;
-}
-
-float PathTraversalState::cubicBezierTo(const FloatPoint& newControl1, const FloatPoint& newControl2, const FloatPoint& newEnd)
-{
- float distance = curveLength<CubicBezier>(*this, CubicBezier(m_current, newControl1, newControl2, newEnd));
-
- m_control1 = newEnd;
- m_control2 = newControl2;
-
- if (m_action != TraversalPointAtLength && m_action != TraversalNormalAngleAtLength)
- m_current = newEnd;
-
- return distance;
-}
-
-}
-
diff --git a/WebCore/platform/graphics/PathTraversalState.h b/WebCore/platform/graphics/PathTraversalState.h
deleted file mode 100644
index 5b75767..0000000
--- a/WebCore/platform/graphics/PathTraversalState.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Eric Seidel <eric@webkit.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef PathTraversalState_h
-#define PathTraversalState_h
-
-#include "FloatPoint.h"
-#include <wtf/Vector.h>
-
-namespace WebCore {
-
- class Path;
-
- class PathTraversalState {
- public:
- enum PathTraversalAction {
- TraversalTotalLength,
- TraversalPointAtLength,
- TraversalSegmentAtLength,
- TraversalNormalAngleAtLength
- };
-
- PathTraversalState(PathTraversalAction);
-
- float closeSubpath();
- float moveTo(const FloatPoint&);
- float lineTo(const FloatPoint&);
- float quadraticBezierTo(const FloatPoint& newControl, const FloatPoint& newEnd);
- float cubicBezierTo(const FloatPoint& newControl1, const FloatPoint& newControl2, const FloatPoint& newEnd);
-
- public:
- PathTraversalAction m_action;
- bool m_success;
-
- FloatPoint m_current;
- FloatPoint m_start;
- FloatPoint m_control1;
- FloatPoint m_control2;
-
- float m_totalLength;
- unsigned m_segmentIndex;
- float m_desiredLength;
-
- // For normal calculations
- FloatPoint m_previous;
- float m_normalAngle; // degrees
- };
-}
-
-#endif
diff --git a/WebCore/platform/graphics/Pattern.cpp b/WebCore/platform/graphics/Pattern.cpp
deleted file mode 100644
index d388bd7..0000000
--- a/WebCore/platform/graphics/Pattern.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Pattern.h"
-
-#include "Image.h"
-
-namespace WebCore {
-
-Pattern::Pattern(Image* image, bool repeatX, bool repeatY)
- : m_tileImage(image)
- , m_repeatX(repeatX)
- , m_repeatY(repeatY)
-{
- ASSERT(image);
-}
-
-Pattern::~Pattern()
-{
-}
-
-}
diff --git a/WebCore/platform/graphics/Pattern.h b/WebCore/platform/graphics/Pattern.h
deleted file mode 100644
index 985c7c0..0000000
--- a/WebCore/platform/graphics/Pattern.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef Pattern_h
-#define Pattern_h
-
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-
-#if PLATFORM(CG)
-typedef struct CGPattern* CGPatternRef;
-typedef CGPatternRef PlatformPatternPtr;
-#elif PLATFORM(CAIRO)
-#include <cairo.h>
-typedef cairo_pattern_t* PlatformPatternPtr;
-#elif PLATFORM(SKIA) || PLATFORM(SGL)
-class SkShader;
-typedef SkShader* PlatformPatternPtr;
-#elif PLATFORM(QT)
-#include <QBrush>
-typedef QBrush PlatformPatternPtr;
-#elif PLATFORM(WX)
-#if USE(WXGC)
-class wxGraphicsBrush;
-typedef wxGraphicsBrush* PlatformPatternPtr;
-#else
-class wxBrush;
-typedef wxBrush* PlatformPatternPtr;
-#endif // USE(WXGC)
-#endif
-
-namespace WebCore {
- class AffineTransform;
- class Image;
-
- class Pattern : public RefCounted<Pattern> {
- public:
- static PassRefPtr<Pattern> create(Image* tileImage, bool repeatX, bool repeatY)
- {
- return adoptRef(new Pattern(tileImage, repeatX, repeatY));
- }
- virtual ~Pattern();
-
- Image* tileImage() const { return m_tileImage.get(); }
-
- PlatformPatternPtr createPlatformPattern(const AffineTransform& patternTransform) const;
-
- private:
- Pattern(Image*, bool repeatX, bool repeatY);
-
- RefPtr<Image> m_tileImage;
- bool m_repeatX;
- bool m_repeatY;
- };
-
-} //namespace
-
-#endif
diff --git a/WebCore/platform/graphics/Pen.cpp b/WebCore/platform/graphics/Pen.cpp
deleted file mode 100644
index a3dcb86..0000000
--- a/WebCore/platform/graphics/Pen.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2003 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Pen.h"
-
-namespace WebCore {
-
-Pen::Pen(const Color &color, unsigned width, PenStyle style) : m_style(style), m_width(width), m_color(color)
-{
-}
-
-const Color &Pen::color() const
-{
- return m_color;
-}
-
-unsigned Pen::width() const
-{
- return m_width;
-}
-
-Pen::PenStyle Pen::style() const
-{
- return m_style;
-}
-
-void Pen::setColor(const Color &color)
-{
- m_color = color;
-}
-
-void Pen::setWidth(unsigned width)
-{
- m_width = width;
-}
-
-void Pen::setStyle(PenStyle style)
-{
- m_style = style;
-}
-
-bool Pen::operator==(const Pen &compareTo) const
-{
- return (m_width == compareTo.m_width) &&
- (m_style == compareTo.m_style) &&
- (m_color == compareTo.m_color);
-}
-
-bool Pen::operator!=(const Pen &compareTo) const
-{
- return !(*this == compareTo);
-}
-
-}
diff --git a/WebCore/platform/graphics/Pen.h b/WebCore/platform/graphics/Pen.h
deleted file mode 100644
index cb45a2e..0000000
--- a/WebCore/platform/graphics/Pen.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2003-6 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef Pen_h
-#define Pen_h
-
-#include "Color.h"
-
-#if PLATFORM(WX)
-class wxPen;
-#endif
-
-namespace WebCore {
-
-class Pen {
-public:
- enum PenStyle {
- NoPen,
- SolidLine,
- DotLine,
- DashLine
- };
-
- Pen(const Color &c = Color::black, unsigned w = 0, PenStyle ps = SolidLine);
-
- const Color &color() const;
- unsigned width() const;
- PenStyle style() const;
-
- void setColor(const Color &);
- void setWidth(unsigned);
- void setStyle(PenStyle);
-
- bool operator==(const Pen &) const;
- bool operator!=(const Pen &) const;
-
-#if PLATFORM(WX)
- Pen(const wxPen&);
- operator wxPen() const;
-#endif
-
-private:
- PenStyle m_style;
- unsigned m_width;
- Color m_color;
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/graphics/SegmentedFontData.cpp b/WebCore/platform/graphics/SegmentedFontData.cpp
deleted file mode 100644
index ceefe4f..0000000
--- a/WebCore/platform/graphics/SegmentedFontData.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "SegmentedFontData.h"
-
-#include "SimpleFontData.h"
-#include <wtf/Assertions.h>
-
-namespace WebCore {
-
-SegmentedFontData::~SegmentedFontData()
-{
-}
-
-const SimpleFontData* SegmentedFontData::fontDataForCharacter(UChar32 c) const
-{
- Vector<FontDataRange>::const_iterator end = m_ranges.end();
- for (Vector<FontDataRange>::const_iterator it = m_ranges.begin(); it != end; ++it) {
- if (it->from() <= c && it->to() >= c)
- return it->fontData();
- }
- return m_ranges[0].fontData();
-}
-
-bool SegmentedFontData::containsCharacters(const UChar* characters, int length) const
-{
- Vector<FontDataRange>::const_iterator end = m_ranges.end();
- for (Vector<FontDataRange>::const_iterator it = m_ranges.begin(); it != end; ++it) {
- if (it->from() <= characters[0] && it->to() >= characters[0])
- return true;
- }
- return false;
-}
-
-bool SegmentedFontData::isCustomFont() const
-{
- // All segmented fonts are custom fonts.
- return true;
-}
-
-bool SegmentedFontData::isLoading() const
-{
- Vector<FontDataRange>::const_iterator end = m_ranges.end();
- for (Vector<FontDataRange>::const_iterator it = m_ranges.begin(); it != end; ++it) {
- if (it->fontData()->isLoading())
- return true;
- }
- return false;
-}
-
-bool SegmentedFontData::isSegmented() const
-{
- return true;
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/graphics/SegmentedFontData.h b/WebCore/platform/graphics/SegmentedFontData.h
deleted file mode 100644
index 1adec15..0000000
--- a/WebCore/platform/graphics/SegmentedFontData.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef SegmentedFontData_h
-#define SegmentedFontData_h
-
-#include "FontData.h"
-#include <wtf/Vector.h>
-
-namespace WebCore {
-
-class SimpleFontData;
-
-struct FontDataRange {
- FontDataRange(UChar32 from, UChar32 to, const SimpleFontData* fontData)
- : m_from(from)
- , m_to(to)
- , m_fontData(fontData)
- {
- }
-
- UChar32 from() const { return m_from; }
- UChar32 to() const { return m_to; }
- const SimpleFontData* fontData() const { return m_fontData; }
-
-private:
- UChar32 m_from;
- UChar32 m_to;
- const SimpleFontData* m_fontData;
-};
-
-class SegmentedFontData : public FontData {
-public:
- virtual ~SegmentedFontData();
-
- virtual const SimpleFontData* fontDataForCharacter(UChar32) const;
- virtual bool containsCharacters(const UChar*, int length) const;
-
- virtual bool isCustomFont() const;
- virtual bool isLoading() const;
- virtual bool isSegmented() const;
-
- void appendRange(const FontDataRange& range) { m_ranges.append(range); }
- unsigned numRanges() const { return m_ranges.size(); }
- const FontDataRange& rangeAt(unsigned i) const { return m_ranges[i]; }
-
-private:
- Vector<FontDataRange, 1> m_ranges;
-};
-
-} // namespace WebCore
-
-#endif // SegmentedFontData_h
diff --git a/WebCore/platform/graphics/SimpleFontData.cpp b/WebCore/platform/graphics/SimpleFontData.cpp
deleted file mode 100644
index 372fcc8..0000000
--- a/WebCore/platform/graphics/SimpleFontData.cpp
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Copyright (C) 2005, 2008 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2006 Alexey Proskuryakov
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "SimpleFontData.h"
-
-#include "FontCache.h"
-#if ENABLE(SVG_FONTS)
-#include "SVGFontData.h"
-#include "SVGFontFaceElement.h"
-#endif
-
-#include <wtf/MathExtras.h>
-
-namespace WebCore {
-
-SimpleFontData::SimpleFontData(const FontPlatformData& f, bool customFont, bool loading, SVGFontData* svgFontData)
- : m_font(f)
- , m_treatAsFixedPitch(false)
-#if ENABLE(SVG_FONTS)
- , m_svgFontData(svgFontData)
-#endif
- , m_isCustomFont(customFont)
- , m_isLoading(loading)
- , m_smallCapsFontData(0)
-{
-#if ENABLE(SVG_FONTS) && !PLATFORM(QT)
- if (SVGFontFaceElement* svgFontFaceElement = svgFontData ? svgFontData->svgFontFaceElement() : 0) {
- m_unitsPerEm = svgFontFaceElement->unitsPerEm();
-
- double scale = f.size();
- if (m_unitsPerEm)
- scale /= m_unitsPerEm;
-
- m_ascent = static_cast<int>(svgFontFaceElement->ascent() * scale);
- m_descent = static_cast<int>(svgFontFaceElement->descent() * scale);
- m_xHeight = static_cast<int>(svgFontFaceElement->xHeight() * scale);
- m_lineGap = 0.1f * f.size();
- m_lineSpacing = m_ascent + m_descent + m_lineGap;
-
- m_spaceGlyph = 0;
- m_spaceWidth = 0;
- m_adjustedSpaceWidth = 0;
- determinePitch();
- m_missingGlyphData.fontData = this;
- m_missingGlyphData.glyph = 0;
- return;
- }
-#endif
-
- platformInit();
-
- GlyphPage* glyphPageZero = GlyphPageTreeNode::getRootChild(this, 0)->page();
- if (!glyphPageZero) {
- LOG_ERROR("Failed to get glyph page zero.");
- m_spaceGlyph = 0;
- m_spaceWidth = 0;
- m_adjustedSpaceWidth = 0;
- determinePitch();
- m_missingGlyphData.fontData = this;
- m_missingGlyphData.glyph = 0;
- return;
- }
-
- // Nasty hack to determine if we should round or ceil space widths.
- // If the font is monospace or fake monospace we ceil to ensure that
- // every character and the space are the same width. Otherwise we round.
- m_spaceGlyph = glyphPageZero->glyphDataForCharacter(' ').glyph;
- float width = widthForGlyph(m_spaceGlyph);
- m_spaceWidth = width;
- determinePitch();
- m_adjustedSpaceWidth = m_treatAsFixedPitch ? ceilf(width) : roundf(width);
-
- // Force the glyph for ZERO WIDTH SPACE to have zero width, unless it is shared with SPACE.
- // Helvetica is an example of a non-zero width ZERO WIDTH SPACE glyph.
- // See <http://bugs.webkit.org/show_bug.cgi?id=13178>
- // Ask for the glyph for 0 to avoid paging in ZERO WIDTH SPACE. Control characters, including 0,
- // are mapped to the ZERO WIDTH SPACE glyph.
- Glyph zeroWidthSpaceGlyph = glyphPageZero->glyphDataForCharacter(0).glyph;
- if (zeroWidthSpaceGlyph) {
- if (zeroWidthSpaceGlyph != m_spaceGlyph)
- m_glyphToWidthMap.setWidthForGlyph(zeroWidthSpaceGlyph, 0);
- else
- LOG_ERROR("Font maps SPACE and ZERO WIDTH SPACE to the same glyph. Glyph width not overridden.");
- }
-
- m_missingGlyphData.fontData = this;
- m_missingGlyphData.glyph = 0;
-}
-
-SimpleFontData::~SimpleFontData()
-{
- if (!isCustomFont()) {
- if (m_smallCapsFontData)
- FontCache::releaseFontData(m_smallCapsFontData);
- GlyphPageTreeNode::pruneTreeFontData(this);
- }
-
-#if ENABLE(SVG_FONTS) && !PLATFORM(QT)
- if (!m_svgFontData || !m_svgFontData->svgFontFaceElement())
-#endif
- platformDestroy();
-}
-
-float SimpleFontData::widthForGlyph(Glyph glyph) const
-{
- float width = m_glyphToWidthMap.widthForGlyph(glyph);
- if (width != cGlyphWidthUnknown)
- return width;
-
- width = platformWidthForGlyph(glyph);
- m_glyphToWidthMap.setWidthForGlyph(glyph, width);
-
- return width;
-}
-
-const SimpleFontData* SimpleFontData::fontDataForCharacter(UChar32) const
-{
- return this;
-}
-
-bool SimpleFontData::isSegmented() const
-{
- return false;
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/graphics/SimpleFontData.h b/WebCore/platform/graphics/SimpleFontData.h
deleted file mode 100644
index 5f26cbf..0000000
--- a/WebCore/platform/graphics/SimpleFontData.h
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * This file is part of the internal font implementation.
- *
- * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef SimpleFontData_h
-#define SimpleFontData_h
-
-#include "FontData.h"
-#include "FontPlatformData.h"
-#include "GlyphPageTreeNode.h"
-#include "GlyphWidthMap.h"
-#include <wtf/OwnPtr.h>
-
-#if USE(ATSUI)
-typedef struct OpaqueATSUStyle* ATSUStyle;
-#endif
-
-#if PLATFORM(WIN)
-#include <usp10.h>
-#endif
-
-#if PLATFORM(CAIRO)
-#include <cairo.h>
-#endif
-
-namespace WebCore {
-
-class FontDescription;
-class FontPlatformData;
-class SharedBuffer;
-class SVGFontData;
-class WidthMap;
-
-enum Pitch { UnknownPitch, FixedPitch, VariablePitch };
-
-class SimpleFontData : public FontData {
-public:
- SimpleFontData(const FontPlatformData&, bool customFont = false, bool loading = false, SVGFontData* data = 0);
- virtual ~SimpleFontData();
-
-public:
- const FontPlatformData& platformData() const { return m_font; }
- SimpleFontData* smallCapsFontData(const FontDescription& fontDescription) const;
-
- // vertical metrics
- int ascent() const { return m_ascent; }
- int descent() const { return m_descent; }
- int lineSpacing() const { return m_lineSpacing; }
- int lineGap() const { return m_lineGap; }
- float xHeight() const { return m_xHeight; }
- unsigned unitsPerEm() const { return m_unitsPerEm; }
-
- float widthForGlyph(Glyph) const;
- float platformWidthForGlyph(Glyph) const;
-
- virtual const SimpleFontData* fontDataForCharacter(UChar32) const;
- virtual bool containsCharacters(const UChar*, int length) const;
-
- void determinePitch();
- Pitch pitch() const { return m_treatAsFixedPitch ? FixedPitch : VariablePitch; }
-
-#if ENABLE(SVG_FONTS)
- SVGFontData* svgFontData() const { return m_svgFontData.get(); }
- bool isSVGFont() const { return m_svgFontData; }
-#else
- bool isSVGFont() const { return false; }
-#endif
-
- virtual bool isCustomFont() const { return m_isCustomFont; }
- virtual bool isLoading() const { return m_isLoading; }
- virtual bool isSegmented() const;
-
- const GlyphData& missingGlyphData() const { return m_missingGlyphData; }
-
-#if PLATFORM(MAC)
- NSFont* getNSFont() const { return m_font.font(); }
-#endif
-
-#if USE(CORE_TEXT)
- CTFontRef getCTFont() const;
- CFDictionaryRef getCFStringAttributes() const;
-#endif
-
-#if USE(ATSUI)
- void checkShapesArabic() const;
- bool shapesArabic() const
- {
- if (!m_checkedShapesArabic)
- checkShapesArabic();
- return m_shapesArabic;
- }
-#endif
-
-#if PLATFORM(WIN)
- bool isSystemFont() const { return m_isSystemFont; }
- SCRIPT_FONTPROPERTIES* scriptFontProperties() const;
- SCRIPT_CACHE* scriptCache() const { return &m_scriptCache; }
-
- static void setShouldApplyMacAscentHack(bool);
- static bool shouldApplyMacAscentHack();
-#endif
-
-#if PLATFORM(CAIRO)
- void setFont(cairo_t*) const;
-#endif
-
-#if PLATFORM(WX)
- wxFont getWxFont() const { return m_font.font(); }
-#endif
-
-private:
- void platformInit();
- void platformDestroy();
-
- void commonInit();
-
-#if PLATFORM(WIN)
- void initGDIFont();
- void platformCommonDestroy();
- float widthForGDIGlyph(Glyph glyph) const;
-#endif
-
-public:
- int m_ascent;
- int m_descent;
- int m_lineSpacing;
- int m_lineGap;
- float m_xHeight;
- unsigned m_unitsPerEm;
-
- FontPlatformData m_font;
-
- mutable GlyphWidthMap m_glyphToWidthMap;
-
- bool m_treatAsFixedPitch;
-
-#if ENABLE(SVG_FONTS)
- OwnPtr<SVGFontData> m_svgFontData;
-#endif
-
- bool m_isCustomFont; // Whether or not we are custom font loaded via @font-face
- bool m_isLoading; // Whether or not this custom font is still in the act of loading.
-
- Glyph m_spaceGlyph;
- float m_spaceWidth;
- float m_adjustedSpaceWidth;
-
- GlyphData m_missingGlyphData;
-
- mutable SimpleFontData* m_smallCapsFontData;
-
-#if PLATFORM(CG) || PLATFORM(WIN)
- float m_syntheticBoldOffset;
-#endif
-
-#if PLATFORM(MAC)
-#ifdef BUILDING_ON_TIGER
- void* m_styleGroup;
-#endif
-#endif
-
-#if USE(ATSUI)
- mutable ATSUStyle m_ATSUStyle;
- mutable bool m_ATSUStyleInitialized;
- mutable bool m_ATSUMirrors;
- mutable bool m_checkedShapesArabic;
- mutable bool m_shapesArabic;
-#endif
-
-#if USE(CORE_TEXT)
- mutable RetainPtr<CTFontRef> m_CTFont;
- mutable RetainPtr<CFDictionaryRef> m_CFStringAttributes;
-#endif
-
-#if PLATFORM(WIN)
- bool m_isSystemFont;
- mutable SCRIPT_CACHE m_scriptCache;
- mutable SCRIPT_FONTPROPERTIES* m_scriptFontProperties;
-#endif
-};
-
-} // namespace WebCore
-
-#endif // SimpleFontData_h
diff --git a/WebCore/platform/graphics/StringTruncator.cpp b/WebCore/platform/graphics/StringTruncator.cpp
deleted file mode 100644
index b6c86ce..0000000
--- a/WebCore/platform/graphics/StringTruncator.cpp
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "StringTruncator.h"
-
-#include "CharacterNames.h"
-#include "Font.h"
-#include "TextBreakIterator.h"
-#include <wtf/Assertions.h>
-#include <wtf/Vector.h>
-
-namespace WebCore {
-
-#define STRING_BUFFER_SIZE 2048
-
-typedef unsigned TruncationFunction(const String&, unsigned length, unsigned keepCount, UChar* buffer);
-
-static inline int textBreakAtOrPreceding(TextBreakIterator* it, int offset)
-{
- if (isTextBreak(it, offset))
- return offset;
-
- int result = textBreakPreceding(it, offset);
- return result == TextBreakDone ? 0 : result;
-}
-
-static inline int boundedTextBreakFollowing(TextBreakIterator* it, int offset, int length)
-{
- int result = textBreakFollowing(it, offset);
- return result == TextBreakDone ? length : result;
-}
-
-static unsigned centerTruncateToBuffer(const String& string, unsigned length, unsigned keepCount, UChar* buffer)
-{
- ASSERT(keepCount < length);
- ASSERT(keepCount < STRING_BUFFER_SIZE);
-
- unsigned omitStart = (keepCount + 1) / 2;
- TextBreakIterator* it = characterBreakIterator(string.characters(), length);
- unsigned omitEnd = boundedTextBreakFollowing(it, omitStart + (length - keepCount) - 1, length);
- omitStart = textBreakAtOrPreceding(it, omitStart);
-
- unsigned truncatedLength = omitStart + 1 + (length - omitEnd);
- ASSERT(truncatedLength <= length);
-
- memcpy(buffer, string.characters(), sizeof(UChar) * omitStart);
- buffer[omitStart] = horizontalEllipsis;
- memcpy(&buffer[omitStart + 1], &string.characters()[omitEnd], sizeof(UChar) * (length - omitEnd));
-
- return truncatedLength;
-}
-
-static unsigned rightTruncateToBuffer(const String& string, unsigned length, unsigned keepCount, UChar* buffer)
-{
- ASSERT(keepCount < length);
- ASSERT(keepCount < STRING_BUFFER_SIZE);
-
- TextBreakIterator* it = characterBreakIterator(string.characters(), length);
- unsigned keepLength = textBreakAtOrPreceding(it, keepCount);
- unsigned truncatedLength = keepLength + 1;
-
- memcpy(buffer, string.characters(), sizeof(UChar) * keepLength);
- buffer[keepLength] = horizontalEllipsis;
-
- return truncatedLength;
-}
-
-static float stringWidth(const Font& renderer, const UChar* characters, unsigned length, bool disableRoundingHacks)
-{
- TextRun run(characters, length);
- if (disableRoundingHacks)
- run.disableRoundingHacks();
- return renderer.floatWidth(run);
-}
-
-static String truncateString(const String& string, float maxWidth, const Font& font, TruncationFunction truncateToBuffer, bool disableRoundingHacks)
-{
- if (string.isEmpty())
- return string;
-
- ASSERT(maxWidth >= 0);
-
- float currentEllipsisWidth = stringWidth(font, &horizontalEllipsis, 1, disableRoundingHacks);
-
- UChar stringBuffer[STRING_BUFFER_SIZE];
- unsigned truncatedLength;
- unsigned keepCount;
- unsigned length = string.length();
-
- if (length > STRING_BUFFER_SIZE) {
- keepCount = STRING_BUFFER_SIZE - 1; // need 1 character for the ellipsis
- truncatedLength = centerTruncateToBuffer(string, length, keepCount, stringBuffer);
- } else {
- keepCount = length;
- memcpy(stringBuffer, string.characters(), sizeof(UChar) * length);
- truncatedLength = length;
- }
-
- float width = stringWidth(font, stringBuffer, truncatedLength, disableRoundingHacks);
- if (width <= maxWidth)
- return string;
-
- unsigned keepCountForLargestKnownToFit = 0;
- float widthForLargestKnownToFit = currentEllipsisWidth;
-
- unsigned keepCountForSmallestKnownToNotFit = keepCount;
- float widthForSmallestKnownToNotFit = width;
-
- if (currentEllipsisWidth >= maxWidth) {
- keepCountForLargestKnownToFit = 1;
- keepCountForSmallestKnownToNotFit = 2;
- }
-
- while (keepCountForLargestKnownToFit + 1 < keepCountForSmallestKnownToNotFit) {
- ASSERT(widthForLargestKnownToFit <= maxWidth);
- ASSERT(widthForSmallestKnownToNotFit > maxWidth);
-
- float ratio = (keepCountForSmallestKnownToNotFit - keepCountForLargestKnownToFit)
- / (widthForSmallestKnownToNotFit - widthForLargestKnownToFit);
- keepCount = static_cast<unsigned>(maxWidth * ratio);
-
- if (keepCount <= keepCountForLargestKnownToFit) {
- keepCount = keepCountForLargestKnownToFit + 1;
- } else if (keepCount >= keepCountForSmallestKnownToNotFit) {
- keepCount = keepCountForSmallestKnownToNotFit - 1;
- }
-
- ASSERT(keepCount < length);
- ASSERT(keepCount > 0);
- ASSERT(keepCount < keepCountForSmallestKnownToNotFit);
- ASSERT(keepCount > keepCountForLargestKnownToFit);
-
- truncatedLength = truncateToBuffer(string, length, keepCount, stringBuffer);
-
- width = stringWidth(font, stringBuffer, truncatedLength, disableRoundingHacks);
- if (width <= maxWidth) {
- keepCountForLargestKnownToFit = keepCount;
- widthForLargestKnownToFit = width;
- } else {
- keepCountForSmallestKnownToNotFit = keepCount;
- widthForSmallestKnownToNotFit = width;
- }
- }
-
- if (keepCountForLargestKnownToFit == 0) {
- keepCountForLargestKnownToFit = 1;
- }
-
- if (keepCount != keepCountForLargestKnownToFit) {
- keepCount = keepCountForLargestKnownToFit;
- truncatedLength = truncateToBuffer(string, length, keepCount, stringBuffer);
- }
-
- return String(stringBuffer, truncatedLength);
-}
-
-String StringTruncator::centerTruncate(const String& string, float maxWidth, const Font& font, bool disableRoundingHacks)
-{
- return truncateString(string, maxWidth, font, centerTruncateToBuffer, disableRoundingHacks);
-}
-
-String StringTruncator::rightTruncate(const String& string, float maxWidth, const Font& font, bool disableRoundingHacks)
-{
- return truncateString(string, maxWidth, font, rightTruncateToBuffer, disableRoundingHacks);
-}
-
-float StringTruncator::width(const String& string, const Font& font, bool disableRoundingHacks)
-{
- return stringWidth(font, string.characters(), string.length(), disableRoundingHacks);
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/graphics/StringTruncator.h b/WebCore/platform/graphics/StringTruncator.h
deleted file mode 100644
index 0a8532b..0000000
--- a/WebCore/platform/graphics/StringTruncator.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef StringTruncator_h
-#define StringTruncator_h
-
-namespace WebCore {
-
- class Font;
- class String;
-
- class StringTruncator {
- public:
- static String centerTruncate(const String&, float maxWidth, const Font&, bool disableRoundingHacks = true);
- static String rightTruncate(const String&, float maxWidth, const Font&, bool disableRoundingHacks = true);
- static float width(const String&, const Font&, bool disableRoundingHacks = true);
- };
-
-} // namespace WebCore
-
-#endif // !defined(StringTruncator_h)
diff --git a/WebCore/platform/graphics/TextRun.h b/WebCore/platform/graphics/TextRun.h
deleted file mode 100644
index 166b047..0000000
--- a/WebCore/platform/graphics/TextRun.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
- * (C) 2000 Antti Koivisto (koivisto@kde.org)
- * (C) 2000 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2003, 2006, 2007 Apple Computer, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef TextRun_h
-#define TextRun_h
-
-#include "PlatformString.h"
-
-namespace WebCore {
-
-class RenderObject;
-class SVGPaintServer;
-
-class TextRun {
-public:
- TextRun(const UChar* c, int len, bool allowTabs = false, int xpos = 0, int padding = 0, bool rtl = false, bool directionalOverride = false,
- bool applyRunRounding = true, bool applyWordRounding = true)
- : m_characters(c)
- , m_len(len)
- , m_xpos(xpos)
- , m_padding(padding)
- , m_allowTabs(allowTabs)
- , m_rtl(rtl)
- , m_directionalOverride(directionalOverride)
- , m_applyRunRounding(applyRunRounding)
- , m_applyWordRounding(applyWordRounding)
- , m_disableSpacing(false)
-#if ENABLE(SVG_FONTS)
- , m_referencingRenderObject(0)
- , m_activePaintServer(0)
-#endif
- {
- }
-
- TextRun(const String& s, bool allowTabs = false, int xpos = 0, int padding = 0, bool rtl = false, bool directionalOverride = false,
- bool applyRunRounding = true, bool applyWordRounding = true)
- : m_characters(s.characters())
- , m_len(s.length())
- , m_xpos(xpos)
- , m_padding(padding)
- , m_allowTabs(allowTabs)
- , m_rtl(rtl)
- , m_directionalOverride(directionalOverride)
- , m_applyRunRounding(applyRunRounding)
- , m_applyWordRounding(applyWordRounding)
- , m_disableSpacing(false)
-#if ENABLE(SVG_FONTS)
- , m_referencingRenderObject(0)
- , m_activePaintServer(0)
-#endif
- {
- }
-
- UChar operator[](int i) const { return m_characters[i]; }
- const UChar* data(int i) const { return &m_characters[i]; }
-
- const UChar* characters() const { return m_characters; }
- int length() const { return m_len; }
-
- void setText(const UChar* c, int len) { m_characters = c; m_len = len; }
-
- bool allowTabs() const { return m_allowTabs; }
- int xPos() const { return m_xpos; }
- int padding() const { return m_padding; }
- bool rtl() const { return m_rtl; }
- bool ltr() const { return !m_rtl; }
- bool directionalOverride() const { return m_directionalOverride; }
- bool applyRunRounding() const { return m_applyRunRounding; }
- bool applyWordRounding() const { return m_applyWordRounding; }
- bool spacingDisabled() const { return m_disableSpacing; }
-
- void disableSpacing() { m_disableSpacing = true; }
- void disableRoundingHacks() { m_applyRunRounding = m_applyWordRounding = false; }
- void setRTL(bool b) { m_rtl = b; }
- void setDirectionalOverride(bool override) { m_directionalOverride = override; }
-
-#if ENABLE(SVG_FONTS)
- RenderObject* referencingRenderObject() const { return m_referencingRenderObject; }
- void setReferencingRenderObject(RenderObject* object) { m_referencingRenderObject = object; }
-
- SVGPaintServer* activePaintServer() const { return m_activePaintServer; }
- void setActivePaintServer(SVGPaintServer* object) { m_activePaintServer = object; }
-#endif
-
-private:
- const UChar* m_characters;
- int m_len;
-
- int m_xpos;
- int m_padding;
- bool m_allowTabs;
- bool m_rtl;
- bool m_directionalOverride;
- bool m_applyRunRounding;
- bool m_applyWordRounding;
- bool m_disableSpacing;
-
-#if ENABLE(SVG_FONTS)
- RenderObject* m_referencingRenderObject;
- SVGPaintServer* m_activePaintServer;
-#endif
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/graphics/UnitBezier.h b/WebCore/platform/graphics/UnitBezier.h
deleted file mode 100644
index 973d75b..0000000
--- a/WebCore/platform/graphics/UnitBezier.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef UnitBezier_h
-#define UnitBezier_h
-
-#include <math.h>
-
-namespace WebCore {
-
- struct UnitBezier {
- UnitBezier(double p1x, double p1y, double p2x, double p2y)
- {
- // Calculate the polynomial coefficients, implicit first and last control points are (0,0) and (1,1).
- cx = 3.0 * p1x;
- bx = 3.0 * (p2x - p1x) - cx;
- ax = 1.0 - cx -bx;
-
- cy = 3.0 * p1y;
- by = 3.0 * (p2y - p1y) - cy;
- ay = 1.0 - cy - by;
- }
-
- double sampleCurveX(double t)
- {
- // `ax t^3 + bx t^2 + cx t' expanded using Horner's rule.
- return ((ax * t + bx) * t + cx) * t;
- }
-
- double sampleCurveY(double t)
- {
- return ((ay * t + by) * t + cy) * t;
- }
-
- double sampleCurveDerivativeX(double t)
- {
- return (3.0 * ax * t + 2.0 * bx) * t + cx;
- }
-
- // Given an x value, find a parametric value it came from.
- double solveCurveX(double x, double epsilon)
- {
- double t0;
- double t1;
- double t2;
- double x2;
- double d2;
- int i;
-
- // First try a few iterations of Newton's method -- normally very fast.
- for (t2 = x, i = 0; i < 8; i++) {
- x2 = sampleCurveX(t2) - x;
- if (fabs (x2) < epsilon)
- return t2;
- d2 = sampleCurveDerivativeX(t2);
- if (fabs(d2) < 1e-6)
- break;
- t2 = t2 - x2 / d2;
- }
-
- // Fall back to the bisection method for reliability.
- t0 = 0.0;
- t1 = 1.0;
- t2 = x;
-
- if (t2 < t0)
- return t0;
- if (t2 > t1)
- return t1;
-
- while (t0 < t1) {
- x2 = sampleCurveX(t2);
- if (fabs(x2 - x) < epsilon)
- return t2;
- if (x > x2)
- t0 = t2;
- else
- t1 = t2;
- t2 = (t1 - t0) * .5 + t0;
- }
-
- // Failure.
- return t2;
- }
-
- double solve(double x, double epsilon)
- {
- return sampleCurveY(solveCurveX(x, epsilon));
- }
-
- private:
- double ax;
- double bx;
- double cx;
-
- double ay;
- double by;
- double cy;
- };
-}
-#endif
diff --git a/WebCore/platform/graphics/WidthIterator.cpp b/WebCore/platform/graphics/WidthIterator.cpp
deleted file mode 100644
index a16d739..0000000
--- a/WebCore/platform/graphics/WidthIterator.cpp
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
- * Copyright (C) 2003, 2006, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2008 Holger Hans Peter Freyther
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "WidthIterator.h"
-
-#include "Font.h"
-#include "GlyphBuffer.h"
-#include "SimpleFontData.h"
-#include <wtf/MathExtras.h>
-
-#if USE(ICU_UNICODE)
-#include <unicode/unorm.h>
-#endif
-
-using namespace WTF;
-using namespace Unicode;
-
-namespace WebCore {
-
-// According to http://www.unicode.org/Public/UNIDATA/UCD.html#Canonical_Combining_Class_Values
-static const uint8_t hiraganaKatakanaVoicingMarksCombiningClass = 8;
-
-WidthIterator::WidthIterator(const Font* font, const TextRun& run)
- : m_font(font)
- , m_run(run)
- , m_end(run.length())
- , m_currentCharacter(0)
- , m_runWidthSoFar(0)
- , m_finalRoundingWidth(0)
-{
- // If the padding is non-zero, count the number of spaces in the run
- // and divide that by the padding for per space addition.
- m_padding = m_run.padding();
- if (!m_padding)
- m_padPerSpace = 0;
- else {
- float numSpaces = 0;
- for (int i = 0; i < run.length(); i++)
- if (Font::treatAsSpace(m_run[i]))
- numSpaces++;
-
- if (numSpaces == 0)
- m_padPerSpace = 0;
- else
- m_padPerSpace = ceilf(m_run.padding() / numSpaces);
- }
-}
-
-void WidthIterator::advance(int offset, GlyphBuffer* glyphBuffer)
-{
- if (offset > m_end)
- offset = m_end;
-
- int currentCharacter = m_currentCharacter;
- const UChar* cp = m_run.data(currentCharacter);
-
- bool rtl = m_run.rtl();
- bool hasExtraSpacing = (m_font->letterSpacing() || m_font->wordSpacing() || m_padding) && !m_run.spacingDisabled();
-
- float runWidthSoFar = m_runWidthSoFar;
- float lastRoundingWidth = m_finalRoundingWidth;
-
- while (currentCharacter < offset) {
- UChar32 c = *cp;
- unsigned clusterLength = 1;
- if (c >= 0x3041) {
- if (c <= 0x30FE) {
- // Deal with Hiragana and Katakana voiced and semi-voiced syllables.
- // Normalize into composed form, and then look for glyph with base + combined mark.
- // Check above for character range to minimize performance impact.
- UChar32 normalized = normalizeVoicingMarks(currentCharacter);
- if (normalized) {
- c = normalized;
- clusterLength = 2;
- }
- } else if (U16_IS_SURROGATE(c)) {
- if (!U16_IS_SURROGATE_LEAD(c))
- break;
-
- // Do we have a surrogate pair? If so, determine the full Unicode (32 bit)
- // code point before glyph lookup.
- // Make sure we have another character and it's a low surrogate.
- if (currentCharacter + 1 >= m_run.length())
- break;
- UChar low = cp[1];
- if (!U16_IS_TRAIL(low))
- break;
- c = U16_GET_SUPPLEMENTARY(c, low);
- clusterLength = 2;
- }
- }
-
- const GlyphData& glyphData = m_font->glyphDataForCharacter(c, rtl);
- Glyph glyph = glyphData.glyph;
- const SimpleFontData* fontData = glyphData.fontData;
-
- ASSERT(fontData);
-
- // Now that we have a glyph and font data, get its width.
- float width;
- if (c == '\t' && m_run.allowTabs()) {
- float tabWidth = m_font->tabWidth();
- width = tabWidth - fmodf(m_run.xPos() + runWidthSoFar, tabWidth);
- } else {
- width = fontData->widthForGlyph(glyph);
- // We special case spaces in two ways when applying word rounding.
- // First, we round spaces to an adjusted width in all fonts.
- // Second, in fixed-pitch fonts we ensure that all characters that
- // match the width of the space character have the same width as the space character.
- if (width == fontData->m_spaceWidth && (fontData->m_treatAsFixedPitch || glyph == fontData->m_spaceGlyph) && m_run.applyWordRounding()) {
- width = fontData->m_adjustedSpaceWidth;
- }
- }
-
- if (hasExtraSpacing) {
- // Account for letter-spacing.
- if (width && m_font->letterSpacing()) {
- width += m_font->letterSpacing();
- }
-
- if (Font::treatAsSpace(c)) {
- // Account for padding. WebCore uses space padding to justify text.
- // We distribute the specified padding over the available spaces in the run.
- if (m_padding) {
- // Use left over padding if not evenly divisible by number of spaces.
- if (m_padding < m_padPerSpace) {
- width += m_padding;
- m_padding = 0;
- } else {
- width += m_padPerSpace;
- m_padding -= m_padPerSpace;
- }
- }
-
- // Account for word spacing.
- // We apply additional space between "words" by adding width to the space character.
- if (currentCharacter != 0 && !Font::treatAsSpace(cp[-1]) && m_font->wordSpacing()) {
- width += m_font->wordSpacing();
- }
- }
- }
-
- // Advance past the character we just dealt with.
- cp += clusterLength;
- currentCharacter += clusterLength;
-
- // Account for float/integer impedance mismatch between CG and KHTML. "Words" (characters
- // followed by a character defined by isRoundingHackCharacter()) are always an integer width.
- // We adjust the width of the last character of a "word" to ensure an integer width.
- // If we move KHTML to floats we can remove this (and related) hacks.
-
- float oldWidth = width;
-
- // Force characters that are used to determine word boundaries for the rounding hack
- // to be integer width, so following words will start on an integer boundary.
- if (m_run.applyWordRounding() && Font::isRoundingHackCharacter(c)) {
- width = ceilf(width);
- }
-
- // Check to see if the next character is a "rounding hack character", if so, adjust
- // width so that the total run width will be on an integer boundary.
- if ((m_run.applyWordRounding() && currentCharacter < m_run.length() && Font::isRoundingHackCharacter(*cp))
- || (m_run.applyRunRounding() && currentCharacter >= m_end)) {
- float totalWidth = runWidthSoFar + width;
- width += ceilf(totalWidth) - totalWidth;
- }
-
- runWidthSoFar += width;
-
- if (glyphBuffer)
- glyphBuffer->add(glyph, fontData, (rtl ? oldWidth + lastRoundingWidth : width));
-
- lastRoundingWidth = width - oldWidth;
- }
-
- m_currentCharacter = currentCharacter;
- m_runWidthSoFar = runWidthSoFar;
- m_finalRoundingWidth = lastRoundingWidth;
-}
-
-bool WidthIterator::advanceOneCharacter(float& width, GlyphBuffer* glyphBuffer)
-{
- glyphBuffer->clear();
- advance(m_currentCharacter + 1, glyphBuffer);
- float w = 0;
- for (int i = 0; i < glyphBuffer->size(); ++i)
- w += glyphBuffer->advanceAt(i);
- width = w;
- return !glyphBuffer->isEmpty();
-}
-
-UChar32 WidthIterator::normalizeVoicingMarks(int currentCharacter)
-{
- if (currentCharacter + 1 < m_end) {
- if (combiningClass(m_run[currentCharacter + 1]) == hiraganaKatakanaVoicingMarksCombiningClass) {
-#if USE(ICU_UNICODE)
- // Normalize into composed form using 3.2 rules.
- UChar normalizedCharacters[2] = { 0, 0 };
- UErrorCode uStatus = U_ZERO_ERROR;
- int32_t resultLength = unorm_normalize(m_run.data(currentCharacter), 2,
- UNORM_NFC, UNORM_UNICODE_3_2, &normalizedCharacters[0], 2, &uStatus);
- if (resultLength == 1 && uStatus == 0)
- return normalizedCharacters[0];
-#elif USE(QT4_UNICODE)
- QString tmp(reinterpret_cast<const QChar*>(m_run.data(currentCharacter)), 2);
- QString res = tmp.normalized(QString::NormalizationForm_C, QChar::Unicode_3_2);
- if (res.length() == 1)
- return res.at(0).unicode();
-#endif
- }
- }
- return 0;
-}
-
-}
diff --git a/WebCore/platform/graphics/WidthIterator.h b/WebCore/platform/graphics/WidthIterator.h
deleted file mode 100644
index 5706d1e..0000000
--- a/WebCore/platform/graphics/WidthIterator.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2003, 2006, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2008 Holger Hans Peter Freyther
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef WidthIterator_h
-#define WidthIterator_h
-
-#include <wtf/unicode/Unicode.h>
-
-namespace WebCore {
-
-class Font;
-class GlyphBuffer;
-class TextRun;
-
-struct WidthIterator {
- WidthIterator(const Font*, const TextRun&);
-
- void advance(int to, GlyphBuffer* = 0);
- bool advanceOneCharacter(float& width, GlyphBuffer* = 0);
-
- const Font* m_font;
-
- const TextRun& m_run;
- int m_end;
-
- unsigned m_currentCharacter;
- float m_runWidthSoFar;
- float m_padding;
- float m_padPerSpace;
- float m_finalRoundingWidth;
-
-private:
- UChar32 normalizeVoicingMarks(int currentCharacter);
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/graphics/android/AffineTransformAndroid.cpp b/WebCore/platform/graphics/android/AffineTransformAndroid.cpp
deleted file mode 100644
index c01d078..0000000
--- a/WebCore/platform/graphics/android/AffineTransformAndroid.cpp
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * Copyright 2007, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "AffineTransform.h"
-
-#include "FloatRect.h"
-#include "IntRect.h"
-
-#include "android_graphics.h"
-
-namespace WebCore {
-
-static const double deg2rad = 0.017453292519943295769; // pi/180
-
-AffineTransform::AffineTransform()
-{
- m_transform.reset();
-}
-
-AffineTransform::AffineTransform(const SkMatrix& mat) : m_transform(mat) {}
-
-AffineTransform::AffineTransform(double a, double b, double c, double d, double tx, double ty)
-{
- m_transform.reset();
-
- m_transform.set(SkMatrix::kMScaleX, SkDoubleToScalar(a));
- m_transform.set(SkMatrix::kMSkewX, SkDoubleToScalar(b));
- m_transform.set(SkMatrix::kMTransX, SkDoubleToScalar(tx));
-
- m_transform.set(SkMatrix::kMScaleY, SkDoubleToScalar(d));
- m_transform.set(SkMatrix::kMSkewX, SkDoubleToScalar(c));
- m_transform.set(SkMatrix::kMTransX, SkDoubleToScalar(ty));
-}
-
-void AffineTransform::setMatrix(double a, double b, double c, double d, double tx, double ty)
-{
- m_transform.set(SkMatrix::kMScaleX, SkDoubleToScalar(a));
- m_transform.set(SkMatrix::kMSkewX, SkDoubleToScalar(b));
- m_transform.set(SkMatrix::kMTransX, SkDoubleToScalar(tx));
-
- m_transform.set(SkMatrix::kMScaleY, SkDoubleToScalar(d));
- m_transform.set(SkMatrix::kMSkewX, SkDoubleToScalar(c));
- m_transform.set(SkMatrix::kMTransX, SkDoubleToScalar(ty));
-}
-
-void AffineTransform::map(double x, double y, double *x2, double *y2) const
-{
- SkPoint src, dst;
- src.set(SkDoubleToScalar(x), SkDoubleToScalar(y));
- m_transform.mapPoints(&dst, &src, 1);
-
- *x2 = SkScalarToDouble(dst.fX);
- *y2 = SkScalarToDouble(dst.fY);
-}
-
-IntRect AffineTransform::mapRect(const IntRect &rect) const
-{
- SkRect src, dst;
- SkIRect ir;
-
- android_setrect(&src, rect);
- m_transform.mapRect(&dst, src);
- dst.round(&ir);
-
- return IntRect(ir.fLeft, ir.fTop, ir.width(), ir.height());
-}
-
-FloatRect AffineTransform::mapRect(const FloatRect &rect) const
-{
- SkRect src, dst;
- SkIRect ir;
-
- android_setrect(&src, rect);
- m_transform.mapRect(&dst, src);
- dst.round(&ir);
-
- return IntRect(ir.fLeft, ir.fTop, ir.width(), ir.height());
-}
-
-bool AffineTransform::isIdentity() const
-{
- return m_transform.isIdentity();
-}
-
-void AffineTransform::reset()
-{
- m_transform.reset();
-}
-
- double AffineTransform::a() const {
- return SkScalarToDouble(m_transform[0]);
- }
- void AffineTransform::setA(double a) {
- m_transform.set(0, SkDoubleToScalar(a));
- }
-
- double AffineTransform::b() const {
- return SkScalarToDouble(m_transform[1]);
- }
- void AffineTransform::setB(double b) {
- m_transform.set(1, SkDoubleToScalar(b));
- }
-
- double AffineTransform::c() const {
- return SkScalarToDouble(m_transform[3]);
- }
- void AffineTransform::setC(double c) {
- m_transform.set(3, SkDoubleToScalar(c));
- }
-
- double AffineTransform::d() const {
- return SkScalarToDouble(m_transform[4]);
- }
- void AffineTransform::setD(double d) {
- m_transform.set(4, SkDoubleToScalar(d));
- }
-
- double AffineTransform::e() const {
- return SkScalarToDouble(m_transform[2]);
- }
- void AffineTransform::setE(double e) {
- m_transform.set(2, SkDoubleToScalar(e));
- }
-
- double AffineTransform::f() const {
- return SkScalarToDouble(m_transform[5]);
- }
- void AffineTransform::setF(double f) {
- m_transform.set(5, SkDoubleToScalar(f));
- }
-
-AffineTransform &AffineTransform::scale(double sx, double sy)
-{
- m_transform.preScale(SkDoubleToScalar(sx), SkDoubleToScalar(sy));
- return *this;
-}
-
-AffineTransform &AffineTransform::rotate(double d)
-{
- m_transform.preRotate(SkDoubleToScalar(d));
- return *this;
-}
-
-AffineTransform &AffineTransform::translate(double tx, double ty)
-{
- m_transform.preTranslate(SkDoubleToScalar(tx), SkDoubleToScalar(ty));
- return *this;
-}
-
-AffineTransform &AffineTransform::shear(double sx, double sy)
-{
- m_transform.preSkew(SkDoubleToScalar(sx), SkDoubleToScalar(sy));
- return *this;
-}
-
-double AffineTransform::det() const
-{
- return SkScalarToDouble(m_transform[SkMatrix::kMScaleX]) * SkScalarToDouble(m_transform[SkMatrix::kMScaleY]) -
- SkScalarToDouble(m_transform[SkMatrix::kMSkewX]) * SkScalarToDouble(m_transform[SkMatrix::kMSkewY]);
-}
-
-AffineTransform AffineTransform::inverse() const
-{
- AffineTransform inverse;
-
- m_transform.invert(&inverse.m_transform);
-
- return inverse;
-}
-
-AffineTransform::operator SkMatrix() const
-{
- return m_transform;
-}
-
-bool AffineTransform::operator==(const AffineTransform &m2) const
-{
- return m_transform == m2.m_transform;
-}
-
-AffineTransform &AffineTransform::operator*= (const AffineTransform &m2)
-{
- m_transform.setConcat(m2.m_transform, m_transform);
- return *this;
-}
-
-AffineTransform AffineTransform::operator* (const AffineTransform &m2)
-{
- AffineTransform cat;
-
- cat.m_transform.setConcat(m2.m_transform, m_transform);
- return cat;
-}
-
-}
diff --git a/WebCore/platform/graphics/android/FontAndroid.cpp b/WebCore/platform/graphics/android/FontAndroid.cpp
deleted file mode 100644
index 54a1a08..0000000
--- a/WebCore/platform/graphics/android/FontAndroid.cpp
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Copyright 2009, The Android Open Source Project
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Font.h"
-
-#include "FontData.h"
-#include "FontFallbackList.h"
-#include "GraphicsContext.h"
-#include "GlyphBuffer.h"
-#include "PlatformGraphicsContext.h"
-#include "IntRect.h"
-
-#include "SkCanvas.h"
-#include "SkLayerDrawLooper.h"
-#include "SkPaint.h"
-#include "SkTemplates.h"
-#include "SkTypeface.h"
-#include "SkUtils.h"
-
-namespace WebCore {
-
-static void updateForFont(SkPaint* paint, const SimpleFontData* font) {
- font->platformData().setupPaint(paint);
- paint->setTextEncoding(SkPaint::kGlyphID_TextEncoding);
-}
-
-static SkPaint* setupFill(SkPaint* paint, GraphicsContext* gc,
- const SimpleFontData* font) {
- gc->setupFillPaint(paint);
- updateForFont(paint, font);
- return paint;
-}
-
-static SkPaint* setupStroke(SkPaint* paint, GraphicsContext* gc,
- const SimpleFontData* font) {
- gc->setupStrokePaint(paint);
- updateForFont(paint, font);
- return paint;
-}
-
-static bool setupForText(SkPaint* paint, GraphicsContext* gc,
- const SimpleFontData* font) {
- int mode = gc->textDrawingMode();
-
- if ((mode & (cTextFill | cTextStroke)) == (cTextFill | cTextStroke)) {
- SkLayerDrawLooper* looper = new SkLayerDrawLooper;
- paint->setLooper(looper)->unref();
-
- // we clear the looper, in case we have a shadow
-
- SkPaint* fillP = NULL;
- SkPaint* strokeP = NULL;
- if (gc->willStroke()) {
- strokeP = setupStroke(looper->addLayer(), gc, font);
- strokeP->setLooper(NULL);
- }
- if (gc->willFill()) {
- fillP = setupFill(looper->addLayer(), gc, font);
- fillP->setLooper(NULL);
- }
-
- SkPaint shadowPaint;
- SkPoint offset;
- if (gc->setupShadowPaint(&shadowPaint, &offset)) {
- SkPaint* p = looper->addLayer(offset.fX, offset.fY);
- *p = shadowPaint;
- if (strokeP && !fillP) {
- // stroke the shadow if we have stroke but no fill
- p->setStyle(SkPaint::kStroke_Style);
- p->setStrokeWidth(strokeP->getStrokeWidth());
- }
- updateForFont(p, font);
- }
- } else if (mode & cTextFill) {
- (void)setupFill(paint, gc, font);
- } else if (mode & cTextStroke) {
- (void)setupStroke(paint, gc, font);
- } else {
- return false;
- }
- return true;
-}
-
-void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font,
- const GlyphBuffer& glyphBuffer, int from, int numGlyphs,
- const FloatPoint& point) const {
- SkASSERT(sizeof(GlyphBufferGlyph) == sizeof(uint16_t)); // compile-time assert
-
- SkPaint paint;
- if (!setupForText(&paint, gc, font)) {
- return;
- }
-
- SkScalar x = SkFloatToScalar(point.x());
- SkScalar y = SkFloatToScalar(point.y());
- const GlyphBufferGlyph* glyphs = glyphBuffer.glyphs(from);
- const GlyphBufferAdvance* adv = glyphBuffer.advances(from);
- SkAutoSTMalloc<32, SkPoint> storage(numGlyphs);
- SkPoint* pos = storage.get();
-
- /* We need an array of [x,y,x,y,x,y,...], but webkit is giving us
- point.xy + [width, height, width, height, ...], so we have to convert
- */
- for (int i = 0; i < numGlyphs; i++) {
- pos[i].set(x, y);
- x += SkFloatToScalar(adv[i].width());
- y += SkFloatToScalar(adv[i].height());
- }
-
- SkCanvas* canvas = gc->platformContext()->mCanvas;
- canvas->drawPosText(glyphs, numGlyphs * sizeof(*glyphs), pos, paint);
-}
-
-FloatRect Font::selectionRectForComplexText(const TextRun& run, const IntPoint& point, int h, int, int) const
-{
- SkPaint paint;
- SkScalar width, left;
- SkPaint::FontMetrics metrics;
-
- primaryFont()->platformData().setupPaint(&paint);
-
- width = paint.measureText(run.characters(), run.length() << 1);
- SkScalar spacing = paint.getFontMetrics(&metrics);
-
- return FloatRect(point.x(),
- point.y() - floorf(SkScalarToFloat(-metrics.fAscent)),
- roundf(SkScalarToFloat(width)),
- roundf(SkScalarToFloat(spacing)));
-}
-
-void Font::drawComplexText(GraphicsContext* gc, TextRun const& run, FloatPoint const& point, int, int) const
-{
- SkCanvas* canvas = gc->platformContext()->mCanvas;
- SkPaint paint;
-
- if (!setupForText(&paint, gc, primaryFont())) {
- return;
- }
-
- // go to chars, instead of glyphs, which was set by setupForText()
- paint.setTextEncoding(SkPaint::kUTF16_TextEncoding);
-
- canvas->drawText(run.characters(), run.length() << 1,
- SkFloatToScalar(point.x()), SkFloatToScalar(point.y()),
- paint);
-}
-
-float Font::floatWidthForComplexText(const TextRun& run) const
-{
- SkPaint paint;
-
- primaryFont()->platformData().setupPaint(&paint);
-
-//printf("--------- complext measure %d chars\n", run.to() - run.from());
-
- SkScalar width = paint.measureText(run.characters(), run.length() << 1);
- return SkScalarToFloat(width);
-}
-
-int Font::offsetForPositionForComplexText(const TextRun& run, int x, bool includePartialGlyphs) const
-{
- SkPaint paint;
- int count = run.length();
- SkAutoSTMalloc<64, SkScalar> storage(count);
- SkScalar* widths = storage.get();
-
- primaryFont()->platformData().setupPaint(&paint);
-
- count = paint.getTextWidths(run.characters(), count << 1, widths);
-
- if (count > 0)
- {
- SkScalar pos = 0;
- for (int i = 0; i < count; i++)
- {
- if (x < SkScalarRound(pos + SkScalarHalf(widths[i])))
- return i;
- pos += widths[i];
- }
- }
- return count;
-}
-
-}
diff --git a/WebCore/platform/graphics/android/FontCacheAndroid.cpp b/WebCore/platform/graphics/android/FontCacheAndroid.cpp
deleted file mode 100644
index c257348..0000000
--- a/WebCore/platform/graphics/android/FontCacheAndroid.cpp
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright 2009, The Android Open Source Project
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FontCache.h"
-#include "FontPlatformData.h"
-#include "Font.h"
-#include "NotImplemented.h"
-#include "SimpleFontData.h"
-#include "SkPaint.h"
-#include "SkTypeface.h"
-#include "SkUtils.h"
-
-namespace WebCore {
-
-void FontCache::platformInit()
-{
-}
-
-const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
-{
- // since all of our fonts logically map to the fallback, we can always claim
- // that each font supports all characters.
- return font.primaryFont();
-}
-
-FontPlatformData* FontCache::getSimilarFontPlatformData(const Font& font)
-{
- return 0;
-}
-
-FontPlatformData* FontCache::getLastResortFallbackFont(const FontDescription& font)
-{
- static AtomicString str("sans-serif");
- return getCachedFontPlatformData(font, str);
-}
-
-static char* AtomicStringToUTF8String(const AtomicString& utf16)
-{
- SkASSERT(sizeof(uint16_t) == sizeof(utf16.characters()[0]));
- const uint16_t* uni = (uint16_t*)utf16.characters();
-
- size_t bytes = SkUTF16_ToUTF8(uni, utf16.length(), NULL);
- char* utf8 = (char*)sk_malloc_throw(bytes + 1);
-
- (void)SkUTF16_ToUTF8(uni, utf16.length(), utf8);
- utf8[bytes] = 0;
- return utf8;
-}
-
-FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
-{
- char* storage = 0;
- const char* name = 0;
-
- if (family.length() == 0) {
- static const struct {
- FontDescription::GenericFamilyType mType;
- const char* mName;
- } gNames[] = {
- { FontDescription::SerifFamily, "serif" },
- { FontDescription::SansSerifFamily, "sans-serif" },
- { FontDescription::MonospaceFamily, "monospace" },
- { FontDescription::CursiveFamily, "cursive" },
- { FontDescription::FantasyFamily, "fantasy" }
- };
-
- FontDescription::GenericFamilyType type = fontDescription.genericFamily();
- for (unsigned i = 0; i < SK_ARRAY_COUNT(gNames); i++)
- {
- if (type == gNames[i].mType)
- {
- name = gNames[i].mName;
- break;
- }
- }
- // if we fall out of the loop, its ok for name to still be 0
- }
- else { // convert the name to utf8
- storage = AtomicStringToUTF8String(family);
- name = storage;
- }
-
- int style = SkTypeface::kNormal;
- if (fontDescription.weight() >= FontWeightBold)
- style |= SkTypeface::kBold;
- if (fontDescription.italic())
- style |= SkTypeface::kItalic;
-
- SkTypeface* tf = SkTypeface::Create(name, (SkTypeface::Style)style);
-
- FontPlatformData* result = new FontPlatformData(tf,
- fontDescription.computedSize(),
- (style & SkTypeface::kBold) && !tf->isBold(),
- (style & SkTypeface::kItalic) && !tf->isItalic());
- tf->unref();
- sk_free(storage);
- return result;
-}
-
- // new as of SVN change 36269, Sept 8, 2008
-void FontCache::getTraitsInFamily(const AtomicString& familyName, Vector<unsigned>& traitsMasks)
-{
- // Don't understand this yet, but it seems safe to leave unimplemented
-}
-
-}
-
diff --git a/WebCore/platform/graphics/android/FontCustomPlatformData.cpp b/WebCore/platform/graphics/android/FontCustomPlatformData.cpp
deleted file mode 100644
index eb1933c..0000000
--- a/WebCore/platform/graphics/android/FontCustomPlatformData.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright 2008, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FontCustomPlatformData.h"
-
-#include "SkTypeface.h"
-#include "SkStream.h"
-#include "SharedBuffer.h"
-#include "FontPlatformData.h"
-
-namespace WebCore {
-
-FontCustomPlatformData::FontCustomPlatformData(SkTypeface* face)
-{
- face->safeRef();
- m_typeface = face;
-}
-
-FontCustomPlatformData::~FontCustomPlatformData()
-{
- m_typeface->safeUnref();
- // the unref is enough to release the font data...
-}
-
-FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic,
- FontRenderingMode mode)
-{
- // turn bold/italic into fakeBold/fakeItalic
- if (m_typeface != NULL) {
- if (m_typeface->isBold() == bold)
- bold = false;
- if (m_typeface->isItalic() == italic)
- italic = false;
- }
- return FontPlatformData(m_typeface, size, bold, italic);
-}
-
-FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer)
-{
- // pass true until we know how we can share the data, and not have to
- // make a copy of it.
- SkStream* stream = new SkMemoryStream(buffer->data(), buffer->size(), true);
- SkTypeface* face = SkTypeface::CreateFromStream(stream);
- if (NULL == face) {
- SkDebugf("--------- SkTypeface::CreateFromBuffer failed %d\n",
- buffer->size());
- return NULL;
- }
-
- SkAutoUnref aur(face);
-
- return new FontCustomPlatformData(face);
-}
-
-}
diff --git a/WebCore/platform/graphics/android/FontCustomPlatformData.h b/WebCore/platform/graphics/android/FontCustomPlatformData.h
deleted file mode 100644
index e45d509..0000000
--- a/WebCore/platform/graphics/android/FontCustomPlatformData.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2008, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef FontCustomPlatformData_h_
-#define FontCustomPlatformData_h_
-
-#include <wtf/Noncopyable.h>
-#include "FontRenderingMode.h"
-
-class SkTypeface;
-
-namespace WebCore {
-
- class SharedBuffer;
- class FontPlatformData;
-
- class FontCustomPlatformData : Noncopyable {
- public:
- FontCustomPlatformData(SkTypeface* face);
- ~FontCustomPlatformData();
-
- SkTypeface* typeface() const { return m_typeface; }
-
- FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontRenderingMode );
-
- private:
- SkTypeface* m_typeface;
- };
-
- FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer);
-
-} // namespace WebCore
-
-#endif // FontCustomPlatformData_h_
-
diff --git a/WebCore/platform/graphics/android/FontDataAndroid.cpp b/WebCore/platform/graphics/android/FontDataAndroid.cpp
deleted file mode 100644
index 3dd9789..0000000
--- a/WebCore/platform/graphics/android/FontDataAndroid.cpp
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright 2009, The Android Open Source Project
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Font.h"
-#include "FontCache.h"
-#include "SimpleFontData.h"
-#include "FloatRect.h"
-#include "FontDescription.h"
-
-#include "SkPaint.h"
-#include "SkTypeface.h"
-#include "SkTime.h"
-
-namespace WebCore {
-
-void SimpleFontData::platformInit()
-{
- SkPaint paint;
- SkPaint::FontMetrics metrics;
-
- m_font.setupPaint(&paint);
- (void)paint.getFontMetrics(&metrics);
-
- // use ceil instead of round to favor descent, given a lot of accidental
- // clipping of descenders (e.g. 14pt 'g') in textedit fields
- int d = SkScalarCeil(metrics.fDescent);
- int s = SkScalarRound(metrics.fDescent - metrics.fAscent);
- int a = s - d;
-
- m_ascent = a;
- m_descent = d;
- m_xHeight = SkScalarToFloat(-metrics.fAscent) * 0.56f; // hack I stole from the window's port
- m_lineSpacing = a + d;
- m_lineGap = SkScalarRound(metrics.fLeading);
-}
-
-void SimpleFontData::platformDestroy()
-{
- delete m_smallCapsFontData;
-}
-
-SimpleFontData* SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const
-{
- if (!m_smallCapsFontData) {
- m_smallCapsFontData = new SimpleFontData(FontPlatformData(m_font, fontDescription.computedSize() * 0.7f));
- }
- return m_smallCapsFontData;
-}
-
-#define kMaxBufferCount 64
-
-bool SimpleFontData::containsCharacters(const UChar* characters, int length) const
-{
- SkPaint paint;
- uint16_t glyphs[kMaxBufferCount];
-
- m_font.setupPaint(&paint);
- paint.setTextEncoding(SkPaint::kUTF16_TextEncoding);
-
- while (length > 0) {
- int n = SkMin32(length, SK_ARRAY_COUNT(glyphs));
-
- int count = paint.textToGlyphs(characters, n << 1, glyphs);
- for (int i = 0; i < count; i++) {
- if (0 == glyphs[i]) {
- return false; // missing glyph
- }
- }
-
- characters += n;
- length -= n;
- }
- return true;
-}
-
-void SimpleFontData::determinePitch()
-{
- m_treatAsFixedPitch = false;
-}
-
-float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
-{
- SkASSERT(sizeof(glyph) == 2); // compile-time assert
-
- SkPaint paint;
-
- m_font.setupPaint(&paint);
-
- paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
- SkScalar width = paint.measureText(&glyph, 2);
-
- return SkScalarToFloat(width);
-}
-
-}
diff --git a/WebCore/platform/graphics/android/FontPlatformData.h b/WebCore/platform/graphics/android/FontPlatformData.h
deleted file mode 100644
index 2bb8834..0000000
--- a/WebCore/platform/graphics/android/FontPlatformData.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * This file is part of the internal font implementation. It should not be included by anyone other than
- * FontMac.cpp, FontWin.cpp and Font.cpp.
- *
- * Copyright 2009, The Android Open Source Project
- * Copyright (C) 2006 Apple Computer, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- */
-
-#ifndef FontPlatformData_H
-#define FontPlatformData_H
-
-#include "StringImpl.h"
-
-class SkPaint;
-class SkTypeface;
-
-namespace WebCore {
-
-class FontPlatformData {
-public:
- static FontPlatformData Deleted() {
- return FontPlatformData(NULL, -1, false, false);
- }
-
- FontPlatformData();
- FontPlatformData(const FontPlatformData&);
- FontPlatformData(SkTypeface*, float textSize, bool fakeBold, bool fakeItalic);
- FontPlatformData(const FontPlatformData& src, float textSize);
- ~FontPlatformData();
-
- FontPlatformData(WTF::HashTableDeletedValueType)
- : mTypeface(hashTableDeletedFontValue()) { }
- bool isHashTableDeletedValue() const {
- return mTypeface == hashTableDeletedFontValue();
- }
-
- FontPlatformData& operator=(const FontPlatformData&);
- bool operator==(const FontPlatformData& a) const;
-
- void setupPaint(SkPaint*) const;
- unsigned hash() const;
-
-private:
- SkTypeface* mTypeface;
- float mTextSize;
- bool mFakeBold;
- bool mFakeItalic;
-
- static SkTypeface* hashTableDeletedFontValue() {
- return reinterpret_cast<SkTypeface*>(-1);
- }
-};
-
-} /* namespace */
-
-#endif
diff --git a/WebCore/platform/graphics/android/FontPlatformDataAndroid.cpp b/WebCore/platform/graphics/android/FontPlatformDataAndroid.cpp
deleted file mode 100644
index e82c1f6..0000000
--- a/WebCore/platform/graphics/android/FontPlatformDataAndroid.cpp
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * This file is part of the internal font implementation. It should not be included by anyone other than
- * FontMac.cpp, FontWin.cpp and Font.cpp.
- *
- * Copyright 2009, The Android Open Source Project
- * Copyright (C) 2006 Apple Computer, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- */
-
-#include "config.h"
-#include "FontPlatformData.h"
-
-#include "SkPaint.h"
-#include "SkTypeface.h"
-
-//#define TRACE_FONTPLATFORMDATA_LIFE
-//#define COUNT_FONTPLATFORMDATA_LIFE
-
-#ifdef COUNT_FONTPLATFORMDATA_LIFE
-static int gCount;
-static int gMaxCount;
-
-static void inc_count()
-{
- if (++gCount > gMaxCount)
- {
- gMaxCount = gCount;
- SkDebugf("---------- FontPlatformData %d\n", gMaxCount);
- }
-}
-
-static void dec_count() { --gCount; }
-#else
- #define inc_count()
- #define dec_count()
-#endif
-
-#ifdef TRACE_FONTPLATFORMDATA_LIFE
- #define trace(num) SkDebugf("FontPlatformData%d %p %g %d %d\n", num, mTypeface, mTextSize, mFakeBold, mFakeItalic)
-#else
- #define trace(num)
-#endif
-
-namespace WebCore {
-
-FontPlatformData::FontPlatformData()
- : mTypeface(NULL), mTextSize(0), mFakeBold(false), mFakeItalic(false)
-{
- inc_count();
- trace(1);
-}
-
-FontPlatformData::FontPlatformData(const FontPlatformData& src)
-{
- if (hashTableDeletedFontValue() != src.mTypeface) {
- src.mTypeface->safeRef();
- }
-
- mTypeface = src.mTypeface;
-
- mTextSize = src.mTextSize;
- mFakeBold = src.mFakeBold;
- mFakeItalic = src.mFakeItalic;
-
- inc_count();
- trace(2);
-}
-
-FontPlatformData::FontPlatformData(SkTypeface* tf, float textSize, bool fakeBold, bool fakeItalic)
- : mTypeface(tf), mTextSize(textSize), mFakeBold(fakeBold), mFakeItalic(fakeItalic)
-{
- if (hashTableDeletedFontValue() != mTypeface) {
- mTypeface->safeRef();
- }
-
- inc_count();
- trace(3);
-}
-
-FontPlatformData::FontPlatformData(const FontPlatformData& src, float textSize)
- : mTypeface(src.mTypeface), mTextSize(textSize), mFakeBold(src.mFakeBold), mFakeItalic(src.mFakeItalic)
-{
- if (hashTableDeletedFontValue() != mTypeface) {
- mTypeface->safeRef();
- }
-
- inc_count();
- trace(4);
-}
-
-FontPlatformData::~FontPlatformData()
-{
- dec_count();
-#ifdef TRACE_FONTPLATFORMDATA_LIFE
- SkDebugf("----------- ~FontPlatformData\n");
-#endif
-
- if (hashTableDeletedFontValue() != mTypeface) {
- mTypeface->safeUnref();
- }
-}
-
-FontPlatformData& FontPlatformData::operator=(const FontPlatformData& src)
-{
- if (hashTableDeletedFontValue() != src.mTypeface) {
- src.mTypeface->safeRef();
- }
- if (hashTableDeletedFontValue() != mTypeface) {
- mTypeface->safeUnref();
- }
-
- mTypeface = src.mTypeface;
- mTextSize = src.mTextSize;
- mFakeBold = src.mFakeBold;
- mFakeItalic = src.mFakeItalic;
-
- return *this;
-}
-
-void FontPlatformData::setupPaint(SkPaint* paint) const
-{
- float ts = mTextSize;
- if (!(ts > 0))
- ts = 12;
-
- paint->setAntiAlias(true);
- paint->setSubpixelText(true);
- paint->setTextSize(SkFloatToScalar(ts));
- paint->setTypeface(mTypeface);
- paint->setFakeBoldText(mFakeBold);
- paint->setTextSkewX(mFakeItalic ? -SK_Scalar1/4 : 0);
- paint->setTextEncoding(SkPaint::kUTF16_TextEncoding);
-}
-
-bool FontPlatformData::operator==(const FontPlatformData& a) const
-{
- return mTypeface == a.mTypeface &&
- mTextSize == a.mTextSize &&
- mFakeBold == a.mFakeBold &&
- mFakeItalic == a.mFakeItalic;
-}
-
-unsigned FontPlatformData::hash() const
-{
- unsigned h;
-
- if (hashTableDeletedFontValue() == mTypeface) {
- h = reinterpret_cast<unsigned>(mTypeface);
- } else {
- h = SkTypeface::UniqueID(mTypeface);
- }
-
- uint32_t sizeAsInt = *reinterpret_cast<const uint32_t*>(&mTextSize);
-
- h ^= 0x01010101 * (((int)mFakeBold << 1) | (int)mFakeItalic);
- h ^= sizeAsInt;
- return h;
-}
-
-}
-
diff --git a/WebCore/platform/graphics/android/GlyphMapAndroid.cpp b/WebCore/platform/graphics/android/GlyphMapAndroid.cpp
deleted file mode 100644
index 1df06b1..0000000
--- a/WebCore/platform/graphics/android/GlyphMapAndroid.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 2009, The Android Open Source Project
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "GlyphPageTreeNode.h"
-#include "SimpleFontData.h"
-
-#include "SkTemplates.h"
-#include "SkPaint.h"
-#include "SkUtils.h"
-
-namespace WebCore {
-
-#define NO_BREAK_SPACE_UNICHAR 0xA0
-
-bool GlyphPage::fill(unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength, const SimpleFontData* fontData)
-{
- if (SkUTF16_IsHighSurrogate(buffer[bufferLength-1])) {
- SkDebugf("%s last char is high-surrogate", __FUNCTION__);
- return false;
- }
-
- SkPaint paint;
- fontData->platformData().setupPaint(&paint);
- paint.setTextEncoding(SkPaint::kUTF16_TextEncoding);
-
- SkAutoSTMalloc <GlyphPage::size, uint16_t> glyphStorage(length);
- uint16_t* glyphs = glyphStorage.get();
- unsigned count = paint.textToGlyphs(buffer, bufferLength << 1, glyphs);
- if (count != length) {
- SkDebugf("%s count != length\n", __FUNCTION__);
- return false;
- }
-
- unsigned allGlyphs = 0; // track if any of the glyphIDs are non-zero
- for (unsigned i = 0; i < length; i++) {
- setGlyphDataForIndex(offset + i, glyphs[i], fontData);
- allGlyphs |= glyphs[i];
- }
- return allGlyphs != 0;
-}
-
-}
-
diff --git a/WebCore/platform/graphics/android/GradientAndroid.cpp b/WebCore/platform/graphics/android/GradientAndroid.cpp
deleted file mode 100644
index 71b7f73..0000000
--- a/WebCore/platform/graphics/android/GradientAndroid.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright 2006, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Gradient.h"
-
-#include "android_graphics.h"
-#include "CSSParser.h"
-#include "GraphicsContext.h"
-#include "NotImplemented.h"
-#include "SkCanvas.h"
-#include "SkColorShader.h"
-#include "SkGradientShader.h"
-#include "SkPaint.h"
-
-class PlatformGradientRec {
-public:
- PlatformGradientRec() : m_shader(NULL) {}
- ~PlatformGradientRec() { m_shader->safeUnref(); }
-
- SkShader* m_shader;
- SkShader::TileMode m_tileMode;
-};
-
-namespace WebCore {
-
-void Gradient::platformDestroy()
-{
- delete m_gradient;
- m_gradient = 0;
-}
-
-static U8CPU F2B(float x)
-{
- return (int)(x * 255);
-}
-
-SkShader* Gradient::getShader(SkShader::TileMode mode) {
- if (NULL == m_gradient) {
- m_gradient = new PlatformGradientRec;
- } else if (m_gradient->m_tileMode == mode) {
- return m_gradient->m_shader;
- }
-
- SkPoint pts[2];
-
- android_setpt(&pts[0], m_p0);
- android_setpt(&pts[1], m_p1);
- size_t count = m_stops.size();
- SkAutoMalloc storage(count * (sizeof(SkColor) + sizeof(SkScalar)));
- SkColor* colors = (SkColor*)storage.get();
- SkScalar* pos = (SkScalar*)(colors + count);
-
- Vector<ColorStop>::iterator iter = m_stops.begin();
- int i = -1;
- while (i++, iter != m_stops.end()) {
- pos[i] = SkFloatToScalar(iter->stop);
- colors[i] = SkColorSetARGB(F2B(iter->alpha), F2B(iter->red),
- F2B(iter->green), F2B(iter->blue));
- ++iter;
- }
-
- SkShader* s;
- if (0 == count) {
- // it seems the spec says a zero-size gradient draws transparent
- s = new SkColorShader(0);
- } else if (m_radial) {
- s = SkGradientShader::CreateRadial(pts[0], SkFloatToScalar(m_r0),
- colors, pos, count, mode);
- } else {
- s = SkGradientShader::CreateLinear(pts, colors, pos, count, mode);
- }
-
- m_gradient->m_shader->safeUnref();
- m_gradient->m_shader = s;
- m_gradient->m_tileMode = mode;
- return s;
-}
-
-void Gradient::fill(GraphicsContext* context, const FloatRect& rect)
-{
- SkRect r;
- SkPaint paint;
- // we don't care about the mode, so try to use the existing one
- SkShader::TileMode mode = m_gradient ? m_gradient->m_tileMode :
- SkShader::kClamp_TileMode;
-
- paint.setAntiAlias(true);
- paint.setShader(this->getShader(mode));
- android_gc2canvas(context)->drawRect(*android_setrect(&r, rect), paint);
-}
-
-
-} //namespace
diff --git a/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp b/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp
deleted file mode 100644
index c2e0f02..0000000
--- a/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp
+++ /dev/null
@@ -1,1118 +0,0 @@
-/*
- * Copyright 2006, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Gradient.h"
-#include "GraphicsContext.h"
-#include "GraphicsContextPrivate.h"
-#include "NotImplemented.h"
-#include "Path.h"
-#include "Pattern.h"
-
-#include "SkBlurDrawLooper.h"
-#include "SkBlurMaskFilter.h"
-#include "SkCanvas.h"
-#include "SkColorPriv.h"
-#include "SkDashPathEffect.h"
-#include "SkDevice.h"
-#include "SkPaint.h"
-#include "SkPorterDuff.h"
-#include "PlatformGraphicsContext.h"
-#include "AffineTransform.h"
-
-#include "android_graphics.h"
-#include "SkGradientShader.h"
-#include "SkBitmapRef.h"
-#include "SkString.h"
-
-using namespace std;
-
-#define GC2Canvas(ctx) (ctx)->m_data->mPgc->mCanvas
-
-namespace WebCore {
-
-static int RoundToInt(float x)
-{
- return (int)roundf(x);
-}
-
-template <typename T> T* deepCopyPtr(const T* src) {
- return src ? new T(*src) : NULL;
-}
-
-/* TODO / questions
-
- mAlpha: how does this interact with the alpha in Color? multiply them together?
- mPorterDuffMode: do I always respect this? If so, then
- the rgb() & 0xFF000000 check will abort drawing too often
- Is Color premultiplied or not? If it is, then I can't blindly pass it to paint.setColor()
-*/
-
-struct ShadowRec {
- SkScalar mBlur; // >0 means valid shadow
- SkScalar mDx;
- SkScalar mDy;
- SkColor mColor;
-};
-
-class GraphicsContextPlatformPrivate {
-public:
- GraphicsContext* mCG; // back-ptr to our parent
- PlatformGraphicsContext* mPgc;
-
- struct State {
- SkPath* mPath;
- float mMiterLimit;
- float mAlpha;
- float mStrokeThickness;
- SkPaint::Cap mLineCap;
- SkPaint::Join mLineJoin;
- SkPorterDuff::Mode mPorterDuffMode;
- int mDashRatio; //ratio of the length of a dash to its width
- ShadowRec mShadow;
- SkColor mFillColor;
- SkColor mStrokeColor;
- bool mUseAA;
-
- State() {
- mPath = NULL; // lazily allocated
- mMiterLimit = 4;
- mAlpha = 1;
- mStrokeThickness = 0.0f; // Same as default in GraphicsContextPrivate.h
- mLineCap = SkPaint::kDefault_Cap;
- mLineJoin = SkPaint::kDefault_Join;
- mPorterDuffMode = SkPorterDuff::kSrcOver_Mode;
- mDashRatio = 3;
- mUseAA = true;
- mShadow.mBlur = 0;
- mFillColor = SK_ColorBLACK;
- mStrokeColor = SK_ColorBLACK;
- }
-
- State(const State& other) {
- memcpy(this, &other, sizeof(State));
- mPath = deepCopyPtr<SkPath>(other.mPath);
- }
-
- ~State() {
- delete mPath;
- }
-
- void setShadow(int radius, int dx, int dy, SkColor c) {
- // cut the radius in half, to visually match the effect seen in
- // safari browser
- mShadow.mBlur = SkScalarHalf(SkIntToScalar(radius));
- mShadow.mDx = SkIntToScalar(dx);
- mShadow.mDy = SkIntToScalar(dy);
- mShadow.mColor = c;
- }
-
- bool setupShadowPaint(SkPaint* paint, SkPoint* offset) {
- if (mShadow.mBlur > 0) {
- paint->setAntiAlias(true);
- paint->setDither(true);
- paint->setPorterDuffXfermode(mPorterDuffMode);
- paint->setColor(mShadow.mColor);
- paint->setMaskFilter(SkBlurMaskFilter::Create(mShadow.mBlur,
- SkBlurMaskFilter::kNormal_BlurStyle))->unref();
- offset->set(mShadow.mDx, mShadow.mDy);
- return true;
- }
- return false;
- }
-
- SkColor applyAlpha(SkColor c) const
- {
- int s = RoundToInt(mAlpha * 256);
- if (s >= 256)
- return c;
- if (s < 0)
- return 0;
-
- int a = SkAlphaMul(SkColorGetA(c), s);
- return (c & 0x00FFFFFF) | (a << 24);
- }
- };
-
- SkDeque mStateStack;
- State* mState;
-
- GraphicsContextPlatformPrivate(GraphicsContext* cg, PlatformGraphicsContext* pgc)
- : mCG(cg)
- , mPgc(pgc), mStateStack(sizeof(State)) {
- State* state = (State*)mStateStack.push_back();
- new (state) State();
- mState = state;
- }
-
- ~GraphicsContextPlatformPrivate() {
- if (mPgc && mPgc->deleteUs())
- delete mPgc;
-
- // we force restores so we don't leak any subobjects owned by our
- // stack of State records.
- while (mStateStack.count() > 0)
- this->restore();
- }
-
- void save() {
- State* newState = (State*)mStateStack.push_back();
- new (newState) State(*mState);
- mState = newState;
- }
-
- void restore() {
- mState->~State();
- mStateStack.pop_back();
- mState = (State*)mStateStack.back();
- }
-
- void setFillColor(const Color& c) {
- mState->mFillColor = c.rgb();
- }
-
- void setStrokeColor(const Color& c) {
- mState->mStrokeColor = c.rgb();
- }
-
- void setStrokeThickness(float f) {
- mState->mStrokeThickness = f;
- }
-
- void beginPath() {
- if (mState->mPath) {
- mState->mPath->reset();
- }
- }
-
- void addPath(const SkPath& other) {
- if (!mState->mPath) {
- mState->mPath = new SkPath(other);
- } else {
- mState->mPath->addPath(other);
- }
- }
-
- // may return null
- SkPath* getPath() const { return mState->mPath; }
-
- void setup_paint_common(SkPaint* paint) const {
- paint->setAntiAlias(mState->mUseAA);
- paint->setDither(true);
- paint->setPorterDuffXfermode(mState->mPorterDuffMode);
- if (mState->mShadow.mBlur > 0) {
- SkDrawLooper* looper = new SkBlurDrawLooper(mState->mShadow.mBlur,
- mState->mShadow.mDx,
- mState->mShadow.mDy,
- mState->mShadow.mColor);
- paint->setLooper(looper)->unref();
- }
-
- /* need to sniff textDrawingMode(), which returns the bit_OR of...
- const int cTextInvisible = 0;
- const int cTextFill = 1;
- const int cTextStroke = 2;
- const int cTextClip = 4;
- */
- }
-
- void setup_paint_fill(SkPaint* paint) const {
- this->setup_paint_common(paint);
- paint->setColor(mState->mFillColor);
- }
-
- /* sets up the paint for stroking. Returns true if the style is really
- just a dash of squares (the size of the paint's stroke-width.
- */
- bool setup_paint_stroke(SkPaint* paint, SkRect* rect) {
- this->setup_paint_common(paint);
- paint->setColor(mState->mStrokeColor);
-
- float width = mState->mStrokeThickness;
-
- // this allows dashing and dotting to work properly for hairline strokes
- // FIXME: Should we only do this for dashed and dotted strokes?
- if (0 == width) {
- width = 1;
- }
-
-// paint->setColor(mState->applyAlpha(mCG->strokeColor().rgb()));
- paint->setStyle(SkPaint::kStroke_Style);
- paint->setStrokeWidth(SkFloatToScalar(width));
- paint->setStrokeCap(mState->mLineCap);
- paint->setStrokeJoin(mState->mLineJoin);
- paint->setStrokeMiter(SkFloatToScalar(mState->mMiterLimit));
-
- if (rect != NULL && (RoundToInt(width) & 1)) {
- rect->inset(-SK_ScalarHalf, -SK_ScalarHalf);
- }
-
- switch (mCG->strokeStyle()) {
- case NoStroke:
- case SolidStroke:
- width = 0;
- break;
- case DashedStroke:
- width = mState->mDashRatio * width;
- break;
- /* no break */
- case DottedStroke:
- break;
- }
-
- if (width > 0) {
- SkScalar intervals[] = { width, width };
- SkPathEffect* pe = new SkDashPathEffect(intervals, 2, 0);
- paint->setPathEffect(pe)->unref();
- // return true if we're basically a dotted dash of squares
- return RoundToInt(width) == RoundToInt(paint->getStrokeWidth());
- }
- return false;
- }
-
-private:
- // not supported yet
- State& operator=(const State&);
-};
-
-static SkShader::TileMode SpreadMethod2TileMode(GradientSpreadMethod sm) {
- SkShader::TileMode mode = SkShader::kClamp_TileMode;
-
- switch (sm) {
- case SpreadMethodPad:
- mode = SkShader::kClamp_TileMode;
- break;
- case SpreadMethodReflect:
- mode = SkShader::kMirror_TileMode;
- break;
- case SpreadMethodRepeat:
- mode = SkShader::kRepeat_TileMode;
- break;
- }
- return mode;
-}
-
-static void extactShader(SkPaint* paint, ColorSpace cs, Pattern* pat,
- Gradient* grad, GradientSpreadMethod sm) {
- switch (cs) {
- case PatternColorSpace:
- // createPlatformPattern() returns a new inst
- paint->setShader(pat->createPlatformPattern(
- AffineTransform()))->safeUnref();
- break;
- case GradientColorSpace: {
- // grad->getShader() returns a cached obj
- paint->setShader(grad->getShader(SpreadMethod2TileMode(sm)));
- break;
- }
- default:
- break;
- }
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-
-GraphicsContext* GraphicsContext::createOffscreenContext(int width, int height)
-{
- PlatformGraphicsContext* pgc = new PlatformGraphicsContext();
-
- SkBitmap bitmap;
-
- bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
- bitmap.allocPixels();
- bitmap.eraseColor(0);
- pgc->mCanvas->setBitmapDevice(bitmap);
-
- GraphicsContext* ctx = new GraphicsContext(pgc);
-//printf("-------- create offscreen <canvas> %p\n", ctx);
- return ctx;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-
-GraphicsContext::GraphicsContext(PlatformGraphicsContext *gc)
- : m_common(createGraphicsContextPrivate())
- , m_data(new GraphicsContextPlatformPrivate(this, gc))
-{
- setPaintingDisabled(NULL == gc || NULL == gc->mCanvas);
-}
-
-GraphicsContext::~GraphicsContext()
-{
- delete m_data;
- this->destroyGraphicsContextPrivate(m_common);
-}
-
-void GraphicsContext::savePlatformState()
-{
- // save our private State
- m_data->save();
- // save our native canvas
- GC2Canvas(this)->save();
-}
-
-void GraphicsContext::restorePlatformState()
-{
- // restore our native canvas
- GC2Canvas(this)->restore();
- // restore our private State
- m_data->restore();
-}
-
-bool GraphicsContext::willFill() const {
- return m_data->mState->mFillColor != 0;
-}
-
-bool GraphicsContext::willStroke() const {
- return m_data->mState->mStrokeColor != 0;
-}
-
-// Draws a filled rectangle with a stroked border.
-void GraphicsContext::drawRect(const IntRect& rect)
-{
- if (paintingDisabled())
- return;
-
- SkPaint paint;
- SkRect r;
-
- android_setrect(&r, rect);
-
- if (fillColor().alpha()) {
- m_data->setup_paint_fill(&paint);
- GC2Canvas(this)->drawRect(r, paint);
- }
-
- if (strokeStyle() != NoStroke && strokeColor().alpha()) {
- paint.reset();
- m_data->setup_paint_stroke(&paint, &r);
- GC2Canvas(this)->drawRect(r, paint);
- }
-}
-
-// This is only used to draw borders.
-void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2)
-{
- if (paintingDisabled())
- return;
-
- StrokeStyle style = strokeStyle();
- if (style == NoStroke)
- return;
-
- SkPaint paint;
- SkCanvas* canvas = GC2Canvas(this);
- const int idx = SkAbs32(point2.x() - point1.x());
- const int idy = SkAbs32(point2.y() - point1.y());
-
- // special-case horizontal and vertical lines that are really just dots
- if (m_data->setup_paint_stroke(&paint, NULL) && (0 == idx || 0 == idy)) {
- const SkScalar diameter = paint.getStrokeWidth();
- const SkScalar radius = SkScalarHalf(diameter);
- SkScalar x = SkIntToScalar(SkMin32(point1.x(), point2.x()));
- SkScalar y = SkIntToScalar(SkMin32(point1.y(), point2.y()));
- SkScalar dx, dy;
- int count;
- SkRect bounds;
-
- if (0 == idy) { // horizontal
- bounds.set(x, y - radius, x + SkIntToScalar(idx), y + radius);
- x += radius;
- dx = diameter * 2;
- dy = 0;
- count = idx;
- } else { // vertical
- bounds.set(x - radius, y, x + radius, y + SkIntToScalar(idy));
- y += radius;
- dx = 0;
- dy = diameter * 2;
- count = idy;
- }
-
- // the actual count is the number of ONs we hit alternating
- // ON(diameter), OFF(diameter), ...
- {
- SkScalar width = SkScalarDiv(SkIntToScalar(count), diameter);
- // now computer the number of cells (ON and OFF)
- count = SkScalarRound(width);
- // now compute the number of ONs
- count = (count + 1) >> 1;
- }
-
- SkAutoMalloc storage(count * sizeof(SkPoint));
- SkPoint* verts = (SkPoint*)storage.get();
- // now build the array of vertices to past to drawPoints
- for (int i = 0; i < count; i++) {
- verts[i].set(x, y);
- x += dx;
- y += dy;
- }
-
- paint.setStyle(SkPaint::kFill_Style);
- paint.setPathEffect(NULL);
-
- // clipping to bounds is not required for correctness, but it does
- // allow us to reject the entire array of points if we are completely
- // offscreen. This is common in a webpage for android, where most of
- // the content is clipped out. If drawPoints took an (optional) bounds
- // parameter, that might even be better, as we would *just* use it for
- // culling, and not both wacking the canvas' save/restore stack.
- canvas->save(SkCanvas::kClip_SaveFlag);
- canvas->clipRect(bounds);
- canvas->drawPoints(SkCanvas::kPoints_PointMode, count, verts, paint);
- canvas->restore();
- } else {
- SkPoint pts[2];
- android_setpt(&pts[0], point1);
- android_setpt(&pts[1], point2);
- canvas->drawLine(pts[0].fX, pts[0].fY, pts[1].fX, pts[1].fY, paint);
- }
-}
-
-static void setrect_for_underline(SkRect* r, GraphicsContext* context, const IntPoint& point, int yOffset, int width)
-{
- float lineThickness = context->strokeThickness();
-// if (lineThickness < 1) // do we really need/want this?
-// lineThickness = 1;
-
- yOffset += 1; // we add 1 to have underlines appear below the text
-
- r->fLeft = SkIntToScalar(point.x());
- r->fTop = SkIntToScalar(point.y() + yOffset);
- r->fRight = r->fLeft + SkIntToScalar(width);
- r->fBottom = r->fTop + SkFloatToScalar(lineThickness);
-}
-
-void GraphicsContext::drawLineForText(IntPoint const& pt, int width, bool)
-{
- if (paintingDisabled())
- return;
-
- SkRect r;
- setrect_for_underline(&r, this, pt, 0, width);
-
- SkPaint paint;
- paint.setAntiAlias(true);
- paint.setColor(this->strokeColor().rgb());
-
- GC2Canvas(this)->drawRect(r, paint);
-}
-
-void GraphicsContext::drawLineForMisspellingOrBadGrammar(const IntPoint& pt, int width, bool grammar)
-{
- if (paintingDisabled())
- return;
-
- SkRect r;
- setrect_for_underline(&r, this, pt, 0, width);
-
- SkPaint paint;
- paint.setAntiAlias(true);
- paint.setColor(SK_ColorRED); // is this specified somewhere?
-
- GC2Canvas(this)->drawRect(r, paint);
-}
-
-// This method is only used to draw the little circles used in lists.
-void GraphicsContext::drawEllipse(const IntRect& rect)
-{
- if (paintingDisabled())
- return;
-
- SkPaint paint;
- SkRect oval;
-
- android_setrect(&oval, rect);
-
- if (fillColor().rgb() & 0xFF000000) {
- m_data->setup_paint_fill(&paint);
- GC2Canvas(this)->drawOval(oval, paint);
- }
- if (strokeStyle() != NoStroke) {
- paint.reset();
- m_data->setup_paint_stroke(&paint, &oval);
- GC2Canvas(this)->drawOval(oval, paint);
- }
-}
-
-static inline int fast_mod(int value, int max)
-{
- int sign = SkExtractSign(value);
-
- value = SkApplySign(value, sign);
- if (value >= max) {
- value %= max;
- }
- return SkApplySign(value, sign);
-}
-
-void GraphicsContext::strokeArc(const IntRect& r, int startAngle, int angleSpan)
-{
- if (paintingDisabled())
- return;
-
- SkPath path;
- SkPaint paint;
- SkRect oval;
-
- android_setrect(&oval, r);
-
- if (strokeStyle() == NoStroke) {
- m_data->setup_paint_fill(&paint); // we want the fill color
- paint.setStyle(SkPaint::kStroke_Style);
- paint.setStrokeWidth(SkFloatToScalar(this->strokeThickness()));
- }
- else {
- m_data->setup_paint_stroke(&paint, NULL);
- }
-
- // we do this before converting to scalar, so we don't overflow SkFixed
- startAngle = fast_mod(startAngle, 360);
- angleSpan = fast_mod(angleSpan, 360);
-
- path.addArc(oval, SkIntToScalar(-startAngle), SkIntToScalar(-angleSpan));
- GC2Canvas(this)->drawPath(path, paint);
-}
-
-void GraphicsContext::drawConvexPolygon(size_t numPoints, const FloatPoint* points, bool shouldAntialias)
-{
- if (paintingDisabled())
- return;
-
- if (numPoints <= 1)
- return;
-
- SkPaint paint;
- SkPath path;
-
- path.incReserve(numPoints);
- path.moveTo(SkFloatToScalar(points[0].x()), SkFloatToScalar(points[0].y()));
- for (size_t i = 1; i < numPoints; i++)
- path.lineTo(SkFloatToScalar(points[i].x()), SkFloatToScalar(points[i].y()));
-
- if (GC2Canvas(this)->quickReject(path, shouldAntialias ?
- SkCanvas::kAA_EdgeType : SkCanvas::kBW_EdgeType)) {
- return;
- }
-
- if (fillColor().rgb() & 0xFF000000) {
- m_data->setup_paint_fill(&paint);
- paint.setAntiAlias(shouldAntialias);
- GC2Canvas(this)->drawPath(path, paint);
- }
-
- if (strokeStyle() != NoStroke) {
- paint.reset();
- m_data->setup_paint_stroke(&paint, NULL);
- paint.setAntiAlias(shouldAntialias);
- GC2Canvas(this)->drawPath(path, paint);
- }
-}
-
-void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLeft, const IntSize& topRight,
- const IntSize& bottomLeft, const IntSize& bottomRight, const Color& color)
-{
- if (paintingDisabled())
- return;
-
- SkPaint paint;
- SkPath path;
- SkScalar radii[8];
- SkRect r;
-
- radii[0] = SkIntToScalar(topLeft.width());
- radii[1] = SkIntToScalar(topLeft.height());
- radii[2] = SkIntToScalar(topRight.width());
- radii[3] = SkIntToScalar(topRight.height());
- radii[4] = SkIntToScalar(bottomRight.width());
- radii[5] = SkIntToScalar(bottomRight.height());
- radii[6] = SkIntToScalar(bottomLeft.width());
- radii[7] = SkIntToScalar(bottomLeft.height());
- path.addRoundRect(*android_setrect(&r, rect), radii);
-
- m_data->setup_paint_fill(&paint);
- GC2Canvas(this)->drawPath(path, paint);
-}
-
-void GraphicsContext::fillRect(const FloatRect& rect)
-{
- SkPaint paint;
- SkRect r;
-
- android_setrect(&r, rect);
- m_data->setup_paint_fill(&paint);
-
- extactShader(&paint, m_common->state.fillColorSpace,
- m_common->state.fillPattern.get(),
- m_common->state.fillGradient.get(), spreadMethod());
-
- GC2Canvas(this)->drawRect(r, paint);
-}
-
-void GraphicsContext::fillRect(const FloatRect& rect, const Color& color)
-{
- if (paintingDisabled())
- return;
-
- if (color.rgb() & 0xFF000000) {
- SkPaint paint;
- SkRect r;
-
- android_setrect(&r, rect);
- m_data->setup_paint_common(&paint);
- paint.setColor(color.rgb()); // punch in the specified color
- paint.setShader(NULL); // in case we had one set
- GC2Canvas(this)->drawRect(r, paint);
- }
-}
-
-void GraphicsContext::clip(const FloatRect& rect)
-{
- if (paintingDisabled())
- return;
-
- SkRect r;
-
- GC2Canvas(this)->clipRect(*android_setrect(&r, rect));
-}
-
-void GraphicsContext::clip(const Path& path)
-{
- if (paintingDisabled())
- return;
-
-// path.platformPath()->dump(false, "clip path");
-
- GC2Canvas(this)->clipPath(*path.platformPath());
-}
-
-void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect, int thickness)
-{
- if (paintingDisabled())
- return;
-
-//printf("-------- addInnerRoundedRectClip: [%d %d %d %d] thickness=%d\n", rect.x(), rect.y(), rect.width(), rect.height(), thickness);
-
- SkPath path;
- SkRect r;
- android_setrect(&r, rect);
- path.addOval(r, SkPath::kCW_Direction);
- // only perform the inset if we won't invert r
- if (2*thickness < rect.width() && 2*thickness < rect.height())
- {
- r.inset(SkIntToScalar(thickness) ,SkIntToScalar(thickness));
- path.addOval(r, SkPath::kCCW_Direction);
- }
- GC2Canvas(this)->clipPath(path);
-}
-
-void GraphicsContext::clipOut(const IntRect& r)
-{
- if (paintingDisabled())
- return;
-
- SkRect rect;
-
- GC2Canvas(this)->clipRect(*android_setrect(&rect, r), SkRegion::kDifference_Op);
-}
-
-void GraphicsContext::clipOutEllipseInRect(const IntRect& r)
-{
- if (paintingDisabled())
- return;
-
- SkRect oval;
- SkPath path;
-
- path.addOval(*android_setrect(&oval, r), SkPath::kCCW_Direction);
- GC2Canvas(this)->clipPath(path, SkRegion::kDifference_Op);
-}
-
-void GraphicsContext::clipOut(const Path& p)
-{
- if (paintingDisabled())
- return;
-
- GC2Canvas(this)->clipPath(*p.platformPath(), SkRegion::kDifference_Op);
-}
-
-void GraphicsContext::clipToImageBuffer(const FloatRect&, const ImageBuffer*) {
- SkDebugf("xxxxxxxxxxxxxxxxxx clipToImageBuffer not implemented\n");
-}
-
-//////////////////////////////////////////////////////////////////////////////////////////////////
-
-#if SVG_SUPPORT
-KRenderingDeviceContext* GraphicsContext::createRenderingDeviceContext()
-{
- return new KRenderingDeviceContextQuartz(platformContext());
-}
-#endif
-
-void GraphicsContext::beginTransparencyLayer(float opacity)
-{
- if (paintingDisabled())
- return;
-
- SkCanvas* canvas = GC2Canvas(this);
-
- if (opacity < 1)
- {
- canvas->saveLayerAlpha(NULL, (int)(opacity * 255), SkCanvas::kHasAlphaLayer_SaveFlag);
- }
- else
- canvas->save();
-}
-
-void GraphicsContext::endTransparencyLayer()
-{
- if (paintingDisabled())
- return;
-
- GC2Canvas(this)->restore();
-}
-
- ///////////////////////////////////////////////////////////////////////////
-
- void GraphicsContext::setupFillPaint(SkPaint* paint) {
- m_data->setup_paint_fill(paint);
- }
-
- void GraphicsContext::setupStrokePaint(SkPaint* paint) {
- m_data->setup_paint_stroke(paint, NULL);
- }
-
- bool GraphicsContext::setupShadowPaint(SkPaint* paint, SkPoint* offset) {
- return m_data->mState->setupShadowPaint(paint, offset);
- }
-
- // referenced from CanvasStyle.cpp
- void GraphicsContext::setCMYKAFillColor(float c, float m, float y, float k, float a) {
- float r = 1 - (c + k);
- float g = 1 - (m + k);
- float b = 1 - (y + k);
- return this->setFillColor(Color(r, g, b, a));
- }
-
- // referenced from CanvasStyle.cpp
- void GraphicsContext::setCMYKAStrokeColor(float c, float m, float y, float k, float a) {
- float r = 1 - (c + k);
- float g = 1 - (m + k);
- float b = 1 - (y + k);
- return this->setStrokeColor(Color(r, g, b, a));
- }
-
- void GraphicsContext::setPlatformStrokeColor(const Color& c) {
- m_data->setStrokeColor(c);
- }
-
- void GraphicsContext::setPlatformStrokeThickness(float f) {
- m_data->setStrokeThickness(f);
- }
-
- void GraphicsContext::setPlatformFillColor(const Color& c) {
- m_data->setFillColor(c);
- }
-
-void GraphicsContext::setPlatformShadow(const IntSize& size, int blur, const Color& color)
-{
- if (paintingDisabled())
- return;
-
- if (blur <= 0) {
- this->clearPlatformShadow();
- }
-
- SkColor c;
- if (color.isValid()) {
- c = color.rgb();
- } else {
- c = SkColorSetARGB(0xFF/3, 0, 0, 0); // "std" Apple shadow color
- }
- m_data->mState->setShadow(blur, size.width(), size.height(), c);
-}
-
-void GraphicsContext::clearPlatformShadow()
-{
- if (paintingDisabled())
- return;
-
- m_data->mState->setShadow(0, 0, 0, 0);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-void GraphicsContext::drawFocusRing(const Color& color)
-{
- // Do nothing, since we draw the focus ring independently.
-}
-
-PlatformGraphicsContext* GraphicsContext::platformContext() const
-{
- ASSERT(!paintingDisabled());
- return m_data->mPgc;
-}
-
-void GraphicsContext::setMiterLimit(float limit)
-{
- m_data->mState->mMiterLimit = limit;
-}
-
-void GraphicsContext::setAlpha(float alpha)
-{
- m_data->mState->mAlpha = alpha;
-}
-
-void GraphicsContext::setCompositeOperation(CompositeOperator op)
-{
- m_data->mState->mPorterDuffMode = android_convert_compositeOp(op);
-}
-
-void GraphicsContext::clearRect(const FloatRect& rect)
-{
- if (paintingDisabled())
- return;
-
- SkPaint paint;
- SkRect r;
-
- android_setrect(&r, rect);
- m_data->setup_paint_fill(&paint);
- paint.setPorterDuffXfermode(SkPorterDuff::kClear_Mode);
- GC2Canvas(this)->drawRect(r, paint);
-}
-
-void GraphicsContext::strokeRect(const FloatRect& rect, float lineWidth)
-{
- if (paintingDisabled())
- return;
-
- SkPaint paint;
- SkRect r;
-
- android_setrect(&r, rect);
-
- m_data->setup_paint_stroke(&paint, NULL);
- paint.setStrokeWidth(SkFloatToScalar(lineWidth));
- GC2Canvas(this)->drawRect(r, paint);
-}
-
-void GraphicsContext::setLineCap(LineCap cap)
-{
- switch (cap) {
- case ButtCap:
- m_data->mState->mLineCap = SkPaint::kButt_Cap;
- break;
- case RoundCap:
- m_data->mState->mLineCap = SkPaint::kRound_Cap;
- break;
- case SquareCap:
- m_data->mState->mLineCap = SkPaint::kSquare_Cap;
- break;
- default:
- SkDEBUGF(("GraphicsContext::setLineCap: unknown LineCap %d\n", cap));
- break;
- }
-}
-
-void GraphicsContext::setLineJoin(LineJoin join)
-{
- switch (join) {
- case MiterJoin:
- m_data->mState->mLineJoin = SkPaint::kMiter_Join;
- break;
- case RoundJoin:
- m_data->mState->mLineJoin = SkPaint::kRound_Join;
- break;
- case BevelJoin:
- m_data->mState->mLineJoin = SkPaint::kBevel_Join;
- break;
- default:
- SkDEBUGF(("GraphicsContext::setLineJoin: unknown LineJoin %d\n", join));
- break;
- }
-}
-
-void GraphicsContext::scale(const FloatSize& size)
-{
- if (paintingDisabled())
- return;
- GC2Canvas(this)->scale(SkFloatToScalar(size.width()), SkFloatToScalar(size.height()));
-}
-
-void GraphicsContext::rotate(float angleInRadians)
-{
- if (paintingDisabled())
- return;
- GC2Canvas(this)->rotate(SkFloatToScalar(angleInRadians * (180.0f / 3.14159265f)));
-}
-
-void GraphicsContext::translate(float x, float y)
-{
- if (paintingDisabled())
- return;
- GC2Canvas(this)->translate(SkFloatToScalar(x), SkFloatToScalar(y));
-}
-
-void GraphicsContext::concatCTM(const AffineTransform& xform)
-{
- if (paintingDisabled())
- return;
-
-//printf("-------------- GraphicsContext::concatCTM\n");
- GC2Canvas(this)->concat((SkMatrix) xform);
-}
-
-FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& rect)
-{
- if (paintingDisabled())
- return FloatRect();
-
- const SkMatrix& matrix = GC2Canvas(this)->getTotalMatrix();
- SkRect r;
- android_setrect(&r, rect);
- matrix.mapRect(&r);
- FloatRect result(SkScalarToFloat(r.fLeft), SkScalarToFloat(r.fTop), SkScalarToFloat(r.width()), SkScalarToFloat(r.height()));
- return result;
-}
-
-//////////////////////////////////////////////////////////////////////////////////////////////////
-
-void GraphicsContext::setURLForRect(const KURL& link, const IntRect& destRect)
-{
-// appears to be PDF specific, so we ignore it
-#if 0
-if (paintingDisabled())
- return;
-
-CFURLRef urlRef = link.createCFURL();
-if (urlRef) {
- CGContextRef context = platformContext();
-
- // Get the bounding box to handle clipping.
- CGRect box = CGContextGetClipBoundingBox(context);
-
- IntRect intBox((int)box.origin.x, (int)box.origin.y, (int)box.size.width, (int)box.size.height);
- IntRect rect = destRect;
- rect.intersect(intBox);
-
- CGPDFContextSetURLForRect(context, urlRef,
- CGRectApplyAffineTransform(rect, CGContextGetCTM(context)));
-
- CFRelease(urlRef);
-}
-#endif
-}
-
-void GraphicsContext::setUseAntialiasing(bool useAA) {
- if (paintingDisabled())
- return;
- m_data->mState->mUseAA = useAA;
-}
-
-AffineTransform GraphicsContext::getCTM() const {
- return AffineTransform(GC2Canvas(this)->getTotalMatrix());
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-void GraphicsContext::beginPath() {
- m_data->beginPath();
-}
-
-void GraphicsContext::addPath(const Path& p) {
- m_data->addPath(*p.platformPath());
-}
-
-void GraphicsContext::drawPath() {
- this->fillPath();
- this->strokePath();
-}
-
-void GraphicsContext::fillPath() {
- SkPath* path = m_data->getPath();
- if (paintingDisabled() || !path)
- return;
-
- switch (this->fillRule()) {
- case RULE_NONZERO:
- path->setFillType(SkPath::kWinding_FillType);
- break;
- case RULE_EVENODD:
- path->setFillType(SkPath::kEvenOdd_FillType);
- break;
- }
-
- SkPaint paint;
- m_data->setup_paint_fill(&paint);
-
- extactShader(&paint, m_common->state.fillColorSpace,
- m_common->state.fillPattern.get(),
- m_common->state.fillGradient.get(), spreadMethod());
-
- GC2Canvas(this)->drawPath(*path, paint);
-}
-
-void GraphicsContext::strokePath() {
- const SkPath* path = m_data->getPath();
- if (paintingDisabled() || !path || strokeStyle() == NoStroke)
- return;
-
- SkPaint paint;
- m_data->setup_paint_stroke(&paint, NULL);
-
- extactShader(&paint, m_common->state.strokeColorSpace,
- m_common->state.strokePattern.get(),
- m_common->state.strokeGradient.get(), spreadMethod());
-
- GC2Canvas(this)->drawPath(*path, paint);
-}
-
-void GraphicsContext::setImageInterpolationQuality(InterpolationQuality mode)
-{
- /*
- enum InterpolationQuality {
- InterpolationDefault,
- InterpolationNone,
- InterpolationLow,
- InterpolationMedium,
- InterpolationHigh
- };
-
- TODO: record this, so we can know when to use bitmap-filtering when we draw
- ... not sure how meaningful this will be given our playback model.
-
- Certainly safe to do nothing for the present.
- */
-}
-
-} // namespace WebCore
-
-///////////////////////////////////////////////////////////////////////////////
-
-SkCanvas* android_gc2canvas(WebCore::GraphicsContext* gc) {
- return gc->platformContext()->mCanvas;
-}
-
diff --git a/WebCore/platform/graphics/android/ImageAndroid.cpp b/WebCore/platform/graphics/android/ImageAndroid.cpp
deleted file mode 100644
index 04235d5..0000000
--- a/WebCore/platform/graphics/android/ImageAndroid.cpp
+++ /dev/null
@@ -1,297 +0,0 @@
-/*
- * Copyright 2009, The Android Open Source Project
- * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "AffineTransform.h"
-#include "BitmapImage.h"
-#include "Image.h"
-#include "FloatRect.h"
-#include "GraphicsContext.h"
-#include "PlatformGraphicsContext.h"
-#include "PlatformString.h"
-#include "SharedBuffer.h"
-
-#include "android_graphics.h"
-#include "SkBitmapRef.h"
-#include "SkCanvas.h"
-#include "SkColorPriv.h"
-#include "SkImageDecoder.h"
-#include "SkShader.h"
-#include "SkString.h"
-#include "SkTemplates.h"
-
-#include <utils/AssetManager.h>
-
-//#define TRACE_SUBSAMPLED_BITMAPS
-//#define TRACE_SKIPPED_BITMAPS
-
-android::AssetManager* globalAssetManager() {
- static android::AssetManager* gGlobalAssetMgr;
- if (!gGlobalAssetMgr) {
- gGlobalAssetMgr = new android::AssetManager();
- gGlobalAssetMgr->addDefaultAssets();
- }
- return gGlobalAssetMgr;
-}
-
-namespace WebCore {
-
-void FrameData::clear()
-{
- if (m_frame) {
- m_frame->unref();
- m_frame = 0;
- m_duration = 0.;
- m_hasAlpha = true;
- }
-}
-
-BitmapImage::BitmapImage(SkBitmapRef* ref, ImageObserver* observer)
- : Image(observer)
- , m_currentFrame(0)
- , m_frames(0)
- , m_frameTimer(0)
- , m_repetitionCount(0)
- , m_repetitionsComplete(0)
- , m_isSolidColor(false)
- , m_animationFinished(true)
- , m_allDataReceived(true)
- , m_haveSize(true)
- , m_sizeAvailable(true)
- , m_decodedSize(0)
- , m_haveFrameCount(true)
- , m_frameCount(1)
-{
- initPlatformData();
-
- m_size = IntSize(ref->bitmap().width(), ref->bitmap().height());
-
- m_frames.grow(1);
- m_frames[0].m_frame = ref;
- m_frames[0].m_hasAlpha = !ref->bitmap().isOpaque();
- checkForSolidColor();
- ref->ref();
-}
-
-
-void BitmapImage::initPlatformData()
-{
- m_source.clearURL();
-}
-
-void BitmapImage::invalidatePlatformData()
-{
-}
-
-void BitmapImage::checkForSolidColor()
-{
- m_isSolidColor = false;
- if (frameCount() == 1) {
- SkBitmapRef* ref = frameAtIndex(0);
- if (!ref) {
- return; // keep solid == false
- }
-
- const SkBitmap& bm = ref->bitmap();
- if (bm.width() != 1 || bm.height() != 1) {
- return; // keep solid == false
- }
-
- SkAutoLockPixels alp(bm);
- if (!bm.readyToDraw()) {
- return; // keep solid == false
- }
-
- SkPMColor color;
- switch (bm.getConfig()) {
- case SkBitmap::kARGB_8888_Config:
- color = *bm.getAddr32(0, 0);
- break;
- case SkBitmap::kRGB_565_Config:
- color = SkPixel16ToPixel32(*bm.getAddr16(0, 0));
- break;
- case SkBitmap::kIndex8_Config: {
- SkColorTable* ctable = bm.getColorTable();
- if (!ctable) {
- return;
- }
- color = (*ctable)[*bm.getAddr8(0, 0)];
- break;
- }
- default:
- return; // keep solid == false
- }
- m_isSolidColor = true;
- m_solidColor = android_SkPMColorToWebCoreColor(color);
- }
-}
-
-void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dstRect,
- const FloatRect& srcRect, CompositeOperator compositeOp)
-{
- SkBitmapRef* image = this->nativeImageForCurrentFrame();
- if (!image) { // If it's too early we won't have an image yet.
- return;
- }
-
- // in case we get called with an incomplete bitmap
- const SkBitmap& bitmap = image->bitmap();
- if (bitmap.getPixels() == NULL && bitmap.pixelRef() == NULL) {
-#ifdef TRACE_SKIPPED_BITMAPS
- SkDebugf("----- skip bitmapimage: [%d %d] pixels %p pixelref %p\n",
- bitmap.width(), bitmap.height(),
- bitmap.getPixels(), bitmap.pixelRef());
-#endif
- return;
- }
-
- SkIRect srcR;
- SkRect dstR;
- float invScaleX = (float)bitmap.width() / image->origWidth();
- float invScaleY = (float)bitmap.height() / image->origHeight();
-
- android_setrect(&dstR, dstRect);
- android_setrect_scaled(&srcR, srcRect, invScaleX, invScaleY);
- if (srcR.isEmpty() || dstR.isEmpty()) {
-#ifdef TRACE_SKIPPED_BITMAPS
- SkDebugf("----- skip bitmapimage: [%d %d] src-empty %d dst-empty %d\n",
- bitmap.width(), bitmap.height(),
- srcR.isEmpty(), dstR.isEmpty());
-#endif
- return;
- }
-
- SkCanvas* canvas = ctxt->platformContext()->mCanvas;
- SkPaint paint;
-
- paint.setFilterBitmap(true);
- paint.setPorterDuffXfermode(android_convert_compositeOp(compositeOp));
- canvas->drawBitmapRect(bitmap, &srcR, dstR, &paint);
-
- startAnimation();
-
-#ifdef TRACE_SUBSAMPLED_BITMAPS
- if (bitmap.width() != image->origWidth() ||
- bitmap.height() != image->origHeight()) {
- SkDebugf("--- BitmapImage::draw [%d %d] orig [%d %d]\n",
- bitmap.width(), bitmap.height(),
- image->origWidth(), image->origHeight());
- }
-#endif
-}
-
-void BitmapImage::setURL(const String& str)
-{
- m_source.setURL(str);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect,
- const AffineTransform& patternTransform,
- const FloatPoint& phase, CompositeOperator compositeOp,
- const FloatRect& destRect)
-{
- SkBitmapRef* image = this->nativeImageForCurrentFrame();
- if (!image) { // If it's too early we won't have an image yet.
- return;
- }
-
- // in case we get called with an incomplete bitmap
- const SkBitmap& bitmap = image->bitmap();
- if (bitmap.getPixels() == NULL && bitmap.pixelRef() == NULL) {
- return;
- }
-
- SkRect dstR;
- android_setrect(&dstR, destRect);
- if (dstR.isEmpty()) {
- return;
- }
-
- SkCanvas* canvas = ctxt->platformContext()->mCanvas;
- SkPaint paint;
-
- SkShader* shader = SkShader::CreateBitmapShader(bitmap,
- SkShader::kRepeat_TileMode,
- SkShader::kRepeat_TileMode);
- paint.setShader(shader)->unref();
- // now paint is the only owner of shader
- paint.setPorterDuffXfermode(android_convert_compositeOp(compositeOp));
- paint.setFilterBitmap(true);
-
- SkMatrix matrix(patternTransform);
-
- float scaleX = (float)image->origWidth() / bitmap.width();
- float scaleY = (float)image->origHeight() / bitmap.height();
- matrix.preScale(SkFloatToScalar(scaleX), SkFloatToScalar(scaleY));
-
- matrix.postTranslate(SkFloatToScalar(phase.x()),
- SkFloatToScalar(phase.y()));
- shader->setLocalMatrix(matrix);
- canvas->drawRect(dstR, paint);
-
-#ifdef TRACE_SUBSAMPLED_BITMAPS
- if (bitmap.width() != image->origWidth() ||
- bitmap.height() != image->origHeight()) {
- SkDebugf("--- Image::drawPattern [%d %d] orig [%d %d] dst [%g %g]\n",
- bitmap.width(), bitmap.height(),
- image->origWidth(), image->origHeight(),
- SkScalarToFloat(dstR.width()), SkScalarToFloat(dstR.height()));
- }
-#endif
-}
-
-// missingImage, textAreaResizeCorner
-PassRefPtr<Image> Image::loadPlatformResource(const char *name)
-{
- android::AssetManager* am = globalAssetManager();
-
- SkString path("webkit/");
- path.append(name);
- path.append(".png");
-
- android::Asset* a = am->open(path.c_str(),
- android::Asset::ACCESS_BUFFER);
- if (a == NULL) {
- SkDebugf("---------------- failed to open image asset %s\n", name);
- return NULL;
- }
-
- SkAutoTDelete<android::Asset> ad(a);
-
- SkBitmap bm;
- if (SkImageDecoder::DecodeMemory(a->getBuffer(false), a->getLength(), &bm)) {
- SkBitmapRef* ref = new SkBitmapRef(bm);
- // create will call ref(), so we need aur() to release ours upon return
- SkAutoUnref aur(ref);
- return BitmapImage::create(ref, 0);
- }
- return Image::nullImage();
-}
-
-} // namespace
-
diff --git a/WebCore/platform/graphics/android/ImageBufferAndroid.cpp b/WebCore/platform/graphics/android/ImageBufferAndroid.cpp
deleted file mode 100644
index de88b33..0000000
--- a/WebCore/platform/graphics/android/ImageBufferAndroid.cpp
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Copyright 2007, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "BitmapImage.h"
-#include "ImageBuffer.h"
-#include "ImageData.h"
-#include "NotImplemented.h"
-
-#include "android_graphics.h"
-#include "GraphicsContext.h"
-#include "PlatformGraphicsContext.h"
-#include "SkBitmapRef.h"
-#include "SkCanvas.h"
-#include "SkColorPriv.h"
-#include "SkDevice.h"
-#include "SkUnPreMultiply.h"
-
-using namespace std;
-
-namespace WebCore {
-
-ImageBufferData::ImageBufferData(const IntSize&)
-{
-}
-
-ImageBuffer::ImageBuffer(const IntSize& size, bool grayScale, bool& success)
- : m_data(size)
- , m_size(size)
-{
- m_context.set(GraphicsContext::createOffscreenContext(size.width(), size.height()));
- success = true;
-}
-
-ImageBuffer::~ImageBuffer()
-{
-}
-
-GraphicsContext* ImageBuffer::context() const
-{
- return m_context.get();
-}
-
-/* This guy needs to make a deep copy of the bitmap, so that the returned
- image doesn't reflect any subsequent changes to the canvas' backend.
- e.g. this is called when <canvas> wants to make a Pattern, which needs
- to snapshot the current pixels when it is created.
- */
-Image* ImageBuffer::image() const
-{
- if (!m_image) {
- ASSERT(context());
- SkCanvas* canvas = context()->platformContext()->mCanvas;
- SkDevice* device = canvas->getDevice();
- const SkBitmap& orig = device->accessBitmap(false);
-
- SkBitmap copy;
- orig.copyTo(&copy, orig.config());
-
- SkBitmapRef* ref = new SkBitmapRef(copy);
- m_image = BitmapImage::create(ref, 0);
- ref->unref();
- }
- return m_image.get();
-}
-
-PassRefPtr<ImageData> ImageBuffer::getImageData(const IntRect& rect) const
-{
- GraphicsContext* gc = this->context();
- if (!gc) {
- return 0;
- }
-
- const SkBitmap& src = android_gc2canvas(gc)->getDevice()->accessBitmap(false);
- SkAutoLockPixels alp(src);
- if (!src.getPixels()) {
- return 0;
- }
-
- PassRefPtr<ImageData> result = ImageData::create(rect.width(), rect.height());
- unsigned char* data = result->data()->data().data();
-
- if (rect.x() < 0 || rect.y() < 0 || (rect.x() + rect.width()) > m_size.width() || (rect.y() + rect.height()) > m_size.height())
- memset(data, 0, result->data()->length());
-
- int originx = rect.x();
- int destx = 0;
- if (originx < 0) {
- destx = -originx;
- originx = 0;
- }
- int endx = rect.x() + rect.width();
- if (endx > m_size.width())
- endx = m_size.width();
- int numColumns = endx - originx;
-
- int originy = rect.y();
- int desty = 0;
- if (originy < 0) {
- desty = -originy;
- originy = 0;
- }
- int endy = rect.y() + rect.height();
- if (endy > m_size.height())
- endy = m_size.height();
- int numRows = endy - originy;
-
- unsigned srcPixelsPerRow = src.rowBytesAsPixels();
- unsigned destBytesPerRow = 4 * rect.width();
-
- const SkPMColor* srcRows = src.getAddr32(originx, originy);
- unsigned char* destRows = data + desty * destBytesPerRow + destx * 4;
- for (int y = 0; y < numRows; ++y) {
- for (int x = 0; x < numColumns; x++) {
- // ugh, it appears they want unpremultiplied pixels
- SkColor c = SkUnPreMultiply::PMColorToColor(srcRows[x]);
- int basex = x * 4;
- destRows[basex + 0] = SkColorGetR(c);
- destRows[basex + 1] = SkColorGetG(c);
- destRows[basex + 2] = SkColorGetB(c);
- destRows[basex + 3] = SkColorGetA(c);
- }
- srcRows += srcPixelsPerRow;
- destRows += destBytesPerRow;
- }
- return result;
-}
-
-void ImageBuffer::putImageData(ImageData* source, const IntRect& sourceRect, const IntPoint& destPoint)
-{
- GraphicsContext* gc = this->context();
- if (!gc) {
- return;
- }
-
- const SkBitmap& dst = android_gc2canvas(gc)->getDevice()->accessBitmap(true);
- SkAutoLockPixels alp(dst);
- if (!dst.getPixels()) {
- return;
- }
-
- ASSERT(sourceRect.width() > 0);
- ASSERT(sourceRect.height() > 0);
-
- int originx = sourceRect.x();
- int destx = destPoint.x() + sourceRect.x();
- ASSERT(destx >= 0);
- ASSERT(destx < m_size.width());
- ASSERT(originx >= 0);
- ASSERT(originx <= sourceRect.right());
-
- int endx = destPoint.x() + sourceRect.right();
- ASSERT(endx <= m_size.width());
-
- int numColumns = endx - destx;
-
- int originy = sourceRect.y();
- int desty = destPoint.y() + sourceRect.y();
- ASSERT(desty >= 0);
- ASSERT(desty < m_size.height());
- ASSERT(originy >= 0);
- ASSERT(originy <= sourceRect.bottom());
-
- int endy = destPoint.y() + sourceRect.bottom();
- ASSERT(endy <= m_size.height());
- int numRows = endy - desty;
-
- unsigned srcBytesPerRow = 4 * source->width();
- unsigned dstPixelsPerRow = dst.rowBytesAsPixels();
-
- unsigned char* srcRows = source->data()->data().data() + originy * srcBytesPerRow + originx * 4;
- SkPMColor* dstRows = dst.getAddr32(destx, desty);
- for (int y = 0; y < numRows; ++y) {
- for (int x = 0; x < numColumns; x++) {
- int basex = x * 4;
- dstRows[x] = SkPackARGB32(srcRows[basex + 3],
- srcRows[basex + 0],
- srcRows[basex + 1],
- srcRows[basex + 2]);
- }
- dstRows += dstPixelsPerRow;
- srcRows += srcBytesPerRow;
- }
-}
-
-
-String ImageBuffer::toDataURL(const String&) const
-{
- // leaving this unimplemented, until I understand what its for (and what it
- // really is).
- return "data:,"; // I think this means we couldn't make the data url
-}
-
-}
diff --git a/WebCore/platform/graphics/android/ImageBufferData.h b/WebCore/platform/graphics/android/ImageBufferData.h
deleted file mode 100644
index 7d8cd3b..0000000
--- a/WebCore/platform/graphics/android/ImageBufferData.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2008, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ImageBufferData_h
-#define ImageBufferData_h
-
-namespace WebCore {
-
-class IntSize;
-
-class ImageBufferData {
-public:
- ImageBufferData(const IntSize&);
-};
-
-} // namespace WebCore
-
-#endif // ImageBufferData_h
diff --git a/WebCore/platform/graphics/android/ImageSourceAndroid.cpp b/WebCore/platform/graphics/android/ImageSourceAndroid.cpp
deleted file mode 100644
index a6bf6c6..0000000
--- a/WebCore/platform/graphics/android/ImageSourceAndroid.cpp
+++ /dev/null
@@ -1,361 +0,0 @@
-/*
- * Copyright 2007, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ImageDecoder.h"
-#include "ImageSource.h"
-#include "IntSize.h"
-#include "NotImplemented.h"
-#include "SharedBuffer.h"
-#include "PlatformString.h"
-
-#include "JavaSharedClient.h"
-
-#include "SkBitmapRef.h"
-#include "SkImageRef.h"
-#include "SkImageDecoder.h"
-#include "SkStream.h"
-#include "SkTemplates.h"
-
-SkPixelRef* SkCreateRLEPixelRef(const SkBitmap& src);
-
-//#define TRACE_SUBSAMPLE_BITMAPS
-//#define TRACE_RLE_BITMAPS
-
-#include "SkImageRef_GlobalPool.h"
-#include "SkImageRef_ashmem.h"
-
-// made this up, so we don't waste a file-descriptor on small images, plus
-// we don't want to lose too much on the round-up to a page size (4K)
-#define MIN_ASHMEM_ALLOC_SIZE (32*1024)
-
-// don't use RLE for images smaller than this, since they incur a drawing cost
-// (and don't work as patterns yet) we only want to use RLE when we must
-#define MIN_RLE_ALLOC_SIZE (512*1024)
-
-static bool should_use_ashmem(const SkBitmap& bm) {
- return bm.getSize() >= MIN_ASHMEM_ALLOC_SIZE;
-}
-
-/* Images larger than this should be subsampled. Using ashmem, the decoded
- pixels will be purged as needed, so this value can be pretty large. Making
- it too small hurts image quality (e.g. abc.com background). 2Meg works for
- the sites I've tested, but if we hit important sites that need more, we
- should try increasing it and see if it has negative impact on performance
- (i.e. we end up thrashing because we need to keep decoding images that have
- been purged.
-
- Perhaps this value should be some fraction of the available RAM...
-*/
-static size_t computeMaxBitmapSizeForCache() {
- return 2*1024*1024;
-}
-
-/* 8bit images larger than this should be recompressed in RLE, to reduce
- on the imageref cache.
-
- Downside: performance, since we have to decode/encode
- and then rle-decode when we draw.
-*/
-static bool shouldReencodeAsRLE(const SkBitmap& bm) {
- const SkBitmap::Config c = bm.config();
- return (SkBitmap::kIndex8_Config == c || SkBitmap::kA8_Config == c)
- &&
- bm.width() >= 64 // narrower than this won't compress well in RLE
- &&
- bm.getSize() > MIN_RLE_ALLOC_SIZE;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-class PrivateAndroidImageSourceRec : public SkBitmapRef {
-public:
- PrivateAndroidImageSourceRec(const SkBitmap& bm, int origWidth,
- int origHeight, int sampleSize)
- : SkBitmapRef(bm), fSampleSize(sampleSize), fAllDataReceived(false) {
- this->setOrigSize(origWidth, origHeight);
- }
-
- int fSampleSize;
- bool fAllDataReceived;
-};
-
-using namespace android;
-
-namespace WebCore {
-
-class SharedBufferStream : public SkMemoryStream {
-public:
- SharedBufferStream(SharedBuffer* buffer)
- : SkMemoryStream(buffer->data(), buffer->size(), false) {
- fBuffer = buffer;
- buffer->ref();
- }
-
- virtual ~SharedBufferStream() {
- // we can't necessarily call fBuffer->deref() here, as we may be
- // in a different thread from webkit, and SharedBuffer is not
- // threadsafe. Therefore we defer it until it can be executed in the
- // webkit thread.
-// SkDebugf("-------- enqueue buffer %p for deref\n", fBuffer);
- JavaSharedClient::EnqueueFunctionPtr(CallDeref, fBuffer);
- }
-
-private:
- // don't allow this to change our data. should not get called, but we
- // override here just to be sure
- virtual void setMemory(const void* data, size_t length, bool copyData) {
- sk_throw();
- }
-
- // we share ownership of this with webkit
- SharedBuffer* fBuffer;
-
- // will be invoked in the webkit thread
- static void CallDeref(void* buffer) {
-// SkDebugf("-------- call deref on buffer %p\n", buffer);
- ((SharedBuffer*)buffer)->deref();
- }
-};
-
-
-///////////////////////////////////////////////////////////////////////////////
-
-ImageSource::ImageSource() {
- m_decoder.m_image = NULL;
-}
-
-ImageSource::~ImageSource() {
- delete m_decoder.m_image;
-}
-
-bool ImageSource::initialized() const {
- return m_decoder.m_image != NULL;
-}
-
-static int computeSampleSize(const SkBitmap& bitmap) {
- const size_t maxSize = computeMaxBitmapSizeForCache();
- size_t size = bitmap.getSize();
- int sampleSize = 1;
-
- while (size > maxSize) {
- sampleSize <<= 1;
- size >>= 2;
- }
-
-#ifdef TRACE_SUBSAMPLE_BITMAPS
- if (sampleSize > 1) {
- SkDebugf("------- bitmap [%d %d] config=%d origSize=%d predictSize=%d sampleSize=%d\n",
- bitmap.width(), bitmap.height(), bitmap.config(),
- bitmap.getSize(), size, sampleSize);
- }
-#endif
- return sampleSize;
-}
-
-static SkPixelRef* convertToRLE(SkBitmap* bm, const void* data, size_t len) {
- if (!shouldReencodeAsRLE(*bm)) {
- return NULL;
- }
-
- SkBitmap tmp;
-
- if (!SkImageDecoder::DecodeMemory(data, len, &tmp) || !tmp.getPixels()) {
- return NULL;
- }
-
- SkPixelRef* ref = SkCreateRLEPixelRef(tmp);
- if (NULL == ref) {
- return NULL;
- }
-
-#ifdef TRACE_RLE_BITMAPS
- SkDebugf("---- reencode bitmap as RLE: [%d %d] encodeSize=%d\n",
- tmp.width(), tmp.height(), len);
-#endif
-
- bm->setConfig(SkBitmap::kRLE_Index8_Config, tmp.width(), tmp.height());
- return ref;
-}
-
-void ImageSource::clearURL()
-{
- m_decoder.m_url.reset();
-}
-
-void ImageSource::setURL(const String& url)
-{
- if (url.startsWith("data:")) {
- clearURL();
- } else {
- m_decoder.m_url.setUTF16(url.characters(), url.length());
- }
-}
-
-void ImageSource::setData(SharedBuffer* data, bool allDataReceived)
-{
- if (NULL == m_decoder.m_image) {
- SkBitmap tmp;
-
- SkMemoryStream stream(data->data(), data->size(), false);
- SkImageDecoder* codec = SkImageDecoder::Factory(&stream);
- SkAutoTDelete<SkImageDecoder> ad(codec);
-
- if (!codec || !codec->decode(&stream, &tmp, SkBitmap::kNo_Config,
- SkImageDecoder::kDecodeBounds_Mode)) {
- return;
- }
-
- int origW = tmp.width();
- int origH = tmp.height();
- int sampleSize = computeSampleSize(tmp);
- if (sampleSize > 1) {
- codec->setSampleSize(sampleSize);
- stream.rewind();
- if (!codec->decode(&stream, &tmp, SkBitmap::kNo_Config,
- SkImageDecoder::kDecodeBounds_Mode)) {
- return;
- }
- }
-
- m_decoder.m_image = new PrivateAndroidImageSourceRec(tmp, origW, origH,
- sampleSize);
-
-// SkDebugf("----- started: [%d %d] %s\n", origW, origH, m_decoder.m_url.c_str());
- }
-
- PrivateAndroidImageSourceRec* decoder = m_decoder.m_image;
- if (allDataReceived && !decoder->fAllDataReceived) {
- decoder->fAllDataReceived = true;
-
- SkBitmap* bm = &decoder->bitmap();
- SkPixelRef* ref = convertToRLE(bm, data->data(), data->size());
-
- if (NULL == ref) {
- SkStream* strm = new SharedBufferStream(data);
- // imageref now owns the stream object
- if (should_use_ashmem(*bm)) {
-// SkDebugf("---- use ashmem for image [%d %d]\n", bm->width(), bm->height());
- ref = new SkImageRef_ashmem(strm, bm->config(), decoder->fSampleSize);
- } else {
-// SkDebugf("---- use globalpool for image [%d %d]\n", bm->width(), bm->height());
- ref = new SkImageRef_GlobalPool(strm, bm->config(), decoder->fSampleSize);
- }
-
- // SkDebugf("----- allDataReceived [%d %d]\n", bm->width(), bm->height());
- }
-
- // we promise to never change the pixels (makes picture recording fast)
- ref->setImmutable();
- // give it the URL if we have one
- ref->setURI(m_decoder.m_url);
- // our bitmap is now the only owner of the imageref
- bm->setPixelRef(ref)->unref();
-
-// SkDebugf("---- finished: [%d %d] %s\n", bm->width(), bm->height(), ref->getURI());
- }
-}
-
-bool ImageSource::isSizeAvailable()
-{
- return m_decoder.m_image != NULL;
-}
-
-IntSize ImageSource::size() const
-{
- if (m_decoder.m_image) {
- return IntSize(m_decoder.m_image->origWidth(), m_decoder.m_image->origHeight());
- }
- return IntSize(0, 0);
-}
-
-int ImageSource::repetitionCount()
-{
- return 1;
- // A property with value 0 means loop forever.
-}
-
-size_t ImageSource::frameCount() const
-{
- // i.e. 0 frames if we're not decoded, or 1 frame if we are
- return m_decoder.m_image != NULL;
-}
-
-SkBitmapRef* ImageSource::createFrameAtIndex(size_t index)
-{
- SkASSERT(index == 0);
- SkASSERT(m_decoder.m_image != NULL);
- m_decoder.m_image->ref();
- return m_decoder.m_image;
-}
-
-float ImageSource::frameDurationAtIndex(size_t index)
-{
- SkASSERT(index == 0);
- float duration = 0;
-
- // Many annoying ads specify a 0 duration to make an image flash as quickly as possible.
- // We follow Firefox's behavior and use a duration of 100 ms for any frames that specify
- // a duration of <= 10 ms. See gfxImageFrame::GetTimeout in Gecko or Radar 4051389 for more.
- if (duration <= 0.010f)
- duration = 0.100f;
- return duration;
-}
-
-bool ImageSource::frameHasAlphaAtIndex(size_t index)
-{
- SkASSERT(0 == index);
-
- if (NULL == m_decoder.m_image)
- return true; // if we're not sure, assume the worse-case
- const PrivateAndroidImageSourceRec& decoder = *m_decoder.m_image;
- // if we're 16bit, we know even without all the data available
- if (decoder.bitmap().getConfig() == SkBitmap::kRGB_565_Config)
- return false;
-
- if (!decoder.fAllDataReceived)
- return true; // if we're not sure, assume the worse-case
-
- return !decoder.bitmap().isOpaque();
-}
-
-bool ImageSource::frameIsCompleteAtIndex(size_t index)
-{
- SkASSERT(0 == index);
- return m_decoder.m_image && m_decoder.m_image->fAllDataReceived;
-}
-
-void ImageSource::clear()
-{
- // do nothing, since the cache is managed elsewhere
-}
-
-IntSize ImageSource::frameSizeAtIndex(size_t index) const
-{
- // for now, all (1) of our frames are the same size
- return this->size();
-}
-
-}
diff --git a/WebCore/platform/graphics/android/PathAndroid.cpp b/WebCore/platform/graphics/android/PathAndroid.cpp
deleted file mode 100644
index 819173b..0000000
--- a/WebCore/platform/graphics/android/PathAndroid.cpp
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * Copyright 2007, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Path.h"
-#include "FloatRect.h"
-#include "AffineTransform.h"
-
-#include "SkPath.h"
-#include "SkRegion.h"
-
-#include "android_graphics.h"
-
-namespace WebCore {
-
-Path::Path()
-{
- m_path = new SkPath;
-// m_path->setFlags(SkPath::kWinding_FillType);
-}
-
-Path::Path(const Path& other)
-{
- m_path = new SkPath(*other.m_path);
-}
-
-Path::~Path()
-{
- delete m_path;
-}
-
-Path& Path::operator=(const Path& other)
-{
- *m_path = *other.m_path;
- return *this;
-}
-
-bool Path::isEmpty() const
-{
- return m_path->isEmpty();
-}
-
-bool Path::contains(const FloatPoint& point, WindRule rule) const
-{
- SkRegion rgn, clip;
-
- int x = (int)floorf(point.x());
- int y = (int)floorf(point.y());
- clip.setRect(x, y, x + 1, y + 1);
-
- SkPath::FillType ft = m_path->getFillType(); // save
- m_path->setFillType(rule == RULE_NONZERO ? SkPath::kWinding_FillType : SkPath::kEvenOdd_FillType);
-
- bool contains = rgn.setPath(*m_path, clip);
-
- m_path->setFillType(ft); // restore
- return contains;
-}
-
-void Path::translate(const FloatSize& size)
-{
- m_path->offset(SkFloatToScalar(size.width()), SkFloatToScalar(size.height()));
-}
-
-FloatRect Path::boundingRect() const
-{
- SkRect r;
-
- m_path->computeBounds(&r, SkPath::kExact_BoundsType);
- return FloatRect( SkScalarToFloat(r.fLeft),
- SkScalarToFloat(r.fTop),
- SkScalarToFloat(r.width()),
- SkScalarToFloat(r.height()));
-}
-
-void Path::moveTo(const FloatPoint& point)
-{
- m_path->moveTo(SkFloatToScalar(point.x()), SkFloatToScalar(point.y()));
-}
-
-void Path::addLineTo(const FloatPoint& p)
-{
- m_path->lineTo(SkFloatToScalar(p.x()), SkFloatToScalar(p.y()));
-}
-
-void Path::addQuadCurveTo(const FloatPoint& cp, const FloatPoint& ep)
-{
- m_path->quadTo( SkFloatToScalar(cp.x()), SkFloatToScalar(cp.y()),
- SkFloatToScalar(ep.x()), SkFloatToScalar(ep.y()));
-}
-
-void Path::addBezierCurveTo(const FloatPoint& p1, const FloatPoint& p2, const FloatPoint& ep)
-{
- m_path->cubicTo(SkFloatToScalar(p1.x()), SkFloatToScalar(p1.y()),
- SkFloatToScalar(p2.x()), SkFloatToScalar(p2.y()),
- SkFloatToScalar(ep.x()), SkFloatToScalar(ep.y()));
-}
-
-void Path::addArcTo(const FloatPoint& p1, const FloatPoint& p2, float radius)
-{
- m_path->arcTo(SkFloatToScalar(p1.x()), SkFloatToScalar(p1.y()),
- SkFloatToScalar(p2.x()), SkFloatToScalar(p2.y()),
- SkFloatToScalar(radius));
-}
-
-void Path::closeSubpath()
-{
- m_path->close();
-}
-
-static const float gPI = 3.14159265f;
-static const float g2PI = 6.28318531f;
-static const float g180OverPI = 57.29577951308f;
-
-static float fast_mod(float angle, float max) {
- if (angle >= max || angle <= -max) {
- angle = fmodf(angle, max);
- }
- return angle;
-}
-
-void Path::addArc(const FloatPoint& p, float r, float sa, float ea,
- bool clockwise) {
- SkScalar cx = SkFloatToScalar(p.x());
- SkScalar cy = SkFloatToScalar(p.y());
- SkScalar radius = SkFloatToScalar(r);
-
- SkRect oval;
- oval.set(cx - radius, cy - radius, cx + radius, cy + radius);
-
- float sweep = ea - sa;
- bool prependOval = false;
-
- /* Note if clockwise and the sign of the sweep disagree. This particular
- logic was deduced from http://canvex.lazyilluminati.com/misc/arc.html
- */
- if (clockwise && (sweep > 0 || sweep < -g2PI)) {
- sweep = fmodf(sweep, g2PI) - g2PI;
- } else if (!clockwise && (sweep < 0 || sweep > g2PI)) {
- sweep = fmodf(sweep, g2PI) + g2PI;
- }
-
- // If the abs(sweep) >= 2PI, then we need to add a circle before we call
- // arcTo, since it treats the sweep mod 2PI. We don't have a prepend call,
- // so we just remember this, and at the end create a new path with an oval
- // and our current path, and then swap then.
- //
- if (sweep >= g2PI || sweep <= -g2PI) {
- prependOval = true;
-// SkDebugf("addArc sa=%g ea=%g cw=%d sweep %g treat as circle\n", sa, ea, clockwise, sweep);
-
- // now reduce sweep to just the amount we need, so that the current
- // point is left where the caller expects it.
- sweep = fmodf(sweep, g2PI);
- }
-
- sa = fast_mod(sa, g2PI);
- SkScalar startDegrees = SkFloatToScalar(sa * g180OverPI);
- SkScalar sweepDegrees = SkFloatToScalar(sweep * g180OverPI);
-
-// SkDebugf("addArc sa=%g ea=%g cw=%d sweep=%g ssweep=%g\n", sa, ea, clockwise, sweep, SkScalarToFloat(sweepDegrees));
- m_path->arcTo(oval, startDegrees, sweepDegrees, false);
-
- if (prependOval) {
- SkPath tmp;
- tmp.addOval(oval);
- tmp.addPath(*m_path);
- m_path->swap(tmp);
- }
-}
-
-void Path::addRect(const FloatRect& rect)
-{
- SkRect r;
-
- android_setrect(&r, rect);
- m_path->addRect(r);
-}
-
-void Path::addEllipse(const FloatRect& rect)
-{
- SkRect r;
-
- android_setrect(&r, rect);
- m_path->addOval(r);
-}
-
-void Path::clear()
-{
- m_path->reset();
-}
-
-static FloatPoint* setfpts(FloatPoint dst[], const SkPoint src[], int count)
-{
- for (int i = 0; i < count; i++)
- {
- dst[i].setX(SkScalarToFloat(src[i].fX));
- dst[i].setY(SkScalarToFloat(src[i].fY));
- }
- return dst;
-}
-
-void Path::apply(void* info, PathApplierFunction function) const
-{
- SkPath::Iter iter(*m_path, false);
- SkPoint pts[4];
-
- PathElement elem;
- FloatPoint fpts[3];
-
- for (;;)
- {
- switch (iter.next(pts)) {
- case SkPath::kMove_Verb:
- elem.type = PathElementMoveToPoint;
- elem.points = setfpts(fpts, &pts[0], 1);
- break;
- case SkPath::kLine_Verb:
- elem.type = PathElementAddLineToPoint;
- elem.points = setfpts(fpts, &pts[1], 1);
- break;
- case SkPath::kQuad_Verb:
- elem.type = PathElementAddQuadCurveToPoint;
- elem.points = setfpts(fpts, &pts[1], 2);
- break;
- case SkPath::kCubic_Verb:
- elem.type = PathElementAddCurveToPoint;
- elem.points = setfpts(fpts, &pts[1], 3);
- break;
- case SkPath::kClose_Verb:
- elem.type = PathElementCloseSubpath;
- elem.points = NULL;
- break;
- case SkPath::kDone_Verb:
- return;
- }
- function(info, &elem);
- }
-}
-
-void Path::transform(const AffineTransform& xform)
-{
- m_path->transform(xform);
-}
-
-}
diff --git a/WebCore/platform/graphics/android/PatternAndroid.cpp b/WebCore/platform/graphics/android/PatternAndroid.cpp
deleted file mode 100644
index 2840faa..0000000
--- a/WebCore/platform/graphics/android/PatternAndroid.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2006, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Pattern.h"
-
-#include "android_graphics.h"
-#include "GraphicsContext.h"
-#include "SkBitmapRef.h"
-#include "SkCanvas.h"
-#include "SkColorShader.h"
-#include "SkShader.h"
-#include "SkPaint.h"
-
-namespace WebCore {
-
-static SkShader::TileMode toTileMode(bool doRepeat) {
- return doRepeat ? SkShader::kRepeat_TileMode : SkShader::kClamp_TileMode;
-}
-
-SkShader* Pattern::createPlatformPattern(const AffineTransform& transform) const
-{
- SkBitmapRef* ref = tileImage()->nativeImageForCurrentFrame();
- SkShader* s = SkShader::CreateBitmapShader(ref->bitmap(),
- toTileMode(m_repeatX),
- toTileMode(m_repeatY));
-
- // TODO: do I treat transform as a local matrix???
- return s;
-}
-
-} //namespace
diff --git a/WebCore/platform/graphics/android/PlatformGraphicsContext.cpp b/WebCore/platform/graphics/android/PlatformGraphicsContext.cpp
deleted file mode 100644
index b13f45f..0000000
--- a/WebCore/platform/graphics/android/PlatformGraphicsContext.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright 2006, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Node.h"
-#include "PlatformGraphicsContext.h"
-#include "SkCanvas.h"
-
-namespace WebCore {
-
-PlatformGraphicsContext::PlatformGraphicsContext(SkCanvas* canvas, WTF::Vector<Container>* buttons)
- : mCanvas(canvas), m_deleteCanvas(false), m_buttons(buttons)
-{
-}
-
-PlatformGraphicsContext::PlatformGraphicsContext() : m_deleteCanvas(true)
-{
- mCanvas = new SkCanvas;
- // Since this is our own private SkCanvas, and has no relation to a picture
- // storing button references would be meaningless.
- m_buttons = NULL;
-}
-
-PlatformGraphicsContext::~PlatformGraphicsContext()
-{
- if (m_deleteCanvas) {
-// printf("-------------------- deleting offscreen canvas\n");
- delete mCanvas;
- }
-}
-
-void PlatformGraphicsContext::storeButtonInfo(Node* node, const IntRect& r)
-{
- if (m_buttons == NULL)
- return;
- // Check to see if we already have a Container for this node. If so, update
- // it with the new rectangle and make the new recording canvas reference
- // its picture.
- Container* end = m_buttons->end();
- for (Container* ptr = m_buttons->begin(); ptr != end; ptr++) {
- if (ptr->matches(node)) {
- mCanvas->drawPicture(*(ptr->picture()));
- ptr->setRect(r);
- return;
- }
- }
- // We did not have a Container representing this node, so create a new one.
- Container container(node, r);
- // Place a reference to our subpicture in the Picture.
- mCanvas->drawPicture(*(container.picture()));
- // Keep track of the information about the button.
- m_buttons->append(container);
-}
-
-} // WebCore
diff --git a/WebCore/platform/graphics/android/PlatformGraphicsContext.h b/WebCore/platform/graphics/android/PlatformGraphicsContext.h
deleted file mode 100644
index dce8ef3..0000000
--- a/WebCore/platform/graphics/android/PlatformGraphicsContext.h
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright 2006, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef platform_graphics_context_h
-#define platform_graphics_context_h
-
-#include "IntRect.h"
-#include "RenderSkinAndroid.h"
-#include "RenderSkinButton.h"
-#include "SkCanvas.h"
-#include "SkPicture.h"
-#include "SkTDArray.h"
-
-class SkCanvas;
-class WebCore::Node;
-
-class Container {
-public:
- Container(WebCore::Node* node, const WebCore::IntRect& r)
- : m_node(node), m_rect(r), m_state(WebCore::RenderSkinAndroid::kDisabled)
- {
- m_picture = new SkPicture;
- }
-
- ~Container()
- {
- m_picture->unref();
- }
-
- Container& operator=(const Container& src)
- {
- if (this != &src) {
- m_node = src.m_node;
- if (m_picture)
- m_picture->unref();
- m_picture = src.m_picture;
- m_picture->ref();
- m_rect = src.m_rect;
- m_state = WebCore::RenderSkinAndroid::kDisabled;
- }
- return *this;
- }
-
- Container(const Container& src)
- {
- m_node = src.m_node;
- m_picture = src.m_picture;
- m_picture->ref();
- m_rect = src.m_rect;
- m_state = WebCore::RenderSkinAndroid::kDisabled;
- }
-
- // m_picture has a ref count of 1 to begin with. It will increase each time
- // m_picture is referenced by another picture. When the other pictures are
- // deleted, the ref count gets decremented. If the ref count is one, then
- // no other pictures reference this one, so the button is no longer being
- // used, and therefore can be removed.
- bool canBeRemoved()
- {
- return m_picture->getRefCnt() == 1;
- }
-
- bool matches(const WebCore::Node* match) { return m_node == match; }
-
- const WebCore::Node* node() const { return m_node; }
-
- // Provide a pointer to our SkPicture.
- SkPicture* picture() { return m_picture; }
-
- WebCore::IntRect rect() { return m_rect; }
-
- // Update the rectangle with a new rectangle, as the positioning of this
- // button may have changed due to a new layout. If it is a new rectangle,
- // set its state to disabled, so that it will be redrawn when we cycle
- // through the list of buttons.
- void setRect(WebCore::IntRect r)
- {
- if (m_rect != r) {
- m_rect = r;
- m_state = WebCore::RenderSkinAndroid::kDisabled;
- }
- }
-
- // Update the focus state of this button, depending on whether it
- // corresponds to the focused node passed in. If its state has changed,
- // re-record to the subpicture, so the master picture will reflect the
- // change.
- void updateFocusState(WebCore::RenderSkinAndroid::State state)
- {
- if (state == m_state)
- return;
- // If this button is being told to draw focused, but it is already in a
- // pressed state, leave it in the pressed state, to show that it is
- // being followed.
- if (m_state == WebCore::RenderSkinAndroid::kPressed &&
- state == WebCore::RenderSkinAndroid::kFocused)
- return;
- m_state = state;
- SkCanvas* canvas = m_picture->beginRecording(m_rect.width(), m_rect.height());
- WebCore::RenderSkinButton::Draw(canvas, m_rect, state);
- m_picture->endRecording();
- }
-private:
- // Only used for comparison, since after it is stored it will be transferred
- // to the UI thread.
- WebCore::Node* m_node;
- // The rectangle representing the bounds of the button.
- WebCore::IntRect m_rect;
- // An SkPicture that, thanks to storeButtonInfo, is pointed to by the master
- // picture, so that we can rerecord this button without rerecording the
- // world.
- SkPicture* m_picture;
- // The state of the button - Currently kFocused or kNormal (and kDisabled
- // as an initial value), but could be expanded to include other states.
- WebCore::RenderSkinAndroid::State m_state;
-};
-
-namespace WebCore {
-
- class GraphicsContext;
-
-class PlatformGraphicsContext {
-public:
- PlatformGraphicsContext();
- // Pass in a recording canvas, and an array of button information to be
- // updated.
- PlatformGraphicsContext(SkCanvas* canvas, WTF::Vector<Container>* buttons);
- ~PlatformGraphicsContext();
-
- void setupFillPaint(GraphicsContext*, SkPaint*);
- void setupStrokePaint(GraphicsContext*, SkPaint*);
-
- SkCanvas* mCanvas;
-
- bool deleteUs() const { return m_deleteCanvas; }
- // If our graphicscontext has a button list, add a new container for the
- // nod/rect, and record a new subpicture for this node/button in the current
- // mCanvas
- void storeButtonInfo(Node* node, const IntRect& r);
-private:
- bool m_deleteCanvas;
- WTF::Vector<Container>* m_buttons;
-};
-
-}
-#endif
-
diff --git a/WebCore/platform/graphics/android/SkBitmapRef.h b/WebCore/platform/graphics/android/SkBitmapRef.h
deleted file mode 100644
index 094102b..0000000
--- a/WebCore/platform/graphics/android/SkBitmapRef.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 2006, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef SkBitmapRef_DEFINED
-#define SkBitmapRef_DEFINED
-
-#include "SkRefCnt.h"
-#include "SkBitmap.h"
-
-class SkBitmapRef : public SkRefCnt {
-public:
- SkBitmapRef() : fOrigWidth(0), fOrigHeight(0), fAccessed(false) {}
- explicit SkBitmapRef(const SkBitmap& src)
- : fBitmap(src),
- fOrigWidth(src.width()),
- fOrigHeight(src.height()),
- fAccessed(false) {}
-
- const SkBitmap& bitmap() const { return fBitmap; }
- SkBitmap& bitmap() { return fBitmap; }
-
- int origWidth() const { return fOrigWidth; }
- int origHeight() const { return fOrigHeight; }
-
- void setOrigSize(int width, int height) {
- fOrigWidth = width;
- fOrigHeight = height;
- }
- // return true if this is not the first access
- // mark it true so all subsequent calls return true
- bool accessed() { bool result = fAccessed;
- fAccessed = true; return result; }
-
-private:
- SkBitmap fBitmap;
- int fOrigWidth, fOrigHeight;
- bool fAccessed;
-};
-
-#endif
diff --git a/WebCore/platform/graphics/android/android_graphics.cpp b/WebCore/platform/graphics/android/android_graphics.cpp
deleted file mode 100644
index 2bc0c8f..0000000
--- a/WebCore/platform/graphics/android/android_graphics.cpp
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * Copyright 2007, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "android_graphics.h"
-#include "IntPoint.h"
-#include "IntRect.h"
-#include "FloatPoint.h"
-#include "FloatRect.h"
-#include "SkCanvas.h"
-#include "SkColorPriv.h"
-#include "SkCornerPathEffect.h"
-#include "SkGradientShader.h"
-#include "SkPath.h"
-#include "SkRegion.h"
-
-SkPoint* android_setpt(SkPoint* dst, const WebCore::IntPoint& src)
-{
- dst->set(SkIntToScalar(src.x()), SkIntToScalar(src.y()));
- return dst;
-}
-
-SkPoint* android_setpt(SkPoint* dst, const WebCore::FloatPoint& src)
-{
- dst->set(SkFloatToScalar(src.x()), SkFloatToScalar(src.y()));
- return dst;
-}
-
-SkRect* android_setrect(SkRect* dst, const WebCore::IntRect& src)
-{
- dst->set(SkIntToScalar(src.x()),
- SkIntToScalar(src.y()),
- SkIntToScalar(src.x() + src.width()),
- SkIntToScalar(src.y() + src.height()));
- return dst;
-}
-
-SkIRect* android_setrect(SkIRect* dst, const WebCore::IntRect& src)
-{
- dst->set(src.x(), src.y(),
- src.x() + src.width(),
- src.y() + src.height());
- return dst;
-}
-
-SkRect* android_setrect(SkRect* dst, const WebCore::FloatRect& src)
-{
- dst->set(SkFloatToScalar(src.x()),
- SkFloatToScalar(src.y()),
- SkFloatToScalar(src.x() + src.width()),
- SkFloatToScalar(src.y() + src.height()));
- return dst;
-}
-
-SkIRect* android_setrect(SkIRect* dst, const WebCore::FloatRect& src)
-{
- dst->set(SkScalarRound(SkFloatToScalar(src.x())),
- SkScalarRound(SkFloatToScalar(src.y())),
- SkScalarRound(SkFloatToScalar(src.x() + src.width())),
- SkScalarRound(SkFloatToScalar(src.y() + src.height())));
- return dst;
-}
-
-SkIRect* android_setrect_scaled(SkIRect* dst, const WebCore::FloatRect& src,
- float sx, float sy)
-{
- dst->set(SkScalarRound(SkFloatToScalar(src.x() * sx)),
- SkScalarRound(SkFloatToScalar(src.y() * sy)),
- SkScalarRound(SkFloatToScalar((src.x() + src.width()) * sx)),
- SkScalarRound(SkFloatToScalar((src.y() + src.height()) * sy)));
- return dst;
-}
-
-static const struct CompositOpToPorterDuffMode {
- uint8_t mCompositOp;
- uint8_t mPorterDuffMode;
-} gMapCompositOpsToPorterDuffModes[] = {
- { WebCore::CompositeClear, SkPorterDuff::kClear_Mode },
- { WebCore::CompositeCopy, SkPorterDuff::kSrcOver_Mode }, // TODO
- { WebCore::CompositeSourceOver, SkPorterDuff::kSrcOver_Mode },
- { WebCore::CompositeSourceIn, SkPorterDuff::kSrcIn_Mode },
- { WebCore::CompositeSourceOut, SkPorterDuff::kSrcOut_Mode },
- { WebCore::CompositeSourceAtop, SkPorterDuff::kSrcATop_Mode },
- { WebCore::CompositeDestinationOver, SkPorterDuff::kDstOver_Mode },
- { WebCore::CompositeDestinationIn, SkPorterDuff::kDstIn_Mode },
- { WebCore::CompositeDestinationOut, SkPorterDuff::kDstOut_Mode },
- { WebCore::CompositeDestinationAtop, SkPorterDuff::kDstATop_Mode },
- { WebCore::CompositeXOR, SkPorterDuff::kXor_Mode },
- { WebCore::CompositePlusDarker, SkPorterDuff::kDarken_Mode },
- { WebCore::CompositeHighlight, SkPorterDuff::kSrcOver_Mode }, // TODO
- { WebCore::CompositePlusLighter, SkPorterDuff::kLighten_Mode }
-};
-
-SkPorterDuff::Mode android_convert_compositeOp(WebCore::CompositeOperator op)
-{
- const CompositOpToPorterDuffMode* table = gMapCompositOpsToPorterDuffModes;
-
- for (unsigned i = 0; i < SK_ARRAY_COUNT(gMapCompositOpsToPorterDuffModes); i++) {
- if (table[i].mCompositOp == op) {
- return (SkPorterDuff::Mode)table[i].mPorterDuffMode;
- }
- }
-
- SkDEBUGF(("GraphicsContext::setCompositeOperation uknown CompositOperator %d\n", op));
- return SkPorterDuff::kSrcOver_Mode; // fall-back
-}
-
-SkShader::TileMode android_convert_TileRule(WebCore::Image::TileRule rule)
-{
- // stretch == clamp
- // repeat == repeat
- // RoundTile???
-
- return WebCore::Image::RepeatTile == rule ? SkShader::kRepeat_TileMode : SkShader::kClamp_TileMode;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-static U8CPU InvScaleByte(U8CPU component, uint32_t scale)
-{
- SkASSERT(component == (uint8_t)component);
- return (component * scale + 0x8000) >> 16;
-}
-
-// move this guy into SkColor.h
-static SkColor SkPMColorToColor(SkPMColor pm)
-{
- if (0 == pm)
- return 0;
-
- unsigned a = SkGetPackedA32(pm);
- uint32_t scale = (255 << 16) / a;
-
- return SkColorSetARGB(a,
- InvScaleByte(SkGetPackedR32(pm), scale),
- InvScaleByte(SkGetPackedG32(pm), scale),
- InvScaleByte(SkGetPackedB32(pm), scale));
-}
-
-WebCore::Color android_SkPMColorToWebCoreColor(SkPMColor pm)
-{
- SkColor c = SkPMColorToColor(pm);
-
- // need the cast to find the right constructor
- return WebCore::Color((int)SkColorGetR(c), (int)SkColorGetG(c),
- (int)SkColorGetB(c), (int)SkColorGetA(c));
-}
-
-const static SkColor focusOuterColors[] = {
- SkColorSetARGB(0xff, 0xB3, 0x3F, 0x08), // normal focus ring select
- SkColorSetARGB(0xff, 0x46, 0xb0, 0x00), // fake focus ring select, for phone, email, text
- SkColorSetARGB(0xff, 0xb0, 0x16, 0x00), // invalid focus ring color
- SkColorSetARGB(0xff, 0xAD, 0x5C, 0x0A), // normal focus ring pressed
- SkColorSetARGB(0xff, 0x36, 0xc0, 0x00) // fake focus ring pressed
-};
-
-const static SkColor focusInnerColors[] = {
- SkColorSetARGB(0xff, 0xFE, 0x92, 0x30), // normal focus ring select
- SkColorSetARGB(0xff, 0x8c, 0xd9, 0x00), // fake focus ring select, for phone, email, text
- SkColorSetARGB(0xff, 0xd9, 0x2c, 0x00), // invalid focus ring color
- SkColorSetARGB(0xff, 0xFE, 0xBD, 0x3A), // normal focus ring pressed
- SkColorSetARGB(0xff, 0x7c, 0xe9, 0x00) // fake focus ring pressed
-};
-
-const static SkColor focusPressedColors[] = {
- SkColorSetARGB(0x80, 0xFF, 0xC6, 0x4B), // normal focus ring pressed
- SkColorSetARGB(0x80, 0x7c, 0xe9, 0x00) // fake focus ring pressed
-};
-
-#define FOCUS_RING_ROUNDEDNESS SkIntToScalar(5) // used to draw corners
-#define FOCUS_RING_INNER_DIAMETER SkFixedToScalar(SkIntToFixed(3)>>1) // 3/2 == 1.5
-#define FOCUS_RING_OUTER_OUTSET 2 // used to inflate rects added to region
-
-void FocusRing::DrawRing(SkCanvas* canvas,
- const Vector<WebCore::IntRect>& rects, Flavor flavor)
-{
- unsigned rectCount = rects.size();
- SkRegion rgn;
- SkPath path;
- for (unsigned i = 0; i < rectCount; i++)
- {
- SkIRect r;
-
- android_setrect(&r, rects[i]);
- r.inset(-FOCUS_RING_OUTER_OUTSET, -FOCUS_RING_OUTER_OUTSET);
- rgn.op(r, SkRegion::kUnion_Op);
- }
- rgn.getBoundaryPath(&path);
-
- SkPaint paint;
- paint.setAntiAlias(true);
- paint.setPathEffect(new SkCornerPathEffect(FOCUS_RING_ROUNDEDNESS))->unref();
- if (flavor >= NORMAL_ANIMATING) { // pressed
- paint.setColor(focusPressedColors[flavor - NORMAL_ANIMATING]);
- canvas->drawPath(path, paint);
- }
- paint.setStyle(SkPaint::kStroke_Style);
- paint.setStrokeWidth(FOCUS_RING_OUTER_DIAMETER);
- paint.setColor(focusOuterColors[flavor]);
- canvas->drawPath(path, paint);
- paint.setStrokeWidth(FOCUS_RING_INNER_DIAMETER);
- paint.setColor(focusInnerColors[flavor]);
- canvas->drawPath(path, paint);
-}
-
-
diff --git a/WebCore/platform/graphics/android/android_graphics.h b/WebCore/platform/graphics/android/android_graphics.h
deleted file mode 100644
index 21492cf..0000000
--- a/WebCore/platform/graphics/android/android_graphics.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright 2007, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef android_graphics_DEFINED
-#define android_graphics_DEFINED
-
-#include "Color.h"
-#include "Image.h"
-#include "wtf/Vector.h"
-
-#include "SkColor.h"
-#include "SkPorterDuff.h"
-#include "SkScalar.h"
-#include "SkShader.h"
-
-class SkCanvas;
-struct SkPoint;
-struct SKRect;
-
-namespace WebCore {
- class FloatRect;
- class IntPoint;
- class IntRect;
- class GraphicsContext;
-}
-
-SkPoint* android_setpt(SkPoint* dst, const WebCore::IntPoint& src);
-SkPoint* android_setpt(SkPoint* dst, const WebCore::FloatPoint& src);
-SkRect* android_setrect(SkRect* dst, const WebCore::IntRect& src);
-SkRect* android_setrect(SkRect* dst, const WebCore::FloatRect& src);
-SkIRect* android_setrect(SkIRect* dst, const WebCore::IntRect& src);
-SkIRect* android_setrect(SkIRect* dst, const WebCore::FloatRect& src);
-SkIRect* android_setrect_scaled(SkIRect* dst, const WebCore::FloatRect& src,
- float sx, float sy);
-
-SkPorterDuff::Mode android_convert_compositeOp(WebCore::CompositeOperator);
-SkShader::TileMode android_convert_TileRule(WebCore::Image::TileRule);
-
-WebCore::Color android_SkPMColorToWebCoreColor(SkPMColor pm);
-
-SkCanvas* android_gc2canvas(WebCore::GraphicsContext* gc);
-
-// Data and methods for focus rings
-
-// used to inflate node cache entry
-#define FOCUS_RING_HIT_TEST_RADIUS 5
-
-// used to inval rectangle enclosing pressed state of focus ring
-#define FOCUS_RING_OUTER_DIAMETER SkFixedToScalar(SkIntToFixed(13)>>2) // 13/4 == 3.25
-
-struct FocusRing {
-public:
- enum Flavor {
- NORMAL_FLAVOR,
- FAKE_FLAVOR,
- INVALID_FLAVOR,
- NORMAL_ANIMATING,
- FAKE_ANIMATING,
- ANIMATING_COUNT = 2
- };
-
- static void DrawRing(SkCanvas* ,
- const Vector<WebCore::IntRect>& rects, Flavor );
-};
-
-#endif
-
diff --git a/WebCore/platform/graphics/cairo/AffineTransformCairo.cpp b/WebCore/platform/graphics/cairo/AffineTransformCairo.cpp
deleted file mode 100644
index 0f2fccd..0000000
--- a/WebCore/platform/graphics/cairo/AffineTransformCairo.cpp
+++ /dev/null
@@ -1,281 +0,0 @@
-/*
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "AffineTransform.h"
-
-#include "IntRect.h"
-#include "FloatRect.h"
-
-#include <cairo.h>
-
-namespace WebCore {
-
-static const double deg2rad = 0.017453292519943295769; // pi/180
-
-AffineTransform::AffineTransform()
-{
- cairo_matrix_init_identity(&m_transform);
-}
-
-AffineTransform::AffineTransform(double a, double b, double c, double d, double tx, double ty)
-{
- cairo_matrix_init(&m_transform, a, b, c, d, tx, ty);
-}
-
-AffineTransform::AffineTransform(const PlatformAffineTransform& matrix)
-{
- m_transform = matrix;
-}
-
-void AffineTransform::setMatrix(double a, double b, double c, double d, double tx, double ty)
-{
- cairo_matrix_init(&m_transform, a, b, c, d, tx, ty);
-}
-
-void AffineTransform::map(double x, double y, double* x2, double* y2) const
-{
- *x2 = x;
- *y2 = y;
- cairo_matrix_transform_point(&m_transform, x2, y2);
-}
-
-IntRect AffineTransform::mapRect(const IntRect &rect) const
-{
- FloatRect floatRect(rect);
- FloatRect enclosingFloatRect = this->mapRect(floatRect);
-
- return enclosingIntRect(enclosingFloatRect);
-}
-
-FloatRect AffineTransform::mapRect(const FloatRect &rect) const
-{
- double rectMinX = rect.x();
- double rectMaxX = rect.x() + rect.width();
- double rectMinY = rect.y();
- double rectMaxY = rect.y() + rect.height();
-
- double px = rectMinX;
- double py = rectMinY;
- cairo_matrix_transform_point(&m_transform, &px, &py);
-
- double enclosingRectMinX = px;
- double enclosingRectMinY = py;
- double enclosingRectMaxX = px;
- double enclosingRectMaxY = py;
-
- px = rectMaxX;
- py = rectMinY;
- cairo_matrix_transform_point(&m_transform, &px, &py);
- if (px < enclosingRectMinX)
- enclosingRectMinX = px;
- else if (px > enclosingRectMaxX)
- enclosingRectMaxX = px;
- if (py < enclosingRectMinY)
- enclosingRectMinY = py;
- else if (py > enclosingRectMaxY)
- enclosingRectMaxY = py;
-
- px = rectMaxX;
- py = rectMaxY;
- cairo_matrix_transform_point(&m_transform, &px, &py);
- if (px < enclosingRectMinX)
- enclosingRectMinX = px;
- else if (px > enclosingRectMaxX)
- enclosingRectMaxX = px;
- if (py < enclosingRectMinY)
- enclosingRectMinY = py;
- else if (py > enclosingRectMaxY)
- enclosingRectMaxY = py;
-
- px = rectMinX;
- py = rectMaxY;
- cairo_matrix_transform_point(&m_transform, &px, &py);
- if (px < enclosingRectMinX)
- enclosingRectMinX = px;
- else if (px > enclosingRectMaxX)
- enclosingRectMaxX = px;
- if (py < enclosingRectMinY)
- enclosingRectMinY = py;
- else if (py > enclosingRectMaxY)
- enclosingRectMaxY = py;
-
-
- double enclosingRectWidth = enclosingRectMaxX - enclosingRectMinX;
- double enclosingRectHeight = enclosingRectMaxY - enclosingRectMinY;
-
- return FloatRect(enclosingRectMinX, enclosingRectMinY, enclosingRectWidth, enclosingRectHeight);
-}
-
-bool AffineTransform::isIdentity() const
-{
- return ((m_transform.xx == 1) && (m_transform.yy == 1)
- && (m_transform.xy == 0) && (m_transform.yx == 0)
- && (m_transform.x0 == 0) && (m_transform.y0 == 0));
-}
-
-double AffineTransform::a() const
-{
- return m_transform.xx;
-}
-
-void AffineTransform::setA(double a)
-{
- m_transform.xx = a;
-}
-
-double AffineTransform::b() const
-{
- return m_transform.yx;
-}
-
-void AffineTransform::setB(double b)
-{
- m_transform.yx = b;
-}
-
-double AffineTransform::c() const
-{
- return m_transform.xy;
-}
-
-void AffineTransform::setC(double c)
-{
- m_transform.xy = c;
-}
-
-double AffineTransform::d() const
-{
- return m_transform.yy;
-}
-
-void AffineTransform::setD(double d)
-{
- m_transform.yy = d;
-}
-
-double AffineTransform::e() const
-{
- return m_transform.x0;
-}
-
-void AffineTransform::setE(double e)
-{
- m_transform.x0 = e;
-}
-
-double AffineTransform::f() const
-{
- return m_transform.y0;
-}
-
-void AffineTransform::setF(double f)
-{
- m_transform.y0 = f;
-}
-
-void AffineTransform::reset()
-{
- cairo_matrix_init_identity(&m_transform);
-}
-
-AffineTransform &AffineTransform::scale(double sx, double sy)
-{
- cairo_matrix_scale(&m_transform, sx, sy);
- return *this;
-}
-
-AffineTransform &AffineTransform::rotate(double d)
-{
- cairo_matrix_rotate(&m_transform, d * deg2rad);
- return *this;
-}
-
-AffineTransform &AffineTransform::translate(double tx, double ty)
-{
- cairo_matrix_translate(&m_transform, tx, ty);
- return *this;
-}
-
-AffineTransform &AffineTransform::shear(double sx, double sy)
-{
- cairo_matrix_t shear;
- cairo_matrix_init(&shear, 1, sy, sx, 1, 0, 0);
-
- cairo_matrix_t result;
- cairo_matrix_multiply(&result, &shear, &m_transform);
- m_transform = result;
-
- return *this;
-}
-
-double AffineTransform::det() const
-{
- return m_transform.xx * m_transform.yy - m_transform.xy * m_transform.yx;
-}
-
-AffineTransform AffineTransform::inverse() const
-{
- if (!isInvertible()) return AffineTransform();
-
- cairo_matrix_t result = m_transform;
- cairo_matrix_invert(&result);
- return AffineTransform(result);
-}
-
-AffineTransform::operator cairo_matrix_t() const
-{
- return m_transform;
-}
-
-bool AffineTransform::operator== (const AffineTransform &m2) const
-{
- return ((m_transform.xx == m2.m_transform.xx)
- && (m_transform.yy == m2.m_transform.yy)
- && (m_transform.xy == m2.m_transform.xy)
- && (m_transform.yx == m2.m_transform.yx)
- && (m_transform.x0 == m2.m_transform.x0)
- && (m_transform.y0 == m2.m_transform.y0));
-
-}
-
-AffineTransform &AffineTransform::operator*= (const AffineTransform &m2)
-{
- cairo_matrix_t result;
- cairo_matrix_multiply(&result, &m_transform, &m2.m_transform);
- m_transform = result;
-
- return *this;
-}
-
-AffineTransform AffineTransform::operator* (const AffineTransform &m2)
-{
- cairo_matrix_t result;
- cairo_matrix_multiply(&result, &m_transform, &m2.m_transform);
- return result;
-}
-
-}
-
-// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/graphics/cairo/CairoPath.h b/WebCore/platform/graphics/cairo/CairoPath.h
deleted file mode 100644
index b761ce6..0000000
--- a/WebCore/platform/graphics/cairo/CairoPath.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- Copyright (C) 2007 Alp Toker <alp.toker@collabora.co.uk>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- aint with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#ifndef CairoPath_h
-#define CairoPath_h
-
-#include <cairo.h>
-
-namespace WebCore {
-
- // This is necessary since cairo_path_fixed_t isn't exposed in Cairo's public API.
- struct CairoPath {
- cairo_t* m_cr;
-
- CairoPath()
- {
- static cairo_surface_t* pathSurface = cairo_image_surface_create(CAIRO_FORMAT_A8, 1, 1);
- m_cr = cairo_create(pathSurface);
- }
-
- ~CairoPath()
- {
- cairo_destroy(m_cr);
- }
- };
-
-} // namespace WebCore
-
-#endif // CairoPath_h
diff --git a/WebCore/platform/graphics/cairo/FontCairo.cpp b/WebCore/platform/graphics/cairo/FontCairo.cpp
deleted file mode 100644
index 9da9426..0000000
--- a/WebCore/platform/graphics/cairo/FontCairo.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
- * Copyright (C) 2007, 2008 Alp Toker <alp@atoker.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Font.h"
-
-#include "GlyphBuffer.h"
-#include "GraphicsContext.h"
-#include "SimpleFontData.h"
-
-namespace WebCore {
-
-void Font::drawGlyphs(GraphicsContext* context, const SimpleFontData* font, const GlyphBuffer& glyphBuffer,
- int from, int numGlyphs, const FloatPoint& point) const
-{
- cairo_t* cr = context->platformContext();
- cairo_save(cr);
-
- font->setFont(cr);
-
- GlyphBufferGlyph* glyphs = (GlyphBufferGlyph*)glyphBuffer.glyphs(from);
-
- float offset = point.x();
- for (int i = 0; i < numGlyphs; i++) {
- glyphs[i].x = offset;
- glyphs[i].y = point.y();
- offset += glyphBuffer.advanceAt(from + i);
- }
-
- Color fillColor = context->fillColor();
-
- // Text shadow, inspired by FontMac
- IntSize shadowSize;
- int shadowBlur = 0;
- Color shadowColor;
- bool hasShadow = context->textDrawingMode() == cTextFill &&
- context->getShadow(shadowSize, shadowBlur, shadowColor);
-
- // TODO: Blur support
- if (hasShadow) {
- // Disable graphics context shadows (not yet implemented) and paint them manually
- context->clearShadow();
- Color shadowFillColor(shadowColor.red(), shadowColor.green(), shadowColor.blue(), shadowColor.alpha() * fillColor.alpha() / 255);
- cairo_save(cr);
-
- float red, green, blue, alpha;
- shadowFillColor.getRGBA(red, green, blue, alpha);
- cairo_set_source_rgba(cr, red, green, blue, alpha);
-
- cairo_translate(cr, shadowSize.width(), shadowSize.height());
- cairo_show_glyphs(cr, glyphs, numGlyphs);
-
- cairo_restore(cr);
- }
-
- if (context->textDrawingMode() & cTextFill) {
- float red, green, blue, alpha;
- fillColor.getRGBA(red, green, blue, alpha);
- cairo_set_source_rgba(cr, red, green, blue, alpha);
-
- cairo_show_glyphs(cr, glyphs, numGlyphs);
- }
-
- if (context->textDrawingMode() & cTextStroke) {
- Color strokeColor = context->strokeColor();
- float red, green, blue, alpha;
- strokeColor.getRGBA(red, green, blue, alpha);
- cairo_set_source_rgba(cr, red, green, blue, alpha);
- cairo_glyph_path(cr, glyphs, numGlyphs);
- cairo_set_line_width(cr, context->strokeThickness());
- cairo_stroke(cr);
- }
-
- // Re-enable the platform shadow we disabled earlier
- if (hasShadow)
- context->setShadow(shadowSize, shadowBlur, shadowColor);
-
- cairo_restore(cr);
-}
-
-}
diff --git a/WebCore/platform/graphics/cairo/GradientCairo.cpp b/WebCore/platform/graphics/cairo/GradientCairo.cpp
deleted file mode 100644
index 7776424..0000000
--- a/WebCore/platform/graphics/cairo/GradientCairo.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2007 Alp Toker <alp@atoker.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Gradient.h"
-
-#include "CSSParser.h"
-#include "GraphicsContext.h"
-#include <cairo.h>
-
-namespace WebCore {
-
-void Gradient::platformDestroy()
-{
- if (m_gradient) {
- cairo_pattern_destroy(m_gradient);
- m_gradient = 0;
- }
-}
-
-cairo_pattern_t* Gradient::platformGradient()
-{
- if (m_gradient)
- return m_gradient;
-
- if (m_radial)
- m_gradient = cairo_pattern_create_radial(m_p0.x(), m_p0.y(), m_r0, m_p1.x(), m_p1.y(), m_r1);
- else
- m_gradient = cairo_pattern_create_linear(m_p0.x(), m_p0.y(), m_p1.x(), m_p1.y());
-
- Vector<ColorStop>::iterator stopIterator = m_stops.begin();
- while (stopIterator != m_stops.end()) {
- cairo_pattern_add_color_stop_rgba(m_gradient, stopIterator->stop, stopIterator->red, stopIterator->green, stopIterator->blue, stopIterator->alpha);
- ++stopIterator;
- }
-
- return m_gradient;
-}
-
-void Gradient::fill(GraphicsContext* context, const FloatRect& rect)
-{
- cairo_t* cr = context->platformContext();
-
- cairo_save(cr);
- cairo_set_source(cr, platformGradient());
- cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height());
- cairo_fill(cr);
- cairo_restore(cr);
-}
-
-} //namespace
diff --git a/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp b/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
deleted file mode 100644
index c403f44..0000000
--- a/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
+++ /dev/null
@@ -1,1104 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2007 Alp Toker <alp@atoker.com>
- * Copyright (C) 2008 Dirk Schulze <vbs85@gmx.de>
- * Copyright (C) 2008 Nuanti Ltd.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "GraphicsContext.h"
-
-#if PLATFORM(CAIRO)
-
-#include "AffineTransform.h"
-#include "CairoPath.h"
-#include "FloatRect.h"
-#include "Font.h"
-#include "ImageBuffer.h"
-#include "IntRect.h"
-#include "NotImplemented.h"
-#include "Path.h"
-#include "Pattern.h"
-#include "SimpleFontData.h"
-
-#include <cairo.h>
-#include <math.h>
-#include <stdio.h>
-#include <wtf/MathExtras.h>
-
-#if PLATFORM(GTK)
-#include <gdk/gdk.h>
-#include <pango/pango.h>
-#elif PLATFORM(WIN)
-#include <cairo-win32.h>
-#endif
-#include "GraphicsContextPrivate.h"
-#include "GraphicsContextPlatformPrivateCairo.h"
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-namespace WebCore {
-
-static inline void setColor(cairo_t* cr, const Color& col)
-{
- float red, green, blue, alpha;
- col.getRGBA(red, green, blue, alpha);
- cairo_set_source_rgba(cr, red, green, blue, alpha);
-}
-
-// A fillRect helper
-static inline void fillRectSourceOver(cairo_t* cr, const FloatRect& rect, const Color& col)
-{
- setColor(cr, col);
- cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height());
- cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
- cairo_fill(cr);
-}
-
-static inline cairo_pattern_t* applySpreadMethod(cairo_pattern_t* pattern, GradientSpreadMethod spreadMethod)
-{
- switch (spreadMethod) {
- case SpreadMethodPad:
- cairo_pattern_set_extend(pattern, CAIRO_EXTEND_PAD);
- break;
- case SpreadMethodReflect:
- cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REFLECT);
- break;
- case SpreadMethodRepeat:
- cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT);
- break;
- default:
- cairo_pattern_set_extend(pattern, CAIRO_EXTEND_NONE);
- break;
- }
- return pattern;
-}
-
-GraphicsContext::GraphicsContext(PlatformGraphicsContext* cr)
- : m_common(createGraphicsContextPrivate())
- , m_data(new GraphicsContextPlatformPrivate)
-{
- m_data->cr = cairo_reference(cr);
- setPaintingDisabled(!cr);
-}
-
-GraphicsContext::~GraphicsContext()
-{
- destroyGraphicsContextPrivate(m_common);
- delete m_data;
-}
-
-AffineTransform GraphicsContext::getCTM() const
-{
- cairo_t* cr = platformContext();
- cairo_matrix_t m;
- cairo_get_matrix(cr, &m);
- return m;
-}
-
-cairo_t* GraphicsContext::platformContext() const
-{
- return m_data->cr;
-}
-
-void GraphicsContext::savePlatformState()
-{
- cairo_save(m_data->cr);
- m_data->save();
-}
-
-void GraphicsContext::restorePlatformState()
-{
- cairo_restore(m_data->cr);
- m_data->restore();
-}
-
-// Draws a filled rectangle with a stroked border.
-void GraphicsContext::drawRect(const IntRect& rect)
-{
- if (paintingDisabled())
- return;
-
- cairo_t* cr = m_data->cr;
- cairo_save(cr);
-
- if (fillColor().alpha())
- fillRectSourceOver(cr, rect, fillColor());
-
- if (strokeStyle() != NoStroke) {
- setColor(cr, strokeColor());
- FloatRect r(rect);
- r.inflate(-.5f);
- cairo_rectangle(cr, r.x(), r.y(), r.width(), r.height());
- cairo_set_line_width(cr, 1.0);
- cairo_stroke(cr);
- }
-
- cairo_restore(cr);
-}
-
-// FIXME: Now that this is refactored, it should be shared by all contexts.
-static void adjustLineToPixelBoundaries(FloatPoint& p1, FloatPoint& p2, float strokeWidth, StrokeStyle style)
-{
- // For odd widths, we add in 0.5 to the appropriate x/y so that the float arithmetic
- // works out. For example, with a border width of 3, KHTML will pass us (y1+y2)/2, e.g.,
- // (50+53)/2 = 103/2 = 51 when we want 51.5. It is always true that an even width gave
- // us a perfect position, but an odd width gave us a position that is off by exactly 0.5.
- if (style == DottedStroke || style == DashedStroke) {
- if (p1.x() == p2.x()) {
- p1.setY(p1.y() + strokeWidth);
- p2.setY(p2.y() - strokeWidth);
- }
- else {
- p1.setX(p1.x() + strokeWidth);
- p2.setX(p2.x() - strokeWidth);
- }
- }
-
- if (static_cast<int>(strokeWidth) % 2) {
- if (p1.x() == p2.x()) {
- // We're a vertical line. Adjust our x.
- p1.setX(p1.x() + 0.5);
- p2.setX(p2.x() + 0.5);
- }
- else {
- // We're a horizontal line. Adjust our y.
- p1.setY(p1.y() + 0.5);
- p2.setY(p2.y() + 0.5);
- }
- }
-}
-
-// This is only used to draw borders.
-void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2)
-{
- if (paintingDisabled())
- return;
-
- StrokeStyle style = strokeStyle();
- if (style == NoStroke)
- return;
-
- cairo_t* cr = m_data->cr;
- cairo_save(cr);
-
- float width = strokeThickness();
- if (width < 1)
- width = 1;
-
- FloatPoint p1 = point1;
- FloatPoint p2 = point2;
- bool isVerticalLine = (p1.x() == p2.x());
-
- adjustLineToPixelBoundaries(p1, p2, width, style);
- cairo_set_line_width(cr, width);
-
- int patWidth = 0;
- switch (style) {
- case NoStroke:
- case SolidStroke:
- break;
- case DottedStroke:
- patWidth = static_cast<int>(width);
- break;
- case DashedStroke:
- patWidth = 3*static_cast<int>(width);
- break;
- }
-
- setColor(cr, strokeColor());
-
- cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE);
-
- if (patWidth) {
- // Do a rect fill of our endpoints. This ensures we always have the
- // appearance of being a border. We then draw the actual dotted/dashed line.
- if (isVerticalLine) {
- fillRectSourceOver(cr, FloatRect(p1.x() - width/2, p1.y() - width, width, width), strokeColor());
- fillRectSourceOver(cr, FloatRect(p2.x() - width/2, p2.y(), width, width), strokeColor());
- } else {
- fillRectSourceOver(cr, FloatRect(p1.x() - width, p1.y() - width/2, width, width), strokeColor());
- fillRectSourceOver(cr, FloatRect(p2.x(), p2.y() - width/2, width, width), strokeColor());
- }
-
- // Example: 80 pixels with a width of 30 pixels.
- // Remainder is 20. The maximum pixels of line we could paint
- // will be 50 pixels.
- int distance = (isVerticalLine ? (point2.y() - point1.y()) : (point2.x() - point1.x())) - 2*static_cast<int>(width);
- int remainder = distance%patWidth;
- int coverage = distance-remainder;
- int numSegments = coverage/patWidth;
-
- float patternOffset = 0;
- // Special case 1px dotted borders for speed.
- if (patWidth == 1)
- patternOffset = 1.0;
- else {
- bool evenNumberOfSegments = numSegments%2 == 0;
- if (remainder)
- evenNumberOfSegments = !evenNumberOfSegments;
- if (evenNumberOfSegments) {
- if (remainder) {
- patternOffset += patWidth - remainder;
- patternOffset += remainder/2;
- }
- else
- patternOffset = patWidth/2;
- }
- else if (!evenNumberOfSegments) {
- if (remainder)
- patternOffset = (patWidth - remainder)/2;
- }
- }
-
- double dash = patWidth;
- cairo_set_dash(cr, &dash, 1, patternOffset);
- }
-
- cairo_move_to(cr, p1.x(), p1.y());
- cairo_line_to(cr, p2.x(), p2.y());
-
- cairo_stroke(cr);
- cairo_restore(cr);
-}
-
-// This method is only used to draw the little circles used in lists.
-void GraphicsContext::drawEllipse(const IntRect& rect)
-{
- if (paintingDisabled())
- return;
-
- cairo_t* cr = m_data->cr;
- cairo_save(cr);
- float yRadius = .5 * rect.height();
- float xRadius = .5 * rect.width();
- cairo_translate(cr, rect.x() + xRadius, rect.y() + yRadius);
- cairo_scale(cr, xRadius, yRadius);
- cairo_arc(cr, 0., 0., 1., 0., 2 * M_PI);
- cairo_restore(cr);
-
- if (fillColor().alpha()) {
- setColor(cr, fillColor());
- cairo_fill_preserve(cr);
- }
-
- if (strokeStyle() != NoStroke) {
- setColor(cr, strokeColor());
- cairo_set_line_width(cr, strokeThickness());
- cairo_stroke(cr);
- }
-
- cairo_new_path(cr);
-}
-
-void GraphicsContext::strokeArc(const IntRect& rect, int startAngle, int angleSpan)
-{
- if (paintingDisabled() || strokeStyle() == NoStroke)
- return;
-
- int x = rect.x();
- int y = rect.y();
- float w = rect.width();
- float h = rect.height();
- float scaleFactor = h / w;
- float reverseScaleFactor = w / h;
-
- float hRadius = w / 2;
- float vRadius = h / 2;
- float fa = startAngle;
- float falen = fa + angleSpan;
-
- cairo_t* cr = m_data->cr;
- cairo_save(cr);
-
- if (w != h)
- cairo_scale(cr, 1., scaleFactor);
-
- cairo_arc_negative(cr, x + hRadius, (y + vRadius) * reverseScaleFactor, hRadius, -fa * M_PI/180, -falen * M_PI/180);
-
- if (w != h)
- cairo_scale(cr, 1., reverseScaleFactor);
-
- float width = strokeThickness();
- int patWidth = 0;
-
- switch (strokeStyle()) {
- case DottedStroke:
- patWidth = static_cast<int>(width / 2);
- break;
- case DashedStroke:
- patWidth = 3 * static_cast<int>(width / 2);
- break;
- default:
- break;
- }
-
- setColor(cr, strokeColor());
-
- if (patWidth) {
- // Example: 80 pixels with a width of 30 pixels.
- // Remainder is 20. The maximum pixels of line we could paint
- // will be 50 pixels.
- int distance;
- if (hRadius == vRadius)
- distance = static_cast<int>((M_PI * hRadius) / 2.0);
- else // We are elliptical and will have to estimate the distance
- distance = static_cast<int>((M_PI * sqrtf((hRadius * hRadius + vRadius * vRadius) / 2.0)) / 2.0);
-
- int remainder = distance % patWidth;
- int coverage = distance - remainder;
- int numSegments = coverage / patWidth;
-
- float patternOffset = 0.0;
- // Special case 1px dotted borders for speed.
- if (patWidth == 1)
- patternOffset = 1.0;
- else {
- bool evenNumberOfSegments = numSegments % 2 == 0;
- if (remainder)
- evenNumberOfSegments = !evenNumberOfSegments;
- if (evenNumberOfSegments) {
- if (remainder) {
- patternOffset += patWidth - remainder;
- patternOffset += remainder / 2.0;
- } else
- patternOffset = patWidth / 2.0;
- } else {
- if (remainder)
- patternOffset = (patWidth - remainder) / 2.0;
- }
- }
-
- double dash = patWidth;
- cairo_set_dash(cr, &dash, 1, patternOffset);
- }
-
- cairo_stroke(cr);
- cairo_restore(cr);
-}
-
-void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points, bool shouldAntialias)
-{
- if (paintingDisabled())
- return;
-
- if (npoints <= 1)
- return;
-
- cairo_t* cr = m_data->cr;
-
- cairo_save(cr);
- cairo_set_antialias(cr, shouldAntialias ? CAIRO_ANTIALIAS_DEFAULT : CAIRO_ANTIALIAS_NONE);
- cairo_move_to(cr, points[0].x(), points[0].y());
- for (size_t i = 1; i < npoints; i++)
- cairo_line_to(cr, points[i].x(), points[i].y());
- cairo_close_path(cr);
-
- if (fillColor().alpha()) {
- setColor(cr, fillColor());
- cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD);
- cairo_fill_preserve(cr);
- }
-
- if (strokeStyle() != NoStroke) {
- setColor(cr, strokeColor());
- cairo_set_line_width(cr, strokeThickness());
- cairo_stroke(cr);
- }
-
- cairo_new_path(cr);
- cairo_restore(cr);
-}
-
-void GraphicsContext::fillPath()
-{
- if (paintingDisabled())
- return;
-
- cairo_t* cr = m_data->cr;
- cairo_save(cr);
-
- cairo_set_fill_rule(cr, fillRule() == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING);
- switch (m_common->state.fillColorSpace) {
- case SolidColorSpace:
- if (fillColor().alpha()) {
- setColor(cr, fillColor());
- cairo_clip(cr);
- cairo_paint_with_alpha(cr, m_common->state.globalAlpha);
- }
- break;
- case PatternColorSpace:
- cairo_set_source(cr, m_common->state.fillPattern.get()->createPlatformPattern(getCTM()));
- cairo_clip(cr);
- cairo_paint_with_alpha(cr, m_common->state.globalAlpha);
- break;
- case GradientColorSpace:
- cairo_pattern_t* pattern = m_common->state.fillGradient.get()->platformGradient();
- pattern = applySpreadMethod(pattern, spreadMethod());
- cairo_set_source(cr, pattern);
- cairo_clip(cr);
- cairo_paint_with_alpha(cr, m_common->state.globalAlpha);
- break;
- }
- cairo_restore(cr);
-}
-
-void GraphicsContext::strokePath()
-{
- if (paintingDisabled())
- return;
-
- cairo_t* cr = m_data->cr;
- cairo_save(cr);
- switch (m_common->state.strokeColorSpace) {
- case SolidColorSpace:
- if (strokeColor().alpha()) {
- setColor(cr, strokeColor());
- if (m_common->state.globalAlpha < 1.0f) {
- cairo_push_group(cr);
- cairo_paint_with_alpha(cr, m_common->state.globalAlpha);
- cairo_pop_group_to_source(cr);
- }
- cairo_stroke(cr);
- }
- break;
- case PatternColorSpace:
- cairo_set_source(cr, m_common->state.strokePattern.get()->createPlatformPattern(getCTM()));
- if (m_common->state.globalAlpha < 1.0f) {
- cairo_push_group(cr);
- cairo_paint_with_alpha(cr, m_common->state.globalAlpha);
- cairo_pop_group_to_source(cr);
- }
- cairo_stroke(cr);
- break;
- case GradientColorSpace:
- cairo_pattern_t* pattern = m_common->state.strokeGradient.get()->platformGradient();
- pattern = applySpreadMethod(pattern, spreadMethod());
- cairo_set_source(cr, pattern);
- if (m_common->state.globalAlpha < 1.0f) {
- cairo_push_group(cr);
- cairo_paint_with_alpha(cr, m_common->state.globalAlpha);
- cairo_pop_group_to_source(cr);
- }
- cairo_stroke(cr);
- break;
- }
- cairo_restore(cr);
-}
-
-void GraphicsContext::drawPath()
-{
- fillPath();
- strokePath();
-}
-
-void GraphicsContext::fillRect(const FloatRect& rect)
-{
- if (paintingDisabled())
- return;
-
- cairo_t* cr = m_data->cr;
- cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height());
- fillPath();
-}
-
-void GraphicsContext::fillRect(const FloatRect& rect, const Color& color)
-{
- if (paintingDisabled())
- return;
-
- if (color.alpha())
- fillRectSourceOver(m_data->cr, rect, color);
-}
-
-void GraphicsContext::clip(const FloatRect& rect)
-{
- if (paintingDisabled())
- return;
-
- cairo_t* cr = m_data->cr;
- cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height());
- cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr);
- cairo_set_fill_rule(cr, CAIRO_FILL_RULE_WINDING);
- cairo_clip(cr);
- cairo_set_fill_rule(cr, savedFillRule);
- m_data->clip(rect);
-}
-
-void GraphicsContext::drawFocusRing(const Color& color)
-{
- if (paintingDisabled())
- return;
-
- const Vector<IntRect>& rects = focusRingRects();
- unsigned rectCount = rects.size();
-
- cairo_t* cr = m_data->cr;
- cairo_save(cr);
- cairo_push_group(cr);
- cairo_new_path(cr);
-
-#if PLATFORM(GTK)
- GdkRegion* reg = gdk_region_new();
- for (unsigned i = 0; i < rectCount; i++) {
- GdkRectangle rect = rects[i];
- gdk_region_union_with_rect(reg, &rect);
- }
- gdk_cairo_region(cr, reg);
- gdk_region_destroy(reg);
-
- setColor(cr, color);
- cairo_set_line_width(cr, 2.0f);
- setPlatformStrokeStyle(DottedStroke);
-#else
- int radius = (focusRingWidth() - 1) / 2;
- for (unsigned i = 0; i < rectCount; i++)
- addPath(Path::createRoundedRectangle(rects[i], FloatSize(radius, radius)));
-
- // Force the alpha to 50%. This matches what the Mac does with outline rings.
- Color ringColor(color.red(), color.green(), color.blue(), 127);
- setColor(cr, ringColor);
- cairo_set_line_width(cr, focusRingWidth());
- setPlatformStrokeStyle(SolidStroke);
-#endif
-
- cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
- cairo_stroke_preserve(cr);
-
- cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
- cairo_set_fill_rule(cr, CAIRO_FILL_RULE_WINDING);
- cairo_fill(cr);
-
- cairo_pop_group_to_source(cr);
- cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
- cairo_paint(cr);
- cairo_restore(cr);
-}
-
-void GraphicsContext::drawLineForText(const IntPoint& origin, int width, bool printing)
-{
- if (paintingDisabled())
- return;
-
- // This is a workaround for http://bugs.webkit.org/show_bug.cgi?id=15659
- StrokeStyle savedStrokeStyle = strokeStyle();
- setStrokeStyle(SolidStroke);
-
- IntPoint endPoint = origin + IntSize(width, 0);
- drawLine(origin, endPoint);
-
- setStrokeStyle(savedStrokeStyle);
-}
-
-void GraphicsContext::drawLineForMisspellingOrBadGrammar(const IntPoint& origin, int width, bool grammar)
-{
- if (paintingDisabled())
- return;
-
- cairo_t* cr = m_data->cr;
- cairo_save(cr);
-
- // Convention is green for grammar, red for spelling
- // These need to become configurable
- if (grammar)
- cairo_set_source_rgb(cr, 0, 1, 0);
- else
- cairo_set_source_rgb(cr, 1, 0, 0);
-
-#if PLATFORM(GTK)
- // We ignore most of the provided constants in favour of the platform style
- pango_cairo_show_error_underline(cr, origin.x(), origin.y(), width, cMisspellingLineThickness);
-#else
- notImplemented();
-#endif
-
- cairo_restore(cr);
-}
-
-FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& frect)
-{
- FloatRect result;
- double x = frect.x();
- double y = frect.y();
- cairo_t* cr = m_data->cr;
- cairo_user_to_device(cr, &x, &y);
- x = round(x);
- y = round(y);
- cairo_device_to_user(cr, &x, &y);
- result.setX(static_cast<float>(x));
- result.setY(static_cast<float>(y));
- x = frect.width();
- y = frect.height();
- cairo_user_to_device_distance(cr, &x, &y);
- x = round(x);
- y = round(y);
- cairo_device_to_user_distance(cr, &x, &y);
- result.setWidth(static_cast<float>(x));
- result.setHeight(static_cast<float>(y));
- return result;
-}
-
-void GraphicsContext::translate(float x, float y)
-{
- if (paintingDisabled())
- return;
-
- cairo_t* cr = m_data->cr;
- cairo_translate(cr, x, y);
- m_data->translate(x, y);
-}
-
-IntPoint GraphicsContext::origin()
-{
- cairo_matrix_t matrix;
- cairo_t* cr = m_data->cr;
- cairo_get_matrix(cr, &matrix);
- return IntPoint(static_cast<int>(matrix.x0), static_cast<int>(matrix.y0));
-}
-
-void GraphicsContext::setPlatformFillColor(const Color& col)
-{
- // Cairo contexts can't hold separate fill and stroke colors
- // so we set them just before we actually fill or stroke
-}
-
-void GraphicsContext::setPlatformStrokeColor(const Color& col)
-{
- // Cairo contexts can't hold separate fill and stroke colors
- // so we set them just before we actually fill or stroke
-}
-
-void GraphicsContext::setPlatformStrokeThickness(float strokeThickness)
-{
- if (paintingDisabled())
- return;
-
- cairo_set_line_width(m_data->cr, strokeThickness);
-}
-
-void GraphicsContext::setPlatformStrokeStyle(const StrokeStyle& strokeStyle)
-{
- static double dashPattern[] = {5.0, 5.0};
- static double dotPattern[] = {1.0, 1.0};
-
- if (paintingDisabled())
- return;
-
- switch (strokeStyle) {
- case NoStroke:
- // FIXME: is it the right way to emulate NoStroke?
- cairo_set_line_width(m_data->cr, 0);
- break;
- case SolidStroke:
- cairo_set_dash(m_data->cr, 0, 0, 0);
- break;
- case DottedStroke:
- cairo_set_dash(m_data->cr, dotPattern, 2, 0);
- break;
- case DashedStroke:
- cairo_set_dash(m_data->cr, dashPattern, 2, 0);
- break;
- }
-}
-
-void GraphicsContext::setURLForRect(const KURL& link, const IntRect& destRect)
-{
- notImplemented();
-}
-
-void GraphicsContext::concatCTM(const AffineTransform& transform)
-{
- if (paintingDisabled())
- return;
-
- cairo_t* cr = m_data->cr;
- const cairo_matrix_t* matrix = reinterpret_cast<const cairo_matrix_t*>(&transform);
- cairo_transform(cr, matrix);
- m_data->concatCTM(transform);
-}
-
-void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect, int thickness)
-{
- if (paintingDisabled())
- return;
-
- clip(rect);
-
- Path p;
- FloatRect r(rect);
- // Add outer ellipse
- p.addEllipse(r);
- // Add inner ellipse
- r.inflate(-thickness);
- p.addEllipse(r);
- addPath(p);
-
- cairo_t* cr = m_data->cr;
- cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr);
- cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD);
- cairo_clip(cr);
- cairo_set_fill_rule(cr, savedFillRule);
-}
-
-void GraphicsContext::clipToImageBuffer(const FloatRect& rect, const ImageBuffer* imageBuffer)
-{
- if (paintingDisabled())
- return;
-
- notImplemented();
-}
-
-void GraphicsContext::setPlatformShadow(IntSize const&, int, Color const&)
-{
- notImplemented();
-}
-
-void GraphicsContext::clearPlatformShadow()
-{
- notImplemented();
-}
-
-void GraphicsContext::beginTransparencyLayer(float opacity)
-{
- if (paintingDisabled())
- return;
-
- cairo_t* cr = m_data->cr;
- cairo_push_group(cr);
- m_data->layers.append(opacity);
- m_data->beginTransparencyLayer();
-}
-
-void GraphicsContext::endTransparencyLayer()
-{
- if (paintingDisabled())
- return;
-
- cairo_t* cr = m_data->cr;
-
- cairo_pop_group_to_source(cr);
- cairo_paint_with_alpha(cr, m_data->layers.last());
- m_data->layers.removeLast();
- m_data->endTransparencyLayer();
-}
-
-void GraphicsContext::clearRect(const FloatRect& rect)
-{
- if (paintingDisabled())
- return;
-
- cairo_t* cr = m_data->cr;
-
- cairo_save(cr);
- cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height());
- cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
- cairo_fill(cr);
- cairo_restore(cr);
-}
-
-void GraphicsContext::strokeRect(const FloatRect& rect, float width)
-{
- if (paintingDisabled())
- return;
-
- cairo_t* cr = m_data->cr;
- cairo_save(cr);
- cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height());
- cairo_set_line_width(cr, width);
- strokePath();
- cairo_restore(cr);
-}
-
-void GraphicsContext::setLineCap(LineCap lineCap)
-{
- if (paintingDisabled())
- return;
-
- cairo_line_cap_t cairoCap = CAIRO_LINE_CAP_BUTT;
- switch (lineCap) {
- case ButtCap:
- // no-op
- break;
- case RoundCap:
- cairoCap = CAIRO_LINE_CAP_ROUND;
- break;
- case SquareCap:
- cairoCap = CAIRO_LINE_CAP_SQUARE;
- break;
- }
- cairo_set_line_cap(m_data->cr, cairoCap);
-}
-
-void GraphicsContext::setLineDash(const DashArray& dashes, float dashOffset)
-{
- cairo_set_dash(m_data->cr, dashes.data(), dashes.size(), dashOffset);
-}
-
-void GraphicsContext::setLineJoin(LineJoin lineJoin)
-{
- if (paintingDisabled())
- return;
-
- cairo_line_join_t cairoJoin = CAIRO_LINE_JOIN_MITER;
- switch (lineJoin) {
- case MiterJoin:
- // no-op
- break;
- case RoundJoin:
- cairoJoin = CAIRO_LINE_JOIN_ROUND;
- break;
- case BevelJoin:
- cairoJoin = CAIRO_LINE_JOIN_BEVEL;
- break;
- }
- cairo_set_line_join(m_data->cr, cairoJoin);
-}
-
-void GraphicsContext::setMiterLimit(float miter)
-{
- if (paintingDisabled())
- return;
-
- cairo_set_miter_limit(m_data->cr, miter);
-}
-
-void GraphicsContext::setAlpha(float alpha)
-{
- m_common->state.globalAlpha = alpha;
-}
-
-float GraphicsContext::getAlpha()
-{
- return m_common->state.globalAlpha;
-}
-
-static inline cairo_operator_t toCairoOperator(CompositeOperator op)
-{
- switch (op) {
- case CompositeClear:
- return CAIRO_OPERATOR_CLEAR;
- case CompositeCopy:
- return CAIRO_OPERATOR_SOURCE;
- case CompositeSourceOver:
- return CAIRO_OPERATOR_OVER;
- case CompositeSourceIn:
- return CAIRO_OPERATOR_IN;
- case CompositeSourceOut:
- return CAIRO_OPERATOR_OUT;
- case CompositeSourceAtop:
- return CAIRO_OPERATOR_ATOP;
- case CompositeDestinationOver:
- return CAIRO_OPERATOR_DEST_OVER;
- case CompositeDestinationIn:
- return CAIRO_OPERATOR_DEST_IN;
- case CompositeDestinationOut:
- return CAIRO_OPERATOR_DEST_OUT;
- case CompositeDestinationAtop:
- return CAIRO_OPERATOR_DEST_ATOP;
- case CompositeXOR:
- return CAIRO_OPERATOR_XOR;
- case CompositePlusDarker:
- return CAIRO_OPERATOR_SATURATE;
- case CompositeHighlight:
- // There is no Cairo equivalent for CompositeHighlight.
- return CAIRO_OPERATOR_OVER;
- case CompositePlusLighter:
- return CAIRO_OPERATOR_ADD;
- default:
- return CAIRO_OPERATOR_SOURCE;
- }
-}
-
-void GraphicsContext::setCompositeOperation(CompositeOperator op)
-{
- if (paintingDisabled())
- return;
-
- cairo_set_operator(m_data->cr, toCairoOperator(op));
-}
-
-void GraphicsContext::beginPath()
-{
- if (paintingDisabled())
- return;
-
- cairo_t* cr = m_data->cr;
- cairo_new_path(cr);
-}
-
-void GraphicsContext::addPath(const Path& path)
-{
- if (paintingDisabled())
- return;
-
- cairo_t* cr = m_data->cr;
- cairo_path_t* p = cairo_copy_path(path.platformPath()->m_cr);
- cairo_append_path(cr, p);
- cairo_path_destroy(p);
-}
-
-void GraphicsContext::clip(const Path& path)
-{
- if (paintingDisabled())
- return;
-
- cairo_t* cr = m_data->cr;
- cairo_path_t* p = cairo_copy_path(path.platformPath()->m_cr);
- cairo_append_path(cr, p);
- cairo_path_destroy(p);
- cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr);
- cairo_set_fill_rule(cr, CAIRO_FILL_RULE_WINDING);
- cairo_clip(cr);
- cairo_set_fill_rule(cr, savedFillRule);
- m_data->clip(path);
-}
-
-void GraphicsContext::clipOut(const Path& path)
-{
- if (paintingDisabled())
- return;
-
-#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1,4,0)
- cairo_t* cr = m_data->cr;
- double x1, y1, x2, y2;
- cairo_clip_extents(cr, &x1, &y1, &x2, &y2);
- cairo_rectangle(cr, x1, y1, x2 - x1, y2 - y1);
- addPath(path);
-
- cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr);
- cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD);
- cairo_clip(cr);
- cairo_set_fill_rule(cr, savedFillRule);
-#else
- notImplemented();
-#endif
-}
-
-void GraphicsContext::rotate(float radians)
-{
- if (paintingDisabled())
- return;
-
- cairo_rotate(m_data->cr, radians);
- m_data->rotate(radians);
-}
-
-void GraphicsContext::scale(const FloatSize& size)
-{
- if (paintingDisabled())
- return;
-
- cairo_scale(m_data->cr, size.width(), size.height());
- m_data->scale(size);
-}
-
-void GraphicsContext::clipOut(const IntRect& r)
-{
- if (paintingDisabled())
- return;
-
-#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1,4,0)
- cairo_t* cr = m_data->cr;
- double x1, y1, x2, y2;
- cairo_clip_extents(cr, &x1, &y1, &x2, &y2);
- cairo_rectangle(cr, x1, x2, x2 - x1, y2 - y1);
- cairo_rectangle(cr, r.x(), r.y(), r.width(), r.height());
- cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr);
- cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD);
- cairo_clip(cr);
- cairo_set_fill_rule(cr, savedFillRule);
-#else
- notImplemented();
-#endif
-}
-
-void GraphicsContext::clipOutEllipseInRect(const IntRect& r)
-{
- if (paintingDisabled())
- return;
-
- Path p;
- p.addEllipse(r);
- clipOut(p);
-}
-
-void GraphicsContext::fillRoundedRect(const IntRect& r, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color& color)
-{
- if (paintingDisabled())
- return;
-
- cairo_t* cr = m_data->cr;
- cairo_save(cr);
- beginPath();
- addPath(Path::createRoundedRectangle(r, topLeft, topRight, bottomLeft, bottomRight));
- setColor(cr, color);
- cairo_fill(cr);
- cairo_restore(cr);
-}
-
-#if PLATFORM(GTK)
-void GraphicsContext::setGdkExposeEvent(GdkEventExpose* expose)
-{
- m_data->expose = expose;
-}
-
-GdkEventExpose* GraphicsContext::gdkExposeEvent() const
-{
- return m_data->expose;
-}
-
-GdkDrawable* GraphicsContext::gdkDrawable() const
-{
- if (!m_data->expose)
- return 0;
-
- return GDK_DRAWABLE(m_data->expose->window);
-}
-#endif
-
-void GraphicsContext::setUseAntialiasing(bool enable)
-{
- if (paintingDisabled())
- return;
-
- // When true, use the default Cairo backend antialias mode (usually this
- // enables standard 'grayscale' antialiasing); false to explicitly disable
- // antialiasing. This is the same strategy as used in drawConvexPolygon().
- cairo_set_antialias(m_data->cr, enable ? CAIRO_ANTIALIAS_DEFAULT : CAIRO_ANTIALIAS_NONE);
-}
-
-void GraphicsContext::setImageInterpolationQuality(InterpolationQuality)
-{
-}
-
-InterpolationQuality GraphicsContext::imageInterpolationQuality() const
-{
- return InterpolationDefault;
-}
-
-} // namespace WebCore
-
-#endif // PLATFORM(CAIRO)
diff --git a/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h b/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h
deleted file mode 100644
index 9a14555..0000000
--- a/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2007 Alp Toker <alp@atoker.com>
- * Copyright (C) 2008 Brent Fulgham <bfulgham@gmail.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "GraphicsContext.h"
-
-#include <cairo.h>
-#include <math.h>
-#include <stdio.h>
-#include <wtf/MathExtras.h>
-
-#if PLATFORM(GTK)
-#include <gdk/gdk.h>
-#include <pango/pango.h>
-#elif PLATFORM(WIN)
-#include <cairo-win32.h>
-#endif
-
-namespace WebCore {
-
-class GraphicsContextPlatformPrivate {
-public:
- GraphicsContextPlatformPrivate()
- : cr(0)
-#if PLATFORM(GTK)
- , expose(0)
-#elif PLATFORM(WIN)
- // NOTE: These may note be needed: review and remove once Cairo implementation is complete
- , m_hdc(0)
- , m_transparencyCount(0)
-#endif
- {
- }
-
- ~GraphicsContextPlatformPrivate()
- {
- cairo_destroy(cr);
- }
-
-#if PLATFORM(WIN)
- // On Windows, we need to update the HDC for form controls to draw in the right place.
- void save();
- void restore();
- void clip(const FloatRect&);
- void clip(const Path&);
- void scale(const FloatSize&);
- void rotate(float);
- void translate(float, float);
- void concatCTM(const AffineTransform&);
- void beginTransparencyLayer() { m_transparencyCount++; }
- void endTransparencyLayer() { m_transparencyCount--; }
-#else
- // On everything else, we do nothing.
- void save() {}
- void restore() {}
- void clip(const FloatRect&) {}
- void clip(const Path&) {}
- void scale(const FloatSize&) {}
- void rotate(float) {}
- void translate(float, float) {}
- void concatCTM(const AffineTransform&) {}
- void beginTransparencyLayer() {}
- void endTransparencyLayer() {}
-#endif
-
- cairo_t* cr;
- Vector<float> layers;
-
-#if PLATFORM(GTK)
- GdkEventExpose* expose;
-#elif PLATFORM(WIN)
- HDC m_hdc;
- unsigned m_transparencyCount;
-#endif
-};
-
-} // namespace WebCore
-
diff --git a/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp b/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp
deleted file mode 100644
index 5f65ed2..0000000
--- a/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
- * Copyright (C) 2007 Holger Hans Peter Freyther <zecke@selfish.org>
- * Copyright (C) 2008 Dirk Schulze <vbs85@gmx.de>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ImageBuffer.h"
-
-#include "Base64.h"
-#include "BitmapImage.h"
-#include "GraphicsContext.h"
-#include "ImageData.h"
-#include "MIMETypeRegistry.h"
-#include "NotImplemented.h"
-#include "Pattern.h"
-#include "PlatformString.h"
-
-#include <cairo.h>
-#include <wtf/Vector.h>
-
-using namespace std;
-
-namespace WebCore {
-
-ImageBufferData::ImageBufferData(const IntSize& size)
- : m_surface(0)
-{
-}
-
-ImageBuffer::ImageBuffer(const IntSize& size, bool grayScale, bool& success)
- : m_data(size)
- , m_size(size)
-{
- success = false; // Make early return mean error.
- m_data.m_surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
- size.width(),
- size.height());
- if (cairo_surface_status(m_data.m_surface) != CAIRO_STATUS_SUCCESS)
- return; // create will notice we didn't set m_initialized and fail.
-
- cairo_t* cr = cairo_create(m_data.m_surface);
- m_context.set(new GraphicsContext(cr));
- cairo_destroy(cr); // The context is now owned by the GraphicsContext.
- success = true;
-}
-
-ImageBuffer::~ImageBuffer()
-{
- cairo_surface_destroy(m_data.m_surface);
-}
-
-GraphicsContext* ImageBuffer::context() const
-{
- return m_context.get();
-}
-
-Image* ImageBuffer::image() const
-{
- if (!m_image) {
- // It's assumed that if image() is called, the actual rendering to the
- // GraphicsContext must be done.
- ASSERT(context());
- // BitmapImage will release the passed in surface on destruction
- m_image = BitmapImage::create(cairo_surface_reference(m_data.m_surface));
- }
- return m_image.get();
-}
-
-PassRefPtr<ImageData> ImageBuffer::getImageData(const IntRect& rect) const
-{
- ASSERT(cairo_surface_get_type(m_data.m_surface) == CAIRO_SURFACE_TYPE_IMAGE);
-
- PassRefPtr<ImageData> result = ImageData::create(rect.width(), rect.height());
- unsigned char* dataSrc = cairo_image_surface_get_data(m_data.m_surface);
- unsigned char* dataDst = result->data()->data().data();
-
- if (rect.x() < 0 || rect.y() < 0 || (rect.x() + rect.width()) > m_size.width() || (rect.y() + rect.height()) > m_size.height())
- memset(dataSrc, 0, result->data()->length());
-
- int originx = rect.x();
- int destx = 0;
- if (originx < 0) {
- destx = -originx;
- originx = 0;
- }
- int endx = rect.x() + rect.width();
- if (endx > m_size.width())
- endx = m_size.width();
- int numColumns = endx - originx;
-
- int originy = rect.y();
- int desty = 0;
- if (originy < 0) {
- desty = -originy;
- originy = 0;
- }
- int endy = rect.y() + rect.height();
- if (endy > m_size.height())
- endy = m_size.height();
- int numRows = endy - originy;
-
- int stride = cairo_image_surface_get_stride(m_data.m_surface);
- unsigned destBytesPerRow = 4 * rect.width();
-
- unsigned char* destRows = dataDst + desty * destBytesPerRow + destx * 4;
- for (int y = 0; y < numRows; ++y) {
- unsigned char *row = dataSrc + stride * (y + originy);
- for (int x = 0; x < numColumns; x++) {
- uint32_t *pixel = (uint32_t *) row + x + originx;
- int basex = x * 4;
- if (unsigned int alpha = (*pixel & 0xff000000) >> 24) {
- destRows[basex] = (*pixel & 0x00ff0000) >> 16;
- destRows[basex + 1] = (*pixel & 0x0000ff00) >> 8;
- destRows[basex + 2] = (*pixel & 0x000000ff);
- destRows[basex + 3] = alpha;
- } else
- reinterpret_cast<uint32_t*>(destRows + basex)[0] = pixel[0];
- }
- destRows += destBytesPerRow;
- }
-
- return result;
-}
-
-void ImageBuffer::putImageData(ImageData* source, const IntRect& sourceRect, const IntPoint& destPoint)
-{
- ASSERT(cairo_surface_get_type(m_data.m_surface) == CAIRO_SURFACE_TYPE_IMAGE);
-
- unsigned char* dataDst = cairo_image_surface_get_data(m_data.m_surface);
-
- ASSERT(sourceRect.width() > 0);
- ASSERT(sourceRect.height() > 0);
-
- int originx = sourceRect.x();
- int destx = destPoint.x() + sourceRect.x();
- ASSERT(destx >= 0);
- ASSERT(destx < m_size.width());
- ASSERT(originx >= 0);
- ASSERT(originx <= sourceRect.right());
-
- int endx = destPoint.x() + sourceRect.right();
- ASSERT(endx <= m_size.width());
-
- int numColumns = endx - destx;
-
- int originy = sourceRect.y();
- int desty = destPoint.y() + sourceRect.y();
- ASSERT(desty >= 0);
- ASSERT(desty < m_size.height());
- ASSERT(originy >= 0);
- ASSERT(originy <= sourceRect.bottom());
-
- int endy = destPoint.y() + sourceRect.bottom();
- ASSERT(endy <= m_size.height());
- int numRows = endy - desty;
-
- unsigned srcBytesPerRow = 4 * source->width();
- int stride = cairo_image_surface_get_stride(m_data.m_surface);
-
- unsigned char* srcRows = source->data()->data().data() + originy * srcBytesPerRow + originx * 4;
- for (int y = 0; y < numRows; ++y) {
- unsigned char *row = dataDst + stride * (y + desty);
- for (int x = 0; x < numColumns; x++) {
- uint32_t *pixel = (uint32_t *) row + x + destx;
- int basex = x * 4;
- if (unsigned int alpha = srcRows[basex + 3]) {
- *pixel = alpha << 24 | srcRows[basex] << 16 | srcRows[basex + 1] << 8 | srcRows[basex + 2];
- } else
- pixel[0] = reinterpret_cast<uint32_t*>(srcRows + basex)[0];
- }
- srcRows += srcBytesPerRow;
- }
-}
-
-static cairo_status_t writeFunction(void* closure, const unsigned char* data, unsigned int length)
-{
- Vector<char>* in = reinterpret_cast<Vector<char>*>(closure);
- in->append(data, length);
- return CAIRO_STATUS_SUCCESS;
-}
-
-String ImageBuffer::toDataURL(const String& mimeType) const
-{
- cairo_surface_t* image = cairo_get_target(context()->platformContext());
- if (!image)
- return "data:,";
-
- String actualMimeType("image/png");
- if (MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType))
- actualMimeType = mimeType;
-
- Vector<char> in;
- // Only PNG output is supported for now.
- cairo_surface_write_to_png_stream(image, writeFunction, &in);
-
- Vector<char> out;
- base64Encode(in, out);
-
- return "data:" + actualMimeType + ";base64," + String(out.data(), out.size());
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/graphics/cairo/ImageBufferData.h b/WebCore/platform/graphics/cairo/ImageBufferData.h
deleted file mode 100644
index 49f15df..0000000
--- a/WebCore/platform/graphics/cairo/ImageBufferData.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2008 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ImageBufferData_h
-#define ImageBufferData_h
-
-#include "cairo.h"
-
-namespace WebCore {
-
-class IntSize;
-
-class ImageBufferData {
-public:
- ImageBufferData(const IntSize&);
-
- cairo_surface_t* m_surface;
-};
-
-} // namespace WebCore
-
-#endif // ImageBufferData_h
diff --git a/WebCore/platform/graphics/cairo/ImageCairo.cpp b/WebCore/platform/graphics/cairo/ImageCairo.cpp
deleted file mode 100644
index 0a35cf2..0000000
--- a/WebCore/platform/graphics/cairo/ImageCairo.cpp
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2007 Alp Toker <alp@atoker.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "BitmapImage.h"
-
-#if PLATFORM(CAIRO)
-
-#include "AffineTransform.h"
-#include "FloatRect.h"
-#include "GraphicsContext.h"
-#include "ImageObserver.h"
-#include <cairo.h>
-#include <math.h>
-
-namespace WebCore {
-
-void FrameData::clear()
-{
- if (m_frame) {
- cairo_surface_destroy(m_frame);
- m_frame = 0;
- // NOTE: We purposefully don't reset metadata here, so that even if we
- // throw away previously-decoded data, animation loops can still access
- // properties like frame durations without re-decoding.
- }
-}
-
-BitmapImage::BitmapImage(cairo_surface_t* surface, ImageObserver* observer)
- : Image(observer)
- , m_currentFrame(0)
- , m_frames(0)
- , m_frameTimer(0)
- , m_repetitionCount(cAnimationNone)
- , m_repetitionCountStatus(Unknown)
- , m_repetitionsComplete(0)
- , m_isSolidColor(false)
- , m_animationFinished(true)
- , m_allDataReceived(true)
- , m_haveSize(true)
- , m_sizeAvailable(true)
- , m_decodedSize(0)
- , m_haveFrameCount(true)
- , m_frameCount(1)
-{
- initPlatformData();
-
- // TODO: check to be sure this is an image surface
-
- int width = cairo_image_surface_get_width(surface);
- int height = cairo_image_surface_get_height(surface);
- m_decodedSize = width * height * 4;
- m_size = IntSize(width, height);
-
- m_frames.grow(1);
- m_frames[0].m_frame = surface;
- m_frames[0].m_hasAlpha = cairo_surface_get_content(surface) != CAIRO_CONTENT_COLOR;
- m_frames[0].m_haveMetadata = true;
- checkForSolidColor();
-}
-
-void BitmapImage::draw(GraphicsContext* context, const FloatRect& dst, const FloatRect& src, CompositeOperator op)
-{
- startAnimation();
-
- cairo_surface_t* image = frameAtIndex(m_currentFrame);
- if (!image) // If it's too early we won't have an image yet.
- return;
-
- FloatRect srcRect(src);
- FloatRect dstRect(dst);
-
- if (mayFillWithSolidColor()) {
- fillWithSolidColor(context, dstRect, solidColor(), op);
- return;
- }
-
- IntSize selfSize = size();
-
- cairo_t* cr = context->platformContext();
- cairo_save(cr);
-
- // Set the compositing operation.
- if (op == CompositeSourceOver && !frameHasAlphaAtIndex(m_currentFrame))
- context->setCompositeOperation(CompositeCopy);
- else
- context->setCompositeOperation(op);
-
- // If we're drawing a sub portion of the image or scaling then create
- // a pattern transformation on the image and draw the transformed pattern.
- // Test using example site at http://www.meyerweb.com/eric/css/edge/complexspiral/demo.html
- cairo_pattern_t* pattern = cairo_pattern_create_for_surface(image);
-
- // To avoid the unwanted gradient effect (#14017) we use
- // CAIRO_FILTER_NEAREST now, but the real fix will be to have
- // CAIRO_EXTEND_PAD implemented for surfaces in Cairo allowing us to still
- // use bilinear filtering
- cairo_pattern_set_filter(pattern, CAIRO_FILTER_NEAREST);
-
- float scaleX = srcRect.width() / dstRect.width();
- float scaleY = srcRect.height() / dstRect.height();
- cairo_matrix_t matrix = { scaleX, 0, 0, scaleY, srcRect.x(), srcRect.y() };
- cairo_pattern_set_matrix(pattern, &matrix);
-
- // Draw the image.
- cairo_translate(cr, dstRect.x(), dstRect.y());
- cairo_set_source(cr, pattern);
- cairo_pattern_destroy(pattern);
- cairo_rectangle(cr, 0, 0, dstRect.width(), dstRect.height());
- cairo_clip(cr);
- cairo_paint_with_alpha(cr, context->getAlpha());
-
- cairo_restore(cr);
-
- if (imageObserver())
- imageObserver()->didDraw(this);
-}
-
-void Image::drawPattern(GraphicsContext* context, const FloatRect& tileRect, const AffineTransform& patternTransform,
- const FloatPoint& phase, CompositeOperator op, const FloatRect& destRect)
-{
- cairo_surface_t* image = nativeImageForCurrentFrame();
- if (!image) // If it's too early we won't have an image yet.
- return;
-
- cairo_t* cr = context->platformContext();
- context->save();
-
- // TODO: Make use of tileRect.
-
- cairo_pattern_t* pattern = cairo_pattern_create_for_surface(image);
- cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT);
-
- // Workaround to avoid the unwanted gradient effect (#14017)
- cairo_pattern_set_filter(pattern, CAIRO_FILTER_NEAREST);
-
- cairo_matrix_t pattern_matrix = cairo_matrix_t(patternTransform);
- cairo_matrix_t phase_matrix = {1, 0, 0, 1, phase.x(), phase.y()};
- cairo_matrix_t combined;
- cairo_matrix_multiply(&combined, &pattern_matrix, &phase_matrix);
- cairo_matrix_invert(&combined);
- cairo_pattern_set_matrix(pattern, &combined);
-
- context->setCompositeOperation(op);
- cairo_set_source(cr, pattern);
- cairo_pattern_destroy(pattern);
- cairo_rectangle(cr, destRect.x(), destRect.y(), destRect.width(), destRect.height());
- cairo_fill(cr);
-
- context->restore();
-
- if (imageObserver())
- imageObserver()->didDraw(this);
-}
-
-void BitmapImage::checkForSolidColor()
-{
- // FIXME: It's easy to implement this optimization. Just need to check the RGBA32 buffer to see if it is 1x1.
- m_isSolidColor = false;
-}
-
-}
-
-#endif // PLATFORM(CAIRO)
diff --git a/WebCore/platform/graphics/cairo/ImageSourceCairo.cpp b/WebCore/platform/graphics/cairo/ImageSourceCairo.cpp
deleted file mode 100644
index b7a4cbb..0000000
--- a/WebCore/platform/graphics/cairo/ImageSourceCairo.cpp
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2007 Alp Toker <alp.toker@collabora.co.uk>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ImageSource.h"
-
-#if PLATFORM(CAIRO)
-
-#include "BMPImageDecoder.h"
-#include "GIFImageDecoder.h"
-#include "ICOImageDecoder.h"
-#include "JPEGImageDecoder.h"
-#include "PNGImageDecoder.h"
-#include "SharedBuffer.h"
-#include <cairo.h>
-
-#if !PLATFORM(WIN)
-#include "XBMImageDecoder.h"
-#endif
-
-namespace WebCore {
-
-ImageDecoder* createDecoder(const Vector<char>& data)
-{
- // We need at least 4 bytes to figure out what kind of image we're dealing with.
- int length = data.size();
- if (length < 4)
- return 0;
-
- const unsigned char* uContents = (const unsigned char*)data.data();
- const char* contents = data.data();
-
- // GIFs begin with GIF8(7 or 9).
- if (strncmp(contents, "GIF8", 4) == 0)
- return new GIFImageDecoder();
-
- // Test for PNG.
- if (uContents[0]==0x89 &&
- uContents[1]==0x50 &&
- uContents[2]==0x4E &&
- uContents[3]==0x47)
- return new PNGImageDecoder();
-
- // JPEG
- if (uContents[0]==0xFF &&
- uContents[1]==0xD8 &&
- uContents[2]==0xFF)
- return new JPEGImageDecoder();
-
- // BMP
- if (strncmp(contents, "BM", 2) == 0)
- return new BMPImageDecoder();
-
- // ICOs always begin with a 2-byte 0 followed by a 2-byte 1.
- // CURs begin with 2-byte 0 followed by 2-byte 2.
- if (!memcmp(contents, "\000\000\001\000", 4) ||
- !memcmp(contents, "\000\000\002\000", 4))
- return new ICOImageDecoder();
-
-#if !PLATFORM(WIN)
- // XBMs require 8 bytes of info.
- if (length >= 8 && strncmp(contents, "#define ", 8) == 0)
- return new XBMImageDecoder();
-#endif
-
- // Give up. We don't know what the heck this is.
- return 0;
-}
-
-ImageSource::ImageSource()
- : m_decoder(0)
-{
-}
-
-ImageSource::~ImageSource()
-{
- clear();
-}
-
-void ImageSource::clear()
-{
- delete m_decoder;
- m_decoder = 0;
-}
-
-bool ImageSource::initialized() const
-{
- return m_decoder;
-}
-
-void ImageSource::setData(SharedBuffer* data, bool allDataReceived)
-{
- // Make the decoder by sniffing the bytes.
- // This method will examine the data and instantiate an instance of the appropriate decoder plugin.
- // If insufficient bytes are available to determine the image type, no decoder plugin will be
- // made.
- if (!m_decoder)
- m_decoder = createDecoder(data->buffer());
-
- if (!m_decoder)
- return;
-
- m_decoder->setData(data, allDataReceived);
-}
-
-bool ImageSource::isSizeAvailable()
-{
- if (!m_decoder)
- return false;
-
- return m_decoder->isSizeAvailable();
-}
-
-IntSize ImageSource::size() const
-{
- if (!m_decoder)
- return IntSize();
-
- return m_decoder->size();
-}
-
-IntSize ImageSource::frameSizeAtIndex(size_t) const
-{
- return size();
-}
-
-int ImageSource::repetitionCount()
-{
- if (!m_decoder)
- return cAnimationNone;
-
- return m_decoder->repetitionCount();
-}
-
-size_t ImageSource::frameCount() const
-{
- return m_decoder ? m_decoder->frameCount() : 0;
-}
-
-NativeImagePtr ImageSource::createFrameAtIndex(size_t index)
-{
- if (!initialized())
- return 0;
-
- if (!m_decoder)
- return 0;
-
- RGBA32Buffer* buffer = m_decoder->frameBufferAtIndex(index);
- if (!buffer || buffer->status() == RGBA32Buffer::FrameEmpty)
- return 0;
-
- // Cairo does not like zero height images.
- // If we have a zero height image, just pretend we don't have enough data yet.
- if (!buffer->height())
- return 0;
-
- return cairo_image_surface_create_for_data((unsigned char*)buffer->bytes().data(),
- CAIRO_FORMAT_ARGB32,
- size().width(),
- buffer->height(),
- size().width()*4);
-}
-
-bool ImageSource::frameIsCompleteAtIndex(size_t index)
-{
- if (!m_decoder)
- return false;
-
- RGBA32Buffer* buffer = m_decoder->frameBufferAtIndex(index);
- return buffer && buffer->status() == RGBA32Buffer::FrameComplete;
-}
-
-float ImageSource::frameDurationAtIndex(size_t index)
-{
- if (!m_decoder)
- return 0;
-
- RGBA32Buffer* buffer = m_decoder->frameBufferAtIndex(index);
- if (!buffer || buffer->status() == RGBA32Buffer::FrameEmpty)
- return 0;
-
- // Many annoying ads specify a 0 duration to make an image flash as quickly
- // as possible. We follow WinIE's behavior and use a duration of 100 ms
- // for any frames that specify a duration of <= 50 ms. See
- // <http://bugs.webkit.org/show_bug.cgi?id=14413> or Radar 4051389 for
- // more.
- const float duration = buffer->duration() / 1000.0f;
- return (duration < 0.051f) ? 0.100f : duration;
-}
-
-bool ImageSource::frameHasAlphaAtIndex(size_t index)
-{
- // When a frame has not finished decoding, always mark it as having alpha,
- // so we don't get a black background for the undecoded sections.
- // TODO: A better solution is probably to have the underlying buffer's
- // hasAlpha() return true in these cases, since it is, in fact, technically
- // true.
- if (!frameIsCompleteAtIndex(index))
- return true;
-
- return m_decoder->frameBufferAtIndex(index)->hasAlpha();
-}
-
-}
-
-#endif // PLATFORM(CAIRO)
diff --git a/WebCore/platform/graphics/cairo/PathCairo.cpp b/WebCore/platform/graphics/cairo/PathCairo.cpp
deleted file mode 100644
index 3f8d588..0000000
--- a/WebCore/platform/graphics/cairo/PathCairo.cpp
+++ /dev/null
@@ -1,285 +0,0 @@
-/*
- Copyright (C) 2007 Krzysztof Kowalczyk <kkowalczyk@gmail.com>
- Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <wildfox@kde.org>
- 2004, 2005, 2006 Rob Buis <buis@kde.org>
- 2005, 2007 Apple Inc. All Rights reserved.
- 2007 Alp Toker <alp@atoker.com>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- aint with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include "config.h"
-#include "Path.h"
-
-#include "AffineTransform.h"
-#include "CairoPath.h"
-#include "FloatRect.h"
-#include "NotImplemented.h"
-#include "PlatformString.h"
-
-#include <cairo.h>
-#include <math.h>
-#include <wtf/MathExtras.h>
-
-namespace WebCore {
-
-Path::Path()
- : m_path(new CairoPath())
-{
-}
-
-Path::~Path()
-{
- delete m_path;
-}
-
-Path::Path(const Path& other)
- : m_path(new CairoPath())
-{
- cairo_t* cr = platformPath()->m_cr;
- cairo_path_t* p = cairo_copy_path(other.platformPath()->m_cr);
- cairo_append_path(cr, p);
- cairo_path_destroy(p);
-}
-
-Path& Path::operator=(const Path& other)
-{
- if (&other == this)
- return *this;
-
- clear();
- cairo_t* cr = platformPath()->m_cr;
- cairo_path_t* p = cairo_copy_path(other.platformPath()->m_cr);
- cairo_append_path(cr, p);
- cairo_path_destroy(p);
- return *this;
-}
-
-void Path::clear()
-{
- cairo_t* cr = platformPath()->m_cr;
- cairo_new_path(cr);
-}
-
-bool Path::isEmpty() const
-{
- cairo_t* cr = platformPath()->m_cr;
-#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1,5,10)
- return !cairo_has_current_point(cr);
-#else
- cairo_path_t* p = cairo_copy_path(cr);
- bool hasData = p->num_data;
- cairo_path_destroy(p);
- return !hasData;
-#endif
-}
-
-void Path::translate(const FloatSize& p)
-{
- cairo_t* cr = platformPath()->m_cr;
- cairo_translate(cr, p.width(), p.height());
-}
-
-void Path::moveTo(const FloatPoint& p)
-{
- cairo_t* cr = platformPath()->m_cr;
- cairo_move_to(cr, p.x(), p.y());
-}
-
-void Path::addLineTo(const FloatPoint& p)
-{
- cairo_t* cr = platformPath()->m_cr;
- cairo_line_to(cr, p.x(), p.y());
-}
-
-void Path::addRect(const FloatRect& rect)
-{
- cairo_t* cr = platformPath()->m_cr;
- cairo_rectangle(cr, rect.x(), rect.y(), rect.width(), rect.height());
-}
-
-/*
- * inspired by libsvg-cairo
- */
-void Path::addQuadCurveTo(const FloatPoint& controlPoint, const FloatPoint& point)
-{
- cairo_t* cr = platformPath()->m_cr;
- double x, y;
- double x1 = controlPoint.x();
- double y1 = controlPoint.y();
- double x2 = point.x();
- double y2 = point.y();
- cairo_get_current_point(cr, &x, &y);
- cairo_curve_to(cr,
- x + 2.0 / 3.0 * (x1 - x), y + 2.0 / 3.0 * (y1 - y),
- x2 + 2.0 / 3.0 * (x1 - x2), y2 + 2.0 / 3.0 * (y1 - y2),
- x2, y2);
-}
-
-void Path::addBezierCurveTo(const FloatPoint& controlPoint1, const FloatPoint& controlPoint2, const FloatPoint& controlPoint3)
-{
- cairo_t* cr = platformPath()->m_cr;
- cairo_curve_to(cr, controlPoint1.x(), controlPoint1.y(),
- controlPoint2.x(), controlPoint2.y(),
- controlPoint3.x(), controlPoint3.y());
-}
-
-void Path::addArc(const FloatPoint& p, float r, float sa, float ea, bool anticlockwise)
-{
- // http://bugs.webkit.org/show_bug.cgi?id=16449
- // cairo_arc() functions hang or crash when passed inf as radius or start/end angle
- if (!isfinite(r) || !isfinite(sa) || !isfinite(ea))
- return;
-
- cairo_t* cr = platformPath()->m_cr;
- if (anticlockwise)
- cairo_arc_negative(cr, p.x(), p.y(), r, sa, ea);
- else
- cairo_arc(cr, p.x(), p.y(), r, sa, ea);
-}
-
-void Path::addArcTo(const FloatPoint& p1, const FloatPoint& p2, float radius)
-{
- // FIXME: cairo_arc_to not yet in cairo see cairo.h
- // cairo_arc_to(m_cr, p1.x(), p1.y(), p2.x(), p2.y());
- notImplemented();
-}
-
-void Path::addEllipse(const FloatRect& rect)
-{
- cairo_t* cr = platformPath()->m_cr;
- cairo_save(cr);
- float yRadius = .5 * rect.height();
- float xRadius = .5 * rect.width();
- cairo_translate(cr, rect.x() + xRadius, rect.y() + yRadius);
- cairo_scale(cr, xRadius, yRadius);
- cairo_arc(cr, 0., 0., 1., 0., 2 * piDouble);
- cairo_restore(cr);
-}
-
-void Path::closeSubpath()
-{
- cairo_t* cr = platformPath()->m_cr;
- cairo_close_path(cr);
-}
-
-FloatRect Path::boundingRect() const
-{
- cairo_t* cr = platformPath()->m_cr;
- double x0, x1, y0, y1;
-#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 6, 0)
- cairo_path_extents(cr, &x0, &y0, &x1, &y1);
-#else
- cairo_stroke_extents(cr, &x0, &y0, &x1, &y1);
-#endif
- return FloatRect(x0, y0, x1 - x0, y1 - y0);
-}
-
-bool Path::contains(const FloatPoint& point, WindRule rule) const
-{
- if (!boundingRect().contains(point))
- return false;
-
- cairo_t* cr = platformPath()->m_cr;
- cairo_fill_rule_t cur = cairo_get_fill_rule(cr);
- cairo_set_fill_rule(cr, rule == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING);
- bool contains = cairo_in_fill(cr, point.x(), point.y());
- cairo_set_fill_rule(cr, cur);
- return contains;
-}
-
-void Path::apply(void* info, PathApplierFunction function) const
-{
- cairo_t* cr = platformPath()->m_cr;
- cairo_path_t* path = cairo_copy_path(cr);
- cairo_path_data_t* data;
- PathElement pelement;
- FloatPoint points[3];
- pelement.points = points;
-
- for (int i = 0; i < path->num_data; i += path->data[i].header.length) {
- data = &path->data[i];
- switch (data->header.type) {
- case CAIRO_PATH_MOVE_TO:
- pelement.type = PathElementMoveToPoint;
- pelement.points[0] = FloatPoint(data[1].point.x,data[1].point.y);
- function(info, &pelement);
- break;
- case CAIRO_PATH_LINE_TO:
- pelement.type = PathElementAddLineToPoint;
- pelement.points[0] = FloatPoint(data[1].point.x,data[1].point.y);
- function(info, &pelement);
- break;
- case CAIRO_PATH_CURVE_TO:
- pelement.type = PathElementAddCurveToPoint;
- pelement.points[0] = FloatPoint(data[1].point.x,data[1].point.y);
- pelement.points[1] = FloatPoint(data[2].point.x,data[2].point.y);
- pelement.points[2] = FloatPoint(data[3].point.x,data[3].point.y);
- function(info, &pelement);
- break;
- case CAIRO_PATH_CLOSE_PATH:
- pelement.type = PathElementCloseSubpath;
- function(info, &pelement);
- break;
- }
- }
- cairo_path_destroy(path);
-}
-
-void Path::transform(const AffineTransform& trans)
-{
- cairo_t* m_cr = platformPath()->m_cr;
- cairo_matrix_t c_matrix = cairo_matrix_t(trans);
- cairo_matrix_invert(&c_matrix);
- cairo_transform(m_cr, &c_matrix);
-}
-
-String Path::debugString() const
-{
- String string = "";
- cairo_path_t* path = cairo_copy_path(platformPath()->m_cr);
- cairo_path_data_t* data;
-
- if (!path->num_data )
- string = "EMPTY";
-
- for (int i = 0; i < path->num_data; i += path->data[i].header.length) {
- data = &path->data[i];
- switch (data->header.type) {
- case CAIRO_PATH_MOVE_TO:
- string += String::format("M %.2f,%.2f",
- data[1].point.x, data[1].point.y);
- break;
- case CAIRO_PATH_LINE_TO:
- string += String::format("L %.2f,%.2f",
- data[1].point.x, data[1].point.y);
- break;
- case CAIRO_PATH_CURVE_TO:
- string += String::format("C %.2f,%.2f,%.2f,%.2f,%.2f,%.2f",
- data[1].point.x, data[1].point.y,
- data[2].point.x, data[2].point.y,
- data[3].point.x, data[3].point.y);
- break;
- case CAIRO_PATH_CLOSE_PATH:
- string += "X";
- break;
- }
- }
- cairo_path_destroy(path);
- return string;
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/graphics/cairo/PatternCairo.cpp b/WebCore/platform/graphics/cairo/PatternCairo.cpp
deleted file mode 100644
index 16cebf8..0000000
--- a/WebCore/platform/graphics/cairo/PatternCairo.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Pattern.h"
-
-#include "AffineTransform.h"
-#include "GraphicsContext.h"
-
-#include <cairo.h>
-
-namespace WebCore {
-
-cairo_pattern_t* Pattern::createPlatformPattern(const AffineTransform& patternTransform) const
-{
- cairo_surface_t* surface = tileImage()->nativeImageForCurrentFrame();
- if (!surface)
- return 0;
-
- cairo_pattern_t* pattern = cairo_pattern_create_for_surface(surface);
- const cairo_matrix_t* pattern_matrix = reinterpret_cast<const cairo_matrix_t*>(&patternTransform);
- cairo_pattern_set_matrix(pattern, pattern_matrix);
- if (m_repeatX || m_repeatY)
- cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT);
- return pattern;
-}
-
-}
diff --git a/WebCore/platform/graphics/cairo/rgb24-hacks.txt b/WebCore/platform/graphics/cairo/rgb24-hacks.txt
deleted file mode 100644
index 59f8070..0000000
--- a/WebCore/platform/graphics/cairo/rgb24-hacks.txt
+++ /dev/null
@@ -1,32 +0,0 @@
-Index: cairo/src/cairo-win32-surface.c
-===================================================================
---- cairo/src/cairo-win32-surface.c (revision 14498)
-+++ cairo/src/cairo-win32-surface.c (working copy)
-@@ -824,8 +824,13 @@
- * to figure out when we can use GDI. We don't have that checking
- * anywhere at the moment, so just bail and use the fallback
- * paths. */
-- if (surface->format != CAIRO_FORMAT_RGB24)
-- return CAIRO_INT_STATUS_UNSUPPORTED;
-+ //if (surface->format != CAIRO_FORMAT_RGB24)
-+ // return CAIRO_INT_STATUS_UNSUPPORTED;
-+ // FIXME: We'll go ahead and optimize this now and just assume we're ok if
-+ // the color has no alpha. Probably need to check various composite operators to
-+ // get this exactly right.
-+ if (color->alpha != 1.0)
-+ return CAIRO_INT_STATUS_UNSUPPORTED;
-
- /* Optimize for no destination alpha (surface->pixman_image is non-NULL for all
- * surfaces with alpha.)
-@@ -1016,8 +1021,9 @@
-
- /* We can only handle operator SOURCE or OVER with the destination
- * having no alpha */
-- if ((op != CAIRO_OPERATOR_SOURCE && op != CAIRO_OPERATOR_OVER) ||
-- (dst->format != CAIRO_FORMAT_RGB24))
-+ if ((op != CAIRO_OPERATOR_SOURCE && op != CAIRO_OPERATOR_OVER))
-+ // FIXME: It's not clear why ExtTextOut can't be called when the
-+ // destination has alpha. Remove the RGB24 restriction. || (dst->format != CAIRO_FORMAT_RGB24))
- return CAIRO_INT_STATUS_UNSUPPORTED;
-
- /* If we have a fallback mask clip set on the dst, we have
diff --git a/WebCore/platform/graphics/cairo/scale-removal.txt b/WebCore/platform/graphics/cairo/scale-removal.txt
deleted file mode 100644
index 47c0d70..0000000
--- a/WebCore/platform/graphics/cairo/scale-removal.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-Index: cairo/src/cairo-win32-private.h
-===================================================================
---- cairo/src/cairo-win32-private.h (revision 14582)
-+++ cairo/src/cairo-win32-private.h (working copy)
-@@ -39,7 +39,7 @@
- #include <cairo-win32.h>
- #include <cairoint.h>
-
--#define WIN32_FONT_LOGICAL_SCALE 32
-+#define WIN32_FONT_LOGICAL_SCALE 1
-
- typedef struct _cairo_win32_surface {
- cairo_surface_t base;
diff --git a/WebCore/platform/graphics/cg/AffineTransformCG.cpp b/WebCore/platform/graphics/cg/AffineTransformCG.cpp
deleted file mode 100644
index 4f0bca0..0000000
--- a/WebCore/platform/graphics/cg/AffineTransformCG.cpp
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "AffineTransform.h"
-
-#if PLATFORM(CG)
-
-#include "FloatConversion.h"
-#include "FloatRect.h"
-#include "IntRect.h"
-
-#include <wtf/MathExtras.h>
-
-namespace WebCore {
-
-AffineTransform::AffineTransform()
- : m_transform(CGAffineTransformIdentity)
-{
-}
-
-AffineTransform::AffineTransform(double a, double b, double c, double d, double tx, double ty)
-{
- m_transform = CGAffineTransformMake(narrowPrecisionToCGFloat(a),
- narrowPrecisionToCGFloat(b),
- narrowPrecisionToCGFloat(c),
- narrowPrecisionToCGFloat(d),
- narrowPrecisionToCGFloat(tx),
- narrowPrecisionToCGFloat(ty));
-}
-
-AffineTransform::AffineTransform(const PlatformAffineTransform& t)
- : m_transform(t)
-{
-}
-
-void AffineTransform::setMatrix(double a, double b, double c, double d, double tx, double ty)
-{
- m_transform = CGAffineTransformMake(narrowPrecisionToCGFloat(a),
- narrowPrecisionToCGFloat(b),
- narrowPrecisionToCGFloat(c),
- narrowPrecisionToCGFloat(d),
- narrowPrecisionToCGFloat(tx),
- narrowPrecisionToCGFloat(ty));
-}
-
-void AffineTransform::map(double x, double y, double *x2, double *y2) const
-{
- CGPoint result = CGPointApplyAffineTransform(CGPointMake(narrowPrecisionToCGFloat(x), narrowPrecisionToCGFloat(y)), m_transform);
- *x2 = result.x;
- *y2 = result.y;
-}
-
-IntRect AffineTransform::mapRect(const IntRect &rect) const
-{
- return enclosingIntRect(CGRectApplyAffineTransform(CGRect(rect), m_transform));
-}
-
-FloatRect AffineTransform::mapRect(const FloatRect &rect) const
-{
- return FloatRect(CGRectApplyAffineTransform(CGRect(rect), m_transform));
-}
-
-bool AffineTransform::isIdentity() const
-{
- return CGAffineTransformIsIdentity(m_transform);
-}
-
-double AffineTransform::a() const
-{
- return m_transform.a;
-}
-
-void AffineTransform::setA(double a)
-{
- m_transform.a = narrowPrecisionToCGFloat(a);
-}
-
-double AffineTransform::b() const
-{
- return m_transform.b;
-}
-
-void AffineTransform::setB(double b)
-{
- m_transform.b = narrowPrecisionToCGFloat(b);
-}
-
-double AffineTransform::c() const
-{
- return m_transform.c;
-}
-
-void AffineTransform::setC(double c)
-{
- m_transform.c = narrowPrecisionToCGFloat(c);
-}
-
-double AffineTransform::d() const
-{
- return m_transform.d;
-}
-
-void AffineTransform::setD(double d)
-{
- m_transform.d = narrowPrecisionToCGFloat(d);
-}
-
-double AffineTransform::e() const
-{
- return m_transform.tx;
-}
-
-void AffineTransform::setE(double e)
-{
- m_transform.tx = narrowPrecisionToCGFloat(e);
-}
-
-double AffineTransform::f() const
-{
- return m_transform.ty;
-}
-
-void AffineTransform::setF(double f)
-{
- m_transform.ty = narrowPrecisionToCGFloat(f);
-}
-
-void AffineTransform::reset()
-{
- m_transform = CGAffineTransformIdentity;
-}
-
-AffineTransform &AffineTransform::scale(double sx, double sy)
-{
- m_transform = CGAffineTransformScale(m_transform, narrowPrecisionToCGFloat(sx), narrowPrecisionToCGFloat(sy));
- return *this;
-}
-
-AffineTransform &AffineTransform::rotate(double d)
-{
- m_transform = CGAffineTransformRotate(m_transform, narrowPrecisionToCGFloat(deg2rad(d)));
- return *this;
-}
-
-AffineTransform &AffineTransform::translate(double tx, double ty)
-{
- m_transform = CGAffineTransformTranslate(m_transform, narrowPrecisionToCGFloat(tx), narrowPrecisionToCGFloat(ty));
- return *this;
-}
-
-AffineTransform &AffineTransform::shear(double sx, double sy)
-{
- CGAffineTransform shear = CGAffineTransformMake(1.0f, narrowPrecisionToCGFloat(sy), narrowPrecisionToCGFloat(sx), 1.0f, 0.0f, 0.0f);
- m_transform = CGAffineTransformConcat(shear, m_transform);
- return *this;
-}
-
-double AffineTransform::det() const
-{
- return m_transform.a * m_transform.d - m_transform.b * m_transform.c;
-}
-
-AffineTransform AffineTransform::inverse() const
-{
- if (isInvertible())
- return AffineTransform(CGAffineTransformInvert(m_transform));
- return AffineTransform();
-}
-
-AffineTransform::operator PlatformAffineTransform() const
-{
- return m_transform;
-}
-
-bool AffineTransform::operator== (const AffineTransform &m2) const
-{
- return CGAffineTransformEqualToTransform(m_transform, CGAffineTransform(m2));
-}
-
-AffineTransform &AffineTransform::operator*= (const AffineTransform &m2)
-{
- m_transform = CGAffineTransformConcat(m_transform, CGAffineTransform(m2));
- return *this;
-}
-
-AffineTransform AffineTransform::operator* (const AffineTransform &m2)
-{
- return CGAffineTransformConcat(m_transform, CGAffineTransform(m2));
-}
-
-}
-
-#endif // PLATFORM(CG)
diff --git a/WebCore/platform/graphics/cg/ColorCG.cpp b/WebCore/platform/graphics/cg/ColorCG.cpp
deleted file mode 100644
index 48ce9f2..0000000
--- a/WebCore/platform/graphics/cg/ColorCG.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Color.h"
-
-#if PLATFORM(CG)
-
-#include <wtf/Assertions.h>
-#include <ApplicationServices/ApplicationServices.h>
-
-namespace WebCore {
-
-Color::Color(CGColorRef color)
-{
- if (!color) {
- m_color = 0;
- m_valid = false;
- return;
- }
-
- size_t numComponents = CGColorGetNumberOfComponents(color);
- const CGFloat* components = CGColorGetComponents(color);
-
- float r = 0;
- float g = 0;
- float b = 0;
- float a = 0;
-
- switch (numComponents) {
- case 2:
- r = g = b = components[0];
- a = components[1];
- break;
- case 4:
- r = components[0];
- g = components[1];
- b = components[2];
- a = components[3];
- break;
- default:
- ASSERT_NOT_REACHED();
- }
-
- m_color = makeRGBA(r * 255, g * 255, b * 255, a * 255);
-}
-
-#if !PLATFORM(MAC)
-
-CGColorRef cgColor(const Color& c)
-{
- CGColorRef color = NULL;
- CMProfileRef prof = NULL;
- CMGetSystemProfile(&prof);
-
- CGColorSpaceRef rgbSpace = CGColorSpaceCreateWithPlatformColorSpace(prof);
-
- if (rgbSpace != NULL)
- {
- float components[4] = {c.red() / 255.0f, c.green() / 255.0f, c.blue() / 255.0f, c.alpha() / 255.0f};
- color = CGColorCreate(rgbSpace, components);
- CGColorSpaceRelease(rgbSpace);
- }
-
- CMCloseProfile(prof);
-
- return color;
-}
-
-#endif // !PLATFORM(MAC)
-
-}
-
-#endif // PLATFORM(CG)
diff --git a/WebCore/platform/graphics/cg/FloatPointCG.cpp b/WebCore/platform/graphics/cg/FloatPointCG.cpp
deleted file mode 100644
index f9c3353..0000000
--- a/WebCore/platform/graphics/cg/FloatPointCG.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2005 Nokia. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FloatPoint.h"
-
-#if PLATFORM(CG)
-
-#include <ApplicationServices/ApplicationServices.h>
-
-namespace WebCore {
-
-FloatPoint::FloatPoint(const CGPoint& p) : m_x(p.x), m_y(p.y)
-{
-}
-
-FloatPoint::operator CGPoint() const
-{
- return CGPointMake(m_x, m_y);
-}
-
-}
-
-#endif // PLATFORM(CG)
diff --git a/WebCore/platform/graphics/cg/FloatRectCG.cpp b/WebCore/platform/graphics/cg/FloatRectCG.cpp
deleted file mode 100644
index a1ce367..0000000
--- a/WebCore/platform/graphics/cg/FloatRectCG.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2005 Nokia. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FloatRect.h"
-
-#if PLATFORM(CG)
-
-#include <ApplicationServices/ApplicationServices.h>
-
-namespace WebCore {
-
-FloatRect::FloatRect(const CGRect& r) : m_location(r.origin), m_size(r.size)
-{
-}
-
-FloatRect::operator CGRect() const
-{
- return CGRectMake(x(), y(), width(), height());
-}
-
-}
-
-#endif // PLATFORM(CG)
diff --git a/WebCore/platform/graphics/cg/FloatSizeCG.cpp b/WebCore/platform/graphics/cg/FloatSizeCG.cpp
deleted file mode 100644
index 383af21..0000000
--- a/WebCore/platform/graphics/cg/FloatSizeCG.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2005 Nokia. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FloatSize.h"
-
-#if PLATFORM(CG)
-
-#include <ApplicationServices/ApplicationServices.h>
-
-namespace WebCore {
-
-FloatSize::FloatSize(const CGSize& s) : m_width(s.width), m_height(s.height)
-{
-}
-
-FloatSize::operator CGSize() const
-{
- return CGSizeMake(m_width, m_height);
-}
-
-}
-
-#endif // PLATFORM(CG)
diff --git a/WebCore/platform/graphics/cg/GradientCG.cpp b/WebCore/platform/graphics/cg/GradientCG.cpp
deleted file mode 100644
index c189fd5..0000000
--- a/WebCore/platform/graphics/cg/GradientCG.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2007 Alp Toker <alp@atoker.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Gradient.h"
-
-#include "CSSParser.h"
-#include "GraphicsContext.h"
-
-#include <ApplicationServices/ApplicationServices.h>
-
-namespace WebCore {
-
-void Gradient::platformDestroy()
-{
- CGShadingRelease(m_gradient);
- m_gradient = 0;
-}
-
-static void gradientCallback(void* info, const CGFloat* in, CGFloat* out)
-{
- float r, g, b, a;
- static_cast<const Gradient*>(info)->getColor(*in, &r, &g, &b, &a);
- out[0] = r;
- out[1] = g;
- out[2] = b;
- out[3] = a;
-}
-
-CGShadingRef Gradient::platformGradient()
-{
- if (m_gradient)
- return m_gradient;
-
- const CGFloat intervalRanges[2] = { 0, 1 };
- const CGFloat colorComponentRanges[4 * 2] = { 0, 1, 0, 1, 0, 1, 0, 1 };
- const CGFunctionCallbacks gradientCallbacks = { 0, gradientCallback, 0 };
- CGFunctionRef colorFunction = CGFunctionCreate(this, 1, intervalRanges, 4, colorComponentRanges, &gradientCallbacks);
-
- CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
-
- if (m_radial)
- m_gradient = CGShadingCreateRadial(colorSpace, m_p0, m_r0, m_p1, m_r1, colorFunction, true, true);
- else
- m_gradient = CGShadingCreateAxial(colorSpace, m_p0, m_p1, colorFunction, true, true);
-
- CGColorSpaceRelease(colorSpace);
- CGFunctionRelease(colorFunction);
-
- return m_gradient;
-}
-
-void Gradient::fill(GraphicsContext* context, const FloatRect& rect)
-{
- context->clip(rect);
- CGContextDrawShading(context->platformContext(), platformGradient());
-}
-
-} //namespace
diff --git a/WebCore/platform/graphics/cg/GraphicsContextCG.cpp b/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
deleted file mode 100644
index 3f0e6e7..0000000
--- a/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
+++ /dev/null
@@ -1,1144 +0,0 @@
-/*
- * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#define _USE_MATH_DEFINES 1
-#include "config.h"
-#include "GraphicsContext.h"
-
-#include "AffineTransform.h"
-#include "FloatConversion.h"
-#include "GraphicsContextPrivate.h"
-#include "GraphicsContextPlatformPrivateCG.h"
-#include "ImageBuffer.h"
-#include "KURL.h"
-#include "Path.h"
-#include "Pattern.h"
-#include <CoreGraphics/CGBitmapContext.h>
-#include <CoreGraphics/CGPDFContext.h>
-#include <wtf/MathExtras.h>
-#include <wtf/OwnArrayPtr.h>
-#include <wtf/RetainPtr.h>
-
-#if PLATFORM(MAC) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
-#define HAVE_CG_INTERPOLATION_MEDIUM 1
-#endif
-
-using namespace std;
-
-namespace WebCore {
-
-static void setCGFillColor(CGContextRef context, const Color& color)
-{
- CGFloat red, green, blue, alpha;
- color.getRGBA(red, green, blue, alpha);
- CGContextSetRGBFillColor(context, red, green, blue, alpha);
-}
-
-static void setCGStrokeColor(CGContextRef context, const Color& color)
-{
- CGFloat red, green, blue, alpha;
- color.getRGBA(red, green, blue, alpha);
- CGContextSetRGBStrokeColor(context, red, green, blue, alpha);
-}
-
-GraphicsContext::GraphicsContext(CGContextRef cgContext)
- : m_common(createGraphicsContextPrivate())
- , m_data(new GraphicsContextPlatformPrivate(cgContext))
-{
- setPaintingDisabled(!cgContext);
- if (cgContext) {
- // Make sure the context starts in sync with our state.
- setPlatformFillColor(fillColor());
- setPlatformStrokeColor(strokeColor());
- }
-}
-
-GraphicsContext::~GraphicsContext()
-{
- destroyGraphicsContextPrivate(m_common);
- delete m_data;
-}
-
-CGContextRef GraphicsContext::platformContext() const
-{
- ASSERT(!paintingDisabled());
- ASSERT(m_data->m_cgContext);
- return m_data->m_cgContext;
-}
-
-void GraphicsContext::savePlatformState()
-{
- // Note: Do not use this function within this class implementation, since we want to avoid the extra
- // save of the secondary context (in GraphicsContextPlatformPrivateCG.h).
- CGContextSaveGState(platformContext());
- m_data->save();
-}
-
-void GraphicsContext::restorePlatformState()
-{
- // Note: Do not use this function within this class implementation, since we want to avoid the extra
- // restore of the secondary context (in GraphicsContextPlatformPrivateCG.h).
- CGContextRestoreGState(platformContext());
- m_data->restore();
- m_data->m_userToDeviceTransformKnownToBeIdentity = false;
-}
-
-// Draws a filled rectangle with a stroked border.
-void GraphicsContext::drawRect(const IntRect& rect)
-{
- // FIXME: this function does not handle patterns and gradients
- // like drawPath does, it probably should.
- if (paintingDisabled())
- return;
-
- CGContextRef context = platformContext();
-
- if (fillColor().alpha())
- CGContextFillRect(context, rect);
-
- if (strokeStyle() != NoStroke && strokeColor().alpha()) {
- // We do a fill of four rects to simulate the stroke of a border.
- Color oldFillColor = fillColor();
- if (oldFillColor != strokeColor())
- setCGFillColor(context, strokeColor());
- CGRect rects[4] = {
- FloatRect(rect.x(), rect.y(), rect.width(), 1),
- FloatRect(rect.x(), rect.bottom() - 1, rect.width(), 1),
- FloatRect(rect.x(), rect.y() + 1, 1, rect.height() - 2),
- FloatRect(rect.right() - 1, rect.y() + 1, 1, rect.height() - 2)
- };
- CGContextFillRects(context, rects, 4);
- if (oldFillColor != strokeColor())
- setCGFillColor(context, oldFillColor);
- }
-}
-
-// This is only used to draw borders.
-void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2)
-{
- if (paintingDisabled())
- return;
-
- if (strokeStyle() == NoStroke || !strokeColor().alpha())
- return;
-
- float width = strokeThickness();
-
- FloatPoint p1 = point1;
- FloatPoint p2 = point2;
- bool isVerticalLine = (p1.x() == p2.x());
-
- // For odd widths, we add in 0.5 to the appropriate x/y so that the float arithmetic
- // works out. For example, with a border width of 3, KHTML will pass us (y1+y2)/2, e.g.,
- // (50+53)/2 = 103/2 = 51 when we want 51.5. It is always true that an even width gave
- // us a perfect position, but an odd width gave us a position that is off by exactly 0.5.
- if (strokeStyle() == DottedStroke || strokeStyle() == DashedStroke) {
- if (isVerticalLine) {
- p1.move(0, width);
- p2.move(0, -width);
- } else {
- p1.move(width, 0);
- p2.move(-width, 0);
- }
- }
-
- if (((int)width) % 2) {
- if (isVerticalLine) {
- // We're a vertical line. Adjust our x.
- p1.move(0.5f, 0.0f);
- p2.move(0.5f, 0.0f);
- } else {
- // We're a horizontal line. Adjust our y.
- p1.move(0.0f, 0.5f);
- p2.move(0.0f, 0.5f);
- }
- }
-
- int patWidth = 0;
- switch (strokeStyle()) {
- case NoStroke:
- case SolidStroke:
- break;
- case DottedStroke:
- patWidth = (int)width;
- break;
- case DashedStroke:
- patWidth = 3 * (int)width;
- break;
- }
-
- CGContextRef context = platformContext();
- CGContextSaveGState(context);
-
- CGContextSetShouldAntialias(context, false);
-
- if (patWidth) {
- // Do a rect fill of our endpoints. This ensures we always have the
- // appearance of being a border. We then draw the actual dotted/dashed line.
- setCGFillColor(context, strokeColor()); // The save/restore make it safe to mutate the fill color here without setting it back to the old color.
- if (isVerticalLine) {
- CGContextFillRect(context, FloatRect(p1.x() - width / 2, p1.y() - width, width, width));
- CGContextFillRect(context, FloatRect(p2.x() - width / 2, p2.y(), width, width));
- } else {
- CGContextFillRect(context, FloatRect(p1.x() - width, p1.y() - width / 2, width, width));
- CGContextFillRect(context, FloatRect(p2.x(), p2.y() - width / 2, width, width));
- }
-
- // Example: 80 pixels with a width of 30 pixels.
- // Remainder is 20. The maximum pixels of line we could paint
- // will be 50 pixels.
- int distance = (isVerticalLine ? (point2.y() - point1.y()) : (point2.x() - point1.x())) - 2*(int)width;
- int remainder = distance % patWidth;
- int coverage = distance - remainder;
- int numSegments = coverage / patWidth;
-
- float patternOffset = 0.0f;
- // Special case 1px dotted borders for speed.
- if (patWidth == 1)
- patternOffset = 1.0f;
- else {
- bool evenNumberOfSegments = numSegments % 2 == 0;
- if (remainder)
- evenNumberOfSegments = !evenNumberOfSegments;
- if (evenNumberOfSegments) {
- if (remainder) {
- patternOffset += patWidth - remainder;
- patternOffset += remainder / 2;
- } else
- patternOffset = patWidth / 2;
- } else {
- if (remainder)
- patternOffset = (patWidth - remainder)/2;
- }
- }
-
- const CGFloat dottedLine[2] = { patWidth, patWidth };
- CGContextSetLineDash(context, patternOffset, dottedLine, 2);
- }
-
- CGContextBeginPath(context);
- CGContextMoveToPoint(context, p1.x(), p1.y());
- CGContextAddLineToPoint(context, p2.x(), p2.y());
-
- CGContextStrokePath(context);
-
- CGContextRestoreGState(context);
-}
-
-// This method is only used to draw the little circles used in lists.
-void GraphicsContext::drawEllipse(const IntRect& rect)
-{
- // FIXME: CG added CGContextAddEllipseinRect in Tiger, so we should be able to quite easily draw an ellipse.
- // This code can only handle circles, not ellipses. But khtml only
- // uses it for circles.
- ASSERT(rect.width() == rect.height());
-
- if (paintingDisabled())
- return;
-
- CGContextRef context = platformContext();
- CGContextBeginPath(context);
- float r = (float)rect.width() / 2;
- CGContextAddArc(context, rect.x() + r, rect.y() + r, r, 0.0f, 2.0f * piFloat, 0);
- CGContextClosePath(context);
-
- drawPath();
-}
-
-
-void GraphicsContext::strokeArc(const IntRect& rect, int startAngle, int angleSpan)
-{
- if (paintingDisabled() || strokeStyle() == NoStroke || strokeThickness() <= 0.0f || !strokeColor().alpha())
- return;
-
- CGContextRef context = platformContext();
- CGContextSaveGState(context);
- CGContextBeginPath(context);
- CGContextSetShouldAntialias(context, false);
-
- int x = rect.x();
- int y = rect.y();
- float w = (float)rect.width();
- float h = (float)rect.height();
- float scaleFactor = h / w;
- float reverseScaleFactor = w / h;
-
- if (w != h)
- scale(FloatSize(1, scaleFactor));
-
- float hRadius = w / 2;
- float vRadius = h / 2;
- float fa = startAngle;
- float falen = fa + angleSpan;
- float start = -fa * piFloat / 180.0f;
- float end = -falen * piFloat / 180.0f;
- CGContextAddArc(context, x + hRadius, (y + vRadius) * reverseScaleFactor, hRadius, start, end, true);
-
- if (w != h)
- scale(FloatSize(1, reverseScaleFactor));
-
-
- float width = strokeThickness();
- int patWidth = 0;
-
- switch (strokeStyle()) {
- case DottedStroke:
- patWidth = (int)(width / 2);
- break;
- case DashedStroke:
- patWidth = 3 * (int)(width / 2);
- break;
- default:
- break;
- }
-
- if (patWidth) {
- // Example: 80 pixels with a width of 30 pixels.
- // Remainder is 20. The maximum pixels of line we could paint
- // will be 50 pixels.
- int distance;
- if (hRadius == vRadius)
- distance = static_cast<int>((piFloat * hRadius) / 2.0f);
- else // We are elliptical and will have to estimate the distance
- distance = static_cast<int>((piFloat * sqrtf((hRadius * hRadius + vRadius * vRadius) / 2.0f)) / 2.0f);
-
- int remainder = distance % patWidth;
- int coverage = distance - remainder;
- int numSegments = coverage / patWidth;
-
- float patternOffset = 0.0f;
- // Special case 1px dotted borders for speed.
- if (patWidth == 1)
- patternOffset = 1.0f;
- else {
- bool evenNumberOfSegments = numSegments % 2 == 0;
- if (remainder)
- evenNumberOfSegments = !evenNumberOfSegments;
- if (evenNumberOfSegments) {
- if (remainder) {
- patternOffset += patWidth - remainder;
- patternOffset += remainder / 2.0f;
- } else
- patternOffset = patWidth / 2.0f;
- } else {
- if (remainder)
- patternOffset = (patWidth - remainder) / 2.0f;
- }
- }
-
- const CGFloat dottedLine[2] = { patWidth, patWidth };
- CGContextSetLineDash(context, patternOffset, dottedLine, 2);
- }
-
- CGContextStrokePath(context);
-
- CGContextRestoreGState(context);
-}
-
-void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points, bool shouldAntialias)
-{
- if (paintingDisabled() || !fillColor().alpha() && (strokeThickness() <= 0 || strokeStyle() == NoStroke))
- return;
-
- if (npoints <= 1)
- return;
-
- CGContextRef context = platformContext();
-
- CGContextSaveGState(context);
-
- CGContextSetShouldAntialias(context, shouldAntialias);
-
- CGContextBeginPath(context);
- CGContextMoveToPoint(context, points[0].x(), points[0].y());
- for (size_t i = 1; i < npoints; i++)
- CGContextAddLineToPoint(context, points[i].x(), points[i].y());
- CGContextClosePath(context);
-
- drawPath();
-
- CGContextRestoreGState(context);
-}
-
-static void applyStrokePattern(GraphicsContext* context, Pattern* pattern)
-{
- CGContextRef cgContext = context->platformContext();
-
- CGPatternRef platformPattern = pattern->createPlatformPattern(context->getCTM());
- if (!platformPattern)
- return;
-
- CGColorSpaceRef patternSpace = CGColorSpaceCreatePattern(0);
- CGContextSetStrokeColorSpace(cgContext, patternSpace);
- CGColorSpaceRelease(patternSpace);
-
- const CGFloat patternAlpha = 1;
- CGContextSetStrokePattern(cgContext, platformPattern, &patternAlpha);
- CGPatternRelease(platformPattern);
-}
-
-static void applyFillPattern(GraphicsContext* context, Pattern* pattern)
-{
- CGContextRef cgContext = context->platformContext();
-
- CGPatternRef platformPattern = pattern->createPlatformPattern(context->getCTM());
- if (!platformPattern)
- return;
-
- CGColorSpaceRef patternSpace = CGColorSpaceCreatePattern(0);
- CGContextSetFillColorSpace(cgContext, patternSpace);
- CGColorSpaceRelease(patternSpace);
-
- const CGFloat patternAlpha = 1;
- CGContextSetFillPattern(cgContext, platformPattern, &patternAlpha);
- CGPatternRelease(platformPattern);
-}
-
-static inline bool calculateDrawingMode(const GraphicsContextState& state, CGPathDrawingMode& mode)
-{
- bool shouldFill = state.fillColorSpace == PatternColorSpace || state.fillColor.alpha();
- bool shouldStroke = state.strokeColorSpace == PatternColorSpace || (state.strokeStyle != NoStroke && state.strokeColor.alpha());
- bool useEOFill = state.fillRule == RULE_EVENODD;
-
- if (shouldFill) {
- if (shouldStroke) {
- if (useEOFill)
- mode = kCGPathEOFillStroke;
- else
- mode = kCGPathFillStroke;
- } else { // fill, no stroke
- if (useEOFill)
- mode = kCGPathEOFill;
- else
- mode = kCGPathFill;
- }
- } else {
- // Setting mode to kCGPathStroke even if shouldStroke is false. In that case, we return false and mode will not be used,
- // but the compiler will not compain about an uninitialized variable.
- mode = kCGPathStroke;
- }
-
- return shouldFill || shouldStroke;
-}
-
-void GraphicsContext::drawPath()
-{
- if (paintingDisabled())
- return;
-
- CGContextRef context = platformContext();
- const GraphicsContextState& state = m_common->state;
-
- if (state.fillColorSpace == GradientColorSpace || state.strokeColorSpace == GradientColorSpace) {
- // We don't have any optimized way to fill & stroke a path using gradients
- fillPath();
- strokePath();
- return;
- }
-
- if (state.fillColorSpace == PatternColorSpace)
- applyFillPattern(this, m_common->state.fillPattern.get());
- if (state.strokeColorSpace == PatternColorSpace)
- applyStrokePattern(this, m_common->state.strokePattern.get());
-
- CGPathDrawingMode drawingMode;
- if (calculateDrawingMode(state, drawingMode))
- CGContextDrawPath(context, drawingMode);
-}
-
-static inline void fillPathWithFillRule(CGContextRef context, WindRule fillRule)
-{
- if (fillRule == RULE_EVENODD)
- CGContextEOFillPath(context);
- else
- CGContextFillPath(context);
-}
-
-void GraphicsContext::fillPath()
-{
- if (paintingDisabled())
- return;
-
- CGContextRef context = platformContext();
- switch (m_common->state.fillColorSpace) {
- case SolidColorSpace:
- if (fillColor().alpha())
- fillPathWithFillRule(context, fillRule());
- break;
- case PatternColorSpace:
- applyFillPattern(this, m_common->state.fillPattern.get());
- fillPathWithFillRule(context, fillRule());
- break;
- case GradientColorSpace:
- CGContextSaveGState(context);
- if (fillRule() == RULE_EVENODD)
- CGContextEOClip(context);
- else
- CGContextClip(context);
- CGContextDrawShading(context, m_common->state.fillGradient->platformGradient());
- CGContextRestoreGState(context);
- break;
- }
-}
-
-void GraphicsContext::strokePath()
-{
- if (paintingDisabled())
- return;
-
- CGContextRef context = platformContext();
- switch (m_common->state.strokeColorSpace) {
- case SolidColorSpace:
- if (fillColor().alpha())
- CGContextStrokePath(context);
- break;
- case PatternColorSpace:
- applyStrokePattern(this, m_common->state.strokePattern.get());
- CGContextStrokePath(context);
- break;
- case GradientColorSpace:
- CGContextSaveGState(context);
- CGContextReplacePathWithStrokedPath(context);
- CGContextClip(context);
- CGContextDrawShading(context, m_common->state.strokeGradient->platformGradient());
- CGContextRestoreGState(context);
- break;
- }
-}
-
-void GraphicsContext::fillRect(const FloatRect& rect)
-{
- if (paintingDisabled())
- return;
- CGContextRef context = platformContext();
- switch (m_common->state.fillColorSpace) {
- case SolidColorSpace:
- if (fillColor().alpha())
- CGContextFillRect(context, rect);
- break;
- case PatternColorSpace:
- applyFillPattern(this, m_common->state.fillPattern.get());
- CGContextFillRect(context, rect);
- break;
- case GradientColorSpace:
- CGContextSaveGState(context);
- CGContextClipToRect(context, rect);
- CGContextDrawShading(context, m_common->state.fillGradient->platformGradient());
- CGContextRestoreGState(context);
- break;
- }
-}
-
-void GraphicsContext::fillRect(const FloatRect& rect, const Color& color)
-{
- if (paintingDisabled())
- return;
- if (color.alpha()) {
- CGContextRef context = platformContext();
- Color oldFillColor = fillColor();
- if (oldFillColor != color)
- setCGFillColor(context, color);
- CGContextFillRect(context, rect);
- if (oldFillColor != color)
- setCGFillColor(context, oldFillColor);
- }
-}
-
-void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color& color)
-{
- if (paintingDisabled() || !color.alpha())
- return;
-
- CGContextRef context = platformContext();
- Color oldFillColor = fillColor();
- if (oldFillColor != color)
- setCGFillColor(context, color);
-
- addPath(Path::createRoundedRectangle(rect, topLeft, topRight, bottomLeft, bottomRight));
- fillPath();
-
- if (oldFillColor != color)
- setCGFillColor(context, oldFillColor);
-}
-
-void GraphicsContext::clip(const FloatRect& rect)
-{
- if (paintingDisabled())
- return;
- CGContextClipToRect(platformContext(), rect);
- m_data->clip(rect);
-}
-
-void GraphicsContext::clipOut(const IntRect& rect)
-{
- if (paintingDisabled())
- return;
-
- CGRect rects[2] = { CGContextGetClipBoundingBox(platformContext()), rect };
- CGContextBeginPath(platformContext());
- CGContextAddRects(platformContext(), rects, 2);
- CGContextEOClip(platformContext());
-}
-
-void GraphicsContext::clipOutEllipseInRect(const IntRect& rect)
-{
- if (paintingDisabled())
- return;
-
- CGContextBeginPath(platformContext());
- CGContextAddRect(platformContext(), CGContextGetClipBoundingBox(platformContext()));
- CGContextAddEllipseInRect(platformContext(), rect);
- CGContextEOClip(platformContext());
-}
-
-void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect, int thickness)
-{
- if (paintingDisabled())
- return;
-
- clip(rect);
- CGContextRef context = platformContext();
-
- // Add outer ellipse
- CGContextAddEllipseInRect(context, CGRectMake(rect.x(), rect.y(), rect.width(), rect.height()));
- // Add inner ellipse.
- CGContextAddEllipseInRect(context, CGRectMake(rect.x() + thickness, rect.y() + thickness,
- rect.width() - (thickness * 2), rect.height() - (thickness * 2)));
-
- CGContextEOClip(context);
-}
-
-void GraphicsContext::clipToImageBuffer(const FloatRect& rect, const ImageBuffer* imageBuffer)
-{
- if (paintingDisabled())
- return;
-
- CGContextTranslateCTM(platformContext(), rect.x(), rect.y() + rect.height());
- CGContextScaleCTM(platformContext(), 1, -1);
- CGContextClipToMask(platformContext(), FloatRect(FloatPoint(), rect.size()), imageBuffer->image()->getCGImageRef());
- CGContextScaleCTM(platformContext(), 1, -1);
- CGContextTranslateCTM(platformContext(), -rect.x(), -rect.y() - rect.height());
-}
-
-void GraphicsContext::beginTransparencyLayer(float opacity)
-{
- if (paintingDisabled())
- return;
- CGContextRef context = platformContext();
- CGContextSaveGState(context);
- CGContextSetAlpha(context, opacity);
- CGContextBeginTransparencyLayer(context, 0);
- m_data->beginTransparencyLayer();
- m_data->m_userToDeviceTransformKnownToBeIdentity = false;
-}
-
-void GraphicsContext::endTransparencyLayer()
-{
- if (paintingDisabled())
- return;
- CGContextRef context = platformContext();
- CGContextEndTransparencyLayer(context);
- CGContextRestoreGState(context);
- m_data->endTransparencyLayer();
- m_data->m_userToDeviceTransformKnownToBeIdentity = false;
-}
-
-void GraphicsContext::setPlatformShadow(const IntSize& size, int blur, const Color& color)
-{
- if (paintingDisabled())
- return;
- CGContextRef context = platformContext();
- CGAffineTransform transform = CGContextGetCTM(context);
-
- CGFloat A = transform.a * transform.a + transform.b * transform.b;
- CGFloat B = transform.a * transform.c + transform.b * transform.d;
- CGFloat C = B;
- CGFloat D = transform.c * transform.c + transform.d * transform.d;
-
- CGFloat smallEigenvalue = narrowPrecisionToCGFloat(sqrt(0.5 * ((A + D) - sqrt(4 * B * C + (A - D) * (A - D)))));
-
- // Extreme "blur" values can make text drawing crash or take crazy long times, so clamp
- CGFloat blurRadius = min(blur * smallEigenvalue, narrowPrecisionToCGFloat(1000.0));
-
- CGSize sizeInDeviceSpace = CGSizeApplyAffineTransform(size, transform);
-
- CGFloat width = sizeInDeviceSpace.width;
- CGFloat height = sizeInDeviceSpace.height;
-
- // Work around <rdar://problem/5539388> by ensuring that the offsets will get truncated
- // to the desired integer.
- static const CGFloat extraShadowOffset = narrowPrecisionToCGFloat(1.0 / 128);
- if (width > 0)
- width += extraShadowOffset;
- else if (width < 0)
- width -= extraShadowOffset;
-
- if (height > 0)
- height += extraShadowOffset;
- else if (height < 0)
- height -= extraShadowOffset;
-
- // Check for an invalid color, as this means that the color was not set for the shadow
- // and we should therefore just use the default shadow color.
- if (!color.isValid())
- CGContextSetShadow(context, CGSizeMake(width, height), blurRadius);
- else {
- CGColorRef colorCG = cgColor(color);
- CGContextSetShadowWithColor(context,
- CGSizeMake(width, height),
- blurRadius,
- colorCG);
- CGColorRelease(colorCG);
- }
-}
-
-void GraphicsContext::clearPlatformShadow()
-{
- if (paintingDisabled())
- return;
- CGContextSetShadowWithColor(platformContext(), CGSizeZero, 0, 0);
-}
-
-void GraphicsContext::setMiterLimit(float limit)
-{
- if (paintingDisabled())
- return;
- CGContextSetMiterLimit(platformContext(), limit);
-}
-
-void GraphicsContext::setAlpha(float alpha)
-{
- if (paintingDisabled())
- return;
- CGContextSetAlpha(platformContext(), alpha);
-}
-
-void GraphicsContext::clearRect(const FloatRect& r)
-{
- if (paintingDisabled())
- return;
- CGContextClearRect(platformContext(), r);
-}
-
-void GraphicsContext::strokeRect(const FloatRect& r, float lineWidth)
-{
- if (paintingDisabled())
- return;
- CGContextStrokeRectWithWidth(platformContext(), r, lineWidth);
-}
-
-void GraphicsContext::setLineCap(LineCap cap)
-{
- if (paintingDisabled())
- return;
- switch (cap) {
- case ButtCap:
- CGContextSetLineCap(platformContext(), kCGLineCapButt);
- break;
- case RoundCap:
- CGContextSetLineCap(platformContext(), kCGLineCapRound);
- break;
- case SquareCap:
- CGContextSetLineCap(platformContext(), kCGLineCapSquare);
- break;
- }
-}
-
-void GraphicsContext::setLineDash(const DashArray& dashes, float dashOffset)
-{
- CGContextSetLineDash(platformContext(), dashOffset, dashes.data(), dashes.size());
-}
-
-void GraphicsContext::setLineJoin(LineJoin join)
-{
- if (paintingDisabled())
- return;
- switch (join) {
- case MiterJoin:
- CGContextSetLineJoin(platformContext(), kCGLineJoinMiter);
- break;
- case RoundJoin:
- CGContextSetLineJoin(platformContext(), kCGLineJoinRound);
- break;
- case BevelJoin:
- CGContextSetLineJoin(platformContext(), kCGLineJoinBevel);
- break;
- }
-}
-
-void GraphicsContext::beginPath()
-{
- CGContextBeginPath(platformContext());
-}
-
-void GraphicsContext::addPath(const Path& path)
-{
- CGContextAddPath(platformContext(), path.platformPath());
-}
-
-void GraphicsContext::clip(const Path& path)
-{
- if (paintingDisabled())
- return;
- CGContextRef context = platformContext();
- CGContextBeginPath(context);
- CGContextAddPath(context, path.platformPath());
- CGContextClip(context);
- m_data->clip(path);
-}
-
-void GraphicsContext::clipOut(const Path& path)
-{
- if (paintingDisabled())
- return;
-
- CGContextBeginPath(platformContext());
- CGContextAddRect(platformContext(), CGContextGetClipBoundingBox(platformContext()));
- CGContextAddPath(platformContext(), path.platformPath());
- CGContextEOClip(platformContext());
-}
-
-void GraphicsContext::scale(const FloatSize& size)
-{
- if (paintingDisabled())
- return;
- CGContextScaleCTM(platformContext(), size.width(), size.height());
- m_data->scale(size);
- m_data->m_userToDeviceTransformKnownToBeIdentity = false;
-}
-
-void GraphicsContext::rotate(float angle)
-{
- if (paintingDisabled())
- return;
- CGContextRotateCTM(platformContext(), angle);
- m_data->rotate(angle);
- m_data->m_userToDeviceTransformKnownToBeIdentity = false;
-}
-
-void GraphicsContext::translate(float x, float y)
-{
- if (paintingDisabled())
- return;
- CGContextTranslateCTM(platformContext(), x, y);
- m_data->translate(x, y);
- m_data->m_userToDeviceTransformKnownToBeIdentity = false;
-}
-
-void GraphicsContext::concatCTM(const AffineTransform& transform)
-{
- if (paintingDisabled())
- return;
- CGContextConcatCTM(platformContext(), transform);
- m_data->concatCTM(transform);
- m_data->m_userToDeviceTransformKnownToBeIdentity = false;
-}
-
-AffineTransform GraphicsContext::getCTM() const
-{
- return CGContextGetCTM(platformContext());
-}
-
-FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& rect)
-{
- // It is not enough just to round to pixels in device space. The rotation part of the
- // affine transform matrix to device space can mess with this conversion if we have a
- // rotating image like the hands of the world clock widget. We just need the scale, so
- // we get the affine transform matrix and extract the scale.
-
- if (m_data->m_userToDeviceTransformKnownToBeIdentity)
- return rect;
-
- CGAffineTransform deviceMatrix = CGContextGetUserSpaceToDeviceSpaceTransform(platformContext());
- if (CGAffineTransformIsIdentity(deviceMatrix)) {
- m_data->m_userToDeviceTransformKnownToBeIdentity = true;
- return rect;
- }
-
- float deviceScaleX = sqrtf(deviceMatrix.a * deviceMatrix.a + deviceMatrix.b * deviceMatrix.b);
- float deviceScaleY = sqrtf(deviceMatrix.c * deviceMatrix.c + deviceMatrix.d * deviceMatrix.d);
-
- CGPoint deviceOrigin = CGPointMake(rect.x() * deviceScaleX, rect.y() * deviceScaleY);
- CGPoint deviceLowerRight = CGPointMake((rect.x() + rect.width()) * deviceScaleX,
- (rect.y() + rect.height()) * deviceScaleY);
-
- deviceOrigin.x = roundf(deviceOrigin.x);
- deviceOrigin.y = roundf(deviceOrigin.y);
- deviceLowerRight.x = roundf(deviceLowerRight.x);
- deviceLowerRight.y = roundf(deviceLowerRight.y);
-
- // Don't let the height or width round to 0 unless either was originally 0
- if (deviceOrigin.y == deviceLowerRight.y && rect.height() != 0)
- deviceLowerRight.y += 1;
- if (deviceOrigin.x == deviceLowerRight.x && rect.width() != 0)
- deviceLowerRight.x += 1;
-
- FloatPoint roundedOrigin = FloatPoint(deviceOrigin.x / deviceScaleX, deviceOrigin.y / deviceScaleY);
- FloatPoint roundedLowerRight = FloatPoint(deviceLowerRight.x / deviceScaleX, deviceLowerRight.y / deviceScaleY);
- return FloatRect(roundedOrigin, roundedLowerRight - roundedOrigin);
-}
-
-void GraphicsContext::drawLineForText(const IntPoint& point, int width, bool printing)
-{
- if (paintingDisabled())
- return;
-
- if (width <= 0)
- return;
-
- CGContextSaveGState(platformContext());
-
- float x = point.x();
- float y = point.y();
- float lineLength = width;
-
- // Use a minimum thickness of 0.5 in user space.
- // See http://bugs.webkit.org/show_bug.cgi?id=4255 for details of why 0.5 is the right minimum thickness to use.
- float thickness = max(strokeThickness(), 0.5f);
-
- if (!printing) {
- // On screen, use a minimum thickness of 1.0 in user space (later rounded to an integral number in device space).
- float adjustedThickness = max(thickness, 1.0f);
-
- // FIXME: This should be done a better way.
- // We try to round all parameters to integer boundaries in device space. If rounding pixels in device space
- // makes our thickness more than double, then there must be a shrinking-scale factor and rounding to pixels
- // in device space will make the underlines too thick.
- CGRect lineRect = roundToDevicePixels(FloatRect(x, y, lineLength, adjustedThickness));
- if (lineRect.size.height < thickness * 2.0) {
- x = lineRect.origin.x;
- y = lineRect.origin.y;
- lineLength = lineRect.size.width;
- thickness = lineRect.size.height;
- CGContextSetShouldAntialias(platformContext(), false);
- }
- }
-
- if (fillColor() != strokeColor())
- setCGFillColor(platformContext(), strokeColor());
- CGContextFillRect(platformContext(), CGRectMake(x, y, lineLength, thickness));
-
- CGContextRestoreGState(platformContext());
-}
-
-void GraphicsContext::setURLForRect(const KURL& link, const IntRect& destRect)
-{
- if (paintingDisabled())
- return;
-
- CFURLRef urlRef = link.createCFURL();
- if (urlRef) {
- CGContextRef context = platformContext();
-
- // Get the bounding box to handle clipping.
- CGRect box = CGContextGetClipBoundingBox(context);
-
- IntRect intBox((int)box.origin.x, (int)box.origin.y, (int)box.size.width, (int)box.size.height);
- IntRect rect = destRect;
- rect.intersect(intBox);
-
- CGPDFContextSetURLForRect(context, urlRef,
- CGRectApplyAffineTransform(rect, CGContextGetCTM(context)));
-
- CFRelease(urlRef);
- }
-}
-
-void GraphicsContext::setImageInterpolationQuality(InterpolationQuality mode)
-{
- if (paintingDisabled())
- return;
-
- CGInterpolationQuality quality = kCGInterpolationDefault;
- switch (mode) {
- case InterpolationDefault:
- quality = kCGInterpolationDefault;
- break;
- case InterpolationNone:
- quality = kCGInterpolationNone;
- break;
- case InterpolationLow:
- quality = kCGInterpolationLow;
- break;
-
- // Fall through to InterpolationHigh if kCGInterpolationMedium is not available
- case InterpolationMedium:
-#if HAVE(CG_INTERPOLATION_MEDIUM)
- quality = kCGInterpolationMedium;
- break;
-#endif
- case InterpolationHigh:
- quality = kCGInterpolationHigh;
- break;
- }
- CGContextSetInterpolationQuality(platformContext(), quality);
-}
-
-InterpolationQuality GraphicsContext::imageInterpolationQuality() const
-{
- if (paintingDisabled())
- return InterpolationDefault;
-
- CGInterpolationQuality quality = CGContextGetInterpolationQuality(platformContext());
- switch (quality) {
- case kCGInterpolationDefault:
- return InterpolationDefault;
- case kCGInterpolationNone:
- return InterpolationNone;
- case kCGInterpolationLow:
- return InterpolationLow;
-#if HAVE(CG_INTERPOLATION_MEDIUM)
- case kCGInterpolationMedium:
- return InterpolationMedium;
-#endif
- case kCGInterpolationHigh:
- return InterpolationHigh;
- }
- return InterpolationDefault;
-}
-
-void GraphicsContext::setPlatformTextDrawingMode(int mode)
-{
- if (paintingDisabled())
- return;
-
- // Wow, wish CG had used bits here.
- CGContextRef context = platformContext();
- switch (mode) {
- case cTextInvisible: // Invisible
- CGContextSetTextDrawingMode(context, kCGTextInvisible);
- break;
- case cTextFill: // Fill
- CGContextSetTextDrawingMode(context, kCGTextFill);
- break;
- case cTextStroke: // Stroke
- CGContextSetTextDrawingMode(context, kCGTextStroke);
- break;
- case 3: // Fill | Stroke
- CGContextSetTextDrawingMode(context, kCGTextFillStroke);
- break;
- case cTextClip: // Clip
- CGContextSetTextDrawingMode(context, kCGTextClip);
- break;
- case 5: // Fill | Clip
- CGContextSetTextDrawingMode(context, kCGTextFillClip);
- break;
- case 6: // Stroke | Clip
- CGContextSetTextDrawingMode(context, kCGTextStrokeClip);
- break;
- case 7: // Fill | Stroke | Clip
- CGContextSetTextDrawingMode(context, kCGTextFillStrokeClip);
- break;
- default:
- break;
- }
-}
-
-void GraphicsContext::setPlatformStrokeColor(const Color& color)
-{
- if (paintingDisabled())
- return;
- setCGStrokeColor(platformContext(), color);
-}
-
-void GraphicsContext::setPlatformStrokeThickness(float thickness)
-{
- if (paintingDisabled())
- return;
- CGContextSetLineWidth(platformContext(), thickness);
-}
-
-void GraphicsContext::setPlatformFillColor(const Color& color)
-{
- if (paintingDisabled())
- return;
- setCGFillColor(platformContext(), color);
-}
-
-void GraphicsContext::setUseAntialiasing(bool enable)
-{
- if (paintingDisabled())
- return;
- CGContextSetShouldAntialias(platformContext(), enable);
-}
-
-#ifndef BUILDING_ON_TIGER // Tiger's setCompositeOperation() is defined in GraphicsContextMac.mm.
-void GraphicsContext::setCompositeOperation(CompositeOperator mode)
-{
- if (paintingDisabled())
- return;
-
- CGBlendMode target = kCGBlendModeNormal;
- switch (mode) {
- case CompositeClear:
- target = kCGBlendModeClear;
- break;
- case CompositeCopy:
- target = kCGBlendModeCopy;
- break;
- case CompositeSourceOver:
- //kCGBlendModeNormal
- break;
- case CompositeSourceIn:
- target = kCGBlendModeSourceIn;
- break;
- case CompositeSourceOut:
- target = kCGBlendModeSourceOut;
- break;
- case CompositeSourceAtop:
- target = kCGBlendModeSourceAtop;
- break;
- case CompositeDestinationOver:
- target = kCGBlendModeDestinationOver;
- break;
- case CompositeDestinationIn:
- target = kCGBlendModeDestinationIn;
- break;
- case CompositeDestinationOut:
- target = kCGBlendModeDestinationOut;
- break;
- case CompositeDestinationAtop:
- target = kCGBlendModeDestinationAtop;
- break;
- case CompositeXOR:
- target = kCGBlendModeXOR;
- break;
- case CompositePlusDarker:
- target = kCGBlendModePlusDarker;
- break;
- case CompositeHighlight:
- // currently unsupported
- break;
- case CompositePlusLighter:
- target = kCGBlendModePlusLighter;
- break;
- }
- CGContextSetBlendMode(platformContext(), target);
-}
-#endif
-
-}
-
diff --git a/WebCore/platform/graphics/cg/GraphicsContextPlatformPrivateCG.h b/WebCore/platform/graphics/cg/GraphicsContextPlatformPrivateCG.h
deleted file mode 100644
index 8827ff7..0000000
--- a/WebCore/platform/graphics/cg/GraphicsContextPlatformPrivateCG.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <CoreGraphics/CGContext.h>
-
-namespace WebCore {
-
-class GraphicsContextPlatformPrivate {
-public:
- GraphicsContextPlatformPrivate(CGContextRef cgContext)
- : m_cgContext(cgContext)
-#if PLATFORM(WIN)
- , m_hdc(0)
- , m_transparencyCount(0)
-#endif
- , m_userToDeviceTransformKnownToBeIdentity(false)
- {
- CGContextRetain(m_cgContext);
- }
-
- ~GraphicsContextPlatformPrivate()
- {
- CGContextRelease(m_cgContext);
- }
-
-#if PLATFORM(MAC) || PLATFORM(CHROMIUM)
- // These methods do nothing on Mac.
- void save() {}
- void restore() {}
- void clip(const FloatRect&) {}
- void clip(const Path&) {}
- void scale(const FloatSize&) {}
- void rotate(float) {}
- void translate(float, float) {}
- void concatCTM(const AffineTransform&) {}
- void beginTransparencyLayer() {}
- void endTransparencyLayer() {}
-#endif
-
-#if PLATFORM(WIN)
- // On Windows, we need to update the HDC for form controls to draw in the right place.
- void save();
- void restore();
- void clip(const FloatRect&);
- void clip(const Path&);
- void scale(const FloatSize&);
- void rotate(float);
- void translate(float, float);
- void concatCTM(const AffineTransform&);
- void beginTransparencyLayer() { m_transparencyCount++; }
- void endTransparencyLayer() { m_transparencyCount--; }
-
- HDC m_hdc;
- unsigned m_transparencyCount;
-#endif
-
- CGContextRef m_cgContext;
- bool m_userToDeviceTransformKnownToBeIdentity;
-};
-
-}
diff --git a/WebCore/platform/graphics/cg/ImageBufferCG.cpp b/WebCore/platform/graphics/cg/ImageBufferCG.cpp
deleted file mode 100644
index 502313b..0000000
--- a/WebCore/platform/graphics/cg/ImageBufferCG.cpp
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
- * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
- * Copyright (C) 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ImageBuffer.h"
-
-#include "Base64.h"
-#include "BitmapImage.h"
-#include "CString.h"
-#include "GraphicsContext.h"
-#include "ImageData.h"
-#include "MIMETypeRegistry.h"
-#include "PlatformString.h"
-#include <ApplicationServices/ApplicationServices.h>
-#include <wtf/Assertions.h>
-#include <wtf/OwnArrayPtr.h>
-#include <wtf/RetainPtr.h>
-
-using namespace std;
-
-namespace WebCore {
-
-ImageBufferData::ImageBufferData(const IntSize&)
- : m_data(0)
-{
-}
-
-ImageBuffer::ImageBuffer(const IntSize& size, bool grayScale, bool& success)
- : m_data(size)
- , m_size(size)
-{
- success = false; // Make early return mean failure.
- unsigned bytesPerRow;
- if (size.width() < 0 || size.height() < 0)
- return;
- bytesPerRow = size.width();
- if (!grayScale) {
- // Protect against overflow
- if (bytesPerRow > 0x3FFFFFFF)
- return;
- bytesPerRow *= 4;
- }
-
- m_data.m_data = tryFastCalloc(size.height(), bytesPerRow);
- ASSERT((reinterpret_cast<size_t>(m_data.m_data) & 2) == 0);
-
- CGColorSpaceRef colorSpace = grayScale ? CGColorSpaceCreateDeviceGray() : CGColorSpaceCreateDeviceRGB();
- CGContextRef cgContext = CGBitmapContextCreate(m_data.m_data, size.width(), size.height(), 8, bytesPerRow,
- colorSpace, grayScale ? kCGImageAlphaNone : kCGImageAlphaPremultipliedLast);
- CGColorSpaceRelease(colorSpace);
- if (!cgContext)
- return;
-
- m_context.set(new GraphicsContext(cgContext));
- m_context->scale(FloatSize(1, -1));
- m_context->translate(0, -size.height());
- CGContextRelease(cgContext);
- success = true;
-}
-
-ImageBuffer::~ImageBuffer()
-{
- fastFree(m_data.m_data);
-}
-
-GraphicsContext* ImageBuffer::context() const
-{
- return m_context.get();
-}
-
-Image* ImageBuffer::image() const
-{
- if (!m_image) {
- // It's assumed that if image() is called, the actual rendering to the
- // GraphicsContext must be done.
- ASSERT(context());
- CGImageRef cgImage = CGBitmapContextCreateImage(context()->platformContext());
- // BitmapImage will release the passed in CGImage on destruction
- m_image = BitmapImage::create(cgImage);
- }
- return m_image.get();
-}
-
-PassRefPtr<ImageData> ImageBuffer::getImageData(const IntRect& rect) const
-{
- PassRefPtr<ImageData> result = ImageData::create(rect.width(), rect.height());
- unsigned char* data = result->data()->data().data();
-
- if (rect.x() < 0 || rect.y() < 0 || (rect.x() + rect.width()) > m_size.width() || (rect.y() + rect.height()) > m_size.height())
- memset(data, 0, result->data()->length());
-
- int originx = rect.x();
- int destx = 0;
- if (originx < 0) {
- destx = -originx;
- originx = 0;
- }
- int endx = rect.x() + rect.width();
- if (endx > m_size.width())
- endx = m_size.width();
- int numColumns = endx - originx;
-
- int originy = rect.y();
- int desty = 0;
- if (originy < 0) {
- desty = -originy;
- originy = 0;
- }
- int endy = rect.y() + rect.height();
- if (endy > m_size.height())
- endy = m_size.height();
- int numRows = endy - originy;
-
- unsigned srcBytesPerRow = 4 * m_size.width();
- unsigned destBytesPerRow = 4 * rect.width();
-
- // ::create ensures that all ImageBuffers have valid data, so we don't need to check it here.
- unsigned char* srcRows = reinterpret_cast<unsigned char*>(m_data.m_data) + originy * srcBytesPerRow + originx * 4;
- unsigned char* destRows = data + desty * destBytesPerRow + destx * 4;
- for (int y = 0; y < numRows; ++y) {
- for (int x = 0; x < numColumns; x++) {
- int basex = x * 4;
- if (unsigned char alpha = srcRows[basex + 3]) {
- destRows[basex] = (srcRows[basex] * 255) / alpha;
- destRows[basex + 1] = (srcRows[basex + 1] * 255) / alpha;
- destRows[basex + 2] = (srcRows[basex + 2] * 255) / alpha;
- destRows[basex + 3] = alpha;
- } else
- reinterpret_cast<uint32_t*>(destRows + basex)[0] = reinterpret_cast<uint32_t*>(srcRows + basex)[0];
- }
- srcRows += srcBytesPerRow;
- destRows += destBytesPerRow;
- }
- return result;
-}
-
-void ImageBuffer::putImageData(ImageData* source, const IntRect& sourceRect, const IntPoint& destPoint)
-{
- ASSERT(sourceRect.width() > 0);
- ASSERT(sourceRect.height() > 0);
-
- int originx = sourceRect.x();
- int destx = destPoint.x() + sourceRect.x();
- ASSERT(destx >= 0);
- ASSERT(destx < m_size.width());
- ASSERT(originx >= 0);
- ASSERT(originx <= sourceRect.right());
-
- int endx = destPoint.x() + sourceRect.right();
- ASSERT(endx <= m_size.width());
-
- int numColumns = endx - destx;
-
- int originy = sourceRect.y();
- int desty = destPoint.y() + sourceRect.y();
- ASSERT(desty >= 0);
- ASSERT(desty < m_size.height());
- ASSERT(originy >= 0);
- ASSERT(originy <= sourceRect.bottom());
-
- int endy = destPoint.y() + sourceRect.bottom();
- ASSERT(endy <= m_size.height());
- int numRows = endy - desty;
-
- unsigned srcBytesPerRow = 4 * source->width();
- unsigned destBytesPerRow = 4 * m_size.width();
-
- unsigned char* srcRows = source->data()->data().data() + originy * srcBytesPerRow + originx * 4;
- unsigned char* destRows = reinterpret_cast<unsigned char*>(m_data.m_data) + desty * destBytesPerRow + destx * 4;
- for (int y = 0; y < numRows; ++y) {
- for (int x = 0; x < numColumns; x++) {
- int basex = x * 4;
- unsigned char alpha = srcRows[basex + 3];
- if (alpha != 255) {
- destRows[basex] = (srcRows[basex] * alpha + 254) / 255;
- destRows[basex + 1] = (srcRows[basex + 1] * alpha + 254) / 255;
- destRows[basex + 2] = (srcRows[basex + 2] * alpha + 254) / 255;
- destRows[basex + 3] = alpha;
- } else
- reinterpret_cast<uint32_t*>(destRows + basex)[0] = reinterpret_cast<uint32_t*>(srcRows + basex)[0];
- }
- destRows += destBytesPerRow;
- srcRows += srcBytesPerRow;
- }
-}
-
-static RetainPtr<CFStringRef> utiFromMIMEType(const String& mimeType)
-{
-#if PLATFORM(MAC)
- RetainPtr<CFStringRef> mimeTypeCFString(AdoptCF, mimeType.createCFString());
- return RetainPtr<CFStringRef>(AdoptCF, UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, mimeTypeCFString.get(), 0));
-#else
- // FIXME: Add Windows support for all the supported UTIs when a way to convert from MIMEType to UTI reliably is found.
- // For now, only support PNG, JPEG, and GIF. See <rdar://problem/6095286>.
- static const CFStringRef kUTTypePNG = CFSTR("public.png");
- static const CFStringRef kUTTypeJPEG = CFSTR("public.jpeg");
- static const CFStringRef kUTTypeGIF = CFSTR("com.compuserve.gif");
-
- if (equalIgnoringCase(mimeType, "image/png"))
- return kUTTypePNG;
- if (equalIgnoringCase(mimeType, "image/jpeg"))
- return kUTTypeJPEG;
- if (equalIgnoringCase(mimeType, "image/gif"))
- return kUTTypeGIF;
-
- ASSERT_NOT_REACHED();
- return kUTTypePNG;
-#endif
-}
-
-String ImageBuffer::toDataURL(const String& mimeType) const
-{
- ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType));
-
- RetainPtr<CGImageRef> image(AdoptCF, CGBitmapContextCreateImage(context()->platformContext()));
- if (!image)
- return "data:,";
-
- size_t width = CGImageGetWidth(image.get());
- size_t height = CGImageGetHeight(image.get());
-
- OwnArrayPtr<uint32_t> imageData(new uint32_t[width * height]);
- if (!imageData)
- return "data:,";
-
- RetainPtr<CGImageRef> transformedImage(AdoptCF, CGBitmapContextCreateImage(context()->platformContext()));
- if (!transformedImage)
- return "data:,";
-
- RetainPtr<CFMutableDataRef> transformedImageData(AdoptCF, CFDataCreateMutable(kCFAllocatorDefault, 0));
- if (!transformedImageData)
- return "data:,";
-
- RetainPtr<CGImageDestinationRef> imageDestination(AdoptCF, CGImageDestinationCreateWithData(transformedImageData.get(),
- utiFromMIMEType(mimeType).get(), 1, 0));
- if (!imageDestination)
- return "data:,";
-
- CGImageDestinationAddImage(imageDestination.get(), transformedImage.get(), 0);
- CGImageDestinationFinalize(imageDestination.get());
-
- Vector<char> in;
- in.append(CFDataGetBytePtr(transformedImageData.get()), CFDataGetLength(transformedImageData.get()));
-
- Vector<char> out;
- base64Encode(in, out);
- out.append('\0');
-
- return String::format("data:%s;base64,%s", mimeType.utf8().data(), out.data());
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/graphics/cg/ImageBufferData.h b/WebCore/platform/graphics/cg/ImageBufferData.h
deleted file mode 100644
index 5e6fc4c..0000000
--- a/WebCore/platform/graphics/cg/ImageBufferData.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2008 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ImageBufferData_h
-#define ImageBufferData_h
-
-namespace WebCore {
-
-class IntSize;
-
-class ImageBufferData {
-public:
- ImageBufferData(const IntSize&);
-
- void* m_data;
-};
-
-} // namespace WebCore
-
-#endif // ImageBufferData_h
diff --git a/WebCore/platform/graphics/cg/ImageCG.cpp b/WebCore/platform/graphics/cg/ImageCG.cpp
deleted file mode 100644
index 8609c46..0000000
--- a/WebCore/platform/graphics/cg/ImageCG.cpp
+++ /dev/null
@@ -1,312 +0,0 @@
-/*
- * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "BitmapImage.h"
-
-#if PLATFORM(CG)
-
-#include "AffineTransform.h"
-#include "FloatConversion.h"
-#include "FloatRect.h"
-#include "GraphicsContext.h"
-#include "ImageObserver.h"
-#include "PDFDocumentImage.h"
-#include "PlatformString.h"
-#include <ApplicationServices/ApplicationServices.h>
-
-#if PLATFORM(MAC) || PLATFORM(CHROMIUM)
-#include "WebCoreSystemInterface.h"
-#endif
-
-#if PLATFORM(WIN)
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
-#endif
-
-namespace WebCore {
-
-void FrameData::clear()
-{
- if (m_frame) {
- CGImageRelease(m_frame);
- m_frame = 0;
- // NOTE: We purposefully don't reset metadata here, so that even if we
- // throw away previously-decoded data, animation loops can still access
- // properties like frame durations without re-decoding.
- }
-}
-
-// ================================================
-// Image Class
-// ================================================
-
-BitmapImage::BitmapImage(CGImageRef cgImage, ImageObserver* observer)
- : Image(observer)
- , m_currentFrame(0)
- , m_frames(0)
- , m_frameTimer(0)
- , m_repetitionCount(cAnimationNone)
- , m_repetitionCountStatus(Unknown)
- , m_repetitionsComplete(0)
- , m_isSolidColor(false)
- , m_animationFinished(true)
- , m_allDataReceived(true)
- , m_haveSize(true)
- , m_sizeAvailable(true)
- , m_decodedSize(0)
- , m_haveFrameCount(true)
- , m_frameCount(1)
-{
- initPlatformData();
-
- CGFloat width = CGImageGetWidth(cgImage);
- CGFloat height = CGImageGetHeight(cgImage);
- m_decodedSize = width * height * 4;
- m_size = IntSize(width, height);
-
- m_frames.grow(1);
- m_frames[0].m_frame = cgImage;
- m_frames[0].m_hasAlpha = true;
- m_frames[0].m_haveMetadata = true;
- checkForSolidColor();
-}
-
-// Drawing Routines
-
-void BitmapImage::checkForSolidColor()
-{
- if (frameCount() > 1)
- m_isSolidColor = false;
- else {
- CGImageRef image = frameAtIndex(0);
-
- // Currently we only check for solid color in the important special case of a 1x1 image.
- if (image && CGImageGetWidth(image) == 1 && CGImageGetHeight(image) == 1) {
- unsigned char pixel[4]; // RGBA
- CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB();
- CGContextRef bmap = CGBitmapContextCreate(pixel, 1, 1, 8, sizeof(pixel), space,
- kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
- if (bmap) {
- GraphicsContext(bmap).setCompositeOperation(CompositeCopy);
- CGRect dst = { {0, 0}, {1, 1} };
- CGContextDrawImage(bmap, dst, image);
- if (pixel[3] == 0)
- m_solidColor = Color(0, 0, 0, 0);
- else
- m_solidColor = Color(pixel[0] * 255 / pixel[3], pixel[1] * 255 / pixel[3], pixel[2] * 255 / pixel[3], pixel[3]);
- m_isSolidColor = true;
- CFRelease(bmap);
- }
- CFRelease(space);
- }
- }
-}
-
-CGImageRef BitmapImage::getCGImageRef()
-{
- return frameAtIndex(0);
-}
-
-void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator compositeOp)
-{
- startAnimation();
-
- CGImageRef image = frameAtIndex(m_currentFrame);
- if (!image) // If it's too early we won't have an image yet.
- return;
-
- if (mayFillWithSolidColor()) {
- fillWithSolidColor(ctxt, destRect, solidColor(), compositeOp);
- return;
- }
-
- float currHeight = CGImageGetHeight(image);
- if (currHeight <= srcRect.y())
- return;
-
- CGContextRef context = ctxt->platformContext();
- ctxt->save();
-
- bool shouldUseSubimage = false;
-
- // If the source rect is a subportion of the image, then we compute an inflated destination rect that will hold the entire image
- // and then set a clip to the portion that we want to display.
- FloatRect adjustedDestRect = destRect;
- FloatSize selfSize = currentFrameSize();
- if (srcRect.size() != selfSize) {
- CGInterpolationQuality interpolationQuality = CGContextGetInterpolationQuality(context);
- // When the image is scaled using high-quality interpolation, we create a temporary CGImage
- // containing only the portion we want to display. We need to do this because high-quality
- // interpolation smoothes sharp edges, causing pixels from outside the source rect to bleed
- // into the destination rect. See <rdar://problem/6112909>.
- shouldUseSubimage = (interpolationQuality == kCGInterpolationHigh || interpolationQuality == kCGInterpolationDefault) && srcRect.size() != destRect.size();
- if (shouldUseSubimage) {
- image = CGImageCreateWithImageInRect(image, srcRect);
- if (currHeight < srcRect.bottom()) {
- ASSERT(CGImageGetHeight(image) == currHeight - CGRectIntegral(srcRect).origin.y);
- adjustedDestRect.setHeight(destRect.height() / srcRect.height() * CGImageGetHeight(image));
- }
- } else {
- float xScale = srcRect.width() / destRect.width();
- float yScale = srcRect.height() / destRect.height();
-
- adjustedDestRect.setLocation(FloatPoint(destRect.x() - srcRect.x() / xScale, destRect.y() - srcRect.y() / yScale));
- adjustedDestRect.setSize(FloatSize(selfSize.width() / xScale, selfSize.height() / yScale));
-
- CGContextClipToRect(context, destRect);
- }
- }
-
- // If the image is only partially loaded, then shrink the destination rect that we're drawing into accordingly.
- if (!shouldUseSubimage && currHeight < selfSize.height())
- adjustedDestRect.setHeight(adjustedDestRect.height() * currHeight / selfSize.height());
-
- // Flip the coords.
- ctxt->setCompositeOperation(compositeOp);
- CGContextTranslateCTM(context, adjustedDestRect.x(), adjustedDestRect.bottom());
- CGContextScaleCTM(context, 1, -1);
- adjustedDestRect.setLocation(FloatPoint());
-
- // Draw the image.
- CGContextDrawImage(context, adjustedDestRect, image);
-
- if (shouldUseSubimage)
- CGImageRelease(image);
-
- ctxt->restore();
-
- if (imageObserver())
- imageObserver()->didDraw(this);
-}
-
-void Image::drawPatternCallback(void* info, CGContextRef context)
-{
- CGImageRef image = (CGImageRef)info;
- CGContextDrawImage(context, GraphicsContext(context).roundToDevicePixels(FloatRect(0, 0, CGImageGetWidth(image), CGImageGetHeight(image))), image);
-}
-
-void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const AffineTransform& patternTransform,
- const FloatPoint& phase, CompositeOperator op, const FloatRect& destRect)
-{
- if (!nativeImageForCurrentFrame())
- return;
-
- ASSERT(patternTransform.isInvertible());
- if (!patternTransform.isInvertible())
- // Avoid a hang under CGContextDrawTiledImage on release builds.
- return;
-
- CGContextRef context = ctxt->platformContext();
- ctxt->save();
- CGContextClipToRect(context, destRect);
- ctxt->setCompositeOperation(op);
- CGContextTranslateCTM(context, destRect.x(), destRect.y() + destRect.height());
- CGContextScaleCTM(context, 1, -1);
-
- // Compute the scaled tile size.
- float scaledTileHeight = tileRect.height() * narrowPrecisionToFloat(patternTransform.d());
-
- // We have to adjust the phase to deal with the fact we're in Cartesian space now (with the bottom left corner of destRect being
- // the origin).
- float adjustedX = phase.x() - destRect.x() + tileRect.x() * narrowPrecisionToFloat(patternTransform.a()); // We translated the context so that destRect.x() is the origin, so subtract it out.
- float adjustedY = destRect.height() - (phase.y() - destRect.y() + tileRect.y() * narrowPrecisionToFloat(patternTransform.d()) + scaledTileHeight);
-
- CGImageRef tileImage = nativeImageForCurrentFrame();
- float h = CGImageGetHeight(tileImage);
-
- CGImageRef subImage;
- if (tileRect.size() == size())
- subImage = tileImage;
- else {
- // Copying a sub-image out of a partially-decoded image stops the decoding of the original image. It should never happen
- // because sub-images are only used for border-image, which only renders when the image is fully decoded.
- ASSERT(h == height());
- subImage = CGImageCreateWithImageInRect(tileImage, tileRect);
- }
-
-#ifndef BUILDING_ON_TIGER
- // Leopard has an optimized call for the tiling of image patterns, but we can only use it if the image has been decoded enough that
- // its buffer is the same size as the overall image. Because a partially decoded CGImageRef with a smaller width or height than the
- // overall image buffer needs to tile with "gaps", we can't use the optimized tiling call in that case.
- // FIXME: Could create WebKitSystemInterface SPI for CGCreatePatternWithImage2 and probably make Tiger tile faster as well.
- float scaledTileWidth = tileRect.width() * narrowPrecisionToFloat(patternTransform.a());
- float w = CGImageGetWidth(tileImage);
- if (w == size().width() && h == size().height())
- CGContextDrawTiledImage(context, FloatRect(adjustedX, adjustedY, scaledTileWidth, scaledTileHeight), subImage);
- else {
-#endif
-
- // On Leopard, this code now only runs for partially decoded images whose buffers do not yet match the overall size of the image.
- // On Tiger this code runs all the time. This code is suboptimal because the pattern does not reference the image directly, and the
- // pattern is destroyed before exiting the function. This means any decoding the pattern does doesn't end up cached anywhere, so we
- // redecode every time we paint.
- static const CGPatternCallbacks patternCallbacks = { 0, drawPatternCallback, NULL };
- CGAffineTransform matrix = CGAffineTransformMake(narrowPrecisionToCGFloat(patternTransform.a()), 0, 0, narrowPrecisionToCGFloat(patternTransform.d()), adjustedX, adjustedY);
- matrix = CGAffineTransformConcat(matrix, CGContextGetCTM(context));
- // The top of a partially-decoded image is drawn at the bottom of the tile. Map it to the top.
- matrix = CGAffineTransformTranslate(matrix, 0, size().height() - h);
- CGPatternRef pattern = CGPatternCreate(subImage, CGRectMake(0, 0, tileRect.width(), tileRect.height()),
- matrix, tileRect.width(), tileRect.height(),
- kCGPatternTilingConstantSpacing, true, &patternCallbacks);
- if (pattern == NULL) {
- if (subImage != tileImage)
- CGImageRelease(subImage);
- ctxt->restore();
- return;
- }
-
- CGColorSpaceRef patternSpace = CGColorSpaceCreatePattern(NULL);
-
- CGFloat alpha = 1;
- CGColorRef color = CGColorCreateWithPattern(patternSpace, pattern, &alpha);
- CGContextSetFillColorSpace(context, patternSpace);
- CGColorSpaceRelease(patternSpace);
- CGPatternRelease(pattern);
-
- // FIXME: Really want a public API for this. It is just CGContextSetBaseCTM(context, CGAffineTransformIdentiy).
- wkSetPatternBaseCTM(context, CGAffineTransformIdentity);
- CGContextSetPatternPhase(context, CGSizeZero);
-
- CGContextSetFillColorWithColor(context, color);
- CGContextFillRect(context, CGContextGetClipBoundingBox(context));
-
- CGColorRelease(color);
-
-#ifndef BUILDING_ON_TIGER
- }
-#endif
-
- if (subImage != tileImage)
- CGImageRelease(subImage);
- ctxt->restore();
-
- if (imageObserver())
- imageObserver()->didDraw(this);
-}
-
-
-}
-
-#endif // PLATFORM(CG)
diff --git a/WebCore/platform/graphics/cg/ImageSourceCG.cpp b/WebCore/platform/graphics/cg/ImageSourceCG.cpp
deleted file mode 100644
index 73907c9..0000000
--- a/WebCore/platform/graphics/cg/ImageSourceCG.cpp
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ImageSource.h"
-
-#if PLATFORM(CG)
-
-#include "IntSize.h"
-#include "SharedBuffer.h"
-#include <ApplicationServices/ApplicationServices.h>
-
-namespace WebCore {
-
-static const CFStringRef kCGImageSourceShouldPreferRGB32 = CFSTR("kCGImageSourceShouldPreferRGB32");
-
-ImageSource::ImageSource()
- : m_decoder(0)
-{
-}
-
-ImageSource::~ImageSource()
-{
- clear();
-}
-
-void ImageSource::clear()
-{
- if (m_decoder) {
- CFRelease(m_decoder);
- m_decoder = 0;
- }
-}
-
-CFDictionaryRef imageSourceOptions()
-{
- static CFDictionaryRef options;
-
- if (!options) {
- const void* keys[2] = { kCGImageSourceShouldCache, kCGImageSourceShouldPreferRGB32 };
- const void* values[2] = { kCFBooleanTrue, kCFBooleanTrue };
- options = CFDictionaryCreate(NULL, keys, values, 2,
- &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
- }
- return options;
-}
-
-bool ImageSource::initialized() const
-{
- return m_decoder;
-}
-
-void ImageSource::setData(SharedBuffer* data, bool allDataReceived)
-{
- if (!m_decoder)
- m_decoder = CGImageSourceCreateIncremental(NULL);
-#if PLATFORM(MAC)
- // On Mac the NSData inside the SharedBuffer can be secretly appended to without the SharedBuffer's knowledge. We use SharedBuffer's ability
- // to wrap itself inside CFData to get around this, ensuring that ImageIO is really looking at the SharedBuffer.
- CFDataRef cfData = data->createCFData();
-#else
- // If no NSData is available, then we know SharedBuffer will always just be a vector. That means no secret changes can occur to it behind the
- // scenes. We use CFDataCreateWithBytesNoCopy in that case.
- CFDataRef cfData = CFDataCreateWithBytesNoCopy(0, reinterpret_cast<const UInt8*>(data->data()), data->size(), kCFAllocatorNull);
-#endif
- CGImageSourceUpdateData(m_decoder, cfData, allDataReceived);
- CFRelease(cfData);
-}
-
-bool ImageSource::isSizeAvailable()
-{
- bool result = false;
- CGImageSourceStatus imageSourceStatus = CGImageSourceGetStatus(m_decoder);
-
- // Ragnaros yells: TOO SOON! You have awakened me TOO SOON, Executus!
- if (imageSourceStatus >= kCGImageStatusIncomplete) {
- CFDictionaryRef image0Properties = CGImageSourceCopyPropertiesAtIndex(m_decoder, 0, imageSourceOptions());
- if (image0Properties) {
- CFNumberRef widthNumber = (CFNumberRef)CFDictionaryGetValue(image0Properties, kCGImagePropertyPixelWidth);
- CFNumberRef heightNumber = (CFNumberRef)CFDictionaryGetValue(image0Properties, kCGImagePropertyPixelHeight);
- result = widthNumber && heightNumber;
- CFRelease(image0Properties);
- }
- }
-
- return result;
-}
-
-IntSize ImageSource::frameSizeAtIndex(size_t index) const
-{
- IntSize result;
- CFDictionaryRef properties = CGImageSourceCopyPropertiesAtIndex(m_decoder, index, imageSourceOptions());
- if (properties) {
- int w = 0, h = 0;
- CFNumberRef num = (CFNumberRef)CFDictionaryGetValue(properties, kCGImagePropertyPixelWidth);
- if (num)
- CFNumberGetValue(num, kCFNumberIntType, &w);
- num = (CFNumberRef)CFDictionaryGetValue(properties, kCGImagePropertyPixelHeight);
- if (num)
- CFNumberGetValue(num, kCFNumberIntType, &h);
- result = IntSize(w, h);
- CFRelease(properties);
- }
- return result;
-}
-
-IntSize ImageSource::size() const
-{
- return frameSizeAtIndex(0);
-}
-
-int ImageSource::repetitionCount()
-{
- int result = cAnimationLoopOnce; // No property means loop once.
- if (!initialized())
- return result;
-
- // A property with value 0 means loop forever.
- CFDictionaryRef properties = CGImageSourceCopyProperties(m_decoder, imageSourceOptions());
- if (properties) {
- CFDictionaryRef gifProperties = (CFDictionaryRef)CFDictionaryGetValue(properties, kCGImagePropertyGIFDictionary);
- if (gifProperties) {
- CFNumberRef num = (CFNumberRef)CFDictionaryGetValue(gifProperties, kCGImagePropertyGIFLoopCount);
- if (num)
- CFNumberGetValue(num, kCFNumberIntType, &result);
- } else
- result = cAnimationNone; // Turns out we're not a GIF after all, so we don't animate.
-
- CFRelease(properties);
- }
-
- return result;
-}
-
-size_t ImageSource::frameCount() const
-{
- return m_decoder ? CGImageSourceGetCount(m_decoder) : 0;
-}
-
-CGImageRef ImageSource::createFrameAtIndex(size_t index)
-{
- if (!initialized())
- return 0;
-
- CGImageRef image = CGImageSourceCreateImageAtIndex(m_decoder, index, imageSourceOptions());
- CFStringRef imageUTI = CGImageSourceGetType(m_decoder);
- static const CFStringRef xbmUTI = CFSTR("public.xbitmap-image");
- if (!imageUTI || !CFEqual(imageUTI, xbmUTI))
- return image;
-
- // If it is an xbm image, mask out all the white areas to render them transparent.
- const CGFloat maskingColors[6] = {255, 255, 255, 255, 255, 255};
- CGImageRef maskedImage = CGImageCreateWithMaskingColors(image, maskingColors);
- if (!maskedImage)
- return image;
-
- CGImageRelease(image);
- return maskedImage;
-}
-
-bool ImageSource::frameIsCompleteAtIndex(size_t index)
-{
- return CGImageSourceGetStatusAtIndex(m_decoder, index) == kCGImageStatusComplete;
-}
-
-float ImageSource::frameDurationAtIndex(size_t index)
-{
- if (!initialized())
- return 0;
-
- float duration = 0;
- CFDictionaryRef properties = CGImageSourceCopyPropertiesAtIndex(m_decoder, index, imageSourceOptions());
- if (properties) {
- CFDictionaryRef typeProperties = (CFDictionaryRef)CFDictionaryGetValue(properties, kCGImagePropertyGIFDictionary);
- if (typeProperties) {
- CFNumberRef num = (CFNumberRef)CFDictionaryGetValue(typeProperties, kCGImagePropertyGIFDelayTime);
- if (num)
- CFNumberGetValue(num, kCFNumberFloatType, &duration);
- }
- CFRelease(properties);
- }
-
- // Many annoying ads specify a 0 duration to make an image flash as quickly as possible.
- // We follow WinIE's behavior and use a duration of 100 ms for any frames that specify
- // a duration of <= 50 ms. See <http://bugs.webkit.org/show_bug.cgi?id=14413> or Radar 4051389 for more.
- if (duration < 0.051f)
- return 0.100f;
- return duration;
-}
-
-bool ImageSource::frameHasAlphaAtIndex(size_t index)
-{
- // Might be interesting to do this optimization on Mac some day, but for now we're just using this
- // for the Cairo source, since it uses our decoders, and our decoders can answer this question.
- // FIXME: Could return false for JPEG and other non-transparent image formats.
- // FIXME: Could maybe return false for a GIF Frame if we have enough info in the GIF properties dictionary
- // to determine whether or not a transparent color was defined.
- return true;
-}
-
-}
-
-#endif // PLATFORM(CG)
diff --git a/WebCore/platform/graphics/cg/IntPointCG.cpp b/WebCore/platform/graphics/cg/IntPointCG.cpp
deleted file mode 100644
index 95dbe5f..0000000
--- a/WebCore/platform/graphics/cg/IntPointCG.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "IntPoint.h"
-
-#if PLATFORM(CG)
-
-#include <ApplicationServices/ApplicationServices.h>
-
-namespace WebCore {
-
-IntPoint::IntPoint(const CGPoint& p) : m_x(static_cast<int>(p.x)), m_y(static_cast<int>(p.y))
-{
-}
-
-IntPoint::operator CGPoint() const
-{
- return CGPointMake(m_x, m_y);
-}
-
-}
-
-#endif // PLATFORM(CG)
diff --git a/WebCore/platform/graphics/cg/IntRectCG.cpp b/WebCore/platform/graphics/cg/IntRectCG.cpp
deleted file mode 100644
index 73fd63f..0000000
--- a/WebCore/platform/graphics/cg/IntRectCG.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "IntRect.h"
-
-#if PLATFORM(CG)
-
-#include <ApplicationServices/ApplicationServices.h>
-
-namespace WebCore {
-
-IntRect::operator CGRect() const
-{
- return CGRectMake(x(), y(), width(), height());
-}
-
-IntRect enclosingIntRect(const CGRect& rect)
-{
- int l = static_cast<int>(floorf(rect.origin.x));
- int t = static_cast<int>(floorf(rect.origin.y));
- int r = static_cast<int>(ceilf(CGRectGetMaxX(rect)));
- int b = static_cast<int>(ceilf(CGRectGetMaxY(rect)));
- return IntRect(l, t, r - l, b - t);
-}
-
-}
-
-#endif // PLATFORM(CG)
diff --git a/WebCore/platform/graphics/cg/IntSizeCG.cpp b/WebCore/platform/graphics/cg/IntSizeCG.cpp
deleted file mode 100644
index d8e8c83..0000000
--- a/WebCore/platform/graphics/cg/IntSizeCG.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "IntSize.h"
-
-#if PLATFORM(CG)
-
-#include <ApplicationServices/ApplicationServices.h>
-
-namespace WebCore {
-
-IntSize::IntSize(const CGSize& s) : m_width(static_cast<int>(s.width)), m_height(static_cast<int>(s.height))
-{
-}
-
-IntSize::operator CGSize() const
-{
- return CGSizeMake(m_width, m_height);
-}
-
-}
-
-#endif // PLATFORM(CG)
diff --git a/WebCore/platform/graphics/cg/PDFDocumentImage.cpp b/WebCore/platform/graphics/cg/PDFDocumentImage.cpp
deleted file mode 100644
index 2578f08..0000000
--- a/WebCore/platform/graphics/cg/PDFDocumentImage.cpp
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#define _USE_MATH_DEFINES 1
-#include "config.h"
-#include "PDFDocumentImage.h"
-
-#if PLATFORM(CG)
-
-#include "GraphicsContext.h"
-#include "ImageObserver.h"
-#include <wtf/MathExtras.h>
-
-using namespace std;
-
-namespace WebCore {
-
-PDFDocumentImage::PDFDocumentImage()
- : Image(0) // PDFs don't animate
- , m_document(0)
- , m_rotation(0.0f)
- , m_currentPage(-1)
-{
-}
-
-PDFDocumentImage::~PDFDocumentImage()
-{
- CGPDFDocumentRelease(m_document);
-}
-
-IntSize PDFDocumentImage::size() const
-{
- const float sina = sinf(-m_rotation);
- const float cosa = cosf(-m_rotation);
- const float width = m_mediaBox.size().width();
- const float height = m_mediaBox.size().height();
- const float rotWidth = width * cosa - height * sina;
- const float rotHeight = width * sina + height * cosa;
-
- return IntSize((int)(fabsf(rotWidth) + 0.5f), (int)(fabsf(rotHeight) + 0.5f));
-}
-
-bool PDFDocumentImage::dataChanged(bool allDataReceived)
-{
- if (allDataReceived && !m_document) {
-#if PLATFORM(MAC)
- // On Mac the NSData inside the SharedBuffer can be secretly appended to without the SharedBuffer's knowledge. We use SharedBuffer's ability
- // to wrap itself inside CFData to get around this, ensuring that ImageIO is really looking at the SharedBuffer.
- CFDataRef data = m_data->createCFData();
-#else
- // If no NSData is available, then we know SharedBuffer will always just be a vector. That means no secret changes can occur to it behind the
- // scenes. We use CFDataCreateWithBytesNoCopy in that case.
- CFDataRef data = CFDataCreateWithBytesNoCopy(0, reinterpret_cast<const UInt8*>(m_data->data()), m_data->size(), kCFAllocatorNull);
-#endif
- CGDataProviderRef dataProvider = CGDataProviderCreateWithCFData(data);
- CFRelease(data);
- m_document = CGPDFDocumentCreateWithProvider(dataProvider);
- CGDataProviderRelease(dataProvider);
- setCurrentPage(0);
- }
- return m_document; // return true if size is available
-}
-
-void PDFDocumentImage::adjustCTM(GraphicsContext* context) const
-{
- // rotate the crop box and calculate bounding box
- float sina = sinf(-m_rotation);
- float cosa = cosf(-m_rotation);
- float width = m_cropBox.width();
- float height = m_cropBox.height();
-
- // calculate rotated x and y edges of the corp box. if they're negative, it means part of the image has
- // been rotated outside of the bounds and we need to shift over the image so it lies inside the bounds again
- CGPoint rx = CGPointMake(width * cosa, width * sina);
- CGPoint ry = CGPointMake(-height * sina, height * cosa);
-
- // adjust so we are at the crop box origin
- const CGFloat zero = 0;
- CGContextTranslateCTM(context->platformContext(), floorf(-min(zero, min(rx.x, ry.x))), floorf(-min(zero, min(rx.y, ry.y))));
-
- // rotate -ve to remove rotation
- CGContextRotateCTM(context->platformContext(), -m_rotation);
-
- // shift so we are completely within media box
- CGContextTranslateCTM(context->platformContext(), m_mediaBox.x() - m_cropBox.x(), m_mediaBox.y() - m_cropBox.y());
-}
-
-void PDFDocumentImage::setCurrentPage(int page)
-{
- if (!m_document)
- return;
-
- if (page == m_currentPage)
- return;
-
- if (!(page >= 0 && page < pageCount()))
- return;
-
- m_currentPage = page;
-
- CGPDFPageRef cgPage = CGPDFDocumentGetPage(m_document, page + 1);
-
- // get media box (guaranteed)
- m_mediaBox = CGPDFPageGetBoxRect(cgPage, kCGPDFMediaBox);
-
- // get crop box (not always there). if not, use media box
- CGRect r = CGPDFPageGetBoxRect(cgPage, kCGPDFCropBox);
- if (!CGRectIsEmpty(r))
- m_cropBox = r;
- else
- m_cropBox = m_mediaBox;
-
- // get page rotation angle
- m_rotation = CGPDFPageGetRotationAngle(cgPage) * piFloat / 180.0f; // to radians
-}
-
-int PDFDocumentImage::pageCount() const
-{
- return m_document ? CGPDFDocumentGetNumberOfPages(m_document) : 0;
-}
-
-void PDFDocumentImage::draw(GraphicsContext* context, const FloatRect& dstRect, const FloatRect& srcRect, CompositeOperator op)
-{
- if (!m_document || m_currentPage == -1)
- return;
-
- context->save();
-
- context->setCompositeOperation(op);
-
- float hScale = dstRect.width() / srcRect.width();
- float vScale = dstRect.height() / srcRect.height();
-
- // Scale and translate so the document is rendered in the correct location,
- // including accounting for the fact that a GraphicsContext is always flipped
- // and doing appropriate flipping.
- CGContextTranslateCTM(context->platformContext(), dstRect.x() - srcRect.x() * hScale, dstRect.y() - srcRect.y() * vScale);
- CGContextScaleCTM(context->platformContext(), hScale, vScale);
- CGContextScaleCTM(context->platformContext(), 1, -1);
- CGContextTranslateCTM(context->platformContext(), 0, -srcRect.height());
- CGContextClipToRect(context->platformContext(), CGRectIntegral(srcRect));
-
- // Rotate translate image into position according to doc properties.
- adjustCTM(context);
-
- CGContextTranslateCTM(context->platformContext(), -m_mediaBox.x(), -m_mediaBox.y());
- CGContextDrawPDFPage(context->platformContext(), CGPDFDocumentGetPage(m_document, m_currentPage + 1));
-
- context->restore();
-
- if (imageObserver())
- imageObserver()->didDraw(this);
-}
-
-}
-
-#endif // PLATFORM(CG)
diff --git a/WebCore/platform/graphics/cg/PDFDocumentImage.h b/WebCore/platform/graphics/cg/PDFDocumentImage.h
deleted file mode 100644
index 5c9d4e1..0000000
--- a/WebCore/platform/graphics/cg/PDFDocumentImage.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "Image.h"
-
-#include "FloatRect.h"
-#include "GraphicsTypes.h"
-
-#if PLATFORM(CG)
-
-#include <ApplicationServices/ApplicationServices.h>
-
-namespace WebCore {
-
- class GraphicsContext;
-
- class PDFDocumentImage : public Image {
- public:
- static PassRefPtr<PDFDocumentImage> create()
- {
- return adoptRef(new PDFDocumentImage);
- }
- ~PDFDocumentImage();
-
- virtual bool hasSingleSecurityOrigin() const { return true; }
-
- virtual bool dataChanged(bool allDataReceived);
-
- // FIXME: PDF Images are underreporting decoded sizes and will be unable
- // to prune because these functions are not implemented yet.
- virtual void destroyDecodedData(bool incremental = false, bool preserveNearbyFrames = false) { }
- virtual unsigned decodedSize() const { return 0; }
-
- virtual IntSize size() const;
-
- private:
- PDFDocumentImage();
- virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, CompositeOperator);
-
- void setCurrentPage(int);
- int pageCount() const;
- void adjustCTM(GraphicsContext*) const;
-
- CGPDFDocumentRef m_document;
- FloatRect m_mediaBox;
- FloatRect m_cropBox;
- float m_rotation;
- int m_currentPage;
- };
-
-}
-
-#endif // PLATFORM(CG)
diff --git a/WebCore/platform/graphics/cg/PathCG.cpp b/WebCore/platform/graphics/cg/PathCG.cpp
deleted file mode 100644
index 1382589..0000000
--- a/WebCore/platform/graphics/cg/PathCG.cpp
+++ /dev/null
@@ -1,291 +0,0 @@
-/*
- * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
- * 2006, 2008 Rob Buis <buis@kde.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Path.h"
-
-#if PLATFORM(CG)
-
-#include "AffineTransform.h"
-#include <ApplicationServices/ApplicationServices.h>
-#include "FloatRect.h"
-#include "IntRect.h"
-#include "PlatformString.h"
-
-#include <wtf/MathExtras.h>
-
-namespace WebCore {
-
-Path::Path()
- : m_path(CGPathCreateMutable())
-{
-}
-
-Path::~Path()
-{
- CGPathRelease(m_path);
-}
-
-Path::Path(const Path& other)
- : m_path(CGPathCreateMutableCopy(other.m_path))
-{
-}
-
-Path& Path::operator=(const Path& other)
-{
- CGMutablePathRef path = CGPathCreateMutableCopy(other.m_path);
- CGPathRelease(m_path);
- m_path = path;
- return *this;
-}
-
-
-static void copyClosingSubpathsApplierFunction(void* info, const CGPathElement* element)
-{
- CGMutablePathRef path = static_cast<CGMutablePathRef>(info);
- CGPoint* points = element->points;
-
- switch (element->type) {
- case kCGPathElementMoveToPoint:
- if (!CGPathIsEmpty(path)) // to silence a warning when trying to close an empty path
- CGPathCloseSubpath(path); // This is the only change from CGPathCreateMutableCopy
- CGPathMoveToPoint(path, 0, points[0].x, points[0].y);
- break;
- case kCGPathElementAddLineToPoint:
- CGPathAddLineToPoint(path, 0, points[0].x, points[0].y);
- break;
- case kCGPathElementAddQuadCurveToPoint:
- CGPathAddQuadCurveToPoint(path, 0, points[0].x, points[0].y, points[1].x, points[1].y);
- break;
- case kCGPathElementAddCurveToPoint:
- CGPathAddCurveToPoint(path, 0, points[0].x, points[0].y, points[1].x, points[1].y, points[2].x, points[2].y);
- break;
- case kCGPathElementCloseSubpath:
- CGPathCloseSubpath(path);
- break;
- }
-}
-
-static CGMutablePathRef copyCGPathClosingSubpaths(CGPathRef originalPath)
-{
- CGMutablePathRef path = CGPathCreateMutable();
- CGPathApply(originalPath, path, copyClosingSubpathsApplierFunction);
- CGPathCloseSubpath(path);
- return path;
-}
-
-bool Path::contains(const FloatPoint &point, WindRule rule) const
-{
- if (!boundingRect().contains(point))
- return false;
-
- // CGPathContainsPoint returns false for non-closed paths, as a work-around, we copy and close the path first. Radar 4758998 asks for a better CG API to use
- CGMutablePathRef path = copyCGPathClosingSubpaths(m_path);
- bool ret = CGPathContainsPoint(path, 0, point, rule == RULE_EVENODD ? true : false);
- CGPathRelease(path);
- return ret;
-}
-
-void Path::translate(const FloatSize& size)
-{
- CGAffineTransform translation = CGAffineTransformMake(1, 0, 0, 1, size.width(), size.height());
- CGMutablePathRef newPath = CGPathCreateMutable();
- CGPathAddPath(newPath, &translation, m_path);
- CGPathRelease(m_path);
- m_path = newPath;
-}
-
-FloatRect Path::boundingRect() const
-{
- return CGPathGetBoundingBox(m_path);
-}
-
-void Path::moveTo(const FloatPoint& point)
-{
- CGPathMoveToPoint(m_path, 0, point.x(), point.y());
-}
-
-void Path::addLineTo(const FloatPoint& p)
-{
- CGPathAddLineToPoint(m_path, 0, p.x(), p.y());
-}
-
-void Path::addQuadCurveTo(const FloatPoint& cp, const FloatPoint& p)
-{
- CGPathAddQuadCurveToPoint(m_path, 0, cp.x(), cp.y(), p.x(), p.y());
-}
-
-void Path::addBezierCurveTo(const FloatPoint& cp1, const FloatPoint& cp2, const FloatPoint& p)
-{
- CGPathAddCurveToPoint(m_path, 0, cp1.x(), cp1.y(), cp2.x(), cp2.y(), p.x(), p.y());
-}
-
-void Path::addArcTo(const FloatPoint& p1, const FloatPoint& p2, float radius)
-{
- CGPathAddArcToPoint(m_path, 0, p1.x(), p1.y(), p2.x(), p2.y(), radius);
-}
-
-void Path::closeSubpath()
-{
- if (!CGPathIsEmpty(m_path)) // to silence a warning when trying to close an empty path
- CGPathCloseSubpath(m_path);
-}
-
-void Path::addArc(const FloatPoint& p, float r, float sa, float ea, bool clockwise)
-{
- // Workaround for <rdar://problem/5189233> CGPathAddArc hangs or crashes when passed inf as start or end angle
- if (isfinite(sa) && isfinite(ea))
- CGPathAddArc(m_path, 0, p.x(), p.y(), r, sa, ea, clockwise);
-}
-
-void Path::addRect(const FloatRect& r)
-{
- CGPathAddRect(m_path, 0, r);
-}
-
-void Path::addEllipse(const FloatRect& r)
-{
- CGPathAddEllipseInRect(m_path, 0, r);
-}
-
-void Path::clear()
-{
- CGPathRelease(m_path);
- m_path = CGPathCreateMutable();
-}
-
-bool Path::isEmpty() const
-{
- return CGPathIsEmpty(m_path);
- }
-
-static void CGPathToCFStringApplierFunction(void* info, const CGPathElement *element)
-{
- CFMutableStringRef string = (CFMutableStringRef)info;
- CFStringRef typeString = CFSTR("");
- CGPoint* points = element->points;
- switch (element->type) {
- case kCGPathElementMoveToPoint:
- CFStringAppendFormat(string, 0, CFSTR("M%.2f,%.2f "), points[0].x, points[0].y);
- break;
- case kCGPathElementAddLineToPoint:
- CFStringAppendFormat(string, 0, CFSTR("L%.2f,%.2f "), points[0].x, points[0].y);
- break;
- case kCGPathElementAddQuadCurveToPoint:
- CFStringAppendFormat(string, 0, CFSTR("Q%.2f,%.2f,%.2f,%.2f "),
- points[0].x, points[0].y, points[1].x, points[1].y);
- break;
- case kCGPathElementAddCurveToPoint:
- CFStringAppendFormat(string, 0, CFSTR("C%.2f,%.2f,%.2f,%.2f,%.2f,%.2f "),
- points[0].x, points[0].y, points[1].x, points[1].y,
- points[2].x, points[2].y);
- break;
- case kCGPathElementCloseSubpath:
- typeString = CFSTR("X"); break;
- }
-}
-
-static CFStringRef CFStringFromCGPath(CGPathRef path)
-{
- if (!path)
- return 0;
-
- CFMutableStringRef string = CFStringCreateMutable(NULL, 0);
- CGPathApply(path, string, CGPathToCFStringApplierFunction);
- CFStringTrimWhitespace(string);
-
-
- return string;
-}
-
-
-#pragma mark -
-#pragma mark Path Management
-
-String Path::debugString() const
-{
- String result;
- if (!isEmpty()) {
- CFStringRef pathString = CFStringFromCGPath(m_path);
- result = String(pathString);
- CFRelease(pathString);
- }
- return result;
-}
-
-struct PathApplierInfo {
- void* info;
- PathApplierFunction function;
-};
-
-void CGPathApplierToPathApplier(void *info, const CGPathElement *element)
-{
- PathApplierInfo* pinfo = (PathApplierInfo*)info;
- FloatPoint points[3];
- PathElement pelement;
- pelement.type = (PathElementType)element->type;
- pelement.points = points;
- CGPoint* cgPoints = element->points;
- switch (element->type) {
- case kCGPathElementMoveToPoint:
- case kCGPathElementAddLineToPoint:
- points[0] = cgPoints[0];
- break;
- case kCGPathElementAddQuadCurveToPoint:
- points[0] = cgPoints[0];
- points[1] = cgPoints[1];
- break;
- case kCGPathElementAddCurveToPoint:
- points[0] = cgPoints[0];
- points[1] = cgPoints[1];
- points[2] = cgPoints[2];
- break;
- case kCGPathElementCloseSubpath:
- break;
- }
- pinfo->function(pinfo->info, &pelement);
-}
-
-void Path::apply(void* info, PathApplierFunction function) const
-{
- PathApplierInfo pinfo;
- pinfo.info = info;
- pinfo.function = function;
- CGPathApply(m_path, &pinfo, CGPathApplierToPathApplier);
-}
-
-void Path::transform(const AffineTransform& transform)
-{
- CGMutablePathRef path = CGPathCreateMutable();
- CGAffineTransform transformCG = transform;
- CGPathAddPath(path, &transformCG, m_path);
- CGPathRelease(m_path);
- m_path = path;
-}
-
-}
-
-#endif // PLATFORM(CG)
diff --git a/WebCore/platform/graphics/cg/PatternCG.cpp b/WebCore/platform/graphics/cg/PatternCG.cpp
deleted file mode 100644
index e1f7a69..0000000
--- a/WebCore/platform/graphics/cg/PatternCG.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Pattern.h"
-
-#include "AffineTransform.h"
-#include "GraphicsContext.h"
-
-#include <ApplicationServices/ApplicationServices.h>
-
-namespace WebCore {
-
-static void patternCallback(void* info, CGContextRef context)
-{
- CGImageRef platformImage = static_cast<Image*>(info)->getCGImageRef();
- if (!platformImage)
- return;
-
- CGRect rect = GraphicsContext(context).roundToDevicePixels(
- FloatRect(0, 0, CGImageGetWidth(platformImage), CGImageGetHeight(platformImage)));
- CGContextDrawImage(context, rect, platformImage);
-}
-
-static void patternReleaseCallback(void* info)
-{
- static_cast<Image*>(info)->deref();
-}
-
-CGPatternRef Pattern::createPlatformPattern(const AffineTransform& transform) const
-{
- IntRect tileRect = tileImage()->rect();
-
- AffineTransform patternTransform = transform;
- patternTransform.scale(1, -1);
- patternTransform.translate(0, -tileRect.height());
-
- // If FLT_MAX should also be used for xStep or yStep, nothing is rendered. Using fractions of FLT_MAX also
- // result in nothing being rendered.
- // INT_MAX is almost correct, but there seems to be some number wrapping occuring making the fill
- // pattern is not filled correctly.
- // So, just pick a really large number that works.
- float xStep = m_repeatX ? tileRect.width() : (100000000.0f);
- float yStep = m_repeatY ? tileRect.height() : (100000000.0f);
-
- // The pattern will release the tile when it's done rendering in patternReleaseCallback
- tileImage()->ref();
-
- const CGPatternCallbacks patternCallbacks = { 0, patternCallback, patternReleaseCallback };
- return CGPatternCreate(tileImage(), tileRect, patternTransform, xStep, yStep,
- kCGPatternTilingConstantSpacing, TRUE, &patternCallbacks);
-}
-
-}
diff --git a/WebCore/platform/graphics/filters/FEBlend.cpp b/WebCore/platform/graphics/filters/FEBlend.cpp
deleted file mode 100644
index 7210367..0000000
--- a/WebCore/platform/graphics/filters/FEBlend.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
- 2004, 2005 Rob Buis <buis@kde.org>
- 2005 Eric Seidel <eric@webkit.org>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- aint with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include "config.h"
-
-#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
-#include "FEBlend.h"
-
-namespace WebCore {
-
-FEBlend::FEBlend(FilterEffect* in, FilterEffect* in2, BlendModeType mode)
- : FilterEffect()
- , m_in(in)
- , m_in2(in2)
- , m_mode(mode)
-{
-}
-
-PassRefPtr<FEBlend> FEBlend::create(FilterEffect* in, FilterEffect* in2, BlendModeType mode)
-{
- return adoptRef(new FEBlend(in, in2, mode));
-}
-
-FilterEffect* FEBlend::in2() const
-{
- return m_in2.get();
-}
-
-void FEBlend::setIn2(FilterEffect* in2)
-{
- m_in2 = in2;
-}
-
-BlendModeType FEBlend::blendMode() const
-{
- return m_mode;
-}
-
-void FEBlend::setBlendMode(BlendModeType mode)
-{
- m_mode = mode;
-}
-
-void FEBlend::apply()
-{
-}
-
-void FEBlend::dump()
-{
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/platform/graphics/filters/FEBlend.h b/WebCore/platform/graphics/filters/FEBlend.h
deleted file mode 100644
index b2835e8..0000000
--- a/WebCore/platform/graphics/filters/FEBlend.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
- 2004, 2005 Rob Buis <buis@kde.org>
- 2005 Eric Seidel <eric@webkit.org>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- aint with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#ifndef SVGFEBlend_h
-#define SVGFEBlend_h
-
-#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
-#include "FilterEffect.h"
-
-namespace WebCore {
-
- enum BlendModeType {
- FEBLEND_MODE_UNKNOWN = 0,
- FEBLEND_MODE_NORMAL = 1,
- FEBLEND_MODE_MULTIPLY = 2,
- FEBLEND_MODE_SCREEN = 3,
- FEBLEND_MODE_DARKEN = 4,
- FEBLEND_MODE_LIGHTEN = 5
- };
-
- class FEBlend : public FilterEffect {
- public:
- static PassRefPtr<FEBlend> create(FilterEffect*, FilterEffect*, BlendModeType);
-
- FilterEffect* in2() const;
- void setIn2(FilterEffect*);
-
- BlendModeType blendMode() const;
- void setBlendMode(BlendModeType);
-
- virtual void apply();
- virtual void dump();
-
- private:
- FEBlend(FilterEffect*, FilterEffect*, BlendModeType);
-
- RefPtr<FilterEffect> m_in;
- RefPtr<FilterEffect> m_in2;
- BlendModeType m_mode;
- };
-
-} // namespace WebCore
-
-#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
-
-#endif // SVGFEBlend_h
diff --git a/WebCore/platform/graphics/filters/FEColorMatrix.cpp b/WebCore/platform/graphics/filters/FEColorMatrix.cpp
deleted file mode 100644
index f783106..0000000
--- a/WebCore/platform/graphics/filters/FEColorMatrix.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
- 2004, 2005 Rob Buis <buis@kde.org>
- 2005 Eric Seidel <eric@webkit.org>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- aint with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include "config.h"
-
-#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
-#include "FEColorMatrix.h"
-
-namespace WebCore {
-
-FEColorMatrix::FEColorMatrix(FilterEffect* in, ColorMatrixType type, const Vector<float>& values)
- : FilterEffect()
- , m_in(in)
- , m_type(type)
- , m_values(values)
-{
-}
-
-PassRefPtr<FEColorMatrix> FEColorMatrix::create(FilterEffect* in, ColorMatrixType type, const Vector<float>& values)
-{
- return adoptRef(new FEColorMatrix(in, type, values));
-}
-
-ColorMatrixType FEColorMatrix::type() const
-{
- return m_type;
-}
-
-void FEColorMatrix::setType(ColorMatrixType type)
-{
- m_type = type;
-}
-
-const Vector<float>& FEColorMatrix::values() const
-{
- return m_values;
-}
-
-void FEColorMatrix::setValues(const Vector<float> &values)
-{
- m_values = values;
-}
-
-void FEColorMatrix::apply()
-{
-}
-
-void FEColorMatrix::dump()
-{
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/platform/graphics/filters/FEColorMatrix.h b/WebCore/platform/graphics/filters/FEColorMatrix.h
deleted file mode 100644
index d8193ed..0000000
--- a/WebCore/platform/graphics/filters/FEColorMatrix.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
- 2004, 2005 Rob Buis <buis@kde.org>
- 2005 Eric Seidel <eric@webkit.org>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- aint with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#ifndef SVGFEColorMatrix_h
-#define SVGFEColorMatrix_h
-
-#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
-#include "FilterEffect.h"
-#include <wtf/Vector.h>
-
-namespace WebCore {
-
- enum ColorMatrixType {
- FECOLORMATRIX_TYPE_UNKNOWN = 0,
- FECOLORMATRIX_TYPE_MATRIX = 1,
- FECOLORMATRIX_TYPE_SATURATE = 2,
- FECOLORMATRIX_TYPE_HUEROTATE = 3,
- FECOLORMATRIX_TYPE_LUMINANCETOALPHA = 4
- };
-
- class FEColorMatrix : public FilterEffect {
- public:
- static PassRefPtr<FEColorMatrix> create(FilterEffect*, ColorMatrixType, const Vector<float>&);
-
- ColorMatrixType type() const;
- void setType(ColorMatrixType);
-
- const Vector<float>& values() const;
- void setValues(const Vector<float>&);
-
- virtual void apply();
- virtual void dump();
-
- private:
- FEColorMatrix(FilterEffect*, ColorMatrixType, const Vector<float>&);
-
- RefPtr<FilterEffect> m_in;
- ColorMatrixType m_type;
- Vector<float> m_values;
- };
-
-} // namespace WebCore
-
-#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
-
-#endif // SVGFEColorMatrix_h
diff --git a/WebCore/platform/graphics/filters/FEComponentTransfer.cpp b/WebCore/platform/graphics/filters/FEComponentTransfer.cpp
deleted file mode 100644
index 708ea3e..0000000
--- a/WebCore/platform/graphics/filters/FEComponentTransfer.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
- 2004, 2005 Rob Buis <buis@kde.org>
- 2005 Eric Seidel <eric@webkit.org>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- aint with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include "config.h"
-
-#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
-#include "FEComponentTransfer.h"
-
-namespace WebCore {
-
-FEComponentTransfer::FEComponentTransfer(FilterEffect* in, const ComponentTransferFunction& redFunc,
- const ComponentTransferFunction& greenFunc, const ComponentTransferFunction& blueFunc, const ComponentTransferFunction& alphaFunc)
- : FilterEffect()
- , m_in(in)
- , m_redFunc(redFunc)
- , m_greenFunc(greenFunc)
- , m_blueFunc(blueFunc)
- , m_alphaFunc(alphaFunc)
-{
-}
-
-PassRefPtr<FEComponentTransfer> FEComponentTransfer::create(FilterEffect* in, const ComponentTransferFunction& redFunc,
- const ComponentTransferFunction& greenFunc, const ComponentTransferFunction& blueFunc, const ComponentTransferFunction& alphaFunc)
-{
- return adoptRef(new FEComponentTransfer(in, redFunc, greenFunc, blueFunc, alphaFunc));
-}
-
-ComponentTransferFunction FEComponentTransfer::redFunction() const
-{
- return m_redFunc;
-}
-
-void FEComponentTransfer::setRedFunction(const ComponentTransferFunction& func)
-{
- m_redFunc = func;
-}
-
-ComponentTransferFunction FEComponentTransfer::greenFunction() const
-{
- return m_greenFunc;
-}
-
-void FEComponentTransfer::setGreenFunction(const ComponentTransferFunction& func)
-{
- m_greenFunc = func;
-}
-
-ComponentTransferFunction FEComponentTransfer::blueFunction() const
-{
- return m_blueFunc;
-}
-
-void FEComponentTransfer::setBlueFunction(const ComponentTransferFunction& func)
-{
- m_blueFunc = func;
-}
-
-ComponentTransferFunction FEComponentTransfer::alphaFunction() const
-{
- return m_alphaFunc;
-}
-
-void FEComponentTransfer::setAlphaFunction(const ComponentTransferFunction& func)
-{
- m_alphaFunc = func;
-}
-
-void FEComponentTransfer::apply()
-{
-}
-
-void FEComponentTransfer::dump()
-{
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/platform/graphics/filters/FEComponentTransfer.h b/WebCore/platform/graphics/filters/FEComponentTransfer.h
deleted file mode 100644
index 20d70c0..0000000
--- a/WebCore/platform/graphics/filters/FEComponentTransfer.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
- 2004, 2005 Rob Buis <buis@kde.org>
- 2005 Eric Seidel <eric@webkit.org>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- aint with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#ifndef SVGFEComponentTransfer_h
-#define SVGFEComponentTransfer_h
-
-#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
-#include "FilterEffect.h"
-#include "SVGFEDisplacementMap.h"
-
-#include <wtf/Vector.h>
-
-namespace WebCore {
-
- enum ComponentTransferType {
- FECOMPONENTTRANSFER_TYPE_UNKNOWN = 0,
- FECOMPONENTTRANSFER_TYPE_IDENTITY = 1,
- FECOMPONENTTRANSFER_TYPE_TABLE = 2,
- FECOMPONENTTRANSFER_TYPE_DISCRETE = 3,
- FECOMPONENTTRANSFER_TYPE_LINEAR = 4,
- FECOMPONENTTRANSFER_TYPE_GAMMA = 5
- };
-
- struct ComponentTransferFunction {
- ComponentTransferFunction()
- : type(FECOMPONENTTRANSFER_TYPE_UNKNOWN)
- , slope(0.0f)
- , intercept(0.0f)
- , amplitude(0.0f)
- , exponent(0.0f)
- , offset(0.0f)
- {
- }
-
- ComponentTransferType type;
-
- float slope;
- float intercept;
- float amplitude;
- float exponent;
- float offset;
-
- Vector<float> tableValues;
- };
-
- class FEComponentTransfer : public FilterEffect {
- public:
- static PassRefPtr<FEComponentTransfer> create(FilterEffect*, const ComponentTransferFunction&,
- const ComponentTransferFunction&, const ComponentTransferFunction&, const ComponentTransferFunction&);
-
- ComponentTransferFunction redFunction() const;
- void setRedFunction(const ComponentTransferFunction&);
-
- ComponentTransferFunction greenFunction() const;
- void setGreenFunction(const ComponentTransferFunction&);
-
- ComponentTransferFunction blueFunction() const;
- void setBlueFunction(const ComponentTransferFunction&);
-
- ComponentTransferFunction alphaFunction() const;
- void setAlphaFunction(const ComponentTransferFunction&);
-
- virtual void apply();
- virtual void dump();
-
- private:
- FEComponentTransfer(FilterEffect*,const ComponentTransferFunction&, const ComponentTransferFunction&,
- const ComponentTransferFunction&, const ComponentTransferFunction&);
-
- RefPtr<FilterEffect> m_in;
- ComponentTransferFunction m_redFunc;
- ComponentTransferFunction m_greenFunc;
- ComponentTransferFunction m_blueFunc;
- ComponentTransferFunction m_alphaFunc;
- };
-
-} // namespace WebCore
-
-#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
-
-#endif // SVGFEComponentTransfer_h
diff --git a/WebCore/platform/graphics/filters/FEComposite.cpp b/WebCore/platform/graphics/filters/FEComposite.cpp
deleted file mode 100644
index 0b5ce94..0000000
--- a/WebCore/platform/graphics/filters/FEComposite.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
- 2004, 2005 Rob Buis <buis@kde.org>
- 2005 Eric Seidel <eric@webkit.org>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- aint with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include "config.h"
-
-#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
-#include "FEComposite.h"
-
-namespace WebCore {
-
-FEComposite::FEComposite(FilterEffect* in, FilterEffect* in2, const CompositeOperationType& type,
- const float& k1, const float& k2, const float& k3, const float& k4)
- : FilterEffect()
- , m_in(in)
- , m_in2(in2)
- , m_type(type)
- , m_k1(k1)
- , m_k2(k2)
- , m_k3(k3)
- , m_k4(k4)
-{
-}
-
-PassRefPtr<FEComposite> FEComposite::create(FilterEffect* in, FilterEffect* in2, const CompositeOperationType& type,
- const float& k1, const float& k2, const float& k3, const float& k4)
-{
- return adoptRef(new FEComposite(in, in2, type, k1, k2, k3, k4));
-}
-
-CompositeOperationType FEComposite::operation() const
-{
- return m_type;
-}
-
-void FEComposite::setOperation(CompositeOperationType type)
-{
- m_type = type;
-}
-
-float FEComposite::k1() const
-{
- return m_k1;
-}
-
-void FEComposite::setK1(float k1)
-{
- m_k1 = k1;
-}
-
-float FEComposite::k2() const
-{
- return m_k2;
-}
-
-void FEComposite::setK2(float k2)
-{
- m_k2 = k2;
-}
-
-float FEComposite::k3() const
-{
- return m_k3;
-}
-
-void FEComposite::setK3(float k3)
-{
- m_k3 = k3;
-}
-
-float FEComposite::k4() const
-{
- return m_k4;
-}
-
-void FEComposite::setK4(float k4)
-{
- m_k4 = k4;
-}
-
-void FEComposite::apply()
-{
-}
-
-void FEComposite::dump()
-{
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/platform/graphics/filters/FEComposite.h b/WebCore/platform/graphics/filters/FEComposite.h
deleted file mode 100644
index d205395..0000000
--- a/WebCore/platform/graphics/filters/FEComposite.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
- 2004, 2005 Rob Buis <buis@kde.org>
- 2005 Eric Seidel <eric@webkit.org>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- aint with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#ifndef SVGFEComposite_h
-#define SVGFEComposite_h
-
-#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
-#include "FilterEffect.h"
-#include "PlatformString.h"
-
-namespace WebCore {
-
- enum CompositeOperationType {
- FECOMPOSITE_OPERATOR_UNKNOWN = 0,
- FECOMPOSITE_OPERATOR_OVER = 1,
- FECOMPOSITE_OPERATOR_IN = 2,
- FECOMPOSITE_OPERATOR_OUT = 3,
- FECOMPOSITE_OPERATOR_ATOP = 4,
- FECOMPOSITE_OPERATOR_XOR = 5,
- FECOMPOSITE_OPERATOR_ARITHMETIC = 6
- };
-
- class FEComposite : public FilterEffect {
- public:
- static PassRefPtr<FEComposite> create(FilterEffect*, FilterEffect*, const CompositeOperationType&,
- const float&, const float&, const float&, const float&);
-
- CompositeOperationType operation() const;
- void setOperation(CompositeOperationType);
-
- float k1() const;
- void setK1(float);
-
- float k2() const;
- void setK2(float);
-
- float k3() const;
- void setK3(float);
-
- float k4() const;
- void setK4(float);
-
- virtual void apply();
- virtual void dump();
-
- private:
- FEComposite(FilterEffect*, FilterEffect*, const CompositeOperationType&,
- const float&, const float&, const float&, const float&);
-
- RefPtr<FilterEffect> m_in;
- RefPtr<FilterEffect> m_in2;
- CompositeOperationType m_type;
- float m_k1;
- float m_k2;
- float m_k3;
- float m_k4;
- };
-
-} // namespace WebCore
-
-#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
-
-#endif // SVGFEComposite_h
diff --git a/WebCore/platform/graphics/gtk/ColorGtk.cpp b/WebCore/platform/graphics/gtk/ColorGtk.cpp
deleted file mode 100644
index 27f1b14..0000000
--- a/WebCore/platform/graphics/gtk/ColorGtk.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2007 Alp Toker <alp@atoker.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-#include "Color.h"
-
-#include <gdk/gdk.h>
-
-namespace WebCore {
-
-Color::Color(const GdkColor& c)
- : m_color(makeRGB(c.red >> 8, c.green >> 8, c.blue >> 8))
- , m_valid(true)
-{
-}
-
-}
-
-// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/graphics/gtk/FontCacheGtk.cpp b/WebCore/platform/graphics/gtk/FontCacheGtk.cpp
deleted file mode 100644
index d2b43cc..0000000
--- a/WebCore/platform/graphics/gtk/FontCacheGtk.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2008 Alp Toker <alp@atoker.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "FontCache.h"
-
-#include "Font.h"
-#include "SimpleFontData.h"
-#include <wtf/Assertions.h>
-
-namespace WebCore {
-
-void FontCache::platformInit()
-{
- if (!FontPlatformData::init())
- ASSERT_NOT_REACHED();
-}
-
-const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
-{
-#if defined(USE_FREETYPE)
- FcResult fresult;
- FontPlatformData* prim = const_cast<FontPlatformData*>(&font.primaryFont()->m_font);
-
- if (!prim->m_fallbacks)
- prim->m_fallbacks = FcFontSort(NULL, prim->m_pattern, FcTrue, NULL, &fresult);
-
- FcFontSet* fs = prim->m_fallbacks;
-
- for (int i = 0; i < fs->nfont; i++) {
- FcPattern* fin = FcFontRenderPrepare(NULL, prim->m_pattern, fs->fonts[i]);
- cairo_font_face_t* fontFace = cairo_ft_font_face_create_for_pattern(fin);
- FontPlatformData alternateFont(fontFace, font.fontDescription().computedPixelSize(), false, false);
- cairo_font_face_destroy(fontFace);
- alternateFont.m_pattern = fin;
- SimpleFontData* sfd = getCachedFontData(&alternateFont);
- if (sfd->containsCharacters(characters, length))
- return sfd;
- }
-#endif
-
- return 0;
-}
-
-FontPlatformData* FontCache::getSimilarFontPlatformData(const Font& font)
-{
- return 0;
-}
-
-FontPlatformData* FontCache::getLastResortFallbackFont(const FontDescription& fontDescription)
-{
- // FIXME: Would be even better to somehow get the user's default font here.
- // For now we'll pick the default that the user would get without changing any prefs.
- static AtomicString timesStr("Times New Roman");
- return getCachedFontPlatformData(fontDescription, timesStr);
-}
-
-void FontCache::getTraitsInFamily(const AtomicString& familyName, Vector<unsigned>& traitsMasks)
-{
-}
-
-FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
-{
- return new FontPlatformData(fontDescription, family);
-}
-
-}
diff --git a/WebCore/platform/graphics/gtk/FontCustomPlatformData.cpp b/WebCore/platform/graphics/gtk/FontCustomPlatformData.cpp
deleted file mode 100644
index bb2e064..0000000
--- a/WebCore/platform/graphics/gtk/FontCustomPlatformData.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2008 Alp Toker <alp@atoker.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "FontCustomPlatformData.h"
-
-#include "SharedBuffer.h"
-#include "FontPlatformData.h"
-
-namespace WebCore {
-
-FontCustomPlatformData::~FontCustomPlatformData()
-{
- cairo_font_face_destroy(m_fontFace);
-}
-
-FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontRenderingMode)
-{
- return FontPlatformData(m_fontFace, size, bold, italic);
-}
-
-static void releaseData(void* data)
-{
- static_cast<SharedBuffer*>(data)->deref();
-}
-
-FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer)
-{
- ASSERT_ARG(buffer, buffer);
-
- int error;
-
- static FT_Library library = 0;
- if (!library) {
- error = FT_Init_FreeType(&library);
- if (error) {
- library = 0;
- return 0;
- }
- }
-
- FT_Face face;
- error = FT_New_Memory_Face(library, reinterpret_cast<const FT_Byte*>(buffer->data()), buffer->size(), 0, &face);
- if (error)
- return 0;
-
- buffer->ref();
- cairo_font_face_t* fontFace = cairo_ft_font_face_create_for_ft_face(face, 0);
-
- static cairo_user_data_key_t bufferKey;
- cairo_font_face_set_user_data(fontFace, &bufferKey, buffer, releaseData);
-
- return new FontCustomPlatformData(fontFace);
-}
-
-}
diff --git a/WebCore/platform/graphics/gtk/FontCustomPlatformData.h b/WebCore/platform/graphics/gtk/FontCustomPlatformData.h
deleted file mode 100644
index b36cc79..0000000
--- a/WebCore/platform/graphics/gtk/FontCustomPlatformData.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2008 Alp Toker <alp@atoker.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef FontCustomPlatformData_h
-#define FontCustomPlatformData_h
-
-#include "FontRenderingMode.h"
-#include <wtf/Noncopyable.h>
-
-typedef struct _cairo_font_face cairo_font_face_t;
-
-namespace WebCore {
-
-class FontPlatformData;
-class SharedBuffer;
-
-struct FontCustomPlatformData : Noncopyable {
- FontCustomPlatformData(cairo_font_face_t* fontFace)
- : m_fontFace(fontFace)
- {}
-
- ~FontCustomPlatformData();
-
- FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontRenderingMode = NormalRenderingMode);
-
- cairo_font_face_t* m_fontFace;
-};
-
-FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer);
-
-}
-
-#endif
diff --git a/WebCore/platform/graphics/gtk/FontCustomPlatformDataPango.cpp b/WebCore/platform/graphics/gtk/FontCustomPlatformDataPango.cpp
deleted file mode 100644
index 4f2f2bb..0000000
--- a/WebCore/platform/graphics/gtk/FontCustomPlatformDataPango.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2008 Alp Toker <alp@atoker.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "FontCustomPlatformData.h"
-
-#include "SharedBuffer.h"
-#include "FontPlatformData.h"
-
-namespace WebCore {
-
-FontCustomPlatformData::~FontCustomPlatformData()
-{
-}
-
-FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontRenderingMode)
-{
- return FontPlatformData(m_fontFace, size, bold, italic);
-}
-
-static void releaseData(void* data)
-{
- static_cast<SharedBuffer*>(data)->deref();
-}
-
-FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer)
-{
- // FIXME: we need support in pango to read fonts from memory to implement this.y
- return 0;
-}
-
-}
diff --git a/WebCore/platform/graphics/gtk/FontGtk.cpp b/WebCore/platform/graphics/gtk/FontGtk.cpp
deleted file mode 100644
index 288ba91..0000000
--- a/WebCore/platform/graphics/gtk/FontGtk.cpp
+++ /dev/null
@@ -1,371 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
- * Copyright (c) 2007 Hiroyuki Ikezoe
- * Copyright (c) 2007 Kouhei Sutou
- * Copyright (C) 2007 Alp Toker <alp@atoker.com>
- * Copyright (C) 2008 Xan Lopez <xan@gnome.org>
- * Copyright (C) 2008 Nuanti Ltd.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Font.h"
-
-#include "GraphicsContext.h"
-#include "NotImplemented.h"
-#include "SimpleFontData.h"
-
-#include <cairo.h>
-#include <gdk/gdk.h>
-#include <pango/pango.h>
-#include <pango/pangocairo.h>
-#if defined(USE_FREETYPE)
-#include <pango/pangofc-fontmap.h>
-#endif
-
-#if !defined(PANGO_VERSION_CHECK)
-// PANGO_VERSION_CHECK() and pango_layout_get_line_readonly() appeared in 1.5.2
-#define pango_layout_get_line_readonly pango_layout_get_line
-#define PANGO_VERSION_CHECK(major,minor,micro) 0
-#endif
-
-namespace WebCore {
-
-#define IS_HIGH_SURROGATE(u) ((UChar)(u) >= (UChar)0xd800 && (UChar)(u) <= (UChar)0xdbff)
-#define IS_LOW_SURROGATE(u) ((UChar)(u) >= (UChar)0xdc00 && (UChar)(u) <= (UChar)0xdfff)
-
-static void utf16_to_utf8(const UChar* aText, gint aLength, char* &text, gint &length)
-{
- gboolean need_copy = FALSE;
- int i;
-
- for (i = 0; i < aLength; i++) {
- if (!aText[i] || IS_LOW_SURROGATE(aText[i])) {
- need_copy = TRUE;
- break;
- }
- else if (IS_HIGH_SURROGATE(aText[i])) {
- if (i < aLength - 1 && IS_LOW_SURROGATE(aText[i+1]))
- i++;
- else {
- need_copy = TRUE;
- break;
- }
- }
- }
-
- if (need_copy) {
-
- /* Pango doesn't correctly handle nuls. We convert them to 0xff. */
- /* Also "validate" UTF-16 text to make sure conversion doesn't fail. */
-
- UChar* p = (UChar*)g_memdup(aText, aLength * sizeof(aText[0]));
-
- /* don't need to reset i */
- for (i = 0; i < aLength; i++) {
- if (!p[i] || IS_LOW_SURROGATE(p[i]))
- p[i] = 0xFFFD;
- else if (IS_HIGH_SURROGATE(p[i])) {
- if (i < aLength - 1 && IS_LOW_SURROGATE(aText[i+1]))
- i++;
- else
- p[i] = 0xFFFD;
- }
- }
-
- aText = p;
- }
-
- glong items_written;
- text = g_utf16_to_utf8(reinterpret_cast<const gunichar2*>(aText), aLength, NULL, &items_written, NULL);
- length = items_written;
-
- if (need_copy)
- g_free((gpointer)aText);
-
-}
-
-static gchar* convertUniCharToUTF8(const UChar* characters, gint length, int from, int to)
-{
- gchar* utf8 = 0;
- gint new_length = 0;
- utf16_to_utf8(characters, length, utf8, new_length);
- if (!utf8)
- return NULL;
-
- if (from > 0) {
- // discard the first 'from' characters
- // FIXME: we should do this before the conversion probably
- gchar* str_left = g_utf8_offset_to_pointer(utf8, from);
- gchar* tmp = g_strdup(str_left);
- g_free(utf8);
- utf8 = tmp;
- }
-
- gchar* pos = utf8;
- gint len = strlen(pos);
- GString* ret = g_string_new_len(NULL, len);
-
- // replace line break by space
- while (len > 0) {
- gint index, start;
- pango_find_paragraph_boundary(pos, len, &index, &start);
- g_string_append_len(ret, pos, index);
- if (index == start)
- break;
- g_string_append_c(ret, ' ');
- pos += start;
- len -= start;
- }
- return g_string_free(ret, FALSE);
-}
-
-static void setPangoAttributes(const Font* font, const TextRun& run, PangoLayout* layout)
-{
-#if defined(USE_FREETYPE)
- if (font->primaryFont()->m_font.m_pattern) {
- PangoFontDescription* desc = pango_fc_font_description_from_pattern(font->primaryFont()->m_font.m_pattern, FALSE);
- pango_layout_set_font_description(layout, desc);
- pango_font_description_free(desc);
- }
-#elif defined(USE_PANGO)
- if (font->primaryFont()->m_font.m_font) {
- PangoFontDescription* desc = pango_font_describe(font->primaryFont()->m_font.m_font);
- pango_layout_set_font_description(layout, desc);
- pango_font_description_free(desc);
- }
-#endif
-
- pango_layout_set_auto_dir(layout, FALSE);
-
- PangoContext* pangoContext = pango_layout_get_context(layout);
- PangoDirection direction = run.rtl() ? PANGO_DIRECTION_RTL : PANGO_DIRECTION_LTR;
- pango_context_set_base_dir(pangoContext, direction);
- PangoAttrList* list = pango_attr_list_new();
- PangoAttribute* attr;
-
- attr = pango_attr_size_new_absolute(font->pixelSize() * PANGO_SCALE);
- attr->end_index = G_MAXUINT;
- pango_attr_list_insert_before(list, attr);
-
- if (!run.spacingDisabled()) {
- attr = pango_attr_letter_spacing_new(font->letterSpacing() * PANGO_SCALE);
- attr->end_index = G_MAXUINT;
- pango_attr_list_insert_before(list, attr);
- }
-
- // Pango does not yet support synthesising small caps
- // See http://bugs.webkit.org/show_bug.cgi?id=15610
-
- pango_layout_set_attributes(layout, list);
- pango_attr_list_unref(list);
-}
-
-void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const
-{
- cairo_t* cr = context->platformContext();
- cairo_save(cr);
- cairo_translate(cr, point.x(), point.y());
-
- PangoLayout* layout = pango_cairo_create_layout(cr);
- setPangoAttributes(this, run, layout);
-
- gchar* utf8 = convertUniCharToUTF8(run.characters(), run.length(), 0, run.length());
- pango_layout_set_text(layout, utf8, -1);
-
- // Our layouts are single line
- PangoLayoutLine* layoutLine = pango_layout_get_line_readonly(layout, 0);
-
- GdkRegion* partialRegion = NULL;
- if (to - from != run.length()) {
- // Clip the region of the run to be rendered
- char* start = g_utf8_offset_to_pointer(utf8, from);
- char* end = g_utf8_offset_to_pointer(start, to - from);
- int ranges[] = {start - utf8, end - utf8};
- partialRegion = gdk_pango_layout_line_get_clip_region(layoutLine, 0, 0, ranges, 1);
- gdk_region_shrink(partialRegion, 0, -pixelSize());
- }
-
- Color fillColor = context->fillColor();
- float red, green, blue, alpha;
-
- // Text shadow, inspired by FontMac
- IntSize shadowSize;
- int shadowBlur = 0;
- Color shadowColor;
- bool hasShadow = context->textDrawingMode() == cTextFill &&
- context->getShadow(shadowSize, shadowBlur, shadowColor);
-
- // TODO: Blur support
- if (hasShadow) {
- // Disable graphics context shadows (not yet implemented) and paint them manually
- context->clearShadow();
- Color shadowFillColor(shadowColor.red(), shadowColor.green(), shadowColor.blue(), shadowColor.alpha() * fillColor.alpha() / 255);
- cairo_save(cr);
-
- shadowFillColor.getRGBA(red, green, blue, alpha);
- cairo_set_source_rgba(cr, red, green, blue, alpha);
-
- cairo_translate(cr, shadowSize.width(), shadowSize.height());
-
- if (partialRegion) {
- gdk_cairo_region(cr, partialRegion);
- cairo_clip(cr);
- }
-
- pango_cairo_show_layout_line(cr, layoutLine);
-
- cairo_restore(cr);
- }
-
- fillColor.getRGBA(red, green, blue, alpha);
- cairo_set_source_rgba(cr, red, green, blue, alpha);
-
- if (partialRegion) {
- gdk_cairo_region(cr, partialRegion);
- cairo_clip(cr);
- }
-
- pango_cairo_show_layout_line(cr, layoutLine);
-
- if (context->textDrawingMode() & cTextStroke) {
- Color strokeColor = context->strokeColor();
- strokeColor.getRGBA(red, green, blue, alpha);
- cairo_set_source_rgba(cr, red, green, blue, alpha);
- pango_cairo_layout_line_path(cr, layoutLine);
- cairo_set_line_width(cr, context->strokeThickness());
- cairo_stroke(cr);
- }
-
- // Re-enable the platform shadow we disabled earlier
- if (hasShadow)
- context->setShadow(shadowSize, shadowBlur, shadowColor);
-
- // Pango sometimes leaves behind paths we don't want
- cairo_new_path(cr);
-
- if (partialRegion)
- gdk_region_destroy(partialRegion);
-
- g_free(utf8);
- g_object_unref(layout);
-
- cairo_restore(cr);
-}
-
-// We should create the layout with our actual context but we can't access it from here.
-static PangoLayout* getDefaultPangoLayout(const TextRun& run)
-{
- static PangoFontMap* map = pango_cairo_font_map_get_default();
-#if PANGO_VERSION_CHECK(1,21,5)
- static PangoContext* pangoContext = pango_font_map_create_context(map);
-#else
- // Deprecated in Pango 1.21.
- static PangoContext* pangoContext = pango_cairo_font_map_create_context(PANGO_CAIRO_FONT_MAP(map));
-#endif
- PangoLayout* layout = pango_layout_new(pangoContext);
-
- return layout;
-}
-
-float Font::floatWidthForComplexText(const TextRun& run) const
-{
- if (run.length() == 0)
- return 0.0f;
-
- PangoLayout* layout = getDefaultPangoLayout(run);
- setPangoAttributes(this, run, layout);
-
- gchar* utf8 = convertUniCharToUTF8(run.characters(), run.length(), 0, run.length());
- pango_layout_set_text(layout, utf8, -1);
-
- int width;
- pango_layout_get_pixel_size(layout, &width, 0);
-
- g_free(utf8);
- g_object_unref(layout);
-
- return width;
-}
-
-int Font::offsetForPositionForComplexText(const TextRun& run, int x, bool includePartialGlyphs) const
-{
- PangoLayout* layout = getDefaultPangoLayout(run);
- setPangoAttributes(this, run, layout);
-
- gchar* utf8 = convertUniCharToUTF8(run.characters(), run.length(), 0, run.length());
- pango_layout_set_text(layout, utf8, -1);
-
- int index, trailing;
- pango_layout_xy_to_index(layout, x * PANGO_SCALE, 1, &index, &trailing);
- glong offset = g_utf8_pointer_to_offset(utf8, utf8 + index);
- if (includePartialGlyphs)
- offset += trailing;
-
- g_free(utf8);
- g_object_unref(layout);
-
- return offset;
-}
-
-FloatRect Font::selectionRectForComplexText(const TextRun& run, const IntPoint& point, int h, int from, int to) const
-{
- PangoLayout* layout = getDefaultPangoLayout(run);
- setPangoAttributes(this, run, layout);
-
- gchar* utf8 = convertUniCharToUTF8(run.characters(), run.length(), 0, run.length());
- pango_layout_set_text(layout, utf8, -1);
-
- char* start = g_utf8_offset_to_pointer(utf8, from);
- char* end = g_utf8_offset_to_pointer(start, to - from);
-
- if (run.ltr()) {
- from = start - utf8;
- to = end - utf8;
- } else {
- from = end - utf8;
- to = start - utf8;
- }
-
- PangoLayoutLine* layoutLine = pango_layout_get_line_readonly(layout, 0);
- int x_pos;
-
- x_pos = 0;
- if (from < layoutLine->length)
- pango_layout_line_index_to_x(layoutLine, from, FALSE, &x_pos);
- float beforeWidth = PANGO_PIXELS_FLOOR(x_pos);
-
- x_pos = 0;
- if (run.ltr() || to < layoutLine->length)
- pango_layout_line_index_to_x(layoutLine, to, FALSE, &x_pos);
- float afterWidth = PANGO_PIXELS(x_pos);
-
- g_free(utf8);
- g_object_unref(layout);
-
- return FloatRect(point.x() + beforeWidth, point.y(), afterWidth - beforeWidth, h);
-}
-
-}
diff --git a/WebCore/platform/graphics/gtk/FontPlatformData.h b/WebCore/platform/graphics/gtk/FontPlatformData.h
deleted file mode 100644
index efa5dd5..0000000
--- a/WebCore/platform/graphics/gtk/FontPlatformData.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * This file is part of the internal font implementation. It should not be included by anyone other than
- * FontMac.cpp, FontWin.cpp and Font.cpp.
- *
- * Copyright (C) 2006 Apple Computer, Inc.
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
- * Copyright (C) 2007 Holger Hans Peter Freyther
- * Copyright (C) 2007 Pioneer Research Center USA, Inc.
- * All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef FontPlatformData_h
-#define FontPlatformData_h
-
-#include "GlyphBuffer.h"
-#include "FontDescription.h"
-#include <cairo.h>
-#if defined(USE_FREETYPE)
-#include <cairo-ft.h>
-#include <fontconfig/fcfreetype.h>
-#elif defined(USE_PANGO)
-#include <pango/pangocairo.h>
-#else
-#error "Must defined a font backend"
-#endif
-
-namespace WebCore {
-
-class FontPlatformData {
-public:
- FontPlatformData(WTF::HashTableDeletedValueType)
-#if defined(USE_FREETYPE)
- : m_pattern(hashTableDeletedFontValue())
- , m_fallbacks(0)
-#elif defined(USE_PANGO)
- : m_context(0)
- , m_font(hashTableDeletedFontValue())
-#else
-#error "Must defined a font backend"
-#endif
- , m_scaledFont(0)
- { }
-
- FontPlatformData()
-#if defined(USE_FREETYPE)
- : m_pattern(0)
- , m_fallbacks(0)
-#elif defined(USE_PANGO)
- : m_context(0)
- , m_font(0)
-#else
-#error "Must defined a font backend"
-#endif
- , m_scaledFont(0)
- { }
-
- FontPlatformData(const FontDescription&, const AtomicString& family);
-
- FontPlatformData(float size, bool bold, bool italic);
- FontPlatformData(cairo_font_face_t* fontFace, int size, bool bold, bool italic);
-
- ~FontPlatformData();
-
- static bool init();
-
- bool isFixedPitch();
- float size() const { return m_size; }
-
- void setFont(cairo_t*) const;
-
- unsigned hash() const
- {
-#if defined(USE_FREETYPE)
- if (m_pattern)
- return FcPatternHash(m_pattern);
-#endif
- uintptr_t hashCodes[1] = { reinterpret_cast<uintptr_t>(m_scaledFont) };
- return StringImpl::computeHash(reinterpret_cast<UChar*>(hashCodes), sizeof(hashCodes) / sizeof(UChar));
- }
-
- bool operator==(const FontPlatformData&) const;
- bool isHashTableDeletedValue() const {
-#if defined(USE_FREETYPE)
- return m_pattern == hashTableDeletedFontValue();
-#elif defined(USE_PANGO)
- return m_font == hashTableDeletedFontValue();
-#endif
- };
-
-#if defined(USE_FREETYPE)
- FcPattern* m_pattern;
- FcFontSet* m_fallbacks;
-#elif defined(USE_PANGO)
- static PangoFontMap* m_fontMap;
- static GHashTable* m_hashTable;
-
- PangoContext* m_context;
- PangoFont* m_font;
-#else
-#error "Must defined a font backend"
-#endif
- float m_size;
- bool m_syntheticBold;
- bool m_syntheticOblique;
- cairo_scaled_font_t* m_scaledFont;
-private:
-#if defined(USE_FREETYPE)
- static FcPattern *hashTableDeletedFontValue() { return reinterpret_cast<FcPattern*>(-1); }
-#elif defined(USE_PANGO)
- static PangoFont *hashTableDeletedFontValue() { return reinterpret_cast<PangoFont*>(-1); }
-#endif
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/graphics/gtk/FontPlatformDataGtk.cpp b/WebCore/platform/graphics/gtk/FontPlatformDataGtk.cpp
deleted file mode 100644
index 17d789b..0000000
--- a/WebCore/platform/graphics/gtk/FontPlatformDataGtk.cpp
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc.
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
- * Copyright (C) 2007, 2008 Alp Toker <alp@atoker.com>
- * Copyright (C) 2007 Holger Hans Peter Freyther
- * All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-#include "FontPlatformData.h"
-
-#include "CString.h"
-#include "PlatformString.h"
-#include "FontDescription.h"
-
-#include <cairo-ft.h>
-#include <cairo.h>
-#include <fontconfig/fcfreetype.h>
-#include <gtk/gtk.h>
-
-namespace WebCore {
-
-FontPlatformData::FontPlatformData(const FontDescription& fontDescription, const AtomicString& familyName)
- : m_pattern(0)
- , m_fallbacks(0)
- , m_size(fontDescription.computedPixelSize())
- , m_syntheticBold(false)
- , m_syntheticOblique(false)
- , m_scaledFont(0)
-{
- FontPlatformData::init();
-
- CString familyNameString = familyName.string().utf8();
- const char* fcfamily = familyNameString.data();
- int fcslant = FC_SLANT_ROMAN;
- // FIXME: Map all FontWeight values to fontconfig weights.
- int fcweight = FC_WEIGHT_NORMAL;
- double fcsize = fontDescription.computedPixelSize();
- if (fontDescription.italic())
- fcslant = FC_SLANT_ITALIC;
- if (fontDescription.weight() >= FontWeight600)
- fcweight = FC_WEIGHT_BOLD;
-
- int type = fontDescription.genericFamily();
-
- FcPattern* pattern = FcPatternCreate();
- cairo_font_face_t* fontFace;
- static const cairo_font_options_t* defaultOptions = cairo_font_options_create();
- const cairo_font_options_t* options = NULL;
- cairo_matrix_t fontMatrix;
-
- if (!FcPatternAddString(pattern, FC_FAMILY, reinterpret_cast<const FcChar8*>(fcfamily)))
- goto freePattern;
-
- switch (type) {
- case FontDescription::SerifFamily:
- fcfamily = "serif";
- break;
- case FontDescription::SansSerifFamily:
- fcfamily = "sans-serif";
- break;
- case FontDescription::MonospaceFamily:
- fcfamily = "monospace";
- break;
- case FontDescription::StandardFamily:
- fcfamily = "sans-serif";
- break;
- case FontDescription::NoFamily:
- default:
- fcfamily = NULL;
- break;
- }
-
- if (fcfamily && !FcPatternAddString(pattern, FC_FAMILY, reinterpret_cast<const FcChar8*>(fcfamily)))
- goto freePattern;
- if (!FcPatternAddInteger(pattern, FC_WEIGHT, fcweight))
- goto freePattern;
- if (!FcPatternAddInteger(pattern, FC_SLANT, fcslant))
- goto freePattern;
- if (!FcPatternAddDouble(pattern, FC_PIXEL_SIZE, fcsize))
- goto freePattern;
-
- FcConfigSubstitute(NULL, pattern, FcMatchPattern);
- FcDefaultSubstitute(pattern);
-
- FcResult fcresult;
- m_pattern = FcFontMatch(NULL, pattern, &fcresult);
- // FIXME: should we set some default font?
- if (!m_pattern)
- goto freePattern;
- fontFace = cairo_ft_font_face_create_for_pattern(m_pattern);
- cairo_matrix_t ctm;
- cairo_matrix_init_scale(&fontMatrix, fontDescription.computedPixelSize(), fontDescription.computedPixelSize());
- cairo_matrix_init_identity(&ctm);
-
-#if GTK_CHECK_VERSION(2,10,0)
- if (GdkScreen* screen = gdk_screen_get_default())
- options = gdk_screen_get_font_options(screen);
-#endif
- // gdk_screen_get_font_options() returns NULL if no default options are
- // set, so we always have to check.
- if (!options)
- options = defaultOptions;
-
- m_scaledFont = cairo_scaled_font_create(fontFace, &fontMatrix, &ctm, options);
- cairo_font_face_destroy(fontFace);
-
-freePattern:
- FcPatternDestroy(pattern);
-}
-
-FontPlatformData::FontPlatformData(float size, bool bold, bool italic)
- : m_pattern(0)
- , m_fallbacks(0)
- , m_size(size)
- , m_syntheticBold(bold)
- , m_syntheticOblique(italic)
- , m_scaledFont(0)
-{
-}
-
-FontPlatformData::FontPlatformData(cairo_font_face_t* fontFace, int size, bool bold, bool italic)
- : m_pattern(0)
- , m_fallbacks(0)
- , m_size(size)
- , m_syntheticBold(bold)
- , m_syntheticOblique(italic)
- , m_scaledFont(0)
-{
- cairo_matrix_t fontMatrix;
- cairo_matrix_init_scale(&fontMatrix, size, size);
- cairo_matrix_t ctm;
- cairo_matrix_init_identity(&ctm);
- static const cairo_font_options_t* defaultOptions = cairo_font_options_create();
- const cairo_font_options_t* options = NULL;
-
-#if GTK_CHECK_VERSION(2,10,0)
- if (GdkScreen* screen = gdk_screen_get_default())
- options = gdk_screen_get_font_options(screen);
-#endif
- // gdk_screen_get_font_options() returns NULL if no default options are
- // set, so we always have to check.
- if (!options)
- options = defaultOptions;
-
- m_scaledFont = cairo_scaled_font_create(fontFace, &fontMatrix, &ctm, options);
-}
-
-bool FontPlatformData::init()
-{
- static bool initialized = false;
- if (initialized)
- return true;
- if (!FcInit()) {
- fprintf(stderr, "Can't init font config library\n");
- return false;
- }
- initialized = true;
- return true;
-}
-
-FontPlatformData::~FontPlatformData()
-{
-}
-
-bool FontPlatformData::isFixedPitch()
-{
- // TODO: Support isFixedPitch() for custom fonts.
- if (!m_pattern)
- return false;
-
- int spacing;
- if (FcPatternGetInteger(m_pattern, FC_SPACING, 0, &spacing) == FcResultMatch)
- return spacing == FC_MONO;
- return false;
-}
-
-void FontPlatformData::setFont(cairo_t* cr) const
-{
- ASSERT(m_scaledFont);
-
- cairo_set_scaled_font(cr, m_scaledFont);
-}
-
-bool FontPlatformData::operator==(const FontPlatformData& other) const
-{
- if (m_pattern == other.m_pattern)
- return true;
- if (m_pattern == 0 || m_pattern == reinterpret_cast<FcPattern*>(-1)
- || other.m_pattern == 0 || other.m_pattern == reinterpret_cast<FcPattern*>(-1))
- return false;
- return FcPatternEqual(m_pattern, other.m_pattern);
-}
-
-}
diff --git a/WebCore/platform/graphics/gtk/FontPlatformDataPango.cpp b/WebCore/platform/graphics/gtk/FontPlatformDataPango.cpp
deleted file mode 100644
index be3fd43..0000000
--- a/WebCore/platform/graphics/gtk/FontPlatformDataPango.cpp
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc.
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
- * Copyright (C) 2007, 2008 Alp Toker <alp@atoker.com>
- * Copyright (C) 2007 Holger Hans Peter Freyther
- * Copyright (C) 2007 Pioneer Research Center USA, Inc.
- * All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-#include "config.h"
-#include "FontPlatformData.h"
-
-#include "CString.h"
-#include "PlatformString.h"
-#include "FontDescription.h"
-#include <cairo.h>
-#include <assert.h>
-
-#include <pango/pango.h>
-#include <pango/pangocairo.h>
-
-#if !defined(PANGO_VERSION_CHECK)
-#define PANGO_VERSION_CHECK(major,minor,micro) 0
-#endif
-
-// Use cairo-ft i a recent enough Pango version isn't available
-#if !PANGO_VERSION_CHECK(1,18,0)
-#include <cairo-ft.h>
-#include <pango/pangofc-fontmap.h>
-#endif
-#include <gtk/gtk.h>
-
-namespace WebCore {
-
- PangoFontMap* FontPlatformData::m_fontMap = 0;
- GHashTable* FontPlatformData::m_hashTable = 0;
-
-FontPlatformData::FontPlatformData(const FontDescription& fontDescription, const AtomicString& familyName)
- : m_context(0)
- , m_font(0)
- , m_size(fontDescription.computedSize())
- , m_syntheticBold(false)
- , m_syntheticOblique(false)
- , m_scaledFont(0)
-{
- FontPlatformData::init();
-
- CString stored_family = familyName.string().utf8();
- char const* families[] = {
- stored_family.data(),
- NULL
- };
-
- switch (fontDescription.genericFamily()) {
- case FontDescription::SerifFamily:
- families[1] = "serif";
- break;
- case FontDescription::SansSerifFamily:
- families[1] = "sans";
- break;
- case FontDescription::MonospaceFamily:
- families[1] = "monospace";
- break;
- case FontDescription::NoFamily:
- case FontDescription::StandardFamily:
- default:
- families[1] = "sans";
- break;
- }
-
- PangoFontDescription* description = pango_font_description_new();
- pango_font_description_set_absolute_size(description, fontDescription.computedSize() * PANGO_SCALE);
-
- // FIXME: Map all FontWeight values to Pango font weights.
- if (fontDescription.weight() >= FontWeight600)
- pango_font_description_set_weight(description, PANGO_WEIGHT_BOLD);
- if (fontDescription.italic())
- pango_font_description_set_style(description, PANGO_STYLE_ITALIC);
-
-#if PANGO_VERSION_CHECK(1,21,5) // deprecated in 1.21
- m_context = pango_font_map_create_context(m_fontMap);
-#else
- m_context = pango_cairo_font_map_create_context(PANGO_CAIRO_FONT_MAP(m_fontMap));
-#endif
- for (unsigned int i = 0; !m_font && i < G_N_ELEMENTS(families); i++) {
- pango_font_description_set_family(description, families[i]);
- pango_context_set_font_description(m_context, description);
- m_font = pango_font_map_load_font(m_fontMap, m_context, description);
- }
-
-#if PANGO_VERSION_CHECK(1,18,0)
- if (m_font)
- m_scaledFont = cairo_scaled_font_reference(pango_cairo_font_get_scaled_font(PANGO_CAIRO_FONT(m_font)));
-#else
- // This compatibility code for older versions of Pango is not well-tested.
- if (m_font) {
- PangoFcFont* fcfont = PANGO_FC_FONT(m_font);
- cairo_font_face_t* face = cairo_ft_font_face_create_for_pattern(fcfont->font_pattern);
- double size;
- if (FcPatternGetDouble(fcfont->font_pattern, FC_PIXEL_SIZE, 0, &size) != FcResultMatch)
- size = 12.0;
- cairo_matrix_t fontMatrix;
- cairo_matrix_init_scale(&fontMatrix, size, size);
- cairo_font_options_t* fontOptions;
- if (pango_cairo_context_get_font_options(m_context))
- fontOptions = cairo_font_options_copy(pango_cairo_context_get_font_options(m_context));
- else
- fontOptions = cairo_font_options_create();
- cairo_matrix_t ctm;
- cairo_matrix_init_identity(&ctm);
- m_scaledFont = cairo_scaled_font_create(face, &fontMatrix, &ctm, fontOptions);
- cairo_font_options_destroy(fontOptions);
- cairo_font_face_destroy(face);
- }
-#endif
- pango_font_description_free(description);
-}
-
-FontPlatformData::FontPlatformData(float size, bool bold, bool italic)
- : m_context(0)
- , m_font(0)
- , m_size(size)
- , m_syntheticBold(bold)
- , m_syntheticOblique(italic)
- , m_scaledFont(0)
-{
-}
-
-FontPlatformData::FontPlatformData(cairo_font_face_t* fontFace, int size, bool bold, bool italic)
- : m_context(0)
- , m_font(0)
- , m_size(size)
- , m_syntheticBold(bold)
- , m_syntheticOblique(italic)
- , m_scaledFont(0)
-{
- cairo_matrix_t fontMatrix;
- cairo_matrix_init_scale(&fontMatrix, size, size);
- cairo_matrix_t ctm;
- cairo_matrix_init_identity(&ctm);
- cairo_font_options_t* options = cairo_font_options_create();
-
- // We force antialiasing and disable hinting to provide consistent
- // typographic qualities for custom fonts on all platforms.
- cairo_font_options_set_hint_style(options, CAIRO_HINT_STYLE_NONE);
- cairo_font_options_set_antialias(options, CAIRO_ANTIALIAS_GRAY);
-
- m_scaledFont = cairo_scaled_font_create(fontFace, &fontMatrix, &ctm, options);
- cairo_font_options_destroy(options);
-}
-
-bool FontPlatformData::init()
-{
- static bool initialized = false;
- if (initialized)
- return true;
- initialized = true;
-
- if (!m_fontMap)
- m_fontMap = pango_cairo_font_map_get_default();
- if (!m_hashTable) {
- PangoFontFamily** families = 0;
- int n_families = 0;
-
- m_hashTable = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_object_unref);
-
- pango_font_map_list_families(m_fontMap, &families, &n_families);
-
- for (int family = 0; family < n_families; family++)
- g_hash_table_insert(m_hashTable,
- g_strdup(pango_font_family_get_name(families[family])),
- g_object_ref(families[family]));
-
- g_free(families);
- }
-
- return true;
-}
-
-FontPlatformData::~FontPlatformData()
-{
- // Destroy takes place in FontData::platformDestroy().
-}
-
-bool FontPlatformData::isFixedPitch()
-{
- PangoFontDescription* description = pango_font_describe_with_absolute_size(m_font);
- PangoFontFamily* family = reinterpret_cast<PangoFontFamily*>(g_hash_table_lookup(m_hashTable, pango_font_description_get_family(description)));
- pango_font_description_free(description);
- return pango_font_family_is_monospace(family);
-}
-
-void FontPlatformData::setFont(cairo_t* cr) const
-{
- ASSERT(m_scaledFont);
-
- cairo_set_scaled_font(cr, m_scaledFont);
-}
-
-bool FontPlatformData::operator==(const FontPlatformData& other) const
-{
- if (m_font == other.m_font)
- return true;
- if (m_font == 0 || m_font == reinterpret_cast<PangoFont*>(-1)
- || other.m_font == 0 || other.m_font == reinterpret_cast<PangoFont*>(-1))
- return false;
- PangoFontDescription* thisDesc = pango_font_describe(m_font);
- PangoFontDescription* otherDesc = pango_font_describe(other.m_font);
- bool result = pango_font_description_equal(thisDesc, otherDesc);
- pango_font_description_free(otherDesc);
- pango_font_description_free(thisDesc);
- return result;
-}
-
-}
diff --git a/WebCore/platform/graphics/gtk/GlyphPageTreeNodeGtk.cpp b/WebCore/platform/graphics/gtk/GlyphPageTreeNodeGtk.cpp
deleted file mode 100644
index 24ad864..0000000
--- a/WebCore/platform/graphics/gtk/GlyphPageTreeNodeGtk.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
- * Copyright (C) 2007 Alp Toker <alp.toker@collabora.co.uk>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "GlyphPageTreeNode.h"
-
-#include "SimpleFontData.h"
-
-namespace WebCore {
-
-bool GlyphPage::fill(unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength, const SimpleFontData* fontData)
-{
- // The bufferLength will be greater than the glyph page size if the buffer has Unicode supplementary characters.
- // We won't support this for now.
- if (bufferLength > GlyphPage::size)
- return false;
-
- FT_Face face = cairo_ft_scaled_font_lock_face(fontData->m_font.m_scaledFont);
- if (!face)
- return false;
-
- bool haveGlyphs = false;
- for (unsigned i = 0; i < length; i++) {
- Glyph glyph = FcFreeTypeCharIndex(face, buffer[i]);
- if (!glyph)
- setGlyphDataForIndex(offset + i, 0, 0);
- else {
- setGlyphDataForIndex(offset + i, glyph, fontData);
- haveGlyphs = true;
- }
- }
-
- cairo_ft_scaled_font_unlock_face(fontData->m_font.m_scaledFont);
-
- return haveGlyphs;
-}
-
-}
diff --git a/WebCore/platform/graphics/gtk/GlyphPageTreeNodePango.cpp b/WebCore/platform/graphics/gtk/GlyphPageTreeNodePango.cpp
deleted file mode 100644
index 8fada5c..0000000
--- a/WebCore/platform/graphics/gtk/GlyphPageTreeNodePango.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
- * Copyright (C) 2007 Alp Toker <alp.toker@collabora.co.uk>
- * Copyright (C) 2007 Pioneer Research Center USA, Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "GlyphPageTreeNode.h"
-
-#include "SimpleFontData.h"
-#include <pango/pango-font.h>
-
-namespace WebCore {
-
-static PangoGlyph pango_font_get_glyph(PangoFont* font, PangoContext* context, gunichar wc)
-{
- PangoGlyph result = 0;
- gchar buffer[7];
-
- gint length = g_unichar_to_utf8(wc, buffer);
- g_return_val_if_fail(length, 0);
-
- GList* items = pango_itemize(context, buffer, 0, length, NULL, NULL);
-
- if (g_list_length(items) == 1) {
- PangoItem* item = reinterpret_cast<PangoItem*>(items->data);
- PangoFont* tmpFont = item->analysis.font;
- item->analysis.font = font;
-
- PangoGlyphString* glyphs = pango_glyph_string_new();
- pango_shape(buffer, length, &item->analysis, glyphs);
-
- item->analysis.font = tmpFont;
-
- if (glyphs->num_glyphs == 1)
- result = glyphs->glyphs[0].glyph;
- else
- g_warning("didn't get 1 glyph but %d", glyphs->num_glyphs);
-
- pango_glyph_string_free(glyphs);
- }
-
- g_list_foreach(items, (GFunc)pango_item_free, NULL);
- g_list_free(items);
-
- return result;
-}
-
-bool GlyphPage::fill(unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength, const SimpleFontData* fontData)
-{
- // The bufferLength will be greater than the glyph page size if the buffer has Unicode supplementary characters.
- // We won't support this for now.
- if (bufferLength > GlyphPage::size)
- return false;
-
- if (!fontData->m_font.m_font || fontData->m_font.m_font == reinterpret_cast<PangoFont*>(-1))
- return false;
-
- bool haveGlyphs = false;
- for (unsigned i = 0; i < length; i++) {
- Glyph glyph = pango_font_get_glyph(fontData->m_font.m_font, fontData->m_font.m_context, buffer[i]);
- if (!glyph)
- setGlyphDataForIndex(offset + i, 0, 0);
- else {
- setGlyphDataForIndex(offset + i, glyph, fontData);
- haveGlyphs = true;
- }
- }
-
- return haveGlyphs;
-}
-
-}
diff --git a/WebCore/platform/graphics/gtk/IconGtk.cpp b/WebCore/platform/graphics/gtk/IconGtk.cpp
deleted file mode 100644
index d8b38a0..0000000
--- a/WebCore/platform/graphics/gtk/IconGtk.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2007 Holger Hans Peter Freyther
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Icon.h"
-
-#include "CString.h"
-#include "GraphicsContext.h"
-#include "MIMETypeRegistry.h"
-#include "NotImplemented.h"
-#include "PassRefPtr.h"
-
-#include <gtk/gtk.h>
-
-namespace WebCore {
-
-Icon::Icon()
- : m_icon(0)
-{
-}
-
-Icon::~Icon()
-{
- if (m_icon)
- g_object_unref(m_icon);
-}
-
-static String lookupIconName(String MIMEType)
-{
- /*
- Lookup an appropriate icon according to either the Icon Naming Spec
- or conventional Gnome icon names respectively.
-
- See http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html
-
- The icon theme is probed for the following names:
- 1. media-subtype
- 2. gnome-mime-media-subtype
- 3. media-x-generic
- 4. gnome-mime-media
-
- In the worst case it falls back to the stock file icon.
- */
- int pos = MIMEType.find('/');
- if(pos >= 0) {
- String media = MIMEType.substring(0, pos);
- String subtype = MIMEType.substring(pos + 1);
- GtkIconTheme* iconTheme = gtk_icon_theme_get_default();
- String iconName = media + "-" + subtype;
- if(gtk_icon_theme_has_icon(iconTheme, iconName.utf8().data()))
- return iconName;
- iconName = "gnome-mime-" + media + "-" + subtype;
- if(gtk_icon_theme_has_icon(iconTheme, iconName.utf8().data()))
- return iconName;
- iconName = media + "-x-generic";
- if(gtk_icon_theme_has_icon(iconTheme, iconName.utf8().data()))
- return iconName;
- iconName = media + "gnome-mime-" + media;
- if(gtk_icon_theme_has_icon(iconTheme, iconName.utf8().data()))
- return iconName;
- }
- return GTK_STOCK_FILE;
-}
-
-PassRefPtr<Icon> Icon::createIconForFile(const String& filename)
-{
- if (!g_path_skip_root(filename.utf8().data()))
- return 0;
-
- String MIMEType = MIMETypeRegistry::getMIMETypeForPath(filename);
- String iconName = lookupIconName(MIMEType);
-
- RefPtr<Icon> icon = adoptRef(new Icon);
- icon->m_icon = gtk_icon_theme_load_icon(gtk_icon_theme_get_default(), iconName.utf8().data(), 16, GTK_ICON_LOOKUP_USE_BUILTIN, NULL);
- if (!icon->m_icon)
- return 0;
- return icon.release();
-}
-
-PassRefPtr<Icon> Icon::createIconForFiles(const Vector<String>& filenames)
-{
- //FIXME: Implement this
- return 0;
-}
-
-void Icon::paint(GraphicsContext* context, const IntRect& rect)
-{
- if (context->paintingDisabled())
- return;
-
- // TODO: Scale/clip the image if necessary.
- cairo_t* cr = context->platformContext();
- cairo_save(cr);
- gdk_cairo_set_source_pixbuf(cr, m_icon, rect.x(), rect.y());
- cairo_paint(cr);
- cairo_restore(cr);
-}
-
-}
diff --git a/WebCore/platform/graphics/gtk/ImageGtk.cpp b/WebCore/platform/graphics/gtk/ImageGtk.cpp
deleted file mode 100644
index b745209..0000000
--- a/WebCore/platform/graphics/gtk/ImageGtk.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "BitmapImage.h"
-
-// This function loads resources from WebKit
-Vector<char> loadResourceIntoArray(const char*);
-
-namespace WebCore {
-
-void BitmapImage::initPlatformData()
-{
-}
-
-void BitmapImage::invalidatePlatformData()
-{
-}
-
-PassRefPtr<Image> Image::loadPlatformResource(const char *name)
-{
- Vector<char> arr = loadResourceIntoArray(name);
- RefPtr<BitmapImage> img = BitmapImage::create();
- RefPtr<SharedBuffer> buffer = SharedBuffer::create(arr.data(), arr.size());
- img->setData(buffer, true);
- return img.release();
-}
-
-}
diff --git a/WebCore/platform/graphics/gtk/IntPointGtk.cpp b/WebCore/platform/graphics/gtk/IntPointGtk.cpp
deleted file mode 100644
index c402158..0000000
--- a/WebCore/platform/graphics/gtk/IntPointGtk.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2007 Alp Toker <alp@atoker.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-#include "IntPoint.h"
-
-#include <gdk/gdk.h>
-
-namespace WebCore {
-
-IntPoint::IntPoint(const GdkPoint& p)
- : m_x(p.x)
- , m_y(p.y)
-{
-}
-
-IntPoint::operator GdkPoint() const
-{
- GdkPoint p = { x(), y() };
- return p;
-}
-
-}
-
-// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/graphics/gtk/IntRectGtk.cpp b/WebCore/platform/graphics/gtk/IntRectGtk.cpp
deleted file mode 100644
index aaa1944..0000000
--- a/WebCore/platform/graphics/gtk/IntRectGtk.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2007 Alp Toker <alp@atoker.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-#include "IntRect.h"
-
-#include <gdk/gdk.h>
-
-namespace WebCore {
-
-IntRect::IntRect(const GdkRectangle& r)
- : m_location(IntPoint(r.x, r.y))
- , m_size(r.width, r.height)
-{
-}
-
-IntRect::operator GdkRectangle() const
-{
- GdkRectangle r = { x(), y(), width(), height() };
- return r;
-}
-
-}
-
-// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp b/WebCore/platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp
deleted file mode 100644
index 1f0cac6..0000000
--- a/WebCore/platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp
+++ /dev/null
@@ -1,622 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2007 Collabora Ltd. All rights reserved.
- * Copyright (C) 2007 Alp Toker <alp@atoker.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * aint with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-
-#if ENABLE(VIDEO)
-
-#include "MediaPlayerPrivateGStreamer.h"
-#include "VideoSinkGStreamer.h"
-
-#include "CString.h"
-#include "GraphicsContext.h"
-#include "IntRect.h"
-#include "KURL.h"
-#include "MIMETypeRegistry.h"
-#include "MediaPlayer.h"
-#include "NotImplemented.h"
-#include "ScrollView.h"
-#include "Widget.h"
-#include <wtf/GOwnPtr.h>
-
-#include <gdk/gdkx.h>
-#include <gst/base/gstbasesrc.h>
-#include <gst/gst.h>
-#include <gst/interfaces/mixer.h>
-#include <gst/interfaces/xoverlay.h>
-#include <gst/video/video.h>
-#include <limits>
-#include <math.h>
-
-using namespace std;
-
-namespace WebCore {
-
-gboolean mediaPlayerPrivateErrorCallback(GstBus* bus, GstMessage* message, gpointer data)
-{
- if (GST_MESSAGE_TYPE(message) == GST_MESSAGE_ERROR)
- {
- GOwnPtr<GError> err;
- GOwnPtr<gchar> debug;
-
- gst_message_parse_error(message, &err.outPtr(), &debug.outPtr());
- if (err->code == 3) {
- LOG_VERBOSE(Media, "File not found");
- MediaPlayerPrivate* mp = reinterpret_cast<MediaPlayerPrivate*>(data);
- if (mp)
- mp->loadingFailed();
- } else
- LOG_VERBOSE(Media, "Error: %d, %s", err->code, err->message);
- }
- return true;
-}
-
-gboolean mediaPlayerPrivateEOSCallback(GstBus* bus, GstMessage* message, gpointer data)
-{
- if (GST_MESSAGE_TYPE(message) == GST_MESSAGE_EOS)
- {
- LOG_VERBOSE(Media, "End of Stream");
- MediaPlayerPrivate* mp = reinterpret_cast<MediaPlayerPrivate*>(data);
- mp->didEnd();
- }
- return true;
-}
-
-gboolean mediaPlayerPrivateStateCallback(GstBus* bus, GstMessage* message, gpointer data)
-{
- if (GST_MESSAGE_TYPE(message) == GST_MESSAGE_STATE_CHANGED)
- {
- MediaPlayerPrivate* mp = reinterpret_cast<MediaPlayerPrivate*>(data);
- mp->updateStates();
- }
- return true;
-}
-
-gboolean mediaPlayerPrivateBufferingCallback(GstBus* bus, GstMessage* message, gpointer data)
-{
- if (GST_MESSAGE_TYPE(message) == GST_MESSAGE_BUFFERING)
- {
- gint percent = 0;
- gst_message_parse_buffering(message, &percent);
- LOG_VERBOSE(Media, "Buffering %d", percent);
- }
- return true;
-}
-
-MediaPlayerPrivate::MediaPlayerPrivate(MediaPlayer* player)
- : m_player(player)
- , m_playBin(0)
- , m_videoSink(0)
- , m_source(0)
- , m_rate(1.0f)
- , m_endTime(numeric_limits<float>::infinity())
- , m_isEndReached(false)
- , m_volume(0.5f)
- , m_networkState(MediaPlayer::Empty)
- , m_readyState(MediaPlayer::DataUnavailable)
- , m_startedPlaying(false)
- , m_isStreaming(false)
- , m_rect(IntRect())
- , m_visible(true)
-{
-
- static bool gstInitialized = false;
- // FIXME: We should pass the arguments from the command line
- if (!gstInitialized) {
- gst_init(0, NULL);
- gstInitialized = true;
- }
-
- // FIXME: The size shouldn't be fixed here, this is just a quick hack.
- m_surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 640, 480);
-}
-
-MediaPlayerPrivate::~MediaPlayerPrivate()
-{
- if (m_surface)
- cairo_surface_destroy(m_surface);
-
- if (m_playBin) {
- gst_element_set_state(m_playBin, GST_STATE_NULL);
- gst_object_unref(GST_OBJECT(m_playBin));
- }
-}
-
-void MediaPlayerPrivate::load(String url)
-{
- LOG_VERBOSE(Media, "Load %s", url.utf8().data());
- if (m_networkState != MediaPlayer::Loading) {
- m_networkState = MediaPlayer::Loading;
- m_player->networkStateChanged();
- }
- if (m_readyState != MediaPlayer::DataUnavailable) {
- m_readyState = MediaPlayer::DataUnavailable;
- m_player->readyStateChanged();
- }
-
- createGSTPlayBin(url);
- pause();
-}
-
-void MediaPlayerPrivate::play()
-{
- LOG_VERBOSE(Media, "Play");
- // When end reached, rewind for Test video-seek-past-end-playing
- if (m_isEndReached)
- seek(0);
- m_isEndReached = false;
-
- gst_element_set_state(m_playBin, GST_STATE_PLAYING);
- m_startedPlaying = true;
-}
-
-void MediaPlayerPrivate::pause()
-{
- LOG_VERBOSE(Media, "Pause");
- gst_element_set_state(m_playBin, GST_STATE_PAUSED);
- m_startedPlaying = false;
-}
-
-float MediaPlayerPrivate::duration()
-{
- if (!m_playBin)
- return 0.0;
-
- GstFormat fmt = GST_FORMAT_TIME;
- gint64 len = 0;
-
- if (gst_element_query_duration(m_playBin, &fmt, &len))
- LOG_VERBOSE(Media, "Duration: %" GST_TIME_FORMAT, GST_TIME_ARGS(len));
- else
- LOG_VERBOSE(Media, "Duration query failed ");
-
- if ((GstClockTime)len == GST_CLOCK_TIME_NONE) {
- m_isStreaming = true;
- return numeric_limits<float>::infinity();
- }
- return (float) (len / 1000000000.0);
- // FIXME: handle 3.14.9.5 properly
-}
-
-float MediaPlayerPrivate::currentTime() const
-{
- if (!m_playBin)
- return 0;
- // Necessary as sometimes, gstreamer return 0:00 at the EOS
- if (m_isEndReached)
- return m_endTime;
-
- float ret;
-
- GstQuery* query = gst_query_new_position(GST_FORMAT_TIME);
- if (gst_element_query(m_playBin, query)) {
- gint64 position;
- gst_query_parse_position(query, NULL, &position);
- ret = (float) (position / 1000000000.0);
- LOG_VERBOSE(Media, "Position %" GST_TIME_FORMAT, GST_TIME_ARGS(position));
- } else {
- LOG_VERBOSE(Media, "Position query failed...");
- ret = 0.0;
- }
- gst_query_unref(query);
-
- return ret;
-}
-
-void MediaPlayerPrivate::seek(float time)
-{
- GstClockTime sec = (GstClockTime)(time * GST_SECOND);
-
- if (!m_playBin)
- return;
-
- if (m_isStreaming)
- return;
-
- LOG_VERBOSE(Media, "Seek: %" GST_TIME_FORMAT, GST_TIME_ARGS(sec));
- // FIXME: What happens when the seeked position is not available?
- if (!gst_element_seek( m_playBin, m_rate,
- GST_FORMAT_TIME,
- (GstSeekFlags)(GST_SEEK_FLAG_FLUSH),
- GST_SEEK_TYPE_SET, sec,
- GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE))
- LOG_VERBOSE(Media, "Seek to %f failed", time);
-}
-
-void MediaPlayerPrivate::setEndTime(float time)
-{
- if (!m_playBin)
- return;
- if (m_isStreaming)
- return;
- if (m_endTime != time) {
- m_endTime = time;
- GstClockTime start = (GstClockTime)(currentTime() * GST_SECOND);
- GstClockTime end = (GstClockTime)(time * GST_SECOND);
- LOG_VERBOSE(Media, "setEndTime: %" GST_TIME_FORMAT, GST_TIME_ARGS(end));
- // FIXME: What happens when the seeked position is not available?
- if (!gst_element_seek(m_playBin, m_rate,
- GST_FORMAT_TIME,
- (GstSeekFlags)(GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE),
- GST_SEEK_TYPE_SET, start,
- GST_SEEK_TYPE_SET, end ))
- LOG_VERBOSE(Media, "Seek to %f failed", time);
- }
-}
-
-void MediaPlayerPrivate::startEndPointTimerIfNeeded()
-{
- notImplemented();
-}
-
-void MediaPlayerPrivate::cancelSeek()
-{
- notImplemented();
-}
-
-void MediaPlayerPrivate::endPointTimerFired(Timer<MediaPlayerPrivate>*)
-{
- notImplemented();
-}
-
-bool MediaPlayerPrivate::paused() const
-{
- return !m_startedPlaying;
-}
-
-bool MediaPlayerPrivate::seeking() const
-{
- return false;
-}
-
-// Returns the size of the video
-IntSize MediaPlayerPrivate::naturalSize()
-{
- if (!hasVideo())
- return IntSize();
-
- int x = 0, y = 0;
- if (GstPad* pad = gst_element_get_static_pad(m_videoSink, "sink")) {
- gst_video_get_size(GST_PAD(pad), &x, &y);
- gst_object_unref(GST_OBJECT(pad));
- }
-
- return IntSize(x, y);
-}
-
-bool MediaPlayerPrivate::hasVideo()
-{
- gint currentVideo = -1;
- if (m_playBin)
- g_object_get(G_OBJECT(m_playBin), "current-video", &currentVideo, NULL);
- return currentVideo > -1;
-}
-
-void MediaPlayerPrivate::setVolume(float volume)
-{
- m_volume = volume;
- LOG_VERBOSE(Media, "Volume to %f", volume);
- setMuted(false);
-}
-
-void MediaPlayerPrivate::setMuted(bool b)
-{
- if (!m_playBin)
- return;
-
- if (b) {
- g_object_get(G_OBJECT(m_playBin), "volume", &m_volume, NULL);
- g_object_set(G_OBJECT(m_playBin), "volume", (double)0.0, NULL);
- } else {
- g_object_set(G_OBJECT(m_playBin), "volume", m_volume, NULL);
- }
-}
-
-void MediaPlayerPrivate::setRate(float rate)
-{
- if (rate == 0.0) {
- gst_element_set_state(m_playBin, GST_STATE_PAUSED);
- return;
- }
- if (m_isStreaming)
- return;
-
- m_rate = rate;
- LOG_VERBOSE(Media, "Set Rate to %f", rate);
- if (!gst_element_seek(m_playBin, rate,
- GST_FORMAT_TIME,
- (GstSeekFlags)(GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE),
- GST_SEEK_TYPE_SET, (GstClockTime) (currentTime() * GST_SECOND),
- GST_SEEK_TYPE_SET, (GstClockTime) (m_endTime * GST_SECOND)))
- LOG_VERBOSE(Media, "Set Rate to %f failed", rate);
-}
-
-int MediaPlayerPrivate::dataRate() const
-{
- notImplemented();
- return 1;
-}
-
-MediaPlayer::NetworkState MediaPlayerPrivate::networkState()
-{
- return m_networkState;
-}
-
-MediaPlayer::ReadyState MediaPlayerPrivate::readyState()
-{
- return m_readyState;
-}
-
-float MediaPlayerPrivate::maxTimeBuffered()
-{
- notImplemented();
- LOG_VERBOSE(Media, "maxTimeBuffered");
- // rtsp streams are not buffered
- return m_isStreaming ? 0 : maxTimeLoaded();
-}
-
-float MediaPlayerPrivate::maxTimeSeekable()
-{
- // TODO
- LOG_VERBOSE(Media, "maxTimeSeekable");
- if (m_isStreaming)
- return numeric_limits<float>::infinity();
- // infinite duration means live stream
- return maxTimeLoaded();
-}
-
-float MediaPlayerPrivate::maxTimeLoaded()
-{
- // TODO
- LOG_VERBOSE(Media, "maxTimeLoaded");
- notImplemented();
- return duration();
-}
-
-unsigned MediaPlayerPrivate::bytesLoaded()
-{
- notImplemented();
- LOG_VERBOSE(Media, "bytesLoaded");
- /*if (!m_playBin)
- return 0;
- float dur = duration();
- float maxTime = maxTimeLoaded();
- if (!dur)
- return 0;*/
- return 1;//totalBytes() * maxTime / dur;
-}
-
-bool MediaPlayerPrivate::totalBytesKnown()
-{
- notImplemented();
- LOG_VERBOSE(Media, "totalBytesKnown");
- return totalBytes() > 0;
-}
-
-unsigned MediaPlayerPrivate::totalBytes()
-{
- notImplemented();
- LOG_VERBOSE(Media, "totalBytes");
- if (!m_playBin)
- return 0;
-
- if (!m_source)
- return 0;
-
- // Do something with m_source to get the total bytes of the media
-
- return 100;
-}
-
-void MediaPlayerPrivate::cancelLoad()
-{
- notImplemented();
-}
-
-void MediaPlayerPrivate::updateStates()
-{
- // There is no (known) way to get such level of information about
- // the state of GStreamer, therefore, when in PAUSED state,
- // we are sure we can display the first frame and go to play
-
- MediaPlayer::NetworkState oldNetworkState = m_networkState;
- MediaPlayer::ReadyState oldReadyState = m_readyState;
- GstState state;
- GstState pending;
-
- if (!m_playBin)
- return;
-
- GstStateChangeReturn ret = gst_element_get_state (m_playBin,
- &state, &pending, 250 * GST_NSECOND);
-
- switch(ret) {
- case GST_STATE_CHANGE_SUCCESS:
- LOG_VERBOSE(Media, "State: %s, pending: %s",
- gst_element_state_get_name(state),
- gst_element_state_get_name(pending));
-
- if (state == GST_STATE_READY) {
- m_readyState = MediaPlayer::CanPlayThrough;
- } else if (state == GST_STATE_PAUSED) {
- m_readyState = MediaPlayer::CanPlayThrough;
- }
- if (m_networkState < MediaPlayer::Loaded)
- m_networkState = MediaPlayer::Loaded;
-
- g_object_get(m_playBin, "source", &m_source, NULL);
- if (!m_source)
- LOG_VERBOSE(Media, "m_source is NULL");
- break;
- case GST_STATE_CHANGE_ASYNC:
- LOG_VERBOSE(Media, "Async: State: %s, pending: %s",
- gst_element_state_get_name(state),
- gst_element_state_get_name(pending));
- // Change in progress
- return;
- break;
- case GST_STATE_CHANGE_NO_PREROLL:
- LOG_VERBOSE(Media, "No preroll: State: %s, pending: %s",
- gst_element_state_get_name(state),
- gst_element_state_get_name(pending));
- if (state == GST_STATE_READY) {
- m_readyState = MediaPlayer::CanPlay;
- } else if (state == GST_STATE_PAUSED) {
- m_readyState = MediaPlayer::CanPlay;
- }
- if (m_networkState < MediaPlayer::LoadedMetaData)
- m_networkState = MediaPlayer::LoadedMetaData;
- break;
- default:
- LOG_VERBOSE(Media, "Else : %d", ret);
- break;
- }
-
- if (seeking())
- m_readyState = MediaPlayer::DataUnavailable;
-
- if (m_networkState != oldNetworkState) {
- LOG_VERBOSE(Media, "Network State Changed from %u to %u",
- oldNetworkState, m_networkState);
- m_player->networkStateChanged();
- }
- if (m_readyState != oldReadyState) {
- LOG_VERBOSE(Media, "Ready State Changed from %u to %u",
- oldReadyState, m_readyState);
- m_player->readyStateChanged();
- }
-}
-
-void MediaPlayerPrivate::loadStateChanged()
-{
- updateStates();
-}
-
-void MediaPlayerPrivate::rateChanged()
-{
- updateStates();
-}
-
-void MediaPlayerPrivate::sizeChanged()
-{
- notImplemented();
-}
-
-void MediaPlayerPrivate::timeChanged()
-{
- updateStates();
- m_player->timeChanged();
-}
-
-void MediaPlayerPrivate::volumeChanged()
-{
- m_player->volumeChanged();
-}
-
-void MediaPlayerPrivate::didEnd()
-{
- m_isEndReached = true;
- pause();
- timeChanged();
-}
-
-void MediaPlayerPrivate::loadingFailed()
-{
- if (m_networkState != MediaPlayer::LoadFailed) {
- m_networkState = MediaPlayer::LoadFailed;
- m_player->networkStateChanged();
- }
- if (m_readyState != MediaPlayer::DataUnavailable) {
- m_readyState = MediaPlayer::DataUnavailable;
- m_player->readyStateChanged();
- }
-}
-
-void MediaPlayerPrivate::setRect(const IntRect& rect)
-{
- m_rect = rect;
-}
-
-void MediaPlayerPrivate::setVisible(bool visible)
-{
- m_visible = visible;
-}
-
-void MediaPlayerPrivate::repaint()
-{
- m_player->repaint();
-}
-
-void MediaPlayerPrivate::paint(GraphicsContext* context, const IntRect& rect)
-{
- if (context->paintingDisabled())
- return;
-
- if (!m_visible)
- return;
-
- //TODO: m_rect vs rect?
- cairo_t* cr = context->platformContext();
-
- cairo_save(cr);
- cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
- cairo_translate(cr, rect.x(), rect.y());
- cairo_rectangle(cr, 0, 0, rect.width(), rect.height());
- cairo_set_source_surface(cr, m_surface, 0, 0);
- cairo_fill(cr);
- cairo_restore(cr);
-}
-
-void MediaPlayerPrivate::getSupportedTypes(HashSet<String>& types)
-{
- // FIXME: do the real thing
- notImplemented();
- types.add(String("video/x-theora+ogg"));
-}
-
-void MediaPlayerPrivate::createGSTPlayBin(String url)
-{
- ASSERT(!m_playBin);
- m_playBin = gst_element_factory_make("playbin", "play");
-
- GstBus* bus = gst_pipeline_get_bus(GST_PIPELINE(m_playBin));
- gst_bus_add_signal_watch(bus);
- g_signal_connect(bus, "message::error", G_CALLBACK(mediaPlayerPrivateErrorCallback), this);
- g_signal_connect(bus, "message::eos", G_CALLBACK(mediaPlayerPrivateEOSCallback), this);
- g_signal_connect(bus, "message::state-changed", G_CALLBACK(mediaPlayerPrivateStateCallback), this);
- g_signal_connect(bus, "message::buffering", G_CALLBACK(mediaPlayerPrivateBufferingCallback), this);
- gst_object_unref(bus);
-
- g_object_set(G_OBJECT(m_playBin), "uri", url.utf8().data(), NULL);
-
- GstElement* audioSink = gst_element_factory_make("gconfaudiosink", NULL);
- m_videoSink = webkit_video_sink_new(m_surface);
-
- g_object_set(m_playBin, "audio-sink", audioSink, NULL);
- g_object_set(m_playBin, "video-sink", m_videoSink, NULL);
-
- setVolume(m_volume);
-}
-
-}
-
-#endif
-
diff --git a/WebCore/platform/graphics/gtk/MediaPlayerPrivateGStreamer.h b/WebCore/platform/graphics/gtk/MediaPlayerPrivateGStreamer.h
deleted file mode 100644
index 3f08bc0..0000000
--- a/WebCore/platform/graphics/gtk/MediaPlayerPrivateGStreamer.h
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2007 Collabora Ltd. All rights reserved.
- * Copyright (C) 2007 Alp Toker <alp@atoker.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * aint with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef MediaPlayerPrivateGStreamer_h
-#define MediaPlayerPrivateGStreamer_h
-
-#if ENABLE(VIDEO)
-
-#include "MediaPlayer.h"
-#include "Timer.h"
-
-#include <gtk/gtk.h>
-
-typedef struct _GstElement GstElement;
-typedef struct _GstMessage GstMessage;
-typedef struct _GstBus GstBus;
-
-namespace WebCore {
-
- class GraphicsContext;
- class IntSize;
- class IntRect;
- class String;
-
- gboolean mediaPlayerPrivateErrorCallback(GstBus* bus, GstMessage* message, gpointer data);
- gboolean mediaPlayerPrivateEOSCallback(GstBus* bus, GstMessage* message, gpointer data);
- gboolean mediaPlayerPrivateStateCallback(GstBus* bus, GstMessage* message, gpointer data);
-
- class MediaPlayerPrivate : Noncopyable
- {
- friend gboolean mediaPlayerPrivateErrorCallback(GstBus* bus, GstMessage* message, gpointer data);
- friend gboolean mediaPlayerPrivateEOSCallback(GstBus* bus, GstMessage* message, gpointer data);
- friend gboolean mediaPlayerPrivateStateCallback(GstBus* bus, GstMessage* message, gpointer data);
-
- public:
- MediaPlayerPrivate(MediaPlayer*);
- ~MediaPlayerPrivate();
-
- IntSize naturalSize();
- bool hasVideo();
-
- void load(String url);
- void cancelLoad();
-
- void play();
- void pause();
-
- bool paused() const;
- bool seeking() const;
-
- float duration();
- float currentTime() const;
- void seek(float);
- void setEndTime(float);
-
- void setRate(float);
- void setVolume(float);
- void setMuted(bool);
-
- int dataRate() const;
-
- MediaPlayer::NetworkState networkState();
- MediaPlayer::ReadyState readyState();
-
- float maxTimeBuffered();
- float maxTimeSeekable();
- unsigned bytesLoaded();
- bool totalBytesKnown();
- unsigned totalBytes();
-
- void setVisible(bool);
- void setRect(const IntRect&);
-
- void loadStateChanged();
- void rateChanged();
- void sizeChanged();
- void timeChanged();
- void volumeChanged();
- void didEnd();
- void loadingFailed();
-
- void repaint();
- void paint(GraphicsContext*, const IntRect&);
- static void getSupportedTypes(HashSet<String>&);
- static bool isAvailable() { return true; }
-
- private:
-
- void updateStates();
- void cancelSeek();
- void endPointTimerFired(Timer<MediaPlayerPrivate>*);
- float maxTimeLoaded();
- void startEndPointTimerIfNeeded();
-
- void createGSTPlayBin(String url);
-
- private:
- MediaPlayer* m_player;
- GstElement* m_playBin;
- GstElement* m_videoSink;
- GstElement* m_source;
- float m_rate;
- float m_endTime;
- bool m_isEndReached;
- double m_volume;
- MediaPlayer::NetworkState m_networkState;
- MediaPlayer::ReadyState m_readyState;
- bool m_startedPlaying;
- bool m_isStreaming;
- IntRect m_rect;
- bool m_visible;
- cairo_surface_t* m_surface;
- };
-}
-
-#endif
-#endif
diff --git a/WebCore/platform/graphics/gtk/SimpleFontDataGtk.cpp b/WebCore/platform/graphics/gtk/SimpleFontDataGtk.cpp
deleted file mode 100644
index 1ca3e95..0000000
--- a/WebCore/platform/graphics/gtk/SimpleFontDataGtk.cpp
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
- * Copyright (C) 2007, 2008 Alp Toker <alp@atoker.com>
- * Copyright (C) 2007 Holger Hans Peter Freyther
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "SimpleFontData.h"
-
-#include "FloatRect.h"
-#include "Font.h"
-#include "FontCache.h"
-#include "FontDescription.h"
-#include "GlyphBuffer.h"
-#include <cairo.h>
-#include <unicode/uchar.h>
-#include <unicode/unorm.h>
-#include <wtf/MathExtras.h>
-
-namespace WebCore {
-
-void SimpleFontData::platformInit()
-{
- cairo_font_extents_t font_extents;
- cairo_text_extents_t text_extents;
- cairo_scaled_font_extents(m_font.m_scaledFont, &font_extents);
- m_ascent = static_cast<int>(font_extents.ascent);
- m_descent = static_cast<int>(font_extents.descent);
- m_lineSpacing = static_cast<int>(font_extents.height);
- cairo_scaled_font_text_extents(m_font.m_scaledFont, "x", &text_extents);
- m_xHeight = text_extents.height;
- cairo_scaled_font_text_extents(m_font.m_scaledFont, " ", &text_extents);
- m_spaceWidth = static_cast<int>(text_extents.x_advance);
- m_lineGap = m_lineSpacing - m_ascent - m_descent;
-}
-
-void SimpleFontData::platformDestroy()
-{
- delete m_smallCapsFontData;
-
- if (isCustomFont())
- return;
-
- if (m_font.m_pattern && ((FcPattern*)-1 != m_font.m_pattern)) {
- FcPatternDestroy(m_font.m_pattern);
- m_font.m_pattern = 0;
- }
-
- if (m_font.m_fallbacks) {
- FcFontSetDestroy(m_font.m_fallbacks);
- m_font.m_fallbacks = 0;
- }
-
- if (m_font.m_scaledFont) {
- cairo_scaled_font_destroy(m_font.m_scaledFont);
- m_font.m_scaledFont = 0;
- }
-}
-
-SimpleFontData* SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const
-{
- if (!m_smallCapsFontData) {
- FontDescription desc = FontDescription(fontDescription);
- desc.setSpecifiedSize(0.70f*fontDescription.computedSize());
- const FontPlatformData* pdata = new FontPlatformData(desc, desc.family().family());
- m_smallCapsFontData = new SimpleFontData(*pdata);
- }
- return m_smallCapsFontData;
-}
-
-bool SimpleFontData::containsCharacters(const UChar* characters, int length) const
-{
- FT_Face face = cairo_ft_scaled_font_lock_face(m_font.m_scaledFont);
-
- if (!face)
- return false;
-
- for (unsigned i = 0; i < length; i++) {
- if (FcFreeTypeCharIndex(face, characters[i]) == 0) {
- cairo_ft_scaled_font_unlock_face(m_font.m_scaledFont);
- return false;
- }
- }
-
- cairo_ft_scaled_font_unlock_face(m_font.m_scaledFont);
-
- return true;
-}
-
-void SimpleFontData::determinePitch()
-{
- m_treatAsFixedPitch = m_font.isFixedPitch();
-}
-
-float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
-{
- ASSERT(m_font.m_scaledFont);
-
- cairo_glyph_t cglyph = { glyph, 0, 0 };
- cairo_text_extents_t extents;
- cairo_scaled_font_glyph_extents(m_font.m_scaledFont, &cglyph, 1, &extents);
-
- float w = (float)m_spaceWidth;
- if (cairo_scaled_font_status(m_font.m_scaledFont) == CAIRO_STATUS_SUCCESS && extents.x_advance != 0)
- w = (float)extents.x_advance;
- return w;
-}
-
-void SimpleFontData::setFont(cairo_t* cr) const
-{
- ASSERT(cr);
- m_font.setFont(cr);
-}
-
-}
diff --git a/WebCore/platform/graphics/gtk/SimpleFontDataPango.cpp b/WebCore/platform/graphics/gtk/SimpleFontDataPango.cpp
deleted file mode 100644
index 8621865..0000000
--- a/WebCore/platform/graphics/gtk/SimpleFontDataPango.cpp
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
- * Copyright (C) 2007, 2008 Alp Toker <alp@atoker.com>
- * Copyright (C) 2007 Holger Hans Peter Freyther
- * Copyright (C) 2007 Pioneer Research Center USA, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "SimpleFontData.h"
-
-#include "FloatRect.h"
-#include "Font.h"
-#include "FontCache.h"
-#include "FontDescription.h"
-#include "GlyphBuffer.h"
-#include <cairo.h>
-#include <wtf/MathExtras.h>
-
-namespace WebCore {
-
-void SimpleFontData::platformInit()
-{
- cairo_font_extents_t font_extents;
- cairo_text_extents_t text_extents;
- cairo_scaled_font_extents(m_font.m_scaledFont, &font_extents);
- m_ascent = static_cast<int>(font_extents.ascent);
- m_descent = static_cast<int>(font_extents.descent);
- m_lineSpacing = static_cast<int>(font_extents.height);
- cairo_scaled_font_text_extents(m_font.m_scaledFont, "x", &text_extents);
- m_xHeight = text_extents.height;
- cairo_scaled_font_text_extents(m_font.m_scaledFont, " ", &text_extents);
- m_spaceWidth = static_cast<int>(text_extents.x_advance);
- m_lineGap = m_lineSpacing - m_ascent - m_descent;
-}
-
-void SimpleFontData::platformDestroy()
-{
- if (!isCustomFont()) {
-
- if (m_font.m_font && m_font.m_font != reinterpret_cast<PangoFont*>(-1)) {
- g_object_unref(m_font.m_font);
- m_font.m_font = 0;
- }
-
- if (m_font.m_context) {
- g_object_unref (m_font.m_context);
- m_font.m_context = 0;
- }
-
- if (m_font.m_scaledFont) {
- cairo_scaled_font_destroy(m_font.m_scaledFont);
- m_font.m_scaledFont = 0;
- }
- }
-
- delete m_smallCapsFontData;
-}
-
-SimpleFontData* SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const
-{
- if (!m_smallCapsFontData) {
- FontDescription desc = FontDescription(fontDescription);
- desc.setSpecifiedSize(0.70f*fontDescription.computedSize());
- const FontPlatformData* pdata = new FontPlatformData(desc, desc.family().family());
- m_smallCapsFontData = new SimpleFontData(*pdata);
- }
- return m_smallCapsFontData;
-}
-
-bool SimpleFontData::containsCharacters(const UChar* characters, int length) const
-{
- bool result = true;
-
- PangoCoverage* requested = pango_coverage_from_bytes((guchar*)characters, length);
- PangoCoverage* available = pango_font_get_coverage(m_font.m_font, pango_language_get_default());
- pango_coverage_max(requested, available);
-
- for (int i = 0; i < length; i++) {
- if (PANGO_COVERAGE_NONE == pango_coverage_get(requested, i)) {
- result = false;
- break;
- }
- }
-
- pango_coverage_unref(requested);
- pango_coverage_unref(available);
-
- return result;
-}
-
-void SimpleFontData::determinePitch()
-{
- m_treatAsFixedPitch = m_font.isFixedPitch();
-}
-
-float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
-{
- ASSERT(m_font.m_scaledFont);
-
- cairo_glyph_t cglyph = { glyph, 0, 0 };
- cairo_text_extents_t extents;
- cairo_scaled_font_glyph_extents(m_font.m_scaledFont, &cglyph, 1, &extents);
-
- float w = (float)m_spaceWidth;
- if (cairo_scaled_font_status(m_font.m_scaledFont) == CAIRO_STATUS_SUCCESS && extents.x_advance != 0)
- w = (float)extents.x_advance;
- return w;
-}
-
-void SimpleFontData::setFont(cairo_t* cr) const
-{
- ASSERT(cr);
- m_font.setFont(cr);
-}
-
-}
diff --git a/WebCore/platform/graphics/gtk/VideoSinkGStreamer.cpp b/WebCore/platform/graphics/gtk/VideoSinkGStreamer.cpp
deleted file mode 100644
index 04df7ac..0000000
--- a/WebCore/platform/graphics/gtk/VideoSinkGStreamer.cpp
+++ /dev/null
@@ -1,312 +0,0 @@
-/*
- * Copyright (C) 2007 OpenedHand
- * Copyright (C) 2007 Alp Toker <alp@atoker.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/**
- * SECTION:webkit-video-sink
- * @short_description: GStreamer video sink
- *
- * #WebKitVideoSink is a GStreamer sink element that sends
- * data to a #cairo_surface_t.
- */
-
-#include "config.h"
-#include "VideoSinkGStreamer.h"
-
-#include <glib.h>
-#include <gst/gst.h>
-#include <gst/video/video.h>
-
-static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE("sink",
- GST_PAD_SINK, GST_PAD_ALWAYS,
- GST_STATIC_CAPS(GST_VIDEO_CAPS_RGBx ";" GST_VIDEO_CAPS_BGRx));
-
-GST_DEBUG_CATEGORY_STATIC(webkit_video_sink_debug);
-#define GST_CAT_DEFAULT webkit_video_sink_debug
-
-static GstElementDetails webkit_video_sink_details =
- GST_ELEMENT_DETAILS((gchar*) "WebKit video sink",
- (gchar*) "Sink/Video",
- (gchar*) "Sends video data from a GStreamer pipeline to a Cairo surface",
- (gchar*) "Alp Toker <alp@atoker.com>");
-
-enum {
- PROP_0,
- PROP_SURFACE
-};
-
-struct _WebKitVideoSinkPrivate {
- cairo_surface_t* surface;
- GAsyncQueue* async_queue;
- gboolean rgb_ordering;
- int width;
- int height;
- int fps_n;
- int fps_d;
- int par_n;
- int par_d;
-};
-
-#define _do_init(bla) \
- GST_DEBUG_CATEGORY_INIT (webkit_video_sink_debug, \
- "webkitsink", \
- 0, \
- "webkit video sink")
-
-GST_BOILERPLATE_FULL(WebKitVideoSink,
- webkit_video_sink,
- GstBaseSink,
- GST_TYPE_BASE_SINK,
- _do_init);
-
-static void
-webkit_video_sink_base_init(gpointer g_class)
-{
- GstElementClass* element_class = GST_ELEMENT_CLASS(g_class);
-
- gst_element_class_add_pad_template(element_class, gst_static_pad_template_get(&sinktemplate));
- gst_element_class_set_details(element_class, &webkit_video_sink_details);
-}
-
-static void
-webkit_video_sink_init(WebKitVideoSink* sink, WebKitVideoSinkClass* klass)
-{
- WebKitVideoSinkPrivate* priv;
-
- sink->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE(sink, WEBKIT_TYPE_VIDEO_SINK, WebKitVideoSinkPrivate);
- priv->async_queue = g_async_queue_new();
-}
-
-static gboolean
-webkit_video_sink_idle_func(gpointer data)
-{
- WebKitVideoSinkPrivate* priv;
- GstBuffer* buffer;
-
- priv = (WebKitVideoSinkPrivate*)data;
-
- if (!priv->async_queue)
- return FALSE;
-
- buffer = (GstBuffer*)g_async_queue_try_pop(priv->async_queue);
- if (buffer == NULL || G_UNLIKELY(!GST_IS_BUFFER(buffer)))
- return FALSE;
-
- // TODO: consider priv->rgb_ordering?
- cairo_surface_t* src = cairo_image_surface_create_for_data(GST_BUFFER_DATA(buffer), CAIRO_FORMAT_RGB24, priv->width, priv->height, (4 * priv->width + 3) & ~ 3);
-
- // TODO: We copy the data twice right now. This could be easily improved.
- cairo_t* cr = cairo_create(priv->surface);
- cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
- cairo_set_source_surface(cr, src, 0, 0);
- cairo_surface_destroy(src);
- cairo_rectangle(cr, 0, 0, priv->width, priv->height);
- cairo_fill(cr);
- cairo_destroy(cr);
-
- gst_buffer_unref(buffer);
-
- return FALSE;
-}
-
-static GstFlowReturn
-webkit_video_sink_render(GstBaseSink* bsink, GstBuffer* buffer)
-{
- WebKitVideoSink* sink = WEBKIT_VIDEO_SINK(bsink);
- WebKitVideoSinkPrivate* priv = sink->priv;
-
- g_async_queue_push(priv->async_queue, gst_buffer_ref(buffer));
- g_idle_add_full(G_PRIORITY_HIGH_IDLE, webkit_video_sink_idle_func, priv, NULL);
-
- return GST_FLOW_OK;
-}
-
-static gboolean
-webkit_video_sink_set_caps(GstBaseSink* bsink, GstCaps* caps)
-{
- WebKitVideoSink* sink = WEBKIT_VIDEO_SINK(bsink);
- WebKitVideoSinkPrivate* priv = sink->priv;
- GstStructure* structure;
- gboolean ret;
- const GValue* fps;
- const GValue* par;
- gint width, height;
- int red_mask;
-
- GstCaps* intersection = gst_caps_intersect(gst_static_pad_template_get_caps(&sinktemplate), caps);
-
- if (gst_caps_is_empty(intersection))
- return FALSE;
-
- gst_caps_unref(intersection);
-
- structure = gst_caps_get_structure(caps, 0);
-
- ret = gst_structure_get_int(structure, "width", &width);
- ret &= gst_structure_get_int(structure, "height", &height);
- fps = gst_structure_get_value(structure, "framerate");
- ret &= (fps != NULL);
-
- par = gst_structure_get_value(structure, "pixel-aspect-ratio");
-
- if (!ret)
- return FALSE;
-
- priv->width = width;
- priv->height = height;
-
- /* We dont yet use fps or pixel aspect into but handy to have */
- priv->fps_n = gst_value_get_fraction_numerator(fps);
- priv->fps_d = gst_value_get_fraction_denominator(fps);
-
- if (par) {
- priv->par_n = gst_value_get_fraction_numerator(par);
- priv->par_d = gst_value_get_fraction_denominator(par);
- } else
- priv->par_n = priv->par_d = 1;
-
- gst_structure_get_int(structure, "red_mask", &red_mask);
- priv->rgb_ordering = (red_mask == static_cast<int>(0xff000000));
-
- return TRUE;
-}
-
-static void
-webkit_video_sink_dispose(GObject* object)
-{
- WebKitVideoSink* sink = WEBKIT_VIDEO_SINK(object);
- WebKitVideoSinkPrivate* priv = sink->priv;
-
- if (priv->surface) {
- cairo_surface_destroy(priv->surface);
- priv->surface = NULL;
- }
-
- if (priv->async_queue) {
- g_async_queue_unref(priv->async_queue);
- priv->async_queue = NULL;
- }
-
- G_OBJECT_CLASS(parent_class)->dispose(object);
-}
-
-static void
-webkit_video_sink_finalize(GObject* object)
-{
- G_OBJECT_CLASS(parent_class)->finalize(object);
-}
-
-static void
-webkit_video_sink_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec)
-{
- WebKitVideoSink* sink = WEBKIT_VIDEO_SINK(object);
- WebKitVideoSinkPrivate* priv = sink->priv;
-
- switch (prop_id) {
- case PROP_SURFACE:
- if (priv->surface)
- cairo_surface_destroy(priv->surface);
- priv->surface = cairo_surface_reference((cairo_surface_t*)g_value_get_pointer(value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
- break;
- }
-}
-
-static void
-webkit_video_sink_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec)
-{
- WebKitVideoSink* sink = WEBKIT_VIDEO_SINK(object);
-
- switch (prop_id) {
- case PROP_SURFACE:
- g_value_set_pointer(value, sink->priv->surface);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
- break;
- }
-}
-
-static gboolean
-webkit_video_sink_stop(GstBaseSink* base_sink)
-{
- WebKitVideoSinkPrivate* priv = WEBKIT_VIDEO_SINK(base_sink)->priv;
-
- g_async_queue_lock(priv->async_queue);
-
- /* Remove all remaining objects from the queue */
- while(GstBuffer* buffer = (GstBuffer*)g_async_queue_try_pop_unlocked(priv->async_queue))
- gst_buffer_unref(buffer);
-
- g_async_queue_unlock(priv->async_queue);
-
- return TRUE;
-}
-
-static void
-webkit_video_sink_class_init(WebKitVideoSinkClass* klass)
-{
- GObjectClass* gobject_class = G_OBJECT_CLASS(klass);
- GstBaseSinkClass* gstbase_sink_class = GST_BASE_SINK_CLASS(klass);
-
- g_type_class_add_private(klass, sizeof(WebKitVideoSinkPrivate));
-
- gobject_class->set_property = webkit_video_sink_set_property;
- gobject_class->get_property = webkit_video_sink_get_property;
-
- gobject_class->dispose = webkit_video_sink_dispose;
- gobject_class->finalize = webkit_video_sink_finalize;
-
- gstbase_sink_class->render = webkit_video_sink_render;
- gstbase_sink_class->preroll = webkit_video_sink_render;
- gstbase_sink_class->stop = webkit_video_sink_stop;
- gstbase_sink_class->set_caps = webkit_video_sink_set_caps;
-
- g_object_class_install_property(
- gobject_class, PROP_SURFACE,
- g_param_spec_pointer("surface", "surface", "Target cairo_surface_t*",
- (GParamFlags)(G_PARAM_READWRITE)));
-}
-
-/**
- * webkit_video_sink_new:
- * @surface: a #cairo_surface_t
- *
- * Creates a new GStreamer video sink which uses @surface as the target
- * for sinking a video stream from GStreamer.
- *
- * Return value: a #GstElement for the newly created video sink
- */
-GstElement*
-webkit_video_sink_new(cairo_surface_t* surface)
-{
- return (GstElement*)g_object_new(WEBKIT_TYPE_VIDEO_SINK, "surface", surface, NULL);
-}
-
-void
-webkit_video_sink_set_surface(WebKitVideoSink* sink, cairo_surface_t* surface)
-{
- WebKitVideoSinkPrivate* priv;
-
- sink->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE(sink, WEBKIT_TYPE_VIDEO_SINK, WebKitVideoSinkPrivate);
- if (priv->surface)
- cairo_surface_destroy(priv->surface);
- priv->surface = cairo_surface_reference(surface);
-}
diff --git a/WebCore/platform/graphics/gtk/VideoSinkGStreamer.h b/WebCore/platform/graphics/gtk/VideoSinkGStreamer.h
deleted file mode 100644
index 2a706fb..0000000
--- a/WebCore/platform/graphics/gtk/VideoSinkGStreamer.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2007 OpenedHand
- * Copyright (C) 2007 Alp Toker <alp@atoker.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef _HAVE_WEBKIT_VIDEO_SINK_H
-#define _HAVE_WEBKIT_VIDEO_SINK_H
-
-#include <cairo.h>
-#include <glib-object.h>
-#include <gst/base/gstbasesink.h>
-
-G_BEGIN_DECLS
-
-#define WEBKIT_TYPE_VIDEO_SINK webkit_video_sink_get_type()
-
-#define WEBKIT_VIDEO_SINK(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
- WEBKIT_TYPE_VIDEO_SINK, WebKitVideoSink))
-
-#define WEBKIT_VIDEO_SINK_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST ((klass), \
- WEBKIT_TYPE_VIDEO_SINK, WebKitVideoSinkClass))
-
-#define WEBKIT_IS_VIDEO_SINK(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
- WEBKIT_TYPE_VIDEO_SINK))
-
-#define WEBKIT_IS_VIDEO_SINK_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE ((klass), \
- WEBKIT_TYPE_VIDEO_SINK))
-
-#define WEBKIT_VIDEO_SINK_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), \
- WEBKIT_TYPE_VIDEO_SINK, WebKitVideoSinkClass))
-
-typedef struct _WebKitVideoSink WebKitVideoSink;
-typedef struct _WebKitVideoSinkClass WebKitVideoSinkClass;
-typedef struct _WebKitVideoSinkPrivate WebKitVideoSinkPrivate;
-
-struct _WebKitVideoSink
-{
- /*< private >*/
- GstBaseSink parent;
- WebKitVideoSinkPrivate *priv;
-};
-
-struct _WebKitVideoSinkClass
-{
- /*< private >*/
- GstBaseSinkClass parent_class;
-
- /* Future padding */
- void (* _webkit_reserved1) (void);
- void (* _webkit_reserved2) (void);
- void (* _webkit_reserved3) (void);
- void (* _webkit_reserved4) (void);
- void (* _webkit_reserved5) (void);
- void (* _webkit_reserved6) (void);
-};
-
-GType webkit_video_sink_get_type (void) G_GNUC_CONST;
-GstElement *webkit_video_sink_new (cairo_surface_t *surface);
-
-void webkit_video_sink_set_surface (WebKitVideoSink *sink, cairo_surface_t *surface);
-
-G_END_DECLS
-
-#endif
diff --git a/WebCore/platform/graphics/mac/ColorMac.h b/WebCore/platform/graphics/mac/ColorMac.h
deleted file mode 100644
index 3be9094..0000000
--- a/WebCore/platform/graphics/mac/ColorMac.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ColorMac_h
-#define ColorMac_h
-
-#include "Color.h"
-
-#ifdef __OBJC__
-@class NSColor;
-#else
-class NSColor;
-#endif
-
-namespace WebCore {
-
- Color colorFromNSColor(NSColor *);
- NSColor* nsColor(const Color&);
-
- bool usesTestModeFocusRingColor();
- void setUsesTestModeFocusRingColor(bool);
-
-}
-
-#endif
diff --git a/WebCore/platform/graphics/mac/ColorMac.mm b/WebCore/platform/graphics/mac/ColorMac.mm
deleted file mode 100644
index 96fdc39..0000000
--- a/WebCore/platform/graphics/mac/ColorMac.mm
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "Color.h"
-#import "ColorMac.h"
-
-#import <wtf/Assertions.h>
-#import <wtf/RetainPtr.h>
-
-@interface WebCoreControlTintObserver : NSObject
-+ (void)controlTintDidChange;
-@end
-
-namespace WebCore {
-
-// NSColor calls don't throw, so no need to block Cocoa exceptions in this file
-
-static RGBA32 oldAquaFocusRingColor = 0xFF7DADD9;
-static RGBA32 systemFocusRingColor;
-static bool useOldAquaFocusRingColor;
-
-
-static RGBA32 makeRGBAFromNSColor(NSColor *c)
-{
- return makeRGBA((int)(255 * [c redComponent]), (int)(255 * [c greenComponent]), (int)(255 * [c blueComponent]), (int)(255 * [c alphaComponent]));
-}
-
-Color colorFromNSColor(NSColor *c)
-{
- return Color(makeRGBAFromNSColor(c));
-}
-
-NSColor* nsColor(const Color& color)
-{
- unsigned c = color.rgb();
- switch (c) {
- case 0: {
- // Need this to avoid returning nil because cachedRGBAValues will default to 0.
- static RetainPtr<NSColor> clearColor = [NSColor clearColor];
- return clearColor.get();
- }
- case Color::black: {
- static RetainPtr<NSColor> blackColor = [NSColor blackColor];
- return blackColor.get();
- }
- case Color::white: {
- static RetainPtr<NSColor> whiteColor = [NSColor whiteColor];
- return whiteColor.get();
- }
- default: {
- const int cacheSize = 32;
- static unsigned cachedRGBAValues[cacheSize];
- static RetainPtr<NSColor> cachedColors[cacheSize];
-
- for (int i = 0; i != cacheSize; ++i)
- if (cachedRGBAValues[i] == c)
- return cachedColors[i].get();
-
-#ifdef COLORMATCH_EVERYTHING
- NSColor* result = [NSColor colorWithCalibratedRed:color.red() / 255.0f
- green:color.green() / 255.0f
- blue:color.blue() / 255.0f
- alpha:color.alpha() /255.0f];
-#else
- NSColor* result = [NSColor colorWithDeviceRed:color.red() / 255.0f
- green:color.green() / 255.0f
- blue:color.blue() / 255.0f
- alpha:color.alpha() /255.0f];
-#endif
-
- static int cursor;
- cachedRGBAValues[cursor] = c;
- cachedColors[cursor] = result;
- if (++cursor == cacheSize)
- cursor = 0;
- return result;
- }
- }
-}
-
-static CGColorRef CGColorFromNSColor(NSColor* color)
-{
- // This needs to always use device colorspace so it can de-calibrate the color for
- // CGColor to possibly recalibrate it.
- NSColor* deviceColor = [color colorUsingColorSpaceName:NSDeviceRGBColorSpace];
- CGFloat red = [deviceColor redComponent];
- CGFloat green = [deviceColor greenComponent];
- CGFloat blue = [deviceColor blueComponent];
- CGFloat alpha = [deviceColor alphaComponent];
- const CGFloat components[4] = { red, green, blue, alpha };
- static CGColorSpaceRef deviceRGBColorSpace = CGColorSpaceCreateDeviceRGB();
- CGColorRef cgColor = CGColorCreate(deviceRGBColorSpace, components);
- return cgColor;
-}
-
-CGColorRef cgColor(const Color& c)
-{
- // We could directly create a CGColor here, but that would
- // skip any RGB caching the nsColor method does. A direct
- // creation could be investigated for a possible performance win.
- return CGColorFromNSColor(nsColor(c));
-}
-
-Color focusRingColor()
-{
- static bool tintIsKnown = false;
- if (!tintIsKnown) {
- [[NSNotificationCenter defaultCenter] addObserver:[WebCoreControlTintObserver class]
- selector:@selector(controlTintDidChange)
- name:NSControlTintDidChangeNotification
- object:NSApp];
- [WebCoreControlTintObserver controlTintDidChange];
- tintIsKnown = true;
- }
-
- if (usesTestModeFocusRingColor())
- return oldAquaFocusRingColor;
-
- return systemFocusRingColor;
-}
-
-bool usesTestModeFocusRingColor()
-{
- return useOldAquaFocusRingColor;
-}
-
-void setUsesTestModeFocusRingColor(bool newValue)
-{
- useOldAquaFocusRingColor = newValue;
-}
-
-}
-
-@implementation WebCoreControlTintObserver
-
-+ (void)controlTintDidChange
-{
-#ifdef COLORMATCH_EVERYTHING
-#error Not yet implemented.
-#else
- NSColor* color = [[NSColor keyboardFocusIndicatorColor] colorUsingColorSpaceName:NSDeviceRGBColorSpace];
- WebCore::systemFocusRingColor = WebCore::makeRGBAFromNSColor(color);
-#endif
-}
-
-@end
diff --git a/WebCore/platform/graphics/mac/CoreTextController.cpp b/WebCore/platform/graphics/mac/CoreTextController.cpp
deleted file mode 100644
index 171a7ec..0000000
--- a/WebCore/platform/graphics/mac/CoreTextController.cpp
+++ /dev/null
@@ -1,533 +0,0 @@
-/*
- * Copyright (C) 2007, 2008 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "CoreTextController.h"
-
-#if USE(CORE_TEXT)
-
-#include "CharacterNames.h"
-#include "Font.h"
-#include "FontCache.h"
-#include "SimpleFontData.h"
-#include "TextBreakIterator.h"
-#include <wtf/MathExtras.h>
-
-using namespace std;
-
-namespace WebCore {
-
-static inline CGFloat roundCGFloat(CGFloat f)
-{
- if (sizeof(CGFloat) == sizeof(float))
- return roundf(static_cast<float>(f));
- return static_cast<CGFloat>(round(f));
-}
-
-static inline CGFloat ceilCGFloat(CGFloat f)
-{
- if (sizeof(CGFloat) == sizeof(float))
- return ceilf(static_cast<float>(f));
- return static_cast<CGFloat>(ceil(f));
-}
-
-CoreTextController::CoreTextRun::CoreTextRun(CTRunRef ctRun, const SimpleFontData* fontData, const UChar* characters, unsigned stringLocation, size_t stringLength)
- : m_CTRun(ctRun)
- , m_fontData(fontData)
- , m_characters(characters)
- , m_stringLocation(stringLocation)
- , m_stringLength(stringLength)
-{
- m_glyphCount = CTRunGetGlyphCount(ctRun);
- m_indices = CTRunGetStringIndicesPtr(ctRun);
- if (!m_indices) {
- m_indicesData.adoptCF(CFDataCreateMutable(kCFAllocatorDefault, m_glyphCount * sizeof(CFIndex)));
- CFDataIncreaseLength(m_indicesData.get(), m_glyphCount * sizeof(CFIndex));
- m_indices = reinterpret_cast<const CFIndex*>(CFDataGetMutableBytePtr(m_indicesData.get()));
- CTRunGetStringIndices(ctRun, CFRangeMake(0, 0), const_cast<CFIndex*>(m_indices));
- }
-}
-
-// Missing glyphs run constructor. Core Text will not generate a run of missing glyphs, instead falling back on
-// glyphs from LastResort. We want to use the primary font's missing glyph in order to match the fast text code path.
-CoreTextController::CoreTextRun::CoreTextRun(const SimpleFontData* fontData, const UChar* characters, unsigned stringLocation, size_t stringLength, bool ltr)
- : m_fontData(fontData)
- , m_characters(characters)
- , m_stringLocation(stringLocation)
- , m_stringLength(stringLength)
-{
- Vector<CFIndex, 16> indices;
- unsigned r = 0;
- while (r < stringLength) {
- indices.append(r);
- if (U_IS_SURROGATE(characters[r])) {
- ASSERT(r + 1 < stringLength);
- ASSERT(U_IS_SURROGATE_LEAD(characters[r]));
- ASSERT(U_IS_TRAIL(characters[r + 1]));
- r += 2;
- } else
- r++;
- }
- m_glyphCount = indices.size();
- if (!ltr) {
- for (unsigned r = 0, end = m_glyphCount - 1; r < m_glyphCount / 2; ++r, --end)
- std::swap(indices[r], indices[end]);
- }
- m_indicesData.adoptCF(CFDataCreateMutable(kCFAllocatorDefault, m_glyphCount * sizeof(CFIndex)));
- CFDataAppendBytes(m_indicesData.get(), reinterpret_cast<const UInt8*>(indices.data()), m_glyphCount * sizeof(CFIndex));
- m_indices = reinterpret_cast<const CFIndex*>(CFDataGetBytePtr(m_indicesData.get()));
-}
-
-CoreTextController::CoreTextController(const Font* font, const TextRun& run, bool mayUseNaturalWritingDirection)
- : m_font(*font)
- , m_run(run)
- , m_mayUseNaturalWritingDirection(mayUseNaturalWritingDirection)
- , m_currentCharacter(0)
- , m_end(run.length())
- , m_totalWidth(0)
- , m_runWidthSoFar(0)
- , m_numGlyphsSoFar(0)
- , m_currentRun(0)
- , m_glyphInCurrentRun(0)
- , m_finalRoundingWidth(0)
- , m_lastRoundingGlyph(0)
-{
- m_padding = m_run.padding();
- if (!m_padding)
- m_padPerSpace = 0;
- else {
- float numSpaces = 0;
- for (int s = 0; s < m_run.length(); s++)
- if (Font::treatAsSpace(m_run[s]))
- numSpaces++;
-
- if (numSpaces == 0)
- m_padPerSpace = 0;
- else
- m_padPerSpace = ceilf(m_run.padding() / numSpaces);
- }
-
- collectCoreTextRuns();
- adjustGlyphsAndAdvances();
-}
-
-int CoreTextController::offsetForPosition(int h, bool includePartialGlyphs)
-{
- // FIXME: For positions occurring within a ligature, we should return the closest "ligature caret" or
- // approximate it by dividing the width of the ligature by the number of characters it encompasses.
- // However, Core Text does not expose a low-level API for directly finding
- // out how many characters a ligature encompasses (the "attachment count").
- if (h >= m_totalWidth)
- return m_run.ltr() ? m_end : 0;
- if (h < 0)
- return m_run.ltr() ? 0 : m_end;
-
- CGFloat x = h;
-
- size_t runCount = m_coreTextRuns.size();
- size_t offsetIntoAdjustedGlyphs = 0;
-
- for (size_t r = 0; r < runCount; ++r) {
- const CoreTextRun& coreTextRun = m_coreTextRuns[r];
- for (unsigned j = 0; j < coreTextRun.glyphCount(); ++j) {
- CGFloat adjustedAdvance = m_adjustedAdvances[offsetIntoAdjustedGlyphs + j].width;
- if (x <= adjustedAdvance) {
- CFIndex hitIndex = coreTextRun.indexAt(j);
- int stringLength = coreTextRun.stringLength();
- TextBreakIterator* characterIterator = characterBreakIterator(coreTextRun.characters(), stringLength);
- int clusterStart;
- if (isTextBreak(characterIterator, hitIndex))
- clusterStart = hitIndex;
- else {
- clusterStart = textBreakPreceding(characterIterator, hitIndex);
- if (clusterStart == TextBreakDone)
- clusterStart = 0;
- }
-
- if (!includePartialGlyphs)
- return coreTextRun.stringLocation() + clusterStart;
-
- int clusterEnd = textBreakFollowing(characterIterator, hitIndex);
- if (clusterEnd == TextBreakDone)
- clusterEnd = stringLength;
-
- CGFloat clusterWidth = adjustedAdvance;
- // FIXME: The search stops at the boundaries of coreTextRun. In theory, it should go on into neighboring CoreTextRuns
- // derived from the same CTLine. In practice, we do not expect there to be more than one CTRun in a CTLine, as no
- // reordering and on font fallback should occur within a CTLine.
- if (clusterEnd - clusterStart > 1) {
- int firstGlyphBeforeCluster = j - 1;
- while (firstGlyphBeforeCluster && coreTextRun.indexAt(firstGlyphBeforeCluster) >= clusterStart && coreTextRun.indexAt(firstGlyphBeforeCluster) < clusterEnd) {
- CGFloat width = m_adjustedAdvances[offsetIntoAdjustedGlyphs + firstGlyphBeforeCluster].width;
- clusterWidth += width;
- x += width;
- firstGlyphBeforeCluster--;
- }
- unsigned firstGlyphAfterCluster = j + 1;
- while (firstGlyphAfterCluster < coreTextRun.glyphCount() && coreTextRun.indexAt(firstGlyphAfterCluster) >= clusterStart && coreTextRun.indexAt(firstGlyphAfterCluster) < clusterEnd) {
- clusterWidth += m_adjustedAdvances[offsetIntoAdjustedGlyphs + firstGlyphAfterCluster].width;
- firstGlyphAfterCluster++;
- }
- }
- if (x <= clusterWidth / 2)
- return coreTextRun.stringLocation() + (m_run.ltr() ? clusterStart : clusterEnd);
- else
- return coreTextRun.stringLocation() + (m_run.ltr() ? clusterEnd : clusterStart);
- }
- x -= adjustedAdvance;
- }
- offsetIntoAdjustedGlyphs += coreTextRun.glyphCount();
- }
-
- ASSERT_NOT_REACHED();
- return 0;
-}
-
-void CoreTextController::collectCoreTextRuns()
-{
- if (!m_end)
- return;
-
- // We break up glyph run generation for the string by FontData and (if needed) the use of small caps.
- const UChar* cp = m_run.characters();
- bool hasTrailingSoftHyphen = m_run[m_end - 1] == softHyphen;
-
- if (m_font.isSmallCaps() || hasTrailingSoftHyphen)
- m_smallCapsBuffer.resize(m_end);
-
- unsigned indexOfFontTransition = m_run.rtl() ? m_end - 1 : 0;
- const UChar* curr = m_run.rtl() ? cp + m_end - 1 : cp;
- const UChar* end = m_run.rtl() ? cp - 1 : cp + m_end;
-
- // FIXME: Using HYPHEN-MINUS rather than HYPHEN because Times has a HYPHEN-MINUS glyph that looks like its
- // SOFT-HYPHEN glyph, and has no HYPHEN glyph.
- static const UChar hyphen = '-';
-
- if (hasTrailingSoftHyphen && m_run.rtl()) {
- collectCoreTextRunsForCharacters(&hyphen, 1, m_end - 1, m_font.glyphDataForCharacter(hyphen, false).fontData);
- indexOfFontTransition--;
- curr--;
- }
-
- GlyphData glyphData;
- GlyphData nextGlyphData;
-
- bool isSurrogate = U16_IS_SURROGATE(*curr);
- if (isSurrogate) {
- if (m_run.ltr()) {
- if (!U16_IS_SURROGATE_LEAD(curr[0]) || curr + 1 == end || !U16_IS_TRAIL(curr[1]))
- return;
- nextGlyphData = m_font.glyphDataForCharacter(U16_GET_SUPPLEMENTARY(curr[0], curr[1]), false);
- } else {
- if (!U16_IS_TRAIL(curr[0]) || curr -1 == end || !U16_IS_SURROGATE_LEAD(curr[-1]))
- return;
- nextGlyphData = m_font.glyphDataForCharacter(U16_GET_SUPPLEMENTARY(curr[-1], curr[0]), false);
- }
- } else
- nextGlyphData = m_font.glyphDataForCharacter(*curr, false);
-
- UChar newC = 0;
-
- bool isSmallCaps;
- bool nextIsSmallCaps = !isSurrogate && m_font.isSmallCaps() && !(U_GET_GC_MASK(*curr) & U_GC_M_MASK) && (newC = u_toupper(*curr)) != *curr;
-
- if (nextIsSmallCaps)
- m_smallCapsBuffer[curr - cp] = newC;
-
- while (true) {
- curr = m_run.rtl() ? curr - (isSurrogate ? 2 : 1) : curr + (isSurrogate ? 2 : 1);
- if (curr == end)
- break;
-
- glyphData = nextGlyphData;
- isSmallCaps = nextIsSmallCaps;
- int index = curr - cp;
- isSurrogate = U16_IS_SURROGATE(*curr);
- UChar c = *curr;
- bool forceSmallCaps = !isSurrogate && isSmallCaps && (U_GET_GC_MASK(c) & U_GC_M_MASK);
- if (isSurrogate) {
- if (m_run.ltr()) {
- if (!U16_IS_SURROGATE_LEAD(curr[0]) || curr + 1 == end || !U16_IS_TRAIL(curr[1]))
- return;
- nextGlyphData = m_font.glyphDataForCharacter(U16_GET_SUPPLEMENTARY(curr[0], curr[1]), false);
- } else {
- if (!U16_IS_TRAIL(curr[0]) || curr -1 == end || !U16_IS_SURROGATE_LEAD(curr[-1]))
- return;
- nextGlyphData = m_font.glyphDataForCharacter(U16_GET_SUPPLEMENTARY(curr[-1], curr[0]), false);
- }
- } else
- nextGlyphData = m_font.glyphDataForCharacter(*curr, false, forceSmallCaps);
-
- if (!isSurrogate && m_font.isSmallCaps()) {
- nextIsSmallCaps = forceSmallCaps || (newC = u_toupper(c)) != c;
- if (nextIsSmallCaps)
- m_smallCapsBuffer[index] = forceSmallCaps ? c : newC;
- }
-
- if (nextGlyphData.fontData != glyphData.fontData || nextIsSmallCaps != isSmallCaps || !nextGlyphData.glyph != !glyphData.glyph) {
- int itemStart = m_run.rtl() ? index + 1 : indexOfFontTransition;
- int itemLength = m_run.rtl() ? indexOfFontTransition - index : index - indexOfFontTransition;
- collectCoreTextRunsForCharacters((isSmallCaps ? m_smallCapsBuffer.data() : cp) + itemStart, itemLength, itemStart, glyphData.glyph ? glyphData.fontData : 0);
- indexOfFontTransition = index;
- }
- }
-
- int itemLength = m_run.rtl() ? indexOfFontTransition + 1 : m_end - indexOfFontTransition - (hasTrailingSoftHyphen ? 1 : 0);
- if (itemLength) {
- int itemStart = m_run.rtl() ? 0 : indexOfFontTransition;
- collectCoreTextRunsForCharacters((nextIsSmallCaps ? m_smallCapsBuffer.data() : cp) + itemStart, itemLength, itemStart, nextGlyphData.glyph ? nextGlyphData.fontData : 0);
- }
-
- if (hasTrailingSoftHyphen && m_run.ltr())
- collectCoreTextRunsForCharacters(&hyphen, 1, m_end - 1, m_font.glyphDataForCharacter(hyphen, false).fontData);
-}
-
-void CoreTextController::advance(unsigned offset, GlyphBuffer* glyphBuffer)
-{
- // FIXME: For offsets falling inside a ligature, we should advance only as far as the appropriate "ligature caret"
- // or divide the width of the ligature by the number of offsets it encompasses and make an advance proportional
- // to the offsets into the ligature. However, Core Text does not expose a low-level API for
- // directly finding out how many characters a ligature encompasses (the "attachment count").
- if (static_cast<int>(offset) > m_end)
- offset = m_end;
-
- if (offset <= m_currentCharacter)
- return;
-
- m_currentCharacter = offset;
-
- size_t runCount = m_coreTextRuns.size();
-
- bool ltr = m_run.ltr();
-
- unsigned k = ltr ? m_numGlyphsSoFar : m_adjustedGlyphs.size() - 1 - m_numGlyphsSoFar;
- while (m_currentRun < runCount) {
- const CoreTextRun& coreTextRun = m_coreTextRuns[ltr ? m_currentRun : runCount - 1 - m_currentRun];
- size_t glyphCount = coreTextRun.glyphCount();
- unsigned g = ltr ? m_glyphInCurrentRun : glyphCount - 1 - m_glyphInCurrentRun;
- while (m_glyphInCurrentRun < glyphCount) {
- if (coreTextRun.indexAt(g) + coreTextRun.stringLocation() >= m_currentCharacter)
- return;
- CGSize adjustedAdvance = m_adjustedAdvances[k];
- if (glyphBuffer)
- glyphBuffer->add(m_adjustedGlyphs[k], coreTextRun.fontData(), adjustedAdvance);
- m_runWidthSoFar += adjustedAdvance.width;
- m_numGlyphsSoFar++;
- m_glyphInCurrentRun++;
- if (ltr) {
- g++;
- k++;
- } else {
- g--;
- k--;
- }
- }
- m_currentRun++;
- m_glyphInCurrentRun = 0;
- }
- if (!ltr && m_numGlyphsSoFar == m_adjustedAdvances.size())
- m_runWidthSoFar += m_finalRoundingWidth;
-}
-
-void CoreTextController::collectCoreTextRunsForCharacters(const UChar* cp, unsigned length, unsigned stringLocation, const SimpleFontData* fontData)
-{
- if (!fontData) {
- // Create a run of missing glyphs from the primary font.
- m_coreTextRuns.append(CoreTextRun(m_font.primaryFont(), cp, stringLocation, length, m_run.ltr()));
- return;
- }
-
- RetainPtr<CFStringRef> string(AdoptCF, CFStringCreateWithCharactersNoCopy(NULL, cp, length, kCFAllocatorNull));
-
- RetainPtr<CFAttributedStringRef> attributedString(AdoptCF, CFAttributedStringCreate(NULL, string.get(), fontData->getCFStringAttributes()));
-
- RetainPtr<CTTypesetterRef> typesetter;
-
- if (!m_mayUseNaturalWritingDirection || m_run.directionalOverride()) {
- static const void* optionKeys[] = { kCTTypesetterOptionForcedEmbeddingLevel };
- static const void* ltrOptionValues[] = { kCFBooleanFalse };
- static const void* rtlOptionValues[] = { kCFBooleanTrue };
- static RetainPtr<CFDictionaryRef> ltrTypesetterOptions(AdoptCF, CFDictionaryCreate(kCFAllocatorDefault, optionKeys, ltrOptionValues, sizeof(optionKeys) / sizeof(*optionKeys), &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
- static RetainPtr<CFDictionaryRef> rtlTypesetterOptions(AdoptCF, CFDictionaryCreate(kCFAllocatorDefault, optionKeys, rtlOptionValues, sizeof(optionKeys) / sizeof(*optionKeys), &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
- typesetter.adoptCF(CTTypesetterCreateWithAttributedStringAndOptions(attributedString.get(), m_run.ltr() ? ltrTypesetterOptions.get() : rtlTypesetterOptions.get()));
- } else
- typesetter.adoptCF(CTTypesetterCreateWithAttributedString(attributedString.get()));
-
- RetainPtr<CTLineRef> line(AdoptCF, CTTypesetterCreateLine(typesetter.get(), CFRangeMake(0, 0)));
-
- CFArrayRef runArray = CTLineGetGlyphRuns(line.get());
-
- CFIndex runCount = CFArrayGetCount(runArray);
-
- for (CFIndex r = 0; r < runCount; r++) {
- CTRunRef ctRun = static_cast<CTRunRef>(CFArrayGetValueAtIndex(runArray, r));
- ASSERT(CFGetTypeID(ctRun) == CTRunGetTypeID());
- m_coreTextRuns.append(CoreTextRun(ctRun, fontData, cp, stringLocation, length));
- }
-}
-
-void CoreTextController::adjustGlyphsAndAdvances()
-{
- size_t runCount = m_coreTextRuns.size();
- for (size_t r = 0; r < runCount; ++r) {
- const CoreTextRun& coreTextRun = m_coreTextRuns[r];
- unsigned glyphCount = coreTextRun.glyphCount();
- const SimpleFontData* fontData = coreTextRun.fontData();
-
- Vector<CGGlyph, 256> glyphsVector;
- const CGGlyph* glyphs;
-
- Vector<CGSize, 256> advancesVector;
- const CGSize* advances;
-
- if (coreTextRun.ctRun()) {
- glyphs = CTRunGetGlyphsPtr(coreTextRun.ctRun());
- if (!glyphs) {
- glyphsVector.grow(glyphCount);
- CTRunGetGlyphs(coreTextRun.ctRun(), CFRangeMake(0, 0), glyphsVector.data());
- glyphs = glyphsVector.data();
- }
-
- advances = CTRunGetAdvancesPtr(coreTextRun.ctRun());
- if (!advances) {
- advancesVector.grow(glyphCount);
- CTRunGetAdvances(coreTextRun.ctRun(), CFRangeMake(0, 0), advancesVector.data());
- advances = advancesVector.data();
- }
- } else {
- // Synthesize a run of missing glyphs.
- glyphsVector.fill(0, glyphCount);
- glyphs = glyphsVector.data();
- advancesVector.fill(CGSizeMake(fontData->widthForGlyph(0), 0), glyphCount);
- advances = advancesVector.data();
- }
-
- bool lastRun = r + 1 == runCount;
- const UChar* cp = coreTextRun.characters();
- CGFloat roundedSpaceWidth = roundCGFloat(fontData->m_spaceWidth);
- bool roundsAdvances = !m_font.isPrinterFont() && fontData->platformData().roundsGlyphAdvances();
- bool hasExtraSpacing = (m_font.letterSpacing() || m_font.wordSpacing() || m_padding) && !m_run.spacingDisabled();
-
-
- for (unsigned i = 0; i < glyphCount; i++) {
- CFIndex characterIndex = coreTextRun.indexAt(i);
- UChar ch = *(cp + characterIndex);
- bool lastGlyph = lastRun && i + 1 == glyphCount;
- UChar nextCh;
- if (lastGlyph)
- nextCh = ' ';
- else if (i + 1 < glyphCount)
- nextCh = *(cp + coreTextRun.indexAt(i + 1));
- else
- nextCh = *(m_coreTextRuns[r + 1].characters() + m_coreTextRuns[r + 1].indexAt(0));
-
- bool treatAsSpace = Font::treatAsSpace(ch);
- CGGlyph glyph = treatAsSpace ? fontData->m_spaceGlyph : glyphs[i];
- CGSize advance = treatAsSpace ? CGSizeMake(fontData->m_spaceWidth, advances[i].height) : advances[i];
-
- if (ch == '\t' && m_run.allowTabs()) {
- float tabWidth = m_font.tabWidth();
- advance.width = tabWidth - fmodf(m_run.xPos() + m_totalWidth, tabWidth);
- } else if (ch == zeroWidthSpace || Font::treatAsZeroWidthSpace(ch) && !treatAsSpace) {
- advance.width = 0;
- glyph = fontData->m_spaceGlyph;
- }
-
- float roundedAdvanceWidth = roundf(advance.width);
- if (roundsAdvances)
- advance.width = roundedAdvanceWidth;
-
- advance.width += fontData->m_syntheticBoldOffset;
-
- // We special case spaces in two ways when applying word rounding.
- // First, we round spaces to an adjusted width in all fonts.
- // Second, in fixed-pitch fonts we ensure that all glyphs that
- // match the width of the space glyph have the same width as the space glyph.
- if (roundedAdvanceWidth == roundedSpaceWidth && (fontData->m_treatAsFixedPitch || glyph == fontData->m_spaceGlyph) && m_run.applyWordRounding())
- advance.width = fontData->m_adjustedSpaceWidth;
-
- if (hasExtraSpacing) {
- // If we're a glyph with an advance, go ahead and add in letter-spacing.
- // That way we weed out zero width lurkers. This behavior matches the fast text code path.
- if (advance.width && m_font.letterSpacing())
- advance.width += m_font.letterSpacing();
-
- // Handle justification and word-spacing.
- if (glyph == fontData->m_spaceGlyph) {
- // Account for padding. WebCore uses space padding to justify text.
- // We distribute the specified padding over the available spaces in the run.
- if (m_padding) {
- // Use leftover padding if not evenly divisible by number of spaces.
- if (m_padding < m_padPerSpace) {
- advance.width += m_padding;
- m_padding = 0;
- } else {
- advance.width += m_padPerSpace;
- m_padding -= m_padPerSpace;
- }
- }
-
- // Account for word-spacing.
- if (treatAsSpace && characterIndex > 0 && !Font::treatAsSpace(*m_run.data(characterIndex - 1)) && m_font.wordSpacing())
- advance.width += m_font.wordSpacing();
- }
- }
-
- // Deal with the float/integer impedance mismatch between CG and WebCore. "Words" (characters
- // followed by a character defined by isRoundingHackCharacter()) are always an integer width.
- // We adjust the width of the last character of a "word" to ensure an integer width.
- // Force characters that are used to determine word boundaries for the rounding hack
- // to be integer width, so the following words will start on an integer boundary.
- if (m_run.applyWordRounding() && Font::isRoundingHackCharacter(ch))
- advance.width = ceilCGFloat(advance.width);
-
- // Check to see if the next character is a "rounding hack character", if so, adjust the
- // width so that the total run width will be on an integer boundary.
- if (m_run.applyWordRounding() && !lastGlyph && Font::isRoundingHackCharacter(nextCh) || m_run.applyRunRounding() && lastGlyph) {
- CGFloat totalWidth = m_totalWidth + advance.width;
- CGFloat extraWidth = ceilCGFloat(totalWidth) - totalWidth;
- if (m_run.ltr())
- advance.width += extraWidth;
- else {
- m_totalWidth += extraWidth;
- if (m_lastRoundingGlyph)
- m_adjustedAdvances[m_lastRoundingGlyph - 1].width += extraWidth;
- else
- m_finalRoundingWidth = extraWidth;
- m_lastRoundingGlyph = m_adjustedAdvances.size() + 1;
- }
- }
-
- m_totalWidth += advance.width;
- advance.height *= -1;
- m_adjustedAdvances.append(advance);
- m_adjustedGlyphs.append(glyph);
- }
- }
-}
-
-} // namespace WebCore
-
-#endif // USE(CORE_TEXT)
diff --git a/WebCore/platform/graphics/mac/CoreTextController.h b/WebCore/platform/graphics/mac/CoreTextController.h
deleted file mode 100644
index 8dbb7fb..0000000
--- a/WebCore/platform/graphics/mac/CoreTextController.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (C) 2007, 2008 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef CoreTextController_h
-#define CoreTextController_h
-
-#if USE(CORE_TEXT)
-
-#include "Font.h"
-#include "GlyphBuffer.h"
-#include <wtf/RetainPtr.h>
-#include <wtf/Vector.h>
-
-namespace WebCore {
-
-class CoreTextController {
-public:
- CoreTextController(const Font*, const TextRun&, bool mayUseNaturalWritingDirection = false);
-
- // Advance and emit glyphs up to the specified character.
- void advance(unsigned to, GlyphBuffer* = 0);
-
- // Compute the character offset for a given x coordinate.
- int offsetForPosition(int x, bool includePartialGlyphs);
-
- // Returns the width of everything we've consumed so far.
- float runWidthSoFar() const { return m_runWidthSoFar; }
-
- float totalWidth() const { return m_totalWidth; }
-
- // Extra width to the left of the leftmost glyph.
- float finalRoundingWidth() const { return m_finalRoundingWidth; }
-
-private:
- class CoreTextRun {
- public:
- CoreTextRun(CTRunRef, const SimpleFontData*, const UChar* characters, unsigned stringLocation, size_t stringLength);
- CoreTextRun(const SimpleFontData*, const UChar* characters, unsigned stringLocation, size_t stringLength, bool ltr);
-
- CTRunRef ctRun() const { return m_CTRun.get(); }
- unsigned glyphCount() const { return m_glyphCount; }
- const SimpleFontData* fontData() const { return m_fontData; }
- const UChar* characters() const { return m_characters; }
- unsigned stringLocation() const { return m_stringLocation; }
- size_t stringLength() const { return m_stringLength; }
- CFIndex indexAt(size_t i) const { return m_indices[i]; }
-
- private:
- RetainPtr<CTRunRef> m_CTRun;
- unsigned m_glyphCount;
- const SimpleFontData* m_fontData;
- const UChar* m_characters;
- unsigned m_stringLocation;
- size_t m_stringLength;
- const CFIndex* m_indices;
- // Used only if CTRunGet*Ptr fails or if this is a missing glyphs run.
- RetainPtr<CFMutableDataRef> m_indicesData;
- };
-
- void collectCoreTextRuns();
- void collectCoreTextRunsForCharacters(const UChar*, unsigned length, unsigned stringLocation, const SimpleFontData*);
- void adjustGlyphsAndAdvances();
-
- const Font& m_font;
- const TextRun& m_run;
- bool m_mayUseNaturalWritingDirection;
-
- Vector<UChar, 256> m_smallCapsBuffer;
-
- Vector<CoreTextRun, 16> m_coreTextRuns;
- Vector<CGSize, 256> m_adjustedAdvances;
- Vector<CGGlyph, 256> m_adjustedGlyphs;
-
- unsigned m_currentCharacter;
- int m_end;
-
- CGFloat m_totalWidth;
-
- float m_runWidthSoFar;
- unsigned m_numGlyphsSoFar;
- size_t m_currentRun;
- unsigned m_glyphInCurrentRun;
- float m_finalRoundingWidth;
- float m_padding;
- float m_padPerSpace;
-
- unsigned m_lastRoundingGlyph;
-};
-
-} // namespace WebCore
-#endif // USE(CORE_TEXT)
-#endif // CoreTextController_h
diff --git a/WebCore/platform/graphics/mac/FloatPointMac.mm b/WebCore/platform/graphics/mac/FloatPointMac.mm
deleted file mode 100644
index 2f73314..0000000
--- a/WebCore/platform/graphics/mac/FloatPointMac.mm
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2005 Nokia. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FloatPoint.h"
-
-namespace WebCore {
-
-#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
-
-FloatPoint::FloatPoint(const NSPoint& p) : m_x(p.x), m_y(p.y)
-{
-}
-
-FloatPoint::operator NSPoint() const
-{
- return NSMakePoint(m_x, m_y);
-}
-
-#endif
-
-}
diff --git a/WebCore/platform/graphics/mac/FloatRectMac.mm b/WebCore/platform/graphics/mac/FloatRectMac.mm
deleted file mode 100644
index 1d6b045..0000000
--- a/WebCore/platform/graphics/mac/FloatRectMac.mm
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2005 Nokia. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FloatRect.h"
-
-namespace WebCore {
-
-#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
-
-FloatRect::FloatRect(const NSRect& r) : m_location(r.origin), m_size(r.size)
-{
-}
-
-FloatRect::operator NSRect() const
-{
- return NSMakeRect(x(), y(), width(), height());
-}
-
-#endif
-
-}
diff --git a/WebCore/platform/graphics/mac/FloatSizeMac.mm b/WebCore/platform/graphics/mac/FloatSizeMac.mm
deleted file mode 100644
index 01efbe9..0000000
--- a/WebCore/platform/graphics/mac/FloatSizeMac.mm
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2005 Nokia. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FloatSize.h"
-
-namespace WebCore {
-
-#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
-
-FloatSize::FloatSize(const NSSize& s) : m_width(s.width), m_height(s.height)
-{
-}
-
-FloatSize::operator NSSize() const
-{
- return NSMakeSize(m_width, m_height);
-}
-
-#endif
-
-}
diff --git a/WebCore/platform/graphics/mac/FontCacheMac.mm b/WebCore/platform/graphics/mac/FontCacheMac.mm
deleted file mode 100644
index e7cda66..0000000
--- a/WebCore/platform/graphics/mac/FontCacheMac.mm
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "FontCache.h"
-
-#import "Font.h"
-#import "SimpleFontData.h"
-#import "FontPlatformData.h"
-#import "WebCoreSystemInterface.h"
-#import "WebFontCache.h"
-
-#ifdef BUILDING_ON_TIGER
-typedef int NSInteger;
-#endif
-
-namespace WebCore {
-
-static void fontCacheATSNotificationCallback(ATSFontNotificationInfoRef, void*)
-{
- FontCache::invalidate();
-}
-
-void FontCache::platformInit()
-{
- wkSetUpFontCache();
- // FIXME: Passing kATSFontNotifyOptionReceiveWhileSuspended may be an overkill and does not seem to work anyway.
- ATSFontNotificationSubscribe(fontCacheATSNotificationCallback, kATSFontNotifyOptionReceiveWhileSuspended, 0, 0);
-}
-
-static int toAppKitFontWeight(FontWeight fontWeight)
-{
- static int appKitFontWeights[] = {
- 2, // FontWeight100
- 3, // FontWeight200
- 4, // FontWeight300
- 5, // FontWeight400
- 6, // FontWeight500
- 8, // FontWeight600
- 9, // FontWeight700
- 10, // FontWeight800
- 12, // FontWeight900
- };
- return appKitFontWeights[fontWeight];
-}
-
-static inline bool isAppKitFontWeightBold(NSInteger appKitFontWeight)
-{
- return appKitFontWeight >= 7;
-}
-
-const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
-{
- const FontPlatformData& platformData = font.fontDataAt(0)->fontDataForCharacter(characters[0])->platformData();
- NSFont *nsFont = platformData.font();
-
- NSString *string = [[NSString alloc] initWithCharactersNoCopy:const_cast<UChar*>(characters) length:length freeWhenDone:NO];
- NSFont *substituteFont = wkGetFontInLanguageForRange(nsFont, string, NSMakeRange(0, length));
- [string release];
-
- if (!substituteFont && length == 1)
- substituteFont = wkGetFontInLanguageForCharacter(nsFont, characters[0]);
- if (!substituteFont)
- return 0;
-
- // Use the family name from the AppKit-supplied substitute font, requesting the
- // traits, weight, and size we want. One way this does better than the original
- // AppKit request is that it takes synthetic bold and oblique into account.
- // But it does create the possibility that we could end up with a font that
- // doesn't actually cover the characters we need.
-
- NSFontManager *fontManager = [NSFontManager sharedFontManager];
-
- NSFontTraitMask traits;
- NSInteger weight;
- CGFloat size;
-
- if (nsFont) {
- traits = [fontManager traitsOfFont:nsFont];
- if (platformData.m_syntheticBold)
- traits |= NSBoldFontMask;
- if (platformData.m_syntheticOblique)
- traits |= NSFontItalicTrait;
- weight = [fontManager weightOfFont:nsFont];
- size = [nsFont pointSize];
- } else {
- // For custom fonts nsFont is nil.
- traits = font.italic() ? NSFontItalicTrait : 0;
- weight = toAppKitFontWeight(font.weight());
- size = font.pixelSize();
- }
-
- if (NSFont *bestVariation = [fontManager fontWithFamily:[substituteFont familyName] traits:traits weight:weight size:size])
- substituteFont = bestVariation;
-
- substituteFont = font.fontDescription().usePrinterFont() ? [substituteFont printerFont] : [substituteFont screenFont];
-
- NSFontTraitMask substituteFontTraits = [fontManager traitsOfFont:substituteFont];
- NSInteger substituteFontWeight = [fontManager weightOfFont:substituteFont];
-
- FontPlatformData alternateFont(substituteFont,
- !font.isPlatformFont() && isAppKitFontWeightBold(weight) && !isAppKitFontWeightBold(substituteFontWeight),
- !font.isPlatformFont() && (traits & NSFontItalicTrait) && !(substituteFontTraits & NSFontItalicTrait));
- return getCachedFontData(&alternateFont);
-}
-
-FontPlatformData* FontCache::getSimilarFontPlatformData(const Font& font)
-{
- // Attempt to find an appropriate font using a match based on
- // the presence of keywords in the the requested names. For example, we'll
- // match any name that contains "Arabic" to Geeza Pro.
- FontPlatformData* platformData = 0;
- const FontFamily* currFamily = &font.fontDescription().family();
- while (currFamily && !platformData) {
- if (currFamily->family().length()) {
- static String matchWords[3] = { String("Arabic"), String("Pashto"), String("Urdu") };
- static AtomicString geezaStr("Geeza Pro");
- for (int j = 0; j < 3 && !platformData; ++j)
- if (currFamily->family().contains(matchWords[j], false))
- platformData = getCachedFontPlatformData(font.fontDescription(), geezaStr);
- }
- currFamily = currFamily->next();
- }
-
- return platformData;
-}
-
-FontPlatformData* FontCache::getLastResortFallbackFont(const FontDescription& fontDescription)
-{
- static AtomicString timesStr("Times");
- static AtomicString lucidaGrandeStr("Lucida Grande");
-
- // FIXME: Would be even better to somehow get the user's default font here. For now we'll pick
- // the default that the user would get without changing any prefs.
- FontPlatformData* platformFont = getCachedFontPlatformData(fontDescription, timesStr);
- if (!platformFont)
- // The Times fallback will almost always work, but in the highly unusual case where
- // the user doesn't have it, we fall back on Lucida Grande because that's
- // guaranteed to be there, according to Nathan Taylor. This is good enough
- // to avoid a crash at least.
- platformFont = getCachedFontPlatformData(fontDescription, lucidaGrandeStr);
-
- return platformFont;
-}
-
-void FontCache::getTraitsInFamily(const AtomicString& familyName, Vector<unsigned>& traitsMasks)
-{
- [WebFontCache getTraits:traitsMasks inFamily:familyName];
-}
-
-FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
-{
- NSFontTraitMask traits = fontDescription.italic() ? NSFontItalicTrait : 0;
- NSInteger weight = toAppKitFontWeight(fontDescription.weight());
- float size = fontDescription.computedPixelSize();
-
- NSFont *nsFont = [WebFontCache fontWithFamily:family traits:traits weight:weight size:size];
- if (!nsFont)
- return 0;
-
- NSFontManager *fontManager = [NSFontManager sharedFontManager];
- NSFontTraitMask actualTraits = 0;
- if (fontDescription.italic())
- actualTraits = [fontManager traitsOfFont:nsFont];
- NSInteger actualWeight = [fontManager weightOfFont:nsFont];
-
- FontPlatformData* result = new FontPlatformData;
-
- // Use the correct font for print vs. screen.
- result->setFont(fontDescription.usePrinterFont() ? [nsFont printerFont] : [nsFont screenFont]);
- result->m_syntheticBold = isAppKitFontWeightBold(weight) && !isAppKitFontWeightBold(actualWeight);
- result->m_syntheticOblique = (traits & NSFontItalicTrait) && !(actualTraits & NSFontItalicTrait);
- return result;
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp b/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp
deleted file mode 100644
index 1fb144c..0000000
--- a/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Computer, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "FontCustomPlatformData.h"
-
-#include <ApplicationServices/ApplicationServices.h>
-#include "SharedBuffer.h"
-#include "FontPlatformData.h"
-
-namespace WebCore {
-
-FontCustomPlatformData::~FontCustomPlatformData()
-{
- ATSFontDeactivate(m_atsContainer, NULL, kATSOptionFlagsDefault);
- CGFontRelease(m_cgFont);
-}
-
-FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontRenderingMode)
-{
- return FontPlatformData(m_cgFont, (ATSUFontID)m_atsFont, size, bold, italic);
-}
-
-FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer)
-{
- ASSERT_ARG(buffer, buffer);
-
- // Use ATS to activate the font.
- ATSFontContainerRef containerRef = 0;
-
- // The value "3" means that the font is private and can't be seen by anyone else.
- ATSFontActivateFromMemory((void*)buffer->data(), buffer->size(), 3, kATSFontFormatUnspecified, NULL, kATSOptionFlagsDefault, &containerRef);
- if (!containerRef)
- return 0;
- ItemCount fontCount;
- ATSFontFindFromContainer(containerRef, kATSOptionFlagsDefault, 0, NULL, &fontCount);
-
- // We just support the first font in the list.
- if (fontCount == 0) {
- ATSFontDeactivate(containerRef, NULL, kATSOptionFlagsDefault);
- return 0;
- }
-
- ATSFontRef fontRef = 0;
- ATSFontFindFromContainer(containerRef, kATSOptionFlagsDefault, 1, &fontRef, NULL);
- if (!fontRef) {
- ATSFontDeactivate(containerRef, NULL, kATSOptionFlagsDefault);
- return 0;
- }
-
- CGFontRef cgFontRef = CGFontCreateWithPlatformFont(&fontRef);
-#ifndef BUILDING_ON_TIGER
- // Workaround for <rdar://problem/5675504>.
- if (!CGFontGetNumberOfGlyphs(cgFontRef)) {
- CFRelease(cgFontRef);
- cgFontRef = 0;
- }
-#endif
- if (!cgFontRef) {
- ATSFontDeactivate(containerRef, NULL, kATSOptionFlagsDefault);
- return 0;
- }
-
- return new FontCustomPlatformData(containerRef, fontRef, cgFontRef);
-}
-
-}
diff --git a/WebCore/platform/graphics/mac/FontCustomPlatformData.h b/WebCore/platform/graphics/mac/FontCustomPlatformData.h
deleted file mode 100644
index 1e73ae0..0000000
--- a/WebCore/platform/graphics/mac/FontCustomPlatformData.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Computer, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef FontCustomPlatformData_h
-#define FontCustomPlatformData_h
-
-#include "FontRenderingMode.h"
-#include <wtf/Noncopyable.h>
-
-typedef struct CGFont* CGFontRef;
-typedef UInt32 ATSFontContainerRef;
-typedef UInt32 ATSFontRef;
-
-namespace WebCore {
-
-class FontPlatformData;
-class SharedBuffer;
-
-struct FontCustomPlatformData : Noncopyable {
- FontCustomPlatformData(ATSFontContainerRef container, ATSFontRef atsFont, CGFontRef cgFont)
- : m_atsContainer(container), m_atsFont(atsFont), m_cgFont(cgFont)
- {}
- ~FontCustomPlatformData();
-
- FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontRenderingMode = NormalRenderingMode);
-
- ATSFontContainerRef m_atsContainer;
- ATSFontRef m_atsFont;
- CGFontRef m_cgFont;
-};
-
-FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer);
-
-}
-
-#endif
diff --git a/WebCore/platform/graphics/mac/FontMac.mm b/WebCore/platform/graphics/mac/FontMac.mm
deleted file mode 100644
index bef18d0..0000000
--- a/WebCore/platform/graphics/mac/FontMac.mm
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
- * (C) 1999 Antti Koivisto (koivisto@kde.org)
- * (C) 2000 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2003, 2006 Apple Computer, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#import "config.h"
-#import "Font.h"
-
-#import "GlyphBuffer.h"
-#import "GraphicsContext.h"
-#import "Logging.h"
-#import "SimpleFontData.h"
-#import "WebCoreSystemInterface.h"
-#import "WebCoreTextRenderer.h"
-
-#define SYNTHETIC_OBLIQUE_ANGLE 14
-
-#ifdef __LP64__
-#define URefCon void*
-#else
-#define URefCon UInt32
-#endif
-
-using namespace std;
-
-namespace WebCore {
-
-void Font::drawGlyphs(GraphicsContext* context, const SimpleFontData* font, const GlyphBuffer& glyphBuffer, int from, int numGlyphs, const FloatPoint& point) const
-{
- CGContextRef cgContext = context->platformContext();
-
- bool originalShouldUseFontSmoothing = wkCGContextGetShouldSmoothFonts(cgContext);
- bool newShouldUseFontSmoothing = WebCoreShouldUseFontSmoothing();
-
- if (originalShouldUseFontSmoothing != newShouldUseFontSmoothing)
- CGContextSetShouldSmoothFonts(cgContext, newShouldUseFontSmoothing);
-
- const FontPlatformData& platformData = font->platformData();
- NSFont* drawFont;
- if (!isPrinterFont()) {
- drawFont = [platformData.font() screenFont];
- if (drawFont != platformData.font())
- // We are getting this in too many places (3406411); use ERROR so it only prints on debug versions for now. (We should debug this also, eventually).
- LOG_ERROR("Attempting to set non-screen font (%@) when drawing to screen. Using screen font anyway, may result in incorrect metrics.",
- [[[platformData.font() fontDescriptor] fontAttributes] objectForKey:NSFontNameAttribute]);
- } else {
- drawFont = [platformData.font() printerFont];
- if (drawFont != platformData.font())
- NSLog(@"Attempting to set non-printer font (%@) when printing. Using printer font anyway, may result in incorrect metrics.",
- [[[platformData.font() fontDescriptor] fontAttributes] objectForKey:NSFontNameAttribute]);
- }
-
- CGContextSetFont(cgContext, platformData.cgFont());
-
- CGAffineTransform matrix = CGAffineTransformIdentity;
- if (drawFont)
- memcpy(&matrix, [drawFont matrix], sizeof(matrix));
- matrix.b = -matrix.b;
- matrix.d = -matrix.d;
- if (platformData.m_syntheticOblique)
- matrix = CGAffineTransformConcat(matrix, CGAffineTransformMake(1, 0, -tanf(SYNTHETIC_OBLIQUE_ANGLE * acosf(0) / 90), 1, 0, 0));
- CGContextSetTextMatrix(cgContext, matrix);
-
- if (drawFont) {
- wkSetCGFontRenderingMode(cgContext, drawFont);
- CGContextSetFontSize(cgContext, 1.0f);
- } else
- CGContextSetFontSize(cgContext, platformData.m_size);
-
- IntSize shadowSize;
- int shadowBlur;
- Color shadowColor;
- context->getShadow(shadowSize, shadowBlur, shadowColor);
-
- bool hasSimpleShadow = context->textDrawingMode() == cTextFill && shadowColor.isValid() && !shadowBlur;
- if (hasSimpleShadow) {
- // Paint simple shadows ourselves instead of relying on CG shadows, to avoid losing subpixel antialiasing.
- context->clearShadow();
- Color fillColor = context->fillColor();
- Color shadowFillColor(shadowColor.red(), shadowColor.green(), shadowColor.blue(), shadowColor.alpha() * fillColor.alpha() / 255);
- context->setFillColor(shadowFillColor);
- CGContextSetTextPosition(cgContext, point.x() + shadowSize.width(), point.y() + shadowSize.height());
- CGContextShowGlyphsWithAdvances(cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs);
- if (font->m_syntheticBoldOffset) {
- CGContextSetTextPosition(cgContext, point.x() + shadowSize.width() + font->m_syntheticBoldOffset, point.y() + shadowSize.height());
- CGContextShowGlyphsWithAdvances(cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs);
- }
- context->setFillColor(fillColor);
- }
-
- CGContextSetTextPosition(cgContext, point.x(), point.y());
- CGContextShowGlyphsWithAdvances(cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs);
- if (font->m_syntheticBoldOffset) {
- CGContextSetTextPosition(cgContext, point.x() + font->m_syntheticBoldOffset, point.y());
- CGContextShowGlyphsWithAdvances(cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs);
- }
-
- if (hasSimpleShadow)
- context->setShadow(shadowSize, shadowBlur, shadowColor);
-
- if (originalShouldUseFontSmoothing != newShouldUseFontSmoothing)
- CGContextSetShouldSmoothFonts(cgContext, originalShouldUseFontSmoothing);
-}
-
-}
diff --git a/WebCore/platform/graphics/mac/FontMacATSUI.mm b/WebCore/platform/graphics/mac/FontMacATSUI.mm
deleted file mode 100644
index 9a45c5a..0000000
--- a/WebCore/platform/graphics/mac/FontMacATSUI.mm
+++ /dev/null
@@ -1,623 +0,0 @@
-/*
- * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
- * (C) 1999 Antti Koivisto (koivisto@kde.org)
- * (C) 2000 Dirk Mueller (mueller@kde.org)
- * Copyright (C) 2003, 2006 Apple Computer, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#import "config.h"
-#import "Font.h"
-
-#if USE(ATSUI)
-
-#import "CharacterNames.h"
-#import "GraphicsContext.h"
-#import "Logging.h"
-#import "ShapeArabic.h"
-#import "SimpleFontData.h"
-#import <wtf/OwnArrayPtr.h>
-
-#define SYNTHETIC_OBLIQUE_ANGLE 14
-
-#ifdef __LP64__
-#define URefCon void*
-#else
-#define URefCon UInt32
-#endif
-
-using namespace std;
-
-namespace WebCore {
-
-struct ATSULayoutParameters : Noncopyable
-{
- ATSULayoutParameters(const TextRun& run)
- : m_run(run)
- , m_font(0)
- , m_hasSyntheticBold(false)
- , m_syntheticBoldPass(false)
- , m_padPerSpace(0)
- {}
-
- ~ATSULayoutParameters()
- {
- ATSUDisposeTextLayout(m_layout);
- }
-
- void initialize(const Font*, const GraphicsContext* = 0);
-
- const TextRun& m_run;
-
- const Font* m_font;
-
- ATSUTextLayout m_layout;
- OwnArrayPtr<const SimpleFontData*> m_fonts;
-
- OwnArrayPtr<UChar> m_charBuffer;
- bool m_hasSyntheticBold;
- bool m_syntheticBoldPass;
- float m_padPerSpace;
-};
-
-static TextRun copyRunForDirectionalOverrideIfNecessary(const TextRun& run, OwnArrayPtr<UChar>& charactersWithOverride)
-{
- if (!run.directionalOverride())
- return run;
-
- charactersWithOverride.set(new UChar[run.length() + 2]);
- charactersWithOverride[0] = run.rtl() ? rightToLeftOverride : leftToRightOverride;
- memcpy(&charactersWithOverride[1], run.data(0), sizeof(UChar) * run.length());
- charactersWithOverride[run.length() + 1] = popDirectionalFormatting;
-
- TextRun result = run;
- result.setText(charactersWithOverride.get(), run.length() + 2);
- return result;
-}
-
-static bool fontHasMirroringInfo(ATSUFontID fontID)
-{
- ByteCount propTableSize;
- OSStatus status = ATSFontGetTable(fontID, 'prop', 0, 0, 0, &propTableSize);
- if (status == noErr) // naively assume that if a 'prop' table exists then it contains mirroring info
- return true;
- else if (status != kATSInvalidFontTableAccess) // anything other than a missing table is logged as an error
- LOG_ERROR("ATSFontGetTable failed (%d)", status);
-
- return false;
-}
-
-static void disableLigatures(const SimpleFontData* fontData)
-{
- // Don't be too aggressive: if the font doesn't contain 'a', then assume that any ligatures it contains are
- // in characters that always go through ATSUI, and therefore allow them. Geeza Pro is an example.
- // See bugzilla 5166.
- if (fontData->platformData().allowsLigatures())
- return;
-
- ATSUFontFeatureType featureTypes[] = { kLigaturesType };
- ATSUFontFeatureSelector featureSelectors[] = { kCommonLigaturesOffSelector };
- OSStatus status = ATSUSetFontFeatures(fontData->m_ATSUStyle, 1, featureTypes, featureSelectors);
- if (status != noErr)
- LOG_ERROR("ATSUSetFontFeatures failed (%d) -- ligatures remain enabled", status);
-}
-
-static void initializeATSUStyle(const SimpleFontData* fontData)
-{
- if (fontData->m_ATSUStyleInitialized)
- return;
-
- ATSUFontID fontID = fontData->platformData().m_atsuFontID;
- if (!fontID) {
- LOG_ERROR("unable to get ATSUFontID for %@", fontData->m_font.font());
- return;
- }
-
- OSStatus status = ATSUCreateStyle(&fontData->m_ATSUStyle);
- if (status != noErr)
- // Who knows how many ATSU functions will crash when passed a NULL style...
- LOG_ERROR("ATSUCreateStyle failed (%d)", status);
-
- CGAffineTransform transform = CGAffineTransformMakeScale(1, -1);
- if (fontData->m_font.m_syntheticOblique)
- transform = CGAffineTransformConcat(transform, CGAffineTransformMake(1, 0, -tanf(SYNTHETIC_OBLIQUE_ANGLE * acosf(0) / 90), 1, 0, 0));
- Fixed fontSize = FloatToFixed(fontData->platformData().m_size);
- ByteCount styleSizes[4] = { sizeof(Fixed), sizeof(ATSUFontID), sizeof(CGAffineTransform), sizeof(Fract) };
- // Turn off automatic kerning until it is supported in the CG code path (bug 6136)
- Fract kerningInhibitFactor = FloatToFract(1.0);
-
- ATSUAttributeTag styleTags[4] = { kATSUSizeTag, kATSUFontTag, kATSUFontMatrixTag, kATSUKerningInhibitFactorTag };
- ATSUAttributeValuePtr styleValues[4] = { &fontSize, &fontID, &transform, &kerningInhibitFactor };
- status = ATSUSetAttributes(fontData->m_ATSUStyle, 4, styleTags, styleSizes, styleValues);
- if (status != noErr)
- LOG_ERROR("ATSUSetAttributes failed (%d)", status);
-
- fontData->m_ATSUMirrors = fontHasMirroringInfo(fontID);
-
- // Turn off ligatures such as 'fi' to match the CG code path's behavior, until bug 6135 is fixed.
- disableLigatures(fontData);
-
- fontData->m_ATSUStyleInitialized = true;
-}
-
-static OSStatus overrideLayoutOperation(ATSULayoutOperationSelector iCurrentOperation, ATSULineRef iLineRef, URefCon iRefCon,
- void *iOperationCallbackParameterPtr, ATSULayoutOperationCallbackStatus *oCallbackStatus)
-{
- ATSULayoutParameters* params = reinterpret_cast<ATSULayoutParameters*>(iRefCon);
- OSStatus status;
- ItemCount count;
- ATSLayoutRecord *layoutRecords;
-
- if (params->m_run.applyWordRounding()) {
- status = ATSUDirectGetLayoutDataArrayPtrFromLineRef(iLineRef, kATSUDirectDataLayoutRecordATSLayoutRecordCurrent, true, (void **)&layoutRecords, &count);
- if (status != noErr) {
- *oCallbackStatus = kATSULayoutOperationCallbackStatusContinue;
- return status;
- }
-
- Fixed lastNativePos = 0;
- float lastAdjustedPos = 0;
- const UChar* characters = params->m_charBuffer ? params->m_charBuffer.get() : params->m_run.characters();
- const SimpleFontData** renderers = params->m_fonts.get();
- const SimpleFontData* renderer;
- const SimpleFontData* lastRenderer = 0;
- ByteCount offset = layoutRecords[0].originalOffset;
- UChar nextCh = *(UChar *)(((char *)characters)+offset);
- bool shouldRound = false;
- bool syntheticBoldPass = params->m_syntheticBoldPass;
- Fixed syntheticBoldOffset = 0;
- ATSGlyphRef spaceGlyph = 0;
- bool hasExtraSpacing = (params->m_font->letterSpacing() || params->m_font->wordSpacing() || params->m_run.padding()) && !params->m_run.spacingDisabled();
- float padding = params->m_run.padding();
- // In the CoreGraphics code path, the rounding hack is applied in logical order.
- // Here it is applied in visual left-to-right order, which may be better.
- ItemCount lastRoundingChar = 0;
- ItemCount i;
- for (i = 1; i < count; i++) {
- bool isLastChar = i == count - 1;
- renderer = renderers[offset / 2];
- if (renderer != lastRenderer) {
- lastRenderer = renderer;
- spaceGlyph = renderer->m_spaceGlyph;
- // The CoreGraphics interpretation of NSFontAntialiasedIntegerAdvancementsRenderingMode seems
- // to be "round each glyph's width to the nearest integer". This is not the same as ATSUI
- // does in any of its device-metrics modes.
- shouldRound = renderer->platformData().roundsGlyphAdvances();
- if (syntheticBoldPass)
- syntheticBoldOffset = FloatToFixed(renderer->m_syntheticBoldOffset);
- }
- float width;
- if (nextCh == zeroWidthSpace || Font::treatAsZeroWidthSpace(nextCh) && !Font::treatAsSpace(nextCh)) {
- width = 0;
- layoutRecords[i-1].glyphID = spaceGlyph;
- } else {
- width = FixedToFloat(layoutRecords[i].realPos - lastNativePos);
- if (shouldRound)
- width = roundf(width);
- width += renderer->m_syntheticBoldOffset;
- if (renderer->m_treatAsFixedPitch ? width == renderer->m_spaceWidth : (layoutRecords[i-1].flags & kATSGlyphInfoIsWhiteSpace))
- width = renderer->m_adjustedSpaceWidth;
- }
- lastNativePos = layoutRecords[i].realPos;
-
- if (hasExtraSpacing) {
- if (width && params->m_font->letterSpacing())
- width +=params->m_font->letterSpacing();
- if (Font::treatAsSpace(nextCh)) {
- if (params->m_run.padding()) {
- if (padding < params->m_padPerSpace) {
- width += padding;
- padding = 0;
- } else {
- width += params->m_padPerSpace;
- padding -= params->m_padPerSpace;
- }
- }
- if (offset != 0 && !Font::treatAsSpace(*((UChar *)(((char *)characters)+offset) - 1)) && params->m_font->wordSpacing())
- width += params->m_font->wordSpacing();
- }
- }
-
- UChar ch = nextCh;
- offset = layoutRecords[i].originalOffset;
- // Use space for nextCh at the end of the loop so that we get inside the rounding hack code.
- // We won't actually round unless the other conditions are satisfied.
- nextCh = isLastChar ? ' ' : *(UChar *)(((char *)characters)+offset);
-
- if (Font::isRoundingHackCharacter(ch))
- width = ceilf(width);
- lastAdjustedPos = lastAdjustedPos + width;
- if (Font::isRoundingHackCharacter(nextCh) && (!isLastChar || params->m_run.applyRunRounding())){
- if (params->m_run.ltr())
- lastAdjustedPos = ceilf(lastAdjustedPos);
- else {
- float roundingWidth = ceilf(lastAdjustedPos) - lastAdjustedPos;
- Fixed rw = FloatToFixed(roundingWidth);
- ItemCount j;
- for (j = lastRoundingChar; j < i; j++)
- layoutRecords[j].realPos += rw;
- lastRoundingChar = i;
- lastAdjustedPos += roundingWidth;
- }
- }
- if (syntheticBoldPass) {
- if (syntheticBoldOffset)
- layoutRecords[i-1].realPos += syntheticBoldOffset;
- else
- layoutRecords[i-1].glyphID = spaceGlyph;
- }
- layoutRecords[i].realPos = FloatToFixed(lastAdjustedPos);
- }
-
- status = ATSUDirectReleaseLayoutDataArrayPtr(iLineRef, kATSUDirectDataLayoutRecordATSLayoutRecordCurrent, (void **)&layoutRecords);
- }
- *oCallbackStatus = kATSULayoutOperationCallbackStatusHandled;
- return noErr;
-}
-
-static inline bool isArabicLamWithAlefLigature(UChar c)
-{
- return c >= 0xfef5 && c <= 0xfefc;
-}
-
-static void shapeArabic(const UChar* source, UChar* dest, unsigned totalLength, unsigned shapingStart)
-{
- while (shapingStart < totalLength) {
- unsigned shapingEnd;
- // We do not want to pass a Lam with Alef ligature followed by a space to the shaper,
- // since we want to be able to identify this sequence as the result of shaping a Lam
- // followed by an Alef and padding with a space.
- bool foundLigatureSpace = false;
- for (shapingEnd = shapingStart; !foundLigatureSpace && shapingEnd < totalLength - 1; ++shapingEnd)
- foundLigatureSpace = isArabicLamWithAlefLigature(source[shapingEnd]) && source[shapingEnd + 1] == ' ';
- shapingEnd++;
-
- UErrorCode shapingError = U_ZERO_ERROR;
- unsigned charsWritten = shapeArabic(source + shapingStart, shapingEnd - shapingStart, dest + shapingStart, shapingEnd - shapingStart, U_SHAPE_LETTERS_SHAPE | U_SHAPE_LENGTH_FIXED_SPACES_NEAR, &shapingError);
-
- if (U_SUCCESS(shapingError) && charsWritten == shapingEnd - shapingStart) {
- for (unsigned j = shapingStart; j < shapingEnd - 1; ++j) {
- if (isArabicLamWithAlefLigature(dest[j]) && dest[j + 1] == ' ')
- dest[++j] = zeroWidthSpace;
- }
- if (foundLigatureSpace) {
- dest[shapingEnd] = ' ';
- shapingEnd++;
- } else if (isArabicLamWithAlefLigature(dest[shapingEnd - 1])) {
- // u_shapeArabic quirk: if the last two characters in the source string are a Lam and an Alef,
- // the space is put at the beginning of the string, despite U_SHAPE_LENGTH_FIXED_SPACES_NEAR.
- ASSERT(dest[shapingStart] == ' ');
- dest[shapingStart] = zeroWidthSpace;
- }
- } else {
- // Something went wrong. Abandon shaping and just copy the rest of the buffer.
- LOG_ERROR("u_shapeArabic failed(%d)", shapingError);
- shapingEnd = totalLength;
- memcpy(dest + shapingStart, source + shapingStart, (shapingEnd - shapingStart) * sizeof(UChar));
- }
- shapingStart = shapingEnd;
- }
-}
-
-void ATSULayoutParameters::initialize(const Font* font, const GraphicsContext* graphicsContext)
-{
- m_font = font;
-
- const SimpleFontData* fontData = font->primaryFont();
- m_fonts.set(new const SimpleFontData*[m_run.length()]);
- if (font->isSmallCaps())
- m_charBuffer.set(new UChar[m_run.length()]);
-
- ATSUTextLayout layout;
- OSStatus status;
- ATSULayoutOperationOverrideSpecifier overrideSpecifier;
-
- initializeATSUStyle(fontData);
-
- // FIXME: This is currently missing the following required features that the CoreGraphics code path has:
- // - \n, \t, and nonbreaking space render as a space.
-
- UniCharCount runLength = m_run.length();
-
- if (m_charBuffer)
- memcpy(m_charBuffer.get(), m_run.characters(), runLength * sizeof(UChar));
-
- status = ATSUCreateTextLayoutWithTextPtr(
- (m_charBuffer ? m_charBuffer.get() : m_run.characters()),
- 0, // offset
- runLength, // length
- runLength, // total length
- 1, // styleRunCount
- &runLength, // length of style run
- &fontData->m_ATSUStyle,
- &layout);
- if (status != noErr)
- LOG_ERROR("ATSUCreateTextLayoutWithTextPtr failed(%d)", status);
- m_layout = layout;
- ATSUSetTextLayoutRefCon(m_layout, (URefCon)this);
-
- // FIXME: There are certain times when this method is called, when we don't have access to a GraphicsContext
- // measuring text runs with floatWidthForComplexText is one example.
- // ATSUI requires that we pass a valid CGContextRef to it when specifying kATSUCGContextTag (crashes when passed 0)
- // ATSUI disables sub-pixel rendering if kATSUCGContextTag is not specified! So we're in a bind.
- // Sometimes [[NSGraphicsContext currentContext] graphicsPort] may return the wrong (or no!) context. Nothing we can do about it (yet).
- CGContextRef cgContext = graphicsContext ? graphicsContext->platformContext() : (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
-
- ATSLineLayoutOptions lineLayoutOptions = kATSLineKeepSpacesOutOfMargin | kATSLineHasNoHangers;
- Boolean rtl = m_run.rtl();
- overrideSpecifier.operationSelector = kATSULayoutOperationPostLayoutAdjustment;
- overrideSpecifier.overrideUPP = overrideLayoutOperation;
- ATSUAttributeTag tags[] = { kATSUCGContextTag, kATSULineLayoutOptionsTag, kATSULineDirectionTag, kATSULayoutOperationOverrideTag };
- ByteCount sizes[] = { sizeof(CGContextRef), sizeof(ATSLineLayoutOptions), sizeof(Boolean), sizeof(ATSULayoutOperationOverrideSpecifier) };
- ATSUAttributeValuePtr values[] = { &cgContext, &lineLayoutOptions, &rtl, &overrideSpecifier };
-
- status = ATSUSetLayoutControls(layout, (m_run.applyWordRounding() ? 4 : 3), tags, sizes, values);
- if (status != noErr)
- LOG_ERROR("ATSUSetLayoutControls failed(%d)", status);
-
- status = ATSUSetTransientFontMatching(layout, YES);
- if (status != noErr)
- LOG_ERROR("ATSUSetTransientFontMatching failed(%d)", status);
-
- m_hasSyntheticBold = false;
- ATSUFontID ATSUSubstituteFont;
- UniCharArrayOffset substituteOffset = 0;
- UniCharCount substituteLength;
- UniCharArrayOffset lastOffset;
- const SimpleFontData* substituteFontData = 0;
-
- while (substituteOffset < runLength) {
- // FIXME: Using ATSUMatchFontsToText() here results in several problems: the CSS font family list is not necessarily followed for the 2nd
- // and onwards unmatched characters; segmented fonts do not work correctly; behavior does not match the simple text and Uniscribe code
- // paths. Change this function to use Font::glyphDataForCharacter() for each character instead.
- lastOffset = substituteOffset;
- status = ATSUMatchFontsToText(layout, substituteOffset, kATSUToTextEnd, &ATSUSubstituteFont, &substituteOffset, &substituteLength);
- if (status == kATSUFontsMatched || status == kATSUFontsNotMatched) {
- const FontData* fallbackFontData = m_font->fontDataForCharacters(m_run.characters() + substituteOffset, substituteLength);
- substituteFontData = fallbackFontData ? fallbackFontData->fontDataForCharacter(m_run[0]) : 0;
- if (substituteFontData) {
- initializeATSUStyle(substituteFontData);
- if (substituteFontData->m_ATSUStyle)
- ATSUSetRunStyle(layout, substituteFontData->m_ATSUStyle, substituteOffset, substituteLength);
- } else
- substituteFontData = fontData;
- } else {
- substituteOffset = runLength;
- substituteLength = 0;
- }
-
- bool shapedArabic = false;
- bool isSmallCap = false;
- UniCharArrayOffset firstSmallCap = 0;
- const SimpleFontData *r = fontData;
- UniCharArrayOffset i;
- for (i = lastOffset; ; i++) {
- if (i == substituteOffset || i == substituteOffset + substituteLength) {
- if (isSmallCap) {
- isSmallCap = false;
- initializeATSUStyle(r->smallCapsFontData(m_font->fontDescription()));
- ATSUSetRunStyle(layout, r->smallCapsFontData(m_font->fontDescription())->m_ATSUStyle, firstSmallCap, i - firstSmallCap);
- }
- if (i == substituteOffset && substituteLength > 0)
- r = substituteFontData;
- else
- break;
- }
- if (!shapedArabic && WTF::Unicode::isArabicChar(m_run[i]) && !r->shapesArabic()) {
- shapedArabic = true;
- if (!m_charBuffer) {
- m_charBuffer.set(new UChar[runLength]);
- memcpy(m_charBuffer.get(), m_run.characters(), i * sizeof(UChar));
- ATSUTextMoved(layout, m_charBuffer.get());
- }
- shapeArabic(m_run.characters(), m_charBuffer.get(), runLength, i);
- }
- if (m_run.rtl() && !r->m_ATSUMirrors) {
- UChar mirroredChar = u_charMirror(m_run[i]);
- if (mirroredChar != m_run[i]) {
- if (!m_charBuffer) {
- m_charBuffer.set(new UChar[runLength]);
- memcpy(m_charBuffer.get(), m_run.characters(), runLength * sizeof(UChar));
- ATSUTextMoved(layout, m_charBuffer.get());
- }
- m_charBuffer[i] = mirroredChar;
- }
- }
- if (m_font->isSmallCaps()) {
- const SimpleFontData* smallCapsData = r->smallCapsFontData(m_font->fontDescription());
- UChar c = m_charBuffer[i];
- UChar newC;
- if (U_GET_GC_MASK(c) & U_GC_M_MASK)
- m_fonts[i] = isSmallCap ? smallCapsData : r;
- else if (!u_isUUppercase(c) && (newC = u_toupper(c)) != c) {
- m_charBuffer[i] = newC;
- if (!isSmallCap) {
- isSmallCap = true;
- firstSmallCap = i;
- }
- m_fonts[i] = smallCapsData;
- } else {
- if (isSmallCap) {
- isSmallCap = false;
- initializeATSUStyle(smallCapsData);
- ATSUSetRunStyle(layout, smallCapsData->m_ATSUStyle, firstSmallCap, i - firstSmallCap);
- }
- m_fonts[i] = r;
- }
- } else
- m_fonts[i] = r;
- if (m_fonts[i]->m_syntheticBoldOffset)
- m_hasSyntheticBold = true;
- }
- substituteOffset += substituteLength;
- }
- if (m_run.padding()) {
- float numSpaces = 0;
- unsigned k;
- for (k = 0; k < runLength; k++)
- if (Font::treatAsSpace(m_run[k]))
- numSpaces++;
-
- if (numSpaces == 0)
- m_padPerSpace = 0;
- else
- m_padPerSpace = ceilf(m_run.padding() / numSpaces);
- } else
- m_padPerSpace = 0;
-}
-
-FloatRect Font::selectionRectForComplexText(const TextRun& run, const IntPoint& point, int h, int from, int to) const
-{
- OwnArrayPtr<UChar> charactersWithOverride;
- TextRun adjustedRun = copyRunForDirectionalOverrideIfNecessary(run, charactersWithOverride);
- if (run.directionalOverride()) {
- from++;
- to++;
- }
-
- ATSULayoutParameters params(adjustedRun);
- params.initialize(this);
-
- ATSTrapezoid firstGlyphBounds;
- ItemCount actualNumBounds;
-
- OSStatus status = ATSUGetGlyphBounds(params.m_layout, 0, 0, from, to - from, kATSUseFractionalOrigins, 1, &firstGlyphBounds, &actualNumBounds);
- if (status != noErr || actualNumBounds != 1) {
- static ATSTrapezoid zeroTrapezoid = { {0, 0}, {0, 0}, {0, 0}, {0, 0} };
- firstGlyphBounds = zeroTrapezoid;
- }
-
- float beforeWidth = MIN(FixedToFloat(firstGlyphBounds.lowerLeft.x), FixedToFloat(firstGlyphBounds.upperLeft.x));
- float afterWidth = MAX(FixedToFloat(firstGlyphBounds.lowerRight.x), FixedToFloat(firstGlyphBounds.upperRight.x));
-
- FloatRect rect(point.x() + floorf(beforeWidth), point.y(), roundf(afterWidth) - floorf(beforeWidth), h);
-
- return rect;
-}
-
-void Font::drawComplexText(GraphicsContext* graphicsContext, const TextRun& run, const FloatPoint& point, int from, int to) const
-{
- OSStatus status;
-
- int drawPortionLength = to - from;
- OwnArrayPtr<UChar> charactersWithOverride;
- TextRun adjustedRun = copyRunForDirectionalOverrideIfNecessary(run, charactersWithOverride);
- if (run.directionalOverride())
- from++;
-
- ATSULayoutParameters params(adjustedRun);
- params.initialize(this, graphicsContext);
-
- // ATSUI can't draw beyond -32768 to +32767 so we translate the CTM and tell ATSUI to draw at (0, 0).
- CGContextRef context = graphicsContext->platformContext();
- CGContextTranslateCTM(context, point.x(), point.y());
-
- IntSize shadowSize;
- int shadowBlur;
- Color shadowColor;
- graphicsContext->getShadow(shadowSize, shadowBlur, shadowColor);
-
- bool hasSimpleShadow = graphicsContext->textDrawingMode() == cTextFill && shadowColor.isValid() && !shadowBlur;
- if (hasSimpleShadow) {
- // Paint simple shadows ourselves instead of relying on CG shadows, to avoid losing subpixel antialiasing.
- graphicsContext->clearShadow();
- Color fillColor = graphicsContext->fillColor();
- Color shadowFillColor(shadowColor.red(), shadowColor.green(), shadowColor.blue(), shadowColor.alpha() * fillColor.alpha() / 255);
- graphicsContext->setFillColor(shadowFillColor);
- CGContextTranslateCTM(context, shadowSize.width(), shadowSize.height());
- status = ATSUDrawText(params.m_layout, from, drawPortionLength, 0, 0);
- if (status == noErr && params.m_hasSyntheticBold) {
- // Force relayout for the bold pass
- ATSUClearLayoutCache(params.m_layout, 0);
- params.m_syntheticBoldPass = true;
- status = ATSUDrawText(params.m_layout, from, drawPortionLength, 0, 0);
- // Force relayout for the next pass
- ATSUClearLayoutCache(params.m_layout, 0);
- params.m_syntheticBoldPass = false;
- }
- CGContextTranslateCTM(context, -shadowSize.width(), -shadowSize.height());
- graphicsContext->setFillColor(fillColor);
- }
-
- status = ATSUDrawText(params.m_layout, from, drawPortionLength, 0, 0);
- if (status == noErr && params.m_hasSyntheticBold) {
- // Force relayout for the bold pass
- ATSUClearLayoutCache(params.m_layout, 0);
- params.m_syntheticBoldPass = true;
- status = ATSUDrawText(params.m_layout, from, drawPortionLength, 0, 0);
- }
- CGContextTranslateCTM(context, -point.x(), -point.y());
-
- if (status != noErr)
- // Nothing to do but report the error (dev build only).
- LOG_ERROR("ATSUDrawText() failed(%d)", status);
-
- if (hasSimpleShadow)
- graphicsContext->setShadow(shadowSize, shadowBlur, shadowColor);
-}
-
-float Font::floatWidthForComplexText(const TextRun& run) const
-{
- if (run.length() == 0)
- return 0;
-
- ATSULayoutParameters params(run);
- params.initialize(this);
-
- OSStatus status;
-
- ATSTrapezoid firstGlyphBounds;
- ItemCount actualNumBounds;
- status = ATSUGetGlyphBounds(params.m_layout, 0, 0, 0, run.length(), kATSUseFractionalOrigins, 1, &firstGlyphBounds, &actualNumBounds);
- if (status != noErr)
- LOG_ERROR("ATSUGetGlyphBounds() failed(%d)", status);
- if (actualNumBounds != 1)
- LOG_ERROR("unexpected result from ATSUGetGlyphBounds(): actualNumBounds(%d) != 1", actualNumBounds);
-
- return MAX(FixedToFloat(firstGlyphBounds.upperRight.x), FixedToFloat(firstGlyphBounds.lowerRight.x)) -
- MIN(FixedToFloat(firstGlyphBounds.upperLeft.x), FixedToFloat(firstGlyphBounds.lowerLeft.x));
-}
-
-int Font::offsetForPositionForComplexText(const TextRun& run, int x, bool includePartialGlyphs) const
-{
- OwnArrayPtr<UChar> charactersWithOverride;
- TextRun adjustedRun = copyRunForDirectionalOverrideIfNecessary(run, charactersWithOverride);
-
- ATSULayoutParameters params(adjustedRun);
- params.initialize(this);
-
- UniCharArrayOffset primaryOffset = 0;
-
- // FIXME: No idea how to avoid including partial glyphs.
- // Not even sure if that's the behavior this yields now.
- Boolean isLeading;
- UniCharArrayOffset secondaryOffset = 0;
- OSStatus status = ATSUPositionToOffset(params.m_layout, FloatToFixed(x), FloatToFixed(-1), &primaryOffset, &isLeading, &secondaryOffset);
- unsigned offset;
- if (status == noErr) {
- offset = (unsigned)primaryOffset;
- if (run.directionalOverride() && offset > 0)
- offset--;
- } else
- // Failed to find offset! Return 0 offset.
- offset = 0;
-
- return offset;
-}
-
-}
-#endif // USE(ATSUI)
diff --git a/WebCore/platform/graphics/mac/FontMacCoreText.cpp b/WebCore/platform/graphics/mac/FontMacCoreText.cpp
deleted file mode 100644
index 5fb9d5d..0000000
--- a/WebCore/platform/graphics/mac/FontMacCoreText.cpp
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Font.h"
-
-#if USE(CORE_TEXT)
-
-#include "CoreTextController.h"
-#include "FontFallbackList.h"
-#include "GlyphBuffer.h"
-#include "GraphicsContext.h"
-#include "IntRect.h"
-#include "SimpleFontData.h"
-#include <wtf/MathExtras.h>
-
-namespace WebCore {
-
-FloatRect Font::selectionRectForComplexText(const TextRun& run, const IntPoint& point, int h,
- int from, int to) const
-{
- CoreTextController controller(this, run);
- controller.advance(from);
- float beforeWidth = controller.runWidthSoFar();
- controller.advance(to);
- float afterWidth = controller.runWidthSoFar();
-
- // Using roundf() rather than ceilf() for the right edge as a compromise to ensure correct caret positioning
- if (run.rtl()) {
- float totalWidth = controller.totalWidth();
- return FloatRect(point.x() + floorf(totalWidth - afterWidth), point.y(), roundf(totalWidth - beforeWidth) - floorf(totalWidth - afterWidth), h);
- }
-
- return FloatRect(point.x() + floorf(beforeWidth), point.y(), roundf(afterWidth) - floorf(beforeWidth), h);
-}
-
-void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point,
- int from, int to) const
-{
- // This glyph buffer holds our glyphs + advances + font data for each glyph.
- GlyphBuffer glyphBuffer;
-
- float startX = point.x();
- CoreTextController controller(this, run);
- controller.advance(from);
- float beforeWidth = controller.runWidthSoFar();
- controller.advance(to, &glyphBuffer);
-
- // We couldn't generate any glyphs for the run. Give up.
- if (glyphBuffer.isEmpty())
- return;
-
- float afterWidth = controller.runWidthSoFar();
-
- if (run.rtl()) {
- startX += controller.totalWidth() + controller.finalRoundingWidth() - afterWidth;
- for (int i = 0, end = glyphBuffer.size() - 1; i < glyphBuffer.size() / 2; ++i, --end)
- glyphBuffer.swap(i, end);
- } else
- startX += beforeWidth;
-
- // Draw the glyph buffer now at the starting point returned in startX.
- FloatPoint startPoint(startX, point.y());
- drawGlyphBuffer(context, glyphBuffer, run, startPoint);
-}
-
-float Font::floatWidthForComplexText(const TextRun& run) const
-{
- CoreTextController controller(this, run, true);
- return controller.totalWidth();
-}
-
-int Font::offsetForPositionForComplexText(const TextRun& run, int x, bool includePartialGlyphs) const
-{
- CoreTextController controller(this, run);
- return controller.offsetForPosition(x, includePartialGlyphs);
-}
-
-}
-#endif // USE(CORE_TEXT)
diff --git a/WebCore/platform/graphics/mac/FontPlatformData.h b/WebCore/platform/graphics/mac/FontPlatformData.h
deleted file mode 100644
index 40a2dbd..0000000
--- a/WebCore/platform/graphics/mac/FontPlatformData.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * This file is part of the internal font implementation.
- * It should not be included by source files outside it.
- *
- * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef FontPlatformData_h
-#define FontPlatformData_h
-
-#include "StringImpl.h"
-
-#ifdef __OBJC__
-@class NSFont;
-#else
-class NSFont;
-#endif
-
-typedef struct CGFont* CGFontRef;
-typedef UInt32 ATSUFontID;
-#ifndef BUILDING_ON_TIGER
-typedef const struct __CTFont* CTFontRef;
-#endif
-
-#include <CoreFoundation/CFBase.h>
-#include <objc/objc-auto.h>
-#include <wtf/RetainPtr.h>
-
-namespace WebCore {
-
-#ifndef BUILDING_ON_TIGER
-inline CTFontRef toCTFontRef(NSFont *nsFont) { return reinterpret_cast<CTFontRef>(nsFont); }
-#endif
-
-struct FontPlatformData {
- FontPlatformData(float size, bool syntheticBold, bool syntheticOblique)
- : m_syntheticBold(syntheticBold)
- , m_syntheticOblique(syntheticOblique)
- , m_atsuFontID(0)
- , m_size(size)
- , m_font(0)
-#ifdef BUILDING_ON_TIGER
- , m_cgFont(0)
-#endif
- {
- }
-
- FontPlatformData(NSFont * = 0, bool syntheticBold = false, bool syntheticOblique = false);
-
- FontPlatformData(CGFontRef f, ATSUFontID fontID, float s, bool b , bool o)
- : m_syntheticBold(b), m_syntheticOblique(o), m_atsuFontID(fontID), m_size(s), m_font(0), m_cgFont(f)
- {
- }
-
- FontPlatformData(const FontPlatformData&);
-
- ~FontPlatformData();
-
- FontPlatformData(WTF::HashTableDeletedValueType) : m_font(hashTableDeletedFontValue()) { }
- bool isHashTableDeletedValue() const { return m_font == hashTableDeletedFontValue(); }
-
- float size() const { return m_size; }
-
- bool m_syntheticBold;
- bool m_syntheticOblique;
-
- ATSUFontID m_atsuFontID;
- float m_size;
-
- unsigned hash() const
- {
- ASSERT(m_font != 0 || m_cgFont == 0);
- uintptr_t hashCodes[2] = { (uintptr_t)m_font, m_syntheticBold << 1 | m_syntheticOblique };
- return StringImpl::computeHash(reinterpret_cast<UChar*>(hashCodes), sizeof(hashCodes) / sizeof(UChar));
- }
-
- const FontPlatformData& operator=(const FontPlatformData& f);
-
- bool operator==(const FontPlatformData& other) const
- {
- return m_font == other.m_font && m_syntheticBold == other.m_syntheticBold && m_syntheticOblique == other.m_syntheticOblique &&
- m_cgFont == other.m_cgFont && m_size == other.m_size && m_atsuFontID == other.m_atsuFontID;
- }
-
- NSFont *font() const { return m_font; }
- void setFont(NSFont *font);
-
- bool roundsGlyphAdvances() const;
- bool allowsLigatures() const;
-
-#ifndef BUILDING_ON_TIGER
- CGFontRef cgFont() const { return m_cgFont.get(); }
-#else
- CGFontRef cgFont() const { return m_cgFont; }
-#endif
-
-private:
- static NSFont *hashTableDeletedFontValue() { return reinterpret_cast<NSFont *>(-1); }
-
- NSFont *m_font;
-#ifndef BUILDING_ON_TIGER
- RetainPtr<CGFontRef> m_cgFont;
-#else
- CGFontRef m_cgFont; // It is not necessary to refcount this, since either an NSFont owns it or some CachedFont has it referenced.
-#endif
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/graphics/mac/FontPlatformDataMac.mm b/WebCore/platform/graphics/mac/FontPlatformDataMac.mm
deleted file mode 100644
index 15e573d..0000000
--- a/WebCore/platform/graphics/mac/FontPlatformDataMac.mm
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * This file is part of the internal font implementation.
- *
- * Copyright (C) 2006-7 Apple Computer, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#import "config.h"
-#import "FontPlatformData.h"
-
-#import "WebCoreSystemInterface.h"
-
-namespace WebCore {
-
-FontPlatformData::FontPlatformData(NSFont *f, bool b , bool o)
-: m_syntheticBold(b), m_syntheticOblique(o), m_font(f)
-{
- if (f)
- CFRetain(f);
- m_size = f ? [f pointSize] : 0.0f;
-#ifndef BUILDING_ON_TIGER
- m_cgFont = CTFontCopyGraphicsFont(toCTFontRef(f), 0);
- m_atsuFontID = CTFontGetPlatformFont(toCTFontRef(f), 0);
-#else
- m_cgFont = wkGetCGFontFromNSFont(f);
- m_atsuFontID = wkGetNSFontATSUFontId(f);
-#endif
-}
-
-FontPlatformData::FontPlatformData(const FontPlatformData& f)
-{
- m_font = f.m_font && f.m_font != reinterpret_cast<NSFont *>(-1) ? static_cast<const NSFont *>(CFRetain(f.m_font)) : f.m_font;
- m_syntheticBold = f.m_syntheticBold;
- m_syntheticOblique = f.m_syntheticOblique;
- m_size = f.m_size;
- m_cgFont = f.m_cgFont;
- m_atsuFontID = f.m_atsuFontID;
-}
-
-FontPlatformData:: ~FontPlatformData()
-{
- if (m_font && m_font != reinterpret_cast<NSFont *>(-1))
- CFRelease(m_font);
-}
-
-const FontPlatformData& FontPlatformData::operator=(const FontPlatformData& f)
-{
- m_syntheticBold = f.m_syntheticBold;
- m_syntheticOblique = f.m_syntheticOblique;
- m_size = f.m_size;
- m_cgFont = f.m_cgFont;
- m_atsuFontID = f.m_atsuFontID;
- if (m_font == f.m_font)
- return *this;
- if (f.m_font && f.m_font != reinterpret_cast<NSFont *>(-1))
- CFRetain(f.m_font);
- if (m_font && m_font != reinterpret_cast<NSFont *>(-1))
- CFRelease(m_font);
- m_font = f.m_font;
- return *this;
-}
-
-void FontPlatformData::setFont(NSFont *font)
-{
- if (m_font == font)
- return;
- if (font)
- CFRetain(font);
- if (m_font && m_font != reinterpret_cast<NSFont *>(-1))
- CFRelease(m_font);
- m_font = font;
- m_size = font ? [font pointSize] : 0.0f;
-#ifndef BUILDING_ON_TIGER
- m_cgFont = CTFontCopyGraphicsFont(toCTFontRef(font), 0);
- m_atsuFontID = CTFontGetPlatformFont(toCTFontRef(font), 0);
-#else
- m_cgFont = wkGetCGFontFromNSFont(font);
- m_atsuFontID = wkGetNSFontATSUFontId(font);
-#endif
-}
-
-bool FontPlatformData::roundsGlyphAdvances() const
-{
- return [m_font renderingMode] == NSFontAntialiasedIntegerAdvancementsRenderingMode;
-}
-
-bool FontPlatformData::allowsLigatures() const
-{
- return ![[m_font coveredCharacterSet] characterIsMember:'a'];
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/graphics/mac/GlyphPageTreeNodeMac.cpp b/WebCore/platform/graphics/mac/GlyphPageTreeNodeMac.cpp
deleted file mode 100644
index 143e665..0000000
--- a/WebCore/platform/graphics/mac/GlyphPageTreeNodeMac.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "GlyphPageTreeNode.h"
-
-#include "SimpleFontData.h"
-#include "WebCoreSystemInterface.h"
-#include <ApplicationServices/ApplicationServices.h>
-
-namespace WebCore {
-
-bool GlyphPage::fill(unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength, const SimpleFontData* fontData)
-{
- bool haveGlyphs = false;
-
-#ifndef BUILDING_ON_TIGER
- Vector<CGGlyph, 512> glyphs(bufferLength);
- wkGetGlyphsForCharacters(fontData->platformData().cgFont(), buffer, glyphs.data(), bufferLength);
-
- for (unsigned i = 0; i < length; ++i) {
- if (!glyphs[i])
- setGlyphDataForIndex(offset + i, 0, 0);
- else {
- setGlyphDataForIndex(offset + i, glyphs[i], fontData);
- haveGlyphs = true;
- }
- }
-#else
- // Use an array of long so we get good enough alignment.
- long glyphVector[(GLYPH_VECTOR_SIZE + sizeof(long) - 1) / sizeof(long)];
-
- OSStatus status = wkInitializeGlyphVector(GlyphPage::size, &glyphVector);
- if (status != noErr)
- // This should never happen, perhaps indicates a bad font! If it does the
- // font substitution code will find an alternate font.
- return false;
-
- wkConvertCharToGlyphs(fontData->m_styleGroup, buffer, bufferLength, &glyphVector);
-
- unsigned numGlyphs = wkGetGlyphVectorNumGlyphs(&glyphVector);
- if (numGlyphs != length) {
- // This should never happen, perhaps indicates a bad font?
- // If it does happen, the font substitution code will find an alternate font.
- wkClearGlyphVector(&glyphVector);
- return false;
- }
-
- ATSLayoutRecord* glyphRecord = (ATSLayoutRecord*)wkGetGlyphVectorFirstRecord(glyphVector);
- for (unsigned i = 0; i < length; i++) {
- Glyph glyph = glyphRecord->glyphID;
- if (!glyph)
- setGlyphDataForIndex(offset + i, 0, 0);
- else {
- setGlyphDataForIndex(offset + i, glyph, fontData);
- haveGlyphs = true;
- }
- glyphRecord = (ATSLayoutRecord *)((char *)glyphRecord + wkGetGlyphVectorRecordSize(glyphVector));
- }
- wkClearGlyphVector(&glyphVector);
-#endif
-
- return haveGlyphs;
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/graphics/mac/GraphicsContextMac.mm b/WebCore/platform/graphics/mac/GraphicsContextMac.mm
deleted file mode 100644
index 3f9176c..0000000
--- a/WebCore/platform/graphics/mac/GraphicsContextMac.mm
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "GraphicsContext.h"
-
-#import "../cg/GraphicsContextPlatformPrivateCG.h"
-
-#import "WebCoreSystemInterface.h"
-
-// FIXME: More of this should use CoreGraphics instead of AppKit.
-// FIXME: More of this should move into GraphicsContextCG.cpp.
-
-namespace WebCore {
-
-// NSColor, NSBezierPath, and NSGraphicsContext
-// calls in this file are all exception-safe, so we don't block
-// exceptions for those.
-
-void GraphicsContext::drawFocusRing(const Color& color)
-{
- if (paintingDisabled())
- return;
-
- int radius = (focusRingWidth() - 1) / 2;
- int offset = radius + focusRingOffset();
- CGColorRef colorRef = color.isValid() ? cgColor(color) : 0;
-
- CGMutablePathRef focusRingPath = CGPathCreateMutable();
- const Vector<IntRect>& rects = focusRingRects();
- unsigned rectCount = rects.size();
- for (unsigned i = 0; i < rectCount; i++)
- CGPathAddRect(focusRingPath, 0, CGRectInset(rects[i], -offset, -offset));
-
- CGContextRef context = platformContext();
-#ifdef BUILDING_ON_TIGER
- CGContextBeginTransparencyLayer(context, NULL);
-#endif
- CGContextBeginPath(context);
- CGContextAddPath(context, focusRingPath);
- wkDrawFocusRing(context, colorRef, radius);
-#ifdef BUILDING_ON_TIGER
- CGContextEndTransparencyLayer(context);
-#endif
- CGColorRelease(colorRef);
-
- CGPathRelease(focusRingPath);
-}
-
-#ifdef BUILDING_ON_TIGER // Post-Tiger's setCompositeOperation() is defined in GraphicsContextCG.cpp.
-void GraphicsContext::setCompositeOperation(CompositeOperator op)
-{
- if (paintingDisabled())
- return;
- NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
- [[NSGraphicsContext graphicsContextWithGraphicsPort:platformContext() flipped:YES]
- setCompositingOperation:(NSCompositingOperation)op];
- [pool drain];
-}
-#endif
-
-void GraphicsContext::drawLineForMisspellingOrBadGrammar(const IntPoint& point, int width, bool grammar)
-{
- if (paintingDisabled())
- return;
-
- // Constants for spelling pattern color
- static RetainPtr<NSColor> spellingPatternColor = nil;
- static bool usingDotForSpelling = false;
-
- // Constants for grammar pattern color
- static RetainPtr<NSColor> grammarPatternColor = nil;
- static bool usingDotForGrammar = false;
-
- // These are the same for misspelling or bad grammar
- int patternHeight = cMisspellingLineThickness;
- int patternWidth = cMisspellingLinePatternWidth;
-
- // Initialize pattern color if needed
- if (!grammar && !spellingPatternColor) {
- NSImage *image = [NSImage imageNamed:@"SpellingDot"];
- ASSERT(image); // if image is not available, we want to know
- NSColor *color = (image ? [NSColor colorWithPatternImage:image] : nil);
- if (color)
- usingDotForSpelling = true;
- else
- color = [NSColor redColor];
- spellingPatternColor = color;
- }
-
- if (grammar && !grammarPatternColor) {
- NSImage *image = [NSImage imageNamed:@"GrammarDot"];
- ASSERT(image); // if image is not available, we want to know
- NSColor *color = (image ? [NSColor colorWithPatternImage:image] : nil);
- if (color)
- usingDotForGrammar = true;
- else
- color = [NSColor greenColor];
- grammarPatternColor = color;
- }
-
- bool usingDot;
- NSColor *patternColor;
- if (grammar) {
- usingDot = usingDotForGrammar;
- patternColor = grammarPatternColor.get();
- } else {
- usingDot = usingDotForSpelling;
- patternColor = spellingPatternColor.get();
- }
-
- // Make sure to draw only complete dots.
- // NOTE: Code here used to shift the underline to the left and increase the width
- // to make sure everything gets underlined, but that results in drawing out of
- // bounds (e.g. when at the edge of a view) and could make it appear that the
- // space between adjacent misspelled words was underlined.
- if (usingDot) {
- // allow slightly more considering that the pattern ends with a transparent pixel
- int widthMod = width % patternWidth;
- if (patternWidth - widthMod > cMisspellingLinePatternGapWidth)
- width -= widthMod;
- }
-
- // FIXME: This code should not use NSGraphicsContext currentContext
- // In order to remove this requirement we will need to use CGPattern instead of NSColor
- // FIXME: This code should not be using wkSetPatternPhaseInUserSpace, as this approach is wrong
- // for transforms.
-
- // Draw underline
- NSGraphicsContext *currentContext = [NSGraphicsContext currentContext];
- CGContextRef context = (CGContextRef)[currentContext graphicsPort];
- CGContextSaveGState(context);
-
- [patternColor set];
-
- wkSetPatternPhaseInUserSpace(context, point);
-
- NSRectFillUsingOperation(NSMakeRect(point.x(), point.y(), width, patternHeight), NSCompositeSourceOver);
-
- CGContextRestoreGState(context);
-}
-
-}
diff --git a/WebCore/platform/graphics/mac/IconMac.mm b/WebCore/platform/graphics/mac/IconMac.mm
deleted file mode 100644
index 63abe59..0000000
--- a/WebCore/platform/graphics/mac/IconMac.mm
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#import "config.h"
-#import "Icon.h"
-
-#import "GraphicsContext.h"
-#import "LocalCurrentGraphicsContext.h"
-#import "PlatformString.h"
-#import <wtf/PassRefPtr.h>
-
-namespace WebCore {
-
-Icon::Icon(NSImage *image)
- : m_nsImage(image)
-{
- // Need this because WebCore uses AppKit's flipped coordinate system exclusively.
- [image setFlipped:YES];
-}
-
-Icon::~Icon()
-{
-}
-
-PassRefPtr<Icon> Icon::createIconForFile(const String& filename)
-{
- // Don't pass relative filenames -- we don't want a result that depends on the current directory.
- // Need 0U here to disambiguate String::operator[] from operator(NSString*, int)[]
- if (filename.isEmpty() || filename[0U] != '/')
- return 0;
-
- NSImage* image = [[NSWorkspace sharedWorkspace] iconForFile:filename];
- if (!image)
- return 0;
-
- return adoptRef(new Icon(image));
-}
-
-PassRefPtr<Icon> Icon::createIconForFiles(const Vector<String>& filenames)
-{
- if (filenames.isEmpty())
- return 0;
-#ifdef BUILDING_ON_TIGER
- // FIXME: find a better image to use on Tiger.
- return createIconForFile(filenames[0]);
-#else
- NSImage* image = [NSImage imageNamed:NSImageNameMultipleDocuments];
- if (!image)
- return 0;
-
- return adoptRef(new Icon(image));
-#endif
-}
-
-void Icon::paint(GraphicsContext* context, const IntRect& rect)
-{
- if (context->paintingDisabled())
- return;
-
- LocalCurrentGraphicsContext localCurrentGC(context);
-
- [m_nsImage.get() drawInRect:rect
- fromRect:NSMakeRect(0, 0, [m_nsImage.get() size].width, [m_nsImage.get() size].height)
- operation:NSCompositeSourceOver fraction:1.0f];
-}
-
-}
diff --git a/WebCore/platform/graphics/mac/ImageMac.mm b/WebCore/platform/graphics/mac/ImageMac.mm
deleted file mode 100644
index a0d257b..0000000
--- a/WebCore/platform/graphics/mac/ImageMac.mm
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "BitmapImage.h"
-
-#import "FloatRect.h"
-#import "FoundationExtras.h"
-#import "GraphicsContext.h"
-#import "PlatformString.h"
-
-@interface WebCoreBundleFinder : NSObject
-@end
-
-@implementation WebCoreBundleFinder
-@end
-
-namespace WebCore {
-
-void BitmapImage::initPlatformData()
-{
-}
-
-void BitmapImage::invalidatePlatformData()
-{
- if (m_frames.size() != 1)
- return;
-
- m_nsImage = 0;
- m_tiffRep = 0;
-}
-
-PassRefPtr<Image> Image::loadPlatformResource(const char *name)
-{
- NSBundle *bundle = [NSBundle bundleForClass:[WebCoreBundleFinder class]];
- NSString *imagePath = [bundle pathForResource:[NSString stringWithUTF8String:name] ofType:@"tiff"];
- NSData *namedImageData = [NSData dataWithContentsOfFile:imagePath];
- if (namedImageData) {
- RefPtr<Image> image = BitmapImage::create();
- image->setData(SharedBuffer::wrapNSData(namedImageData), true);
- return image.release();
- }
-
- // We have reports indicating resource loads are failing, but we don't yet know the root cause(s).
- // Two theories are bad installs (image files are missing), and too-many-open-files.
- // See rdar://5607381
- ASSERT_NOT_REACHED();
- return Image::nullImage();
-}
-
-CFDataRef BitmapImage::getTIFFRepresentation()
-{
- if (m_tiffRep)
- return m_tiffRep.get();
-
- unsigned numFrames = frameCount();
-
- // If numFrames is zero, we know for certain this image doesn't have valid data
- // Even though the call to CGImageDestinationCreateWithData will fail and we'll handle it gracefully,
- // in certain circumstances that call will spam the console with an error message
- if (!numFrames)
- return 0;
-
- Vector<CGImageRef> images;
- for (unsigned i = 0; i < numFrames; ++i ) {
- CGImageRef cgImage = frameAtIndex(i);
- if (cgImage)
- images.append(cgImage);
- }
-
- unsigned numValidFrames = images.size();
-
- RetainPtr<CFMutableDataRef> data(AdoptCF, CFDataCreateMutable(0, 0));
- // FIXME: Use type kCGImageTypeIdentifierTIFF constant once is becomes available in the API
- CGImageDestinationRef destination = CGImageDestinationCreateWithData(data.get(), CFSTR("public.tiff"), numValidFrames, 0);
-
- if (!destination)
- return 0;
-
- for (unsigned i = 0; i < numValidFrames; ++i)
- CGImageDestinationAddImage(destination, images[i], 0);
-
- CGImageDestinationFinalize(destination);
- CFRelease(destination);
-
- m_tiffRep = data;
- return m_tiffRep.get();
-}
-
-NSImage* BitmapImage::getNSImage()
-{
- if (m_nsImage)
- return m_nsImage.get();
-
- CFDataRef data = getTIFFRepresentation();
- if (!data)
- return 0;
-
- m_nsImage.adoptNS([[NSImage alloc] initWithData:(NSData*)data]);
- return m_nsImage.get();
-}
-
-}
diff --git a/WebCore/platform/graphics/mac/IntPointMac.mm b/WebCore/platform/graphics/mac/IntPointMac.mm
deleted file mode 100644
index 7a2e730..0000000
--- a/WebCore/platform/graphics/mac/IntPointMac.mm
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "IntPoint.h"
-
-namespace WebCore {
-
-#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))
-{
-}
-
-IntPoint::operator NSPoint() const
-{
- return NSMakePoint(m_x, m_y);
-}
-
-#endif
-
-}
diff --git a/WebCore/platform/graphics/mac/IntRectMac.mm b/WebCore/platform/graphics/mac/IntRectMac.mm
deleted file mode 100644
index 738618a..0000000
--- a/WebCore/platform/graphics/mac/IntRectMac.mm
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "IntRect.h"
-
-namespace WebCore {
-
-#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
-
-IntRect::operator NSRect() const
-{
- return NSMakeRect(x(), y(), width(), height());
-}
-
-IntRect enclosingIntRect(const NSRect& rect)
-{
- int l = static_cast<int>(floorf(rect.origin.x));
- int t = static_cast<int>(floorf(rect.origin.y));
- int r = static_cast<int>(ceilf(NSMaxX(rect)));
- int b = static_cast<int>(ceilf(NSMaxY(rect)));
- return IntRect(l, t, r - l, b - t);
-}
-
-#endif
-
-}
diff --git a/WebCore/platform/graphics/mac/IntSizeMac.mm b/WebCore/platform/graphics/mac/IntSizeMac.mm
deleted file mode 100644
index c7dcd88..0000000
--- a/WebCore/platform/graphics/mac/IntSizeMac.mm
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "IntSize.h"
-
-namespace WebCore {
-
-#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))
-{
-}
-
-IntSize::operator NSSize() const
-{
- return NSMakeSize(m_width, m_height);
-}
-
-#endif
-
-}
diff --git a/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h b/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h
deleted file mode 100644
index 3f18ab4..0000000
--- a/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef MediaPlayerPrivateQTKit_h
-#define MediaPlayerPrivateQTKit_h
-
-#if ENABLE(VIDEO)
-
-#include "MediaPlayer.h"
-#include "Timer.h"
-#include <wtf/RetainPtr.h>
-
-#ifdef __OBJC__
-#import <QTKit/QTTime.h>
-@class QTMovie;
-@class QTMovieView;
-@class QTVideoRendererWebKitOnly;
-@class WebCoreMovieObserver;
-#else
-class QTMovie;
-class QTMovieView;
-class QTTime;
-class QTVideoRendererWebKitOnly;
-class WebCoreMovieObserver;
-#endif
-
-#ifndef DRAW_FRAME_RATE
-#define DRAW_FRAME_RATE 0
-#endif
-
-namespace WebCore {
-
-class MediaPlayerPrivate : Noncopyable {
-public:
- MediaPlayerPrivate(MediaPlayer*);
- ~MediaPlayerPrivate();
-
- IntSize naturalSize() const;
- bool hasVideo() const;
-
- void load(const String& url);
- void cancelLoad();
-
- void play();
- void pause();
-
- bool paused() const;
- bool seeking() const;
-
- float duration() const;
- float currentTime() const;
- void seek(float time);
- void setEndTime(float time);
-
- void setRate(float);
- void setVolume(float);
-
- int dataRate() const;
-
- MediaPlayer::NetworkState networkState() const { return m_networkState; }
- MediaPlayer::ReadyState readyState() const { return m_readyState; }
-
- float maxTimeBuffered() const;
- float maxTimeSeekable() const;
- unsigned bytesLoaded() const;
- bool totalBytesKnown() const;
- unsigned totalBytes() const;
-
- void setVisible(bool);
- void setRect(const IntRect& r);
-
- void loadStateChanged();
- void rateChanged();
- void sizeChanged();
- void timeChanged();
- void didEnd();
-
- void repaint();
- void paint(GraphicsContext*, const IntRect&);
-
- static void getSupportedTypes(HashSet<String>& types);
- static bool isAvailable();
-
-private:
- void createQTMovie(const String& url);
- void setUpVideoRendering();
- void tearDownVideoRendering();
- void createQTMovieView();
- void detachQTMovieView();
- void createQTVideoRenderer();
- void destroyQTVideoRenderer();
- QTTime createQTTime(float time) const;
-
- void updateStates();
- void doSeek();
- void cancelSeek();
- void seekTimerFired(Timer<MediaPlayerPrivate>*);
- void endPointTimerFired(Timer<MediaPlayerPrivate>*);
- float maxTimeLoaded() const;
- void startEndPointTimerIfNeeded();
- void disableUnsupportedTracks(unsigned& enabledTrackCount);
-
- MediaPlayer* m_player;
- RetainPtr<QTMovie> m_qtMovie;
- RetainPtr<QTMovieView> m_qtMovieView;
- RetainPtr<QTVideoRendererWebKitOnly> m_qtVideoRenderer;
- RetainPtr<WebCoreMovieObserver> m_objcObserver;
- float m_seekTo;
- float m_endTime;
- Timer<MediaPlayerPrivate> m_seekTimer;
- Timer<MediaPlayerPrivate> m_endPointTimer;
- MediaPlayer::NetworkState m_networkState;
- MediaPlayer::ReadyState m_readyState;
- bool m_startedPlaying;
- bool m_isStreaming;
- bool m_visible;
-#if DRAW_FRAME_RATE
- int m_frameCountWhilePlaying;
- double m_timeStartedPlaying;
- double m_timeStoppedPlaying;
-#endif
-};
-
-}
-
-#endif
-#endif
diff --git a/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm b/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm
deleted file mode 100644
index 0ec56d6..0000000
--- a/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm
+++ /dev/null
@@ -1,1024 +0,0 @@
-/*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-
-#if ENABLE(VIDEO)
-
-#import "MediaPlayerPrivateQTKit.h"
-
-#import "BlockExceptions.h"
-#import "GraphicsContext.h"
-#import "KURL.h"
-#import "FrameView.h"
-#import "SoftLinking.h"
-#import "WebCoreSystemInterface.h"
-#import <QTKit/QTKit.h>
-#import <objc/objc-runtime.h>
-
-#if DRAW_FRAME_RATE
-#import "Font.h"
-#import "Frame.h"
-#import "Document.h"
-#import "RenderObject.h"
-#import "RenderStyle.h"
-#endif
-
-#ifdef BUILDING_ON_TIGER
-static IMP method_setImplementation(Method m, IMP imp)
-{
- IMP result = m->method_imp;
- m->method_imp = imp;
- return result;
-}
-#endif
-
-SOFT_LINK_FRAMEWORK(QTKit)
-
-SOFT_LINK(QTKit, QTMakeTime, QTTime, (long long timeValue, long timeScale), (timeValue, timeScale))
-
-SOFT_LINK_CLASS(QTKit, QTMovie)
-SOFT_LINK_CLASS(QTKit, QTMovieView)
-
-SOFT_LINK_POINTER(QTKit, QTMediaTypeAttribute, NSString *)
-SOFT_LINK_POINTER(QTKit, QTMediaTypeBase, NSString *)
-SOFT_LINK_POINTER(QTKit, QTMediaTypeSound, NSString *)
-SOFT_LINK_POINTER(QTKit, QTMediaTypeText, NSString *)
-SOFT_LINK_POINTER(QTKit, QTMediaTypeVideo, NSString *)
-SOFT_LINK_POINTER(QTKit, QTMovieAskUnresolvedDataRefsAttribute, NSString *)
-SOFT_LINK_POINTER(QTKit, QTMovieDataSizeAttribute, NSString *)
-SOFT_LINK_POINTER(QTKit, QTMovieDidEndNotification, NSString *)
-SOFT_LINK_POINTER(QTKit, QTMovieHasVideoAttribute, NSString *)
-SOFT_LINK_POINTER(QTKit, QTMovieIsActiveAttribute, NSString *)
-SOFT_LINK_POINTER(QTKit, QTMovieLoadStateAttribute, NSString *)
-SOFT_LINK_POINTER(QTKit, QTMovieLoadStateDidChangeNotification, NSString *)
-SOFT_LINK_POINTER(QTKit, QTMovieNaturalSizeAttribute, NSString *)
-SOFT_LINK_POINTER(QTKit, QTMoviePreventExternalURLLinksAttribute, NSString *)
-SOFT_LINK_POINTER(QTKit, QTMovieRateDidChangeNotification, NSString *)
-SOFT_LINK_POINTER(QTKit, QTMovieSizeDidChangeNotification, NSString *)
-SOFT_LINK_POINTER(QTKit, QTMovieTimeDidChangeNotification, NSString *)
-SOFT_LINK_POINTER(QTKit, QTMovieTimeScaleAttribute, NSString *)
-SOFT_LINK_POINTER(QTKit, QTMovieURLAttribute, NSString *)
-SOFT_LINK_POINTER(QTKit, QTMovieVolumeDidChangeNotification, NSString *)
-SOFT_LINK_POINTER(QTKit, QTSecurityPolicyNoCrossSiteAttribute, NSString *)
-SOFT_LINK_POINTER(QTKit, QTVideoRendererWebKitOnlyNewImageAvailableNotification, NSString *)
-
-#define QTMovie getQTMovieClass()
-#define QTMovieView getQTMovieViewClass()
-
-#define QTMediaTypeAttribute getQTMediaTypeAttribute()
-#define QTMediaTypeBase getQTMediaTypeBase()
-#define QTMediaTypeSound getQTMediaTypeSound()
-#define QTMediaTypeText getQTMediaTypeText()
-#define QTMediaTypeVideo getQTMediaTypeVideo()
-#define QTMovieAskUnresolvedDataRefsAttribute getQTMovieAskUnresolvedDataRefsAttribute()
-#define QTMovieDataSizeAttribute getQTMovieDataSizeAttribute()
-#define QTMovieDidEndNotification getQTMovieDidEndNotification()
-#define QTMovieHasVideoAttribute getQTMovieHasVideoAttribute()
-#define QTMovieIsActiveAttribute getQTMovieIsActiveAttribute()
-#define QTMovieLoadStateAttribute getQTMovieLoadStateAttribute()
-#define QTMovieLoadStateDidChangeNotification getQTMovieLoadStateDidChangeNotification()
-#define QTMovieNaturalSizeAttribute getQTMovieNaturalSizeAttribute()
-#define QTMoviePreventExternalURLLinksAttribute getQTMoviePreventExternalURLLinksAttribute()
-#define QTMovieRateDidChangeNotification getQTMovieRateDidChangeNotification()
-#define QTMovieSizeDidChangeNotification getQTMovieSizeDidChangeNotification()
-#define QTMovieTimeDidChangeNotification getQTMovieTimeDidChangeNotification()
-#define QTMovieTimeScaleAttribute getQTMovieTimeScaleAttribute()
-#define QTMovieURLAttribute getQTMovieURLAttribute()
-#define QTMovieVolumeDidChangeNotification getQTMovieVolumeDidChangeNotification()
-#define QTSecurityPolicyNoCrossSiteAttribute getQTSecurityPolicyNoCrossSiteAttribute()
-#define QTVideoRendererWebKitOnlyNewImageAvailableNotification getQTVideoRendererWebKitOnlyNewImageAvailableNotification()
-
-// Older versions of the QTKit header don't have these constants.
-#if !defined QTKIT_VERSION_MAX_ALLOWED || QTKIT_VERSION_MAX_ALLOWED <= QTKIT_VERSION_7_0
-enum {
- QTMovieLoadStateError = -1L,
- QTMovieLoadStateLoaded = 2000L,
- QTMovieLoadStatePlayable = 10000L,
- QTMovieLoadStatePlaythroughOK = 20000L,
- QTMovieLoadStateComplete = 100000L
-};
-#endif
-
-using namespace WebCore;
-using namespace std;
-
-@interface WebCoreMovieObserver : NSObject
-{
- MediaPlayerPrivate* m_callback;
- NSView* m_view;
- BOOL m_delayCallbacks;
-}
--(id)initWithCallback:(MediaPlayerPrivate*)callback;
--(void)disconnect;
--(void)setView:(NSView*)view;
--(void)repaint;
--(void)setDelayCallbacks:(BOOL)shouldDelay;
--(void)loadStateChanged:(NSNotification *)notification;
--(void)rateChanged:(NSNotification *)notification;
--(void)sizeChanged:(NSNotification *)notification;
--(void)timeChanged:(NSNotification *)notification;
--(void)didEnd:(NSNotification *)notification;
-@end
-
-@protocol WebKitVideoRenderingDetails
--(void)setMovie:(id)movie;
--(void)drawInRect:(NSRect)rect;
-@end
-
-namespace WebCore {
-
-static const float endPointTimerInterval = 0.020f;
-
-#ifdef BUILDING_ON_TIGER
-static const long minimumQuickTimeVersion = 0x07300000; // 7.3
-#endif
-
-MediaPlayerPrivate::MediaPlayerPrivate(MediaPlayer* player)
- : m_player(player)
- , m_objcObserver(AdoptNS, [[WebCoreMovieObserver alloc] initWithCallback:this])
- , m_seekTo(-1)
- , m_endTime(numeric_limits<float>::infinity())
- , m_seekTimer(this, &MediaPlayerPrivate::seekTimerFired)
- , m_endPointTimer(this, &MediaPlayerPrivate::endPointTimerFired)
- , m_networkState(MediaPlayer::Empty)
- , m_readyState(MediaPlayer::DataUnavailable)
- , m_startedPlaying(false)
- , m_isStreaming(false)
- , m_visible(false)
-#if DRAW_FRAME_RATE
- , m_frameCountWhilePlaying(0)
- , m_timeStartedPlaying(0)
- , m_timeStoppedPlaying(0)
-#endif
-{
-}
-
-MediaPlayerPrivate::~MediaPlayerPrivate()
-{
- tearDownVideoRendering();
-
- [[NSNotificationCenter defaultCenter] removeObserver:m_objcObserver.get()];
- [m_objcObserver.get() disconnect];
-}
-
-void MediaPlayerPrivate::createQTMovie(const String& url)
-{
- [[NSNotificationCenter defaultCenter] removeObserver:m_objcObserver.get()];
-
- if (m_qtMovie) {
- destroyQTVideoRenderer();
- m_qtMovie = 0;
- }
-
- // Disable streaming support for now, <rdar://problem/5693967>
- if (protocolIs(url, "rtsp"))
- return;
-
- NSURL *cocoaURL = KURL(url);
- NSDictionary *movieAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
- cocoaURL, QTMovieURLAttribute,
- [NSNumber numberWithBool:YES], QTMoviePreventExternalURLLinksAttribute,
- [NSNumber numberWithBool:YES], QTSecurityPolicyNoCrossSiteAttribute,
- [NSNumber numberWithBool:NO], QTMovieAskUnresolvedDataRefsAttribute,
- [NSNumber numberWithBool:YES], @"QTMovieOpenForPlaybackAttribute", // FIXME: Use defined attribute when required version of QT supports this attribute
- nil];
-
- NSError* error = nil;
- m_qtMovie.adoptNS([[QTMovie alloc] initWithAttributes:movieAttributes error:&error]);
-
- // FIXME: Find a proper way to detect streaming content.
- m_isStreaming = protocolIs(url, "rtsp");
-
- if (!m_qtMovie)
- return;
-
- [m_qtMovie.get() setVolume:m_player->volume()];
-
- [[NSNotificationCenter defaultCenter] addObserver:m_objcObserver.get()
- selector:@selector(loadStateChanged:)
- name:QTMovieLoadStateDidChangeNotification
- object:m_qtMovie.get()];
- [[NSNotificationCenter defaultCenter] addObserver:m_objcObserver.get()
- selector:@selector(rateChanged:)
- name:QTMovieRateDidChangeNotification
- object:m_qtMovie.get()];
- [[NSNotificationCenter defaultCenter] addObserver:m_objcObserver.get()
- selector:@selector(sizeChanged:)
- name:QTMovieSizeDidChangeNotification
- object:m_qtMovie.get()];
- [[NSNotificationCenter defaultCenter] addObserver:m_objcObserver.get()
- selector:@selector(timeChanged:)
- name:QTMovieTimeDidChangeNotification
- object:m_qtMovie.get()];
- [[NSNotificationCenter defaultCenter] addObserver:m_objcObserver.get()
- selector:@selector(didEnd:)
- name:QTMovieDidEndNotification
- object:m_qtMovie.get()];
-}
-
-static void mainThreadSetNeedsDisplay(id self, SEL _cmd)
-{
- id movieView = [self superview];
- ASSERT(!movieView || [movieView isKindOfClass:[QTMovieView class]]);
- if (!movieView || ![movieView isKindOfClass:[QTMovieView class]])
- return;
-
- WebCoreMovieObserver* delegate = [movieView delegate];
- ASSERT(!delegate || [delegate isKindOfClass:[WebCoreMovieObserver class]]);
- if (!delegate || ![delegate isKindOfClass:[WebCoreMovieObserver class]])
- return;
-
- [delegate repaint];
-}
-
-static Class QTVideoRendererClass()
-{
- static Class QTVideoRendererWebKitOnlyClass = NSClassFromString(@"QTVideoRendererWebKitOnly");
- return QTVideoRendererWebKitOnlyClass;
-}
-
-void MediaPlayerPrivate::createQTMovieView()
-{
- detachQTMovieView();
-
- static bool addedCustomMethods = false;
- if (!addedCustomMethods) {
- Class QTMovieContentViewClass = NSClassFromString(@"QTMovieContentView");
- ASSERT(QTMovieContentViewClass);
-
- Method mainThreadSetNeedsDisplayMethod = class_getInstanceMethod(QTMovieContentViewClass, @selector(_mainThreadSetNeedsDisplay));
- ASSERT(mainThreadSetNeedsDisplayMethod);
-
- method_setImplementation(mainThreadSetNeedsDisplayMethod, reinterpret_cast<IMP>(mainThreadSetNeedsDisplay));
- addedCustomMethods = true;
- }
-
- m_qtMovieView.adoptNS([[QTMovieView alloc] init]);
- setRect(m_player->rect());
- NSView* parentView = m_player->m_frameView->documentView();
- [parentView addSubview:m_qtMovieView.get()];
-#ifdef BUILDING_ON_TIGER
- // setDelegate: isn't a public call in Tiger, so use performSelector to keep the compiler happy
- [m_qtMovieView.get() performSelector:@selector(setDelegate:) withObject:m_objcObserver.get()];
-#else
- [m_qtMovieView.get() setDelegate:m_objcObserver.get()];
-#endif
- [m_objcObserver.get() setView:m_qtMovieView.get()];
- [m_qtMovieView.get() setMovie:m_qtMovie.get()];
- [m_qtMovieView.get() setControllerVisible:NO];
- [m_qtMovieView.get() setPreservesAspectRatio:NO];
- // the area not covered by video should be transparent
- [m_qtMovieView.get() setFillColor:[NSColor clearColor]];
-
- // If we're in a media document, allow QTMovieView to render in its default mode;
- // otherwise tell it to draw synchronously.
- // Note that we expect mainThreadSetNeedsDisplay to be invoked only when synchronous drawing is requested.
- if (!m_player->inMediaDocument())
- wkQTMovieViewSetDrawSynchronously(m_qtMovieView.get(), YES);
-}
-
-void MediaPlayerPrivate::detachQTMovieView()
-{
- if (m_qtMovieView) {
- [m_objcObserver.get() setView:nil];
-#ifdef BUILDING_ON_TIGER
- // setDelegate: isn't a public call in Tiger, so use performSelector to keep the compiler happy
- [m_qtMovieView.get() performSelector:@selector(setDelegate:) withObject:nil];
-#else
- [m_qtMovieView.get() setDelegate:nil];
-#endif
- [m_qtMovieView.get() removeFromSuperview];
- m_qtMovieView = nil;
- }
-}
-
-void MediaPlayerPrivate::createQTVideoRenderer()
-{
- destroyQTVideoRenderer();
-
- m_qtVideoRenderer.adoptNS([[QTVideoRendererClass() alloc] init]);
- if (!m_qtVideoRenderer)
- return;
-
- // associate our movie with our instance of QTVideoRendererWebKitOnly
- [(id<WebKitVideoRenderingDetails>)m_qtVideoRenderer.get() setMovie:m_qtMovie.get()];
-
- // listen to QTVideoRendererWebKitOnly's QTVideoRendererWebKitOnlyNewImageDidBecomeAvailableNotification
- [[NSNotificationCenter defaultCenter] addObserver:m_objcObserver.get()
- selector:@selector(newImageAvailable:)
- name:QTVideoRendererWebKitOnlyNewImageAvailableNotification
- object:m_qtVideoRenderer.get()];
-}
-
-void MediaPlayerPrivate::destroyQTVideoRenderer()
-{
- if (!m_qtVideoRenderer)
- return;
-
- // stop observing the renderer's notifications before we toss it
- [[NSNotificationCenter defaultCenter] removeObserver:m_objcObserver.get()
- name:QTVideoRendererWebKitOnlyNewImageAvailableNotification
- object:m_qtVideoRenderer.get()];
-
- // disassociate our movie from our instance of QTVideoRendererWebKitOnly
- [(id<WebKitVideoRenderingDetails>)m_qtVideoRenderer.get() setMovie:nil];
-
- m_qtVideoRenderer = nil;
-}
-
-void MediaPlayerPrivate::setUpVideoRendering()
-{
- if (!m_player->m_frameView || !m_qtMovie)
- return;
-
- if (m_player->inMediaDocument() || !QTVideoRendererClass() )
- createQTMovieView();
- else
- createQTVideoRenderer();
-}
-
-void MediaPlayerPrivate::tearDownVideoRendering()
-{
- if (m_qtMovieView)
- detachQTMovieView();
- else
- destroyQTVideoRenderer();
-}
-
-QTTime MediaPlayerPrivate::createQTTime(float time) const
-{
- if (!m_qtMovie)
- return QTMakeTime(0, 600);
- long timeScale = [[m_qtMovie.get() attributeForKey:QTMovieTimeScaleAttribute] longValue];
- return QTMakeTime(time * timeScale, timeScale);
-}
-
-void MediaPlayerPrivate::load(const String& url)
-{
- if (m_networkState != MediaPlayer::Loading) {
- m_networkState = MediaPlayer::Loading;
- m_player->networkStateChanged();
- }
- if (m_readyState != MediaPlayer::DataUnavailable) {
- m_readyState = MediaPlayer::DataUnavailable;
- m_player->readyStateChanged();
- }
- cancelSeek();
- m_endPointTimer.stop();
-
- [m_objcObserver.get() setDelayCallbacks:YES];
-
- createQTMovie(url);
-
- [m_objcObserver.get() loadStateChanged:nil];
- [m_objcObserver.get() setDelayCallbacks:NO];
-}
-
-void MediaPlayerPrivate::play()
-{
- if (!m_qtMovie)
- return;
- m_startedPlaying = true;
-#if DRAW_FRAME_RATE
- m_frameCountWhilePlaying = 0;
-#endif
- [m_objcObserver.get() setDelayCallbacks:YES];
- [m_qtMovie.get() setRate:m_player->rate()];
- [m_objcObserver.get() setDelayCallbacks:NO];
- startEndPointTimerIfNeeded();
-}
-
-void MediaPlayerPrivate::pause()
-{
- if (!m_qtMovie)
- return;
- m_startedPlaying = false;
-#if DRAW_FRAME_RATE
- m_timeStoppedPlaying = [NSDate timeIntervalSinceReferenceDate];
-#endif
- [m_objcObserver.get() setDelayCallbacks:YES];
- [m_qtMovie.get() stop];
- [m_objcObserver.get() setDelayCallbacks:NO];
- m_endPointTimer.stop();
-}
-
-float MediaPlayerPrivate::duration() const
-{
- if (!m_qtMovie)
- return 0;
- QTTime time = [m_qtMovie.get() duration];
- if (time.flags == kQTTimeIsIndefinite)
- return numeric_limits<float>::infinity();
- return static_cast<float>(time.timeValue) / time.timeScale;
-}
-
-float MediaPlayerPrivate::currentTime() const
-{
- if (!m_qtMovie)
- return 0;
- QTTime time = [m_qtMovie.get() currentTime];
- return min(static_cast<float>(time.timeValue) / time.timeScale, m_endTime);
-}
-
-void MediaPlayerPrivate::seek(float time)
-{
- cancelSeek();
-
- if (!m_qtMovie)
- return;
-
- if (time > duration())
- time = duration();
-
- m_seekTo = time;
- if (maxTimeLoaded() >= m_seekTo)
- doSeek();
- else
- m_seekTimer.start(0, 0.5f);
-}
-
-void MediaPlayerPrivate::doSeek()
-{
- QTTime qttime = createQTTime(m_seekTo);
- // setCurrentTime generates several event callbacks, update afterwards
- [m_objcObserver.get() setDelayCallbacks:YES];
- float oldRate = [m_qtMovie.get() rate];
- [m_qtMovie.get() setRate:0];
- [m_qtMovie.get() setCurrentTime:qttime];
- float timeAfterSeek = currentTime();
- // restore playback only if not at end, othewise QTMovie will loop
- if (timeAfterSeek < duration() && timeAfterSeek < m_endTime)
- [m_qtMovie.get() setRate:oldRate];
- cancelSeek();
- [m_objcObserver.get() setDelayCallbacks:NO];
-}
-
-void MediaPlayerPrivate::cancelSeek()
-{
- m_seekTo = -1;
- m_seekTimer.stop();
-}
-
-void MediaPlayerPrivate::seekTimerFired(Timer<MediaPlayerPrivate>*)
-{
- if (!m_qtMovie || !seeking() || currentTime() == m_seekTo) {
- cancelSeek();
- updateStates();
- m_player->timeChanged();
- return;
- }
-
- if (maxTimeLoaded() >= m_seekTo)
- doSeek();
- else {
- MediaPlayer::NetworkState state = networkState();
- if (state == MediaPlayer::Empty || state == MediaPlayer::Loaded) {
- cancelSeek();
- updateStates();
- m_player->timeChanged();
- }
- }
-}
-
-void MediaPlayerPrivate::setEndTime(float time)
-{
- m_endTime = time;
- startEndPointTimerIfNeeded();
-}
-
-void MediaPlayerPrivate::startEndPointTimerIfNeeded()
-{
- if (m_endTime < duration() && m_startedPlaying && !m_endPointTimer.isActive())
- m_endPointTimer.startRepeating(endPointTimerInterval);
-}
-
-void MediaPlayerPrivate::endPointTimerFired(Timer<MediaPlayerPrivate>*)
-{
- float time = currentTime();
-
- // just do end for now
- if (time >= m_endTime) {
- pause();
- didEnd();
- }
-}
-
-bool MediaPlayerPrivate::paused() const
-{
- if (!m_qtMovie)
- return true;
- return [m_qtMovie.get() rate] == 0;
-}
-
-bool MediaPlayerPrivate::seeking() const
-{
- if (!m_qtMovie)
- return false;
- return m_seekTo >= 0;
-}
-
-IntSize MediaPlayerPrivate::naturalSize() const
-{
- if (!m_qtMovie)
- return IntSize();
- return IntSize([[m_qtMovie.get() attributeForKey:QTMovieNaturalSizeAttribute] sizeValue]);
-}
-
-bool MediaPlayerPrivate::hasVideo() const
-{
- if (!m_qtMovie)
- return false;
- return [[m_qtMovie.get() attributeForKey:QTMovieHasVideoAttribute] boolValue];
-}
-
-void MediaPlayerPrivate::setVolume(float volume)
-{
- if (!m_qtMovie)
- return;
- [m_qtMovie.get() setVolume:volume];
-}
-
-void MediaPlayerPrivate::setRate(float rate)
-{
- if (!m_qtMovie)
- return;
- if (!paused())
- [m_qtMovie.get() setRate:rate];
-}
-
-int MediaPlayerPrivate::dataRate() const
-{
- if (!m_qtMovie)
- return 0;
- return wkQTMovieDataRate(m_qtMovie.get());
-}
-
-
-float MediaPlayerPrivate::maxTimeBuffered() const
-{
- // rtsp streams are not buffered
- return m_isStreaming ? 0 : maxTimeLoaded();
-}
-
-float MediaPlayerPrivate::maxTimeSeekable() const
-{
- // infinite duration means live stream
- return isinf(duration()) ? 0 : maxTimeLoaded();
-}
-
-float MediaPlayerPrivate::maxTimeLoaded() const
-{
- if (!m_qtMovie)
- return 0;
- return wkQTMovieMaxTimeLoaded(m_qtMovie.get());
-}
-
-unsigned MediaPlayerPrivate::bytesLoaded() const
-{
- float dur = duration();
- if (!dur)
- return 0;
- return totalBytes() * maxTimeLoaded() / dur;
-}
-
-bool MediaPlayerPrivate::totalBytesKnown() const
-{
- return totalBytes() > 0;
-}
-
-unsigned MediaPlayerPrivate::totalBytes() const
-{
- if (!m_qtMovie)
- return 0;
- return [[m_qtMovie.get() attributeForKey:QTMovieDataSizeAttribute] intValue];
-}
-
-void MediaPlayerPrivate::cancelLoad()
-{
- // FIXME: Is there a better way to check for this?
- if (m_networkState < MediaPlayer::Loading || m_networkState == MediaPlayer::Loaded)
- return;
-
- tearDownVideoRendering();
- m_qtMovie = nil;
-
- updateStates();
-}
-
-void MediaPlayerPrivate::updateStates()
-{
- MediaPlayer::NetworkState oldNetworkState = m_networkState;
- MediaPlayer::ReadyState oldReadyState = m_readyState;
-
- long loadState = m_qtMovie ? [[m_qtMovie.get() attributeForKey:QTMovieLoadStateAttribute] longValue] : static_cast<long>(QTMovieLoadStateError);
-
- if (loadState >= QTMovieLoadStateLoaded && m_networkState < MediaPlayer::LoadedMetaData && !m_player->inMediaDocument()) {
- unsigned enabledTrackCount;
- disableUnsupportedTracks(enabledTrackCount);
- // FIXME: We should differentiate between load errors and decode errors <rdar://problem/5605692>
- if (!enabledTrackCount)
- loadState = QTMovieLoadStateError;
- }
-
- // "Loaded" is reserved for fully buffered movies, never the case when streaming
- if (loadState >= QTMovieLoadStateComplete && !m_isStreaming) {
- if (m_networkState < MediaPlayer::Loaded)
- m_networkState = MediaPlayer::Loaded;
- m_readyState = MediaPlayer::CanPlayThrough;
- } else if (loadState >= QTMovieLoadStatePlaythroughOK) {
- if (m_networkState < MediaPlayer::LoadedFirstFrame && !seeking())
- m_networkState = MediaPlayer::LoadedFirstFrame;
- m_readyState = MediaPlayer::CanPlayThrough;
- } else if (loadState >= QTMovieLoadStatePlayable) {
- if (m_networkState < MediaPlayer::LoadedFirstFrame && !seeking())
- m_networkState = MediaPlayer::LoadedFirstFrame;
- // FIXME: This might not work correctly in streaming case, <rdar://problem/5693967>
- m_readyState = currentTime() < maxTimeLoaded() ? MediaPlayer::CanPlay : MediaPlayer::DataUnavailable;
- } else if (loadState >= QTMovieLoadStateLoaded) {
- if (m_networkState < MediaPlayer::LoadedMetaData)
- m_networkState = MediaPlayer::LoadedMetaData;
- m_readyState = MediaPlayer::DataUnavailable;
- } else if (loadState > QTMovieLoadStateError) {
- if (m_networkState < MediaPlayer::Loading)
- m_networkState = MediaPlayer::Loading;
- m_readyState = MediaPlayer::DataUnavailable;
- } else {
- m_networkState = MediaPlayer::LoadFailed;
- m_readyState = MediaPlayer::DataUnavailable;
- }
-
- if (seeking())
- m_readyState = MediaPlayer::DataUnavailable;
-
- if (m_networkState != oldNetworkState)
- m_player->networkStateChanged();
- if (m_readyState != oldReadyState)
- m_player->readyStateChanged();
-
- if (loadState >= QTMovieLoadStateLoaded && oldNetworkState < MediaPlayer::LoadedMetaData && m_player->visible())
- setUpVideoRendering();
-}
-
-void MediaPlayerPrivate::loadStateChanged()
-{
- updateStates();
-}
-
-void MediaPlayerPrivate::rateChanged()
-{
- updateStates();
-}
-
-void MediaPlayerPrivate::sizeChanged()
-{
-}
-
-void MediaPlayerPrivate::timeChanged()
-{
- updateStates();
- m_player->timeChanged();
-}
-
-void MediaPlayerPrivate::didEnd()
-{
- m_endPointTimer.stop();
- m_startedPlaying = false;
-#if DRAW_FRAME_RATE
- m_timeStoppedPlaying = [NSDate timeIntervalSinceReferenceDate];
-#endif
- updateStates();
- m_player->timeChanged();
-}
-
-void MediaPlayerPrivate::setRect(const IntRect& r)
-{
- if (!m_qtMovieView)
- return;
-
- if (m_player->inMediaDocument())
- // We need the QTMovieView to be placed in the proper location for document mode.
- [m_qtMovieView.get() setFrame:r];
- else {
- // We don't really need the QTMovieView in any specific location so let's just get it out of the way
- // where it won't intercept events or try to bring up the context menu.
- IntRect farAwayButCorrectSize(r);
- farAwayButCorrectSize.move(-1000000, -1000000);
- [m_qtMovieView.get() setFrame:farAwayButCorrectSize];
- }
-}
-
-void MediaPlayerPrivate::setVisible(bool b)
-{
- if (m_visible != b) {
- m_visible = b;
- if (b) {
- if (m_networkState >= MediaPlayer::LoadedMetaData)
- setUpVideoRendering();
- } else
- tearDownVideoRendering();
- }
-}
-
-void MediaPlayerPrivate::repaint()
-{
-#if DRAW_FRAME_RATE
- if (m_startedPlaying) {
- m_frameCountWhilePlaying++;
- // to eliminate preroll costs from our calculation,
- // our frame rate calculation excludes the first frame drawn after playback starts
- if (1==m_frameCountWhilePlaying)
- m_timeStartedPlaying = [NSDate timeIntervalSinceReferenceDate];
- }
-#endif
- m_player->repaint();
-}
-
-void MediaPlayerPrivate::paint(GraphicsContext* context, const IntRect& r)
-{
- if (context->paintingDisabled())
- return;
- NSView *view = m_qtMovieView.get();
- id qtVideoRenderer = m_qtVideoRenderer.get();
- if (!view && !qtVideoRenderer)
- return;
-
- [m_objcObserver.get() setDelayCallbacks:YES];
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- context->save();
- context->translate(r.x(), r.y() + r.height());
- context->scale(FloatSize(1.0f, -1.0f));
- context->setImageInterpolationQuality(InterpolationLow);
- IntRect paintRect(IntPoint(0, 0), IntSize(r.width(), r.height()));
- NSGraphicsContext* newContext = [NSGraphicsContext graphicsContextWithGraphicsPort:context->platformContext() flipped:NO];
-
- // draw the current video frame
- if (qtVideoRenderer) {
- [NSGraphicsContext saveGraphicsState];
- [NSGraphicsContext setCurrentContext:newContext];
- [(id<WebKitVideoRenderingDetails>)qtVideoRenderer drawInRect:paintRect];
- [NSGraphicsContext restoreGraphicsState];
- } else
- [view displayRectIgnoringOpacity:paintRect inContext:newContext];
-
-#if DRAW_FRAME_RATE
- // Draw the frame rate only after having played more than 10 frames.
- if (m_frameCountWhilePlaying > 10) {
- Frame* frame = m_player->m_frameView ? m_player->m_frameView->frame() : NULL;
- Document* document = frame ? frame->document() : NULL;
- RenderObject* renderer = document ? document->renderer() : NULL;
- RenderStyle* styleToUse = renderer ? renderer->style() : NULL;
- if (styleToUse) {
- double frameRate = (m_frameCountWhilePlaying - 1) / ( m_startedPlaying ? ([NSDate timeIntervalSinceReferenceDate] - m_timeStartedPlaying) :
- (m_timeStoppedPlaying - m_timeStartedPlaying) );
- String text = String::format("%1.2f", frameRate);
- TextRun textRun(text.characters(), text.length());
- const Color color(255, 0, 0);
- context->scale(FloatSize(1.0f, -1.0f));
- context->setFont(styleToUse->font());
- context->setStrokeColor(color);
- context->setStrokeStyle(SolidStroke);
- context->setStrokeThickness(1.0f);
- context->setFillColor(color);
- context->drawText(textRun, IntPoint(2, -3));
- }
- }
-#endif
-
- context->restore();
- END_BLOCK_OBJC_EXCEPTIONS;
- [m_objcObserver.get() setDelayCallbacks:NO];
-}
-
-void MediaPlayerPrivate::getSupportedTypes(HashSet<String>& types)
-{
- NSArray* fileTypes = [QTMovie movieFileTypes:QTIncludeCommonTypes];
- int count = [fileTypes count];
- for (int n = 0; n < count; n++) {
- CFStringRef ext = reinterpret_cast<CFStringRef>([fileTypes objectAtIndex:n]);
- RetainPtr<CFStringRef> uti(AdoptCF, UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, ext, NULL));
- if (!uti)
- continue;
- RetainPtr<CFStringRef> mime(AdoptCF, UTTypeCopyPreferredTagWithClass(uti.get(), kUTTagClassMIMEType));
- if (!mime)
- continue;
- types.add(mime.get());
- }
-}
-
-bool MediaPlayerPrivate::isAvailable()
-{
-#ifdef BUILDING_ON_TIGER
- SInt32 version;
- OSErr result;
- result = Gestalt(gestaltQuickTime, &version);
- if (result != noErr) {
- LOG_ERROR("No QuickTime available. Disabling <video> and <audio> support.");
- return false;
- }
- if (version < minimumQuickTimeVersion) {
- LOG_ERROR("QuickTime version %x detected, at least %x required. Disabling <video> and <audio> support.", version, minimumQuickTimeVersion);
- return false;
- }
- return true;
-#else
- // On 10.5 and higher, QuickTime will always be new enough for <video> and <audio> support, so we just check that the framework can be loaded.
- return QTKitLibrary();
-#endif
-}
-
-void MediaPlayerPrivate::disableUnsupportedTracks(unsigned& enabledTrackCount)
-{
- if (!m_qtMovie) {
- enabledTrackCount = 0;
- return;
- }
-
- static HashSet<String>* allowedTrackTypes = 0;
- if (!allowedTrackTypes) {
- allowedTrackTypes = new HashSet<String>;
- allowedTrackTypes->add(QTMediaTypeVideo);
- allowedTrackTypes->add(QTMediaTypeSound);
- allowedTrackTypes->add(QTMediaTypeText);
- allowedTrackTypes->add(QTMediaTypeBase);
- allowedTrackTypes->add("clcp");
- allowedTrackTypes->add("sbtl");
- }
-
- NSArray *tracks = [m_qtMovie.get() tracks];
-
- unsigned trackCount = [tracks count];
- enabledTrackCount = trackCount;
- for (unsigned trackIndex = 0; trackIndex < trackCount; trackIndex++) {
- // Grab the track at the current index. If there isn't one there, then
- // we can move onto the next one.
- QTTrack *track = [tracks objectAtIndex:trackIndex];
- if (!track)
- continue;
-
- // Check to see if the track is disabled already, we should move along.
- // We don't need to re-disable it.
- if (![track isEnabled])
- continue;
-
- // Grab the track's media. We're going to check to see if we need to
- // disable the tracks. They could be unsupported.
- QTMedia *trackMedia = [track media];
- if (!trackMedia)
- continue;
-
- // Grab the media type for this track.
- NSString *mediaType = [trackMedia attributeForKey:QTMediaTypeAttribute];
- if (!mediaType)
- continue;
-
- // Test whether the media type is in our white list.
- if (!allowedTrackTypes->contains(mediaType)) {
- // If this track type is not allowed, then we need to disable it.
- [track setEnabled:NO];
- --enabledTrackCount;
- }
-
- // Disable chapter tracks. These are most likely to lead to trouble, as
- // they will be composited under the video tracks, forcing QT to do extra
- // work.
- QTTrack *chapterTrack = [track performSelector:@selector(chapterlist)];
- if (!chapterTrack)
- continue;
-
- // Try to grab the media for the track.
- QTMedia *chapterMedia = [chapterTrack media];
- if (!chapterMedia)
- continue;
-
- // Grab the media type for this track.
- id chapterMediaType = [chapterMedia attributeForKey:QTMediaTypeAttribute];
- if (!chapterMediaType)
- continue;
-
- // Check to see if the track is a video track. We don't care about
- // other non-video tracks.
- if (![chapterMediaType isEqual:QTMediaTypeVideo])
- continue;
-
- // Check to see if the track is already disabled. If it is, we
- // should move along.
- if (![chapterTrack isEnabled])
- continue;
-
- // Disable the evil, evil track.
- [chapterTrack setEnabled:NO];
- --enabledTrackCount;
- }
-}
-
-}
-
-@implementation WebCoreMovieObserver
-
-- (id)initWithCallback:(MediaPlayerPrivate *)callback
-{
- m_callback = callback;
- return [super init];
-}
-
-- (void)disconnect
-{
- [NSObject cancelPreviousPerformRequestsWithTarget:self];
- m_callback = 0;
-}
-
--(NSMenu*)menuForEventDelegate:(NSEvent*)theEvent
-{
- // Get the contextual menu from the QTMovieView's superview, the frame view
- return [[m_view superview] menuForEvent:theEvent];
-}
-
--(void)setView:(NSView*)view
-{
- m_view = view;
-}
-
--(void)repaint
-{
- if (m_delayCallbacks)
- [self performSelector:_cmd withObject:nil afterDelay:0.];
- else if (m_callback)
- m_callback->repaint();
-}
-
-- (void)loadStateChanged:(NSNotification *)notification
-{
- if (m_delayCallbacks)
- [self performSelector:_cmd withObject:nil afterDelay:0];
- else
- m_callback->loadStateChanged();
-}
-
-- (void)rateChanged:(NSNotification *)notification
-{
- if (m_delayCallbacks)
- [self performSelector:_cmd withObject:nil afterDelay:0];
- else
- m_callback->rateChanged();
-}
-
-- (void)sizeChanged:(NSNotification *)notification
-{
- if (m_delayCallbacks)
- [self performSelector:_cmd withObject:nil afterDelay:0];
- else
- m_callback->sizeChanged();
-}
-
-- (void)timeChanged:(NSNotification *)notification
-{
- if (m_delayCallbacks)
- [self performSelector:_cmd withObject:nil afterDelay:0];
- else
- m_callback->timeChanged();
-}
-
-- (void)didEnd:(NSNotification *)notification
-{
- if (m_delayCallbacks)
- [self performSelector:_cmd withObject:nil afterDelay:0];
- else
- m_callback->didEnd();
-}
-
-- (void)newImageAvailable:(NSNotification *)notification
-{
- [self repaint];
-}
-
-- (void)setDelayCallbacks:(BOOL)shouldDelay
-{
- m_delayCallbacks = shouldDelay;
-}
-
-@end
-
-#endif
diff --git a/WebCore/platform/graphics/mac/SimpleFontDataMac.mm b/WebCore/platform/graphics/mac/SimpleFontDataMac.mm
deleted file mode 100644
index 4ee5933..0000000
--- a/WebCore/platform/graphics/mac/SimpleFontDataMac.mm
+++ /dev/null
@@ -1,435 +0,0 @@
-/*
- * Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2006 Alexey Proskuryakov
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "SimpleFontData.h"
-
-#import "BlockExceptions.h"
-#import "Color.h"
-#import "FloatRect.h"
-#import "Font.h"
-#import "FontCache.h"
-#import "FontDescription.h"
-#import "SharedBuffer.h"
-#import "WebCoreSystemInterface.h"
-#import <ApplicationServices/ApplicationServices.h>
-#import <float.h>
-#import <unicode/uchar.h>
-#import <wtf/Assertions.h>
-#import <wtf/RetainPtr.h>
-
-@interface NSFont (WebAppKitSecretAPI)
-- (BOOL)_isFakeFixedPitch;
-@end
-
-namespace WebCore {
-
-const float smallCapsFontSizeMultiplier = 0.7f;
-const float contextDPI = 72.0f;
-static inline float scaleEmToUnits(float x, unsigned unitsPerEm) { return x * (contextDPI / (contextDPI * unitsPerEm)); }
-
-bool initFontData(SimpleFontData* fontData)
-{
- if (!fontData->m_font.cgFont())
- return false;
-
-#ifdef BUILDING_ON_TIGER
- ATSUStyle fontStyle;
- if (ATSUCreateStyle(&fontStyle) != noErr)
- return false;
-
- ATSUFontID fontId = fontData->m_font.m_atsuFontID;
- if (!fontId) {
- ATSUDisposeStyle(fontStyle);
- return false;
- }
-
- ATSUAttributeTag tag = kATSUFontTag;
- ByteCount size = sizeof(ATSUFontID);
- ATSUFontID *valueArray[1] = {&fontId};
- OSStatus status = ATSUSetAttributes(fontStyle, 1, &tag, &size, (void* const*)valueArray);
- if (status != noErr) {
- ATSUDisposeStyle(fontStyle);
- return false;
- }
-
- if (wkGetATSStyleGroup(fontStyle, &fontData->m_styleGroup) != noErr) {
- ATSUDisposeStyle(fontStyle);
- return false;
- }
-
- ATSUDisposeStyle(fontStyle);
-#endif
-
- return true;
-}
-
-static NSString *webFallbackFontFamily(void)
-{
- static RetainPtr<NSString> webFallbackFontFamily = nil;
- if (!webFallbackFontFamily)
- webFallbackFontFamily = [[NSFont systemFontOfSize:16.0f] familyName];
- return webFallbackFontFamily.get();
-}
-
-#if !ERROR_DISABLED
-#ifdef __LP64__
-static NSString* pathFromFont(NSFont*)
-{
- // FMGetATSFontRefFromFont is not available in 64-bit. As pathFromFont is only used for debugging
- // purposes, returning nil is acceptable.
- return nil;
-}
-#else
-static NSString* pathFromFont(NSFont *font)
-{
-#ifndef BUILDING_ON_TIGER
- ATSFontRef atsFont = FMGetATSFontRefFromFont(CTFontGetPlatformFont(toCTFontRef(font), 0));
-#else
- ATSFontRef atsFont = FMGetATSFontRefFromFont(wkGetNSFontATSUFontId(font));
-#endif
- FSRef fileRef;
-
-#ifndef BUILDING_ON_TIGER
- OSStatus status = ATSFontGetFileReference(atsFont, &fileRef);
- if (status != noErr)
- return nil;
-#else
- FSSpec oFile;
- OSStatus status = ATSFontGetFileSpecification(atsFont, &oFile);
- if (status != noErr)
- return nil;
-
- status = FSpMakeFSRef(&oFile, &fileRef);
- if (status != noErr)
- return nil;
-#endif
-
- UInt8 filePathBuffer[PATH_MAX];
- status = FSRefMakePath(&fileRef, filePathBuffer, PATH_MAX);
- if (status == noErr)
- return [NSString stringWithUTF8String:(const char*)filePathBuffer];
-
- return nil;
-}
-#endif // __LP64__
-#endif // !ERROR_DISABLED
-
-void SimpleFontData::platformInit()
-{
-#ifdef BUILDING_ON_TIGER
- m_styleGroup = 0;
-#endif
-#if USE(ATSUI)
- m_ATSUStyleInitialized = false;
- m_ATSUMirrors = false;
- m_checkedShapesArabic = false;
- m_shapesArabic = false;
-#endif
-
- m_syntheticBoldOffset = m_font.m_syntheticBold ? 1.0f : 0.f;
-
- bool failedSetup = false;
- if (!initFontData(this)) {
- // Ack! Something very bad happened, like a corrupt font.
- // Try looking for an alternate 'base' font for this renderer.
-
- // Special case hack to use "Times New Roman" in place of "Times".
- // "Times RO" is a common font whose family name is "Times".
- // It overrides the normal "Times" family font.
- // It also appears to have a corrupt regular variant.
- NSString *fallbackFontFamily;
- if ([[m_font.font() familyName] isEqual:@"Times"])
- fallbackFontFamily = @"Times New Roman";
- else
- fallbackFontFamily = webFallbackFontFamily();
-
- // Try setting up the alternate font.
- // This is a last ditch effort to use a substitute font when something has gone wrong.
-#if !ERROR_DISABLED
- RetainPtr<NSFont> initialFont = m_font.font();
-#endif
- if (m_font.font())
- m_font.setFont([[NSFontManager sharedFontManager] convertFont:m_font.font() toFamily:fallbackFontFamily]);
- else
- m_font.setFont([NSFont fontWithName:fallbackFontFamily size:m_font.size()]);
-#if !ERROR_DISABLED
- NSString *filePath = pathFromFont(initialFont.get());
- if (!filePath)
- filePath = @"not known";
-#endif
- if (!initFontData(this)) {
- if ([fallbackFontFamily isEqual:@"Times New Roman"]) {
- // OK, couldn't setup Times New Roman as an alternate to Times, fallback
- // on the system font. If this fails we have no alternative left.
- m_font.setFont([[NSFontManager sharedFontManager] convertFont:m_font.font() toFamily:webFallbackFontFamily()]);
- if (!initFontData(this)) {
- // We tried, Times, Times New Roman, and the system font. No joy. We have to give up.
- LOG_ERROR("unable to initialize with font %@ at %@", initialFont.get(), filePath);
- failedSetup = true;
- }
- } else {
- // We tried the requested font and the system font. No joy. We have to give up.
- LOG_ERROR("unable to initialize with font %@ at %@", initialFont.get(), filePath);
- failedSetup = true;
- }
- }
-
- // Report the problem.
- LOG_ERROR("Corrupt font detected, using %@ in place of %@ located at \"%@\".",
- [m_font.font() familyName], [initialFont.get() familyName], filePath);
- }
-
- // If all else fails, try to set up using the system font.
- // This is probably because Times and Times New Roman are both unavailable.
- if (failedSetup) {
- m_font.setFont([NSFont systemFontOfSize:[m_font.font() pointSize]]);
- LOG_ERROR("failed to set up font, using system font %s", m_font.font());
- initFontData(this);
- }
-
- int iAscent;
- int iDescent;
- int iLineGap;
-#ifdef BUILDING_ON_TIGER
- wkGetFontMetrics(m_font.cgFont(), &iAscent, &iDescent, &iLineGap, &m_unitsPerEm);
-#else
- iAscent = CGFontGetAscent(m_font.cgFont());
- iDescent = CGFontGetDescent(m_font.cgFont());
- iLineGap = CGFontGetLeading(m_font.cgFont());
- m_unitsPerEm = CGFontGetUnitsPerEm(m_font.cgFont());
-#endif
-
- float pointSize = m_font.m_size;
- float fAscent = scaleEmToUnits(iAscent, m_unitsPerEm) * pointSize;
- float fDescent = -scaleEmToUnits(iDescent, m_unitsPerEm) * pointSize;
- float fLineGap = scaleEmToUnits(iLineGap, m_unitsPerEm) * pointSize;
-
- // We need to adjust Times, Helvetica, and Courier to closely match the
- // vertical metrics of their Microsoft counterparts that are the de facto
- // web standard. The AppKit adjustment of 20% is too big and is
- // incorrectly added to line spacing, so we use a 15% adjustment instead
- // and add it to the ascent.
- NSString *familyName = [m_font.font() familyName];
- if ([familyName isEqualToString:@"Times"] || [familyName isEqualToString:@"Helvetica"] || [familyName isEqualToString:@"Courier"])
- fAscent += floorf(((fAscent + fDescent) * 0.15f) + 0.5f);
- else if ([familyName isEqualToString:@"Geeza Pro"]) {
- // Geeza Pro has glyphs that draw slightly above the ascent or far below the descent. Adjust
- // those vertical metrics to better match reality, so that diacritics at the bottom of one line
- // do not overlap diacritics at the top of the next line.
- fAscent *= 1.08f;
- fDescent *= 2.f;
- }
-
- m_ascent = lroundf(fAscent);
- m_descent = lroundf(fDescent);
- m_lineGap = lroundf(fLineGap);
- m_lineSpacing = m_ascent + m_descent + m_lineGap;
-
- // Hack Hiragino line metrics to allow room for marked text underlines.
- // <rdar://problem/5386183>
- if (m_descent < 3 && m_lineGap >= 3 && [familyName hasPrefix:@"Hiragino"]) {
- m_lineGap -= 3 - m_descent;
- m_descent = 3;
- }
-
- // Measure the actual character "x", because AppKit synthesizes X height rather than getting it from the font.
- // Unfortunately, NSFont will round this for us so we don't quite get the right value.
- GlyphPage* glyphPageZero = GlyphPageTreeNode::getRootChild(this, 0)->page();
- NSGlyph xGlyph = glyphPageZero ? glyphPageZero->glyphDataForCharacter('x').glyph : 0;
- if (xGlyph) {
- NSRect xBox = [m_font.font() boundingRectForGlyph:xGlyph];
- // Use the maximum of either width or height because "x" is nearly square
- // and web pages that foolishly use this metric for width will be laid out
- // poorly if we return an accurate height. Classic case is Times 13 point,
- // which has an "x" that is 7x6 pixels.
- m_xHeight = MAX(NSMaxX(xBox), NSMaxY(xBox));
- } else
- m_xHeight = [m_font.font() xHeight];
-}
-
-void SimpleFontData::platformDestroy()
-{
-#ifdef BUILDING_ON_TIGER
- if (m_styleGroup)
- wkReleaseStyleGroup(m_styleGroup);
-#endif
-#if USE(ATSUI)
- if (m_ATSUStyleInitialized)
- ATSUDisposeStyle(m_ATSUStyle);
-#endif
-}
-
-SimpleFontData* SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const
-{
- if (!m_smallCapsFontData) {
- if (isCustomFont()) {
- FontPlatformData smallCapsFontData(m_font);
- smallCapsFontData.m_size = smallCapsFontData.m_size * smallCapsFontSizeMultiplier;
- m_smallCapsFontData = new SimpleFontData(smallCapsFontData, true, false);
- } else {
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- float size = [m_font.font() pointSize] * smallCapsFontSizeMultiplier;
- FontPlatformData smallCapsFont([[NSFontManager sharedFontManager] convertFont:m_font.font() toSize:size]);
-
- // AppKit resets the type information (screen/printer) when you convert a font to a different size.
- // We have to fix up the font that we're handed back.
- smallCapsFont.setFont(fontDescription.usePrinterFont() ? [smallCapsFont.font() printerFont] : [smallCapsFont.font() screenFont]);
-
- if (smallCapsFont.font()) {
- NSFontManager *fontManager = [NSFontManager sharedFontManager];
- NSFontTraitMask fontTraits = [fontManager traitsOfFont:m_font.font()];
-
- if (m_font.m_syntheticBold)
- fontTraits |= NSBoldFontMask;
- if (m_font.m_syntheticOblique)
- fontTraits |= NSItalicFontMask;
-
- NSFontTraitMask smallCapsFontTraits = [fontManager traitsOfFont:smallCapsFont.font()];
- smallCapsFont.m_syntheticBold = (fontTraits & NSBoldFontMask) && !(smallCapsFontTraits & NSBoldFontMask);
- smallCapsFont.m_syntheticOblique = (fontTraits & NSItalicFontMask) && !(smallCapsFontTraits & NSItalicFontMask);
-
- m_smallCapsFontData = FontCache::getCachedFontData(&smallCapsFont);
- }
- END_BLOCK_OBJC_EXCEPTIONS;
- }
- }
- return m_smallCapsFontData;
-}
-
-bool SimpleFontData::containsCharacters(const UChar* characters, int length) const
-{
- NSString *string = [[NSString alloc] initWithCharactersNoCopy:(UniChar*)characters length:length freeWhenDone:NO];
- NSCharacterSet *set = [[m_font.font() coveredCharacterSet] invertedSet];
- bool result = set && [string rangeOfCharacterFromSet:set].location == NSNotFound;
- [string release];
- return result;
-}
-
-void SimpleFontData::determinePitch()
-{
- NSFont* f = m_font.font();
- // Special case Osaka-Mono.
- // According to <rdar://problem/3999467>, we should treat Osaka-Mono as fixed pitch.
- // Note that the AppKit does not report Osaka-Mono as fixed pitch.
-
- // Special case MS-PGothic.
- // According to <rdar://problem/4032938>, we should not treat MS-PGothic as fixed pitch.
- // Note that AppKit does report MS-PGothic as fixed pitch.
-
- // Special case MonotypeCorsiva
- // According to <rdar://problem/5454704>, we should not treat MonotypeCorsiva as fixed pitch.
- // Note that AppKit does report MonotypeCorsiva as fixed pitch.
-
- NSString *name = [f fontName];
- m_treatAsFixedPitch = ([f isFixedPitch] || [f _isFakeFixedPitch] ||
- [name caseInsensitiveCompare:@"Osaka-Mono"] == NSOrderedSame) &&
- [name caseInsensitiveCompare:@"MS-PGothic"] != NSOrderedSame &&
- [name caseInsensitiveCompare:@"MonotypeCorsiva"] != NSOrderedSame;
-}
-
-float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
-{
- NSFont* font = m_font.font();
- float pointSize = m_font.m_size;
- CGAffineTransform m = CGAffineTransformMakeScale(pointSize, pointSize);
- CGSize advance;
- if (!wkGetGlyphTransformedAdvances(m_font.cgFont(), font, &m, &glyph, &advance)) {
- LOG_ERROR("Unable to cache glyph widths for %@ %f", [font displayName], pointSize);
- advance.width = 0;
- }
- return advance.width + m_syntheticBoldOffset;
-}
-
-#if USE(ATSUI)
-void SimpleFontData::checkShapesArabic() const
-{
- ASSERT(!m_checkedShapesArabic);
-
- m_checkedShapesArabic = true;
-
- ATSUFontID fontID = m_font.m_atsuFontID;
- if (!fontID) {
- LOG_ERROR("unable to get ATSUFontID for %@", m_font.font());
- return;
- }
-
- // This function is called only on fonts that contain Arabic glyphs. Our
- // heuristic is that if such a font has a glyph metamorphosis table, then
- // it includes shaping information for Arabic.
- FourCharCode tables[] = { 'morx', 'mort' };
- for (unsigned i = 0; i < sizeof(tables) / sizeof(tables[0]); ++i) {
- ByteCount tableSize;
- OSStatus status = ATSFontGetTable(fontID, tables[i], 0, 0, 0, &tableSize);
- if (status == noErr) {
- m_shapesArabic = true;
- return;
- }
-
- if (status != kATSInvalidFontTableAccess)
- LOG_ERROR("ATSFontGetTable failed (%d)", status);
- }
-}
-#endif
-
-#if USE(CORE_TEXT)
-CTFontRef SimpleFontData::getCTFont() const
-{
- if (getNSFont())
- return toCTFontRef(getNSFont());
- if (!m_CTFont)
- m_CTFont.adoptCF(CTFontCreateWithGraphicsFont(m_font.cgFont(), m_font.size(), NULL, NULL));
- return m_CTFont.get();
-}
-
-CFDictionaryRef SimpleFontData::getCFStringAttributes() const
-{
- if (m_CFStringAttributes)
- return m_CFStringAttributes.get();
-
- static const float kerningAdjustmentValue = 0;
- static CFNumberRef kerningAdjustment = CFNumberCreate(kCFAllocatorDefault, kCFNumberFloatType, &kerningAdjustmentValue);
-
- static const int ligaturesNotAllowedValue = 0;
- static CFNumberRef ligaturesNotAllowed = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &ligaturesNotAllowedValue);
-
- static const int ligaturesAllowedValue = 1;
- static CFNumberRef ligaturesAllowed = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &ligaturesAllowedValue);
-
- static const void* attributeKeys[] = { kCTFontAttributeName, kCTKernAttributeName, kCTLigatureAttributeName };
- const void* attributeValues[] = { getCTFont(), kerningAdjustment, platformData().allowsLigatures() ? ligaturesAllowed : ligaturesNotAllowed };
-
- m_CFStringAttributes.adoptCF(CFDictionaryCreate(NULL, attributeKeys, attributeValues, sizeof(attributeKeys) / sizeof(*attributeKeys), &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
-
- return m_CFStringAttributes.get();
-}
-
-#endif
-
-} // namespace WebCore
diff --git a/WebCore/platform/graphics/qt/AffineTransformQt.cpp b/WebCore/platform/graphics/qt/AffineTransformQt.cpp
deleted file mode 100644
index 2793043..0000000
--- a/WebCore/platform/graphics/qt/AffineTransformQt.cpp
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "AffineTransform.h"
-
-#include "IntRect.h"
-#include "FloatRect.h"
-
-namespace WebCore {
-
-AffineTransform::AffineTransform()
- : m_transform()
-{
-}
-
-AffineTransform::AffineTransform(double a, double b, double c, double d, double tx, double ty)
- : m_transform(a, b, c, d, tx, ty)
-{
-}
-
-AffineTransform::AffineTransform(const PlatformAffineTransform& matrix)
- : m_transform(matrix)
-{
-}
-
-void AffineTransform::setMatrix(double a, double b, double c, double d, double tx, double ty)
-{
- m_transform.setMatrix(a, b, c, d, tx, ty);
-}
-
-void AffineTransform::map(double x, double y, double* x2, double* y2) const
-{
- qreal tx2, ty2;
- m_transform.map(qreal(x), qreal(y), &tx2, &ty2);
- *x2 = tx2;
- *y2 = ty2;
-}
-
-IntRect AffineTransform::mapRect(const IntRect& rect) const
-{
- return m_transform.mapRect(rect);
-}
-
-FloatRect AffineTransform::mapRect(const FloatRect& rect) const
-{
- return m_transform.mapRect(rect);
-}
-
-bool AffineTransform::isIdentity() const
-{
- return m_transform.isIdentity();
-}
-
-double AffineTransform::a() const
-{
- return m_transform.m11();
-}
-
-void AffineTransform::setA(double a)
-{
- m_transform.setMatrix(a, b(), c(), d(), e(), f());
-}
-
-double AffineTransform::b() const
-{
- return m_transform.m12();
-}
-
-void AffineTransform::setB(double b)
-{
- m_transform.setMatrix(a(), b, c(), d(), e(), f());
-}
-
-double AffineTransform::c() const
-{
- return m_transform.m21();
-}
-
-void AffineTransform::setC(double c)
-{
- m_transform.setMatrix(a(), b(), c, d(), e(), f());
-}
-
-double AffineTransform::d() const
-{
- return m_transform.m22();
-}
-
-void AffineTransform::setD(double d)
-{
- m_transform.setMatrix(a(), b(), c(), d, e(), f());
-}
-
-double AffineTransform::e() const
-{
- return m_transform.dx();
-}
-
-void AffineTransform::setE(double e)
-{
- m_transform.setMatrix(a(), b(), c(), d(), e, f());
-}
-
-double AffineTransform::f() const
-{
- return m_transform.dy();
-}
-
-void AffineTransform::setF(double f)
-{
- m_transform.setMatrix(a(), b(), c(), d(), e(), f);
-}
-
-void AffineTransform::reset()
-{
- m_transform.reset();
-}
-
-AffineTransform& AffineTransform::scale(double sx, double sy)
-{
- m_transform.scale(sx, sy);
- return *this;
-}
-
-AffineTransform& AffineTransform::rotate(double d)
-{
- m_transform.rotate(d);
- return *this;
-}
-
-AffineTransform& AffineTransform::translate(double tx, double ty)
-{
- m_transform.translate(tx, ty);
- return *this;
-}
-
-AffineTransform& AffineTransform::shear(double sx, double sy)
-{
- m_transform.shear(sx, sy);
- return *this;
-}
-
-double AffineTransform::det() const
-{
- return m_transform.det();
-}
-
-AffineTransform AffineTransform::inverse() const
-{
- if(!isInvertible())
- return AffineTransform();
-
- return m_transform.inverted();
-}
-
-AffineTransform::operator QMatrix() const
-{
- return m_transform;
-}
-
-bool AffineTransform::operator==(const AffineTransform& other) const
-{
- return m_transform == other.m_transform;
-}
-
-AffineTransform& AffineTransform::operator*=(const AffineTransform& other)
-{
- m_transform *= other.m_transform;
- return *this;
-}
-
-AffineTransform AffineTransform::operator*(const AffineTransform& other)
-{
- return m_transform * other.m_transform;
-}
-
-}
-
-// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/graphics/qt/ColorQt.cpp b/WebCore/platform/graphics/qt/ColorQt.cpp
deleted file mode 100644
index 5d16740..0000000
--- a/WebCore/platform/graphics/qt/ColorQt.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2006 Zack Rusin <zack@kde.org>
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Color.h"
-
-#include <QColor>
-
-namespace WebCore {
-
-Color::Color(const QColor& c)
- : m_color(makeRGBA(c.red(), c.green(), c.blue(), c.alpha()))
-{
- m_valid = c.isValid();
-}
-
-Color::operator QColor() const
-{
- return QColor(red(), green(), blue(), alpha());
-}
-
-}
-
-// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/graphics/qt/FloatPointQt.cpp b/WebCore/platform/graphics/qt/FloatPointQt.cpp
deleted file mode 100644
index 82093d8..0000000
--- a/WebCore/platform/graphics/qt/FloatPointQt.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2006 Zack Rusin <zack@kde.org>
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FloatPoint.h"
-
-#include <QPointF>
-
-namespace WebCore {
-
-FloatPoint::FloatPoint(const QPointF& p)
- : m_x(p.x())
- , m_y(p.y())
-{
-}
-
-FloatPoint::operator QPointF() const
-{
- return QPointF(m_x, m_y);
-}
-
-}
-
-// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/graphics/qt/FloatRectQt.cpp b/WebCore/platform/graphics/qt/FloatRectQt.cpp
deleted file mode 100644
index 1c918e3..0000000
--- a/WebCore/platform/graphics/qt/FloatRectQt.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2006 Zack Rusin <zack@kde.org>
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FloatRect.h"
-
-#include <QRectF>
-
-namespace WebCore {
-
-FloatRect::FloatRect(const QRectF& r)
- : m_location(r.topLeft())
- , m_size(r.width()
- , r.height())
-{
-}
-
-FloatRect::operator QRectF() const
-{
- return QRectF(x(), y(), width(), height());
-}
-
-}
-
-// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/graphics/qt/FontCacheQt.cpp b/WebCore/platform/graphics/qt/FontCacheQt.cpp
deleted file mode 100644
index be31d96..0000000
--- a/WebCore/platform/graphics/qt/FontCacheQt.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-
- This class provides all functionality needed for loading images, style sheets and html
- pages from the web. It has a memory cache for these objects.
-*/
-#include "config.h"
-#include "FontCache.h"
-#include "FontDescription.h"
-#include "Font.h"
-
-namespace WebCore {
-
-void FontCache::getTraitsInFamily(const AtomicString& familyName, Vector<unsigned>& traitsMasks)
-{
-}
-
-FontPlatformData* FontCache::getCachedFontPlatformData(const FontDescription&, const AtomicString& family, bool checkingAlternateName)
-{
- return 0;
-}
-
-SimpleFontData* FontCache::getCachedFontData(const FontPlatformData*)
-{
- return 0;
-}
-
-FontPlatformData* FontCache::getLastResortFallbackFont(const FontDescription&)
-{
- return 0;
-}
-
-void FontCache::addClient(FontSelector*)
-{
-}
-
-void FontCache::removeClient(FontSelector*)
-{
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/graphics/qt/FontCustomPlatformData.cpp b/WebCore/platform/graphics/qt/FontCustomPlatformData.cpp
deleted file mode 100644
index 8fc3ea0..0000000
--- a/WebCore/platform/graphics/qt/FontCustomPlatformData.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-
- This class provides all functionality needed for loading images, style sheets and html
- pages from the web. It has a memory cache for these objects.
-*/
-#include "config.h"
-#include "FontCustomPlatformData.h"
-
-#include "FontPlatformData.h"
-#include "SharedBuffer.h"
-#include <QFontDatabase>
-
-namespace WebCore {
-
-FontCustomPlatformData::~FontCustomPlatformData()
-{
- QFontDatabase::removeApplicationFont(handle);
-}
-
-FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontRenderingMode)
-{
- FontPlatformData result;
- result.handle = handle;
- return result;
-}
-
-FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer)
-{
- ASSERT_ARG(buffer, buffer);
-
- int id = QFontDatabase::addApplicationFontFromData(QByteArray(buffer->data(), buffer->size()));
- if (id == -1)
- return 0;
- FontCustomPlatformData *data = new FontCustomPlatformData;
- data->handle = id;
- return data;
-}
-
-}
-
diff --git a/WebCore/platform/graphics/qt/FontCustomPlatformData.h b/WebCore/platform/graphics/qt/FontCustomPlatformData.h
deleted file mode 100644
index da5159d..0000000
--- a/WebCore/platform/graphics/qt/FontCustomPlatformData.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-
- This class provides all functionality needed for loading images, style sheets and html
- pages from the web. It has a memory cache for these objects.
-*/
-#ifndef FontCustomPlatformData_h_
-#define FontCustomPlatformData_h_
-
-#include "FontRenderingMode.h"
-#include <wtf/Noncopyable.h>
-
-namespace WebCore {
-
-class SharedBuffer;
-class FontPlatformData;
-
-struct FontCustomPlatformData : Noncopyable {
- ~FontCustomPlatformData();
-
- int handle; // for use with QFontDatabase::addApplicationFont/removeApplicationFont
-
- FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontRenderingMode = NormalRenderingMode);
-};
-
-FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer);
-
-} // namespace WebCore
-
-#endif // FontCustomPlatformData_h_
diff --git a/WebCore/platform/graphics/qt/FontPlatformData.h b/WebCore/platform/graphics/qt/FontPlatformData.h
deleted file mode 100644
index e4363be..0000000
--- a/WebCore/platform/graphics/qt/FontPlatformData.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-
- This class provides all functionality needed for loading images, style sheets and html
- pages from the web. It has a memory cache for these objects.
-*/
-#ifndef FontPlatformData_h
-#define FontPlatformData_h
-
-namespace WebCore {
-
-class FontPlatformData
-{
-public:
- // this is only used for custom loaded fonts and represents the id handle passed to
- // QFontDatabase::addApplicationFont/removeApplicationFont
- int handle;
-};
-
-} // namespace WebCore
-
-#endif // FontPlatformData_h
diff --git a/WebCore/platform/graphics/qt/FontQt.cpp b/WebCore/platform/graphics/qt/FontQt.cpp
deleted file mode 100644
index e2ef605..0000000
--- a/WebCore/platform/graphics/qt/FontQt.cpp
+++ /dev/null
@@ -1,706 +0,0 @@
-/*
- Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include "config.h"
-#include "Font.h"
-#include "FontDescription.h"
-#include "FontSelector.h"
-
-#include "GraphicsContext.h"
-#include <QTextLayout>
-#include <QPainter>
-#include <QFontMetrics>
-#include <QFontInfo>
-#include <qalgorithms.h>
-#include <qdebug.h>
-
-#include <limits.h>
-namespace WebCore {
-
-#if QT_VERSION >= 0x040400
-
-Font::Font()
- : m_letterSpacing(0)
- , m_wordSpacing(0)
- , m_font()
- , m_scFont()
-{
- QFontMetrics metrics(m_font);
- m_spaceWidth = metrics.width(QLatin1Char(' '));
-}
-
-Font::Font(const FontDescription& description, short letterSpacing, short wordSpacing)
- : m_fontDescription(description)
- , m_letterSpacing(letterSpacing)
- , m_wordSpacing(wordSpacing)
-{
- const FontFamily* family = &description.family();
- QString familyName;
- while (family) {
- familyName += family->family();
- family = family->next();
- if (family)
- familyName += QLatin1Char(',');
- }
-
- m_font.setFamily(familyName);
- m_font.setPixelSize(qRound(description.computedSize()));
- m_font.setItalic(description.italic());
- // FIXME: Map all FontWeight values to QFont weights.
- if (description.weight() >= FontWeight600)
- m_font.setWeight(QFont::Bold);
- else
- m_font.setWeight(QFont::Normal);
-
- bool smallCaps = description.smallCaps();
- m_font.setCapitalization(smallCaps ? QFont::SmallCaps : QFont::MixedCase);
-
- QFontMetrics metrics = QFontMetrics(m_font);
- m_spaceWidth = metrics.width(QLatin1Char(' '));
-
- if (wordSpacing)
- m_font.setWordSpacing(wordSpacing);
- if (letterSpacing)
- m_font.setLetterSpacing(QFont::AbsoluteSpacing, letterSpacing);
-}
-
-void Font::setWordSpacing(short s)
-{
- m_font.setWordSpacing(s);
- m_wordSpacing = s;
-}
-void Font::setLetterSpacing(short s)
-{
- m_font.setLetterSpacing(QFont::AbsoluteSpacing, s);
- m_letterSpacing = s;
-}
-
-
-static QString qstring(const TextRun& run)
-{
- QString string((QChar *)run.characters(), run.length());
- QChar *uc = string.data();
- for (int i = 0; i < string.length(); ++i) {
- if (Font::treatAsSpace(uc[i].unicode()))
- uc[i] = 0x20;
- else if (Font::treatAsZeroWidthSpace(uc[i].unicode()))
- uc[i] = 0x200c;
- }
- return string;
-}
-
-
-static QTextLine setupLayout(QTextLayout* layout, const TextRun& style)
-{
- int flags = style.rtl() ? Qt::TextForceRightToLeft : Qt::TextForceLeftToRight;
- if (style.padding())
- flags |= Qt::TextJustificationForced;
- layout->setFlags(flags);
- layout->beginLayout();
- QTextLine line = layout->createLine();
- line.setLineWidth(INT_MAX/256);
- if (style.padding())
- line.setLineWidth(line.naturalTextWidth() + style.padding());
- layout->endLayout();
- return line;
-}
-
-void Font::drawText(GraphicsContext* ctx, const TextRun& run, const FloatPoint& point, int from, int to) const
-{
- if (to < 0)
- to = run.length();
- QPainter *p = ctx->platformContext();
- Color color = ctx->fillColor();
- p->setPen(QColor(color));
-
- QString string = qstring(run);
-
- // text shadow
- IntSize shadowSize;
- int shadowBlur;
- Color shadowColor;
- bool hasShadow = ctx->textDrawingMode() == cTextFill && ctx->getShadow(shadowSize, shadowBlur, shadowColor);
-
- if (from > 0 || to < run.length()) {
- QTextLayout layout(string, m_font);
- QTextLine line = setupLayout(&layout, run);
- float x1 = line.cursorToX(from);
- float x2 = line.cursorToX(to);
- if (x2 < x1)
- qSwap(x1, x2);
-
- QFontMetrics fm(m_font);
- int ascent = fm.ascent();
- QRectF clip(point.x() + x1, point.y() - ascent, x2 - x1, fm.height());
-
- if (hasShadow) {
- // TODO: when blur support is added, the clip will need to account
- // for the blur radius
- qreal dx1 = 0, dx2 = 0, dy1 = 0, dy2 = 0;
- if (shadowSize.width() > 0)
- dx2 = shadowSize.width();
- else
- dx1 = -shadowSize.width();
- if (shadowSize.height() > 0)
- dy2 = shadowSize.height();
- else
- dy1 = -shadowSize.height();
- // expand the clip rect to include the text shadow as well
- clip.adjust(dx1, dx2, dy1, dy2);
- }
- p->save();
- p->setClipRect(clip.toRect());
- QPointF pt(point.x(), point.y() - ascent);
- if (hasShadow) {
- p->save();
- p->setPen(QColor(shadowColor));
- p->translate(shadowSize.width(), shadowSize.height());
- line.draw(p, pt);
- p->restore();
- }
- line.draw(p, pt);
- p->restore();
- return;
- }
-
- p->setFont(m_font);
-
- QPointF pt(point.x(), point.y());
- int flags = run.rtl() ? Qt::TextForceRightToLeft : Qt::TextForceLeftToRight;
- if (hasShadow) {
- // TODO: text shadow blur support
- p->save();
- p->setPen(QColor(shadowColor));
- p->translate(shadowSize.width(), shadowSize.height());
- p->drawText(pt, string, flags, run.padding());
- p->restore();
- }
- p->drawText(pt, string, flags, run.padding());
-}
-
-int Font::width(const TextRun& run) const
-{
- if (!run.length())
- return 0;
- QString string = qstring(run);
- QTextLayout layout(string, m_font);
- QTextLine line = setupLayout(&layout, run);
- int w = int(line.naturalTextWidth());
- // WebKit expects us to ignore word spacing on the first character (as opposed to what Qt does)
- if (treatAsSpace(run[0]))
- w -= m_wordSpacing;
-
- return w + run.padding();
-}
-
-float Font::floatWidth(const TextRun& run) const
-{
- return width(run);
-}
-
-float Font::floatWidth(const TextRun& run, int /*extraCharsAvailable*/, int& charsConsumed, String& glyphName) const
-{
- charsConsumed = run.length();
- glyphName = "";
- return width(run);
-}
-
-int Font::offsetForPosition(const TextRun& run, int position, bool /*includePartialGlyphs*/) const
-{
- QString string = qstring(run);
- QTextLayout layout(string, m_font);
- QTextLine line = setupLayout(&layout, run);
- return line.xToCursor(position);
-}
-
-FloatRect Font::selectionRectForText(const TextRun& run, const IntPoint& pt, int h, int from, int to) const
-{
- QString string = qstring(run);
- QTextLayout layout(string, m_font);
- QTextLine line = setupLayout(&layout, run);
-
- float x1 = line.cursorToX(from);
- float x2 = line.cursorToX(to);
- if (x2 < x1)
- qSwap(x1, x2);
-
- return FloatRect(pt.x() + x1, pt.y(), x2 - x1, h);
-}
-
-#else
-
-
-struct TextRunComponent {
- TextRunComponent() : font(0) {}
- TextRunComponent(const UChar *start, int length, bool rtl, const QFont *font, int offset, bool sc = false);
- TextRunComponent(int spaces, bool rtl, const QFont *font, int offset);
-
- inline bool isSpace() const { return spaces != 0; }
-
- QString string;
- const QFont *font;
- int width;
- int offset;
- int spaces;
-};
-
-TextRunComponent::TextRunComponent(const UChar *start, int length, bool rtl, const QFont *f, int o, bool sc)
- : string(reinterpret_cast<const QChar*>(start), length)
- , font(f)
- , offset(o)
- , spaces(0)
-{
- if (sc)
- string = string.toUpper();
- string.prepend(rtl ? QChar(0x202e) : QChar(0x202d));
- width = QFontMetrics(*font).width(string);
-}
-
-TextRunComponent::TextRunComponent(int s, bool rtl, const QFont *f, int o)
- : string(s, QLatin1Char(' '))
- , font(f)
- , offset(o)
- , spaces(s)
-{
- string.prepend(rtl ? QChar(0x202e) : QChar(0x202d));
- width = spaces * QFontMetrics(*font).width(QLatin1Char(' '));
-}
-
-
-Font::Font()
- : m_letterSpacing(0)
- , m_wordSpacing(0)
- , m_font()
- , m_scFont()
-{
- QFontMetrics metrics(m_font);
- m_spaceWidth = metrics.width(QLatin1Char(' '));
- qreal pointsize = m_font.pointSizeF();
- if (pointsize > 0)
- m_scFont.setPointSizeF(pointsize*0.7);
- else
- m_scFont.setPixelSize(qRound(m_font.pixelSize()*.7));
-}
-
-Font::Font(const FontDescription& description, short letterSpacing, short wordSpacing)
- : m_fontDescription(description)
- , m_letterSpacing(letterSpacing)
- , m_wordSpacing(wordSpacing)
-{
- const FontFamily* family = &description.family();
- QString familyName;
- while (family) {
- familyName += family->family();
- family = family->next();
- if (family)
- familyName += QLatin1Char(',');
- }
-
- m_font.setFamily(familyName);
- m_font.setPixelSize(qRound(description.computedSize()));
- m_font.setItalic(description.italic());
- // FIXME: Map all FontWeight values to QFont weights.
- if (description.weight() >= FontWeight600)
- m_font.setWeight(QFont::Bold);
- else
- m_font.setWeight(QFont::Normal);
-
- QFontMetrics metrics = QFontMetrics(m_font);
- m_spaceWidth = metrics.width(QLatin1Char(' '));
- m_scFont = m_font;
- m_scFont.setPixelSize(qRound(description.computedSize()*.7));
-}
-
-void Font::setWordSpacing(short s)
-{
- m_wordSpacing = s;
-}
-void Font::setLetterSpacing(short s)
-{
- m_letterSpacing = s;
-}
-
-static int generateComponents(Vector<TextRunComponent, 1024>* components, const Font &font, const TextRun &run)
-{
-// qDebug() << "generateComponents" << QString((const QChar *)run.characters(), run.length());
- int letterSpacing = font.letterSpacing();
- int wordSpacing = font.wordSpacing();
- bool smallCaps = font.fontDescription().smallCaps();
- int padding = run.padding();
- int numSpaces = 0;
- if (padding) {
- for (int i = 0; i < run.length(); i++)
- if (Font::treatAsSpace(run[i]))
- ++numSpaces;
- }
-
- int offset = 0;
- const QFont *f = &font.font();
- if (letterSpacing || smallCaps) {
- // need to draw every letter on it's own
- int start = 0;
- if (Font::treatAsSpace(run[0])) {
- int add = 0;
- if (numSpaces) {
- add = padding/numSpaces;
- padding -= add;
- --numSpaces;
- }
- components->append(TextRunComponent(1, run.rtl(), &font.font(), offset));
- offset += add + letterSpacing + components->last().width;
- start = 1;
-// qDebug() << "space at 0" << offset;
- } else if (smallCaps) {
- f = (QChar::category(run[0]) == QChar::Letter_Lowercase ? &font.scFont() : &font.font());
- }
- for (int i = 1; i < run.length(); ++i) {
- uint ch = run[i];
- if (QChar(ch).isHighSurrogate() && QChar(run[i-1]).isLowSurrogate())
- ch = QChar::surrogateToUcs4(ch, run[i-1]);
- if (QChar(ch).isLowSurrogate() || QChar::category(ch) == QChar::Mark_NonSpacing)
- continue;
- if (Font::treatAsSpace(run[i])) {
- int add = 0;
-// qDebug() << " treatAsSpace:" << i << start;
- if (i - start > 0) {
- components->append(TextRunComponent(run.characters() + start, i - start,
- run.rtl(),
- f, offset, f == &font.scFont()));
- offset += components->last().width + letterSpacing;
-// qDebug() << " appending(1) " << components->last().string << components->last().width;
- }
- if (numSpaces) {
- add = padding/numSpaces;
- padding -= add;
- --numSpaces;
- }
- components->append(TextRunComponent(1, run.rtl(), &font.font(), offset));
- offset += wordSpacing + add + components->last().width + letterSpacing;
- start = i + 1;
- continue;
- } else if (!letterSpacing) {
-// qDebug() << i << char(run[i]) << (QChar::category(ch) == QChar::Letter_Lowercase) <<
-// QFontInfo(*f).pointSizeF();
- if (QChar::category(ch) == QChar::Letter_Lowercase) {
- if (f == &font.scFont())
- continue;
- } else {
- if (f == &font.font())
- continue;
- }
- }
- if (i - start > 0) {
- components->append(TextRunComponent(run.characters() + start, i - start,
- run.rtl(),
- f, offset, f == &font.scFont()));
- offset += components->last().width + letterSpacing;
-// qDebug() << " appending(2) " << components->last().string << components->last().width;
- }
- if (smallCaps)
- f = (QChar::category(ch) == QChar::Letter_Lowercase ? &font.scFont() : &font.font());
- start = i;
- }
- if (run.length() - start > 0) {
- components->append(TextRunComponent(run.characters() + start, run.length() - start,
- run.rtl(),
- f, offset, f == &font.scFont()));
- offset += components->last().width;
-// qDebug() << " appending(3) " << components->last().string << components->last().width;
- }
- offset += letterSpacing;
- } else {
- int start = 0;
- for (int i = 0; i < run.length(); ++i) {
- if (Font::treatAsSpace(run[i])) {
- if (i - start > 0) {
- components->append(TextRunComponent(run.characters() + start, i - start,
- run.rtl(),
- f, offset));
- offset += components->last().width;
- }
- int add = 0;
- if (numSpaces) {
- add = padding/numSpaces;
- padding -= add;
- --numSpaces;
- }
- components->append(TextRunComponent(1, run.rtl(), &font.font(), offset));
- offset += add + components->last().width;
- if (i)
- offset += wordSpacing;
- start = i + 1;
- }
- }
- if (run.length() - start > 0) {
- components->append(TextRunComponent(run.characters() + start, run.length() - start,
- run.rtl(),
- f, offset));
- offset += components->last().width;
- }
- }
- return offset;
-}
-
-void Font::drawText(GraphicsContext* ctx, const TextRun& run, const FloatPoint& point, int from, int to) const
-{
- if (to < 0)
- to = run.length();
- QPainter *p = ctx->platformContext();
- Color color = ctx->fillColor();
- p->setPen(QColor(color));
-
- Vector<TextRunComponent, 1024> components;
- int w = generateComponents(&components, *this, run);
-
- if (from > 0 || to < run.length()) {
- FloatRect clip = selectionRectForText(run,
- IntPoint(qRound(point.x()), qRound(point.y())),
- QFontMetrics(m_font).height(), from, to);
- QRectF rect(clip.x(), clip.y() - ascent(), clip.width(), clip.height());
- p->save();
- p->setClipRect(rect.toRect());
- }
-
- if (run.rtl()) {
- for (int i = 0; i < components.size(); ++i) {
- if (!components.at(i).isSpace()) {
- p->setFont(*components.at(i).font);
- QPointF pt(point.x() + w - components.at(i).offset - components.at(i).width, point.y());
- p->drawText(pt, components.at(i).string);
- }
- }
- } else {
- for (int i = 0; i < components.size(); ++i) {
- if (!components.at(i).isSpace()) {
- p->setFont(*components.at(i).font);
- QPointF pt(point.x() + components.at(i).offset, point.y());
- p->drawText(pt, components.at(i).string);
- }
- }
- }
- if (from > 0 || to < run.length())
- p->restore();
-}
-
-int Font::width(const TextRun& run) const
-{
- Vector<TextRunComponent, 1024> components;
- int w = generateComponents(&components, *this, run);
-
-// qDebug() << " width=" << w;
- return w;
-}
-
-float Font::floatWidth(const TextRun& run) const
-{
- return width(run);
-}
-
-float Font::floatWidth(const TextRun& run, int /*extraCharsAvailable*/, int& charsConsumed, String& glyphName) const
-{
- charsConsumed = run.length();
- glyphName = "";
- return width(run);
-}
-
-int Font::offsetForPosition(const TextRun& run, int position, bool includePartialGlyphs) const
-{
- Vector<TextRunComponent, 1024> components;
- int w = generateComponents(&components, *this, run);
-
- int offset = 0;
- if (run.rtl()) {
- for (int i = 0; i < components.size(); ++i) {
- int xe = w - components.at(i).offset;
- int xs = xe - components.at(i).width;
- if (position >= xs) {
- QTextLayout layout(components.at(i).string, *components.at(i).font);
- layout.beginLayout();
- QTextLine l = layout.createLine();
- if (!l.isValid())
- return offset;
-
- l.setLineWidth(INT_MAX/256);
- layout.endLayout();
-
- if (position - xs >= l.width())
- return offset;
- int cursor = l.xToCursor(position - xs);
- if (cursor > 1)
- --cursor;
- return offset + cursor;
- } else {
- offset += components.at(i).string.length() - 1;
- }
- }
- } else {
- for (int i = 0; i < components.size(); ++i) {
- int xs = components.at(i).offset;
- int xe = xs + components.at(i).width;
- if (position <= xe) {
- QTextLayout layout(components.at(i).string, *components.at(i).font);
- layout.beginLayout();
- QTextLine l = layout.createLine();
- if (!l.isValid())
- return offset;
-
- l.setLineWidth(INT_MAX/256);
- layout.endLayout();
-
- if (position - xs >= l.width())
- return offset + components.at(i).string.length() - 1;
- int cursor = l.xToCursor(position - xs);
- if (cursor > 1)
- --cursor;
- return offset + cursor;
- } else {
- offset += components.at(i).string.length() - 1;
- }
- }
- }
- return run.length();
-}
-
-static float cursorToX(const Vector<TextRunComponent, 1024>& components, int width, bool rtl, int cursor)
-{
- int start = 0;
- for (int i = 0; i < components.size(); ++i) {
- if (start + components.at(i).string.length() - 1 < cursor) {
- start += components.at(i).string.length() - 1;
- continue;
- }
- int xs = components.at(i).offset;
- if (rtl)
- xs = width - xs - components.at(i).width;
- QTextLayout layout(components.at(i).string, *components.at(i).font);
- layout.beginLayout();
- QTextLine l = layout.createLine();
- if (!l.isValid())
- return 0;
-
- l.setLineWidth(INT_MAX/256);
- layout.endLayout();
-
- return xs + l.cursorToX(cursor - start + 1);
- }
- return width;
-}
-
-FloatRect Font::selectionRectForText(const TextRun& run, const IntPoint& pt,
- int h, int from, int to) const
-{
- Vector<TextRunComponent, 1024> components;
- int w = generateComponents(&components, *this, run);
-
- if (from == 0 && to == run.length())
- return FloatRect(pt.x(), pt.y(), w, h);
-
- float x1 = cursorToX(components, w, run.rtl(), from);
- float x2 = cursorToX(components, w, run.rtl(), to);
- if (x2 < x1)
- qSwap(x1, x2);
-
- return FloatRect(pt.x() + x1, pt.y(), x2 - x1, h);
-}
-#endif
-
-
-Font::~Font()
-{
-}
-
-Font::Font(const Font& other)
- : m_fontDescription(other.m_fontDescription)
- , m_letterSpacing(other.m_letterSpacing)
- , m_wordSpacing(other.m_wordSpacing)
- , m_font(other.m_font)
- , m_scFont(other.m_scFont)
- , m_spaceWidth(other.m_spaceWidth)
-{
-}
-
-Font& Font::operator=(const Font& other)
-{
- m_fontDescription = other.m_fontDescription;
- m_letterSpacing = other.m_letterSpacing;
- m_wordSpacing = other.m_wordSpacing;
- m_font = other.m_font;
- m_scFont = other.m_scFont;
- m_spaceWidth = other.m_spaceWidth;
- return *this;
-}
-
-bool Font::operator==(const Font& other) const
-{
- return m_fontDescription == other.m_fontDescription
- && m_letterSpacing == other.m_letterSpacing
- && m_wordSpacing == other.m_wordSpacing
- && m_font == other.m_font
- && m_scFont == other.m_scFont
- && m_spaceWidth == other.m_spaceWidth;
-}
-
-void Font::update(PassRefPtr<FontSelector>) const
-{
- // don't think we need this
-}
-
-
-bool Font::isFixedPitch() const
-{
- return QFontInfo(m_font).fixedPitch();
-}
-
-// Metrics that we query the FontFallbackList for.
-int Font::ascent() const
-{
- return QFontMetrics(m_font).ascent();
-}
-
-int Font::descent() const
-{
- return QFontMetrics(m_font).descent();
-}
-
-int Font::lineSpacing() const
-{
- return QFontMetrics(m_font).lineSpacing();
-}
-
-int Font::lineGap() const
-{
- return QFontMetrics(m_font).leading();
-}
-
-float Font::xHeight() const
-{
- return QFontMetrics(m_font).xHeight();
-}
-
-unsigned Font::unitsPerEm() const
-{
- return 1; // FIXME!
-}
-
-int Font::spaceWidth() const
-{
- return m_spaceWidth;
-}
-
-}
diff --git a/WebCore/platform/graphics/qt/GlyphPageTreeNodeQt.cpp b/WebCore/platform/graphics/qt/GlyphPageTreeNodeQt.cpp
deleted file mode 100644
index d32cc63..0000000
--- a/WebCore/platform/graphics/qt/GlyphPageTreeNodeQt.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-
- This class provides all functionality needed for loading images, style sheets and html
- pages from the web. It has a memory cache for these objects.
-*/
-#include "config.h"
-#include "GlyphPageTreeNode.h"
-
-namespace WebCore {
-
-void GlyphPageTreeNode::pruneTreeCustomFontData(const FontData* fontData)
-{
-}
-
-}
diff --git a/WebCore/platform/graphics/qt/GradientQt.cpp b/WebCore/platform/graphics/qt/GradientQt.cpp
deleted file mode 100644
index f414efa..0000000
--- a/WebCore/platform/graphics/qt/GradientQt.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2007 Alp Toker <alp@atoker.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Gradient.h"
-
-#include "CSSParser.h"
-#include "NotImplemented.h"
-
-#include <QGradient>
-
-namespace WebCore {
-
-void Gradient::platformDestroy()
-{
- delete m_gradient;
- m_gradient = 0;
-}
-
-QGradient* Gradient::platformGradient()
-{
- if (m_gradient)
- return m_gradient;
-
- if (m_radial)
- m_gradient = new QRadialGradient(m_p1.x(), m_p1.y(), m_r1, m_p0.x(), m_p0.y());
- else
- m_gradient = new QLinearGradient(m_p0.x(), m_p0.y(), m_p1.x(), m_p1.y());
-
- QColor stopColor;
- Vector<ColorStop>::iterator stopIterator = m_stops.begin();
- qreal lastStop;
- const qreal lastStopDiff = 0.0000001;
- while (stopIterator != m_stops.end()) {
- stopColor.setRgbF(stopIterator->red, stopIterator->green, stopIterator->blue, stopIterator->alpha);
- if (qFuzzyCompare(lastStop, qreal(stopIterator->stop)))
- lastStop = stopIterator->stop + lastStopDiff;
- else
- lastStop = stopIterator->stop;
- if (m_radial && m_r0)
- lastStop = m_r0 / m_r1 + lastStop * (1.0f - m_r0 / m_r1);
- m_gradient->setColorAt(lastStop, stopColor);
- ++stopIterator;
- }
-
- return m_gradient;
-}
-
-void Gradient::fill(GraphicsContext* context, const FloatRect& rect)
-{
- notImplemented();
-}
-
-} //namespace
diff --git a/WebCore/platform/graphics/qt/GraphicsContextQt.cpp b/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
deleted file mode 100644
index 600d77c..0000000
--- a/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
+++ /dev/null
@@ -1,1146 +0,0 @@
-/*
- * Copyright (C) 2006 Dirk Mueller <mueller@kde.org>
- * Copyright (C) 2006 Zack Rusin <zack@kde.org>
- * Copyright (C) 2006 George Staikos <staikos@kde.org>
- * Copyright (C) 2006 Simon Hausmann <hausmann@kde.org>
- * Copyright (C) 2006 Allan Sandfeld Jensen <sandfeld@kde.org>
- * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
- * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
- * Copyright (C) 2008 Dirk Schulze <vbs85@gmx.de>
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#ifdef Q_WS_WIN
-#include <windows.h>
-#endif
-
-#include "AffineTransform.h"
-#include "Color.h"
-#include "FloatConversion.h"
-#include "Font.h"
-#include "GraphicsContext.h"
-#include "GraphicsContextPrivate.h"
-#include "ImageBuffer.h"
-#include "Path.h"
-#include "Pattern.h"
-#include "Pen.h"
-#include "NotImplemented.h"
-
-#include <QDebug>
-#include <QGradient>
-#include <QPainter>
-#include <QPaintDevice>
-#include <QPaintEngine>
-#include <QPainterPath>
-#include <QPixmap>
-#include <QPolygonF>
-#include <QStack>
-#include <QVector>
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-namespace WebCore {
-
-static inline QPainter::CompositionMode toQtCompositionMode(CompositeOperator op)
-{
- switch (op) {
- case CompositeClear:
- return QPainter::CompositionMode_Clear;
- case CompositeCopy:
- return QPainter::CompositionMode_Source;
- case CompositeSourceOver:
- return QPainter::CompositionMode_SourceOver;
- case CompositeSourceIn:
- return QPainter::CompositionMode_SourceIn;
- case CompositeSourceOut:
- return QPainter::CompositionMode_SourceOut;
- case CompositeSourceAtop:
- return QPainter::CompositionMode_SourceAtop;
- case CompositeDestinationOver:
- return QPainter::CompositionMode_DestinationOver;
- case CompositeDestinationIn:
- return QPainter::CompositionMode_DestinationIn;
- case CompositeDestinationOut:
- return QPainter::CompositionMode_DestinationOut;
- case CompositeDestinationAtop:
- return QPainter::CompositionMode_DestinationAtop;
- case CompositeXOR:
- return QPainter::CompositionMode_Xor;
- case CompositePlusDarker:
- return QPainter::CompositionMode_SourceOver;
- case CompositeHighlight:
- return QPainter::CompositionMode_SourceOver;
- case CompositePlusLighter:
- return QPainter::CompositionMode_SourceOver;
- }
-
- return QPainter::CompositionMode_SourceOver;
-}
-
-static inline Qt::PenCapStyle toQtLineCap(LineCap lc)
-{
- switch (lc) {
- case ButtCap:
- return Qt::FlatCap;
- case RoundCap:
- return Qt::RoundCap;
- case SquareCap:
- return Qt::SquareCap;
- }
-
- return Qt::FlatCap;
-}
-
-static inline Qt::PenJoinStyle toQtLineJoin(LineJoin lj)
-{
- switch (lj) {
- case MiterJoin:
- return Qt::SvgMiterJoin;
- case RoundJoin:
- return Qt::RoundJoin;
- case BevelJoin:
- return Qt::BevelJoin;
- }
-
- return Qt::MiterJoin;
-}
-
-static Qt::PenStyle toQPenStyle(StrokeStyle style)
-{
- switch (style) {
- case NoStroke:
- return Qt::NoPen;
- break;
- case SolidStroke:
- return Qt::SolidLine;
- break;
- case DottedStroke:
- return Qt::DotLine;
- break;
- case DashedStroke:
- return Qt::DashLine;
- break;
- }
- qWarning("couldn't recognize the pen style");
- return Qt::NoPen;
-}
-
-static inline QGradient applySpreadMethod(QGradient gradient, GradientSpreadMethod spreadMethod)
-{
- switch (spreadMethod) {
- case SpreadMethodPad:
- gradient.setSpread(QGradient::PadSpread);
- break;
- case SpreadMethodReflect:
- gradient.setSpread(QGradient::ReflectSpread);
- break;
- case SpreadMethodRepeat:
- gradient.setSpread(QGradient::RepeatSpread);
- break;
- }
- return gradient;
-}
-
-struct TransparencyLayer
-{
- TransparencyLayer(const QPainter* p, const QRect &rect)
- : pixmap(rect.width(), rect.height())
- {
- offset = rect.topLeft();
- pixmap.fill(Qt::transparent);
- painter.begin(&pixmap);
- painter.setRenderHint(QPainter::Antialiasing, p->testRenderHint(QPainter::Antialiasing));
- painter.translate(-offset);
- painter.setPen(p->pen());
- painter.setBrush(p->brush());
- painter.setTransform(p->transform(), true);
- painter.setOpacity(p->opacity());
- painter.setFont(p->font());
- if (painter.paintEngine()->hasFeature(QPaintEngine::PorterDuff))
- painter.setCompositionMode(p->compositionMode());
- painter.setClipPath(p->clipPath());
- }
-
- TransparencyLayer()
- {
- }
-
- QPixmap pixmap;
- QPoint offset;
- QPainter painter;
- qreal opacity;
-private:
- TransparencyLayer(const TransparencyLayer &) {}
- TransparencyLayer & operator=(const TransparencyLayer &) { return *this; }
-};
-
-class GraphicsContextPlatformPrivate
-{
-public:
- GraphicsContextPlatformPrivate(QPainter* painter);
- ~GraphicsContextPlatformPrivate();
-
- inline QPainter* p()
- {
- if (layers.isEmpty()) {
- if (redirect)
- return redirect;
-
- return painter;
- } else
- return &layers.top()->painter;
- }
-
- bool antiAliasingForRectsAndLines;
-
- QStack<TransparencyLayer *> layers;
- QPainter* redirect;
-
- QBrush solidColor;
-
- // Only used by SVG for now.
- QPainterPath currentPath;
-
-private:
- QPainter* painter;
-};
-
-
-GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate(QPainter* p)
-{
- painter = p;
- redirect = 0;
-
- solidColor = QBrush(Qt::black);
-
- if (painter) {
- // use the default the QPainter was constructed with
- antiAliasingForRectsAndLines = painter->testRenderHint(QPainter::Antialiasing);
- // FIXME: Maybe only enable in SVG mode?
- painter->setRenderHint(QPainter::Antialiasing, true);
- } else {
- antiAliasingForRectsAndLines = false;
- }
-}
-
-GraphicsContextPlatformPrivate::~GraphicsContextPlatformPrivate()
-{
-}
-
-GraphicsContext::GraphicsContext(PlatformGraphicsContext* context)
- : m_common(createGraphicsContextPrivate())
- , m_data(new GraphicsContextPlatformPrivate(context))
-{
- setPaintingDisabled(!context);
- if (context) {
- // Make sure the context starts in sync with our state.
- setPlatformFillColor(fillColor());
- setPlatformStrokeColor(strokeColor());
- }
-}
-
-GraphicsContext::~GraphicsContext()
-{
- while(!m_data->layers.isEmpty())
- endTransparencyLayer();
-
- destroyGraphicsContextPrivate(m_common);
- delete m_data;
-}
-
-PlatformGraphicsContext* GraphicsContext::platformContext() const
-{
- return m_data->p();
-}
-
-AffineTransform GraphicsContext::getCTM() const
-{
- return platformContext()->combinedMatrix();
-}
-
-void GraphicsContext::savePlatformState()
-{
- m_data->p()->save();
-}
-
-void GraphicsContext::restorePlatformState()
-{
- m_data->p()->restore();
-}
-
-/* FIXME: DISABLED WHILE MERGING BACK FROM UNITY
-void GraphicsContext::drawTextShadow(const TextRun& run, const IntPoint& point, const FontStyle& style)
-{
- if (paintingDisabled())
- return;
-
- if (m_data->shadow.isNull())
- return;
-
- TextShadow* shadow = &m_data->shadow;
-
- if (shadow->blur <= 0) {
- Pen p = pen();
- setPen(shadow->color);
- font().drawText(this, run, style, IntPoint(point.x() + shadow->x, point.y() + shadow->y));
- setPen(p);
- } else {
- const int thickness = shadow->blur;
- // FIXME: OPTIMIZE: limit the area to only the actually painted area + 2*thickness
- const int w = m_data->p()->device()->width();
- const int h = m_data->p()->device()->height();
- const QRgb color = qRgb(255, 255, 255);
- const QRgb bgColor = qRgb(0, 0, 0);
- QImage image(QSize(w, h), QImage::Format_ARGB32);
- image.fill(bgColor);
- QPainter p;
-
- Pen curPen = pen();
- p.begin(&image);
- setPen(color);
- m_data->redirect = &p;
- font().drawText(this, run, style, IntPoint(point.x() + shadow->x, point.y() + shadow->y));
- m_data->redirect = 0;
- p.end();
- setPen(curPen);
-
- int md = thickness * thickness; // max-dist^2
-
- // blur map/precalculated shadow-decay
- float* bmap = (float*) alloca(sizeof(float) * (md + 1));
- for (int n = 0; n <= md; n++) {
- float f;
- f = n / (float) (md + 1);
- f = 1.0 - f * f;
- bmap[n] = f;
- }
-
- float factor = 0.0; // maximal potential opacity-sum
- for (int n = -thickness; n <= thickness; n++) {
- for (int m = -thickness; m <= thickness; m++) {
- int d = n * n + m * m;
- if (d <= md)
- factor += bmap[d];
- }
- }
-
- // alpha map
- float* amap = (float*) alloca(sizeof(float) * (h * w));
- memset(amap, 0, h * w * (sizeof(float)));
-
- for (int j = thickness; j<h-thickness; j++) {
- for (int i = thickness; i<w-thickness; i++) {
- QRgb col = image.pixel(i,j);
- if (col == bgColor)
- continue;
-
- float g = qAlpha(col);
- g = g / 255;
-
- for (int n = -thickness; n <= thickness; n++) {
- for (int m = -thickness; m <= thickness; m++) {
- int d = n * n + m * m;
- if (d > md)
- continue;
-
- float f = bmap[d];
- amap[(i + m) + (j + n) * w] += (g * f);
- }
- }
- }
- }
-
- QImage res(QSize(w,h),QImage::Format_ARGB32);
- int r = shadow->color.red();
- int g = shadow->color.green();
- int b = shadow->color.blue();
- int a1 = shadow->color.alpha();
-
- // arbitratry factor adjustment to make shadows more solid.
- factor = 1.333 / factor;
-
- for (int j = 0; j < h; j++) {
- for (int i = 0; i < w; i++) {
- int a = (int) (amap[i + j * w] * factor * a1);
- if (a > 255)
- a = 255;
-
- res.setPixel(i,j, qRgba(r, g, b, a));
- }
- }
-
- m_data->p()->drawImage(0, 0, res, 0, 0, -1, -1, Qt::DiffuseAlphaDither | Qt::ColorOnly | Qt::PreferDither);
- }
-}
-*/
-
-// Draws a filled rectangle with a stroked border.
-void GraphicsContext::drawRect(const IntRect& rect)
-{
- if (paintingDisabled())
- return;
-
- QPainter *p = m_data->p();
- const bool antiAlias = p->testRenderHint(QPainter::Antialiasing);
- p->setRenderHint(QPainter::Antialiasing, m_data->antiAliasingForRectsAndLines);
-
- p->drawRect(rect);
-
- p->setRenderHint(QPainter::Antialiasing, antiAlias);
-}
-
-// FIXME: Now that this is refactored, it should be shared by all contexts.
-static void adjustLineToPixelBoundaries(FloatPoint& p1, FloatPoint& p2, float strokeWidth,
- const StrokeStyle& penStyle)
-{
- // For odd widths, we add in 0.5 to the appropriate x/y so that the float arithmetic
- // works out. For example, with a border width of 3, KHTML will pass us (y1+y2)/2, e.g.,
- // (50+53)/2 = 103/2 = 51 when we want 51.5. It is always true that an even width gave
- // us a perfect position, but an odd width gave us a position that is off by exactly 0.5.
- if (penStyle == DottedStroke || penStyle == DashedStroke) {
- if (p1.x() == p2.x()) {
- p1.setY(p1.y() + strokeWidth);
- p2.setY(p2.y() - strokeWidth);
- } else {
- p1.setX(p1.x() + strokeWidth);
- p2.setX(p2.x() - strokeWidth);
- }
- }
-
- if (((int) strokeWidth) % 2) {
- if (p1.x() == p2.x()) {
- // We're a vertical line. Adjust our x.
- p1.setX(p1.x() + 0.5);
- p2.setX(p2.x() + 0.5);
- } else {
- // We're a horizontal line. Adjust our y.
- p1.setY(p1.y() + 0.5);
- p2.setY(p2.y() + 0.5);
- }
- }
-}
-
-// This is only used to draw borders.
-void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2)
-{
- if (paintingDisabled())
- return;
-
- FloatPoint p1 = point1;
- FloatPoint p2 = point2;
-
- QPainter *p = m_data->p();
- const bool antiAlias = p->testRenderHint(QPainter::Antialiasing);
- p->setRenderHint(QPainter::Antialiasing, m_data->antiAliasingForRectsAndLines);
- adjustLineToPixelBoundaries(p1, p2, strokeThickness(), strokeStyle());
-
- IntSize shadowSize;
- int shadowBlur;
- Color shadowColor;
- if (textDrawingMode() == cTextFill && getShadow(shadowSize, shadowBlur, shadowColor)) {
- p->save();
- p->translate(shadowSize.width(), shadowSize.height());
- p->setPen(QColor(shadowColor));
- p->drawLine(p1, p2);
- p->restore();
- }
-
- p->drawLine(p1, p2);
-
- p->setRenderHint(QPainter::Antialiasing, antiAlias);
-}
-
-// This method is only used to draw the little circles used in lists.
-void GraphicsContext::drawEllipse(const IntRect& rect)
-{
- if (paintingDisabled())
- return;
-
- m_data->p()->drawEllipse(rect);
-}
-
-void GraphicsContext::strokeArc(const IntRect& rect, int startAngle, int angleSpan)
-{
- if (paintingDisabled() || strokeStyle() == NoStroke || strokeThickness() <= 0.0f || !strokeColor().alpha())
- return;
-
- QPainter *p = m_data->p();
- const bool antiAlias = p->testRenderHint(QPainter::Antialiasing);
- p->setRenderHint(QPainter::Antialiasing, m_data->antiAliasingForRectsAndLines);
-
- p->drawArc(rect, startAngle * 16, angleSpan * 16);
-
- p->setRenderHint(QPainter::Antialiasing, antiAlias);
-}
-
-void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points, bool shouldAntialias)
-{
- if (paintingDisabled())
- return;
-
- if (npoints <= 1)
- return;
-
- QPolygonF polygon(npoints);
-
- for (size_t i = 0; i < npoints; i++)
- polygon[i] = points[i];
-
- QPainter *p = m_data->p();
- p->save();
- p->setRenderHint(QPainter::Antialiasing, shouldAntialias);
- p->drawConvexPolygon(polygon);
- p->restore();
-}
-
-void GraphicsContext::fillPath()
-{
- if (paintingDisabled())
- return;
-
- QPainter *p = m_data->p();
- QPainterPath path = m_data->currentPath;
-
- switch (m_common->state.fillColorSpace) {
- case SolidColorSpace:
- if (fillColor().alpha())
- p->fillPath(path, p->brush());
- break;
- case PatternColorSpace:
- p->fillPath(path, QBrush(m_common->state.fillPattern.get()->createPlatformPattern(getCTM())));
- break;
- case GradientColorSpace:
- QGradient* gradient = m_common->state.fillGradient.get()->platformGradient();
- *gradient = applySpreadMethod(*gradient, spreadMethod());
- p->fillPath(path, QBrush(*gradient));
- break;
- }
-}
-
-void GraphicsContext::strokePath()
-{
- if (paintingDisabled())
- return;
-
- QPainter *p = m_data->p();
- QPen pen = p->pen();
- QPainterPath path = m_data->currentPath;
-
- switch (m_common->state.strokeColorSpace) {
- case SolidColorSpace:
- if (strokeColor().alpha())
- p->strokePath(path, pen);
- break;
- case PatternColorSpace: {
- pen.setBrush(QBrush(m_common->state.strokePattern.get()->createPlatformPattern(getCTM())));
- p->setPen(pen);
- p->strokePath(path, pen);
- break;
- }
- case GradientColorSpace: {
- QGradient* gradient = m_common->state.strokeGradient.get()->platformGradient();
- *gradient = applySpreadMethod(*gradient, spreadMethod());
- pen.setBrush(QBrush(*gradient));
- p->setPen(pen);
- p->strokePath(path, pen);
- break;
- }
- }
-}
-
-void GraphicsContext::fillRect(const FloatRect& rect)
-{
- if (paintingDisabled())
- return;
-
- QPainter *p = m_data->p();
-
- switch (m_common->state.fillColorSpace) {
- case SolidColorSpace:
- if (fillColor().alpha())
- p->fillRect(rect, p->brush());
- break;
- case PatternColorSpace:
- p->fillRect(rect, QBrush(m_common->state.fillPattern.get()->createPlatformPattern(getCTM())));
- break;
- case GradientColorSpace:
- p->fillRect(rect, QBrush(*(m_common->state.fillGradient.get()->platformGradient())));
- break;
- }
-}
-
-void GraphicsContext::fillRect(const FloatRect& rect, const Color& c)
-{
- if (paintingDisabled())
- return;
-
- m_data->solidColor.setColor(QColor(c));
- m_data->p()->fillRect(rect, m_data->solidColor);
-}
-
-void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color& color)
-{
- if (paintingDisabled() || !color.alpha())
- return;
-
- Path path = Path::createRoundedRectangle(rect, topLeft, topRight, bottomLeft, bottomRight);
- m_data->p()->fillPath(*path.platformPath(), QColor(color));
-}
-
-void GraphicsContext::beginPath()
-{
- m_data->currentPath = QPainterPath();
-}
-
-void GraphicsContext::addPath(const Path& path)
-{
- m_data->currentPath = *(path.platformPath());
-}
-
-bool GraphicsContext::inTransparencyLayer() const
-{
- return !m_data->layers.isEmpty();
-}
-
-PlatformPath* GraphicsContext::currentPath()
-{
- return &m_data->currentPath;
-}
-
-void GraphicsContext::clip(const FloatRect& rect)
-{
- if (paintingDisabled())
- return;
-
- QPainter *p = m_data->p();
- if (p->clipRegion().isEmpty())
- p->setClipRect(rect);
- else p->setClipRect(rect, Qt::IntersectClip);
-}
-
-/**
- * Focus ring handling is not handled here. Qt style in
- * RenderTheme handles drawing focus on widgets which
- * need it.
- */
-Color focusRingColor() { return Color(0, 0, 0); }
-void GraphicsContext::drawFocusRing(const Color& color)
-{
- if (paintingDisabled())
- return;
-
- const Vector<IntRect>& rects = focusRingRects();
- unsigned rectCount = rects.size();
-
- if (rects.size() == 0)
- return;
-
- QPainter *p = m_data->p();
- const bool antiAlias = p->testRenderHint(QPainter::Antialiasing);
- p->setRenderHint(QPainter::Antialiasing, m_data->antiAliasingForRectsAndLines);
-
- const QPen oldPen = p->pen();
- const QBrush oldBrush = p->brush();
-
- QPen nPen = p->pen();
- nPen.setColor(color);
- p->setBrush(Qt::NoBrush);
- nPen.setStyle(Qt::DotLine);
- p->setPen(nPen);
-#if 0
- // FIXME How do we do a bounding outline with Qt?
- QPainterPath path;
- for (int i = 0; i < rectCount; ++i)
- path.addRect(QRectF(rects[i]));
- QPainterPathStroker stroker;
- QPainterPath newPath = stroker.createStroke(path);
- p->strokePath(newPath, nPen);
-#else
- for (int i = 0; i < rectCount; ++i)
- p->drawRect(QRectF(rects[i]));
-#endif
- p->setPen(oldPen);
- p->setBrush(oldBrush);
-
- p->setRenderHint(QPainter::Antialiasing, antiAlias);
-}
-
-void GraphicsContext::drawLineForText(const IntPoint& origin, int width, bool printing)
-{
- if (paintingDisabled())
- return;
-
- IntPoint endPoint = origin + IntSize(width, 0);
- drawLine(origin, endPoint);
-}
-
-void GraphicsContext::drawLineForMisspellingOrBadGrammar(const IntPoint&,
- int width, bool grammar)
-{
- if (paintingDisabled())
- return;
-
- notImplemented();
-}
-
-FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& frect)
-{
- QRectF rect(frect);
- rect = m_data->p()->deviceMatrix().mapRect(rect);
-
- QRect result = rect.toRect(); //round it
- return FloatRect(QRectF(result));
-}
-
-void GraphicsContext::setPlatformShadow(const IntSize& pos, int blur, const Color &color)
-{
- // Qt doesn't support shadows natively, they are drawn manually in the draw*
- // functions
-}
-
-void GraphicsContext::clearPlatformShadow()
-{
- // Qt doesn't support shadows natively, they are drawn manually in the draw*
- // functions
-}
-
-void GraphicsContext::beginTransparencyLayer(float opacity)
-{
- if (paintingDisabled())
- return;
-
- int x, y, w, h;
- x = y = 0;
- QPainter *p = m_data->p();
- const QPaintDevice *device = p->device();
- w = device->width();
- h = device->height();
-
- QRectF clip = p->clipPath().boundingRect();
- QRectF deviceClip = p->transform().mapRect(clip);
- x = int(qBound(qreal(0), deviceClip.x(), (qreal)w));
- y = int(qBound(qreal(0), deviceClip.y(), (qreal)h));
- w = int(qBound(qreal(0), deviceClip.width(), (qreal)w) + 2);
- h = int(qBound(qreal(0), deviceClip.height(), (qreal)h) + 2);
-
- TransparencyLayer * layer = new TransparencyLayer(m_data->p(), QRect(x, y, w, h));
-
- layer->opacity = opacity;
- m_data->layers.push(layer);
-}
-
-void GraphicsContext::endTransparencyLayer()
-{
- if (paintingDisabled())
- return;
-
- TransparencyLayer *layer = m_data->layers.pop();
- layer->painter.end();
-
- QPainter *p = m_data->p();
- p->save();
- p->resetTransform();
- p->setOpacity(layer->opacity);
- p->drawPixmap(layer->offset, layer->pixmap);
- p->restore();
-
- delete layer;
-}
-
-void GraphicsContext::clearRect(const FloatRect& rect)
-{
- if (paintingDisabled())
- return;
-
- QPainter *p = m_data->p();
- QPainter::CompositionMode currentCompositionMode = p->compositionMode();
- if (p->paintEngine()->hasFeature(QPaintEngine::PorterDuff))
- p->setCompositionMode(QPainter::CompositionMode_Source);
- p->eraseRect(rect);
- if (p->paintEngine()->hasFeature(QPaintEngine::PorterDuff))
- p->setCompositionMode(currentCompositionMode);
-}
-
-void GraphicsContext::strokeRect(const FloatRect& rect, float width)
-{
- if (paintingDisabled())
- return;
-
- QPainterPath path;
- path.addRect(rect);
- setStrokeThickness(width);
- m_data->currentPath = path;
-
- strokePath();
-}
-
-void GraphicsContext::setLineCap(LineCap lc)
-{
- if (paintingDisabled())
- return;
-
- QPainter *p = m_data->p();
- QPen nPen = p->pen();
- nPen.setCapStyle(toQtLineCap(lc));
- p->setPen(nPen);
-}
-
-void GraphicsContext::setLineDash(const DashArray& dashes, float dashOffset)
-{
- QPainter* p = m_data->p();
- QPen pen = p->pen();
- unsigned dashLength = dashes.size();
- if (dashLength) {
- QVector<qreal> pattern;
- unsigned count = dashLength;
- if (dashLength % 2)
- count *= 2;
-
- for (unsigned i = 0; i < count; i++)
- pattern.append(dashes[i % dashLength] / narrowPrecisionToFloat(pen.widthF()));
-
- pen.setDashPattern(pattern);
- pen.setDashOffset(dashOffset);
- }
- p->setPen(pen);
-}
-
-void GraphicsContext::setLineJoin(LineJoin lj)
-{
- if (paintingDisabled())
- return;
-
- QPainter *p = m_data->p();
- QPen nPen = p->pen();
- nPen.setJoinStyle(toQtLineJoin(lj));
- p->setPen(nPen);
-}
-
-void GraphicsContext::setMiterLimit(float limit)
-{
- if (paintingDisabled())
- return;
-
- QPainter *p = m_data->p();
- QPen nPen = p->pen();
- nPen.setMiterLimit(limit);
- p->setPen(nPen);
-}
-
-void GraphicsContext::setAlpha(float opacity)
-{
- if (paintingDisabled())
- return;
- QPainter *p = m_data->p();
- p->setOpacity(opacity);
-}
-
-void GraphicsContext::setCompositeOperation(CompositeOperator op)
-{
- if (paintingDisabled())
- return;
-
- if (m_data->p()->paintEngine()->hasFeature(QPaintEngine::PorterDuff))
- m_data->p()->setCompositionMode(toQtCompositionMode(op));
-}
-
-void GraphicsContext::clip(const Path& path)
-{
- if (paintingDisabled())
- return;
-
- m_data->p()->setClipPath(*path.platformPath(), Qt::IntersectClip);
-}
-
-void GraphicsContext::clipOut(const Path& path)
-{
- if (paintingDisabled())
- return;
-
- QPainter *p = m_data->p();
- QRectF clipBounds = p->clipPath().boundingRect();
- QPainterPath clippedOut = *path.platformPath();
- QPainterPath newClip;
- newClip.setFillRule(Qt::OddEvenFill);
- newClip.addRect(clipBounds);
- newClip.addPath(clippedOut);
-
- p->setClipPath(newClip, Qt::IntersectClip);
-}
-
-void GraphicsContext::translate(float x, float y)
-{
- if (paintingDisabled())
- return;
-
- m_data->p()->translate(x, y);
-}
-
-IntPoint GraphicsContext::origin()
-{
- if (paintingDisabled())
- return IntPoint();
- const QTransform &transform = m_data->p()->transform();
- return IntPoint(qRound(transform.dx()), qRound(transform.dy()));
-}
-
-void GraphicsContext::rotate(float radians)
-{
- if (paintingDisabled())
- return;
-
- m_data->p()->rotate(180/M_PI*radians);
-}
-
-void GraphicsContext::scale(const FloatSize& s)
-{
- if (paintingDisabled())
- return;
-
- m_data->p()->scale(s.width(), s.height());
-}
-
-void GraphicsContext::clipOut(const IntRect& rect)
-{
- if (paintingDisabled())
- return;
-
- QPainter *p = m_data->p();
- QRectF clipBounds = p->clipPath().boundingRect();
- QPainterPath newClip;
- newClip.setFillRule(Qt::OddEvenFill);
- newClip.addRect(clipBounds);
- newClip.addRect(QRect(rect));
-
- p->setClipPath(newClip, Qt::IntersectClip);
-}
-
-void GraphicsContext::clipOutEllipseInRect(const IntRect& rect)
-{
- if (paintingDisabled())
- return;
-
- QPainter *p = m_data->p();
- QRectF clipBounds = p->clipPath().boundingRect();
- QPainterPath newClip;
- newClip.setFillRule(Qt::OddEvenFill);
- newClip.addRect(clipBounds);
- newClip.addEllipse(QRect(rect));
-
- p->setClipPath(newClip, Qt::IntersectClip);
-}
-
-void GraphicsContext::clipToImageBuffer(const FloatRect&, const ImageBuffer*)
-{
- notImplemented();
-}
-
-void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect,
- int thickness)
-{
- if (paintingDisabled())
- return;
-
- clip(rect);
- QPainterPath path;
-
- // Add outer ellipse
- path.addEllipse(QRectF(rect.x(), rect.y(), rect.width(), rect.height()));
-
- // Add inner ellipse.
- path.addEllipse(QRectF(rect.x() + thickness, rect.y() + thickness,
- rect.width() - (thickness * 2), rect.height() - (thickness * 2)));
-
- path.setFillRule(Qt::OddEvenFill);
- m_data->p()->setClipPath(path, Qt::IntersectClip);
-}
-
-void GraphicsContext::concatCTM(const AffineTransform& transform)
-{
- if (paintingDisabled())
- return;
-
- m_data->p()->setMatrix(transform, true);
-}
-
-void GraphicsContext::setURLForRect(const KURL& link, const IntRect& destRect)
-{
- notImplemented();
-}
-
-void GraphicsContext::setPlatformFont(const Font& aFont)
-{
- if (paintingDisabled())
- return;
- m_data->p()->setFont(aFont.font());
-}
-
-void GraphicsContext::setPlatformStrokeColor(const Color& color)
-{
- if (paintingDisabled())
- return;
- QPainter *p = m_data->p();
- QPen newPen(p->pen());
- newPen.setColor(color);
- p->setPen(newPen);
-}
-
-void GraphicsContext::setPlatformStrokeStyle(const StrokeStyle& strokeStyle)
-{
- if (paintingDisabled())
- return;
- QPainter *p = m_data->p();
- QPen newPen(p->pen());
- newPen.setStyle(toQPenStyle(strokeStyle));
- p->setPen(newPen);
-}
-
-void GraphicsContext::setPlatformStrokeThickness(float thickness)
-{
- if (paintingDisabled())
- return;
- QPainter *p = m_data->p();
- QPen newPen(p->pen());
- newPen.setWidthF(thickness);
- p->setPen(newPen);
-}
-
-void GraphicsContext::setPlatformFillColor(const Color& color)
-{
- if (paintingDisabled())
- return;
- m_data->p()->setBrush(QBrush(color));
-}
-
-void GraphicsContext::setUseAntialiasing(bool enable)
-{
- if (paintingDisabled())
- return;
- m_data->p()->setRenderHint(QPainter::Antialiasing, enable);
-}
-
-#ifdef Q_WS_WIN
-#include <windows.h>
-
-HDC GraphicsContext::getWindowsContext(const IntRect& dstRect, bool supportAlphaBlend, bool mayCreateBitmap)
-{
- // painting through native HDC is only supported for plugin, where mayCreateBitmap is always TRUE
- Q_ASSERT(mayCreateBitmap == TRUE);
-
- if (dstRect.isEmpty())
- return 0;
-
- // Create a bitmap DC in which to draw.
- BITMAPINFO bitmapInfo;
- bitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- bitmapInfo.bmiHeader.biWidth = dstRect.width();
- bitmapInfo.bmiHeader.biHeight = dstRect.height();
- bitmapInfo.bmiHeader.biPlanes = 1;
- bitmapInfo.bmiHeader.biBitCount = 32;
- bitmapInfo.bmiHeader.biCompression = BI_RGB;
- bitmapInfo.bmiHeader.biSizeImage = 0;
- bitmapInfo.bmiHeader.biXPelsPerMeter = 0;
- bitmapInfo.bmiHeader.biYPelsPerMeter = 0;
- bitmapInfo.bmiHeader.biClrUsed = 0;
- bitmapInfo.bmiHeader.biClrImportant = 0;
-
- void* pixels = 0;
- HBITMAP bitmap = ::CreateDIBSection(NULL, &bitmapInfo, DIB_RGB_COLORS, &pixels, 0, 0);
- if (!bitmap)
- return 0;
-
- HDC displayDC = ::GetDC(0);
- HDC bitmapDC = ::CreateCompatibleDC(displayDC);
- ::ReleaseDC(0, displayDC);
-
- ::SelectObject(bitmapDC, bitmap);
-
- // Fill our buffer with clear if we're going to alpha blend.
- if (supportAlphaBlend) {
- BITMAP bmpInfo;
- GetObject(bitmap, sizeof(bmpInfo), &bmpInfo);
- int bufferSize = bmpInfo.bmWidthBytes * bmpInfo.bmHeight;
- memset(bmpInfo.bmBits, 0, bufferSize);
- }
-
- // Make sure we can do world transforms.
- SetGraphicsMode(bitmapDC, GM_ADVANCED);
-
- // Apply a translation to our context so that the drawing done will be at (0,0) of the bitmap.
- XFORM xform;
- xform.eM11 = 1.0f;
- xform.eM12 = 0.0f;
- xform.eM21 = 0.0f;
- xform.eM22 = 1.0f;
- xform.eDx = -dstRect.x();
- xform.eDy = -dstRect.y();
- ::SetWorldTransform(bitmapDC, &xform);
-
-
- return bitmapDC;
-}
-
-void GraphicsContext::releaseWindowsContext(HDC hdc, const IntRect& dstRect, bool supportAlphaBlend, bool mayCreateBitmap)
-{
- // painting through native HDC is only supported for plugin, where mayCreateBitmap is always TRUE
- Q_ASSERT(mayCreateBitmap == TRUE);
-
- if (hdc) {
-
- if (!dstRect.isEmpty()) {
-
- HBITMAP bitmap = static_cast<HBITMAP>(GetCurrentObject(hdc, OBJ_BITMAP));
- BITMAP info;
- GetObject(bitmap, sizeof(info), &info);
- ASSERT(info.bmBitsPixel == 32);
-
- QPixmap pixmap = QPixmap::fromWinHBITMAP(bitmap, supportAlphaBlend ? QPixmap::PremultipliedAlpha : QPixmap::NoAlpha);
- m_data->p()->drawPixmap(dstRect, pixmap);
-
- ::DeleteObject(bitmap);
- }
-
- ::DeleteDC(hdc);
- }
-}
-#endif
-
-void GraphicsContext::setImageInterpolationQuality(InterpolationQuality)
-{
-}
-
-InterpolationQuality GraphicsContext::imageInterpolationQuality() const
-{
- return InterpolationDefault;
-}
-
-}
-
-// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/graphics/qt/IconQt.cpp b/WebCore/platform/graphics/qt/IconQt.cpp
deleted file mode 100644
index b04668c..0000000
--- a/WebCore/platform/graphics/qt/IconQt.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "Icon.h"
-
-#include "GraphicsContext.h"
-#include "PlatformString.h"
-#include "IntRect.h"
-#include "NotImplemented.h"
-
-#include <qpainter.h>
-#include <qpixmap.h>
-#include <qrect.h>
-#include <qglobal.h>
-
-namespace WebCore {
-
-Icon::Icon()
-{
-}
-
-Icon::~Icon()
-{
-}
-
-PassRefPtr<Icon> Icon::createIconForFile(const String& filename)
-{
- RefPtr<Icon> i = adoptRef(new Icon);
- i->m_icon = QIcon(filename);
- return i.release();
-}
-
-PassRefPtr<Icon> Icon::createIconForFiles(const Vector<String>& filenames)
-{
- //FIXME: Implement this
- return 0;
-}
-
-void Icon::paint(GraphicsContext* ctx, const IntRect& rect)
-{
- QPixmap px = m_icon.pixmap(rect.size());
- QPainter *p = static_cast<QPainter*>(ctx->platformContext());
- if (p && !px.isNull()) {
- p->drawPixmap(rect.x(), rect.y(), px);
- }
-}
-
-}
-
-// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/graphics/qt/ImageBufferData.h b/WebCore/platform/graphics/qt/ImageBufferData.h
deleted file mode 100644
index 222dabe..0000000
--- a/WebCore/platform/graphics/qt/ImageBufferData.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2008 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ImageBufferData_h
-#define ImageBufferData_h
-
-#include <QPainter>
-#include <QPixmap>
-
-#include "OwnPtr.h"
-
-namespace WebCore {
-
-class IntSize;
-
-class ImageBufferData {
-public:
- ImageBufferData(const IntSize&);
-
- QPixmap m_pixmap;
- OwnPtr<QPainter> m_painter;
-};
-
-} // namespace WebCore
-
-#endif // ImageBufferData_h
diff --git a/WebCore/platform/graphics/qt/ImageBufferQt.cpp b/WebCore/platform/graphics/qt/ImageBufferQt.cpp
deleted file mode 100644
index d4ab59f..0000000
--- a/WebCore/platform/graphics/qt/ImageBufferQt.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
- * Copyright (C) 2008 Holger Hans Peter Freyther
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ImageBuffer.h"
-
-#include "CString.h"
-#include "GraphicsContext.h"
-#include "ImageData.h"
-#include "MIMETypeRegistry.h"
-#include "NotImplemented.h"
-#include "StillImageQt.h"
-
-#include <QBuffer>
-#include <QImageWriter>
-#include <QPainter>
-#include <QPixmap>
-
-namespace WebCore {
-
-ImageBufferData::ImageBufferData(const IntSize& size)
- : m_pixmap(size)
-{
- m_pixmap.fill(QColor(Qt::transparent));
- m_painter.set(new QPainter(&m_pixmap));
-}
-
-ImageBuffer::ImageBuffer(const IntSize& size, bool grayScale, bool& success)
- : m_data(size)
- , m_size(size)
-{
- m_context.set(new GraphicsContext(m_data.m_painter.get()));
- success = true;
-}
-
-ImageBuffer::~ImageBuffer()
-{
-}
-
-GraphicsContext* ImageBuffer::context() const
-{
- ASSERT(m_data.m_painter->isActive());
-
- return m_context.get();
-}
-
-Image* ImageBuffer::image() const
-{
- if (!m_image) {
- // It's assumed that if image() is called, the actual rendering to the
- // GraphicsContext must be done.
- ASSERT(context());
- m_image = StillImage::create(m_data.m_pixmap);
- }
-
- return m_image.get();
-}
-
-PassRefPtr<ImageData> ImageBuffer::getImageData(const IntRect&) const
-{
- notImplemented();
- return 0;
-}
-
-void ImageBuffer::putImageData(ImageData*, const IntRect&, const IntPoint&)
-{
- notImplemented();
-}
-
-// We get a mimeType here but QImageWriter does not support mimetypes but
-// only formats (png, gif, jpeg..., xpm). So assume we get image/ as image
-// mimetypes and then remove the image/ to get the Qt format.
-String ImageBuffer::toDataURL(const String& mimeType) const
-{
- ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType));
-
- if (!mimeType.startsWith("image/"))
- return "data:,";
-
- // prepare our target
- QByteArray data;
- QBuffer buffer(&data);
- buffer.open(QBuffer::WriteOnly);
-
- if (!m_data.m_pixmap.save(&buffer, mimeType.substring(sizeof "image").utf8().data()))
- return "data:,";
-
- buffer.close();
- return String::format("data:%s;base64,%s", mimeType.utf8().data(), data.toBase64().data());
-}
-
-}
diff --git a/WebCore/platform/graphics/qt/ImageDecoderQt.cpp b/WebCore/platform/graphics/qt/ImageDecoderQt.cpp
deleted file mode 100644
index e3b00a1..0000000
--- a/WebCore/platform/graphics/qt/ImageDecoderQt.cpp
+++ /dev/null
@@ -1,308 +0,0 @@
-/*
- * Copyright (C) 2006 Friedemann Kleint <fkleint@trolltech.com>
- * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ImageDecoderQt.h"
-
-#include <QtCore/QByteArray>
-#include <QtCore/QBuffer>
-
-#include <QtGui/QImageReader>
-#include <qdebug.h>
-
-namespace {
- const QImage::Format DesiredFormat = QImage::Format_ARGB32;
- const bool debugImageDecoderQt = false;
-}
-
-namespace WebCore {
-ImageDecoderQt::ImageData::ImageData(const QImage& image, ImageState imageState, int duration) :
- m_image(image), m_imageState(imageState), m_duration(duration)
-{
-}
-
-// Context, maintains IODevice on a data buffer.
-class ImageDecoderQt::ReadContext {
-public:
-
- enum LoadMode {
- // Load images incrementally. This is still experimental and
- // will cause the image plugins to report errors.
- // Also note that as of Qt 4.2.2, the JPEG loader does not return error codes
- // on "preliminary end of data".
- LoadIncrementally,
- // Load images only if all data have been received
- LoadComplete };
-
- ReadContext(const IncomingData & data, LoadMode loadMode, ImageList &target);
-
- enum ReadResult { ReadEOF, ReadFailed, ReadPartial, ReadComplete };
-
- // Append data and read out all images. Returns the result
- // of the last read operation, so, even if ReadPartial is returned,
- // a few images might have been read.
- ReadResult read(bool allDataReceived);
-
- QImageReader *reader() { return &m_reader; }
-
-private:
- enum IncrementalReadResult { IncrementalReadFailed, IncrementalReadPartial, IncrementalReadComplete };
- // Incrementally read an image
- IncrementalReadResult readImageLines(ImageData &);
-
- const LoadMode m_loadMode;
-
- QByteArray m_data;
- QBuffer m_buffer;
- QImageReader m_reader;
-
- ImageList &m_target;
-
- // Detected data format of the stream
- enum QImage::Format m_dataFormat;
- QSize m_size;
-
-};
-
-ImageDecoderQt::ReadContext::ReadContext(const IncomingData & data, LoadMode loadMode, ImageList &target)
- : m_loadMode(loadMode)
- , m_data(data.data(), data.size())
- , m_buffer(&m_data)
- , m_reader(&m_buffer)
- , m_target(target)
- , m_dataFormat(QImage::Format_Invalid)
-{
- m_buffer.open(QIODevice::ReadOnly);
-}
-
-
-ImageDecoderQt::ReadContext::ReadResult
- ImageDecoderQt::ReadContext::read(bool allDataReceived)
-{
- // Complete mode: Read only all all data received
- if (m_loadMode == LoadComplete && !allDataReceived)
- return ReadPartial;
-
- // Attempt to read out all images
- while (true) {
- if (m_target.empty() || m_target.back().m_imageState == ImageComplete) {
- // Start a new image.
- if (!m_reader.canRead())
- return ReadEOF;
-
- // Attempt to construct an empty image of the matching size and format
- // for efficient reading
- QImage newImage = m_dataFormat != QImage::Format_Invalid ?
- QImage(m_size,m_dataFormat) : QImage();
- m_target.push_back(ImageData(newImage));
- }
-
- // read chunks
- switch (readImageLines(m_target.back())) {
- case IncrementalReadFailed:
- m_target.pop_back();
- return ReadFailed;
- case IncrementalReadPartial:
- return ReadPartial;
- case IncrementalReadComplete:
- m_target.back().m_imageState = ImageComplete;
- //store for next
- m_dataFormat = m_target.back().m_image.format();
- m_size = m_target.back().m_image.size();
- const bool supportsAnimation = m_reader.supportsAnimation();
-
- if (debugImageDecoderQt)
- qDebug() << "readImage(): #" << m_target.size() << " complete, " << m_size << " format " << m_dataFormat
- << " supportsAnimation=" << supportsAnimation ;
- // No point in readinfg further
- if (!supportsAnimation)
- return ReadComplete;
-
- break;
- }
- }
- return ReadComplete;
-}
-
-
-
-ImageDecoderQt::ReadContext::IncrementalReadResult
- ImageDecoderQt::ReadContext::readImageLines(ImageData &imageData)
-{
- // TODO: Implement incremental reading here,
- // set state to reflect complete header, etc.
- // For now, we read the whole image.
-
- const qint64 startPos = m_buffer.pos ();
- // Oops, failed. Rewind.
- if (!m_reader.read(&imageData.m_image)) {
- m_buffer.seek(startPos);
- const bool gotHeader = imageData.m_image.size().width();
-
- if (debugImageDecoderQt)
- qDebug() << "readImageLines(): read() failed: " << m_reader.errorString()
- << " got header=" << gotHeader;
- // [Experimental] Did we manage to read the header?
- if (gotHeader) {
- imageData.m_imageState = ImageHeaderValid;
- return IncrementalReadPartial;
- }
- return IncrementalReadFailed;
- }
- imageData.m_duration = m_reader.nextImageDelay();
- return IncrementalReadComplete;
-}
-
-
-// ImageDecoderQt
-ImageDecoderQt::ImageDecoderQt( )
-{
-}
-
-ImageDecoderQt::~ImageDecoderQt()
-{
-}
-
-bool ImageDecoderQt::hasFirstImageHeader() const
-{
- return !m_imageList.empty() && m_imageList[0].m_imageState >= ImageHeaderValid;
-}
-
-void ImageDecoderQt::reset()
-{
- m_failed = false;
- m_imageList.clear();
- m_pixmapCache.clear();
- m_sizeAvailable = false;
- m_loopCount = cAnimationNone;
- m_size = IntSize(-1, -1);
-}
-
-void ImageDecoderQt::setData(const IncomingData &data, bool allDataReceived)
-{
- reset();
- ReadContext readContext(data, ReadContext::LoadComplete, m_imageList);
-
- if (debugImageDecoderQt)
- qDebug() << " setData " << data.size() << " image bytes, complete=" << allDataReceived;
-
- const ReadContext::ReadResult readResult = readContext.read(allDataReceived);
-
- if (debugImageDecoderQt)
- qDebug() << " read returns " << readResult;
-
- switch ( readResult) {
- case ReadContext::ReadFailed:
- m_failed = true;
- break;
- case ReadContext::ReadEOF:
- case ReadContext::ReadPartial:
- case ReadContext::ReadComplete:
- // Did we read anything - try to set the size.
- if (hasFirstImageHeader()) {
- m_sizeAvailable = true;
- m_size = m_imageList[0].m_image.size();
-
- if (readContext.reader()->supportsAnimation()) {
- if (readContext.reader()->loopCount() != -1)
- m_loopCount = readContext.reader()->loopCount();
- else
- m_loopCount = 0; //loop forever
- }
- }
- break;
- }
-}
-
-
-bool ImageDecoderQt::isSizeAvailable() const
-{
- if (debugImageDecoderQt)
- qDebug() << " ImageDecoderQt::isSizeAvailable() returns" << m_sizeAvailable;
- return m_sizeAvailable;
-}
-
-int ImageDecoderQt::frameCount() const
-{
- if (debugImageDecoderQt)
- qDebug() << " ImageDecoderQt::frameCount() returns" << m_imageList.size();
- return m_imageList.size();
-}
-
-
-int ImageDecoderQt::repetitionCount() const
-{
- if (debugImageDecoderQt)
- qDebug() << " ImageDecoderQt::repetitionCount() returns" << m_loopCount;
- return m_loopCount;
-}
-
-
-bool ImageDecoderQt::supportsAlpha() const
-{
- return hasFirstImageHeader() && m_imageList[0].m_image.hasAlphaChannel();
-}
-
-int ImageDecoderQt::duration(size_t index) const
-{
- if (index >= m_imageList.size())
- return 0;
- return m_imageList[index].m_duration;
-}
-
-RGBA32Buffer* ImageDecoderQt::frameBufferAtIndex(size_t index)
-{
- Q_ASSERT("use imageAtIndex instead");
- return 0;
-}
-
-QPixmap* ImageDecoderQt::imageAtIndex(size_t index) const
-{
- if (debugImageDecoderQt)
- qDebug() << "ImageDecoderQt::imageAtIndex(" << index << ')';
-
- if (index >= m_imageList.size())
- return 0;
-
- if (!m_pixmapCache.contains(index)) {
- m_pixmapCache.insert(index,
- QPixmap::fromImage(m_imageList[index].m_image));
- }
- return &m_pixmapCache[index];
-}
-
-void ImageDecoderQt::clearFrame(size_t index)
-{
- if (m_imageList.size() < (int)index)
- m_imageList[index].m_image = QImage();
- m_pixmapCache.take(index);
-}
-
-}
-
-// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/graphics/qt/ImageDecoderQt.h b/WebCore/platform/graphics/qt/ImageDecoderQt.h
deleted file mode 100644
index 3573dd0..0000000
--- a/WebCore/platform/graphics/qt/ImageDecoderQt.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (C) 2006 Friedemann Kleint <fkleint@trolltech.com>
- * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ImageDecoderQt_h
-#define ImageDecoderQt_h
-
-#include "ImageDecoder.h"
-#include <QtGui/QImage>
-#include <QtGui/QPixmap>
-#include <QtCore/QList>
-#include <QtCore/QHash>
-
-namespace WebCore {
-
-
-class ImageDecoderQt : public ImageDecoder
-{
- ImageDecoderQt(const ImageDecoderQt&);
- ImageDecoderQt &operator=(const ImageDecoderQt&);
-public:
- ImageDecoderQt();
- ~ImageDecoderQt();
-
- typedef Vector<char> IncomingData;
-
- virtual void setData(const IncomingData& data, bool allDataReceived);
-
- virtual bool isSizeAvailable() const;
-
- virtual int frameCount() const;
-
-
- virtual int repetitionCount() const;
-
-
- virtual RGBA32Buffer* frameBufferAtIndex(size_t index);
-
- QPixmap* imageAtIndex(size_t index) const;
-
- virtual bool supportsAlpha() const;
-
- int duration(size_t index) const;
-
- void clearFrame(size_t index);
-private:
- class ReadContext;
- void reset();
- bool hasFirstImageHeader() const;
-
- enum ImageState {
- // Started image reading
- ImagePartial,
- // Header (size / alpha) are known
- ImageHeaderValid,
- // Image is complete
- ImageComplete };
-
- struct ImageData {
- ImageData(const QImage& image, ImageState imageState = ImagePartial, int duration=0);
- QImage m_image;
- ImageState m_imageState;
- int m_duration;
- };
-
- typedef QList<ImageData> ImageList;
- ImageList m_imageList;
- mutable QHash<int, QPixmap> m_pixmapCache;
- int m_loopCount;
-};
-
-
-
-}
-
-#endif
-
diff --git a/WebCore/platform/graphics/qt/ImageQt.cpp b/WebCore/platform/graphics/qt/ImageQt.cpp
deleted file mode 100644
index 9234c69..0000000
--- a/WebCore/platform/graphics/qt/ImageQt.cpp
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright (C) 2006 Dirk Mueller <mueller@kde.org>
- * Copyright (C) 2006 Zack Rusin <zack@kde.org>
- * Copyright (C) 2006 Simon Hausmann <hausmann@kde.org>
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Image.h"
-
-#include "BitmapImage.h"
-#include "FloatRect.h"
-#include "PlatformString.h"
-#include "GraphicsContext.h"
-#include "AffineTransform.h"
-#include "NotImplemented.h"
-#include "StillImageQt.h"
-#include "qwebsettings.h"
-
-#include <QPixmap>
-#include <QPainter>
-#include <QImage>
-#include <QImageReader>
-#if QT_VERSION >= 0x040300
-#include <QTransform>
-#endif
-
-#include <QDebug>
-
-#include <math.h>
-
-// This function loads resources into WebKit
-static QPixmap loadResourcePixmap(const char *name)
-{
- QPixmap pixmap;
- if (qstrcmp(name, "missingImage") == 0)
- pixmap = QWebSettings::webGraphic(QWebSettings::MissingImageGraphic);
- else if (qstrcmp(name, "nullPlugin") == 0)
- pixmap = QWebSettings::webGraphic(QWebSettings::MissingPluginGraphic);
- else if (qstrcmp(name, "urlIcon") == 0)
- pixmap = QWebSettings::webGraphic(QWebSettings::DefaultFrameIconGraphic);
- else if (qstrcmp(name, "textAreaResizeCorner") == 0)
- pixmap = QWebSettings::webGraphic(QWebSettings::TextAreaSizeGripCornerGraphic);
-
- return pixmap;
-}
-
-namespace WebCore {
-
-void FrameData::clear()
-{
- if (m_frame) {
- m_frame = 0;
- // NOTE: We purposefully don't reset metadata here, so that even if we
- // throw away previously-decoded data, animation loops can still access
- // properties like frame durations without re-decoding.
- }
-}
-
-
-
-// ================================================
-// Image Class
-// ================================================
-
-PassRefPtr<Image> Image::loadPlatformResource(const char* name)
-{
- return StillImage::create(loadResourcePixmap(name));
-}
-
-
-void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const AffineTransform& patternTransform,
- const FloatPoint& phase, CompositeOperator op, const FloatRect& destRect)
-{
- notImplemented();
-}
-
-void BitmapImage::initPlatformData()
-{
-}
-
-void BitmapImage::invalidatePlatformData()
-{
-}
-
-// Drawing Routines
-void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dst,
- const FloatRect& src, CompositeOperator op)
-{
- startAnimation();
-
- QPixmap* image = nativeImageForCurrentFrame();
- if (!image)
- return;
-
- if (mayFillWithSolidColor()) {
- fillWithSolidColor(ctxt, dst, solidColor(), op);
- return;
- }
-
- IntSize selfSize = size();
-
- ctxt->save();
-
- // Set the compositing operation.
- ctxt->setCompositeOperation(op);
-
- QPainter* painter(ctxt->platformContext());
-
- // Test using example site at
- // http://www.meyerweb.com/eric/css/edge/complexspiral/demo.html
- painter->drawPixmap(dst, *image, src);
-
- ctxt->restore();
-}
-
-void BitmapImage::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const AffineTransform& patternTransform,
- const FloatPoint& phase, CompositeOperator op, const FloatRect& destRect)
-{
- QPixmap* framePixmap = nativeImageForCurrentFrame();
- if (!framePixmap) // If it's too early we won't have an image yet.
- return;
-
- QPixmap pixmap = *framePixmap;
- QRect tr = QRectF(tileRect).toRect();
- if (tr.x() || tr.y() || tr.width() != pixmap.width() || tr.height() != pixmap.height()) {
- pixmap = pixmap.copy(tr);
- }
-
- QBrush b(pixmap);
- b.setMatrix(patternTransform);
- ctxt->save();
- ctxt->setCompositeOperation(op);
- QPainter* p = ctxt->platformContext();
- p->setBrushOrigin(phase);
- p->fillRect(destRect, b);
- ctxt->restore();
-}
-
-void BitmapImage::checkForSolidColor()
-{
- // FIXME: It's easy to implement this optimization. Just need to check the RGBA32 buffer to see if it is 1x1.
- m_isSolidColor = false;
-}
-
-}
-
-
-// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/graphics/qt/ImageSourceQt.cpp b/WebCore/platform/graphics/qt/ImageSourceQt.cpp
deleted file mode 100644
index 1d14f9d..0000000
--- a/WebCore/platform/graphics/qt/ImageSourceQt.cpp
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ImageSource.h"
-#include "ImageDecoderQt.h"
-#include "SharedBuffer.h"
-
-#include <QBuffer>
-#include <QImage>
-#include <QImageReader>
-
-namespace WebCore {
-static bool canHandleImage(const SharedBuffer& _data)
-{
- // We need at least 4 bytes to figure out what kind of image we're dealing with.
- if (_data.size() < 4)
- return false;
-
- QByteArray data = QByteArray::fromRawData(_data.data(), _data.size());
- QBuffer buffer(&data);
- if (!buffer.open(QBuffer::ReadOnly))
- return false;
-
- return !QImageReader::imageFormat(&buffer).isEmpty();
-}
-
-ImageDecoderQt* createDecoder(const SharedBuffer& data) {
- if (!canHandleImage(data))
- return 0;
- return new ImageDecoderQt();
-}
-
-ImageSource::ImageSource()
- : m_decoder(0)
-{
-}
-
-ImageSource::~ImageSource()
-{
- delete m_decoder;
-}
-
-bool ImageSource::initialized() const
-{
- return m_decoder;
-}
-
-void ImageSource::setData(SharedBuffer* data, bool allDataReceived)
-{
- // Make the decoder by sniffing the bytes.
- // This method will examine the data and instantiate an instance of the appropriate decoder plugin.
- // If insufficient bytes are available to determine the image type, no decoder plugin will be
- // made.
- if (!m_decoder)
- m_decoder = createDecoder(*data);
-
- if (!m_decoder)
- return;
-
- m_decoder->setData(data->buffer(), allDataReceived);
-}
-
-bool ImageSource::isSizeAvailable()
-{
- if (!m_decoder)
- return false;
-
- return m_decoder->isSizeAvailable();
-}
-
-IntSize ImageSource::size() const
-{
- if (!m_decoder)
- return IntSize();
-
- return m_decoder->size();
-}
-
-IntSize ImageSource::frameSizeAtIndex(size_t) const
-{
- return size();
-}
-
-int ImageSource::repetitionCount()
-{
- if (!m_decoder)
- return cAnimationNone;
-
- return m_decoder->repetitionCount();
-}
-
-size_t ImageSource::frameCount() const
-{
- if (!m_decoder)
- return 0;
-
- return m_decoder->frameCount();
-}
-
-NativeImagePtr ImageSource::createFrameAtIndex(size_t index)
-{
- if (!m_decoder)
- return 0;
-
- return m_decoder->imageAtIndex(index);
-}
-
-float ImageSource::frameDurationAtIndex(size_t index)
-{
- if (!m_decoder)
- return 0;
-
- // Many annoying ads specify a 0 duration to make an image flash as quickly
- // as possible. We follow WinIE's behavior and use a duration of 100 ms
- // for any frames that specify a duration of <= 50 ms. See
- // <http://bugs.webkit.org/show_bug.cgi?id=14413> or Radar 4051389 for
- // more.
- const float duration = m_decoder->duration(index) / 1000.0f;
- return (duration < 0.051f) ? 0.100f : duration;
-}
-
-bool ImageSource::frameHasAlphaAtIndex(size_t index)
-{
- if (!m_decoder || !m_decoder->supportsAlpha())
- return false;
-
- const QPixmap* source = m_decoder->imageAtIndex( index);
- if (!source)
- return false;
-
- return source->hasAlphaChannel();
-}
-
-bool ImageSource::frameIsCompleteAtIndex(size_t index)
-{
- return (m_decoder && m_decoder->imageAtIndex(index) != 0);
-}
-
-void ImageSource::clear()
-{
- delete m_decoder;
- m_decoder = 0;
-}
-
-
-}
-
-// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/graphics/qt/IntPointQt.cpp b/WebCore/platform/graphics/qt/IntPointQt.cpp
deleted file mode 100644
index f9d336a..0000000
--- a/WebCore/platform/graphics/qt/IntPointQt.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2006 Zack Rusin <zack@kde.org>
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "IntPoint.h"
-
-#include <QPoint>
-
-namespace WebCore {
-
-IntPoint::IntPoint(const QPoint& p)
- : m_x(p.x())
- , m_y(p.y())
-{
-}
-
-IntPoint::operator QPoint() const
-{
- return QPoint(m_x, m_y);
-}
-
-}
-
-// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/graphics/qt/IntRectQt.cpp b/WebCore/platform/graphics/qt/IntRectQt.cpp
deleted file mode 100644
index ccc153e..0000000
--- a/WebCore/platform/graphics/qt/IntRectQt.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2006 Zack Rusin <zack@kde.org>
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "IntRect.h"
-
-#include <QRect>
-
-namespace WebCore {
-
-IntRect::IntRect(const QRect& r)
- : m_location(r.topLeft())
- , m_size(r.width(), r.height())
-{
-}
-
-IntRect::operator QRect() const
-{
- return QRect(x(), y(), width(), height());
-}
-
-}
-
-// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/graphics/qt/IntSizeQt.cpp b/WebCore/platform/graphics/qt/IntSizeQt.cpp
deleted file mode 100644
index 4f2bf35..0000000
--- a/WebCore/platform/graphics/qt/IntSizeQt.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include <QSize>
-
-#include "IntSize.h"
-
-namespace WebCore {
-
-IntSize::IntSize(const QSize& r)
- : m_width(r.width())
- , m_height(r.height())
-{
-}
-
-IntSize::operator QSize() const
-{
- return QSize(width(), height());
-}
-
-}
-
-// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/graphics/qt/MediaPlayerPrivatePhonon.cpp b/WebCore/platform/graphics/qt/MediaPlayerPrivatePhonon.cpp
deleted file mode 100644
index 431e68e..0000000
--- a/WebCore/platform/graphics/qt/MediaPlayerPrivatePhonon.cpp
+++ /dev/null
@@ -1,533 +0,0 @@
-/*
- Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include "config.h"
-#include "MediaPlayerPrivatePhonon.h"
-
-#include <limits>
-
-#include "CString.h"
-#include "FrameView.h"
-#include "GraphicsContext.h"
-#include "NotImplemented.h"
-#include "Widget.h"
-#include <wtf/HashSet.h>
-
-#include <QDebug>
-#include <QPainter>
-#include <QWidget>
-#include <QMetaEnum>
-#include <QUrl>
-#include <QEvent>
-#include <phonon>
-
-using namespace Phonon;
-
-#define LOG_MEDIAOBJECT() (LOG(Media,"%s", debugMediaObject(this, *m_mediaObject).constData()))
-
-static QByteArray debugMediaObject(WebCore::MediaPlayerPrivate* mediaPlayer, const MediaObject& mediaObject)
-{
- QByteArray byteArray;
- QTextStream stream(&byteArray);
-
- const QMetaObject* metaObj = mediaPlayer->metaObject();
- QMetaEnum phononStates = metaObj->enumerator(metaObj->indexOfEnumerator("PhononState"));
-
- stream << "debugMediaObject -> Phonon::MediaObject(";
- stream << "State: " << phononStates.valueToKey(mediaObject.state());
- stream << " | Current time: " << mediaObject.currentTime();
- stream << " | Remaining time: " << mediaObject.remainingTime();
- stream << " | Total time: " << mediaObject.totalTime();
- stream << " | Meta-data: ";
- QMultiMap<QString, QString> map = mediaObject.metaData();
- for (QMap<QString, QString>::const_iterator it = map.constBegin();
- it != map.constEnd(); ++it) {
- stream << "(" << it.key() << ", " << it.value() << ")";
- }
- stream << " | Has video: " << mediaObject.hasVideo();
- stream << " | Is seekable: " << mediaObject.isSeekable();
- stream << ")";
-
- stream.flush();
-
- return byteArray;
-}
-
-using namespace WTF;
-
-namespace WebCore {
-
-MediaPlayerPrivate::MediaPlayerPrivate(MediaPlayer* player)
- : m_player(player)
- , m_networkState(MediaPlayer::Empty)
- , m_readyState(MediaPlayer::DataUnavailable)
- , m_mediaObject(new MediaObject())
- , m_videoWidget(new VideoWidget(0))
- , m_audioOutput(new AudioOutput())
- , m_isVisible(false)
-{
- // Hint to Phonon to disable overlay painting
- m_videoWidget->setAttribute(Qt::WA_DontShowOnScreen);
-
- createPath(m_mediaObject, m_videoWidget);
- createPath(m_mediaObject, m_audioOutput);
-
- // Make sure we get updates for each frame
- m_videoWidget->installEventFilter(this);
- foreach(QWidget* widget, qFindChildren<QWidget*>(m_videoWidget)) {
- widget->installEventFilter(this);
- }
-
- connect(m_mediaObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)),
- this, SLOT(stateChanged(Phonon::State, Phonon::State)));
- connect(m_mediaObject, SIGNAL(tick(qint64)), this, SLOT(tick(qint64)));
- connect(m_mediaObject, SIGNAL(metaDataChanged()), this, SLOT(metaDataChanged()));
- connect(m_mediaObject, SIGNAL(seekableChanged(bool)), this, SLOT(seekableChanged(bool)));
- connect(m_mediaObject, SIGNAL(hasVideoChanged(bool)), this, SLOT(hasVideoChanged(bool)));
- connect(m_mediaObject, SIGNAL(bufferStatus(int)), this, SLOT(bufferStatus(int)));
- connect(m_mediaObject, SIGNAL(finished()), this, SLOT(finished()));
- connect(m_mediaObject, SIGNAL(currentSourceChanged(const Phonon::MediaSource&)),
- this, SLOT(currentSourceChanged(const Phonon::MediaSource&)));
- connect(m_mediaObject, SIGNAL(aboutToFinish()), this, SLOT(aboutToFinish()));
- connect(m_mediaObject, SIGNAL(prefinishMarkReached(qint32)), this, SLOT(prefinishMarkReached(qint32)));
- connect(m_mediaObject, SIGNAL(totalTimeChanged(qint64)), this, SLOT(totalTimeChanged(qint64)));
-}
-
-MediaPlayerPrivate::~MediaPlayerPrivate()
-{
- LOG(Media, "MediaPlayerPrivatePhonon::dtor deleting videowidget");
- m_videoWidget->close();
- delete m_videoWidget;
- m_videoWidget = 0;
-
- LOG(Media, "MediaPlayerPrivatePhonon::dtor deleting audiooutput");
- delete m_audioOutput;
- m_audioOutput = 0;
-
- LOG(Media, "MediaPlayerPrivatePhonon::dtor deleting mediaobject");
- delete m_mediaObject;
- m_mediaObject = 0;
-}
-
-void MediaPlayerPrivate::getSupportedTypes(HashSet<String>&)
-{
- notImplemented();
-}
-
-bool MediaPlayerPrivate::hasVideo() const
-{
- bool hasVideo = m_mediaObject->hasVideo();
- LOG(Media, "MediaPlayerPrivatePhonon::hasVideo() -> %s", hasVideo ? "true" : "false");
- return hasVideo;
-}
-
-void MediaPlayerPrivate::load(String url)
-{
- LOG(Media, "MediaPlayerPrivatePhonon::load(\"%s\")", url.utf8().data());
-
- // We are now loading
- if (m_networkState != MediaPlayer::Loading) {
- m_networkState = MediaPlayer::Loading;
- m_player->networkStateChanged();
- }
-
- // And we don't have any data yet
- if (m_readyState != MediaPlayer::DataUnavailable) {
- m_readyState = MediaPlayer::DataUnavailable;
- m_player->readyStateChanged();
- }
-
- m_mediaObject->setCurrentSource(QUrl(url));
- m_audioOutput->setVolume(m_player->volume());
- setVisible(m_player->visible());
-}
-
-void MediaPlayerPrivate::cancelLoad()
-{
- notImplemented();
-}
-
-
-void MediaPlayerPrivate::play()
-{
- LOG(Media, "MediaPlayerPrivatePhonon::play()");
- m_mediaObject->play();
-}
-
-void MediaPlayerPrivate::pause()
-{
- LOG(Media, "MediaPlayerPrivatePhonon::pause()");
- m_mediaObject->pause();
-}
-
-
-bool MediaPlayerPrivate::paused() const
-{
- bool paused = m_mediaObject->state() == Phonon::PausedState;
- LOG(Media, "MediaPlayerPrivatePhonon::paused() --> %s", paused ? "true" : "false");
- return paused;
-}
-
-void MediaPlayerPrivate::seek(float position)
-{
- LOG(Media, "MediaPlayerPrivatePhonon::seek(%f)", position);
-
- if (!m_mediaObject->isSeekable())
- return;
-
- if (position > duration())
- position = duration();
-
- m_mediaObject->seek(position * 1000.0f);
-}
-
-bool MediaPlayerPrivate::seeking() const
-{
- return false;
-}
-
-float MediaPlayerPrivate::duration() const
-{
- if (m_networkState < MediaPlayer::LoadedMetaData)
- return 0.0f;
-
- float duration = m_mediaObject->totalTime() / 1000.0f;
-
- if (duration == 0.0f) // We are streaming
- duration = std::numeric_limits<float>::infinity();
-
- LOG(Media, "MediaPlayerPrivatePhonon::duration() --> %f", duration);
- return duration;
-}
-
-float MediaPlayerPrivate::currentTime() const
-{
- float currentTime = m_mediaObject->currentTime() / 1000.0f;
-
- LOG(Media, "MediaPlayerPrivatePhonon::currentTime() --> %f", currentTime);
- return currentTime;
-}
-
-void MediaPlayerPrivate::setEndTime(float endTime)
-{
- notImplemented();
-}
-
-float MediaPlayerPrivate::maxTimeBuffered() const
-{
- notImplemented();
- return 0.0f;
-}
-
-float MediaPlayerPrivate::maxTimeSeekable() const
-{
- notImplemented();
- return 0.0f;
-}
-
-unsigned MediaPlayerPrivate::bytesLoaded() const
-{
- notImplemented();
- return 0;
-}
-
-bool MediaPlayerPrivate::totalBytesKnown() const
-{
- //notImplemented();
- return false;
-}
-
-unsigned MediaPlayerPrivate::totalBytes() const
-{
- //notImplemented();
- return 0;
-}
-
-void MediaPlayerPrivate::setRate(float)
-{
- notImplemented();
-}
-
-void MediaPlayerPrivate::setVolume(float volume)
-{
- LOG(Media, "MediaPlayerPrivatePhonon::setVolume()");
- m_audioOutput->setVolume(volume);
-}
-
-void MediaPlayerPrivate::setMuted(bool muted)
-{
- LOG(Media, "MediaPlayerPrivatePhonon::setMuted()");
- m_audioOutput->setMuted(muted);
-}
-
-
-int MediaPlayerPrivate::dataRate() const
-{
- // This is not used at the moment
- return 0;
-}
-
-
-MediaPlayer::NetworkState MediaPlayerPrivate::networkState() const
-{
- const QMetaObject* metaObj = this->metaObject();
- QMetaEnum networkStates = metaObj->enumerator(metaObj->indexOfEnumerator("NetworkState"));
- LOG(Media, "MediaPlayerPrivatePhonon::networkState() --> %s", networkStates.valueToKey(m_networkState));
- return m_networkState;
-}
-
-MediaPlayer::ReadyState MediaPlayerPrivate::readyState() const
-{
- const QMetaObject* metaObj = this->metaObject();
- QMetaEnum readyStates = metaObj->enumerator(metaObj->indexOfEnumerator("ReadyState"));
- LOG(Media, "MediaPlayerPrivatePhonon::readyState() --> %s", readyStates.valueToKey(m_readyState));
- return m_readyState;
-}
-
-void MediaPlayerPrivate::updateStates()
-{
- MediaPlayer::NetworkState oldNetworkState = m_networkState;
- MediaPlayer::ReadyState oldReadyState = m_readyState;
-
- Phonon::State phononState = m_mediaObject->state();
-
- if (phononState == Phonon::StoppedState) {
- if (oldNetworkState < MediaPlayer::LoadedMetaData) {
- m_networkState = MediaPlayer::LoadedMetaData;
- m_readyState = MediaPlayer::DataUnavailable;
- m_mediaObject->pause();
- }
- } else if (phononState == Phonon::PausedState) {
- m_networkState = MediaPlayer::LoadedFirstFrame;
- m_readyState = MediaPlayer::CanPlayThrough;
- } else if (phononState == Phonon::ErrorState) {
- if (!m_mediaObject || m_mediaObject->errorType() == Phonon::FatalError) {
- m_networkState = MediaPlayer::LoadFailed;
- m_readyState = MediaPlayer::DataUnavailable;
- cancelLoad();
- } else {
- m_mediaObject->pause();
- }
- }
-
- if (seeking())
- m_readyState = MediaPlayer::DataUnavailable;
-
- if (m_networkState != oldNetworkState) {
- const QMetaObject* metaObj = this->metaObject();
- QMetaEnum networkStates = metaObj->enumerator(metaObj->indexOfEnumerator("NetworkState"));
- LOG(Media, "Network state changed from '%s' to '%s'",
- networkStates.valueToKey(oldNetworkState),
- networkStates.valueToKey(m_networkState));
- m_player->networkStateChanged();
- }
-
- if (m_readyState != oldReadyState) {
- const QMetaObject* metaObj = this->metaObject();
- QMetaEnum readyStates = metaObj->enumerator(metaObj->indexOfEnumerator("ReadyState"));
- LOG(Media, "Ready state changed from '%s' to '%s'",
- readyStates.valueToKey(oldReadyState),
- readyStates.valueToKey(m_readyState));
- m_player->readyStateChanged();
- }
-}
-
-void MediaPlayerPrivate::setVisible(bool visible)
-{
- m_isVisible = visible;
- LOG(Media, "MediaPlayerPrivatePhonon::setVisible(%s)", visible ? "true" : "false");
-
- m_videoWidget->setVisible(m_isVisible);
-}
-
-void MediaPlayerPrivate::setRect(const IntRect& newRect)
-{
- if (!m_videoWidget)
- return;
-
- LOG(Media, "MediaPlayerPrivatePhonon::setRect(%d,%d %dx%d)",
- newRect.x(), newRect.y(),
- newRect.width(), newRect.height());
-
- QRect currentRect = m_videoWidget->rect();
-
- if (newRect.width() != currentRect.width() || newRect.height() != currentRect.height())
- m_videoWidget->resize(newRect.width(), newRect.height());
-}
-
-
-void MediaPlayerPrivate::loadStateChanged()
-{
- notImplemented();
-}
-
-void MediaPlayerPrivate::rateChanged()
-{
- notImplemented();
-}
-
-void MediaPlayerPrivate::sizeChanged()
-{
- notImplemented();
-}
-
-void MediaPlayerPrivate::timeChanged()
-{
- notImplemented();
-}
-
-void MediaPlayerPrivate::volumeChanged()
-{
- notImplemented();
-}
-
-void MediaPlayerPrivate::didEnd()
-{
- notImplemented();
-}
-
-void MediaPlayerPrivate::loadingFailed()
-{
- notImplemented();
-}
-
-IntSize MediaPlayerPrivate::naturalSize() const
-{
- if (!hasVideo()) {
- LOG(Media, "MediaPlayerPrivatePhonon::naturalSize() -> %dx%d",
- 0, 0);
- return IntSize();
- }
-
- if (m_networkState < MediaPlayer::LoadedMetaData) {
- LOG(Media, "MediaPlayerPrivatePhonon::naturalSize() -> %dx%d",
- 0, 0);
- return IntSize();
- }
-
- QSize videoSize = m_videoWidget->sizeHint();
- IntSize naturalSize(videoSize.width(), videoSize.height());
- LOG(Media, "MediaPlayerPrivatePhonon::naturalSize() -> %dx%d",
- naturalSize.width(), naturalSize.height());
- return naturalSize;
-}
-
-bool MediaPlayerPrivate::eventFilter(QObject* obj, QEvent* event)
-{
- if (event->type() == QEvent::Paint)
- m_player->repaint();
-
- return QObject::eventFilter(obj, event);
-}
-
-void MediaPlayerPrivate::repaint()
-{
- m_player->repaint();
-}
-
-void MediaPlayerPrivate::paint(GraphicsContext* graphicsContect, const IntRect& rect)
-{
- if (graphicsContect->paintingDisabled())
- return;
-
- if (!m_isVisible)
- return;
-
- QPainter* painter = graphicsContect->platformContext();
-
- painter->fillRect(rect, Qt::black);
-
- m_videoWidget->render(painter, QPoint(rect.x(), rect.y()),
- QRegion(0, 0, rect.width(), rect.height()));
-}
-
-// ====================== Phonon::MediaObject signals ======================
-
-void MediaPlayerPrivate::stateChanged(Phonon::State newState, Phonon::State oldState)
-{
- const QMetaObject* metaObj = this->metaObject();
- QMetaEnum phononStates = metaObj->enumerator(metaObj->indexOfEnumerator("PhononState"));
- LOG(Media, "MediaPlayerPrivatePhonon::stateChanged(newState=%s, oldState=%s)",
- phononStates.valueToKey(newState), phononStates.valueToKey(oldState));
-
- updateStates();
-}
-
-void MediaPlayerPrivate::tick(qint64)
-{
- updateStates();
- m_player->timeChanged();
-}
-
-void MediaPlayerPrivate::metaDataChanged()
-{
- LOG(Media, "MediaPlayerPrivatePhonon::metaDataChanged()");
- LOG_MEDIAOBJECT();
-}
-
-void MediaPlayerPrivate::seekableChanged(bool)
-{
- notImplemented();
- LOG_MEDIAOBJECT();
-}
-
-void MediaPlayerPrivate::hasVideoChanged(bool hasVideo)
-{
- LOG(Media, "MediaPlayerPrivatePhonon::hasVideoChanged(%s)", hasVideo ? "true" : "false");
-}
-
-void MediaPlayerPrivate::bufferStatus(int)
-{
- notImplemented();
- LOG_MEDIAOBJECT();
-}
-
-void MediaPlayerPrivate::finished()
-{
- notImplemented();
- LOG_MEDIAOBJECT();
-}
-
-void MediaPlayerPrivate::currentSourceChanged(const Phonon::MediaSource&)
-{
- notImplemented();
- LOG_MEDIAOBJECT();
-}
-
-void MediaPlayerPrivate::aboutToFinish()
-{
- notImplemented();
- LOG_MEDIAOBJECT();
-}
-
-void MediaPlayerPrivate::prefinishMarkReached(qint32)
-{
- notImplemented();
- LOG_MEDIAOBJECT();
-}
-
-void MediaPlayerPrivate::totalTimeChanged(qint64 totalTime)
-{
- LOG(Media, "MediaPlayerPrivatePhonon::totalTimeChanged(%d)", totalTime);
- LOG_MEDIAOBJECT();
-}
-
-} // namespace WebCore
-
-#include "moc_MediaPlayerPrivatePhonon.cpp"
diff --git a/WebCore/platform/graphics/qt/MediaPlayerPrivatePhonon.h b/WebCore/platform/graphics/qt/MediaPlayerPrivatePhonon.h
deleted file mode 100644
index 5eb2a09..0000000
--- a/WebCore/platform/graphics/qt/MediaPlayerPrivatePhonon.h
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#ifndef MediaPlayerPrivatePhonon_h
-#define MediaPlayerPrivatePhonon_h
-
-#include "MediaPlayer.h"
-#include <wtf/Noncopyable.h>
-
-#include <QObject>
-#include <phononnamespace.h>
-
-QT_BEGIN_NAMESPACE
-class QWidget;
-class QUrl;
-
-namespace Phonon {
- class MediaObject;
- class VideoWidget;
- class AudioOutput;
- class MediaSource;
-}
-QT_END_NAMESPACE
-
-namespace WebCore {
-
- class MediaPlayerPrivate : public QObject, Noncopyable {
-
- Q_OBJECT
-
- public:
- MediaPlayerPrivate(MediaPlayer*);
- ~MediaPlayerPrivate();
-
- // These enums are used for debugging
- Q_ENUMS(ReadyState NetworkState PhononState)
-
- enum ReadyState {
- DataUnavailable,
- CanShowCurrentFrame,
- CanPlay,
- CanPlayThrough
- };
-
- enum NetworkState {
- Empty,
- LoadFailed,
- Loading,
- LoadedMetaData,
- LoadedFirstFrame,
- Loaded
- };
-
- enum PhononState {
- LoadingState,
- StoppedState,
- PlayingState,
- BufferingState,
- PausedState,
- ErrorState
- };
-
- IntSize naturalSize() const;
- bool hasVideo() const;
-
- void load(String url);
- void cancelLoad();
-
- void play();
- void pause();
-
- bool paused() const;
- bool seeking() const;
-
- float duration() const;
- float currentTime() const;
- void seek(float);
- void setEndTime(float);
-
- void setRate(float);
- void setVolume(float);
- void setMuted(bool);
-
- int dataRate() const;
-
- MediaPlayer::NetworkState networkState() const;
- MediaPlayer::ReadyState readyState() const;
-
- float maxTimeBuffered() const;
- float maxTimeSeekable() const;
- unsigned bytesLoaded() const;
- bool totalBytesKnown() const;
- unsigned totalBytes() const;
-
- void setVisible(bool);
- void setRect(const IntRect&);
-
- void loadStateChanged();
- void rateChanged();
- void sizeChanged();
- void timeChanged();
- void volumeChanged();
- void didEnd();
- void loadingFailed();
-
- void repaint();
- void paint(GraphicsContext*, const IntRect&);
- static void getSupportedTypes(HashSet<String>&);
- static bool isAvailable() { return true; }
-
- protected:
- bool eventFilter(QObject*, QEvent*);
-
- private slots:
- void stateChanged(Phonon::State, Phonon::State);
- void tick(qint64);
- void metaDataChanged();
- void seekableChanged(bool);
- void hasVideoChanged(bool);
- void bufferStatus(int);
- void finished();
- void currentSourceChanged(const Phonon::MediaSource&);
- void aboutToFinish();
- void prefinishMarkReached(qint32);
- void totalTimeChanged(qint64);
-
- private:
- void updateStates();
-
- MediaPlayer* m_player;
-
- MediaPlayer::NetworkState m_networkState;
- MediaPlayer::ReadyState m_readyState;
-
- Phonon::MediaObject* m_mediaObject;
- Phonon::VideoWidget* m_videoWidget;
- Phonon::AudioOutput* m_audioOutput;
-
- bool m_isVisible;
- };
-}
-
-#endif // MediaPlayerPrivatePhonon_h
diff --git a/WebCore/platform/graphics/qt/PathQt.cpp b/WebCore/platform/graphics/qt/PathQt.cpp
deleted file mode 100644
index 76f375c..0000000
--- a/WebCore/platform/graphics/qt/PathQt.cpp
+++ /dev/null
@@ -1,278 +0,0 @@
-/*
- * Copyright (C) 2006 Zack Rusin <zack@kde.org>
- * 2006 Rob Buis <buis@kde.org>
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Path.h"
-
-#include "FloatRect.h"
-#include "PlatformString.h"
-#include "AffineTransform.h"
-#include <QPainterPath>
-#include <QMatrix>
-#include <QString>
-
-#define _USE_MATH_DEFINES
-#include <math.h>
-
-namespace WebCore {
-
-Path::Path()
- : m_path(new QPainterPath())
-{
-}
-
-Path::~Path()
-{
- delete m_path;
-}
-
-Path::Path(const Path& other)
- : m_path(new QPainterPath(*other.platformPath()))
-{
-}
-
-Path& Path::operator=(const Path& other)
-{
- if (&other != this) {
- delete m_path;
- m_path = new QPainterPath(*other.platformPath());
- }
-
- return *this;
-}
-
-bool Path::contains(const FloatPoint& point, WindRule rule) const
-{
- Qt::FillRule savedRule = m_path->fillRule();
- m_path->setFillRule(rule == RULE_EVENODD ? Qt::OddEvenFill : Qt::WindingFill);
-
- bool contains = m_path->contains(point);
-
- m_path->setFillRule(savedRule);
- return contains;
-}
-
-void Path::translate(const FloatSize& size)
-{
- QMatrix matrix;
- matrix.translate(size.width(), size.height());
- *m_path = (*m_path) * matrix;
-}
-
-FloatRect Path::boundingRect() const
-{
- return m_path->boundingRect();
-}
-
-void Path::moveTo(const FloatPoint& point)
-{
- m_path->moveTo(point);
-}
-
-void Path::addLineTo(const FloatPoint& p)
-{
- m_path->lineTo(p);
-}
-
-void Path::addQuadCurveTo(const FloatPoint& cp, const FloatPoint& p)
-{
- m_path->quadTo(cp, p);
-}
-
-void Path::addBezierCurveTo(const FloatPoint& cp1, const FloatPoint& cp2, const FloatPoint& p)
-{
- m_path->cubicTo(cp1, cp2, p);
-}
-
-void Path::addArcTo(const FloatPoint& p1, const FloatPoint& p2, float radius)
-{
- //FIXME: busted
- qWarning("arcTo is busted");
- m_path->arcTo(p1.x(), p1.y(), p2.x(), p2.y(), radius, 90);
-}
-
-void Path::closeSubpath()
-{
- m_path->closeSubpath();
-}
-
-#define DEGREES(t) ((t) * 180.0 / M_PI)
-void Path::addArc(const FloatPoint& p, float r, float sar, float ear, bool anticlockwise)
-{
- qreal xc = p.x();
- qreal yc = p.y();
- qreal radius = r;
-
-
- //### HACK
- // In Qt we don't switch the coordinate system for degrees
- // and still use the 0,0 as bottom left for degrees so we need
- // to switch
- sar = -sar;
- ear = -ear;
- anticlockwise = !anticlockwise;
- //end hack
-
- float sa = DEGREES(sar);
- float ea = DEGREES(ear);
-
- double span = 0;
-
- double xs = xc - radius;
- double ys = yc - radius;
- double width = radius*2;
- double height = radius*2;
-
- if (!anticlockwise && (ea < sa))
- span += 360;
- else if (anticlockwise && (sa < ea))
- span -= 360;
-
- // this is also due to switched coordinate system
- // we would end up with a 0 span instead of 360
- if (!(qFuzzyCompare(span + (ea - sa) + 1, 1.0) &&
- qFuzzyCompare(qAbs(span), 360.0))) {
- span += ea - sa;
- }
-
- m_path->moveTo(QPointF(xc + radius * cos(sar),
- yc - radius * sin(sar)));
-
- m_path->arcTo(xs, ys, width, height, sa, span);
-}
-
-void Path::addRect(const FloatRect& r)
-{
- m_path->addRect(r.x(), r.y(), r.width(), r.height());
-}
-
-void Path::addEllipse(const FloatRect& r)
-{
- m_path->addEllipse(r.x(), r.y(), r.width(), r.height());
-}
-
-void Path::clear()
-{
- *m_path = QPainterPath();
-}
-
-bool Path::isEmpty() const
-{
- return m_path->isEmpty();
-}
-
-String Path::debugString() const
-{
- QString ret;
- for (int i = 0; i < m_path->elementCount(); ++i) {
- const QPainterPath::Element &cur = m_path->elementAt(i);
-
- switch (cur.type) {
- case QPainterPath::MoveToElement:
- ret += QString(QLatin1String("M %1 %2")).arg(cur.x).arg(cur.y);
- break;
- case QPainterPath::LineToElement:
- ret += QString(QLatin1String("L %1 %2")).arg(cur.x).arg(cur.y);
- break;
- case QPainterPath::CurveToElement:
- {
- const QPainterPath::Element &c1 = m_path->elementAt(i + 1);
- const QPainterPath::Element &c2 = m_path->elementAt(i + 2);
-
- Q_ASSERT(c1.type == QPainterPath::CurveToDataElement);
- Q_ASSERT(c2.type == QPainterPath::CurveToDataElement);
-
- ret += QString(QLatin1String("C %1 %2 %3 %4 %5 %6")).arg(cur.x).arg(cur.y).arg(c1.x).arg(c1.y).arg(c2.x).arg(c2.y);
-
- i += 2;
- break;
- }
- case QPainterPath::CurveToDataElement:
- Q_ASSERT(false);
- break;
- }
- }
-
- return ret;
-}
-
-void Path::apply(void* info, PathApplierFunction function) const
-{
- PathElement pelement;
- FloatPoint points[3];
- pelement.points = points;
- for (int i = 0; i < m_path->elementCount(); ++i) {
- const QPainterPath::Element& cur = m_path->elementAt(i);
-
- switch (cur.type) {
- case QPainterPath::MoveToElement:
- pelement.type = PathElementMoveToPoint;
- pelement.points[0] = QPointF(cur);
- function(info, &pelement);
- break;
- case QPainterPath::LineToElement:
- pelement.type = PathElementAddLineToPoint;
- pelement.points[0] = QPointF(cur);
- function(info, &pelement);
- break;
- case QPainterPath::CurveToElement:
- {
- const QPainterPath::Element& c1 = m_path->elementAt(i + 1);
- const QPainterPath::Element& c2 = m_path->elementAt(i + 2);
-
- Q_ASSERT(c1.type == QPainterPath::CurveToDataElement);
- Q_ASSERT(c2.type == QPainterPath::CurveToDataElement);
-
- pelement.type = PathElementAddCurveToPoint;
- pelement.points[0] = QPointF(cur);
- pelement.points[1] = QPointF(c1);
- pelement.points[2] = QPointF(c2);
- function(info, &pelement);
-
- i += 2;
- break;
- }
- case QPainterPath::CurveToDataElement:
- Q_ASSERT(false);
- }
- }
-}
-
-void Path::transform(const AffineTransform& transform)
-{
- if (m_path) {
- QMatrix mat = transform;
- QPainterPath temp = mat.map(*m_path);
- delete m_path;
- m_path = new QPainterPath(temp);
- }
-}
-
-}
-
-// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/graphics/qt/PatternQt.cpp b/WebCore/platform/graphics/qt/PatternQt.cpp
deleted file mode 100644
index 883a258..0000000
--- a/WebCore/platform/graphics/qt/PatternQt.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Pattern.h"
-
-#include "AffineTransform.h"
-#include "GraphicsContext.h"
-
-namespace WebCore {
-
-QBrush Pattern::createPlatformPattern(const AffineTransform& transform) const
-{
- QPixmap* pixmap = tileImage()->nativeImageForCurrentFrame();
- if (!pixmap)
- return QBrush();
-
- QBrush brush(*pixmap);
- brush.setMatrix(transform);
-
- return brush;
-}
-
-}
diff --git a/WebCore/platform/graphics/qt/SimpleFontDataQt.cpp b/WebCore/platform/graphics/qt/SimpleFontDataQt.cpp
deleted file mode 100644
index 1ffce33..0000000
--- a/WebCore/platform/graphics/qt/SimpleFontDataQt.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-
- This class provides all functionality needed for loading images, style sheets and html
- pages from the web. It has a memory cache for these objects.
-*/
-#include "config.h"
-#include "SimpleFontData.h"
-
-#include "SVGFontData.h"
-
-namespace WebCore {
-
-SimpleFontData::SimpleFontData(const FontPlatformData& font, bool customFont, bool loading, SVGFontData*)
- : m_font(font)
- , m_isCustomFont(customFont)
- , m_isLoading(loading)
-{
-}
-
-SimpleFontData::~SimpleFontData()
-{
-}
-
-bool SimpleFontData::containsCharacters(const UChar* characters, int length) const
-{
- return true;
-}
-
-const SimpleFontData* SimpleFontData::fontDataForCharacter(UChar32) const
-{
- return this;
-}
-
-bool SimpleFontData::isSegmented() const
-{
- return false;
-}
-
-}
diff --git a/WebCore/platform/graphics/qt/StillImageQt.cpp b/WebCore/platform/graphics/qt/StillImageQt.cpp
deleted file mode 100644
index 95b3bc8..0000000
--- a/WebCore/platform/graphics/qt/StillImageQt.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2008 Holger Hans Peter Freyther
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "StillImageQt.h"
-
-#include "GraphicsContext.h"
-#include "IntSize.h"
-
-#include <QPainter>
-
-namespace WebCore {
-
-StillImage::StillImage(const QPixmap& pixmap)
- : m_pixmap(pixmap)
-{}
-
-IntSize StillImage::size() const
-{
- return IntSize(m_pixmap.width(), m_pixmap.height());
-}
-
-NativeImagePtr StillImage::nativeImageForCurrentFrame()
-{
- return const_cast<NativeImagePtr>(&m_pixmap);
-}
-
-void StillImage::draw(GraphicsContext* ctxt, const FloatRect& dst,
- const FloatRect& src, CompositeOperator op)
-{
- if (m_pixmap.isNull())
- return;
-
- ctxt->save();
- ctxt->setCompositeOperation(op);
- QPainter* painter(ctxt->platformContext());
- painter->drawPixmap(dst, m_pixmap, src);
- ctxt->restore();
-}
-
-}
diff --git a/WebCore/platform/graphics/qt/StillImageQt.h b/WebCore/platform/graphics/qt/StillImageQt.h
deleted file mode 100644
index 37b8b2c..0000000
--- a/WebCore/platform/graphics/qt/StillImageQt.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2008 Holger Hans Peter Freyther
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef StillImageQt_h
-#define StillImageQt_h
-
-#include "Image.h"
-
-namespace WebCore {
-
- class StillImage : public Image {
- public:
- static PassRefPtr<StillImage> create(const QPixmap& pixmap)
- {
- return adoptRef(new StillImage(pixmap));
- }
-
- // FIXME: StillImages are underreporting decoded sizes and will be unable
- // to prune because these functions are not implemented yet.
- virtual void destroyDecodedData(bool incremental = false, bool preserveNearbyFrames = false) { }
- virtual unsigned decodedSize() const { return 0; }
-
- virtual IntSize size() const;
- virtual NativeImagePtr nativeImageForCurrentFrame();
- virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, CompositeOperator);
-
- private:
- StillImage(const QPixmap& pixmap);
-
- QPixmap m_pixmap;
- };
-
-}
-
-#endif
diff --git a/WebCore/platform/graphics/win/ColorSafari.cpp b/WebCore/platform/graphics/win/ColorSafari.cpp
deleted file mode 100644
index a04fd81..0000000
--- a/WebCore/platform/graphics/win/ColorSafari.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Color.h"
-
-#include "NotImplemented.h"
-#include <CoreGraphics/CGColor.h>
-#include <SafariTheme/SafariTheme.h>
-#include <wtf/Assertions.h>
-#include <wtf/RetainPtr.h>
-
-using namespace SafariTheme;
-
-namespace WebCore {
-
-typedef CGColorRef (APIENTRY*stCopyThemeColorPtr)(unsigned, SafariTheme::ThemeControlState);
-static const unsigned stFocusRingColorID = 4;
-
-static const unsigned aquaFocusRingColor = 0xFF7DADD9;
-
-static RGBA32 makeRGBAFromCGColor(CGColorRef c)
-{
- const CGFloat* components = CGColorGetComponents(c);
- return makeRGBA(255 * components[0], 255 * components[1], 255 * components[2], 255 * components[3]);
-}
-
-Color focusRingColor()
-{
- static Color focusRingColor;
- focusRingColor.isValid();
-
- if (!focusRingColor.isValid()) {
- if (HMODULE module = LoadLibrary(SAFARITHEMEDLL))
- if (stCopyThemeColorPtr stCopyThemeColor = (stCopyThemeColorPtr)GetProcAddress(module, "STCopyThemeColor")) {
- RetainPtr<CGColorRef> c(AdoptCF, stCopyThemeColor(stFocusRingColorID, SafariTheme::ActiveState));
- focusRingColor = makeRGBAFromCGColor(c.get());
- }
- if (!focusRingColor.isValid())
- focusRingColor = aquaFocusRingColor;
- }
-
- return focusRingColor;
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/graphics/win/FontCGWin.cpp b/WebCore/platform/graphics/win/FontCGWin.cpp
deleted file mode 100644
index 1766cd9..0000000
--- a/WebCore/platform/graphics/win/FontCGWin.cpp
+++ /dev/null
@@ -1,361 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Font.h"
-
-#include "AffineTransform.h"
-#include "FloatConversion.h"
-#include "GlyphBuffer.h"
-#include "GraphicsContext.h"
-#include "IntRect.h"
-#include "SimpleFontData.h"
-#include "UniscribeController.h"
-#include "WebCoreTextRenderer.h"
-#include <ApplicationServices/ApplicationServices.h>
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
-#include <wtf/MathExtras.h>
-
-namespace WebCore {
-
-const int syntheticObliqueAngle = 14;
-
-static inline CGFloat toCGFloat(FIXED f)
-{
- return f.value + f.fract / CGFloat(65536.0);
-}
-
-static CGPathRef createPathForGlyph(HDC hdc, Glyph glyph)
-{
- CGMutablePathRef path = CGPathCreateMutable();
-
- static const MAT2 identity = { 0, 1, 0, 0, 0, 0, 0, 1 };
- GLYPHMETRICS glyphMetrics;
- // GGO_NATIVE matches the outline perfectly when Windows font smoothing is off.
- // GGO_NATIVE | GGO_UNHINTED does not match perfectly either when Windows font smoothing is on or off.
- DWORD outlineLength = GetGlyphOutline(hdc, glyph, GGO_GLYPH_INDEX | GGO_NATIVE, &glyphMetrics, 0, 0, &identity);
- ASSERT(outlineLength >= 0);
- if (outlineLength < 0)
- return path;
-
- Vector<UInt8> outline(outlineLength);
- GetGlyphOutline(hdc, glyph, GGO_GLYPH_INDEX | GGO_NATIVE, &glyphMetrics, outlineLength, outline.data(), &identity);
-
- unsigned offset = 0;
- while (offset < outlineLength) {
- LPTTPOLYGONHEADER subpath = reinterpret_cast<LPTTPOLYGONHEADER>(outline.data() + offset);
- ASSERT(subpath->dwType == TT_POLYGON_TYPE);
- if (subpath->dwType != TT_POLYGON_TYPE)
- return path;
-
- CGPathMoveToPoint(path, 0, toCGFloat(subpath->pfxStart.x), toCGFloat(subpath->pfxStart.y));
-
- unsigned subpathOffset = sizeof(*subpath);
- while (subpathOffset < subpath->cb) {
- LPTTPOLYCURVE segment = reinterpret_cast<LPTTPOLYCURVE>(reinterpret_cast<UInt8*>(subpath) + subpathOffset);
- switch (segment->wType) {
- case TT_PRIM_LINE:
- for (unsigned i = 0; i < segment->cpfx; i++)
- CGPathAddLineToPoint(path, 0, toCGFloat(segment->apfx[i].x), toCGFloat(segment->apfx[i].y));
- break;
-
- case TT_PRIM_QSPLINE:
- for (unsigned i = 0; i < segment->cpfx; i++) {
- CGFloat x = toCGFloat(segment->apfx[i].x);
- CGFloat y = toCGFloat(segment->apfx[i].y);
- CGFloat cpx;
- CGFloat cpy;
-
- if (i == segment->cpfx - 2) {
- cpx = toCGFloat(segment->apfx[i + 1].x);
- cpy = toCGFloat(segment->apfx[i + 1].y);
- i++;
- } else {
- cpx = (toCGFloat(segment->apfx[i].x) + toCGFloat(segment->apfx[i + 1].x)) / 2;
- cpy = (toCGFloat(segment->apfx[i].y) + toCGFloat(segment->apfx[i + 1].y)) / 2;
- }
-
- CGPathAddQuadCurveToPoint(path, 0, x, y, cpx, cpy);
- }
- break;
-
- case TT_PRIM_CSPLINE:
- for (unsigned i = 0; i < segment->cpfx; i += 3) {
- CGFloat cp1x = toCGFloat(segment->apfx[i].x);
- CGFloat cp1y = toCGFloat(segment->apfx[i].y);
- CGFloat cp2x = toCGFloat(segment->apfx[i + 1].x);
- CGFloat cp2y = toCGFloat(segment->apfx[i + 1].y);
- CGFloat x = toCGFloat(segment->apfx[i + 2].x);
- CGFloat y = toCGFloat(segment->apfx[i + 2].y);
-
- CGPathAddCurveToPoint(path, 0, cp1x, cp1y, cp2x, cp2y, x, y);
- }
- break;
-
- default:
- ASSERT_NOT_REACHED();
- return path;
- }
-
- subpathOffset += sizeof(*segment) + (segment->cpfx - 1) * sizeof(segment->apfx[0]);
- }
- CGPathCloseSubpath(path);
- offset += subpath->cb;
- }
- return path;
-}
-
-static void drawGDIGlyphs(GraphicsContext* graphicsContext, const SimpleFontData* font, const GlyphBuffer& glyphBuffer,
- int from, int numGlyphs, const FloatPoint& point)
-{
- Color fillColor = graphicsContext->fillColor();
-
- bool drawIntoBitmap = false;
- int drawingMode = graphicsContext->textDrawingMode();
- if (drawingMode == cTextFill) {
- if (!fillColor.alpha())
- return;
-
- drawIntoBitmap = fillColor.alpha() != 255 || graphicsContext->inTransparencyLayer();
- if (!drawIntoBitmap) {
- IntSize size;
- int blur;
- Color color;
- graphicsContext->getShadow(size, blur, color);
- drawIntoBitmap = !size.isEmpty() || blur;
- }
- }
-
- // We have to convert CG's two-dimensional floating point advances to just horizontal integer advances.
- Vector<int, 2048> gdiAdvances;
- int totalWidth = 0;
- for (int i = 0; i < numGlyphs; i++) {
- gdiAdvances.append(lroundf(glyphBuffer.advanceAt(from + i)));
- totalWidth += gdiAdvances[i];
- }
-
- HDC hdc = 0;
- OwnPtr<GraphicsContext::WindowsBitmap> bitmap;
- IntRect textRect;
- if (!drawIntoBitmap)
- hdc = graphicsContext->getWindowsContext(textRect, true, false);
- if (!hdc) {
- drawIntoBitmap = true;
- // We put slop into this rect, since glyphs can overflow the ascent/descent bounds and the left/right edges.
- // FIXME: Can get glyphs' optical bounds (even from CG) to get this right.
- int lineGap = font->lineGap();
- textRect = IntRect(point.x() - (font->ascent() + font->descent()) / 2, point.y() - font->ascent() - lineGap, totalWidth + font->ascent() + font->descent(), font->lineSpacing());
- bitmap.set(graphicsContext->createWindowsBitmap(textRect.size()));
- memset(bitmap->buffer(), 255, bitmap->bufferLength());
- hdc = bitmap->hdc();
-
- XFORM xform;
- xform.eM11 = 1.0f;
- xform.eM12 = 0.0f;
- xform.eM21 = 0.0f;
- xform.eM22 = 1.0f;
- xform.eDx = -textRect.x();
- xform.eDy = -textRect.y();
- SetWorldTransform(hdc, &xform);
- }
-
- SelectObject(hdc, font->m_font.hfont());
-
- // Set the correct color.
- if (drawIntoBitmap)
- SetTextColor(hdc, RGB(0, 0, 0));
- else
- SetTextColor(hdc, RGB(fillColor.red(), fillColor.green(), fillColor.blue()));
-
- SetBkMode(hdc, TRANSPARENT);
- SetTextAlign(hdc, TA_LEFT | TA_BASELINE);
-
- // Uniscribe gives us offsets to help refine the positioning of combining glyphs.
- FloatSize translation = glyphBuffer.offsetAt(from);
- if (translation.width() || translation.height()) {
- XFORM xform;
- xform.eM11 = 1.0;
- xform.eM12 = 0;
- xform.eM21 = 0;
- xform.eM22 = 1.0;
- xform.eDx = translation.width();
- xform.eDy = translation.height();
- ModifyWorldTransform(hdc, &xform, MWT_LEFTMULTIPLY);
- }
-
- if (drawingMode == cTextFill) {
- XFORM xform;
- xform.eM11 = 1.0;
- xform.eM12 = 0;
- xform.eM21 = font->platformData().syntheticOblique() ? -tanf(syntheticObliqueAngle * piFloat / 180.0f) : 0;
- xform.eM22 = 1.0;
- xform.eDx = point.x();
- xform.eDy = point.y();
- ModifyWorldTransform(hdc, &xform, MWT_LEFTMULTIPLY);
- ExtTextOut(hdc, 0, 0, ETO_GLYPH_INDEX, 0, reinterpret_cast<const WCHAR*>(glyphBuffer.glyphs(from)), numGlyphs, gdiAdvances.data());
- if (font->m_syntheticBoldOffset) {
- xform.eM21 = 0;
- xform.eDx = font->m_syntheticBoldOffset;
- xform.eDy = 0;
- ModifyWorldTransform(hdc, &xform, MWT_LEFTMULTIPLY);
- ExtTextOut(hdc, 0, 0, ETO_GLYPH_INDEX, 0, reinterpret_cast<const WCHAR*>(glyphBuffer.glyphs(from)), numGlyphs, gdiAdvances.data());
- }
- } else {
- RetainPtr<CGMutablePathRef> path(AdoptCF, CGPathCreateMutable());
-
- XFORM xform;
- GetWorldTransform(hdc, &xform);
- AffineTransform hdcTransform(xform.eM11, xform.eM21, xform.eM12, xform.eM22, xform.eDx, xform.eDy);
- CGAffineTransform initialGlyphTransform = hdcTransform.isInvertible() ? hdcTransform.inverse() : CGAffineTransformIdentity;
- if (font->platformData().syntheticOblique())
- initialGlyphTransform = CGAffineTransformConcat(initialGlyphTransform, CGAffineTransformMake(1, 0, tanf(syntheticObliqueAngle * piFloat / 180.0f), 1, 0, 0));
- initialGlyphTransform.tx = 0;
- initialGlyphTransform.ty = 0;
- CGAffineTransform glyphTranslation = CGAffineTransformIdentity;
-
- for (unsigned i = 0; i < numGlyphs; ++i) {
- RetainPtr<CGPathRef> glyphPath(AdoptCF, createPathForGlyph(hdc, glyphBuffer.glyphAt(from + i)));
- CGAffineTransform glyphTransform = CGAffineTransformConcat(initialGlyphTransform, glyphTranslation);
- CGPathAddPath(path.get(), &glyphTransform, glyphPath.get());
- glyphTranslation = CGAffineTransformTranslate(glyphTranslation, gdiAdvances[i], 0);
- }
-
- CGContextRef cgContext = graphicsContext->platformContext();
- CGContextSaveGState(cgContext);
-
- BOOL fontSmoothingEnabled = false;
- SystemParametersInfo(SPI_GETFONTSMOOTHING, 0, &fontSmoothingEnabled, 0);
- CGContextSetShouldAntialias(cgContext, fontSmoothingEnabled);
-
- CGContextScaleCTM(cgContext, 1.0, -1.0);
- CGContextTranslateCTM(cgContext, point.x() + glyphBuffer.offsetAt(from).width(), -(point.y() + glyphBuffer.offsetAt(from).height()));
-
- if (drawingMode & cTextFill) {
- CGContextAddPath(cgContext, path.get());
- CGContextFillPath(cgContext);
- if (font->m_syntheticBoldOffset) {
- CGContextTranslateCTM(cgContext, font->m_syntheticBoldOffset, 0);
- CGContextAddPath(cgContext, path.get());
- CGContextFillPath(cgContext);
- CGContextTranslateCTM(cgContext, -font->m_syntheticBoldOffset, 0);
- }
- }
- if (drawingMode & cTextStroke) {
- CGContextAddPath(cgContext, path.get());
- CGContextStrokePath(cgContext);
- if (font->m_syntheticBoldOffset) {
- CGContextTranslateCTM(cgContext, font->m_syntheticBoldOffset, 0);
- CGContextAddPath(cgContext, path.get());
- CGContextStrokePath(cgContext);
- CGContextTranslateCTM(cgContext, -font->m_syntheticBoldOffset, 0);
- }
- }
- CGContextRestoreGState(cgContext);
- }
-
- if (drawIntoBitmap) {
- UInt8* buffer = bitmap->buffer();
- unsigned bufferLength = bitmap->bufferLength();
- for (unsigned i = 0; i < bufferLength; i += 4) {
- // Use green, which is always in the middle.
- UInt8 alpha = (255 - buffer[i + 1]) * fillColor.alpha() / 255;
- buffer[i] = fillColor.blue();
- buffer[i + 1] = fillColor.green();
- buffer[i + 2] = fillColor.red();
- buffer[i + 3] = alpha;
- }
- graphicsContext->drawWindowsBitmap(bitmap.get(), textRect.topLeft());
- } else
- graphicsContext->releaseWindowsContext(hdc, textRect, true, false);
-}
-
-void Font::drawGlyphs(GraphicsContext* graphicsContext, const SimpleFontData* font, const GlyphBuffer& glyphBuffer,
- int from, int numGlyphs, const FloatPoint& point) const
-{
- if (font->m_font.useGDI()) {
- drawGDIGlyphs(graphicsContext, font, glyphBuffer, from, numGlyphs, point);
- return;
- }
-
- CGContextRef cgContext = graphicsContext->platformContext();
-
- uint32_t oldFontSmoothingStyle = wkSetFontSmoothingStyle(cgContext, WebCoreShouldUseFontSmoothing());
-
- const FontPlatformData& platformData = font->platformData();
-
- CGContextSetFont(cgContext, platformData.cgFont());
-
- CGAffineTransform matrix = CGAffineTransformIdentity;
- matrix.b = -matrix.b;
- matrix.d = -matrix.d;
-
- if (platformData.syntheticOblique()) {
- static float skew = -tanf(syntheticObliqueAngle * piFloat / 180.0f);
- matrix = CGAffineTransformConcat(matrix, CGAffineTransformMake(1, 0, skew, 1, 0, 0));
- }
-
- CGContextSetTextMatrix(cgContext, matrix);
-
- // Uniscribe gives us offsets to help refine the positioning of combining glyphs.
- FloatSize translation = glyphBuffer.offsetAt(from);
-
- CGContextSetFontSize(cgContext, platformData.size());
- wkSetCGContextFontRenderingStyle(cgContext, font->isSystemFont(), false);
-
- IntSize shadowSize;
- int shadowBlur;
- Color shadowColor;
- graphicsContext->getShadow(shadowSize, shadowBlur, shadowColor);
-
- bool hasSimpleShadow = graphicsContext->textDrawingMode() == cTextFill && shadowColor.isValid() && !shadowBlur;
- if (hasSimpleShadow) {
- // Paint simple shadows ourselves instead of relying on CG shadows, to avoid losing subpixel antialiasing.
- graphicsContext->clearShadow();
- Color fillColor = graphicsContext->fillColor();
- Color shadowFillColor(shadowColor.red(), shadowColor.green(), shadowColor.blue(), shadowColor.alpha() * fillColor.alpha() / 255);
- graphicsContext->setFillColor(shadowFillColor);
- CGContextSetTextPosition(cgContext, point.x() + translation.width() + shadowSize.width(), point.y() + translation.height() + shadowSize.height());
- CGContextShowGlyphsWithAdvances(cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs);
- if (font->m_syntheticBoldOffset) {
- CGContextSetTextPosition(cgContext, point.x() + translation.width() + shadowSize.width() + font->m_syntheticBoldOffset, point.y() + translation.height() + shadowSize.height());
- CGContextShowGlyphsWithAdvances(cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs);
- }
- graphicsContext->setFillColor(fillColor);
- }
-
- CGContextSetTextPosition(cgContext, point.x() + translation.width(), point.y() + translation.height());
- CGContextShowGlyphsWithAdvances(cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs);
- if (font->m_syntheticBoldOffset) {
- CGContextSetTextPosition(cgContext, point.x() + translation.width() + font->m_syntheticBoldOffset, point.y() + translation.height());
- CGContextShowGlyphsWithAdvances(cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs);
- }
-
- if (hasSimpleShadow)
- graphicsContext->setShadow(shadowSize, shadowBlur, shadowColor);
-
- wkRestoreFontSmoothingStyle(cgContext, oldFontSmoothingStyle);
-}
-
-}
diff --git a/WebCore/platform/graphics/win/FontCacheWin.cpp b/WebCore/platform/graphics/win/FontCacheWin.cpp
deleted file mode 100644
index 49b3d76..0000000
--- a/WebCore/platform/graphics/win/FontCacheWin.cpp
+++ /dev/null
@@ -1,525 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include <winsock2.h>
-#include "FontCache.h"
-#include "Font.h"
-#include "SimpleFontData.h"
-#include "StringHash.h"
-#include "UnicodeRange.h"
-#include <windows.h>
-#include <mlang.h>
-#if PLATFORM(CG)
-#include <ApplicationServices/ApplicationServices.h>
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
-#endif
-
-using std::min;
-
-namespace WebCore
-{
-
-void FontCache::platformInit()
-{
-#if PLATFORM(CG)
- wkSetUpFontCache(1536 * 1024 * 4); // This size matches Mac.
-#endif
-}
-
-IMLangFontLink2* FontCache::getFontLinkInterface()
-{
- static IMultiLanguage *multiLanguage;
- if (!multiLanguage) {
- if (CoCreateInstance(CLSID_CMultiLanguage, 0, CLSCTX_ALL, IID_IMultiLanguage, (void**)&multiLanguage) != S_OK)
- return 0;
- }
-
- static IMLangFontLink2* langFontLink;
- if (!langFontLink) {
- if (multiLanguage->QueryInterface(&langFontLink) != S_OK)
- return 0;
- }
-
- return langFontLink;
-}
-
-static int CALLBACK metaFileEnumProc(HDC hdc, HANDLETABLE* table, CONST ENHMETARECORD* record, int tableEntries, LPARAM logFont)
-{
- if (record->iType == EMR_EXTCREATEFONTINDIRECTW) {
- const EMREXTCREATEFONTINDIRECTW* createFontRecord = reinterpret_cast<const EMREXTCREATEFONTINDIRECTW*>(record);
- *reinterpret_cast<LOGFONT*>(logFont) = createFontRecord->elfw.elfLogFont;
- }
- return true;
-}
-
-static int CALLBACK linkedFontEnumProc(CONST LOGFONT* logFont, CONST TEXTMETRIC* metrics, DWORD fontType, LPARAM hfont)
-{
- *reinterpret_cast<HFONT*>(hfont) = CreateFontIndirect(logFont);
- return false;
-}
-
-static const Vector<String>* getLinkedFonts(String& family)
-{
- static HashMap<String, Vector<String>*> systemLinkMap;
- Vector<String>* result = systemLinkMap.get(family);
- if (result)
- return result;
-
- result = new Vector<String>;
- systemLinkMap.set(family, result);
- HKEY fontLinkKey;
- if (FAILED(RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows NT\\CurrentVersion\\FontLink\\SystemLink", 0, KEY_READ, &fontLinkKey)))
- return result;
-
- DWORD linkedFontsBufferSize = 0;
- RegQueryValueEx(fontLinkKey, family.charactersWithNullTermination(), 0, NULL, NULL, &linkedFontsBufferSize);
- WCHAR* linkedFonts = reinterpret_cast<WCHAR*>(malloc(linkedFontsBufferSize));
- if (SUCCEEDED(RegQueryValueEx(fontLinkKey, family.charactersWithNullTermination(), 0, NULL, reinterpret_cast<BYTE*>(linkedFonts), &linkedFontsBufferSize))) {
- unsigned i = 0;
- unsigned length = linkedFontsBufferSize / sizeof(*linkedFonts);
- while (i < length) {
- while (i < length && linkedFonts[i] != ',')
- i++;
- i++;
- unsigned j = i;
- while (j < length && linkedFonts[j])
- j++;
- result->append(String(linkedFonts + i, j - i));
- i = j + 1;
- }
- }
- free(linkedFonts);
- RegCloseKey(fontLinkKey);
- return result;
-}
-
-static const Vector<DWORD, 4>& getCJKCodePageMasks()
-{
- // The default order in which we look for a font for a CJK character. If the user's default code page is
- // one of these, we will use it first.
- static const UINT CJKCodePages[] = {
- 932, /* Japanese */
- 936, /* Simplified Chinese */
- 950, /* Traditional Chinese */
- 949 /* Korean */
- };
-
- static Vector<DWORD, 4> codePageMasks;
- static bool initialized;
- if (!initialized) {
- initialized = true;
- IMLangFontLink2* langFontLink = FontCache::getFontLinkInterface();
- if (!langFontLink)
- return codePageMasks;
-
- UINT defaultCodePage;
- DWORD defaultCodePageMask = 0;
- if (GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_RETURN_NUMBER | LOCALE_IDEFAULTANSICODEPAGE, reinterpret_cast<LPWSTR>(&defaultCodePage), sizeof(defaultCodePage)))
- langFontLink->CodePageToCodePages(defaultCodePage, &defaultCodePageMask);
-
- if (defaultCodePage == CJKCodePages[0] || defaultCodePage == CJKCodePages[1] || defaultCodePage == CJKCodePages[2] || defaultCodePage == CJKCodePages[3])
- codePageMasks.append(defaultCodePageMask);
- for (unsigned i = 0; i < 4; ++i) {
- if (defaultCodePage != CJKCodePages[i]) {
- DWORD codePageMask;
- langFontLink->CodePageToCodePages(CJKCodePages[i], &codePageMask);
- codePageMasks.append(codePageMask);
- }
- }
- }
- return codePageMasks;
-}
-
-static bool currentFontContainsCharacter(HDC hdc, UChar character)
-{
- static Vector<char, 512> glyphsetBuffer;
- glyphsetBuffer.resize(GetFontUnicodeRanges(hdc, 0));
- GLYPHSET* glyphset = reinterpret_cast<GLYPHSET*>(glyphsetBuffer.data());
- GetFontUnicodeRanges(hdc, glyphset);
-
- // FIXME: Change this to a binary search.
- unsigned i = 0;
- while (i < glyphset->cRanges && glyphset->ranges[i].wcLow <= character)
- i++;
-
- return i && glyphset->ranges[i - 1].wcLow + glyphset->ranges[i - 1].cGlyphs > character;
-}
-
-static HFONT createMLangFont(IMLangFontLink2* langFontLink, HDC hdc, DWORD codePageMask, UChar character = 0)
-{
- HFONT MLangFont;
- HFONT hfont = 0;
- if (SUCCEEDED(langFontLink->MapFont(hdc, codePageMask, character, &MLangFont)) && MLangFont) {
- LOGFONT lf;
- GetObject(MLangFont, sizeof(LOGFONT), &lf);
- langFontLink->ReleaseFont(MLangFont);
- hfont = CreateFontIndirect(&lf);
- }
- return hfont;
-}
-
-const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
-{
- UChar character = characters[0];
- SimpleFontData* fontData = 0;
- HDC hdc = GetDC(0);
- HFONT primaryFont = font.primaryFont()->fontDataForCharacter(character)->platformData().hfont();
- HGDIOBJ oldFont = SelectObject(hdc, primaryFont);
- HFONT hfont = 0;
-
- if (IMLangFontLink2* langFontLink = getFontLinkInterface()) {
- // Try MLang font linking first.
- DWORD codePages = 0;
- langFontLink->GetCharCodePages(character, &codePages);
-
- if (codePages && findCharUnicodeRange(character) == cRangeSetCJK) {
- // The CJK character may belong to multiple code pages. We want to
- // do font linking against a single one of them, preferring the default
- // code page for the user's locale.
- const Vector<DWORD, 4>& CJKCodePageMasks = getCJKCodePageMasks();
- unsigned numCodePages = CJKCodePageMasks.size();
- for (unsigned i = 0; i < numCodePages && !hfont; ++i) {
- hfont = createMLangFont(langFontLink, hdc, CJKCodePageMasks[i]);
- if (hfont && !(codePages & CJKCodePageMasks[i])) {
- // We asked about a code page that is not one of the code pages
- // returned by MLang, so the font might not contain the character.
- SelectObject(hdc, hfont);
- if (!currentFontContainsCharacter(hdc, character)) {
- DeleteObject(hfont);
- hfont = 0;
- }
- SelectObject(hdc, primaryFont);
- }
- }
- } else
- hfont = createMLangFont(langFontLink, hdc, codePages, character);
- }
-
- // A font returned from MLang is trusted to contain the character.
- bool containsCharacter = hfont;
-
- if (!hfont) {
- // To find out what font Uniscribe would use, we make it draw into a metafile and intercept
- // calls to CreateFontIndirect().
- HDC metaFileDc = CreateEnhMetaFile(hdc, NULL, NULL, NULL);
- SelectObject(metaFileDc, primaryFont);
-
- bool scriptStringOutSucceeded = false;
- SCRIPT_STRING_ANALYSIS ssa;
-
- // FIXME: If length is greater than 1, we actually return the font for the last character.
- // This function should be renamed getFontDataForCharacter and take a single 32-bit character.
- if (SUCCEEDED(ScriptStringAnalyse(metaFileDc, characters, length, 0, -1, SSA_METAFILE | SSA_FALLBACK | SSA_GLYPHS | SSA_LINK,
- 0, NULL, NULL, NULL, NULL, NULL, &ssa))) {
- scriptStringOutSucceeded = SUCCEEDED(ScriptStringOut(ssa, 0, 0, 0, NULL, 0, 0, FALSE));
- ScriptStringFree(&ssa);
- }
- HENHMETAFILE metaFile = CloseEnhMetaFile(metaFileDc);
- if (scriptStringOutSucceeded) {
- LOGFONT logFont;
- logFont.lfFaceName[0] = 0;
- EnumEnhMetaFile(0, metaFile, metaFileEnumProc, &logFont, NULL);
- if (logFont.lfFaceName[0])
- hfont = CreateFontIndirect(&logFont);
- }
- DeleteEnhMetaFile(metaFile);
- }
-
- String familyName;
- const Vector<String>* linkedFonts = 0;
- unsigned linkedFontIndex = 0;
- while (hfont) {
- SelectObject(hdc, hfont);
- WCHAR name[LF_FACESIZE];
- GetTextFace(hdc, LF_FACESIZE, name);
- familyName = name;
-
- if (containsCharacter || currentFontContainsCharacter(hdc, character))
- break;
-
- if (!linkedFonts)
- linkedFonts = getLinkedFonts(familyName);
- SelectObject(hdc, oldFont);
- DeleteObject(hfont);
- hfont = 0;
-
- if (linkedFonts->size() <= linkedFontIndex)
- break;
-
- LOGFONT logFont;
- logFont.lfCharSet = DEFAULT_CHARSET;
- memcpy(logFont.lfFaceName, linkedFonts->at(linkedFontIndex).characters(), linkedFonts->at(linkedFontIndex).length() * sizeof(WCHAR));
- logFont.lfFaceName[linkedFonts->at(linkedFontIndex).length()] = 0;
- EnumFontFamiliesEx(hdc, &logFont, linkedFontEnumProc, reinterpret_cast<LPARAM>(&hfont), 0);
- linkedFontIndex++;
- }
-
- if (hfont) {
- if (!familyName.isEmpty()) {
- FontPlatformData* result = getCachedFontPlatformData(font.fontDescription(), familyName);
- if (result)
- fontData = getCachedFontData(result);
- }
-
- SelectObject(hdc, oldFont);
- DeleteObject(hfont);
- }
-
- ReleaseDC(0, hdc);
- return fontData;
-}
-
-FontPlatformData* FontCache::getSimilarFontPlatformData(const Font& font)
-{
- return 0;
-}
-
-FontPlatformData* FontCache::getLastResortFallbackFont(const FontDescription& fontDescription)
-{
- // FIXME: Would be even better to somehow get the user's default font here. For now we'll pick
- // the default that the user would get without changing any prefs.
- static AtomicString timesStr("Times New Roman");
- return getCachedFontPlatformData(fontDescription, timesStr);
-}
-
-static LONG toGDIFontWeight(FontWeight fontWeight)
-{
- static LONG gdiFontWeights[] = {
- FW_THIN, // FontWeight100
- FW_EXTRALIGHT, // FontWeight200
- FW_LIGHT, // FontWeight300
- FW_NORMAL, // FontWeight400
- FW_MEDIUM, // FontWeight500
- FW_SEMIBOLD, // FontWeight600
- FW_BOLD, // FontWeight700
- FW_EXTRABOLD, // FontWeight800
- FW_HEAVY // FontWeight900
- };
- return gdiFontWeights[fontWeight];
-}
-
-static inline bool isGDIFontWeightBold(LONG gdiFontWeight)
-{
- return gdiFontWeight >= FW_SEMIBOLD;
-}
-
-static LONG adjustedGDIFontWeight(LONG gdiFontWeight, const String& family)
-{
- static AtomicString lucidaStr("Lucida Grande");
- if (equalIgnoringCase(family, lucidaStr)) {
- if (gdiFontWeight == FW_NORMAL)
- return FW_MEDIUM;
- if (gdiFontWeight == FW_BOLD)
- return FW_SEMIBOLD;
- }
- return gdiFontWeight;
-}
-
-struct MatchImprovingProcData {
- MatchImprovingProcData(LONG desiredWeight, bool desiredItalic)
- : m_desiredWeight(desiredWeight)
- , m_desiredItalic(desiredItalic)
- , m_hasMatched(false)
- {
- }
-
- LONG m_desiredWeight;
- bool m_desiredItalic;
- bool m_hasMatched;
- LOGFONT m_chosen;
-};
-
-static int CALLBACK matchImprovingEnumProc(CONST LOGFONT* candidate, CONST TEXTMETRIC* metrics, DWORD fontType, LPARAM lParam)
-{
- MatchImprovingProcData* matchData = reinterpret_cast<MatchImprovingProcData*>(lParam);
-
- if (!matchData->m_hasMatched) {
- matchData->m_hasMatched = true;
- matchData->m_chosen = *candidate;
- return 1;
- }
-
- if (!candidate->lfItalic != !matchData->m_chosen.lfItalic) {
- if (!candidate->lfItalic == !matchData->m_desiredItalic)
- matchData->m_chosen = *candidate;
-
- return 1;
- }
-
- unsigned chosenWeightDeltaMagnitude = abs(matchData->m_chosen.lfWeight - matchData->m_desiredWeight);
- unsigned candidateWeightDeltaMagnitude = abs(candidate->lfWeight - matchData->m_desiredWeight);
-
- // If both are the same distance from the desired weight, prefer the candidate if it is further from regular.
- if (chosenWeightDeltaMagnitude == candidateWeightDeltaMagnitude && abs(candidate->lfWeight - FW_NORMAL) > abs(matchData->m_chosen.lfWeight - FW_NORMAL)) {
- matchData->m_chosen = *candidate;
- return 1;
- }
-
- // Otherwise, prefer the one closer to the desired weight.
- if (candidateWeightDeltaMagnitude < chosenWeightDeltaMagnitude)
- matchData->m_chosen = *candidate;
-
- return 1;
-}
-
-static HFONT createGDIFont(const AtomicString& family, LONG desiredWeight, bool desiredItalic, int size)
-{
- HDC hdc = GetDC(0);
-
- LOGFONT logFont;
- logFont.lfCharSet = DEFAULT_CHARSET;
- unsigned familyLength = min(family.length(), static_cast<unsigned>(LF_FACESIZE - 1));
- memcpy(logFont.lfFaceName, family.characters(), familyLength * sizeof(UChar));
- logFont.lfFaceName[familyLength] = 0;
- logFont.lfPitchAndFamily = 0;
-
- MatchImprovingProcData matchData(desiredWeight, desiredItalic);
- EnumFontFamiliesEx(hdc, &logFont, matchImprovingEnumProc, reinterpret_cast<LPARAM>(&matchData), 0);
-
- ReleaseDC(0, hdc);
-
- if (!matchData.m_hasMatched)
- return 0;
-
- matchData.m_chosen.lfHeight = -size;
- matchData.m_chosen.lfWidth = 0;
- matchData.m_chosen.lfEscapement = 0;
- matchData.m_chosen.lfOrientation = 0;
- matchData.m_chosen.lfUnderline = false;
- matchData.m_chosen.lfStrikeOut = false;
- matchData.m_chosen.lfCharSet = DEFAULT_CHARSET;
-#if PLATFORM(CG) || PLATFORM(CAIRO)
- matchData.m_chosen.lfOutPrecision = OUT_TT_ONLY_PRECIS;
-#else
- matchData.m_chosen.lfOutPrecision = OUT_TT_PRECIS;
-#endif
- matchData.m_chosen.lfQuality = DEFAULT_QUALITY;
- matchData.m_chosen.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
-
- return CreateFontIndirect(&matchData.m_chosen);
-}
-
-struct TraitsInFamilyProcData {
- TraitsInFamilyProcData(const AtomicString& familyName)
- : m_familyName(familyName)
- {
- }
-
- const AtomicString& m_familyName;
- HashSet<unsigned> m_traitsMasks;
-};
-
-static int CALLBACK traitsInFamilyEnumProc(CONST LOGFONT* logFont, CONST TEXTMETRIC* metrics, DWORD fontType, LPARAM lParam)
-{
- TraitsInFamilyProcData* procData = reinterpret_cast<TraitsInFamilyProcData*>(lParam);
-
- unsigned traitsMask = 0;
- traitsMask |= logFont->lfItalic ? FontStyleItalicMask : FontStyleNormalMask;
- traitsMask |= FontVariantNormalMask;
- LONG weight = adjustedGDIFontWeight(logFont->lfWeight, procData->m_familyName);
- traitsMask |= weight == FW_THIN ? FontWeight100Mask :
- weight == FW_EXTRALIGHT ? FontWeight200Mask :
- weight == FW_LIGHT ? FontWeight300Mask :
- weight == FW_NORMAL ? FontWeight400Mask :
- weight == FW_MEDIUM ? FontWeight500Mask :
- weight == FW_SEMIBOLD ? FontWeight600Mask :
- weight == FW_BOLD ? FontWeight700Mask :
- weight == FW_EXTRABOLD ? FontWeight800Mask :
- FontWeight900Mask;
- procData->m_traitsMasks.add(traitsMask);
- return 1;
-}
-void FontCache::getTraitsInFamily(const AtomicString& familyName, Vector<unsigned>& traitsMasks)
-{
- HDC hdc = GetDC(0);
-
- LOGFONT logFont;
- logFont.lfCharSet = DEFAULT_CHARSET;
- unsigned familyLength = min(familyName.length(), static_cast<unsigned>(LF_FACESIZE - 1));
- memcpy(logFont.lfFaceName, familyName.characters(), familyLength * sizeof(UChar));
- logFont.lfFaceName[familyLength] = 0;
- logFont.lfPitchAndFamily = 0;
-
- TraitsInFamilyProcData procData(familyName);
- EnumFontFamiliesEx(hdc, &logFont, traitsInFamilyEnumProc, reinterpret_cast<LPARAM>(&procData), 0);
- copyToVector(procData.m_traitsMasks, traitsMasks);
-
- ReleaseDC(0, hdc);
-}
-
-FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
-{
- bool isLucidaGrande = false;
- static AtomicString lucidaStr("Lucida Grande");
- if (equalIgnoringCase(family, lucidaStr))
- isLucidaGrande = true;
-
- bool useGDI = fontDescription.renderingMode() == AlternateRenderingMode && !isLucidaGrande;
-
- // The logical size constant is 32. We do this for subpixel precision when rendering using Uniscribe.
- // This masks rounding errors related to the HFONT metrics being different from the CGFont metrics.
- // FIXME: We will eventually want subpixel precision for GDI mode, but the scaled rendering doesn't
- // look as nice. That may be solvable though.
- LONG weight = adjustedGDIFontWeight(toGDIFontWeight(fontDescription.weight()), family);
- HFONT hfont = createGDIFont(family, weight, fontDescription.italic(), fontDescription.computedPixelSize() * (useGDI ? 1 : 32));
-
- if (!hfont)
- return 0;
-
- if (isLucidaGrande)
- useGDI = false; // Never use GDI for Lucida Grande.
-
- LOGFONT logFont;
- GetObject(hfont, sizeof(LOGFONT), &logFont);
-
- bool synthesizeBold = isGDIFontWeightBold(weight) && !isGDIFontWeightBold(logFont.lfWeight);
- bool synthesizeItalic = fontDescription.italic() && !logFont.lfItalic;
-
- FontPlatformData* result = new FontPlatformData(hfont, fontDescription.computedPixelSize(), synthesizeBold, synthesizeItalic, useGDI);
-
-#if PLATFORM(CG)
- bool fontCreationFailed = !result->cgFont();
-#elif PLATFORM(CAIRO)
- bool fontCreationFailed = !result->fontFace();
-#endif
-
- if (fontCreationFailed) {
- // The creation of the CGFontRef failed for some reason. We already asserted in debug builds, but to make
- // absolutely sure that we don't use this font, go ahead and return 0 so that we can fall back to the next
- // font.
- delete result;
- DeleteObject(hfont);
- return 0;
- }
-
- return result;
-}
-
-}
-
diff --git a/WebCore/platform/graphics/win/FontCustomPlatformData.cpp b/WebCore/platform/graphics/win/FontCustomPlatformData.cpp
deleted file mode 100644
index 26fceba..0000000
--- a/WebCore/platform/graphics/win/FontCustomPlatformData.cpp
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "FontCustomPlatformData.h"
-
-#include "Base64.h"
-#include "FontPlatformData.h"
-#include "OpenTypeUtilities.h"
-#include "SharedBuffer.h"
-#include "SoftLinking.h"
-#include <ApplicationServices/ApplicationServices.h>
-#include <wtf/RetainPtr.h>
-
-// From t2embapi.h, which is missing from the Microsoft Platform SDK.
-typedef unsigned long(WINAPIV *READEMBEDPROC) (void*, void*, unsigned long);
-struct TTLOADINFO;
-#define TTLOAD_PRIVATE 0x00000001
-#define LICENSE_PREVIEWPRINT 0x0004
-#define E_NONE 0x0000L
-
-namespace WebCore {
-
-using namespace std;
-
-SOFT_LINK_LIBRARY(T2embed);
-SOFT_LINK(T2embed, TTLoadEmbeddedFont, LONG, __stdcall, (HANDLE* phFontReference, ULONG ulFlags, ULONG* pulPrivStatus, ULONG ulPrivs, ULONG* pulStatus, READEMBEDPROC lpfnReadFromStream, LPVOID lpvReadStream, LPWSTR szWinFamilyName, LPSTR szMacFamilyName, TTLOADINFO* pTTLoadInfo), (phFontReference, ulFlags,pulPrivStatus, ulPrivs, pulStatus, lpfnReadFromStream, lpvReadStream, szWinFamilyName, szMacFamilyName, pTTLoadInfo));
-SOFT_LINK(T2embed, TTGetNewFontName, LONG, __stdcall, (HANDLE* phFontReference, LPWSTR szWinFamilyName, long cchMaxWinName, LPSTR szMacFamilyName, long cchMaxMacName), (phFontReference, szWinFamilyName, cchMaxWinName, szMacFamilyName, cchMaxMacName));
-SOFT_LINK(T2embed, TTDeleteEmbeddedFont, LONG, __stdcall, (HANDLE hFontReference, ULONG ulFlags, ULONG* pulStatus), (hFontReference, ulFlags, pulStatus));
-
-FontCustomPlatformData::~FontCustomPlatformData()
-{
- CGFontRelease(m_cgFont);
- if (m_fontReference) {
- if (m_name.isNull()) {
- ASSERT(T2embedLibrary());
- ULONG status;
- TTDeleteEmbeddedFont(m_fontReference, 0, &status);
- } else
- RemoveFontMemResourceEx(m_fontReference);
- }
-}
-
-FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontRenderingMode renderingMode)
-{
- ASSERT(m_cgFont);
- ASSERT(m_fontReference);
- ASSERT(T2embedLibrary());
-
- LOGFONT logFont;
- if (m_name.isNull())
- TTGetNewFontName(&m_fontReference, logFont.lfFaceName, LF_FACESIZE, 0, 0);
- else
- memcpy(logFont.lfFaceName, m_name.charactersWithNullTermination(), sizeof(logFont.lfFaceName[0]) * min(static_cast<size_t>(LF_FACESIZE), 1 + m_name.length()));
-
- logFont.lfHeight = -size;
- if (renderingMode == NormalRenderingMode)
- logFont.lfHeight *= 32;
- logFont.lfWidth = 0;
- logFont.lfEscapement = 0;
- logFont.lfOrientation = 0;
- logFont.lfUnderline = false;
- logFont.lfStrikeOut = false;
- logFont.lfCharSet = DEFAULT_CHARSET;
- logFont.lfOutPrecision = OUT_TT_ONLY_PRECIS;
- logFont.lfQuality = CLEARTYPE_QUALITY;
- logFont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
- logFont.lfItalic = italic;
- logFont.lfWeight = bold ? 700 : 400;
-
- HFONT hfont = CreateFontIndirect(&logFont);
- return FontPlatformData(hfont, m_cgFont, size, bold, italic, renderingMode == AlternateRenderingMode);
-}
-
-const void* getData(void* info)
-{
- SharedBuffer* buffer = static_cast<SharedBuffer*>(info);
- buffer->ref();
- return (void*)buffer->data();
-}
-
-void releaseData(void* info, const void* data)
-{
- static_cast<SharedBuffer*>(info)->deref();
-}
-
-size_t getBytesWithOffset(void *info, void* buffer, size_t offset, size_t count)
-{
- SharedBuffer* sharedBuffer = static_cast<SharedBuffer*>(info);
- size_t availBytes = count;
- if (offset + count > sharedBuffer->size())
- availBytes -= (offset + count) - sharedBuffer->size();
- memcpy(buffer, sharedBuffer->data() + offset, availBytes);
- return availBytes;
-}
-
-// Streams the concatenation of a header and font data.
-class EOTStream {
-public:
- EOTStream(const Vector<UInt8, 512>& eotHeader, const SharedBuffer* fontData, size_t overlayDst, size_t overlaySrc, size_t overlayLength)
- : m_eotHeader(eotHeader)
- , m_fontData(fontData)
- , m_overlayDst(overlayDst)
- , m_overlaySrc(overlaySrc)
- , m_overlayLength(overlayLength)
- , m_offset(0)
- , m_inHeader(true)
- {
- }
-
- size_t read(void* buffer, size_t count);
-
-private:
- const Vector<UInt8, 512>& m_eotHeader;
- const SharedBuffer* m_fontData;
- size_t m_overlayDst;
- size_t m_overlaySrc;
- size_t m_overlayLength;
- size_t m_offset;
- bool m_inHeader;
-};
-
-size_t EOTStream::read(void* buffer, size_t count)
-{
- size_t bytesToRead = count;
- if (m_inHeader) {
- size_t bytesFromHeader = min(m_eotHeader.size() - m_offset, count);
- memcpy(buffer, m_eotHeader.data() + m_offset, bytesFromHeader);
- m_offset += bytesFromHeader;
- bytesToRead -= bytesFromHeader;
- if (m_offset == m_eotHeader.size()) {
- m_inHeader = false;
- m_offset = 0;
- }
- }
- if (bytesToRead && !m_inHeader) {
- size_t bytesFromData = min(m_fontData->size() - m_offset, bytesToRead);
- memcpy(buffer, m_fontData->data() + m_offset, bytesFromData);
- if (m_offset < m_overlayDst + m_overlayLength && m_offset + bytesFromData >= m_overlayDst) {
- size_t dstOffset = max<int>(m_overlayDst - m_offset, 0);
- size_t srcOffset = max<int>(0, m_offset - m_overlayDst);
- size_t bytesToCopy = min(bytesFromData - dstOffset, m_overlayLength - srcOffset);
- memcpy(reinterpret_cast<char*>(buffer) + dstOffset, m_fontData->data() + m_overlaySrc + srcOffset, bytesToCopy);
- }
- m_offset += bytesFromData;
- bytesToRead -= bytesFromData;
- }
- return count - bytesToRead;
-}
-
-static unsigned long WINAPIV readEmbedProc(void* stream, void* buffer, unsigned long length)
-{
- return static_cast<EOTStream*>(stream)->read(buffer, length);
-}
-
-// Creates a unique and unpredictable font name, in order to avoid collisions and to
-// not allow access from CSS.
-static String createUniqueFontName()
-{
- Vector<char> fontUuid(sizeof(GUID));
- CoCreateGuid(reinterpret_cast<GUID*>(fontUuid.data()));
-
- Vector<char> fontNameVector;
- base64Encode(fontUuid, fontNameVector);
- ASSERT(fontNameVector.size() < LF_FACESIZE);
- return String(fontNameVector.data(), fontNameVector.size());
-}
-
-FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer)
-{
- ASSERT_ARG(buffer, buffer);
- ASSERT(T2embedLibrary());
-
- // Get CG to create the font.
- CGDataProviderDirectAccessCallbacks callbacks = { &getData, &releaseData, &getBytesWithOffset, NULL };
- RetainPtr<CGDataProviderRef> dataProvider(AdoptCF, CGDataProviderCreateDirectAccess(buffer, buffer->size(), &callbacks));
- CGFontRef cgFont = CGFontCreateWithDataProvider(dataProvider.get());
- if (!cgFont)
- return 0;
-
- // Introduce the font to GDI. AddFontMemResourceEx cannot be used, because it will pollute the process's
- // font namespace (Windows has no API for creating an HFONT from data without exposing the font to the
- // entire process first). TTLoadEmbeddedFont lets us override the font family name, so using a unique name
- // we avoid namespace collisions.
-
- String fontName = createUniqueFontName();
-
- // TTLoadEmbeddedFont works only with Embedded OpenType (.eot) data, so we need to create an EOT header
- // and prepend it to the font data.
- Vector<UInt8, 512> eotHeader;
- size_t overlayDst;
- size_t overlaySrc;
- size_t overlayLength;
- if (!getEOTHeader(buffer, eotHeader, overlayDst, overlaySrc, overlayLength)) {
- CGFontRelease(cgFont);
- return 0;
- }
-
- HANDLE fontReference;
- ULONG privStatus;
- ULONG status;
- EOTStream eotStream(eotHeader, buffer, overlayDst, overlaySrc, overlayLength);
-
- LONG loadEmbeddedFontResult = TTLoadEmbeddedFont(&fontReference, TTLOAD_PRIVATE, &privStatus, LICENSE_PREVIEWPRINT, &status, readEmbedProc, &eotStream, const_cast<LPWSTR>(fontName.charactersWithNullTermination()), 0, 0);
- if (loadEmbeddedFontResult == E_NONE)
- fontName = String();
- else {
- fontReference = renameAndActivateFont(buffer, fontName);
- if (!fontReference) {
- CGFontRelease(cgFont);
- return 0;
- }
- }
-
- return new FontCustomPlatformData(cgFont, fontReference, fontName);
-}
-
-}
diff --git a/WebCore/platform/graphics/win/FontCustomPlatformData.h b/WebCore/platform/graphics/win/FontCustomPlatformData.h
deleted file mode 100644
index 34a9851..0000000
--- a/WebCore/platform/graphics/win/FontCustomPlatformData.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef FontCustomPlatformData_h
-#define FontCustomPlatformData_h
-
-#include "FontRenderingMode.h"
-#include "PlatformString.h"
-#include <wtf/Noncopyable.h>
-
-typedef struct CGFont* CGFontRef;
-
-namespace WebCore {
-
-class FontPlatformData;
-class SharedBuffer;
-
-struct FontCustomPlatformData : Noncopyable {
- FontCustomPlatformData(CGFontRef cgFont, HANDLE fontReference, const String& name)
- : m_cgFont(cgFont)
- , m_fontReference(fontReference)
- , m_name(name)
- {
- }
-
- ~FontCustomPlatformData();
-
- FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontRenderingMode = NormalRenderingMode);
-
- CGFontRef m_cgFont;
- HANDLE m_fontReference;
- String m_name;
-};
-
-FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer*);
-
-}
-
-#endif
diff --git a/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.cpp b/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.cpp
deleted file mode 100644
index e54d85a..0000000
--- a/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2007, 2008 Apple Computer, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "FontCustomPlatformDataCairo.h"
-
-#include "SharedBuffer.h"
-#include "FontPlatformData.h"
-#include <wtf/RetainPtr.h>
-
-namespace WebCore {
-
-FontCustomPlatformDataCairo::~FontCustomPlatformDataCairo()
-{
- cairo_font_face_destroy(m_fontFace);
-}
-
-FontPlatformData FontCustomPlatformDataCairo::fontPlatformData(int size, bool bold, bool italic)
-{
- return FontPlatformData(m_fontFace, size, bold, italic);
-}
-
-static void releaseData(void* data)
-{
- static_cast<SharedBuffer*>(data)->deref();
-}
-
-FontCustomPlatformDataCairo* createFontCustomPlatformData(SharedBuffer* buffer)
-{
- ASSERT_ARG(buffer, buffer);
-
- buffer->ref();
- HFONT font = reinterpret_cast<HFONT>(buffer);
- cairo_font_face_t* fontFace = cairo_win32_font_face_create_for_hfont(font);
- if (!fontFace)
- return 0;
-
- static cairo_user_data_key_t bufferKey;
- cairo_font_face_set_user_data(fontFace, &bufferKey, buffer, releaseData);
-
- return new FontCustomPlatformDataCairo(fontFace);
-}
-
-}
diff --git a/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.h b/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.h
deleted file mode 100644
index 87794b5..0000000
--- a/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Computer, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef FontCustomPlatformDataCairo_h
-#define FontCustomPlatformDataCairo_h
-
-#include <wtf/Noncopyable.h>
-
-#include <cairo.h>
-
-namespace WebCore {
-
-class FontPlatformData;
-class SharedBuffer;
-
-struct FontCustomPlatformDataCairo : Noncopyable {
- FontCustomPlatformDataCairo(cairo_font_face_t* fontFace)
- : m_fontFace(fontFace)
- {
- }
- ~FontCustomPlatformDataCairo();
-
- FontPlatformData fontPlatformData(int size, bool bold, bool italic);
-
- cairo_font_face_t* m_fontFace;
-};
-
-FontCustomPlatformDataCairo* createFontCustomPlatformData(SharedBuffer*);
-
-}
-
-#endif
diff --git a/WebCore/platform/graphics/win/FontDatabase.cpp b/WebCore/platform/graphics/win/FontDatabase.cpp
deleted file mode 100644
index 1308ff0..0000000
--- a/WebCore/platform/graphics/win/FontDatabase.cpp
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FontDatabase.h"
-
-#include "CString.h"
-#include "FileSystem.h"
-#include "PlatformString.h"
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
-#include <shlobj.h>
-#include <wtf/RetainPtr.h>
-
-namespace WebCore {
-
-static String systemFontsDirectory()
-{
- static bool initialized;
- static String directory;
-
- if (!initialized) {
- initialized = true;
-
- Vector<UChar> buffer(MAX_PATH);
- if (FAILED(SHGetFolderPath(0, CSIDL_FONTS | CSIDL_FLAG_CREATE, 0, 0, buffer.data())))
- return directory;
- buffer.resize(wcslen(buffer.data()));
-
- directory = String::adopt(buffer);
- }
-
- return directory;
-}
-
-static String fontsPlistPath()
-{
- static String path = pathByAppendingComponent(localUserSpecificStorageDirectory(), "FontsList.plist");
- return path;
-}
-
-static bool systemHasFontsNewerThanFontsPlist()
-{
- WIN32_FILE_ATTRIBUTE_DATA plistAttributes = {0};
- if (!GetFileAttributesEx(fontsPlistPath().charactersWithNullTermination(), GetFileExInfoStandard, &plistAttributes))
- return true;
-
- WIN32_FILE_ATTRIBUTE_DATA fontsDirectoryAttributes = {0};
- if (!GetFileAttributesEx(systemFontsDirectory().charactersWithNullTermination(), GetFileExInfoStandard, &fontsDirectoryAttributes))
- return true;
-
- return CompareFileTime(&plistAttributes.ftLastWriteTime, &fontsDirectoryAttributes.ftLastWriteTime) < 0;
-}
-
-static RetainPtr<CFPropertyListRef> readFontPlist()
-{
- CString plistPath = fontsPlistPath().utf8();
-
- RetainPtr<CFURLRef> url(AdoptCF, CFURLCreateFromFileSystemRepresentation(0, reinterpret_cast<const UInt8*>(plistPath.data()), plistPath.length(), false));
- if (!url)
- return 0;
-
- RetainPtr<CFReadStreamRef> stream(AdoptCF, CFReadStreamCreateWithFile(0, url.get()));
- if (!stream)
- return 0;
-
- if (!CFReadStreamOpen(stream.get()))
- return 0;
-
- CFPropertyListFormat format = kCFPropertyListBinaryFormat_v1_0 | kCFPropertyListXMLFormat_v1_0;
- RetainPtr<CFPropertyListRef> plist(AdoptCF, CFPropertyListCreateFromStream(0, stream.get(), 0, kCFPropertyListMutableContainersAndLeaves, &format, 0));
-
- CFReadStreamClose(stream.get());
-
- return plist;
-}
-
-static bool populateFontDatabaseFromPlist()
-{
- RetainPtr<CFPropertyListRef> plist = readFontPlist();
- if (!plist)
- return false;
-
- RetainPtr<CFDataRef> data(AdoptCF, CFPropertyListCreateXMLData(0, plist.get()));
- if (!data)
- return false;
-
- wkAddFontsFromPlistRepresentation(data.get());
- return true;
-}
-
-static bool populateFontDatabaseFromFileSystem()
-{
- RetainPtr<CFStringRef> directory(AdoptCF, systemFontsDirectory().createCFString());
- if (!directory)
- return false;
-
- wkAddFontsInDirectory(directory.get());
- return true;
-}
-
-static void writeFontDatabaseToPlist()
-{
- RetainPtr<CFDataRef> data(AdoptCF, wkCreateFontsPlistRepresentation());
- if (!data)
- return;
-
- safeCreateFile(fontsPlistPath(), data.get());
-}
-
-void populateFontDatabase()
-{
- static bool initialized;
- if (initialized)
- return;
- initialized = true;
-
- if (!systemHasFontsNewerThanFontsPlist())
- if (populateFontDatabaseFromPlist())
- return;
-
- if (populateFontDatabaseFromFileSystem())
- writeFontDatabaseToPlist();
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/graphics/win/FontDatabase.h b/WebCore/platform/graphics/win/FontDatabase.h
deleted file mode 100644
index 4f76c9e..0000000
--- a/WebCore/platform/graphics/win/FontDatabase.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef FontDatabase_h
-#define FontDatabase_h
-
-namespace WebCore {
-
- void populateFontDatabase();
-
-} // namespace WebCore
-
-#endif // !defined(FontDatabase_h)
diff --git a/WebCore/platform/graphics/win/FontPlatformData.h b/WebCore/platform/graphics/win/FontPlatformData.h
deleted file mode 100644
index d61afa8..0000000
--- a/WebCore/platform/graphics/win/FontPlatformData.h
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * This file is part of the internal font implementation. It should not be included by anyone other than
- * FontMac.cpp, FontWin.cpp and Font.cpp.
- *
- * Copyright (C) 2006, 2007, 2008 Apple Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef FontPlatformData_H
-#define FontPlatformData_H
-
-#include "StringImpl.h"
-#include <wtf/PassRefPtr.h>
-#include <wtf/RetainPtr.h>
-#include <wtf/RefCounted.h>
-
-#if PLATFORM(CAIRO)
-#include <cairo-win32.h>
-#endif
-
-typedef struct HFONT__* HFONT;
-typedef struct CGFont* CGFontRef;
-
-namespace WebCore {
-
-class FontDescription;
-
-class FontPlatformData {
-public:
- FontPlatformData()
-#if PLATFORM(CAIRO)
- : m_fontFace(0)
- ,
-#else
- :
-#endif
- m_size(0)
- , m_syntheticBold(false)
- , m_syntheticOblique(false)
- , m_useGDI(false)
- {
- }
-
- FontPlatformData(HFONT, float size, bool bold, bool oblique, bool useGDI);
- FontPlatformData(float size, bool bold, bool oblique);
-
-#if PLATFORM(CG)
- FontPlatformData(HFONT, CGFontRef, float size, bool bold, bool oblique, bool useGDI);
-#elif PLATFORM(CAIRO)
- FontPlatformData(cairo_font_face_t*, float size, bool bold, bool oblique);
-#endif
- ~FontPlatformData();
-
- FontPlatformData(WTF::HashTableDeletedValueType) : m_font(WTF::HashTableDeletedValue) { }
- bool isHashTableDeletedValue() const { return m_font.isHashTableDeletedValue(); }
-
- HFONT hfont() const { return m_font->hfont(); }
-#if PLATFORM(CG)
- CGFontRef cgFont() const { return m_cgFont.get(); }
-#elif PLATFORM(CAIRO)
- void setFont(cairo_t* ft) const;
- cairo_font_face_t* fontFace() const { return m_fontFace; }
- cairo_scaled_font_t* scaledFont() const { return m_scaledFont; }
-#endif
-
- float size() const { return m_size; }
- void setSize(float size) { m_size = size; }
- bool syntheticBold() const { return m_syntheticBold; }
- bool syntheticOblique() const { return m_syntheticOblique; }
- bool useGDI() const { return m_useGDI; }
-
- unsigned hash() const
- {
- return m_font->hash();
- }
-
- bool operator==(const FontPlatformData& other) const
- {
- return m_font == other.m_font &&
-#if PLATFORM(CG)
- m_cgFont == other.m_cgFont &&
-#elif PLATFORM(CAIRO)
- m_fontFace == other.m_fontFace &&
- m_scaledFont == other.m_scaledFont &&
-#endif
- m_size == other.m_size &&
- m_syntheticBold == other.m_syntheticBold && m_syntheticOblique == other.m_syntheticOblique &&
- m_useGDI == other.m_useGDI;
- }
-
-private:
- class RefCountedHFONT : public RefCounted<RefCountedHFONT> {
- public:
- static PassRefPtr<RefCountedHFONT> create(HFONT hfont) { return adoptRef(new RefCountedHFONT(hfont)); }
- static PassRefPtr<RefCountedHFONT> createDeleted() { return adoptRef(new RefCountedHFONT(reinterpret_cast<HFONT>(-1))); }
-
- ~RefCountedHFONT() { if (m_hfont != reinterpret_cast<HFONT>(-1)) DeleteObject(m_hfont); }
-
- HFONT hfont() const { return m_hfont; }
- unsigned hash() const
- {
- return StringImpl::computeHash(reinterpret_cast<const UChar*>(&m_hfont), sizeof(HFONT) / sizeof(UChar));
- }
-
- private:
- RefCountedHFONT(HFONT hfont)
- : m_hfont(hfont)
- {
- }
-
- HFONT m_hfont;
- };
-
- void platformDataInit(HFONT font, float size, HDC hdc, WCHAR* faceName);
-
- RefPtr<RefCountedHFONT> m_font;
-#if PLATFORM(CG)
- RetainPtr<CGFontRef> m_cgFont;
-#elif PLATFORM(CAIRO)
- cairo_font_face_t* m_fontFace;
- cairo_scaled_font_t* m_scaledFont;
-#endif
-
- float m_size;
- bool m_syntheticBold;
- bool m_syntheticOblique;
- bool m_useGDI;
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp b/WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp
deleted file mode 100644
index bbfdb9f..0000000
--- a/WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * This file is part of the internal font implementation. It should not be included by anyone other than
- * FontMac.cpp, FontWin.cpp and Font.cpp.
- *
- * Copyright (C) 2006, 2007, 2008 Apple Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "FontPlatformData.h"
-
-#include "PlatformString.h"
-#include "StringHash.h"
-#include <ApplicationServices/ApplicationServices.h>
-#include <wtf/HashMap.h>
-#include <wtf/RetainPtr.h>
-#include <wtf/Vector.h>
-
-using std::min;
-
-namespace WebCore {
-
-static inline USHORT readBigEndianWord(const BYTE* word) { return (word[0] << 8) | word[1]; }
-
-static CFStringRef getPostScriptName(CFStringRef faceName, HDC dc)
-{
- const DWORD cMaxNameTableSize = 1024 * 1024;
-
- static HashMap<String, RetainPtr<CFStringRef> > nameMap;
-
- // Check our hash first.
- String faceString(faceName);
- RetainPtr<CFStringRef> result = nameMap.get(faceString);
- if (result)
- return result.get();
-
- // We need to obtain the PostScript name from the name table and use it instead,.
- DWORD bufferSize = GetFontData(dc, 'eman', 0, NULL, 0); // "name" backwards
- if (bufferSize == 0 || bufferSize == GDI_ERROR || bufferSize > cMaxNameTableSize)
- return NULL;
-
- Vector<BYTE> bufferVector(bufferSize);
- BYTE* buffer = bufferVector.data();
- if (GetFontData(dc, 'eman', 0, buffer, bufferSize) == GDI_ERROR)
- return NULL;
-
- if (bufferSize < 6)
- return NULL;
-
- USHORT numberOfRecords = readBigEndianWord(buffer + 2);
- UINT stringsOffset = readBigEndianWord(buffer + 4);
- if (bufferSize < stringsOffset)
- return NULL;
-
- BYTE* strings = buffer + stringsOffset;
-
- // Now walk each name record looking for a Mac or Windows PostScript name.
- UINT offset = 6;
- for (int i = 0; i < numberOfRecords; i++) {
- if (bufferSize < offset + 12)
- return NULL;
-
- USHORT platformID = readBigEndianWord(buffer + offset);
- USHORT encodingID = readBigEndianWord(buffer + offset + 2);
- USHORT languageID = readBigEndianWord(buffer + offset + 4);
- USHORT nameID = readBigEndianWord(buffer + offset + 6);
- USHORT length = readBigEndianWord(buffer + offset + 8);
- USHORT nameOffset = readBigEndianWord(buffer + offset + 10);
-
- if (platformID == 3 && encodingID == 1 && languageID == 0x409 && nameID == 6) {
- // This is a Windows PostScript name and is therefore UTF-16.
- // Pass Big Endian as the encoding.
- if (bufferSize < stringsOffset + nameOffset + length)
- return NULL;
- result.adoptCF(CFStringCreateWithBytes(NULL, strings + nameOffset, length, kCFStringEncodingUTF16BE, false));
- break;
- } else if (platformID == 1 && encodingID == 0 && languageID == 0 && nameID == 6) {
- // This is a Mac PostScript name and is therefore ASCII.
- // See http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6name.html
- if (bufferSize < stringsOffset + nameOffset + length)
- return NULL;
- result.adoptCF(CFStringCreateWithBytes(NULL, strings + nameOffset, length, kCFStringEncodingASCII, false));
- break;
- }
-
- offset += 12;
- }
-
- if (result)
- nameMap.set(faceString, result);
- return result.get();
-}
-
-void FontPlatformData::platformDataInit(HFONT font, float size, HDC hdc, WCHAR* faceName)
-{
- // Try the face name first. Windows may end up localizing this name, and CG doesn't know about
- // the localization. If the create fails, we'll try the PostScript name.
- RetainPtr<CFStringRef> fullName(AdoptCF, CFStringCreateWithCharacters(NULL, (const UniChar*)faceName, wcslen(faceName)));
- m_cgFont.adoptCF(CGFontCreateWithFontName(fullName.get()));
- if (!m_cgFont) {
- CFStringRef postScriptName = getPostScriptName(fullName.get(), hdc);
- if (postScriptName) {
- m_cgFont.adoptCF(CGFontCreateWithFontName(postScriptName));
- ASSERT(m_cgFont);
- }
- }
-}
-
-FontPlatformData::FontPlatformData(HFONT hfont, CGFontRef font, float size, bool bold, bool oblique, bool useGDI)
- : m_font(RefCountedHFONT::create(hfont))
- , m_size(size)
- , m_cgFont(font)
- , m_syntheticBold(bold)
- , m_syntheticOblique(oblique)
- , m_useGDI(useGDI)
-{
-}
-
-}
diff --git a/WebCore/platform/graphics/win/FontPlatformDataCairoWin.cpp b/WebCore/platform/graphics/win/FontPlatformDataCairoWin.cpp
deleted file mode 100644
index 438d0a9..0000000
--- a/WebCore/platform/graphics/win/FontPlatformDataCairoWin.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * This file is part of the internal font implementation. It should not be included by anyone other than
- * FontMac.cpp, FontWin.cpp and Font.cpp.
- *
- * Copyright (C) 2006, 2007, 2008 Apple Inc.
- * Copyright (C) 2007 Alp Toker
- * Copyright (C) 2008 Brent Fulgham
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "FontPlatformData.h"
-
-#include "PlatformString.h"
-#include "StringHash.h"
-#include <wtf/HashMap.h>
-#include <wtf/RetainPtr.h>
-#include <wtf/Vector.h>
-
-#include <cairo-win32.h>
-
-using std::min;
-
-namespace WebCore {
-
-void FontPlatformData::platformDataInit(HFONT font, float size, HDC hdc, WCHAR* faceName)
-{
- m_fontFace = cairo_win32_font_face_create_for_hfont(font);
- cairo_matrix_t sizeMatrix, ctm;
- cairo_matrix_init_identity(&ctm);
- cairo_matrix_init_scale(&sizeMatrix, size, size);
-
- static cairo_font_options_t* fontOptions = 0;
- if (!fontOptions)
- {
- fontOptions = cairo_font_options_create();
- cairo_font_options_set_antialias(fontOptions, CAIRO_ANTIALIAS_SUBPIXEL);
- }
-
- m_scaledFont = cairo_scaled_font_create(m_fontFace, &sizeMatrix, &ctm, fontOptions);
-}
-
-FontPlatformData::FontPlatformData(cairo_font_face_t* fontFace, float size, bool bold, bool oblique)
- : m_font(0)
- , m_size(size)
- , m_fontFace(fontFace)
- , m_scaledFont(0)
- , m_syntheticBold(bold)
- , m_syntheticOblique(oblique)
- , m_useGDI(false)
-{
- cairo_matrix_t fontMatrix;
- cairo_matrix_init_scale(&fontMatrix, size, size);
- cairo_matrix_t ctm;
- cairo_matrix_init_identity(&ctm);
- cairo_font_options_t* options = cairo_font_options_create();
-
- // We force antialiasing and disable hinting to provide consistent
- // typographic qualities for custom fonts on all platforms.
- cairo_font_options_set_hint_style(options, CAIRO_HINT_STYLE_NONE);
- cairo_font_options_set_antialias(options, CAIRO_ANTIALIAS_GRAY);
-
- m_scaledFont = cairo_scaled_font_create(fontFace, &fontMatrix, &ctm, options);
- cairo_font_options_destroy(options);
-}
-
-void FontPlatformData::setFont(cairo_t* cr) const
-{
- ASSERT(m_scaledFont);
-
- cairo_set_scaled_font(cr, m_scaledFont);
-}
-
-}
diff --git a/WebCore/platform/graphics/win/FontPlatformDataWin.cpp b/WebCore/platform/graphics/win/FontPlatformDataWin.cpp
deleted file mode 100644
index 4b4df5a..0000000
--- a/WebCore/platform/graphics/win/FontPlatformDataWin.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * This file is part of the internal font implementation. It should not be included by anyone other than
- * FontMac.cpp, FontWin.cpp and Font.cpp.
- *
- * Copyright (C) 2006, 2007, 2008 Apple Inc.
- * Copyright (C) 2008 Brent Fulgham
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "FontPlatformData.h"
-
-#include "PlatformString.h"
-#include "StringHash.h"
-#include <wtf/HashMap.h>
-#include <wtf/RetainPtr.h>
-#include <wtf/Vector.h>
-
-using std::min;
-
-namespace WebCore {
-
-FontPlatformData::FontPlatformData(HFONT font, float size, bool bold, bool oblique, bool useGDI)
- : m_font(RefCountedHFONT::create(font))
- , m_size(size)
-#if PLATFORM(CG)
- , m_cgFont(0)
-#elif PLATFORM(CAIRO)
- , m_fontFace(0)
- , m_scaledFont(0)
-#endif
- , m_syntheticBold(bold)
- , m_syntheticOblique(oblique)
- , m_useGDI(useGDI)
-{
- HDC hdc = GetDC(0);
- SaveDC(hdc);
-
- SelectObject(hdc, font);
- UINT bufferSize = GetOutlineTextMetrics(hdc, 0, NULL);
-
- ASSERT_WITH_MESSAGE(bufferSize, "Bitmap fonts not supported with CoreGraphics.");
-
- if (bufferSize) {
- OUTLINETEXTMETRICW* metrics = (OUTLINETEXTMETRICW*)malloc(bufferSize);
-
- GetOutlineTextMetricsW(hdc, bufferSize, metrics);
- WCHAR* faceName = (WCHAR*)((uintptr_t)metrics + (uintptr_t)metrics->otmpFaceName);
-
- platformDataInit(font, size, hdc, faceName);
-
- free(metrics);
- }
-
- RestoreDC(hdc, -1);
- ReleaseDC(0, hdc);
-}
-
-FontPlatformData::FontPlatformData(float size, bool bold, bool oblique)
- : m_size(size)
-#if PLATFORM(CG)
- , m_cgFont(0)
-#elif PLATFORM(CAIRO)
- , m_fontFace(0)
- , m_scaledFont(0)
-#endif
- , m_syntheticBold(bold)
- , m_syntheticOblique(oblique)
- , m_useGDI(false)
-{
-}
-
-FontPlatformData::~FontPlatformData()
-{
-}
-
-}
diff --git a/WebCore/platform/graphics/win/FontWin.cpp b/WebCore/platform/graphics/win/FontWin.cpp
deleted file mode 100644
index 5e423e0..0000000
--- a/WebCore/platform/graphics/win/FontWin.cpp
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Font.h"
-
-#include "FontFallbackList.h"
-#include "GlyphBuffer.h"
-#include "GraphicsContext.h"
-#include "IntRect.h"
-#include "NotImplemented.h"
-#include "SimpleFontData.h"
-#include "UniscribeController.h"
-#include <wtf/MathExtras.h>
-
-namespace WebCore {
-
-FloatRect Font::selectionRectForComplexText(const TextRun& run, const IntPoint& point, int h,
- int from, int to) const
-{
- UniscribeController it(this, run);
- it.advance(from);
- float beforeWidth = it.runWidthSoFar();
- it.advance(to);
- float afterWidth = it.runWidthSoFar();
-
- // Using roundf() rather than ceilf() for the right edge as a compromise to ensure correct caret positioning
- if (run.rtl()) {
- it.advance(run.length());
- float totalWidth = it.runWidthSoFar();
- return FloatRect(point.x() + floorf(totalWidth - afterWidth), point.y(), roundf(totalWidth - beforeWidth) - floorf(totalWidth - afterWidth), h);
- }
-
- return FloatRect(point.x() + floorf(beforeWidth), point.y(), roundf(afterWidth) - floorf(beforeWidth), h);
-}
-
-void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point,
- int from, int to) const
-{
- // This glyph buffer holds our glyphs + advances + font data for each glyph.
- GlyphBuffer glyphBuffer;
-
- float startX = point.x();
- UniscribeController controller(this, run);
- controller.advance(from);
- float beforeWidth = controller.runWidthSoFar();
- controller.advance(to, &glyphBuffer);
-
- // We couldn't generate any glyphs for the run. Give up.
- if (glyphBuffer.isEmpty())
- return;
-
- float afterWidth = controller.runWidthSoFar();
-
- if (run.rtl()) {
- controller.advance(run.length());
- startX += controller.runWidthSoFar() - afterWidth;
- } else
- startX += beforeWidth;
-
- // Draw the glyph buffer now at the starting point returned in startX.
- FloatPoint startPoint(startX, point.y());
- drawGlyphBuffer(context, glyphBuffer, run, startPoint);
-}
-
-float Font::floatWidthForComplexText(const TextRun& run) const
-{
- UniscribeController controller(this, run);
- controller.advance(run.length());
- return controller.runWidthSoFar();
-}
-
-int Font::offsetForPositionForComplexText(const TextRun& run, int x, bool includePartialGlyphs) const
-{
- UniscribeController controller(this, run);
- return controller.offsetForPosition(x, includePartialGlyphs);
-}
-
-}
diff --git a/WebCore/platform/graphics/win/GlyphPageTreeNodeCGWin.cpp b/WebCore/platform/graphics/win/GlyphPageTreeNodeCGWin.cpp
deleted file mode 100644
index c11fc1b..0000000
--- a/WebCore/platform/graphics/win/GlyphPageTreeNodeCGWin.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "GlyphPageTreeNode.h"
-
-#include "SimpleFontData.h"
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
-
-namespace WebCore {
-
-bool GlyphPage::fill(unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength, const SimpleFontData* fontData)
-{
- // bufferLength will be greater than the requested number of glyphs if the buffer contains surrogate pairs.
- // We won't support this for now.
- if (bufferLength > length)
- return false;
-
- bool haveGlyphs = false;
- CGGlyph localGlyphBuffer[GlyphPage::size];
- wkGetGlyphs(fontData->platformData().cgFont(), buffer, localGlyphBuffer, bufferLength);
- for (unsigned i = 0; i < length; i++) {
- Glyph glyph = localGlyphBuffer[i];
- if (!glyph)
- setGlyphDataForIndex(offset + i, 0, 0);
- else {
- setGlyphDataForIndex(offset + i, glyph, fontData);
- haveGlyphs = true;
- }
- }
- return haveGlyphs;
-}
-
-}
diff --git a/WebCore/platform/graphics/win/GlyphPageTreeNodeCairoWin.cpp b/WebCore/platform/graphics/win/GlyphPageTreeNodeCairoWin.cpp
deleted file mode 100644
index b679ced..0000000
--- a/WebCore/platform/graphics/win/GlyphPageTreeNodeCairoWin.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "GlyphPageTreeNode.h"
-
-#include "SimpleFontData.h"
-
-namespace WebCore {
-
-bool GlyphPage::fill(unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength, const SimpleFontData* fontData)
-{
- // bufferLength will be greater than the requested number of glyphs if the buffer contains surrogate pairs.
- // We won't support this for now.
- if (bufferLength > length)
- return false;
-
- bool haveGlyphs = false;
-
- HDC dc = GetDC((HWND)0);
- SaveDC(dc);
- SelectObject(dc, fontData->platformData().hfont());
-
- TEXTMETRIC tm;
- GetTextMetrics(dc, &tm);
-
- WORD localGlyphBuffer[GlyphPage::size * 2];
- DWORD result = GetGlyphIndices(dc, buffer, bufferLength, localGlyphBuffer, 0);
- bool success = result != GDI_ERROR && static_cast<unsigned>(result) == bufferLength;
- if (success) {
- for (unsigned i = 0; i < length; i++) {
- Glyph glyph = localGlyphBuffer[i];
- if (!glyph)
- setGlyphDataForIndex(offset + i, 0, 0);
- else {
- setGlyphDataForIndex(offset + i, glyph, fontData);
- haveGlyphs = true;
- }
- }
- }
- RestoreDC(dc, -1);
- ReleaseDC(0, dc);
-
- return haveGlyphs;
-}
-
-}
diff --git a/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp b/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp
deleted file mode 100644
index 5a4279a..0000000
--- a/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp
+++ /dev/null
@@ -1,366 +0,0 @@
-/*
- * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "GraphicsContext.h"
-
-#include "AffineTransform.h"
-#include "NotImplemented.h"
-#include "Path.h"
-
-#include <CoreGraphics/CGBitmapContext.h>
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
-#include "GraphicsContextPlatformPrivateCG.h"
-
-using namespace std;
-
-namespace WebCore {
-
-static CGContextRef CGContextWithHDC(HDC hdc, bool hasAlpha)
-{
- HBITMAP bitmap = static_cast<HBITMAP>(GetCurrentObject(hdc, OBJ_BITMAP));
- CGColorSpaceRef deviceRGB = CGColorSpaceCreateDeviceRGB();
- BITMAP info;
-
- GetObject(bitmap, sizeof(info), &info);
- ASSERT(info.bmBitsPixel == 32);
-
- CGBitmapInfo bitmapInfo = kCGBitmapByteOrder32Little | (hasAlpha ? kCGImageAlphaPremultipliedFirst : kCGImageAlphaNoneSkipFirst);
- CGContextRef context = CGBitmapContextCreate(info.bmBits, info.bmWidth, info.bmHeight, 8,
- info.bmWidthBytes, deviceRGB, bitmapInfo);
- CGColorSpaceRelease(deviceRGB);
-
- // Flip coords
- CGContextTranslateCTM(context, 0, info.bmHeight);
- CGContextScaleCTM(context, 1, -1);
-
- // Put the HDC In advanced mode so it will honor affine transforms.
- SetGraphicsMode(hdc, GM_ADVANCED);
-
- return context;
-}
-
-GraphicsContext::GraphicsContext(HDC hdc, bool hasAlpha)
- : m_common(createGraphicsContextPrivate())
- , m_data(new GraphicsContextPlatformPrivate(CGContextWithHDC(hdc, hasAlpha)))
-{
- CGContextRelease(m_data->m_cgContext);
- m_data->m_hdc = hdc;
- setPaintingDisabled(!m_data->m_cgContext);
- if (m_data->m_cgContext) {
- // Make sure the context starts in sync with our state.
- setPlatformFillColor(fillColor());
- setPlatformStrokeColor(strokeColor());
- }
-}
-
-bool GraphicsContext::inTransparencyLayer() const { return m_data->m_transparencyCount; }
-
-// FIXME: Is it possible to merge getWindowsContext and createWindowsBitmap into a single API
-// suitable for all clients?
-HDC GraphicsContext::getWindowsContext(const IntRect& dstRect, bool supportAlphaBlend, bool mayCreateBitmap)
-{
- // FIXME: Should a bitmap be created also when a shadow is set?
- if (mayCreateBitmap && inTransparencyLayer()) {
- if (dstRect.isEmpty())
- return 0;
-
- // Create a bitmap DC in which to draw.
- BITMAPINFO bitmapInfo;
- bitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- bitmapInfo.bmiHeader.biWidth = dstRect.width();
- bitmapInfo.bmiHeader.biHeight = dstRect.height();
- bitmapInfo.bmiHeader.biPlanes = 1;
- bitmapInfo.bmiHeader.biBitCount = 32;
- bitmapInfo.bmiHeader.biCompression = BI_RGB;
- bitmapInfo.bmiHeader.biSizeImage = 0;
- bitmapInfo.bmiHeader.biXPelsPerMeter = 0;
- bitmapInfo.bmiHeader.biYPelsPerMeter = 0;
- bitmapInfo.bmiHeader.biClrUsed = 0;
- bitmapInfo.bmiHeader.biClrImportant = 0;
-
- void* pixels = 0;
- HBITMAP bitmap = ::CreateDIBSection(NULL, &bitmapInfo, DIB_RGB_COLORS, &pixels, 0, 0);
- if (!bitmap)
- return 0;
-
- HDC bitmapDC = ::CreateCompatibleDC(m_data->m_hdc);
- ::SelectObject(bitmapDC, bitmap);
-
- // Fill our buffer with clear if we're going to alpha blend.
- if (supportAlphaBlend) {
- BITMAP bmpInfo;
- GetObject(bitmap, sizeof(bmpInfo), &bmpInfo);
- int bufferSize = bmpInfo.bmWidthBytes * bmpInfo.bmHeight;
- memset(bmpInfo.bmBits, 0, bufferSize);
- }
-
- // Make sure we can do world transforms.
- SetGraphicsMode(bitmapDC, GM_ADVANCED);
-
- // Apply a translation to our context so that the drawing done will be at (0,0) of the bitmap.
- XFORM xform;
- xform.eM11 = 1.0f;
- xform.eM12 = 0.0f;
- xform.eM21 = 0.0f;
- xform.eM22 = 1.0f;
- xform.eDx = -dstRect.x();
- xform.eDy = -dstRect.y();
- ::SetWorldTransform(bitmapDC, &xform);
-
- return bitmapDC;
- }
-
- CGContextFlush(platformContext());
- m_data->save();
- return m_data->m_hdc;
-}
-
-void GraphicsContext::releaseWindowsContext(HDC hdc, const IntRect& dstRect, bool supportAlphaBlend, bool mayCreateBitmap)
-{
- if (mayCreateBitmap && hdc && inTransparencyLayer()) {
- if (dstRect.isEmpty())
- return;
-
- HBITMAP bitmap = static_cast<HBITMAP>(GetCurrentObject(hdc, OBJ_BITMAP));
-
- // Need to make a CGImage out of the bitmap's pixel buffer and then draw
- // it into our context.
- BITMAP info;
- GetObject(bitmap, sizeof(info), &info);
- ASSERT(info.bmBitsPixel == 32);
-
- CGColorSpaceRef deviceRGB = CGColorSpaceCreateDeviceRGB();
- CGContextRef bitmapContext = CGBitmapContextCreate(info.bmBits, info.bmWidth, info.bmHeight, 8,
- info.bmWidthBytes, deviceRGB, kCGBitmapByteOrder32Little |
- (supportAlphaBlend ? kCGImageAlphaPremultipliedFirst : kCGImageAlphaNoneSkipFirst));
- CGColorSpaceRelease(deviceRGB);
-
- CGImageRef image = CGBitmapContextCreateImage(bitmapContext);
- CGContextDrawImage(m_data->m_cgContext, dstRect, image);
-
- // Delete all our junk.
- CGImageRelease(image);
- CGContextRelease(bitmapContext);
- ::DeleteDC(hdc);
- ::DeleteObject(bitmap);
-
- return;
- }
-
- m_data->restore();
-}
-
-GraphicsContext::WindowsBitmap::WindowsBitmap(HDC hdc, IntSize size)
- : m_hdc(0)
- , m_size(size)
-{
- BITMAPINFO bitmapInfo;
- bitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- bitmapInfo.bmiHeader.biWidth = m_size.width();
- bitmapInfo.bmiHeader.biHeight = m_size.height();
- bitmapInfo.bmiHeader.biPlanes = 1;
- bitmapInfo.bmiHeader.biBitCount = 32;
- bitmapInfo.bmiHeader.biCompression = BI_RGB;
- bitmapInfo.bmiHeader.biSizeImage = 0;
- bitmapInfo.bmiHeader.biXPelsPerMeter = 0;
- bitmapInfo.bmiHeader.biYPelsPerMeter = 0;
- bitmapInfo.bmiHeader.biClrUsed = 0;
- bitmapInfo.bmiHeader.biClrImportant = 0;
-
- m_bitmap = CreateDIBSection(0, &bitmapInfo, DIB_RGB_COLORS, reinterpret_cast<void**>(&m_bitmapBuffer), 0, 0);
- if (!m_bitmap)
- return;
-
- m_hdc = CreateCompatibleDC(hdc);
- SelectObject(m_hdc, m_bitmap);
-
- BITMAP bmpInfo;
- GetObject(m_bitmap, sizeof(bmpInfo), &bmpInfo);
- m_bytesPerRow = bmpInfo.bmWidthBytes;
- m_bitmapBufferLength = bmpInfo.bmWidthBytes * bmpInfo.bmHeight;
-
- SetGraphicsMode(m_hdc, GM_ADVANCED);
-}
-
-GraphicsContext::WindowsBitmap::~WindowsBitmap()
-{
- if (!m_bitmap)
- return;
-
- DeleteDC(m_hdc);
- DeleteObject(m_bitmap);
-}
-
-GraphicsContext::WindowsBitmap* GraphicsContext::createWindowsBitmap(IntSize size)
-{
- return new WindowsBitmap(m_data->m_hdc, size);
-}
-
-void GraphicsContext::drawWindowsBitmap(WindowsBitmap* image, const IntPoint& point)
-{
- RetainPtr<CGColorSpaceRef> deviceRGB(AdoptCF, CGColorSpaceCreateDeviceRGB());
- RetainPtr<CFDataRef> imageData(AdoptCF, CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, image->buffer(), image->bufferLength(), kCFAllocatorNull));
- RetainPtr<CGDataProviderRef> dataProvider(AdoptCF, CGDataProviderCreateWithCFData(imageData.get()));
- RetainPtr<CGImageRef> cgImage(AdoptCF, CGImageCreate(image->size().width(), image->size().height(), 8, 32, image->bytesPerRow(), deviceRGB.get(),
- kCGBitmapByteOrder32Little | kCGImageAlphaFirst, dataProvider.get(), 0, true, kCGRenderingIntentDefault));
- CGContextDrawImage(m_data->m_cgContext, CGRectMake(point.x(), point.y(), image->size().width(), image->size().height()), cgImage.get());
-}
-
-void GraphicsContextPlatformPrivate::concatCTM(const AffineTransform& transform)
-{
- if (!m_hdc)
- return;
-
- CGAffineTransform mat = transform;
- XFORM xform;
- xform.eM11 = mat.a;
- xform.eM12 = mat.b;
- xform.eM21 = mat.c;
- xform.eM22 = mat.d;
- xform.eDx = mat.tx;
- xform.eDy = mat.ty;
-
- ModifyWorldTransform(m_hdc, &xform, MWT_LEFTMULTIPLY);
-}
-
-void GraphicsContext::drawFocusRing(const Color& color)
-{
- if (paintingDisabled())
- return;
-
- float radius = (focusRingWidth() - 1) / 2.0f;
- int offset = radius + focusRingOffset();
- CGColorRef colorRef = color.isValid() ? cgColor(color) : 0;
-
- CGMutablePathRef focusRingPath = CGPathCreateMutable();
- const Vector<IntRect>& rects = focusRingRects();
- unsigned rectCount = rects.size();
- for (unsigned i = 0; i < rectCount; i++)
- CGPathAddRect(focusRingPath, 0, CGRectInset(rects[i], -offset, -offset));
-
- CGContextRef context = platformContext();
- CGContextSaveGState(context);
-
- CGContextBeginPath(context);
- CGContextAddPath(context, focusRingPath);
-
- wkDrawFocusRing(context, colorRef, radius);
-
- CGColorRelease(colorRef);
-
- CGPathRelease(focusRingPath);
-
- CGContextRestoreGState(context);
-}
-
-// Pulled from GraphicsContextCG
-static void setCGStrokeColor(CGContextRef context, const Color& color)
-{
- CGFloat red, green, blue, alpha;
- color.getRGBA(red, green, blue, alpha);
- CGContextSetRGBStrokeColor(context, red, green, blue, alpha);
-}
-
-static const Color& spellingPatternColor() {
- static const Color spellingColor(255, 0, 0);
- return spellingColor;
-}
-
-static const Color& grammarPatternColor() {
- static const Color grammarColor(0, 128, 0);
- return grammarColor;
-}
-
-void GraphicsContext::drawLineForMisspellingOrBadGrammar(const IntPoint& point, int width, bool grammar)
-{
- if (paintingDisabled())
- return;
-
- // These are the same for misspelling or bad grammar
- const int patternHeight = 3; // 3 rows
- ASSERT(cMisspellingLineThickness == patternHeight);
- const int patternWidth = 4; // 4 pixels
- ASSERT(patternWidth == cMisspellingLinePatternWidth);
-
- // Make sure to draw only complete dots.
- // NOTE: Code here used to shift the underline to the left and increase the width
- // to make sure everything gets underlined, but that results in drawing out of
- // bounds (e.g. when at the edge of a view) and could make it appear that the
- // space between adjacent misspelled words was underlined.
- // allow slightly more considering that the pattern ends with a transparent pixel
- int widthMod = width % patternWidth;
- if (patternWidth - widthMod > cMisspellingLinePatternGapWidth)
- width -= widthMod;
-
- // Draw the underline
- CGContextRef context = platformContext();
- CGContextSaveGState(context);
-
- const Color& patternColor = grammar ? grammarPatternColor() : spellingPatternColor();
- setCGStrokeColor(context, patternColor);
-
- wkSetPatternPhaseInUserSpace(context, point);
- CGContextSetBlendMode(context, kCGBlendModeNormal);
-
- // 3 rows, each offset by half a pixel for blending purposes
- const CGPoint upperPoints [] = {{point.x(), point.y() + patternHeight - 2.5 }, {point.x() + width, point.y() + patternHeight - 2.5}};
- const CGPoint middlePoints [] = {{point.x(), point.y() + patternHeight - 1.5 }, {point.x() + width, point.y() + patternHeight - 1.5}};
- const CGPoint lowerPoints [] = {{point.x(), point.y() + patternHeight - 0.5 }, {point.x() + width, point.y() + patternHeight - 0.5 }};
-
- // Dash lengths for the top and bottom of the error underline are the same.
- // These are magic.
- static const float edge_dash_lengths[] = {2.0f, 2.0f};
- static const float middle_dash_lengths[] = {2.76f, 1.24f};
- static const float edge_offset = -(edge_dash_lengths[1] - 1.0f) / 2.0f;
- static const float middle_offset = -(middle_dash_lengths[1] - 1.0f) / 2.0f;
-
- // Line opacities. Once again, these are magic.
- const float upperOpacity = 0.33f;
- const float middleOpacity = 0.75f;
- const float lowerOpacity = 0.88f;
-
- //Top line
- CGContextSetLineDash(context, edge_offset, edge_dash_lengths,
- sizeof(edge_dash_lengths) / sizeof(edge_dash_lengths[0]));
- CGContextSetAlpha(context, upperOpacity);
- CGContextStrokeLineSegments(context, upperPoints, 2);
-
- // Middle line
- CGContextSetLineDash(context, middle_offset, middle_dash_lengths,
- sizeof(middle_dash_lengths) / sizeof(middle_dash_lengths[0]));
- CGContextSetAlpha(context, middleOpacity);
- CGContextStrokeLineSegments(context, middlePoints, 2);
-
- // Bottom line
- CGContextSetLineDash(context, edge_offset, edge_dash_lengths,
- sizeof(edge_dash_lengths) / sizeof(edge_dash_lengths[0]));
- CGContextSetAlpha(context, lowerOpacity);
- CGContextStrokeLineSegments(context, lowerPoints, 2);
-
- CGContextRestoreGState(context);
-}
-
-}
diff --git a/WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp b/WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp
deleted file mode 100644
index 3dcf6ba..0000000
--- a/WebCore/platform/graphics/win/GraphicsContextCairoWin.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "GraphicsContext.h"
-
-#include "AffineTransform.h"
-#include "NotImplemented.h"
-#include "Path.h"
-
-#include <cairo-win32.h>
-#include "GraphicsContextPlatformPrivateCairo.h"
-
-using namespace std;
-
-namespace WebCore {
-
-GraphicsContext::GraphicsContext(HDC dc, bool hasAlpha)
- : m_common(createGraphicsContextPrivate())
- , m_data(new GraphicsContextPlatformPrivate)
-{
- if (dc) {
- cairo_surface_t* surface = cairo_win32_surface_create(dc);
- m_data->cr = cairo_create(surface);
- m_data->m_hdc = dc;
- } else {
- setPaintingDisabled(true);
- m_data->cr = 0;
- m_data->m_hdc = 0;
- }
-
- if (m_data->cr) {
- // Make sure the context starts in sync with our state.
- setPlatformFillColor(fillColor());
- setPlatformStrokeColor(strokeColor());
- }
-}
-
-HDC GraphicsContext::getWindowsContext(const IntRect& dstRect, bool supportAlphaBlend, bool mayCreateBitmap)
-{
- // FIXME: We aren't really doing anything with the 'mayCreateBitmap' flag. This needs
- // to be addressed.
- if (dstRect.isEmpty())
- return 0;
-
- // This is probably wrong, and definitely out of date. Pulled from old SVN
- cairo_surface_t* surface = cairo_get_target(platformContext());
- HDC hdc = cairo_win32_surface_get_dc(surface);
- SaveDC(hdc);
-
- // FIXME: We need to make sure a clip is really set on the HDC.
- // Call SetWorldTransform to honor the current Cairo transform.
- SetGraphicsMode(hdc, GM_ADVANCED); // We need this call for themes to honor world transforms.
- cairo_matrix_t mat;
- cairo_get_matrix(platformContext(), &mat);
- XFORM xform;
- xform.eM11 = mat.xx;
- xform.eM12 = mat.xy;
- xform.eM21 = mat.yx;
- xform.eM22 = mat.yy;
- xform.eDx = mat.x0;
- xform.eDy = mat.y0;
- ::SetWorldTransform(hdc, &xform);
-
- return hdc;
-}
-
-bool GraphicsContext::inTransparencyLayer() const { return m_data->m_transparencyCount; }
-
-void GraphicsContext::releaseWindowsContext(HDC hdc, const IntRect& dstRect, bool supportAlphaBlend, bool mayCreateBitmap)
-{
- // FIXME: We aren't really doing anything with the 'mayCreateBitmap' flag. This needs
- // to be addressed.
- if (dstRect.isEmpty())
- return;
-
- cairo_surface_t* surface = cairo_get_target(platformContext());
- HDC hdc2 = cairo_win32_surface_get_dc(surface);
- RestoreDC(hdc2, -1);
- cairo_surface_mark_dirty(surface);
-}
-
-void GraphicsContextPlatformPrivate::concatCTM(const AffineTransform& transform)
-{
- cairo_surface_t* surface = cairo_get_target(cr);
- HDC hdc = cairo_win32_surface_get_dc(surface);
- SaveDC(hdc);
-
- const cairo_matrix_t* matrix = reinterpret_cast<const cairo_matrix_t*>(&transform);
-
- XFORM xform;
- xform.eM11 = matrix->xx;
- xform.eM12 = matrix->xy;
- xform.eM21 = matrix->yx;
- xform.eM22 = matrix->yy;
- xform.eDx = matrix->x0;
- xform.eDy = matrix->y0;
-
- ModifyWorldTransform(hdc, &xform, MWT_LEFTMULTIPLY);
-}
-
-}
diff --git a/WebCore/platform/graphics/win/GraphicsContextWin.cpp b/WebCore/platform/graphics/win/GraphicsContextWin.cpp
deleted file mode 100644
index dbf9fad..0000000
--- a/WebCore/platform/graphics/win/GraphicsContextWin.cpp
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "GraphicsContext.h"
-
-#if PLATFORM(CG)
-#include "GraphicsContextPlatformPrivateCG.h"
-#elif PLATFORM(CAIRO)
-#include "GraphicsContextPlatformPrivateCairo.h"
-#endif
-
-#include "AffineTransform.h"
-#include "NotImplemented.h"
-#include "Path.h"
-#include <wtf/MathExtras.h>
-
-using namespace std;
-
-namespace WebCore {
-
-class SVGResourceImage;
-
-void GraphicsContextPlatformPrivate::save()
-{
- if (!m_hdc)
- return;
- SaveDC(m_hdc);
-}
-
-void GraphicsContextPlatformPrivate::restore()
-{
- if (!m_hdc)
- return;
- RestoreDC(m_hdc, -1);
-}
-
-void GraphicsContextPlatformPrivate::clip(const FloatRect& clipRect)
-{
- if (!m_hdc)
- return;
- IntersectClipRect(m_hdc, clipRect.x(), clipRect.y(), clipRect.right(), clipRect.bottom());
-}
-
-void GraphicsContextPlatformPrivate::clip(const Path&)
-{
- notImplemented();
-}
-
-void GraphicsContextPlatformPrivate::scale(const FloatSize& size)
-{
- if (!m_hdc)
- return;
- XFORM xform;
- xform.eM11 = size.width();
- xform.eM12 = 0.0f;
- xform.eM21 = 0.0f;
- xform.eM22 = size.height();
- xform.eDx = 0.0f;
- xform.eDy = 0.0f;
- ModifyWorldTransform(m_hdc, &xform, MWT_LEFTMULTIPLY);
-}
-
-static const double deg2rad = 0.017453292519943295769; // pi/180
-
-void GraphicsContextPlatformPrivate::rotate(float degreesAngle)
-{
- float radiansAngle = degreesAngle * deg2rad;
- float cosAngle = cosf(radiansAngle);
- float sinAngle = sinf(radiansAngle);
- XFORM xform;
- xform.eM11 = cosAngle;
- xform.eM12 = -sinAngle;
- xform.eM21 = sinAngle;
- xform.eM22 = cosAngle;
- xform.eDx = 0.0f;
- xform.eDy = 0.0f;
- ModifyWorldTransform(m_hdc, &xform, MWT_LEFTMULTIPLY);
-}
-
-void GraphicsContextPlatformPrivate::translate(float x , float y)
-{
- if (!m_hdc)
- return;
- XFORM xform;
- xform.eM11 = 1.0f;
- xform.eM12 = 0.0f;
- xform.eM21 = 0.0f;
- xform.eM22 = 1.0f;
- xform.eDx = x;
- xform.eDy = y;
- ModifyWorldTransform(m_hdc, &xform, MWT_LEFTMULTIPLY);
-}
-
-#if ENABLE(SVG)
-GraphicsContext* contextForImage(SVGResourceImage*)
-{
- // FIXME: This should go in GraphicsContextCG.cpp
- notImplemented();
- return 0;
-}
-#endif
-
-}
diff --git a/WebCore/platform/graphics/win/IconWin.cpp b/WebCore/platform/graphics/win/IconWin.cpp
deleted file mode 100644
index c02b56e..0000000
--- a/WebCore/platform/graphics/win/IconWin.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
-* Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
-*
-* This library is free software; you can redistribute it and/or
-* modify it under the terms of the GNU Library General Public
-* License as published by the Free Software Foundation; either
-* version 2 of the License, or (at your option) any later version.
-*
-* This library is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Library General Public License for more details.
-*
-* You should have received a copy of the GNU Library General Public License
-* along with this library; see the file COPYING.LIB. If not, write to
-* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-* Boston, MA 02110-1301, USA.
-*
-*/
-
-#include "config.h"
-#include "Icon.h"
-
-#include "GraphicsContext.h"
-#include "PlatformString.h"
-#include <tchar.h>
-#include <windows.h>
-
-namespace WebCore {
-
-static const int shell32MultipleFileIconIndex = 54;
-
-Icon::Icon(HICON icon)
- : m_hIcon(icon)
-{
- ASSERT(icon);
-}
-
-Icon::~Icon()
-{
- DestroyIcon(m_hIcon);
-}
-
-PassRefPtr<Icon> Icon::createIconForFile(const String& filename)
-{
- SHFILEINFO sfi;
- memset(&sfi, 0, sizeof(sfi));
-
- String tmpFilename = filename;
- if (!SHGetFileInfo(tmpFilename.charactersWithNullTermination(), 0, &sfi, sizeof(sfi), SHGFI_ICON | SHGFI_SHELLICONSIZE | SHGFI_SMALLICON))
- return 0;
-
- return adoptRef(new Icon(sfi.hIcon));
-}
-
-PassRefPtr<Icon> Icon::createIconForFiles(const Vector<String>&)
-{
- TCHAR buffer[MAX_PATH];
- UINT length = ::GetSystemDirectory(buffer, ARRAYSIZE(buffer));
- if (!length)
- return 0;
-
- if (_tcscat_s(buffer, TEXT("\\shell32.dll")))
- return 0;
-
- HICON hIcon;
- if (!::ExtractIconEx(buffer, shell32MultipleFileIconIndex, 0, &hIcon, 1))
- return 0;
- return adoptRef(new Icon(hIcon));
-}
-
-void Icon::paint(GraphicsContext* context, const IntRect& r)
-{
- if (context->paintingDisabled())
- return;
-
- HDC hdc = context->getWindowsContext(r);
-
- DrawIconEx(hdc, r.x(), r.y(), m_hIcon, r.width(), r.height(), 0, 0, DI_NORMAL);
-
- context->releaseWindowsContext(hdc, r);
-}
-
-}
diff --git a/WebCore/platform/graphics/win/ImageCGWin.cpp b/WebCore/platform/graphics/win/ImageCGWin.cpp
deleted file mode 100644
index 752729c..0000000
--- a/WebCore/platform/graphics/win/ImageCGWin.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Image.h"
-#include "BitmapImage.h"
-#include "GraphicsContext.h"
-#include <ApplicationServices/ApplicationServices.h>
-
-#include <windows.h>
-#include "PlatformString.h"
-
-namespace WebCore {
-
-bool BitmapImage::getHBITMAPOfSize(HBITMAP bmp, LPSIZE size)
-{
- ASSERT(bmp);
-
- BITMAP bmpInfo;
- GetObject(bmp, sizeof(BITMAP), &bmpInfo);
-
- ASSERT(bmpInfo.bmBitsPixel == 32);
- int bufferSize = bmpInfo.bmWidthBytes * bmpInfo.bmHeight;
-
- CGColorSpaceRef deviceRGB = CGColorSpaceCreateDeviceRGB();
- CGContextRef cgContext = CGBitmapContextCreate(bmpInfo.bmBits, bmpInfo.bmWidth, bmpInfo.bmHeight,
- 8, bmpInfo.bmWidthBytes, deviceRGB, kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst);
-
- GraphicsContext gc(cgContext);
-
- IntSize imageSize = BitmapImage::size();
- if (size)
- drawFrameMatchingSourceSize(&gc, FloatRect(0.0f, 0.0f, bmpInfo.bmWidth, bmpInfo.bmHeight), IntSize(*size), CompositeCopy);
- else
- draw(&gc, FloatRect(0.0f, 0.0f, bmpInfo.bmWidth, bmpInfo.bmHeight), FloatRect(0.0f, 0.0f, imageSize.width(), imageSize.height()), CompositeCopy);
-
- // Do cleanup
- CGContextRelease(cgContext);
- CGColorSpaceRelease(deviceRGB);
-
- return true;
-}
-
-void BitmapImage::drawFrameMatchingSourceSize(GraphicsContext* ctxt, const FloatRect& dstRect, const IntSize& srcSize, CompositeOperator compositeOp)
-{
- int frames = frameCount();
- for (int i = 0; i < frames; ++i) {
- CGImageRef image = frameAtIndex(i);
- if (CGImageGetHeight(image) == static_cast<size_t>(srcSize.height()) && CGImageGetWidth(image) == static_cast<size_t>(srcSize.width())) {
- size_t currentFrame = m_currentFrame;
- m_currentFrame = i;
- draw(ctxt, dstRect, FloatRect(0.0f, 0.0f, srcSize.width(), srcSize.height()), compositeOp);
- m_currentFrame = currentFrame;
- return;
- }
- }
-
- // No image of the correct size was found, fallback to drawing the current frame
- IntSize imageSize = BitmapImage::size();
- draw(ctxt, dstRect, FloatRect(0.0f, 0.0f, imageSize.width(), imageSize.height()), compositeOp);
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/graphics/win/ImageCairoWin.cpp b/WebCore/platform/graphics/win/ImageCairoWin.cpp
deleted file mode 100644
index 95bb7bc..0000000
--- a/WebCore/platform/graphics/win/ImageCairoWin.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Image.h"
-#include "BitmapImage.h"
-#include "GraphicsContext.h"
-#include <cairo.h>
-
-#include <windows.h>
-#include "PlatformString.h"
-
-namespace WebCore {
-
-bool BitmapImage::getHBITMAPOfSize(HBITMAP bmp, LPSIZE size)
-{
- ASSERT(bmp);
-
- BITMAP bmpInfo;
- GetObject(bmp, sizeof(BITMAP), &bmpInfo);
-
- // If this is a 32bpp bitmap, which it always should be, we'll clear it so alpha-wise it will be visible
- if (bmpInfo.bmBitsPixel == 32) {
- int bufferSize = bmpInfo.bmWidthBytes * bmpInfo.bmHeight;
- memset(bmpInfo.bmBits, 255, bufferSize);
- }
-
- HDC tempDC = CreateCompatibleDC(0);
- if (!tempDC) {
- LOG_ERROR("Failed to create in-memory DC for Image::blit()");
- return false;
- }
- SelectObject(tempDC, bmp);
- GraphicsContext gc(tempDC);
-
- IntSize imageSize = BitmapImage::size();
- if (size)
- drawFrameMatchingSourceSize(&gc, FloatRect(0.0f, 0.0f, bmpInfo.bmWidth, bmpInfo.bmHeight), IntSize(*size), CompositeCopy);
- else
- draw(&gc, FloatRect(0.0f, 0.0f, bmpInfo.bmWidth, bmpInfo.bmHeight), FloatRect(0.0f, 0.0f, imageSize.width(), imageSize.height()), CompositeCopy);
-
- // Do cleanup
- DeleteDC(tempDC);
-
- return true;
-}
-
-void BitmapImage::drawFrameMatchingSourceSize(GraphicsContext* ctxt, const FloatRect& dstRect, const IntSize& srcSize, CompositeOperator compositeOp)
-{
- int frames = frameCount();
- for (int i = 0; i < frames; ++i) {
- cairo_surface_t* image = frameAtIndex(i);
- if (cairo_image_surface_get_height(image) == static_cast<size_t>(srcSize.height()) && cairo_image_surface_get_width(image) == static_cast<size_t>(srcSize.width())) {
- size_t currentFrame = m_currentFrame;
- m_currentFrame = i;
- draw(ctxt, dstRect, FloatRect(0.0f, 0.0f, srcSize.width(), srcSize.height()), compositeOp);
- m_currentFrame = currentFrame;
- return;
- }
- }
-
- // No image of the correct size was found, fallback to drawing the current frame
- IntSize imageSize = BitmapImage::size();
- draw(ctxt, dstRect, FloatRect(0.0f, 0.0f, imageSize.width(), imageSize.height()), compositeOp);
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/graphics/win/ImageWin.cpp b/WebCore/platform/graphics/win/ImageWin.cpp
deleted file mode 100644
index 54c5b41..0000000
--- a/WebCore/platform/graphics/win/ImageWin.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Image.h"
-#include "BitmapImage.h"
-
-#include "SharedBuffer.h"
-
-// This function loads resources from WebKit
-PassRefPtr<WebCore::SharedBuffer> loadResourceIntoBuffer(const char*);
-
-namespace WebCore {
-
-void BitmapImage::initPlatformData()
-{
-}
-
-void BitmapImage::invalidatePlatformData()
-{
-}
-
-PassRefPtr<Image> Image::loadPlatformResource(const char *name)
-{
- RefPtr<SharedBuffer> buffer = loadResourceIntoBuffer(name);
- RefPtr<BitmapImage> img = BitmapImage::create();
- img->setData(buffer.release(), true);
- return img.release();
-}
-
-bool BitmapImage::getHBITMAP(HBITMAP bmp)
-{
- return getHBITMAPOfSize(bmp, 0);
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/graphics/win/IntPointWin.cpp b/WebCore/platform/graphics/win/IntPointWin.cpp
deleted file mode 100644
index a6ce0bb..0000000
--- a/WebCore/platform/graphics/win/IntPointWin.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "IntPoint.h"
-
-#include <windows.h>
-
-namespace WebCore {
-
-IntPoint::IntPoint(const POINT& p)
- : m_x(p.x)
- , m_y(p.y)
-{
-}
-
-IntPoint::operator POINT() const
-{
- POINT p = {m_x, m_y};
- return p;
-}
-
-IntPoint::IntPoint(const POINTS& p)
- : m_x(p.x)
- , m_y(p.y)
-{
-}
-
-IntPoint::operator POINTS() const
-{
- POINTS p = {m_x, m_y};
- return p;
-}
-
-}
diff --git a/WebCore/platform/graphics/win/IntRectWin.cpp b/WebCore/platform/graphics/win/IntRectWin.cpp
deleted file mode 100644
index 6228be8..0000000
--- a/WebCore/platform/graphics/win/IntRectWin.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "IntRect.h"
-
-#include <windows.h>
-
-namespace WebCore {
-
-IntRect::IntRect(const RECT& r)
- : m_location(IntPoint(r.left, r.top)), m_size(IntSize(r.right-r.left, r.bottom-r.top))
-{
-}
-
-IntRect::operator RECT() const
-{
- RECT rect = { x(), y(), right(), bottom() };
- return rect;
-}
-
-}
diff --git a/WebCore/platform/graphics/win/IntSizeWin.cpp b/WebCore/platform/graphics/win/IntSizeWin.cpp
deleted file mode 100644
index 8a27cdb..0000000
--- a/WebCore/platform/graphics/win/IntSizeWin.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "IntSize.h"
-
-#include <windows.h>
-
-namespace WebCore {
-
-IntSize::IntSize(const SIZE& s)
- : m_width(s.cx)
- , m_height(s.cy)
-{
-}
-
-IntSize::operator SIZE() const
-{
- SIZE s = {m_width, m_height};
- return s;
-}
-
-}
diff --git a/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeWin.cpp b/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeWin.cpp
deleted file mode 100644
index cef4217..0000000
--- a/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeWin.cpp
+++ /dev/null
@@ -1,483 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if ENABLE(VIDEO)
-#include "MediaPlayerPrivateQuickTimeWin.h"
-
-#include "GraphicsContext.h"
-#include "KURL.h"
-#include "QTMovieWin.h"
-#include "ScrollView.h"
-#include <wtf/MathExtras.h>
-
-#if DRAW_FRAME_RATE
-#include "Font.h"
-#include "FrameView.h"
-#include "Frame.h"
-#include "Document.h"
-#include "RenderObject.h"
-#include "RenderStyle.h"
-#include "Windows.h"
-#endif
-
-using namespace std;
-
-namespace WebCore {
-
-static const double endPointTimerInterval = 0.020;
-
-MediaPlayerPrivate::MediaPlayerPrivate(MediaPlayer* player)
- : m_player(player)
- , m_seekTo(-1)
- , m_endTime(numeric_limits<float>::infinity())
- , m_seekTimer(this, &MediaPlayerPrivate::seekTimerFired)
- , m_endPointTimer(this, &MediaPlayerPrivate::endPointTimerFired)
- , m_networkState(MediaPlayer::Empty)
- , m_readyState(MediaPlayer::DataUnavailable)
- , m_startedPlaying(false)
- , m_isStreaming(false)
-#if DRAW_FRAME_RATE
- , m_frameCountWhilePlaying(0)
- , m_timeStartedPlaying(0)
- , m_timeStoppedPlaying(0)
-#endif
-{
-}
-
-MediaPlayerPrivate::~MediaPlayerPrivate()
-{
-}
-
-void MediaPlayerPrivate::load(const String& url)
-{
- if (!QTMovieWin::initializeQuickTime()) {
- m_networkState = MediaPlayer::LoadFailed;
- m_player->networkStateChanged();
- return;
- }
-
- if (m_networkState != MediaPlayer::Loading) {
- m_networkState = MediaPlayer::Loading;
- m_player->networkStateChanged();
- }
- if (m_readyState != MediaPlayer::DataUnavailable) {
- m_readyState = MediaPlayer::DataUnavailable;
- m_player->readyStateChanged();
- }
- cancelSeek();
- m_endPointTimer.stop();
-
- m_qtMovie.set(new QTMovieWin(this));
- m_qtMovie->load(url.characters(), url.length());
- m_qtMovie->setVolume(m_player->m_volume);
- m_qtMovie->setVisible(m_player->m_visible);
-}
-
-void MediaPlayerPrivate::play()
-{
- if (!m_qtMovie)
- return;
- m_startedPlaying = true;
-#if DRAW_FRAME_RATE
- m_frameCountWhilePlaying = 0;
-#endif
-
- m_qtMovie->play();
- startEndPointTimerIfNeeded();
-}
-
-void MediaPlayerPrivate::pause()
-{
- if (!m_qtMovie)
- return;
- m_startedPlaying = false;
-#if DRAW_FRAME_RATE
- m_timeStoppedPlaying = GetTickCount();
-#endif
- m_qtMovie->pause();
- m_endPointTimer.stop();
-}
-
-float MediaPlayerPrivate::duration() const
-{
- if (!m_qtMovie)
- return 0;
- return m_qtMovie->duration();
-}
-
-float MediaPlayerPrivate::currentTime() const
-{
- if (!m_qtMovie)
- return 0;
- return min(m_qtMovie->currentTime(), m_endTime);
-}
-
-void MediaPlayerPrivate::seek(float time)
-{
- cancelSeek();
-
- if (!m_qtMovie)
- return;
-
- if (time > duration())
- time = duration();
-
- m_seekTo = time;
- if (maxTimeLoaded() >= m_seekTo)
- doSeek();
- else
- m_seekTimer.start(0, 0.5f);
-}
-
-void MediaPlayerPrivate::doSeek()
-{
- float oldRate = m_qtMovie->rate();
- m_qtMovie->setRate(0);
- m_qtMovie->setCurrentTime(m_seekTo);
- float timeAfterSeek = currentTime();
- // restore playback only if not at end, othewise QTMovie will loop
- if (timeAfterSeek < duration() && timeAfterSeek < m_endTime)
- m_qtMovie->setRate(oldRate);
- cancelSeek();
-}
-
-void MediaPlayerPrivate::cancelSeek()
-{
- m_seekTo = -1;
- m_seekTimer.stop();
-}
-
-void MediaPlayerPrivate::seekTimerFired(Timer<MediaPlayerPrivate>*)
-{
- if (!m_qtMovie || !seeking() || currentTime() == m_seekTo) {
- cancelSeek();
- updateStates();
- m_player->timeChanged();
- return;
- }
-
- if (maxTimeLoaded() >= m_seekTo)
- doSeek();
- else {
- MediaPlayer::NetworkState state = networkState();
- if (state == MediaPlayer::Empty || state == MediaPlayer::Loaded) {
- cancelSeek();
- updateStates();
- m_player->timeChanged();
- }
- }
-}
-
-void MediaPlayerPrivate::setEndTime(float time)
-{
- m_endTime = time;
- startEndPointTimerIfNeeded();
-}
-
-void MediaPlayerPrivate::startEndPointTimerIfNeeded()
-{
- if (m_endTime < duration() && m_startedPlaying && !m_endPointTimer.isActive())
- m_endPointTimer.startRepeating(endPointTimerInterval);
-}
-
-void MediaPlayerPrivate::endPointTimerFired(Timer<MediaPlayerPrivate>*)
-{
- float time = currentTime();
- if (time >= m_endTime) {
- pause();
- didEnd();
- }
-}
-
-bool MediaPlayerPrivate::paused() const
-{
- if (!m_qtMovie)
- return true;
- return m_qtMovie->rate() == 0.0f;
-}
-
-bool MediaPlayerPrivate::seeking() const
-{
- if (!m_qtMovie)
- return false;
- return m_seekTo >= 0;
-}
-
-IntSize MediaPlayerPrivate::naturalSize() const
-{
- if (!m_qtMovie)
- return IntSize();
- int width;
- int height;
- m_qtMovie->getNaturalSize(width, height);
- return IntSize(width, height);
-}
-
-bool MediaPlayerPrivate::hasVideo() const
-{
- // This is not used at the moment
- return true;
-}
-
-void MediaPlayerPrivate::setVolume(float volume)
-{
- if (!m_qtMovie)
- return;
- m_qtMovie->setVolume(volume);
-}
-
-void MediaPlayerPrivate::setRate(float rate)
-{
- if (!m_qtMovie)
- return;
- if (!paused())
- m_qtMovie->setRate(rate);
-}
-
-int MediaPlayerPrivate::dataRate() const
-{
- // This is not used at the moment
- return 0;
-}
-
-float MediaPlayerPrivate::maxTimeBuffered() const
-{
- // rtsp streams are not buffered
- return m_isStreaming ? 0 : maxTimeLoaded();
-}
-
-float MediaPlayerPrivate::maxTimeSeekable() const
-{
- // infinite duration means live stream
- return !isfinite(duration()) ? 0 : maxTimeLoaded();
-}
-
-float MediaPlayerPrivate::maxTimeLoaded() const
-{
- if (!m_qtMovie)
- return 0;
- return m_qtMovie->maxTimeLoaded();
-}
-
-unsigned MediaPlayerPrivate::bytesLoaded() const
-{
- if (!m_qtMovie)
- return 0;
- float dur = duration();
- float maxTime = maxTimeLoaded();
- if (!dur)
- return 0;
- return totalBytes() * maxTime / dur;
-}
-
-bool MediaPlayerPrivate::totalBytesKnown() const
-{
- return totalBytes() > 0;
-}
-
-unsigned MediaPlayerPrivate::totalBytes() const
-{
- if (!m_qtMovie)
- return 0;
- return m_qtMovie->dataSize();
-}
-
-void MediaPlayerPrivate::cancelLoad()
-{
- if (m_networkState < MediaPlayer::Loading || m_networkState == MediaPlayer::Loaded)
- return;
-
- // Cancel the load by destroying the movie.
- m_qtMovie.clear();
-
- updateStates();
-}
-
-void MediaPlayerPrivate::updateStates()
-{
- MediaPlayer::NetworkState oldNetworkState = m_networkState;
- MediaPlayer::ReadyState oldReadyState = m_readyState;
-
- long loadState = m_qtMovie ? m_qtMovie->loadState() : QTMovieLoadStateError;
-
- if (loadState >= QTMovieLoadStateLoaded && m_networkState < MediaPlayer::LoadedMetaData && !m_player->inMediaDocument()) {
- unsigned enabledTrackCount;
- m_qtMovie->disableUnsupportedTracks(enabledTrackCount);
- // FIXME: We should differentiate between load errors and decode errors <rdar://problem/5605692>
- if (!enabledTrackCount)
- loadState = QTMovieLoadStateError;
- }
-
- // "Loaded" is reserved for fully buffered movies, never the case when streaming
- if (loadState >= QTMovieLoadStateComplete && !m_isStreaming) {
- if (m_networkState < MediaPlayer::Loaded)
- m_networkState = MediaPlayer::Loaded;
- m_readyState = MediaPlayer::CanPlayThrough;
- } else if (loadState >= QTMovieLoadStatePlaythroughOK) {
- if (m_networkState < MediaPlayer::LoadedFirstFrame && !seeking())
- m_networkState = MediaPlayer::LoadedFirstFrame;
- m_readyState = MediaPlayer::CanPlayThrough;
- } else if (loadState >= QTMovieLoadStatePlayable) {
- if (m_networkState < MediaPlayer::LoadedFirstFrame && !seeking())
- m_networkState = MediaPlayer::LoadedFirstFrame;
- m_readyState = currentTime() < maxTimeLoaded() ? MediaPlayer::CanPlay : MediaPlayer::DataUnavailable;
- } else if (loadState >= QTMovieLoadStateLoaded) {
- if (m_networkState < MediaPlayer::LoadedMetaData)
- m_networkState = MediaPlayer::LoadedMetaData;
- m_readyState = MediaPlayer::DataUnavailable;
- } else if (loadState > QTMovieLoadStateError) {
- if (m_networkState < MediaPlayer::Loading)
- m_networkState = MediaPlayer::Loading;
- m_readyState = MediaPlayer::DataUnavailable;
- } else {
- m_networkState = MediaPlayer::LoadFailed;
- m_readyState = MediaPlayer::DataUnavailable;
- }
-
- if (seeking())
- m_readyState = MediaPlayer::DataUnavailable;
-
- if (m_networkState != oldNetworkState)
- m_player->networkStateChanged();
- if (m_readyState != oldReadyState)
- m_player->readyStateChanged();
-}
-
-
-void MediaPlayerPrivate::didEnd()
-{
- m_endPointTimer.stop();
- m_startedPlaying = false;
-#if DRAW_FRAME_RATE
- m_timeStoppedPlaying = GetTickCount();
-#endif
- updateStates();
- m_player->timeChanged();
-}
-
-void MediaPlayerPrivate::setRect(const IntRect& r)
-{
- if (m_qtMovie)
- m_qtMovie->setSize(r.width(), r.height());
-}
-
-void MediaPlayerPrivate::setVisible(bool b)
-{
- if (!m_qtMovie)
- return;
- m_qtMovie->setVisible(b);
-}
-
-void MediaPlayerPrivate::paint(GraphicsContext* p, const IntRect& r)
-{
- if (p->paintingDisabled() || !m_qtMovie)
- return;
- HDC hdc = p->getWindowsContext(r);
- m_qtMovie->paint(hdc, r.x(), r.y());
- p->releaseWindowsContext(hdc, r);
-
-#if DRAW_FRAME_RATE
- if (m_frameCountWhilePlaying > 10) {
- Frame* frame = m_player->m_frameView ? m_player->m_frameView->frame() : NULL;
- Document* document = frame ? frame->document() : NULL;
- RenderObject* renderer = document ? document->renderer() : NULL;
- RenderStyle* styleToUse = renderer ? renderer->style() : NULL;
- if (styleToUse) {
- double frameRate = (m_frameCountWhilePlaying - 1) / (0.001 * ( m_startedPlaying ? (GetTickCount() - m_timeStartedPlaying) :
- (m_timeStoppedPlaying - m_timeStartedPlaying) ));
- String text = String::format("%1.2f", frameRate);
- TextRun textRun(text.characters(), text.length());
- const Color color(255, 0, 0);
- p->save();
- p->translate(r.x(), r.y() + r.height());
- p->setFont(styleToUse->font());
- p->setStrokeColor(color);
- p->setStrokeStyle(SolidStroke);
- p->setStrokeThickness(1.0f);
- p->setFillColor(color);
- p->drawText(textRun, IntPoint(2, -3));
- p->restore();
- }
- }
-#endif
-}
-
-void MediaPlayerPrivate::getSupportedTypes(HashSet<String>& types)
-{
- unsigned count = QTMovieWin::countSupportedTypes();
- for (unsigned n = 0; n < count; n++) {
- const UChar* character;
- unsigned len;
- QTMovieWin::getSupportedType(n, character, len);
- if (len)
- types.add(String(character, len));
- }
-}
-
-bool MediaPlayerPrivate::isAvailable()
-{
- return QTMovieWin::initializeQuickTime();
-}
-
-void MediaPlayerPrivate::movieEnded(QTMovieWin* movie)
-{
- ASSERT(m_qtMovie.get() == movie);
- didEnd();
-}
-
-void MediaPlayerPrivate::movieLoadStateChanged(QTMovieWin* movie)
-{
- ASSERT(m_qtMovie.get() == movie);
- updateStates();
-}
-
-void MediaPlayerPrivate::movieTimeChanged(QTMovieWin* movie)
-{
- ASSERT(m_qtMovie.get() == movie);
- updateStates();
- m_player->timeChanged();
-}
-
-void MediaPlayerPrivate::movieNewImageAvailable(QTMovieWin* movie)
-{
- ASSERT(m_qtMovie.get() == movie);
-#if DRAW_FRAME_RATE
- if (m_startedPlaying) {
- m_frameCountWhilePlaying++;
- // to eliminate preroll costs from our calculation,
- // our frame rate calculation excludes the first frame drawn after playback starts
- if (1==m_frameCountWhilePlaying)
- m_timeStartedPlaying = GetTickCount();
- }
-#endif
- m_player->repaint();
-}
-
-}
-
-#endif
-
diff --git a/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeWin.h b/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeWin.h
deleted file mode 100644
index c4c893c..0000000
--- a/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeWin.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef MediaPlayerPrivateQTKit_h
-#define MediaPlayerPrivateQTKit_h
-
-#if ENABLE(VIDEO)
-
-#include "MediaPlayer.h"
-#include "Timer.h"
-#include <QTMovieWin.h>
-#include <wtf/OwnPtr.h>
-
-#ifndef DRAW_FRAME_RATE
-#define DRAW_FRAME_RATE 0
-#endif
-
-namespace WebCore {
-
-class GraphicsContext;
-class IntSize;
-class IntRect;
-class String;
-
-class MediaPlayerPrivate : QTMovieWinClient, Noncopyable {
-public:
- MediaPlayerPrivate(MediaPlayer*);
- ~MediaPlayerPrivate();
-
- IntSize naturalSize() const;
- bool hasVideo() const;
-
- void load(const String& url);
- void cancelLoad();
-
- void play();
- void pause();
-
- bool paused() const;
- bool seeking() const;
-
- float duration() const;
- float currentTime() const;
- void seek(float time);
- void setEndTime(float);
-
- void setRate(float);
- void setVolume(float);
-
- int dataRate() const;
-
- MediaPlayer::NetworkState networkState() const { return m_networkState; }
- MediaPlayer::ReadyState readyState() const { return m_readyState; }
-
- float maxTimeBuffered() const;
- float maxTimeSeekable() const;
- unsigned bytesLoaded() const;
- bool totalBytesKnown() const;
- unsigned totalBytes() const;
-
- void setVisible(bool);
- void setRect(const IntRect&);
-
- void loadStateChanged();
- void didEnd();
-
- void paint(GraphicsContext*, const IntRect&);
-
- static void getSupportedTypes(HashSet<String>& types);
- static bool isAvailable();
-
-private:
- void updateStates();
- void doSeek();
- void cancelSeek();
- void seekTimerFired(Timer<MediaPlayerPrivate>*);
- void endPointTimerFired(Timer<MediaPlayerPrivate>*);
- float maxTimeLoaded() const;
- void startEndPointTimerIfNeeded();
-
- virtual void movieEnded(QTMovieWin*);
- virtual void movieLoadStateChanged(QTMovieWin*);
- virtual void movieTimeChanged(QTMovieWin*);
- virtual void movieNewImageAvailable(QTMovieWin*);
-
- MediaPlayer* m_player;
- OwnPtr<QTMovieWin> m_qtMovie;
- float m_seekTo;
- float m_endTime;
- Timer<MediaPlayerPrivate> m_seekTimer;
- Timer<MediaPlayerPrivate> m_endPointTimer;
- MediaPlayer::NetworkState m_networkState;
- MediaPlayer::ReadyState m_readyState;
- bool m_startedPlaying;
- bool m_isStreaming;
-#if DRAW_FRAME_RATE
- int m_frameCountWhilePlaying;
- int m_timeStartedPlaying;
- int m_timeStoppedPlaying;
-#endif
-};
-
-}
-
-#endif
-#endif
diff --git a/WebCore/platform/graphics/win/OpenTypeUtilities.cpp b/WebCore/platform/graphics/win/OpenTypeUtilities.cpp
deleted file mode 100644
index 1951320..0000000
--- a/WebCore/platform/graphics/win/OpenTypeUtilities.cpp
+++ /dev/null
@@ -1,387 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "OpenTypeUtilities.h"
-
-#include "SharedBuffer.h"
-
-namespace WebCore {
-
-struct BigEndianUShort {
- operator unsigned short() const { return (v & 0x00ff) << 8 | v >> 8; }
- BigEndianUShort(unsigned short u) : v((u & 0x00ff) << 8 | u >> 8) { }
- unsigned short v;
-};
-
-struct BigEndianULong {
- operator unsigned() const { return (v & 0xff) << 24 | (v & 0xff00) << 8 | (v & 0xff0000) >> 8 | v >> 24; }
- BigEndianULong(unsigned u) : v((u & 0xff) << 24 | (u & 0xff00) << 8 | (u & 0xff0000) >> 8 | u >> 24) { }
- unsigned v;
-};
-
-#pragma pack(1)
-
-struct EOTPrefix {
- unsigned eotSize;
- unsigned fontDataSize;
- unsigned version;
- unsigned flags;
- UInt8 fontPANOSE[10];
- UInt8 charset;
- UInt8 italic;
- unsigned weight;
- unsigned short fsType;
- unsigned short magicNumber;
- unsigned unicodeRange[4];
- unsigned codePageRange[2];
- unsigned checkSumAdjustment;
- unsigned reserved[4];
- unsigned short padding1;
-};
-
-struct TableDirectoryEntry {
- BigEndianULong tag;
- BigEndianULong checkSum;
- BigEndianULong offset;
- BigEndianULong length;
-};
-
-struct sfntHeader {
- Fixed version;
- BigEndianUShort numTables;
- BigEndianUShort searchRange;
- BigEndianUShort entrySelector;
- BigEndianUShort rangeShift;
- TableDirectoryEntry tables[1];
-};
-
-struct OS2Table {
- BigEndianUShort version;
- BigEndianUShort avgCharWidth;
- BigEndianUShort weightClass;
- BigEndianUShort widthClass;
- BigEndianUShort fsType;
- BigEndianUShort subscriptXSize;
- BigEndianUShort subscriptYSize;
- BigEndianUShort subscriptXOffset;
- BigEndianUShort subscriptYOffset;
- BigEndianUShort superscriptXSize;
- BigEndianUShort superscriptYSize;
- BigEndianUShort superscriptXOffset;
- BigEndianUShort superscriptYOffset;
- BigEndianUShort strikeoutSize;
- BigEndianUShort strikeoutPosition;
- BigEndianUShort familyClass;
- UInt8 panose[10];
- BigEndianULong unicodeRange[4];
- UInt8 vendID[4];
- BigEndianUShort fsSelection;
- BigEndianUShort firstCharIndex;
- BigEndianUShort lastCharIndex;
- BigEndianUShort typoAscender;
- BigEndianUShort typoDescender;
- BigEndianUShort typoLineGap;
- BigEndianUShort winAscent;
- BigEndianUShort winDescent;
- BigEndianULong codePageRange[2];
- BigEndianUShort xHeight;
- BigEndianUShort capHeight;
- BigEndianUShort defaultChar;
- BigEndianUShort breakChar;
- BigEndianUShort maxContext;
-};
-
-struct headTable {
- Fixed version;
- Fixed fontRevision;
- BigEndianULong checkSumAdjustment;
- BigEndianULong magicNumber;
- BigEndianUShort flags;
- BigEndianUShort unitsPerEm;
- long long created;
- long long modified;
- BigEndianUShort xMin;
- BigEndianUShort xMax;
- BigEndianUShort yMin;
- BigEndianUShort yMax;
- BigEndianUShort macStyle;
- BigEndianUShort lowestRectPPEM;
- BigEndianUShort fontDirectionHint;
- BigEndianUShort indexToLocFormat;
- BigEndianUShort glyphDataFormat;
-};
-
-struct nameRecord {
- BigEndianUShort platformID;
- BigEndianUShort encodingID;
- BigEndianUShort languageID;
- BigEndianUShort nameID;
- BigEndianUShort length;
- BigEndianUShort offset;
-};
-
-struct nameTable {
- BigEndianUShort format;
- BigEndianUShort count;
- BigEndianUShort stringOffset;
- nameRecord nameRecords[1];
-};
-
-#pragma pack()
-
-static void appendBigEndianStringToEOTHeader(Vector<UInt8, 512>& eotHeader, const BigEndianUShort* string, unsigned short length)
-{
- size_t size = eotHeader.size();
- eotHeader.resize(size + length + 2 * sizeof(unsigned short));
- UChar* dst = reinterpret_cast<UChar*>(eotHeader.data() + size);
- unsigned i = 0;
- dst[i++] = length;
- unsigned numCharacters = length / 2;
- for (unsigned j = 0; j < numCharacters; j++)
- dst[i++] = string[j];
- dst[i] = 0;
-}
-
-bool getEOTHeader(SharedBuffer* fontData, Vector<UInt8, 512>& eotHeader, size_t& overlayDst, size_t& overlaySrc, size_t& overlayLength)
-{
- overlayDst = 0;
- overlaySrc = 0;
- overlayLength = 0;
-
- size_t dataLength = fontData->size();
- const char* data = fontData->data();
-
- eotHeader.resize(sizeof(EOTPrefix));
- EOTPrefix* prefix = reinterpret_cast<EOTPrefix*>(eotHeader.data());
-
- prefix->fontDataSize = dataLength;
- prefix->version = 0x00020001;
- prefix->flags = 0;
-
- if (dataLength < offsetof(sfntHeader, tables))
- return false;
-
- const sfntHeader* sfnt = reinterpret_cast<const sfntHeader*>(data);
-
- if (dataLength < offsetof(sfntHeader, tables) + sfnt->numTables * sizeof(TableDirectoryEntry))
- return false;
-
- bool haveOS2 = false;
- bool haveHead = false;
- bool haveName = false;
-
- const BigEndianUShort* familyName = 0;
- unsigned short familyNameLength = 0;
- const BigEndianUShort* subfamilyName = 0;
- unsigned short subfamilyNameLength = 0;
- const BigEndianUShort* fullName = 0;
- unsigned short fullNameLength = 0;
- const BigEndianUShort* versionString = 0;
- unsigned short versionStringLength = 0;
-
- for (unsigned i = 0; i < sfnt->numTables; i++) {
- unsigned tableOffset = sfnt->tables[i].offset;
- unsigned tableLength = sfnt->tables[i].length;
-
- if (dataLength < tableOffset || dataLength < tableLength || dataLength < tableOffset + tableLength)
- return false;
-
- unsigned tableTag = sfnt->tables[i].tag;
- switch (tableTag) {
- case 'OS/2':
- {
- if (dataLength < tableOffset + sizeof(OS2Table))
- return false;
-
- haveOS2 = true;
- const OS2Table* OS2 = reinterpret_cast<const OS2Table*>(data + tableOffset);
- for (unsigned j = 0; j < 10; j++)
- prefix->fontPANOSE[j] = OS2->panose[j];
- prefix->italic = OS2->fsSelection & 0x01;
- prefix->weight = OS2->weightClass;
- // FIXME: Should use OS2->fsType, but some TrueType fonts set it to an over-restrictive value.
- // Since ATS does not enforce this on Mac OS X, we do not enforce it either.
- prefix->fsType = 0;
- for (unsigned j = 0; j < 4; j++)
- prefix->unicodeRange[j] = OS2->unicodeRange[j];
- for (unsigned j = 0; j < 2; j++)
- prefix->codePageRange[j] = OS2->codePageRange[j];
- break;
- }
- case 'head':
- {
- if (dataLength < tableOffset + sizeof(headTable))
- return false;
-
- haveHead = true;
- const headTable* head = reinterpret_cast<const headTable*>(data + tableOffset);
- prefix->checkSumAdjustment = head->checkSumAdjustment;
- break;
- }
- case 'name':
- {
- if (dataLength < tableOffset + offsetof(nameTable, nameRecords))
- return false;
-
- haveName = true;
- const nameTable* name = reinterpret_cast<const nameTable*>(data + tableOffset);
- for (int j = 0; j < name->count; j++) {
- if (dataLength < tableOffset + offsetof(nameTable, nameRecords) + (j + 1) * sizeof(nameRecord))
- return false;
- if (name->nameRecords[j].platformID == 3 && name->nameRecords[j].encodingID == 1 && name->nameRecords[j].languageID == 0x0409) {
- if (dataLength < tableOffset + name->stringOffset + name->nameRecords[j].offset + name->nameRecords[j].length)
- return false;
-
- unsigned short nameLength = name->nameRecords[j].length;
- const BigEndianUShort* nameString = reinterpret_cast<const BigEndianUShort*>(data + tableOffset + name->stringOffset + name->nameRecords[j].offset);
-
- switch (name->nameRecords[j].nameID) {
- case 1:
- familyNameLength = nameLength;
- familyName = nameString;
- break;
- case 2:
- subfamilyNameLength = nameLength;
- subfamilyName = nameString;
- break;
- case 4:
- fullNameLength = nameLength;
- fullName = nameString;
- break;
- case 5:
- versionStringLength = nameLength;
- versionString = nameString;
- break;
- default:
- break;
- }
- }
- }
- break;
- }
- default:
- break;
- }
- if (haveOS2 && haveHead && haveName)
- break;
- }
-
- prefix->charset = DEFAULT_CHARSET;
- prefix->magicNumber = 0x504c;
- prefix->reserved[0] = 0;
- prefix->reserved[1] = 0;
- prefix->reserved[2] = 0;
- prefix->reserved[3] = 0;
- prefix->padding1 = 0;
-
- appendBigEndianStringToEOTHeader(eotHeader, familyName, familyNameLength);
- appendBigEndianStringToEOTHeader(eotHeader, subfamilyName, subfamilyNameLength);
- appendBigEndianStringToEOTHeader(eotHeader, versionString, versionStringLength);
-
- // If possible, ensure that the family name is a prefix of the full name.
- if (fullNameLength >= familyNameLength && memcmp(familyName, fullName, familyNameLength)) {
- overlaySrc = reinterpret_cast<const char*>(fullName) - data;
- overlayDst = reinterpret_cast<const char*>(familyName) - data;
- overlayLength = familyNameLength;
- }
-
- appendBigEndianStringToEOTHeader(eotHeader, fullName, fullNameLength);
-
- unsigned short padding = 0;
- eotHeader.append(reinterpret_cast<UInt8*>(&padding), sizeof(padding));
-
- prefix->eotSize = eotHeader.size() + fontData->size();
-
- return true;
-}
-
-HANDLE renameAndActivateFont(SharedBuffer* fontData, const String& fontName)
-{
- size_t originalDataSize = fontData->size();
- const sfntHeader* sfnt = reinterpret_cast<const sfntHeader*>(fontData->data());
-
- unsigned t;
- for (t = 0; t < sfnt->numTables; ++t) {
- if (sfnt->tables[t].tag == 'name')
- break;
- }
- if (t == sfnt->numTables)
- return 0;
-
- const int nameRecordCount = 5;
-
- // Rounded up to a multiple of 4 to simplify the checksum calculation.
- size_t nameTableSize = ((offsetof(nameTable, nameRecords) + nameRecordCount * sizeof(nameRecord) + fontName.length() * sizeof(UChar)) & ~3) + 4;
-
- Vector<char> rewrittenFontData(fontData->size() + nameTableSize);
- char* data = rewrittenFontData.data();
- memcpy(data, fontData->data(), originalDataSize);
-
- // Make the table directory entry point to the new 'name' table.
- sfntHeader* rewrittenSfnt = reinterpret_cast<sfntHeader*>(data);
- rewrittenSfnt->tables[t].length = nameTableSize;
- rewrittenSfnt->tables[t].offset = originalDataSize;
-
- // Write the new 'name' table after the original font data.
- nameTable* name = reinterpret_cast<nameTable*>(data + originalDataSize);
- name->format = 0;
- name->count = nameRecordCount;
- name->stringOffset = offsetof(nameTable, nameRecords) + nameRecordCount * sizeof(nameRecord);
- for (unsigned i = 0; i < nameRecordCount; ++i) {
- name->nameRecords[i].platformID = 3;
- name->nameRecords[i].encodingID = 1;
- name->nameRecords[i].languageID = 0x0409;
- name->nameRecords[i].offset = 0;
- name->nameRecords[i].length = fontName.length() * sizeof(UChar);
- }
-
- // The required 'name' record types: Family, Style, Unique, Full and PostScript.
- name->nameRecords[0].nameID = 1;
- name->nameRecords[1].nameID = 2;
- name->nameRecords[2].nameID = 3;
- name->nameRecords[3].nameID = 4;
- name->nameRecords[4].nameID = 6;
-
- for (unsigned i = 0; i < fontName.length(); ++i)
- reinterpret_cast<BigEndianUShort*>(data + originalDataSize + name->stringOffset)[i] = fontName[i];
-
- // Update the table checksum in the directory entry.
- rewrittenSfnt->tables[t].checkSum = 0;
- for (unsigned i = 0; i * sizeof(BigEndianULong) < nameTableSize; ++i)
- rewrittenSfnt->tables[t].checkSum = rewrittenSfnt->tables[t].checkSum + reinterpret_cast<BigEndianULong*>(name)[i];
-
- DWORD numFonts = 0;
- HANDLE fontHandle = AddFontMemResourceEx(data, originalDataSize + nameTableSize, 0, &numFonts);
-
- if (fontHandle && numFonts != 1) {
- RemoveFontMemResourceEx(fontHandle);
- return 0;
- }
-
- return fontHandle;
-}
-
-}
diff --git a/WebCore/platform/graphics/win/OpenTypeUtilities.h b/WebCore/platform/graphics/win/OpenTypeUtilities.h
deleted file mode 100644
index ab35551..0000000
--- a/WebCore/platform/graphics/win/OpenTypeUtilities.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef OpenTypeUtilities_h
-#define OpenTypeUtilities_h
-
-#include "PlatformString.h"
-#include <wtf/Forward.h>
-
-namespace WebCore {
-
-class SharedBuffer;
-
-bool getEOTHeader(SharedBuffer* fontData, Vector<UInt8, 512>& eotHeader, size_t& overlayDst, size_t& overlaySrc, size_t& overlayLength);
-HANDLE renameAndActivateFont(SharedBuffer*, const String&);
-
-} // namespace WebCore
-
-#endif // OpenTypeUtilities_h
diff --git a/WebCore/platform/graphics/win/QTMovieWin.cpp b/WebCore/platform/graphics/win/QTMovieWin.cpp
deleted file mode 100644
index 8eee41b..0000000
--- a/WebCore/platform/graphics/win/QTMovieWin.cpp
+++ /dev/null
@@ -1,875 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "config.h"
-
-#include <windows.h>
-
-#include "QTMovieWin.h"
-
-// Put Movies.h first so build failures here point clearly to QuickTime
-#include <Movies.h>
-#include <QuickTimeComponents.h>
-#include <GXMath.h>
-#include <QTML.h>
-
-#include "QTMovieWinTimer.h"
-
-#include <wtf/Assertions.h>
-#include <wtf/HashSet.h>
-#include <wtf/Noncopyable.h>
-#include <wtf/Vector.h>
-
-using namespace std;
-
-static const long minimumQuickTimeVersion = 0x07300000; // 7.3
-
-// Resizing GWorlds is slow, give them a minimum size so size of small
-// videos can be animated smoothly
-static const int cGWorldMinWidth = 640;
-static const int cGWorldMinHeight = 360;
-
-static const float cNonContinuousTimeChange = 0.2f;
-
-union UppParam {
- long longValue;
- void* ptr;
-};
-
-static MovieDrawingCompleteUPP gMovieDrawingCompleteUPP = 0;
-static HashSet<QTMovieWinPrivate*>* gTaskList;
-static Vector<CFStringRef>* gSupportedTypes = 0;
-static SInt32 quickTimeVersion = 0;
-
-static void updateTaskTimer(int maxInterval = 1000)
-{
- if (!gTaskList->size()) {
- stopSharedTimer();
- return;
- }
-
- long intervalInMS;
- QTGetTimeUntilNextTask(&intervalInMS, 1000);
- if (intervalInMS > maxInterval)
- intervalInMS = maxInterval;
- setSharedTimerFireDelay(static_cast<float>(intervalInMS) / 1000);
-}
-
-class QTMovieWinPrivate : Noncopyable {
-public:
- QTMovieWinPrivate();
- ~QTMovieWinPrivate();
- void task();
- void startTask();
- void endTask();
-
- void createMovieController();
- void registerDrawingCallback();
- void drawingComplete();
- void updateGWorld();
- void createGWorld();
- void deleteGWorld();
- void clearGWorld();
-
- void setSize(int, int);
-
- QTMovieWin* m_movieWin;
- Movie m_movie;
- MovieController m_movieController;
- bool m_tasking;
- QTMovieWinClient* m_client;
- long m_loadState;
- bool m_ended;
- bool m_seeking;
- float m_lastMediaTime;
- double m_lastLoadStateCheckTime;
- int m_width;
- int m_height;
- bool m_visible;
- GWorldPtr m_gWorld;
- int m_gWorldWidth;
- int m_gWorldHeight;
- GWorldPtr m_savedGWorld;
- long m_loadError;
-};
-
-QTMovieWinPrivate::QTMovieWinPrivate()
- : m_movieWin(0)
- , m_movie(0)
- , m_movieController(0)
- , m_tasking(false)
- , m_client(0)
- , m_loadState(0)
- , m_ended(false)
- , m_seeking(false)
- , m_lastMediaTime(0)
- , m_lastLoadStateCheckTime(0)
- , m_width(0)
- , m_height(0)
- , m_visible(false)
- , m_gWorld(0)
- , m_gWorldWidth(0)
- , m_gWorldHeight(0)
- , m_savedGWorld(0)
- , m_loadError(0)
-{
-}
-
-QTMovieWinPrivate::~QTMovieWinPrivate()
-{
- endTask();
- if (m_gWorld)
- deleteGWorld();
- if (m_movieController)
- DisposeMovieController(m_movieController);
- if (m_movie)
- DisposeMovie(m_movie);
-}
-
-static void taskTimerFired()
-{
- // The hash content might change during task()
- Vector<QTMovieWinPrivate*> tasks;
- copyToVector(*gTaskList, tasks);
- size_t count = tasks.size();
- for (unsigned n = 0; n < count; ++n)
- tasks[n]->task();
-
- updateTaskTimer();
-}
-
-void QTMovieWinPrivate::startTask()
-{
- if (m_tasking)
- return;
- if (!gTaskList)
- gTaskList = new HashSet<QTMovieWinPrivate*>;
- gTaskList->add(this);
- m_tasking = true;
- updateTaskTimer();
-}
-
-void QTMovieWinPrivate::endTask()
-{
- if (!m_tasking)
- return;
- gTaskList->remove(this);
- m_tasking = false;
- updateTaskTimer();
-}
-
-void QTMovieWinPrivate::task()
-{
- ASSERT(m_tasking);
-
- if (!m_loadError) {
- if (m_movieController)
- MCIdle(m_movieController);
- else
- MoviesTask(m_movie, 0);
- }
-
- // GetMovieLoadState documentation says that you should not call it more often than every quarter of a second.
- if (systemTime() >= m_lastLoadStateCheckTime + 0.25 || m_loadError) {
- // If load fails QT's load state is kMovieLoadStateComplete.
- // This is different from QTKit API and seems strange.
- long loadState = m_loadError ? kMovieLoadStateError : GetMovieLoadState(m_movie);
- if (loadState != m_loadState) {
-
- // we only need to erase the movie gworld when the load state changes to loaded while it
- // is visible as the gworld is destroyed/created when visibility changes
- if (loadState >= QTMovieLoadStateLoaded && m_loadState < QTMovieLoadStateLoaded && m_visible)
- clearGWorld();
-
- m_loadState = loadState;
- if (!m_movieController && m_loadState >= kMovieLoadStateLoaded)
- createMovieController();
- m_client->movieLoadStateChanged(m_movieWin);
- }
- m_lastLoadStateCheckTime = systemTime();
- }
-
- bool ended = !!IsMovieDone(m_movie);
- if (ended != m_ended) {
- m_ended = ended;
- if (m_client && ended)
- m_client->movieEnded(m_movieWin);
- }
-
- float time = m_movieWin->currentTime();
- if (time < m_lastMediaTime || time >= m_lastMediaTime + cNonContinuousTimeChange || m_seeking) {
- m_seeking = false;
- if (m_client)
- m_client->movieTimeChanged(m_movieWin);
- }
- m_lastMediaTime = time;
-
- if (m_loadError)
- endTask();
-}
-
-void QTMovieWinPrivate::createMovieController()
-{
- Rect bounds;
- long flags;
-
- if (!m_movie)
- return;
-
- if (m_movieController)
- DisposeMovieController(m_movieController);
-
- GetMovieBox(m_movie, &bounds);
- flags = mcTopLeftMovie | mcNotVisible;
- m_movieController = NewMovieController(m_movie, &bounds, flags);
- if (!m_movieController)
- return;
-
- MCSetControllerPort(m_movieController, m_gWorld);
- MCSetControllerAttached(m_movieController, false);
-}
-
-void QTMovieWinPrivate::registerDrawingCallback()
-{
- UppParam param;
- param.ptr = this;
- SetMovieDrawingCompleteProc(m_movie, movieDrawingCallWhenChanged, gMovieDrawingCompleteUPP, param.longValue);
-}
-
-void QTMovieWinPrivate::drawingComplete()
-{
- if (!m_gWorld || m_loadState < kMovieLoadStateLoaded)
- return;
- m_client->movieNewImageAvailable(m_movieWin);
-}
-
-void QTMovieWinPrivate::updateGWorld()
-{
- bool shouldBeVisible = m_visible;
- if (!m_height || !m_width)
- shouldBeVisible = false;
-
- if (shouldBeVisible && !m_gWorld)
- createGWorld();
- else if (!shouldBeVisible && m_gWorld)
- deleteGWorld();
- else if (m_gWorld && (m_width > m_gWorldWidth || m_height > m_gWorldHeight)) {
- // need a bigger, better gWorld
- deleteGWorld();
- createGWorld();
- }
-}
-
-void QTMovieWinPrivate::createGWorld()
-{
- ASSERT(!m_gWorld);
- if (!m_movie)
- return;
-
- m_gWorldWidth = max(cGWorldMinWidth, m_width);
- m_gWorldHeight = max(cGWorldMinHeight, m_height);
- Rect bounds;
- bounds.top = 0;
- bounds.left = 0;
- bounds.right = m_gWorldWidth;
- bounds.bottom = m_gWorldHeight;
- OSErr err = QTNewGWorld(&m_gWorld, k32BGRAPixelFormat, &bounds, NULL, NULL, NULL);
- if (err)
- return;
- GetMovieGWorld(m_movie, &m_savedGWorld, 0);
- if (m_movieController)
- MCSetControllerPort(m_movieController, m_gWorld);
- SetMovieGWorld(m_movie, m_gWorld, 0);
- bounds.right = m_width;
- bounds.bottom = m_height;
- if (m_movieController)
- MCSetControllerBoundsRect(m_movieController, &bounds);
- SetMovieBox(m_movie, &bounds);
-}
-
-void QTMovieWinPrivate::clearGWorld()
-{
- if (!m_movie||!m_gWorld)
- return;
-
- GrafPtr savePort;
- GetPort(&savePort);
- MacSetPort((GrafPtr)m_gWorld);
-
- Rect bounds;
- bounds.top = 0;
- bounds.left = 0;
- bounds.right = m_gWorldWidth;
- bounds.bottom = m_gWorldHeight;
- EraseRect(&bounds);
-
- MacSetPort(savePort);
-}
-
-
-void QTMovieWinPrivate::setSize(int width, int height)
-{
- if (m_width == width && m_height == height)
- return;
- m_width = width;
- m_height = height;
- if (!m_movie)
- return;
- Rect bounds;
- bounds.top = 0;
- bounds.left = 0;
- bounds.right = width;
- bounds.bottom = height;
- if (m_movieController)
- MCSetControllerBoundsRect(m_movieController, &bounds);
- SetMovieBox(m_movie, &bounds);
- updateGWorld();
-}
-
-void QTMovieWinPrivate::deleteGWorld()
-{
- ASSERT(m_gWorld);
- if (m_movieController)
- MCSetControllerPort(m_movieController, m_savedGWorld);
- if (m_movie)
- SetMovieGWorld(m_movie, m_savedGWorld, 0);
- m_savedGWorld = 0;
- DisposeGWorld(m_gWorld);
- m_gWorld = 0;
- m_gWorldWidth = 0;
- m_gWorldHeight = 0;
-}
-
-
-QTMovieWin::QTMovieWin(QTMovieWinClient* client)
- : m_private(new QTMovieWinPrivate())
-{
- m_private->m_movieWin = this;
- m_private->m_client = client;
- initializeQuickTime();
-}
-
-QTMovieWin::~QTMovieWin()
-{
- delete m_private;
-}
-
-void QTMovieWin::play()
-{
- if (m_private->m_movieController)
- MCDoAction(m_private->m_movieController, mcActionPrerollAndPlay, (void *)GetMoviePreferredRate(m_private->m_movie));
- else
- StartMovie(m_private->m_movie);
- m_private->startTask();
-}
-
-void QTMovieWin::pause()
-{
- if (m_private->m_movieController)
- MCDoAction(m_private->m_movieController, mcActionPlay, 0);
- else
- StopMovie(m_private->m_movie);
- updateTaskTimer();
-}
-
-float QTMovieWin::rate() const
-{
- if (!m_private->m_movie)
- return 0;
- return FixedToFloat(GetMovieRate(m_private->m_movie));
-}
-
-void QTMovieWin::setRate(float rate)
-{
- if (!m_private->m_movie)
- return;
- if (m_private->m_movieController)
- MCDoAction(m_private->m_movieController, mcActionPrerollAndPlay, (void *)FloatToFixed(rate));
- else
- SetMovieRate(m_private->m_movie, FloatToFixed(rate));
- updateTaskTimer();
-}
-
-float QTMovieWin::duration() const
-{
- if (!m_private->m_movie)
- return 0;
- TimeValue val = GetMovieDuration(m_private->m_movie);
- TimeScale scale = GetMovieTimeScale(m_private->m_movie);
- return static_cast<float>(val) / scale;
-}
-
-float QTMovieWin::currentTime() const
-{
- if (!m_private->m_movie)
- return 0;
- TimeValue val = GetMovieTime(m_private->m_movie, 0);
- TimeScale scale = GetMovieTimeScale(m_private->m_movie);
- return static_cast<float>(val) / scale;
-}
-
-void QTMovieWin::setCurrentTime(float time) const
-{
- if (!m_private->m_movie)
- return;
- m_private->m_seeking = true;
- TimeScale scale = GetMovieTimeScale(m_private->m_movie);
- if (m_private->m_movieController){
- QTRestartAtTimeRecord restart = { time * scale , 0 };
- MCDoAction(m_private->m_movieController, mcActionRestartAtTime, (void *)&restart);
- } else
- SetMovieTimeValue(m_private->m_movie, TimeValue(time * scale));
- updateTaskTimer();
-}
-
-void QTMovieWin::setVolume(float volume)
-{
- if (!m_private->m_movie)
- return;
- SetMovieVolume(m_private->m_movie, static_cast<short>(volume * 256));
-}
-
-unsigned QTMovieWin::dataSize() const
-{
- if (!m_private->m_movie)
- return 0;
- return GetMovieDataSize(m_private->m_movie, 0, GetMovieDuration(m_private->m_movie));
-}
-
-float QTMovieWin::maxTimeLoaded() const
-{
- if (!m_private->m_movie)
- return 0;
- TimeValue val;
- GetMaxLoadedTimeInMovie(m_private->m_movie, &val);
- TimeScale scale = GetMovieTimeScale(m_private->m_movie);
- return static_cast<float>(val) / scale;
-}
-
-long QTMovieWin::loadState() const
-{
- return m_private->m_loadState;
-}
-
-void QTMovieWin::getNaturalSize(int& width, int& height)
-{
- Rect rect = { 0, };
-
- if (m_private->m_movie)
- GetMovieNaturalBoundsRect(m_private->m_movie, &rect);
- width = rect.right;
- height = rect.bottom;
-}
-
-void QTMovieWin::setSize(int width, int height)
-{
- m_private->setSize(width, height);
- updateTaskTimer(0);
-}
-
-void QTMovieWin::setVisible(bool b)
-{
- m_private->m_visible = b;
- m_private->updateGWorld();
-}
-
-void QTMovieWin::paint(HDC hdc, int x, int y)
-{
- if (!m_private->m_gWorld)
- return;
-
- HDC hdcSrc = static_cast<HDC>(GetPortHDC(reinterpret_cast<GrafPtr>(m_private->m_gWorld)));
- if (!hdcSrc)
- return;
-
- // FIXME: If we could determine the movie has no alpha, we could use BitBlt for those cases, which might be faster.
- BLENDFUNCTION blendFunction;
- blendFunction.BlendOp = AC_SRC_OVER;
- blendFunction.BlendFlags = 0;
- blendFunction.SourceConstantAlpha = 255;
- blendFunction.AlphaFormat = AC_SRC_ALPHA;
- AlphaBlend(hdc, x, y, m_private->m_width, m_private->m_height, hdcSrc,
- 0, 0, m_private->m_width, m_private->m_height, blendFunction);
-}
-
-void QTMovieWin::load(const UChar* url, int len)
-{
- if (m_private->m_movie) {
- m_private->endTask();
- if (m_private->m_gWorld)
- m_private->deleteGWorld();
- if (m_private->m_movieController)
- DisposeMovieController(m_private->m_movieController);
- m_private->m_movieController = 0;
- DisposeMovie(m_private->m_movie);
- m_private->m_movie = 0;
- }
-
- // Define a property array for NewMovieFromProperties. 8 should be enough for our needs.
- QTNewMoviePropertyElement movieProps[8];
- ItemCount moviePropCount = 0;
-
- bool boolTrue = true;
-
- // Create a URL data reference of type CFURL
- CFStringRef urlStringRef = CFStringCreateWithCharacters(kCFAllocatorDefault, reinterpret_cast<const UniChar*>(url), len);
-
- // Disable streaming support for now.
- if (CFStringHasPrefix(urlStringRef, CFSTR("rtsp:"))) {
- m_private->m_loadError = noMovieFound;
- goto end;
- }
-
- CFURLRef urlRef = CFURLCreateWithString(kCFAllocatorDefault, urlStringRef, 0);
-
- // Add the movie data location to the property array
- movieProps[moviePropCount].propClass = kQTPropertyClass_DataLocation;
- movieProps[moviePropCount].propID = kQTDataLocationPropertyID_CFURL;
- movieProps[moviePropCount].propValueSize = sizeof(urlRef);
- movieProps[moviePropCount].propValueAddress = &urlRef;
- movieProps[moviePropCount].propStatus = 0;
- moviePropCount++;
-
- movieProps[moviePropCount].propClass = kQTPropertyClass_MovieInstantiation;
- movieProps[moviePropCount].propID = kQTMovieInstantiationPropertyID_DontAskUnresolvedDataRefs;
- movieProps[moviePropCount].propValueSize = sizeof(boolTrue);
- movieProps[moviePropCount].propValueAddress = &boolTrue;
- movieProps[moviePropCount].propStatus = 0;
- moviePropCount++;
-
- movieProps[moviePropCount].propClass = kQTPropertyClass_MovieInstantiation;
- movieProps[moviePropCount].propID = kQTMovieInstantiationPropertyID_AsyncOK;
- movieProps[moviePropCount].propValueSize = sizeof(boolTrue);
- movieProps[moviePropCount].propValueAddress = &boolTrue;
- movieProps[moviePropCount].propStatus = 0;
- moviePropCount++;
-
- movieProps[moviePropCount].propClass = kQTPropertyClass_NewMovieProperty;
- movieProps[moviePropCount].propID = kQTNewMoviePropertyID_Active;
- movieProps[moviePropCount].propValueSize = sizeof(boolTrue);
- movieProps[moviePropCount].propValueAddress = &boolTrue;
- movieProps[moviePropCount].propStatus = 0;
- moviePropCount++;
-
- movieProps[moviePropCount].propClass = kQTPropertyClass_NewMovieProperty;
- movieProps[moviePropCount].propID = kQTNewMoviePropertyID_DontInteractWithUser;
- movieProps[moviePropCount].propValueSize = sizeof(boolTrue);
- movieProps[moviePropCount].propValueAddress = &boolTrue;
- movieProps[moviePropCount].propStatus = 0;
- moviePropCount++;
-
- movieProps[moviePropCount].propClass = kQTPropertyClass_MovieInstantiation;
- movieProps[moviePropCount].propID = '!url';
- movieProps[moviePropCount].propValueSize = sizeof(boolTrue);
- movieProps[moviePropCount].propValueAddress = &boolTrue;
- movieProps[moviePropCount].propStatus = 0;
- moviePropCount++;
-
- movieProps[moviePropCount].propClass = kQTPropertyClass_MovieInstantiation;
- movieProps[moviePropCount].propID = 'site';
- movieProps[moviePropCount].propValueSize = sizeof(boolTrue);
- movieProps[moviePropCount].propValueAddress = &boolTrue;
- movieProps[moviePropCount].propStatus = 0;
- moviePropCount++;
-
- m_private->m_loadError = NewMovieFromProperties(moviePropCount, movieProps, 0, NULL, &m_private->m_movie);
-
- CFRelease(urlRef);
-end:
- m_private->startTask();
- // get the load fail callback quickly
- if (m_private->m_loadError)
- updateTaskTimer(0);
- else
- m_private->registerDrawingCallback();
-
- CFRelease(urlStringRef);
-}
-
-void QTMovieWin::disableUnsupportedTracks(unsigned& enabledTrackCount)
-{
- if (!m_private->m_movie) {
- enabledTrackCount = 0;
- return;
- }
-
- static HashSet<OSType>* allowedTrackTypes = 0;
- if (!allowedTrackTypes) {
- allowedTrackTypes = new HashSet<OSType>;
- allowedTrackTypes->add(VideoMediaType);
- allowedTrackTypes->add(SoundMediaType);
- allowedTrackTypes->add(TextMediaType);
- allowedTrackTypes->add(BaseMediaType);
- allowedTrackTypes->add('clcp'); // Closed caption
- allowedTrackTypes->add('sbtl'); // Subtitle
- }
-
- long trackCount = GetMovieTrackCount(m_private->m_movie);
- enabledTrackCount = trackCount;
-
- // Track indexes are 1-based. yuck. These things must descend from old-
- // school mac resources or something.
- for (long trackIndex = 1; trackIndex <= trackCount; trackIndex++) {
- // Grab the track at the current index. If there isn't one there, then
- // we can move onto the next one.
- Track currentTrack = GetMovieIndTrack(m_private->m_movie, trackIndex);
- if (!currentTrack)
- continue;
-
- // Check to see if the track is disabled already, we should move along.
- // We don't need to re-disable it.
- if (!GetTrackEnabled(currentTrack))
- continue;
-
- // Grab the track's media. We're going to check to see if we need to
- // disable the tracks. They could be unsupported.
- Media trackMedia = GetTrackMedia(currentTrack);
- if (!trackMedia)
- continue;
-
- // Grab the media type for this track. Make sure that we don't
- // get an error in doing so. If we do, then something really funky is
- // wrong.
- OSType mediaType;
- GetMediaHandlerDescription(trackMedia, &mediaType, nil, nil);
- OSErr mediaErr = GetMoviesError();
- if (mediaErr != noErr)
- continue;
-
- if (!allowedTrackTypes->contains(mediaType)) {
- SetTrackEnabled(currentTrack, false);
- --enabledTrackCount;
- }
-
- // Grab the track reference count for chapters. This will tell us if it
- // has chapter tracks in it. If there aren't any references, then we
- // can move on the next track.
- long referenceCount = GetTrackReferenceCount(currentTrack, kTrackReferenceChapterList);
- if (referenceCount <= 0)
- continue;
-
- long referenceIndex = 0;
- while (1) {
- // If we get nothing here, we've overstepped our bounds and can stop
- // looking. Chapter indices here are 1-based as well - hence, the
- // pre-increment.
- referenceIndex++;
- Track chapterTrack = GetTrackReference(currentTrack, kTrackReferenceChapterList, referenceIndex);
- if (!chapterTrack)
- break;
-
- // Try to grab the media for the track.
- Media chapterMedia = GetTrackMedia(chapterTrack);
- if (!chapterMedia)
- continue;
-
- // Grab the media type for this track. Make sure that we don't
- // get an error in doing so. If we do, then something really
- // funky is wrong.
- OSType mediaType;
- GetMediaHandlerDescription(chapterMedia, &mediaType, nil, nil);
- OSErr mediaErr = GetMoviesError();
- if (mediaErr != noErr)
- continue;
-
- // Check to see if the track is a video track. We don't care about
- // other non-video tracks.
- if (mediaType != VideoMediaType)
- continue;
-
- // Check to see if the track is already disabled. If it is, we
- // should move along.
- if (!GetTrackEnabled(chapterTrack))
- continue;
-
- // Disabled the evil, evil track.
- SetTrackEnabled(chapterTrack, false);
- --enabledTrackCount;
- }
- }
-}
-
-pascal OSErr movieDrawingCompleteProc(Movie movie, long data)
-{
- UppParam param;
- param.longValue = data;
- QTMovieWinPrivate* mp = static_cast<QTMovieWinPrivate*>(param.ptr);
- if (mp)
- mp->drawingComplete();
- return 0;
-}
-
-static void initializeSupportedTypes()
-{
- if (gSupportedTypes)
- return;
-
- gSupportedTypes = new Vector<CFStringRef>;
- if (quickTimeVersion < minimumQuickTimeVersion) {
- LOG_ERROR("QuickTime version %x detected, at least %x required. Returning empty list of supported media MIME types.", quickTimeVersion, minimumQuickTimeVersion);
- return;
- }
-
- // QuickTime doesn't have an importer for video/quicktime. Add it manually.
- gSupportedTypes->append(CFSTR("video/quicktime"));
-
- for (int index = 0; index < 2; index++) {
- ComponentDescription findCD;
-
- // look at all movie importers that can import in place and are installed.
- findCD.componentType = MovieImportType;
- findCD.componentSubType = 0;
- findCD.componentManufacturer = 0;
- findCD.componentFlagsMask = cmpIsMissing | movieImportSubTypeIsFileExtension | canMovieImportInPlace | dontAutoFileMovieImport;
-
- // look at those registered by HFS file types the first time through, by file extension the second time
- findCD.componentFlags = canMovieImportInPlace | (index ? movieImportSubTypeIsFileExtension : 0);
-
- long componentCount = CountComponents(&findCD);
- if (!componentCount)
- continue;
-
- Component comp = 0;
- while (comp = FindNextComponent(comp, &findCD)) {
- // Does this component have a MIME type container?
- ComponentDescription infoCD;
- OSErr err = GetComponentInfo(comp, &infoCD, nil /*name*/, nil /*info*/, nil /*icon*/);
- if (err)
- continue;
- if (!(infoCD.componentFlags & hasMovieImportMIMEList))
- continue;
- QTAtomContainer mimeList = NULL;
- err = MovieImportGetMIMETypeList((ComponentInstance)comp, &mimeList);
- if (err || !mimeList)
- continue;
-
- // Grab every type from the container.
- QTLockContainer(mimeList);
- int typeCount = QTCountChildrenOfType(mimeList, kParentAtomIsContainer, kMimeInfoMimeTypeTag);
- for (int typeIndex = 1; typeIndex <= typeCount; typeIndex++) {
- QTAtom mimeTag = QTFindChildByIndex(mimeList, 0, kMimeInfoMimeTypeTag, typeIndex, NULL);
- if (!mimeTag)
- continue;
- char* atomData;
- long typeLength;
- if (noErr != QTGetAtomDataPtr(mimeList, mimeTag, &typeLength, &atomData))
- continue;
-
- char typeBuffer[256];
- if (typeLength >= sizeof(typeBuffer))
- continue;
- memcpy(typeBuffer, atomData, typeLength);
- typeBuffer[typeLength] = 0;
-
- // Only add "audio/..." and "video/..." types.
- if (strncmp(typeBuffer, "audio/", 6) && strncmp(typeBuffer, "video/", 6))
- continue;
-
- CFStringRef cfMimeType = CFStringCreateWithCString(NULL, typeBuffer, kCFStringEncodingUTF8);
- if (!cfMimeType)
- continue;
-
- // Only add each type once.
- bool alreadyAdded = false;
- for (int addedIndex = 0; addedIndex < gSupportedTypes->size(); addedIndex++) {
- CFStringRef type = gSupportedTypes->at(addedIndex);
- if (kCFCompareEqualTo == CFStringCompare(cfMimeType, type, kCFCompareCaseInsensitive)) {
- alreadyAdded = true;
- break;
- }
- }
- if (!alreadyAdded)
- gSupportedTypes->append(cfMimeType);
- else
- CFRelease(cfMimeType);
- }
- DisposeHandle(mimeList);
- }
- }
-}
-
-unsigned QTMovieWin::countSupportedTypes()
-{
- initializeSupportedTypes();
- return static_cast<unsigned>(gSupportedTypes->size());
-}
-
-void QTMovieWin::getSupportedType(unsigned index, const UChar*& str, unsigned& len)
-{
- initializeSupportedTypes();
- ASSERT(index < gSupportedTypes->size());
-
- // Allocate sufficient buffer to hold any MIME type
- static UniChar* staticBuffer = 0;
- if (!staticBuffer)
- staticBuffer = new UniChar[32];
-
- CFStringRef cfstr = gSupportedTypes->at(index);
- len = CFStringGetLength(cfstr);
- CFRange range = { 0, len };
- CFStringGetCharacters(cfstr, range, staticBuffer);
- str = reinterpret_cast<const UChar*>(staticBuffer);
-
-}
-
-bool QTMovieWin::initializeQuickTime()
-{
- static bool initialized = false;
- static bool initializationSucceeded = false;
- if (!initialized) {
- initialized = true;
- // Initialize and check QuickTime version
- OSErr result = InitializeQTML(0);
- if (result == noErr)
- result = Gestalt(gestaltQuickTime, &quickTimeVersion);
- if (result != noErr) {
- LOG_ERROR("No QuickTime available. Disabling <video> and <audio> support.");
- return false;
- }
- if (quickTimeVersion < minimumQuickTimeVersion) {
- LOG_ERROR("QuickTime version %x detected, at least %x required. Disabling <video> and <audio> support.", quickTimeVersion, minimumQuickTimeVersion);
- return false;
- }
- EnterMovies();
- setSharedTimerFiredFunction(taskTimerFired);
- gMovieDrawingCompleteUPP = NewMovieDrawingCompleteUPP(movieDrawingCompleteProc);
- initializationSucceeded = true;
- }
- return initializationSucceeded;
-}
-
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
-{
- switch (fdwReason) {
- case DLL_PROCESS_ATTACH:
- setSharedTimerInstanceHandle(hinstDLL);
- return TRUE;
- case DLL_PROCESS_DETACH:
- case DLL_THREAD_ATTACH:
- case DLL_THREAD_DETACH:
- return FALSE;
- }
- ASSERT_NOT_REACHED();
- return FALSE;
-}
diff --git a/WebCore/platform/graphics/win/QTMovieWin.h b/WebCore/platform/graphics/win/QTMovieWin.h
deleted file mode 100644
index e31780a..0000000
--- a/WebCore/platform/graphics/win/QTMovieWin.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef QTMovieWin_h
-#define QTMovieWin_h
-
-#include <Unicode.h>
-
-#ifdef QTMOVIEWIN_EXPORTS
-#define QTMOVIEWIN_API __declspec(dllexport)
-#else
-#define QTMOVIEWIN_API __declspec(dllimport)
-#endif
-
-class QTMovieWin;
-class QTMovieWinPrivate;
-
-class QTMovieWinClient {
-public:
- virtual void movieEnded(QTMovieWin*) = 0;
- virtual void movieLoadStateChanged(QTMovieWin*) = 0;
- virtual void movieTimeChanged(QTMovieWin*) = 0;
- virtual void movieNewImageAvailable(QTMovieWin*) = 0;
-};
-
-enum {
- QTMovieLoadStateError = -1L,
- QTMovieLoadStateLoaded = 2000L,
- QTMovieLoadStatePlayable = 10000L,
- QTMovieLoadStatePlaythroughOK = 20000L,
- QTMovieLoadStateComplete = 100000L
-};
-
-class QTMOVIEWIN_API QTMovieWin {
-public:
- static bool initializeQuickTime();
-
- QTMovieWin(QTMovieWinClient*);
- ~QTMovieWin();
-
- void load(const UChar* url, int len);
- long loadState() const;
- float maxTimeLoaded() const;
-
- void play();
- void pause();
-
- float rate() const;
- void setRate(float);
-
- float duration() const;
- float currentTime() const;
- void setCurrentTime(float) const;
-
- void setVolume(float);
-
- unsigned dataSize() const;
-
- void getNaturalSize(int& width, int& height);
- void setSize(int width, int height);
-
- void setVisible(bool);
- void paint(HDC, int x, int y);
-
- void disableUnsupportedTracks(unsigned& enabledTrackCount);
-
- static unsigned countSupportedTypes();
- static void getSupportedType(unsigned index, const UChar*& str, unsigned& len);
-
-private:
- QTMovieWinPrivate* m_private;
- friend class QTMovieWinPrivate;
-};
-
-#endif
diff --git a/WebCore/platform/graphics/win/QTMovieWinTimer.cpp b/WebCore/platform/graphics/win/QTMovieWinTimer.cpp
deleted file mode 100644
index d0aa3e6..0000000
--- a/WebCore/platform/graphics/win/QTMovieWinTimer.cpp
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "config.h"
-
-#include <windows.h>
-
-#include "QTMovieWinTimer.h"
-
-#include <wtf/Assertions.h>
-
-// This file is used by the QuickTime access DLL. It copies some WebCore code
-// which can't be used directly due to dependency issues.
-
-// FIXME: Find a way to do timers that can manage <10ms resolution properly too.
-
-static UINT_PTR timerID;
-static void (*sharedTimerFiredFunction)();
-
-static HINSTANCE instanceHandle = 0;
-
-static HWND timerWindowHandle = 0;
-static UINT timerFiredMessage = 0;
-static const LPCWSTR kTimerWindowClassName = L"TimerWindowClass";
-static bool processingCustomTimerMessage = false;
-
-static LRESULT CALLBACK TimerWindowWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
- if (message == timerFiredMessage) {
- processingCustomTimerMessage = true;
- sharedTimerFiredFunction();
- processingCustomTimerMessage = false;
- } else
- return DefWindowProc(hWnd, message, wParam, lParam);
- return 0;
-}
-
-static void initializeOffScreenTimerWindow()
-{
- if (timerWindowHandle)
- return;
-
- WNDCLASSEX wcex;
- memset(&wcex, 0, sizeof(WNDCLASSEX));
- wcex.cbSize = sizeof(WNDCLASSEX);
- wcex.lpfnWndProc = TimerWindowWndProc;
- wcex.hInstance = instanceHandle;
- wcex.lpszClassName = kTimerWindowClassName;
- RegisterClassEx(&wcex);
-
- timerWindowHandle = CreateWindow(kTimerWindowClassName, 0, 0,
- CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, HWND_MESSAGE, 0, instanceHandle, 0);
- timerFiredMessage = RegisterWindowMessage(L"com.apple.WebKit.TimerFired");
-}
-
-void setSharedTimerFiredFunction(void (*f)())
-{
- sharedTimerFiredFunction = f;
-}
-
-static void CALLBACK timerFired(HWND, UINT, UINT_PTR, DWORD)
-{
- sharedTimerFiredFunction();
-}
-
-void setSharedTimerFireDelay(double interval)
-{
- ASSERT(sharedTimerFiredFunction);
-
- unsigned intervalInMS;
- if (interval < 0)
- intervalInMS = 0;
- else {
- interval *= 1000;
- if (interval > USER_TIMER_MAXIMUM)
- intervalInMS = USER_TIMER_MAXIMUM;
- else
- intervalInMS = (unsigned)interval;
- }
-
- if (timerID) {
- KillTimer(0, timerID);
- timerID = 0;
- }
-
- // We don't allow nested PostMessages, since the custom messages will effectively starve
- // painting and user input. (Win32 has a tri-level queue with application messages >
- // user input > WM_PAINT/WM_TIMER.)
- // In addition, if the queue contains input events that have been there since the last call to
- // GetQueueStatus, PeekMessage or GetMessage we favor timers.
- if (intervalInMS < USER_TIMER_MINIMUM && processingCustomTimerMessage &&
- !LOWORD(::GetQueueStatus(QS_ALLINPUT))) {
- // Windows SetTimer does not allow timeouts smaller than 10ms (USER_TIMER_MINIMUM)
- initializeOffScreenTimerWindow();
- PostMessage(timerWindowHandle, timerFiredMessage, 0, 0);
- } else
- timerID = SetTimer(0, 0, intervalInMS, timerFired);
-}
-
-void stopSharedTimer()
-{
- if (timerID) {
- KillTimer(0, timerID);
- timerID = 0;
- }
-}
-
-void setSharedTimerInstanceHandle(HINSTANCE handle)
-{
- instanceHandle = handle;
-}
-
-double systemTime()
-{
- FILETIME ft;
- GetSystemTimeAsFileTime(&ft);
- ULARGE_INTEGER t;
- memcpy(&t, &ft, sizeof(t));
- return t.QuadPart * 0.0000001 - 11644473600.0;
-}
diff --git a/WebCore/platform/graphics/win/QTMovieWinTimer.h b/WebCore/platform/graphics/win/QTMovieWinTimer.h
deleted file mode 100644
index 3e3c2bc..0000000
--- a/WebCore/platform/graphics/win/QTMovieWinTimer.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef QTMovieViewTimer_h
-#define QTMovieViewTimer_h
-
-// This header should not be included from WebCore.
-// It is used by the QuickTime access DLL. It copies some WebCore code
-// which can't be used directly due to dependency issues.
-
-void setSharedTimerFiredFunction(void (*)());
-void setSharedTimerFireDelay(double delay);
-void stopSharedTimer();
-void setSharedTimerInstanceHandle(HINSTANCE handle);
-double systemTime();
-
-#endif
diff --git a/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp b/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp
deleted file mode 100644
index 8b5ab87..0000000
--- a/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "SimpleFontData.h"
-
-#include <winsock2.h>
-#include "Font.h"
-#include "FontCache.h"
-#include "FloatRect.h"
-#include "FontDescription.h"
-#include "PlatformString.h"
-#include <wtf/MathExtras.h>
-#include <wtf/RetainPtr.h>
-#include <unicode/uchar.h>
-#include <unicode/unorm.h>
-#include <ApplicationServices/ApplicationServices.h>
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
-#include <mlang.h>
-#include <tchar.h>
-
-namespace WebCore {
-
-using std::max;
-
-static inline float scaleEmToUnits(float x, unsigned unitsPerEm) { return unitsPerEm ? x / static_cast<float>(unitsPerEm) : x; }
-
-void SimpleFontData::platformInit()
-{
- m_syntheticBoldOffset = m_font.syntheticBold() ? 1.0f : 0.f;
- m_scriptCache = 0;
- m_scriptFontProperties = 0;
- m_isSystemFont = false;
-
- if (m_font.useGDI())
- return initGDIFont();
-
- CGFontRef font = m_font.cgFont();
- int iAscent = CGFontGetAscent(font);
- int iDescent = CGFontGetDescent(font);
- int iLineGap = CGFontGetLeading(font);
- m_unitsPerEm = CGFontGetUnitsPerEm(font);
- float pointSize = m_font.size();
- float fAscent = scaleEmToUnits(iAscent, m_unitsPerEm) * pointSize;
- float fDescent = -scaleEmToUnits(iDescent, m_unitsPerEm) * pointSize;
- float fLineGap = scaleEmToUnits(iLineGap, m_unitsPerEm) * pointSize;
-
- if (!isCustomFont()) {
- HDC dc = GetDC(0);
- HGDIOBJ oldFont = SelectObject(dc, m_font.hfont());
- int faceLength = GetTextFace(dc, 0, 0);
- Vector<TCHAR> faceName(faceLength);
- GetTextFace(dc, faceLength, faceName.data());
- m_isSystemFont = !_tcscmp(faceName.data(), _T("Lucida Grande"));
- SelectObject(dc, oldFont);
- ReleaseDC(0, dc);
-
- if (shouldApplyMacAscentHack()) {
- // This code comes from FontDataMac.mm. We only ever do this when running regression tests so that our metrics will match Mac.
-
- // We need to adjust Times, Helvetica, and Courier to closely match the
- // vertical metrics of their Microsoft counterparts that are the de facto
- // web standard. The AppKit adjustment of 20% is too big and is
- // incorrectly added to line spacing, so we use a 15% adjustment instead
- // and add it to the ascent.
- if (!_tcscmp(faceName.data(), _T("Times")) || !_tcscmp(faceName.data(), _T("Helvetica")) || !_tcscmp(faceName.data(), _T("Courier")))
- fAscent += floorf(((fAscent + fDescent) * 0.15f) + 0.5f);
- }
- }
-
- m_ascent = lroundf(fAscent);
- m_descent = lroundf(fDescent);
- m_lineGap = lroundf(fLineGap);
- m_lineSpacing = m_ascent + m_descent + m_lineGap;
-
- // Measure the actual character "x", because AppKit synthesizes X height rather than getting it from the font.
- // Unfortunately, NSFont will round this for us so we don't quite get the right value.
- GlyphPage* glyphPageZero = GlyphPageTreeNode::getRootChild(this, 0)->page();
- Glyph xGlyph = glyphPageZero ? glyphPageZero->glyphDataForCharacter('x').glyph : 0;
- if (xGlyph) {
- CGRect xBox;
- CGFontGetGlyphBBoxes(font, &xGlyph, 1, &xBox);
- // Use the maximum of either width or height because "x" is nearly square
- // and web pages that foolishly use this metric for width will be laid out
- // poorly if we return an accurate height. Classic case is Times 13 point,
- // which has an "x" that is 7x6 pixels.
- m_xHeight = scaleEmToUnits(max(CGRectGetMaxX(xBox), CGRectGetMaxY(xBox)), m_unitsPerEm) * pointSize;
- } else {
- int iXHeight = CGFontGetXHeight(font);
- m_xHeight = scaleEmToUnits(iXHeight, m_unitsPerEm) * pointSize;
- }
-}
-
-void SimpleFontData::platformDestroy()
-{
- platformCommonDestroy();
-}
-
-float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
-{
- if (m_font.useGDI())
- return widthForGDIGlyph(glyph);
-
- CGFontRef font = m_font.cgFont();
- float pointSize = m_font.size();
- CGSize advance;
- CGAffineTransform m = CGAffineTransformMakeScale(pointSize, pointSize);
-
- // FIXME: Need to add real support for printer fonts.
- bool isPrinterFont = false;
- wkGetGlyphAdvances(font, m, m_isSystemFont, isPrinterFont, glyph, advance);
-
- return advance.width + m_syntheticBoldOffset;
-}
-
-}
diff --git a/WebCore/platform/graphics/win/SimpleFontDataCairoWin.cpp b/WebCore/platform/graphics/win/SimpleFontDataCairoWin.cpp
deleted file mode 100644
index 07d5305..0000000
--- a/WebCore/platform/graphics/win/SimpleFontDataCairoWin.cpp
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "SimpleFontData.h"
-
-#include <windows.h>
-
-#include "Font.h"
-#include "FontCache.h"
-#include "FontDescription.h"
-#include "MathExtras.h"
-#include "NotImplemented.h"
-#include <cairo.h>
-#include <cairo-win32.h>
-#include <mlang.h>
-#include <tchar.h>
-
-namespace WebCore {
-
-void SimpleFontData::platformInit()
-{
- m_scriptCache = 0;
- m_scriptFontProperties = 0;
- m_isSystemFont = false;
- m_syntheticBoldOffset = 0;
-
- if (m_font.useGDI())
- return initGDIFont();
-
- HDC hdc = GetDC(0);
- SaveDC(hdc);
-
- cairo_scaled_font_t* scaledFont = m_font.scaledFont();
- const double metricsMultiplier = cairo_win32_scaled_font_get_metrics_factor(scaledFont) * m_font.size();
-
- cairo_win32_scaled_font_select_font(scaledFont, hdc);
-
- TEXTMETRIC textMetrics;
- GetTextMetrics(hdc, &textMetrics);
- m_ascent = lroundf(textMetrics.tmAscent * metricsMultiplier);
- m_descent = lroundf(textMetrics.tmDescent * metricsMultiplier);
- m_xHeight = m_ascent * 0.56f; // Best guess for xHeight for non-Truetype fonts.
- m_lineGap = lroundf(textMetrics.tmExternalLeading * metricsMultiplier);
- m_lineSpacing = m_ascent + m_descent + m_lineGap;
-
- OUTLINETEXTMETRIC metrics;
- if (GetOutlineTextMetrics(hdc, sizeof(metrics), &metrics) > 0) {
- // This is a TrueType font. We might be able to get an accurate xHeight
- GLYPHMETRICS gm;
- MAT2 mat = { 1, 0, 0, 1 };
- DWORD len = GetGlyphOutline(hdc, 'x', GGO_METRICS, &gm, 0, 0, &mat);
- if (len != GDI_ERROR && gm.gmptGlyphOrigin.y > 0)
- m_xHeight = gm.gmptGlyphOrigin.y * metricsMultiplier;
- }
-
- cairo_win32_scaled_font_done_font(scaledFont);
-
- m_isSystemFont = false;
- m_scriptCache = 0;
- m_scriptFontProperties = 0;
-
- RestoreDC(hdc, -1);
- ReleaseDC(0, hdc);
-}
-
-void SimpleFontData::platformDestroy()
-{
- cairo_font_face_destroy(m_font.fontFace());
- cairo_scaled_font_destroy(m_font.scaledFont());
-
- DeleteObject(m_font.hfont());
-
- platformCommonDestroy();
-}
-
-float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
-{
- if (m_font.useGDI())
- return widthForGDIGlyph(glyph);
-
- HDC hdc = GetDC(0);
- SaveDC(hdc);
-
- cairo_scaled_font_t* scaledFont = m_font.scaledFont();
- cairo_win32_scaled_font_select_font(scaledFont, hdc);
-
- int width;
- GetCharWidthI(hdc, glyph, 1, 0, &width);
-
- cairo_win32_scaled_font_done_font(scaledFont);
-
- RestoreDC(hdc, -1);
- ReleaseDC(0, hdc);
-
- const double metricsMultiplier = cairo_win32_scaled_font_get_metrics_factor(scaledFont) * m_font.size();
- return width * metricsMultiplier;
-}
-
-void SimpleFontData::setFont(cairo_t* cr) const
-{
- ASSERT(cr);
- m_font.setFont(cr);
-}
-
-}
diff --git a/WebCore/platform/graphics/win/SimpleFontDataWin.cpp b/WebCore/platform/graphics/win/SimpleFontDataWin.cpp
deleted file mode 100644
index 0e9f9fb..0000000
--- a/WebCore/platform/graphics/win/SimpleFontDataWin.cpp
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "SimpleFontData.h"
-
-#include <winsock2.h>
-#include "Font.h"
-#include "FontCache.h"
-#include "FloatRect.h"
-#include "FontDescription.h"
-#include <wtf/MathExtras.h>
-#include <unicode/uchar.h>
-#include <unicode/unorm.h>
-#include <ApplicationServices/ApplicationServices.h>
-#include <mlang.h>
-#include <tchar.h>
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
-
-namespace WebCore {
-
-using std::max;
-
-const float cSmallCapsFontSizeMultiplier = 0.7f;
-
-static bool g_shouldApplyMacAscentHack;
-
-void SimpleFontData::setShouldApplyMacAscentHack(bool b)
-{
- g_shouldApplyMacAscentHack = b;
-}
-
-bool SimpleFontData::shouldApplyMacAscentHack()
-{
- return g_shouldApplyMacAscentHack;
-}
-
-void SimpleFontData::initGDIFont()
-{
- HDC hdc = GetDC(0);
- HGDIOBJ oldFont = SelectObject(hdc, m_font.hfont());
- OUTLINETEXTMETRIC metrics;
- GetOutlineTextMetrics(hdc, sizeof(metrics), &metrics);
- TEXTMETRIC& textMetrics = metrics.otmTextMetrics;
- m_ascent = textMetrics.tmAscent;
- m_descent = textMetrics.tmDescent;
- m_lineGap = textMetrics.tmExternalLeading;
- m_lineSpacing = m_ascent + m_descent + m_lineGap;
- m_xHeight = m_ascent * 0.56f; // Best guess for xHeight if no x glyph is present.
-
- GLYPHMETRICS gm;
- MAT2 mat = { 1, 0, 0, 1 };
- DWORD len = GetGlyphOutline(hdc, 'x', GGO_METRICS, &gm, 0, 0, &mat);
- if (len != GDI_ERROR && gm.gmptGlyphOrigin.y > 0)
- m_xHeight = gm.gmptGlyphOrigin.y;
-
- m_unitsPerEm = metrics.otmEMSquare;
-
- SelectObject(hdc, oldFont);
- ReleaseDC(0, hdc);
-
- return;
-}
-
-void SimpleFontData::platformCommonDestroy()
-{
- // We don't hash this on Win32, so it's effectively owned by us.
- delete m_smallCapsFontData;
-
- ScriptFreeCache(&m_scriptCache);
- delete m_scriptFontProperties;
-}
-
-SimpleFontData* SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const
-{
- if (!m_smallCapsFontData) {
- float smallCapsHeight = cSmallCapsFontSizeMultiplier * m_font.size();
- if (isCustomFont()) {
- FontPlatformData smallCapsFontData(m_font);
- smallCapsFontData.setSize(smallCapsHeight);
- m_smallCapsFontData = new SimpleFontData(smallCapsFontData, true, false);
- } else {
- LOGFONT winfont;
- GetObject(m_font.hfont(), sizeof(LOGFONT), &winfont);
- winfont.lfHeight = -lroundf(smallCapsHeight * (m_font.useGDI() ? 1 : 32));
- HFONT hfont = CreateFontIndirect(&winfont);
- m_smallCapsFontData = new SimpleFontData(FontPlatformData(hfont, smallCapsHeight, m_font.syntheticBold(), m_font.syntheticOblique(), m_font.useGDI()));
- }
- }
- return m_smallCapsFontData;
-}
-
-bool SimpleFontData::containsCharacters(const UChar* characters, int length) const
-{
- // FIXME: Support custom fonts.
- if (isCustomFont())
- return false;
-
- // FIXME: Microsoft documentation seems to imply that characters can be output using a given font and DC
- // merely by testing code page intersection. This seems suspect though. Can't a font only partially
- // cover a given code page?
- IMLangFontLink2* langFontLink = FontCache::getFontLinkInterface();
- if (!langFontLink)
- return false;
-
- HDC dc = GetDC(0);
-
- DWORD acpCodePages;
- langFontLink->CodePageToCodePages(CP_ACP, &acpCodePages);
-
- DWORD fontCodePages;
- langFontLink->GetFontCodePages(dc, m_font.hfont(), &fontCodePages);
-
- DWORD actualCodePages;
- long numCharactersProcessed;
- long offset = 0;
- while (offset < length) {
- langFontLink->GetStrCodePages(characters, length, acpCodePages, &actualCodePages, &numCharactersProcessed);
- if ((actualCodePages & fontCodePages) == 0)
- return false;
- offset += numCharactersProcessed;
- }
-
- ReleaseDC(0, dc);
-
- return true;
-}
-
-void SimpleFontData::determinePitch()
-{
- if (isCustomFont()) {
- m_treatAsFixedPitch = false;
- return;
- }
-
- // TEXTMETRICS have this. Set m_treatAsFixedPitch based off that.
- HDC dc = GetDC(0);
- SaveDC(dc);
- SelectObject(dc, m_font.hfont());
-
- // Yes, this looks backwards, but the fixed pitch bit is actually set if the font
- // is *not* fixed pitch. Unbelievable but true.
- TEXTMETRIC tm;
- GetTextMetrics(dc, &tm);
- m_treatAsFixedPitch = ((tm.tmPitchAndFamily & TMPF_FIXED_PITCH) == 0);
-
- RestoreDC(dc, -1);
- ReleaseDC(0, dc);
-}
-
-float SimpleFontData::widthForGDIGlyph(Glyph glyph) const
-{
- HDC hdc = GetDC(0);
- HGDIOBJ oldFont = SelectObject(hdc, m_font.hfont());
- int width;
- GetCharWidthI(hdc, glyph, 1, 0, &width);
- SelectObject(hdc, oldFont);
- ReleaseDC(0, hdc);
- return width + m_syntheticBoldOffset;
-}
-
-SCRIPT_FONTPROPERTIES* SimpleFontData::scriptFontProperties() const
-{
- if (!m_scriptFontProperties) {
- m_scriptFontProperties = new SCRIPT_FONTPROPERTIES;
- memset(m_scriptFontProperties, 0, sizeof(SCRIPT_FONTPROPERTIES));
- m_scriptFontProperties->cBytes = sizeof(SCRIPT_FONTPROPERTIES);
- HRESULT result = ScriptGetFontProperties(0, scriptCache(), m_scriptFontProperties);
- if (result == E_PENDING) {
- HDC dc = GetDC(0);
- SaveDC(dc);
- SelectObject(dc, m_font.hfont());
- ScriptGetFontProperties(dc, scriptCache(), m_scriptFontProperties);
- RestoreDC(dc, -1);
- ReleaseDC(0, dc);
- }
- }
- return m_scriptFontProperties;
-}
-
-}
diff --git a/WebCore/platform/graphics/win/UniscribeController.cpp b/WebCore/platform/graphics/win/UniscribeController.cpp
deleted file mode 100644
index 371bc51..0000000
--- a/WebCore/platform/graphics/win/UniscribeController.cpp
+++ /dev/null
@@ -1,434 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "UniscribeController.h"
-#include "Font.h"
-#include "SimpleFontData.h"
-#include <wtf/MathExtras.h>
-
-namespace WebCore {
-
-// FIXME: Rearchitect this to be more like WidthIterator in Font.cpp. Have an advance() method
-// that does stuff in that method instead of doing everything in the constructor. Have advance()
-// take the GlyphBuffer as an arg so that we don't have to populate the glyph buffer when
-// measuring.
-UniscribeController::UniscribeController(const Font* font, const TextRun& run)
-: m_font(*font)
-, m_run(run)
-, m_end(run.length())
-, m_currentCharacter(0)
-, m_runWidthSoFar(0)
-, m_computingOffsetPosition(false)
-, m_includePartialGlyphs(false)
-, m_offsetX(0)
-, m_offsetPosition(0)
-{
- m_padding = m_run.padding();
- if (!m_padding)
- m_padPerSpace = 0;
- else {
- float numSpaces = 0;
- for (int s = 0; s < m_run.length(); s++)
- if (Font::treatAsSpace(m_run[s]))
- numSpaces++;
-
- if (numSpaces == 0)
- m_padPerSpace = 0;
- else
- m_padPerSpace = ceilf(m_run.padding() / numSpaces);
- }
-
- // Null out our uniscribe structs
- resetControlAndState();
-}
-
-int UniscribeController::offsetForPosition(int x, bool includePartialGlyphs)
-{
- m_computingOffsetPosition = true;
- m_includePartialGlyphs = includePartialGlyphs;
- m_offsetX = x;
- m_offsetPosition = 0;
- advance(m_run.length());
- if (m_computingOffsetPosition) {
- // The point is to the left or to the right of the entire run.
- if (m_offsetX >= m_runWidthSoFar && m_run.ltr() || m_offsetX < 0 && m_run.rtl())
- m_offsetPosition = m_end;
- }
- m_computingOffsetPosition = false;
- return m_offsetPosition;
-}
-
-void UniscribeController::advance(unsigned offset, GlyphBuffer* glyphBuffer)
-{
- // FIXME: We really want to be using a newer version of Uniscribe that supports the new OpenType
- // functions. Those functions would allow us to turn off kerning and ligatures. Without being able
- // to do that, we will have buggy line breaking and metrics when simple and complex text are close
- // together (the complex code path will narrow the text because of kerning and ligatures and then
- // when bidi processing splits into multiple runs, the simple portions will get wider and cause us to
- // spill off the edge of a line).
- if (static_cast<int>(offset) > m_end)
- offset = m_end;
-
- // Itemize the string.
- const UChar* cp = m_run.data(m_currentCharacter);
- int length = offset - m_currentCharacter;
- if (length <= 0)
- return;
-
- unsigned baseCharacter = m_currentCharacter;
-
- // We break up itemization of the string by fontData and (if needed) the use of small caps.
-
- // FIXME: It's inconsistent that we use logical order when itemizing, since this
- // does not match normal RTL.
-
- // FIXME: This function should decode surrogate pairs. Currently it makes little difference that
- // it does not because the font cache on Windows does not support non-BMP characters.
- Vector<UChar, 256> smallCapsBuffer;
- if (m_font.isSmallCaps())
- smallCapsBuffer.resize(length);
-
- unsigned indexOfFontTransition = m_run.rtl() ? length - 1 : 0;
- const UChar* curr = m_run.rtl() ? cp + length - 1 : cp;
- const UChar* end = m_run.rtl() ? cp - 1 : cp + length;
-
- const SimpleFontData* fontData;
- const SimpleFontData* nextFontData = m_font.glyphDataForCharacter(*curr, false).fontData;
-
- UChar newC = 0;
-
- bool isSmallCaps;
- bool nextIsSmallCaps = m_font.isSmallCaps() && !(U_GET_GC_MASK(*curr) & U_GC_M_MASK) && (newC = u_toupper(*curr)) != *curr;
-
- if (nextIsSmallCaps)
- smallCapsBuffer[curr - cp] = newC;
-
- while (true) {
- curr = m_run.rtl() ? curr - 1 : curr + 1;
- if (curr == end)
- break;
-
- fontData = nextFontData;
- isSmallCaps = nextIsSmallCaps;
- int index = curr - cp;
- UChar c = *curr;
-
- bool forceSmallCaps = isSmallCaps && (U_GET_GC_MASK(c) & U_GC_M_MASK);
- nextFontData = m_font.glyphDataForCharacter(*curr, false, forceSmallCaps).fontData;
- if (m_font.isSmallCaps()) {
- nextIsSmallCaps = forceSmallCaps || (newC = u_toupper(c)) != c;
- if (nextIsSmallCaps)
- smallCapsBuffer[index] = forceSmallCaps ? c : newC;
- }
-
- if (nextFontData != fontData || nextIsSmallCaps != isSmallCaps) {
- int itemStart = m_run.rtl() ? index + 1 : indexOfFontTransition;
- int itemLength = m_run.rtl() ? indexOfFontTransition - index : index - indexOfFontTransition;
- m_currentCharacter = baseCharacter + itemStart;
- itemizeShapeAndPlace((isSmallCaps ? smallCapsBuffer.data() : cp) + itemStart, itemLength, fontData, glyphBuffer);
- indexOfFontTransition = index;
- }
- }
-
- int itemLength = m_run.rtl() ? indexOfFontTransition + 1 : length - indexOfFontTransition;
- if (itemLength) {
- int itemStart = m_run.rtl() ? 0 : indexOfFontTransition;
- m_currentCharacter = baseCharacter + itemStart;
- itemizeShapeAndPlace((nextIsSmallCaps ? smallCapsBuffer.data() : cp) + itemStart, itemLength, nextFontData, glyphBuffer);
- }
-
- m_currentCharacter = baseCharacter + length;
-}
-
-void UniscribeController::itemizeShapeAndPlace(const UChar* cp, unsigned length, const SimpleFontData* fontData, GlyphBuffer* glyphBuffer)
-{
- // ScriptItemize (in Windows XP versions prior to SP2) can overflow by 1. This is why there is an extra empty item
- // hanging out at the end of the array
- m_items.resize(6);
- int numItems = 0;
- while (ScriptItemize(cp, length, m_items.size() - 1, &m_control, &m_state, m_items.data(), &numItems) == E_OUTOFMEMORY) {
- m_items.resize(m_items.size() * 2);
- resetControlAndState();
- }
- m_items.resize(numItems + 1);
-
- if (m_run.rtl()) {
- for (int i = m_items.size() - 2; i >= 0; i--) {
- if (!shapeAndPlaceItem(cp, i, fontData, glyphBuffer))
- return;
- }
- } else {
- for (unsigned i = 0; i < m_items.size() - 1; i++) {
- if (!shapeAndPlaceItem(cp, i, fontData, glyphBuffer))
- return;
- }
- }
-}
-
-void UniscribeController::resetControlAndState()
-{
- memset(&m_control, 0, sizeof(SCRIPT_CONTROL));
- memset(&m_state, 0, sizeof(SCRIPT_STATE));
-
- // Set up the correct direction for the run.
- m_state.uBidiLevel = m_run.rtl();
-
- // Lock the correct directional override.
- m_state.fOverrideDirection = m_run.directionalOverride();
-}
-
-bool UniscribeController::shapeAndPlaceItem(const UChar* cp, unsigned i, const SimpleFontData* fontData, GlyphBuffer* glyphBuffer)
-{
- // Determine the string for this item.
- const UChar* str = cp + m_items[i].iCharPos;
- int len = m_items[i+1].iCharPos - m_items[i].iCharPos;
- SCRIPT_ITEM item = m_items[i];
-
- // Set up buffers to hold the results of shaping the item.
- Vector<WORD> glyphs;
- Vector<WORD> clusters;
- Vector<SCRIPT_VISATTR> visualAttributes;
- clusters.resize(len);
-
- // Shape the item.
- // The recommended size for the glyph buffer is 1.5 * the character length + 16 in the uniscribe docs.
- // Apparently this is a good size to avoid having to make repeated calls to ScriptShape.
- glyphs.resize(1.5 * len + 16);
- visualAttributes.resize(glyphs.size());
-
- if (!shape(str, len, item, fontData, glyphs, clusters, visualAttributes))
- return true;
-
- // We now have a collection of glyphs.
- Vector<GOFFSET> offsets;
- Vector<int> advances;
- offsets.resize(glyphs.size());
- advances.resize(glyphs.size());
- int glyphCount = 0;
- HRESULT placeResult = ScriptPlace(0, fontData->scriptCache(), glyphs.data(), glyphs.size(), visualAttributes.data(),
- &item.a, advances.data(), offsets.data(), 0);
- if (placeResult == E_PENDING) {
- // The script cache isn't primed with enough info yet. We need to select our HFONT into
- // a DC and pass the DC in to ScriptPlace.
- HDC hdc = GetDC(0);
- HFONT hfont = fontData->platformData().hfont();
- HFONT oldFont = (HFONT)SelectObject(hdc, hfont);
- placeResult = ScriptPlace(hdc, fontData->scriptCache(), glyphs.data(), glyphs.size(), visualAttributes.data(),
- &item.a, advances.data(), offsets.data(), 0);
- SelectObject(hdc, oldFont);
- ReleaseDC(0, hdc);
- }
-
- if (FAILED(placeResult) || glyphs.isEmpty())
- return true;
-
- // Convert all chars that should be treated as spaces to use the space glyph.
- // We also create a map that allows us to quickly go from space glyphs or rounding
- // hack glyphs back to their corresponding characters.
- Vector<int> spaceCharacters(glyphs.size());
- spaceCharacters.fill(-1);
- Vector<int> roundingHackCharacters(glyphs.size());
- roundingHackCharacters.fill(-1);
- Vector<int> roundingHackWordBoundaries(glyphs.size());
- roundingHackWordBoundaries.fill(-1);
-
- const float cLogicalScale = fontData->m_font.useGDI() ? 1.0f : 32.0f;
- unsigned logicalSpaceWidth = fontData->m_spaceWidth * cLogicalScale;
- float roundedSpaceWidth = roundf(fontData->m_spaceWidth);
-
- for (int k = 0; k < len; k++) {
- UChar ch = *(str + k);
- if (Font::treatAsSpace(ch)) {
- // Substitute in the space glyph at the appropriate place in the glyphs
- // array.
- glyphs[clusters[k]] = fontData->m_spaceGlyph;
- advances[clusters[k]] = logicalSpaceWidth;
- spaceCharacters[clusters[k]] = m_currentCharacter + k + item.iCharPos;
- }
-
- if (Font::isRoundingHackCharacter(ch))
- roundingHackCharacters[clusters[k]] = m_currentCharacter + k + item.iCharPos;
-
- int boundary = k + m_currentCharacter + item.iCharPos;
- if (boundary < m_run.length() &&
- Font::isRoundingHackCharacter(*(str + k + 1)))
- roundingHackWordBoundaries[clusters[k]] = boundary;
- }
-
- // Populate our glyph buffer with this information.
- bool hasExtraSpacing = m_font.letterSpacing() || m_font.wordSpacing() || m_padding;
-
- float leftEdge = m_runWidthSoFar;
-
- for (unsigned k = 0; k < glyphs.size(); k++) {
- Glyph glyph = glyphs[k];
- float advance = advances[k] / cLogicalScale;
- float offsetX = offsets[k].du / cLogicalScale;
- float offsetY = offsets[k].dv / cLogicalScale;
-
- // Match AppKit's rules for the integer vs. non-integer rendering modes.
- float roundedAdvance = roundf(advance);
- if (!m_font.isPrinterFont() && !fontData->isSystemFont()) {
- advance = roundedAdvance;
- offsetX = roundf(offsetX);
- offsetY = roundf(offsetY);
- }
-
- advance += fontData->m_syntheticBoldOffset;
-
- // We special case spaces in two ways when applying word rounding.
- // First, we round spaces to an adjusted width in all fonts.
- // Second, in fixed-pitch fonts we ensure that all glyphs that
- // match the width of the space glyph have the same width as the space glyph.
- if (roundedAdvance == roundedSpaceWidth && (fontData->m_treatAsFixedPitch || glyph == fontData->m_spaceGlyph) &&
- m_run.applyWordRounding())
- advance = fontData->m_adjustedSpaceWidth;
-
- if (hasExtraSpacing) {
- // If we're a glyph with an advance, go ahead and add in letter-spacing.
- // That way we weed out zero width lurkers. This behavior matches the fast text code path.
- if (advance && m_font.letterSpacing())
- advance += m_font.letterSpacing();
-
- // Handle justification and word-spacing.
- if (glyph == fontData->m_spaceGlyph) {
- // Account for padding. WebCore uses space padding to justify text.
- // We distribute the specified padding over the available spaces in the run.
- if (m_padding) {
- // Use leftover padding if not evenly divisible by number of spaces.
- if (m_padding < m_padPerSpace) {
- advance += m_padding;
- m_padding = 0;
- } else {
- advance += m_padPerSpace;
- m_padding -= m_padPerSpace;
- }
- }
-
- // Account for word-spacing.
- int characterIndex = spaceCharacters[k];
- if (characterIndex > 0 && !Font::treatAsSpace(*m_run.data(characterIndex - 1)) && m_font.wordSpacing())
- advance += m_font.wordSpacing();
- }
- }
-
- // Deal with the float/integer impedance mismatch between CG and WebCore. "Words" (characters
- // followed by a character defined by isRoundingHackCharacter()) are always an integer width.
- // We adjust the width of the last character of a "word" to ensure an integer width.
- // Force characters that are used to determine word boundaries for the rounding hack
- // to be integer width, so the following words will start on an integer boundary.
- int roundingHackIndex = roundingHackCharacters[k];
- if (m_run.applyWordRounding() && roundingHackIndex != -1)
- advance = ceilf(advance);
-
- // Check to see if the next character is a "rounding hack character", if so, adjust the
- // width so that the total run width will be on an integer boundary.
- int position = m_currentCharacter + len;
- bool lastGlyph = (k == glyphs.size() - 1) && (m_run.rtl() ? i == 0 : i == m_items.size() - 2) && (position >= m_end);
- if ((m_run.applyWordRounding() && roundingHackWordBoundaries[k] != -1) ||
- (m_run.applyRunRounding() && lastGlyph)) {
- float totalWidth = m_runWidthSoFar + advance;
- advance += ceilf(totalWidth) - totalWidth;
- }
-
- m_runWidthSoFar += advance;
-
- // FIXME: We need to take the GOFFSETS for combining glyphs and store them in the glyph buffer
- // as well, so that when the time comes to draw those glyphs, we can apply the appropriate
- // translation.
- if (glyphBuffer) {
- FloatSize size(offsetX, -offsetY);
- glyphBuffer->add(glyph, fontData, advance, &size);
- }
-
- // Mutate the glyph array to contain our altered advances.
- if (m_computingOffsetPosition)
- advances[k] = advance;
- }
-
- while (m_computingOffsetPosition && m_offsetX >= leftEdge && m_offsetX < m_runWidthSoFar) {
- // The position is somewhere inside this run.
- int trailing = 0;
- ScriptXtoCP(m_offsetX - leftEdge, clusters.size(), glyphs.size(), clusters.data(), visualAttributes.data(),
- advances.data(), &item.a, &m_offsetPosition, &trailing);
- if (trailing && m_includePartialGlyphs && m_offsetPosition < len - 1) {
- m_offsetPosition += m_currentCharacter + m_items[i].iCharPos;
- m_offsetX += m_run.rtl() ? -trailing : trailing;
- } else {
- m_computingOffsetPosition = false;
- m_offsetPosition += m_currentCharacter + m_items[i].iCharPos;
- if (trailing && m_includePartialGlyphs)
- m_offsetPosition++;
- return false;
- }
- }
-
- return true;
-}
-
-bool UniscribeController::shape(const UChar* str, int len, SCRIPT_ITEM item, const SimpleFontData* fontData,
- Vector<WORD>& glyphs, Vector<WORD>& clusters,
- Vector<SCRIPT_VISATTR>& visualAttributes)
-{
- HDC hdc = 0;
- HFONT oldFont = 0;
- HRESULT shapeResult = E_PENDING;
- int glyphCount = 0;
- do {
- shapeResult = ScriptShape(hdc, fontData->scriptCache(), str, len, glyphs.size(), &item.a,
- glyphs.data(), clusters.data(), visualAttributes.data(), &glyphCount);
- if (shapeResult == E_PENDING) {
- // The script cache isn't primed with enough info yet. We need to select our HFONT into
- // a DC and pass the DC in to ScriptShape.
- ASSERT(!hdc);
- hdc = GetDC(0);
- HFONT hfont = fontData->platformData().hfont();
- oldFont = (HFONT)SelectObject(hdc, hfont);
- } else if (shapeResult == E_OUTOFMEMORY) {
- // Need to resize our buffers.
- glyphs.resize(glyphs.size() * 2);
- visualAttributes.resize(glyphs.size());
- }
- } while (shapeResult == E_PENDING || shapeResult == E_OUTOFMEMORY);
-
- if (hdc) {
- SelectObject(hdc, oldFont);
- ReleaseDC(0, hdc);
- }
-
- if (FAILED(shapeResult))
- return false;
-
- glyphs.shrink(glyphCount);
- visualAttributes.shrink(glyphCount);
-
- return true;
-}
-
-}
diff --git a/WebCore/platform/graphics/win/UniscribeController.h b/WebCore/platform/graphics/win/UniscribeController.h
deleted file mode 100644
index 6ea45e1..0000000
--- a/WebCore/platform/graphics/win/UniscribeController.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef UniscribeController_h
-#define UniscribeController_h
-
-#include <usp10.h>
-#include "Font.h"
-#include "GlyphBuffer.h"
-#include "Vector.h"
-
-namespace WebCore {
-
-class UniscribeController {
-public:
- UniscribeController(const Font*, const TextRun&);
-
- // Advance and measure/place up to the specified character.
- void advance(unsigned to, GlyphBuffer* = 0);
-
- // Compute the character offset for a given x coordinate.
- int offsetForPosition(int x, bool includePartialGlyphs);
-
- // Returns the width of everything we've consumed so far.
- float runWidthSoFar() const { return m_runWidthSoFar; }
-
-private:
- void resetControlAndState();
-
- void itemizeShapeAndPlace(const UChar*, unsigned length, const SimpleFontData*, GlyphBuffer*);
- bool shapeAndPlaceItem(const UChar*, unsigned index, const SimpleFontData*, GlyphBuffer*);
- bool shape(const UChar* str, int len, SCRIPT_ITEM item, const SimpleFontData* fontData,
- Vector<WORD>& glyphs, Vector<WORD>& clusters,
- Vector<SCRIPT_VISATTR>& visualAttributes);
-
- const Font& m_font;
- const TextRun& m_run;
-
- SCRIPT_CONTROL m_control;
- SCRIPT_STATE m_state;
- Vector<SCRIPT_ITEM> m_items;
-
- unsigned m_currentCharacter;
- int m_end;
-
- float m_runWidthSoFar;
- float m_padding;
- float m_padPerSpace;
-
- bool m_computingOffsetPosition;
- bool m_includePartialGlyphs;
- float m_offsetX;
- int m_offsetPosition;
-};
-
-}
-#endif
diff --git a/WebCore/platform/graphics/wx/AffineTransformWx.cpp b/WebCore/platform/graphics/wx/AffineTransformWx.cpp
deleted file mode 100644
index 12485ae..0000000
--- a/WebCore/platform/graphics/wx/AffineTransformWx.cpp
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * Copyright (C) 2007 Kevin Ollivier All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "AffineTransform.h"
-
-#include "FloatRect.h"
-#include "IntRect.h"
-#include "NotImplemented.h"
-
-#include <stdio.h>
-#include <wx/defs.h>
-#include <wx/graphics.h>
-
-namespace WebCore {
-
-#if USE(WXGC)
-AffineTransform::AffineTransform(const PlatformAffineTransform& matrix)
-{
- m_transform = matrix;
-}
-#endif
-
-AffineTransform::AffineTransform(double a, double b, double c, double d, double e, double f)
-{
-#if USE(WXGC)
- wxGraphicsRenderer* renderer = wxGraphicsRenderer::GetDefaultRenderer();
- m_transform = renderer->CreateMatrix();
-#endif
- setMatrix(a, b, c, d, e, f);
-}
-
-AffineTransform::AffineTransform()
-{
- // NB: If we ever support using Cairo backend on Win/Mac, this will need to be
- // changed somehow (though I'm not sure how as we don't have a reference to the
- // graphics context here.
-#if USE(WXGC)
- wxGraphicsRenderer* renderer = wxGraphicsRenderer::GetDefaultRenderer();
- m_transform = renderer->CreateMatrix();
-#endif
-}
-
-AffineTransform AffineTransform::inverse() const
-{
- notImplemented();
- return *this;
-}
-
-void AffineTransform::setMatrix(double a, double b, double c, double d, double e, double f)
-{
-#if USE(WXGC)
- m_transform.Set(a, b, c, d, e, f);
-#endif
-}
-
-void AffineTransform::map(double x, double y, double *x2, double *y2) const
-{
- notImplemented();
-}
-
-IntRect AffineTransform::mapRect(const IntRect &rect) const
-{
- notImplemented();
- return IntRect();
-}
-
-FloatRect AffineTransform::mapRect(const FloatRect &rect) const
-{
- notImplemented();
- return FloatRect();
-}
-
-
-AffineTransform& AffineTransform::scale(double sx, double sy)
-{
-#if USE(WXGC)
- m_transform.Scale((wxDouble)sx, (wxDouble)sy);
-#endif
- return *this;
-}
-
-void AffineTransform::reset()
-{
- notImplemented();
-}
-
-AffineTransform& AffineTransform::rotate(double d)
-{
-#if USE(WXGC)
- m_transform.Rotate((wxDouble)d);
-#endif
- return *this;
-}
-
-AffineTransform& AffineTransform::translate(double tx, double ty)
-{
-#if USE(WXGC)
- m_transform.Translate((wxDouble)tx, (wxDouble)ty);
-#endif
- return *this;
-}
-
-AffineTransform& AffineTransform::shear(double sx, double sy)
-{
- notImplemented();
- return *this;
-}
-
-AffineTransform& AffineTransform::operator*=(const AffineTransform& other)
-{
- notImplemented();
- return *this;
-}
-
-bool AffineTransform::operator== (const AffineTransform &other) const
-{
-#if USE(WXGC)
- return m_transform.IsEqual((wxGraphicsMatrix)other);
-#else
- notImplemented();
- return true;
-#endif
-}
-
-AffineTransform AffineTransform::operator* (const AffineTransform &other)
-{
- notImplemented();
- return *this; //m_transform * other.m_transform;
-}
-
-double AffineTransform::det() const
-{
- notImplemented();
- return 0;
-}
-
-#if USE(WXGC)
-AffineTransform::operator wxGraphicsMatrix() const
-{
- return m_transform;
-}
-#endif
-
-double AffineTransform::a() const
-{
- double a = 0;
-#if USE(WXGC)
- m_transform.Get(&a);
-#endif
- return a;
-}
-
-void AffineTransform::setA(double a)
-{
- setMatrix(a, b(), c(), d(), e(), f());
-}
-
-double AffineTransform::b() const
-{
- double b = 0;
-#if USE(WXGC)
- m_transform.Get(&b);
-#endif
- return b;
-}
-
-void AffineTransform::setB(double b)
-{
- setMatrix(a(), b, c(), d(), e(), f());
-}
-
-double AffineTransform::c() const
-{
- double c = 0;
-#if USE(WXGC)
- m_transform.Get(&c);
-#endif
- return c;
-}
-
-void AffineTransform::setC(double c)
-{
- setMatrix(a(), b(), c, d(), e(), f());
-}
-
-double AffineTransform::d() const
-{
- double d = 0;
-#if USE(WXGC)
- m_transform.Get(&d);
-#endif
- return d;
-}
-
-void AffineTransform::setD(double d)
-{
- setMatrix(a(), b(), c(), d, e(), f());
-}
-
-double AffineTransform::e() const
-{
- double e = 0;
-#if USE(WXGC)
- m_transform.Get(&e);
-#endif
- return e;
-}
-
-void AffineTransform::setE(double e)
-{
- setMatrix(a(), b(), c(), d(), e, f());
-}
-
-double AffineTransform::f() const
-{
- double f = 0;
-#if USE(WXGC)
- m_transform.Get(&f);
-#endif
- return f;
-}
-
-void AffineTransform::setF(double f)
-{
- setMatrix(a(), b(), c(), d(), e(), f);
-}
-
-}
diff --git a/WebCore/platform/graphics/wx/ColorWx.cpp b/WebCore/platform/graphics/wx/ColorWx.cpp
deleted file mode 100644
index 0381c59..0000000
--- a/WebCore/platform/graphics/wx/ColorWx.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Kevin Ollivier. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Color.h"
-
-#include <wx/defs.h>
-#include <wx/colour.h>
-
-namespace WebCore {
-
-Color::Color(const wxColour& color)
-{
- m_color = makeRGBA((int)color.Red(), (int)color.Green(), (int)color.Blue(), (int)color.Alpha());
-}
-
-Color::operator wxColour() const
-{
- return wxColour(red(), green(), blue(), alpha());
-}
-
-}
diff --git a/WebCore/platform/graphics/wx/FloatRectWx.cpp b/WebCore/platform/graphics/wx/FloatRectWx.cpp
deleted file mode 100644
index bb460e5..0000000
--- a/WebCore/platform/graphics/wx/FloatRectWx.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2007 Kevin Ollivier. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FloatRect.h"
-
-#include <wx/defs.h>
-#include <wx/graphics.h>
-
-namespace WebCore {
-
-#if USE(WXGC)
-FloatRect::FloatRect(const wxRect2DDouble& r)
- : m_location(FloatPoint(r.m_x, r.m_y))
- , m_size(FloatSize(r.m_width, r.m_height))
-{
-}
-
-FloatRect::operator wxRect2DDouble() const
-{
- return wxRect2DDouble(x(), y(), width(), height());
-}
-#endif
-
-}
diff --git a/WebCore/platform/graphics/wx/FontCacheWx.cpp b/WebCore/platform/graphics/wx/FontCacheWx.cpp
deleted file mode 100755
index db107e4..0000000
--- a/WebCore/platform/graphics/wx/FontCacheWx.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FontCache.h"
-#include "Font.h"
-#include "FontPlatformData.h"
-#include "NotImplemented.h"
-#include "SimpleFontData.h"
-
-namespace WebCore {
-
-void FontCache::platformInit()
-{
-}
-
-const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
-{
- SimpleFontData* fontData = 0;
- fontData = new SimpleFontData(FontPlatformData(font.fontDescription(), font.family().family()));
- return fontData;
-}
-
-FontPlatformData* FontCache::getSimilarFontPlatformData(const Font& font)
-{
- return new FontPlatformData(font.fontDescription(), font.family().family());
-}
-
-FontPlatformData* FontCache::getLastResortFallbackFont(const FontDescription& fontDescription)
-{
- // FIXME: Would be even better to somehow get the user's default font here. For now we'll pick
- // the default that the user would get without changing any prefs.
- static AtomicString timesStr("systemfont");
- return getCachedFontPlatformData(fontDescription, timesStr);
-}
-
-FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
-{
- return new FontPlatformData(fontDescription,family);
-}
-
-void FontCache::getTraitsInFamily(const AtomicString& familyName, Vector<unsigned>& traitsMasks)
-{
- notImplemented();
-}
-
-}
diff --git a/WebCore/platform/graphics/wx/FontPlatformData.h b/WebCore/platform/graphics/wx/FontPlatformData.h
deleted file mode 100644
index e3a3cce..0000000
--- a/WebCore/platform/graphics/wx/FontPlatformData.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (C) 2006 Kevin Ollivier All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef FontPlatformData_H
-#define FontPlatformData_H
-
-#include "FontDescription.h"
-#include "CString.h"
-#include "AtomicString.h"
-#include "StringImpl.h"
-
-#include <wx/defs.h>
-#include <wx/font.h>
-
-namespace WebCore {
-
-class FontPlatformData {
-public:
- enum FontState { UNINITIALIZED, DELETED, VALID };
-
- FontPlatformData(WTF::HashTableDeletedValueType)
- : m_fontState(DELETED)
- { }
-
- ~FontPlatformData();
-
- FontPlatformData(wxFont f)
- : m_font(f)
- , m_fontState(VALID)
- {
- m_fontHash = computeHash();
- }
-
- FontPlatformData(const FontDescription&, const AtomicString&);
-
- FontPlatformData()
- : m_fontState(UNINITIALIZED)
- {
- }
-
- wxFont font() const {
- return m_font;
- }
-
- unsigned hash() const {
- switch (m_fontState) {
- case DELETED:
- return -1;
- case UNINITIALIZED:
- return 0;
- case VALID:
- return computeHash();
- }
- }
-
- bool operator==(const FontPlatformData& other) const
- {
- if (m_fontState == VALID)
- return other.m_fontState == VALID && m_font.Ok() && other.m_font.Ok() && m_font.IsSameAs(other.m_font);
- else
- return m_fontState == other.m_fontState;
- }
-
- bool isHashTableDeletedValue() const { return m_fontState == DELETED; }
-
- unsigned computeHash() const {
- ASSERT(m_font.Ok());
-
- // make a hash that is unique for this font, but not globally unique - that is,
- // a font whose properties are equal should generate the same hash
- uintptr_t hashCodes[6] = { m_font.GetPointSize(), m_font.GetFamily(), m_font.GetStyle(),
- m_font.GetWeight(), m_font.GetUnderlined(),
- StringImpl::computeHash(m_font.GetFaceName().mb_str(wxConvUTF8)) };
-
- return StringImpl::computeHash(reinterpret_cast<UChar*>(hashCodes), sizeof(hashCodes) / sizeof(UChar));
- }
-
-private:
- wxFont m_font;
- FontState m_fontState;
- unsigned m_fontHash;
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/graphics/wx/FontPlatformDataWx.cpp b/WebCore/platform/graphics/wx/FontPlatformDataWx.cpp
deleted file mode 100755
index 7162eab..0000000
--- a/WebCore/platform/graphics/wx/FontPlatformDataWx.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FontPlatformData.h"
-
-#include "FontDescription.h"
-
-#include <wx/defs.h>
-#include <wx/gdicmn.h>
-#include <wx/font.h>
-
-namespace WebCore {
-
-static wxFontFamily fontFamilyToWxFontFamily(const int family)
-{
- switch (family) {
- case FontDescription::StandardFamily:
- return wxFONTFAMILY_DEFAULT;
- case FontDescription::SerifFamily:
- return wxFONTFAMILY_ROMAN;
- case FontDescription::SansSerifFamily:
- return wxFONTFAMILY_MODERN;
- case FontDescription::MonospaceFamily:
- return wxFONTFAMILY_TELETYPE; // TODO: Check these are equivalent
- case FontDescription::CursiveFamily:
- return wxFONTFAMILY_SCRIPT;
- case FontDescription::FantasyFamily:
- return wxFONTFAMILY_DECORATIVE;
- default:
- return wxFONTFAMILY_DEFAULT;
- }
-}
-
-static wxFontWeight fontWeightToWxFontWeight(FontWeight weight)
-{
- if (weight >= FontWeight600)
- return wxFONTWEIGHT_BOLD;
-
- return wxFONTWEIGHT_NORMAL;
-}
-
-static int italicToWxFontStyle(bool isItalic)
-{
- if (isItalic)
- return wxFONTSTYLE_ITALIC;
-
- return wxFONTSTYLE_NORMAL;
-}
-
-FontPlatformData::FontPlatformData(const FontDescription& desc, const AtomicString& family)
-{
-// NB: The Windows wxFont constructor has two forms, one taking a wxSize (with pixels)
-// and one taking an int (points). When points are used, Windows calculates
-// a pixel size using an algorithm which causes the size to be way off. However,
-// this is a moot issue on Linux and Mac as they only accept the point argument. So,
-// we use the pixel size constructor on Windows, but we use point size on Linux and Mac.
-#if __WXMSW__
- m_font = wxFont( wxSize(0, -desc.computedPixelSize()),
- fontFamilyToWxFontFamily(desc.genericFamily()),
- italicToWxFontStyle(desc.italic()),
- fontWeightToWxFontWeight(desc.weight()),
- false,
- family.string()
- );
-#else
- m_font = wxFont( desc.computedPixelSize(),
- fontFamilyToWxFontFamily(desc.genericFamily()),
- italicToWxFontStyle(desc.italic()),
- fontWeightToWxFontWeight(desc.weight()),
- false,
- family.string()
- );
-#endif
- m_fontState = VALID;
- m_fontHash = computeHash();
-
-}
-
-FontPlatformData::~FontPlatformData()
-{
- m_fontState = UNINITIALIZED;
-}
-
-}
diff --git a/WebCore/platform/graphics/wx/FontWx.cpp b/WebCore/platform/graphics/wx/FontWx.cpp
deleted file mode 100644
index 07223e9..0000000
--- a/WebCore/platform/graphics/wx/FontWx.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2007 Kevin Ollivier. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Font.h"
-
-#include "FontFallbackList.h"
-#include "GlyphBuffer.h"
-#include "GraphicsContext.h"
-#include "IntRect.h"
-#include "NotImplemented.h"
-#include "SimpleFontData.h"
-
-#include <wx/dcclient.h>
-#include "fontprops.h"
-#include "non-kerned-drawing.h"
-
-namespace WebCore {
-
-void Font::drawGlyphs(GraphicsContext* graphicsContext, const SimpleFontData* font, const GlyphBuffer& glyphBuffer,
- int from, int numGlyphs, const FloatPoint& point) const
-{
- // prepare DC
- Color color = graphicsContext->fillColor();
-
- // We can't use wx drawing methods on Win/Linux because they automatically kern text
- // so we've created a function with platform dependent drawing implementations that
- // will hopefully be folded into wx once the API has solidified.
- // see platform/wx/wxcode/<platform> for the implementations.
- drawTextWithSpacing(graphicsContext, font, color, glyphBuffer, from, numGlyphs, point);
-}
-
-FloatRect Font::selectionRectForComplexText(const TextRun& run, const IntPoint& point, int h, int from, int to) const
-{
- notImplemented();
- return FloatRect();
-}
-
-void Font::drawComplexText(GraphicsContext* graphicsContext, const TextRun& run, const FloatPoint& point, int from, int to) const
-{
- notImplemented();
-}
-
-float Font::floatWidthForComplexText(const TextRun& run) const
-{
- notImplemented();
- return 0;
-}
-
-int Font::offsetForPositionForComplexText(const TextRun& run, int x, bool includePartialGlyphs) const
-{
- notImplemented();
- return 0;
-}
-
-}
diff --git a/WebCore/platform/graphics/wx/GlyphMapWx.cpp b/WebCore/platform/graphics/wx/GlyphMapWx.cpp
deleted file mode 100755
index ebf86e4..0000000
--- a/WebCore/platform/graphics/wx/GlyphMapWx.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "GlyphPageTreeNode.h"
-
-#include "SimpleFontData.h"
-#include <unicode/utf16.h>
-
-namespace WebCore
-{
-
-bool GlyphPage::fill(unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength, const SimpleFontData* fontData)
-{
- bool isUtf16 = bufferLength != length;
-
- for (unsigned i = 0; i < length; i++) {
- UChar32 character;
-
- if(isUtf16) {
- UChar lead = buffer[i * 2];
- UChar trail = buffer[i * 2 + 1];
- character = U16_GET_SUPPLEMENTARY(lead, trail);
- } else {
- character = buffer[i];
- }
-
- setGlyphDataForIndex(offset + i, character, fontData);
- }
-
- return true;
-}
-
-} \ No newline at end of file
diff --git a/WebCore/platform/graphics/wx/GradientWx.cpp b/WebCore/platform/graphics/wx/GradientWx.cpp
deleted file mode 100644
index fc4661e..0000000
--- a/WebCore/platform/graphics/wx/GradientWx.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2008 Kevin Ollivier <kevino@theolliviers.com> All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Gradient.h"
-
-#include "CSSParser.h"
-#include "NotImplemented.h"
-
-namespace WebCore {
-
-void Gradient::platformDestroy()
-{
- notImplemented();
-}
-
-PlatformGradient Gradient::platformGradient()
-{
- notImplemented();
- return 0;
-}
-
-void Gradient::fill(GraphicsContext*, const FloatRect&)
-{
- notImplemented();
-}
-
-} //namespace
diff --git a/WebCore/platform/graphics/wx/GraphicsContextWx.cpp b/WebCore/platform/graphics/wx/GraphicsContextWx.cpp
deleted file mode 100644
index 435e7ce..0000000
--- a/WebCore/platform/graphics/wx/GraphicsContextWx.cpp
+++ /dev/null
@@ -1,503 +0,0 @@
-/*
- * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "GraphicsContext.h"
-
-#include "AffineTransform.h"
-#include "FloatRect.h"
-#include "Font.h"
-#include "IntRect.h"
-#include "NotImplemented.h"
-#include "Pen.h"
-#include <wtf/MathExtras.h>
-
-#include <math.h>
-#include <stdio.h>
-
-#include <wx/defs.h>
-#include <wx/window.h>
-#include <wx/dcclient.h>
-#include <wx/dcgraph.h>
-#include <wx/graphics.h>
-
-#if __WXMAC__
-#include <Carbon/Carbon.h>
-#elif __WXMSW__
-#include <windows.h>
-#endif
-
-namespace WebCore {
-
-int getWxCompositingOperation(CompositeOperator op, bool hasAlpha)
-{
- // FIXME: Add support for more operators.
- if (op == CompositeSourceOver && !hasAlpha)
- op = CompositeCopy;
-
- int function;
- switch (op) {
- case CompositeClear:
- function = wxCLEAR;
- case CompositeCopy:
- function = wxCOPY;
- break;
- default:
- function = wxCOPY;
- }
- return function;
-}
-
-static int strokeStyleToWxPenStyle(int p)
-{
- if (p == SolidStroke)
- return wxSOLID;
- if (p == DottedStroke)
- return wxDOT;
- if (p == DashedStroke)
- return wxLONG_DASH;
- if (p == NoStroke)
- return wxTRANSPARENT;
-
- return wxSOLID;
-}
-
-class GraphicsContextPlatformPrivate {
-public:
- GraphicsContextPlatformPrivate();
- ~GraphicsContextPlatformPrivate();
-
-#if USE(WXGC)
- wxGCDC* context;
-#else
- wxWindowDC* context;
-#endif
- int mswDCStateID;
- wxRegion gtkCurrentClipRgn;
- wxRegion gtkPaintClipRgn;
-};
-
-GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate() :
- context(0),
- mswDCStateID(0),
- gtkCurrentClipRgn(wxRegion()),
- gtkPaintClipRgn(wxRegion())
-{
-}
-
-GraphicsContextPlatformPrivate::~GraphicsContextPlatformPrivate()
-{
-}
-
-
-GraphicsContext::GraphicsContext(PlatformGraphicsContext* context)
- : m_common(createGraphicsContextPrivate())
- , m_data(new GraphicsContextPlatformPrivate)
-{
- setPaintingDisabled(!context);
- if (context) {
- // Make sure the context starts in sync with our state.
- setPlatformFillColor(fillColor());
- setPlatformStrokeColor(strokeColor());
- }
-#if USE(WXGC)
- m_data->context = (wxGCDC*)context;
-#else
- m_data->context = (wxWindowDC*)context;
-#endif
-}
-
-GraphicsContext::~GraphicsContext()
-{
- destroyGraphicsContextPrivate(m_common);
- delete m_data;
-}
-
-PlatformGraphicsContext* GraphicsContext::platformContext() const
-{
- return (PlatformGraphicsContext*)m_data->context;
-}
-
-void GraphicsContext::savePlatformState()
-{
- if (m_data->context)
- {
-#if USE(WXGC)
- wxGraphicsContext* gc = m_data->context->GetGraphicsContext();
- gc->PushState();
-#else
- // when everything is working with USE_WXGC, we can remove this
- #if __WXMAC__
- CGContextRef context;
- wxGraphicsContext* gc = m_data->context->GetGraphicsContext();
- if (gc)
- context = (CGContextRef)gc->GetNativeContext();
- if (context)
- CGContextSaveGState(context);
- #elif __WXMSW__
- HDC dc = (HDC)m_data->context->GetHDC();
- m_data->mswDCStateID = ::SaveDC(dc);
- #elif __WXGTK__
- m_data->gtkCurrentClipRgn = m_data->context->m_currentClippingRegion;
- m_data->gtkPaintClipRgn = m_data->context->m_paintClippingRegion;
- #endif
-#endif // __WXMAC__
- }
-}
-
-void GraphicsContext::restorePlatformState()
-{
- if (m_data->context)
- {
-#if USE(WXGC)
- wxGraphicsContext* gc = m_data->context->GetGraphicsContext();
- gc->PopState();
-#else
- #if __WXMAC__
- CGContextRef context;
- wxGraphicsContext* gc = m_data->context->GetGraphicsContext();
- if (gc)
- context = (CGContextRef)gc->GetNativeContext();
- if (context)
- CGContextRestoreGState(context);
- #elif __WXMSW__
- HDC dc = (HDC)m_data->context->GetHDC();
- ::RestoreDC(dc, m_data->mswDCStateID);
- #elif __WXGTK__
- m_data->context->m_currentClippingRegion = m_data->gtkCurrentClipRgn;
- m_data->context->m_paintClippingRegion = m_data->gtkPaintClipRgn;
- #endif
-
-#endif // USE_WXGC
- }
-}
-
-// Draws a filled rectangle with a stroked border.
-void GraphicsContext::drawRect(const IntRect& rect)
-{
- if (paintingDisabled())
- return;
-
- m_data->context->SetPen(wxPen(strokeColor(), strokeThickness(), strokeStyleToWxPenStyle(strokeStyle())));
- m_data->context->DrawRectangle(rect.x(), rect.y(), rect.width(), rect.height());
-}
-
-// This is only used to draw borders.
-void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2)
-{
- if (paintingDisabled())
- return;
-
- FloatPoint p1 = point1;
- FloatPoint p2 = point2;
-
- m_data->context->SetPen(wxPen(strokeColor(), strokeThickness(), strokeStyleToWxPenStyle(strokeStyle())));
- m_data->context->DrawLine(point1.x(), point1.y(), point2.x(), point2.y());
-}
-
-// This method is only used to draw the little circles used in lists.
-void GraphicsContext::drawEllipse(const IntRect& rect)
-{
- if (paintingDisabled())
- return;
-
- m_data->context->SetPen(wxPen(strokeColor(), strokeThickness(), strokeStyleToWxPenStyle(strokeStyle())));
- m_data->context->DrawEllipse(rect.x(), rect.y(), rect.width(), rect.height());
-}
-
-void GraphicsContext::strokeArc(const IntRect& rect, int startAngle, int angleSpan)
-{
- if (paintingDisabled())
- return;
-
- m_data->context->SetPen(wxPen(strokeColor(), strokeThickness(), strokeStyleToWxPenStyle(strokeStyle())));
- m_data->context->DrawEllipticArc(rect.x(), rect.y(), rect.width(), rect.height(), startAngle, angleSpan);
-}
-
-void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points, bool shouldAntialias)
-{
- if (paintingDisabled())
- return;
-
- if (npoints <= 1)
- return;
-
- wxPoint* polygon = new wxPoint[npoints];
- for (size_t i = 0; i < npoints; i++)
- polygon[i] = wxPoint(points[i].x(), points[i].y());
- m_data->context->SetPen(wxPen(strokeColor(), strokeThickness(), strokeStyleToWxPenStyle(strokeStyle())));
- m_data->context->DrawPolygon((int)npoints, polygon);
- delete [] polygon;
-}
-
-void GraphicsContext::fillRect(const FloatRect& rect, const Color& color)
-{
- if (paintingDisabled())
- return;
-
- m_data->context->SetPen(*wxTRANSPARENT_PEN);
- m_data->context->SetBrush(wxBrush(color));
- m_data->context->DrawRectangle(rect.x(), rect.y(), rect.width(), rect.height());
-}
-
-void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color& color)
-{
- if (paintingDisabled())
- return;
-
- notImplemented();
-}
-
-void GraphicsContext::drawFocusRing(const Color& color)
-{
- if (paintingDisabled())
- return;
-
- notImplemented();
-}
-
-void GraphicsContext::clip(const FloatRect& r)
-{
- wxWindowDC* windc = dynamic_cast<wxWindowDC*>(m_data->context);
- wxPoint pos(0, 0);
-
- if (windc) {
-#ifndef __WXGTK__
- wxWindow* window = windc->GetWindow();
-#else
- wxWindow* window = windc->m_owner;
-#endif
- if (window) {
- wxWindow* parent = window->GetParent();
- // we need to convert from WebView "global" to WebFrame "local" coords.
- // FIXME: We only want to go to the top WebView.
- while (parent) {
- pos += window->GetPosition();
- parent = parent->GetParent();
- }
- }
- }
-
- m_data->context->SetClippingRegion(r.x() - pos.x, r.y() - pos.y, r.width() + pos.x, r.height() + pos.y);
-}
-
-void GraphicsContext::clipOut(const Path&)
-{
- notImplemented();
-}
-
-void GraphicsContext::clipOut(const IntRect&)
-{
- notImplemented();
-}
-
-void GraphicsContext::clipOutEllipseInRect(const IntRect&)
-{
- notImplemented();
-}
-
-void GraphicsContext::drawLineForText(const IntPoint& origin, int width, bool printing)
-{
- if (paintingDisabled())
- return;
-
- IntPoint endPoint = origin + IntSize(width, 0);
- m_data->context->SetPen(wxPen(strokeColor(), strokeThickness(), wxSOLID));
- m_data->context->DrawLine(origin.x(), origin.y(), endPoint.x(), endPoint.y());
-}
-
-
-void GraphicsContext::drawLineForMisspellingOrBadGrammar(const IntPoint& origin, int width, bool grammar)
-{
- if (grammar)
- m_data->context->SetPen(wxPen(*wxGREEN, 2, wxLONG_DASH));
- else
- m_data->context->SetPen(wxPen(*wxRED, 2, wxLONG_DASH));
-
- m_data->context->DrawLine(origin.x(), origin.y(), origin.x() + width, origin.y());
-}
-
-void GraphicsContext::clip(const Path&)
-{
- notImplemented();
-}
-
-void GraphicsContext::clipToImageBuffer(const FloatRect&, const ImageBuffer*)
-{
- notImplemented();
-}
-
-AffineTransform GraphicsContext::getCTM() const
-{
- notImplemented();
- return AffineTransform();
-}
-
-void GraphicsContext::translate(float tx, float ty)
-{
-#if USE(WXGC)
- if (m_data->context) {
- wxGraphicsContext* gc = m_data->context->GetGraphicsContext();
- gc->Translate(tx, ty);
- }
-#endif
-}
-
-void GraphicsContext::rotate(float angle)
-{
-#if USE(WXGC)
- if (m_data->context) {
- wxGraphicsContext* gc = m_data->context->GetGraphicsContext();
- gc->Rotate(angle);
- }
-#endif
-}
-
-void GraphicsContext::scale(const FloatSize& scale)
-{
-#if USE(WXGC)
- if (m_data->context) {
- wxGraphicsContext* gc = m_data->context->GetGraphicsContext();
- gc->Scale(scale.width(), scale.height());
- }
-#endif
-}
-
-
-FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& frect)
-{
- FloatRect result;
-
- wxCoord x = (wxCoord)frect.x();
- wxCoord y = (wxCoord)frect.y();
-
- x = m_data->context->LogicalToDeviceX(x);
- y = m_data->context->LogicalToDeviceY(y);
- result.setX((float)x);
- result.setY((float)y);
- x = (wxCoord)frect.width();
- y = (wxCoord)frect.height();
- x = m_data->context->LogicalToDeviceXRel(x);
- y = m_data->context->LogicalToDeviceYRel(y);
- result.setWidth((float)x);
- result.setHeight((float)y);
- return result;
-}
-
-void GraphicsContext::setURLForRect(const KURL&, const IntRect&)
-{
- notImplemented();
-}
-
-void GraphicsContext::setCompositeOperation(CompositeOperator op)
-{
- if (m_data->context)
- m_data->context->SetLogicalFunction(getWxCompositingOperation(op, false));
-}
-
-void GraphicsContext::beginPath()
-{
- notImplemented();
-}
-
-void GraphicsContext::addPath(const Path& path)
-{
- notImplemented();
-}
-
-void GraphicsContext::setPlatformStrokeColor(const Color& color)
-{
- if (paintingDisabled())
- return;
-
- if (m_data->context)
- m_data->context->SetPen(wxPen(color, strokeThickness(), strokeStyleToWxPenStyle(strokeStyle())));
-}
-
-void GraphicsContext::setPlatformStrokeThickness(float thickness)
-{
- if (paintingDisabled())
- return;
-
- if (m_data->context)
- m_data->context->SetPen(wxPen(strokeColor(), thickness, strokeStyleToWxPenStyle(strokeStyle())));
-
-}
-
-void GraphicsContext::setPlatformFillColor(const Color& color)
-{
- if (paintingDisabled())
- return;
-
- if (m_data->context)
- m_data->context->SetBrush(wxBrush(color));
-}
-
-void GraphicsContext::concatCTM(const AffineTransform& transform)
-{
- if (paintingDisabled())
- return;
-
- notImplemented();
- return;
-}
-
-void GraphicsContext::setUseAntialiasing(bool enable)
-{
- if (paintingDisabled())
- return;
- notImplemented();
-}
-
-void GraphicsContext::setImageInterpolationQuality(InterpolationQuality)
-{
-}
-
-InterpolationQuality GraphicsContext::imageInterpolationQuality() const
-{
- return InterpolationDefault;
-}
-
-void GraphicsContext::fillPath()
-{
-}
-
-void GraphicsContext::strokePath()
-{
-}
-
-void GraphicsContext::drawPath()
-{
- fillPath();
- strokePath();
-}
-
-void GraphicsContext::fillRect(const FloatRect& rect)
-{
- if (paintingDisabled())
- return;
-}
-
-}
diff --git a/WebCore/platform/graphics/wx/ImageBufferData.h b/WebCore/platform/graphics/wx/ImageBufferData.h
deleted file mode 100644
index d4a6114..0000000
--- a/WebCore/platform/graphics/wx/ImageBufferData.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2008 Kevin Ollivier. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ImageBufferData_h
-#define ImageBufferData_h
-
-
-#include "OwnPtr.h"
-
-namespace WebCore {
-
-class IntSize;
-
-class ImageBufferData {
-public:
- ImageBufferData(const IntSize&);
-};
-
-} // namespace WebCore
-
-#endif // ImageBufferData_h
diff --git a/WebCore/platform/graphics/wx/ImageBufferWx.cpp b/WebCore/platform/graphics/wx/ImageBufferWx.cpp
deleted file mode 100644
index ea3dfe8..0000000
--- a/WebCore/platform/graphics/wx/ImageBufferWx.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ImageBuffer.h"
-
-#include "GraphicsContext.h"
-#include "ImageData.h"
-#include "NotImplemented.h"
-
-namespace WebCore {
-
-ImageBufferData::ImageBufferData(const IntSize&)
-{
-}
-
-ImageBuffer::ImageBuffer(const IntSize&, bool grayScale, bool& success) :
- m_data(IntSize())
-{
- notImplemented();
- success = false;
-}
-
-ImageBuffer::~ImageBuffer()
-{
-}
-
-GraphicsContext* ImageBuffer::context() const
-{
- notImplemented();
- return 0;
-}
-
-PassRefPtr<ImageData> ImageBuffer::getImageData(const IntRect&) const
-{
- notImplemented();
- return 0;
-}
-
-void ImageBuffer::putImageData(ImageData*, const IntRect&, const IntPoint&)
-{
- notImplemented();
-}
-
-String ImageBuffer::toDataURL(const String&) const
-{
- notImplemented();
- return String();
-}
-
-Image* ImageBuffer::image() const
-{
- notImplemented();
- return 0;
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/graphics/wx/ImageSourceWx.cpp b/WebCore/platform/graphics/wx/ImageSourceWx.cpp
deleted file mode 100644
index 3ce4f2a..0000000
--- a/WebCore/platform/graphics/wx/ImageSourceWx.cpp
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Computer, Kevin Ollivier. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ImageSource.h"
-
-#include "BMPImageDecoder.h"
-#include "GIFImageDecoder.h"
-#include "ICOImageDecoder.h"
-#include "JPEGImageDecoder.h"
-#include "PNGImageDecoder.h"
-#include "SharedBuffer.h"
-#include "XBMImageDecoder.h"
-
-#include <wx/defs.h>
-#include <wx/bitmap.h>
-#include <wx/image.h>
-#include <wx/rawbmp.h>
-
-namespace WebCore {
-
-ImageDecoder* createDecoder(const SharedBuffer& data)
-{
- // We need at least 4 bytes to figure out what kind of image we're dealing with.
- int length = data.size();
- if (length < 4)
- return 0;
-
- const unsigned char* uContents = (const unsigned char*)data.data();
- const char* contents = data.data();
-
- // GIFs begin with GIF8(7 or 9).
- if (strncmp(contents, "GIF8", 4) == 0)
- return new GIFImageDecoder();
-
- // Test for PNG.
- if (uContents[0]==0x89 &&
- uContents[1]==0x50 &&
- uContents[2]==0x4E &&
- uContents[3]==0x47)
- return new PNGImageDecoder();
-
- // JPEG
- if (uContents[0]==0xFF &&
- uContents[1]==0xD8 &&
- uContents[2]==0xFF)
- return new JPEGImageDecoder();
-
- // BMP
- if (strncmp(contents, "BM", 2) == 0)
- return new BMPImageDecoder();
-
- // ICOs always begin with a 2-byte 0 followed by a 2-byte 1.
- // CURs begin with 2-byte 0 followed by 2-byte 2.
- if (!memcmp(contents, "\000\000\001\000", 4) ||
- !memcmp(contents, "\000\000\002\000", 4))
- return new ICOImageDecoder();
-
- // XBMs require 8 bytes of info.
- if (length >= 8 && strncmp(contents, "#define ", 8) == 0)
- return new XBMImageDecoder();
-
- // Give up. We don't know what the heck this is.
- return 0;
-}
-
-ImageSource::ImageSource()
- : m_decoder(0)
-{}
-
-ImageSource::~ImageSource()
-{
- delete m_decoder;
-}
-
-bool ImageSource::initialized() const
-{
- return m_decoder;
-}
-
-void ImageSource::setData(SharedBuffer* data, bool allDataReceived)
-{
- // Make the decoder by sniffing the bytes.
- // This method will examine the data and instantiate an instance of the appropriate decoder plugin.
- // If insufficient bytes are available to determine the image type, no decoder plugin will be
- // made.
- m_decoder = createDecoder(*data);
- if (!m_decoder)
- return;
- m_decoder->setData(data, allDataReceived);
-}
-
-bool ImageSource::isSizeAvailable()
-{
- if (!m_decoder)
- return false;
-
- return m_decoder->isSizeAvailable();
-}
-
-IntSize ImageSource::size() const
-{
- if (!m_decoder)
- return IntSize();
-
- return m_decoder->size();
-}
-
-IntSize ImageSource::frameSizeAtIndex(size_t) const
-{
- return size();
-}
-
-int ImageSource::repetitionCount()
-{
- if (!m_decoder)
- return cAnimationNone;
-
- return m_decoder->repetitionCount();
-}
-
-size_t ImageSource::frameCount() const
-{
- return m_decoder ? m_decoder->frameCount() : 0;
-}
-
-bool ImageSource::frameIsCompleteAtIndex(size_t index)
-{
- // FIXME: should we be testing the RGBA32Buffer's status as well?
- return (m_decoder && m_decoder->frameBufferAtIndex(index) != 0);
-}
-
-void ImageSource::clear()
-{
- delete m_decoder;
- m_decoder = 0;
-}
-
-NativeImagePtr ImageSource::createFrameAtIndex(size_t index)
-{
- if (!m_decoder)
- return 0;
-
- RGBA32Buffer* buffer = m_decoder->frameBufferAtIndex(index);
- if (!buffer || buffer->status() == RGBA32Buffer::FrameEmpty)
- return 0;
-
- IntRect imageRect = buffer->rect();
- unsigned char* bytes = (unsigned char*)buffer->bytes().data();
- long colorSize = buffer->bytes().size();
-
- typedef wxPixelData<wxBitmap, wxAlphaPixelFormat> PixelData;
-
- int width = size().width();
- int height = size().height();
-
- wxBitmap* bmp = new wxBitmap(width, height, 32);
- PixelData data(*bmp);
-
- int rowCounter = 0;
- long pixelCounter = 0;
-
- PixelData::Iterator p(data);
-
- PixelData::Iterator rowStart = p;
-
- // NB: It appears that the data is in BGRA format instead of RGBA format.
- // This code works properly on both ppc and intel, meaning the issue is
- // likely not an issue of byte order getting mixed up on different archs.
- for (long i = 0; i < buffer->bytes().size()*4; i+=4) {
- p.Red() = bytes[i+2];
- p.Green() = bytes[i+1];
- p.Blue() = bytes[i+0];
- p.Alpha() = bytes[i+3];
-
- p++;
-
- pixelCounter++;
- if ( (pixelCounter % width ) == 0 ) {
- rowCounter++;
- p = rowStart;
- p.MoveTo(data, 0, rowCounter);
- }
-
- }
-
- bmp->UseAlpha();
- ASSERT(bmp->IsOk());
- return bmp;
-}
-
-float ImageSource::frameDurationAtIndex(size_t index)
-{
- if (!m_decoder)
- return 0;
-
- RGBA32Buffer* buffer = m_decoder->frameBufferAtIndex(index);
- if (!buffer || buffer->status() == RGBA32Buffer::FrameEmpty)
- return 0;
-
- float duration = buffer->duration() / 1000.0f;
-
- // Follow other ports (and WinIE's) behavior to slow annoying ads that
- // specify a 0 duration.
- if (duration < 0.051f)
- return 0.100f;
- return duration;
-}
-
-bool ImageSource::frameHasAlphaAtIndex(size_t index)
-{
- if (!m_decoder || !m_decoder->supportsAlpha())
- return false;
-
- RGBA32Buffer* buffer = m_decoder->frameBufferAtIndex(index);
- if (!buffer || buffer->status() == RGBA32Buffer::FrameEmpty)
- return false;
-
- return buffer->hasAlpha();
-}
-
-}
diff --git a/WebCore/platform/graphics/wx/ImageWx.cpp b/WebCore/platform/graphics/wx/ImageWx.cpp
deleted file mode 100644
index a05a31f..0000000
--- a/WebCore/platform/graphics/wx/ImageWx.cpp
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Computer, Kevin Ollivier. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Image.h"
-
-#include "AffineTransform.h"
-#include "BitmapImage.h"
-#include "FloatRect.h"
-#include "GraphicsContext.h"
-#include "NotImplemented.h"
-
-#include <math.h>
-#include <stdio.h>
-
-#include <wx/defs.h>
-#include <wx/bitmap.h>
-#include <wx/dc.h>
-#include <wx/dcmemory.h>
-#include <wx/dcgraph.h>
-#include <wx/graphics.h>
-#include <wx/image.h>
-#include <wx/thread.h>
-
-// This function loads resources from WebKit
-Vector<char> loadResourceIntoArray(const char*);
-
-namespace WebCore {
-
-// this is in GraphicsContextWx.cpp
-int getWxCompositingOperation(CompositeOperator op, bool hasAlpha);
-
-void FrameData::clear()
-{
- if (m_frame) {
- delete m_frame;
- m_frame = 0;
- // NOTE: We purposefully don't reset metadata here, so that even if we
- // throw away previously-decoded data, animation loops can still access
- // properties like frame durations without re-decoding.
- }
-}
-
-// ================================================
-// Image Class
-// ================================================
-
-PassRefPtr<Image> Image::loadPlatformResource(const char *name)
-{
- Vector<char> arr = loadResourceIntoArray(name);
- RefPtr<Image> img = BitmapImage::create();
- RefPtr<SharedBuffer> buffer = SharedBuffer::create(arr.data(), arr.size());
- img->setData(buffer, true);
- return img.release();
-}
-
-void BitmapImage::initPlatformData()
-{
- // FIXME: NYI
-}
-
-// Drawing Routines
-
-void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dst, const FloatRect& src, CompositeOperator op)
-{
- if (!m_source.initialized())
- return;
-
- if (mayFillWithSolidColor()) {
- fillWithSolidColor(ctxt, dst, solidColor(), op);
- return;
- }
-
-#if USE(WXGC)
- wxGCDC* context = (wxGCDC*)ctxt->platformContext();
-#else
- wxWindowDC* context = ctxt->platformContext();
-#endif
-
- startAnimation();
-
- wxBitmap* bitmap = frameAtIndex(m_currentFrame);
- if (!bitmap) // If it's too early we won't have an image yet.
- return;
-
- // If we're drawing a sub portion of the image or scaling then create
- // a pattern transformation on the image and draw the transformed pattern.
- // Test using example site at http://www.meyerweb.com/eric/css/edge/complexspiral/demo.html
- // FIXME: NYI
-
- ctxt->save();
-
- // Set the compositing operation.
- ctxt->setCompositeOperation(op);
-
- IntRect srcIntRect(src);
- IntRect dstIntRect(dst);
- bool rescaling = false;
- if ((dstIntRect.width() != srcIntRect.width()) || (dstIntRect.height() != srcIntRect.height()))
- {
- rescaling = true;
- wxImage img = bitmap->ConvertToImage();
- img.Rescale(dstIntRect.width(), dstIntRect.height());
- bitmap = new wxBitmap(img);
- }
- wxMemoryDC mydc;
- ASSERT(bitmap->GetRefData());
- mydc.SelectObject(*bitmap);
-
- context->Blit((wxCoord)dstIntRect.x(),(wxCoord)dstIntRect.y(), (wxCoord)dstIntRect.width(), (wxCoord)dstIntRect.height(), &mydc,
- (wxCoord)srcIntRect.x(), (wxCoord)srcIntRect.y(), wxCOPY, true);
- mydc.SelectObject(wxNullBitmap);
-
- // NB: delete is causing crashes during page load, but not during the deletion
- // itself. It occurs later on when a valid bitmap created in frameAtIndex
- // suddenly becomes invalid after returning. It's possible these errors deal
- // with reentrancy and threding problems.
- //delete bitmap;
- if (rescaling)
- {
- delete bitmap;
- bitmap = NULL;
- }
- ctxt->restore();
-}
-
-void BitmapImage::drawPattern(GraphicsContext* ctxt, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, CompositeOperator, const FloatRect& dstRect)
-{
- if (!m_source.initialized())
- return;
-
-#if USE(WXGC)
- wxGCDC* context = (wxGCDC*)ctxt->platformContext();
-#else
- wxWindowDC* context = ctxt->platformContext();
-#endif
-
- ctxt->save();
- ctxt->clip(IntRect(dstRect.x(), dstRect.y(), dstRect.width(), dstRect.height()));
- wxBitmap* bitmap = frameAtIndex(m_currentFrame);
- if (!bitmap) // If it's too early we won't have an image yet.
- return;
-
- float currentW = 0;
- float currentH = 0;
-
-#if USE(WXGC)
- wxGraphicsContext* gc = context->GetGraphicsContext();
- gc->ConcatTransform(patternTransform);
-#endif
-
- wxMemoryDC mydc;
- mydc.SelectObject(*bitmap);
-
- while ( currentW < dstRect.width() ) {
- while ( currentH < dstRect.height() ) {
- context->Blit((wxCoord)dstRect.x() + currentW, (wxCoord)dstRect.y() + currentH,
- (wxCoord)srcRect.width(), (wxCoord)srcRect.height(), &mydc,
- (wxCoord)srcRect.x(), (wxCoord)srcRect.y(), wxCOPY, true);
- currentH += srcRect.height();
- }
- currentW += srcRect.width();
- currentH = 0;
- }
- ctxt->restore();
- mydc.SelectObject(wxNullBitmap);
-
- // NB: delete is causing crashes during page load, but not during the deletion
- // itself. It occurs later on when a valid bitmap created in frameAtIndex
- // suddenly becomes invalid after returning. It's possible these errors deal
- // with reentrancy and threding problems.
- //delete bitmap;
-
- startAnimation();
-
-}
-
-void BitmapImage::checkForSolidColor()
-{
-
-}
-
-void BitmapImage::invalidatePlatformData()
-{
-
-}
-
-}
diff --git a/WebCore/platform/graphics/wx/IntPointWx.cpp b/WebCore/platform/graphics/wx/IntPointWx.cpp
deleted file mode 100644
index 389ac9f..0000000
--- a/WebCore/platform/graphics/wx/IntPointWx.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Kevin Ollivier <kevino@theolliviers.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "IntPoint.h"
-
-#include <wx/defs.h>
-#include <wx/gdicmn.h>
-
-namespace WebCore {
-
-IntPoint::IntPoint(const wxPoint& p)
- : m_x(p.x)
- , m_y(p.y)
-{
-}
-
-IntPoint::operator wxPoint() const
-{
- return wxPoint(m_x, m_y);
-}
-
-}
diff --git a/WebCore/platform/graphics/wx/IntRectWx.cpp b/WebCore/platform/graphics/wx/IntRectWx.cpp
deleted file mode 100644
index 10c1b55..0000000
--- a/WebCore/platform/graphics/wx/IntRectWx.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Kevin Ollivier <kevino@theolliviers.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "IntRect.h"
-
-#include <wx/defs.h>
-#include <wx/gdicmn.h>
-
-namespace WebCore {
-
-IntRect::IntRect(const wxRect& r)
- : m_location(IntPoint(r.x, r.y))
- , m_size(IntSize(r.width, r.height))
-{
-}
-
-IntRect::operator wxRect() const
-{
- return wxRect(x(), y(), width(), height());
-}
-
-}
diff --git a/WebCore/platform/graphics/wx/PathWx.cpp b/WebCore/platform/graphics/wx/PathWx.cpp
deleted file mode 100644
index 5ff9914..0000000
--- a/WebCore/platform/graphics/wx/PathWx.cpp
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Copyright (C) 2007 Kevin Ollivier All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Path.h"
-
-#include "AffineTransform.h"
-#include "FloatPoint.h"
-#include "FloatRect.h"
-#include "NotImplemented.h"
-
-#include <stdio.h>
-
-#include <wx/defs.h>
-#include <wx/graphics.h>
-
-namespace WebCore {
-
-int getWxWindRuleForWindRule(WindRule rule)
-{
- if (rule == RULE_EVENODD)
- return wxODDEVEN_RULE;
-
- return wxWINDING_RULE;
-}
-
-Path::Path()
-{
- m_path = 0;
- // NB: This only supports the 'default' renderer as determined by wx on
- // each platform. If an app uses a non-default renderer (e.g. Cairo on Win),
- // there will be problems, but there's no way we can determine which
- // renderer an app is using right now with wx API, so we will just handle
- // the common case.
-#if USE(WXGC)
- wxGraphicsRenderer* renderer = wxGraphicsRenderer::GetDefaultRenderer();
- if (renderer) {
- wxGraphicsPath path = renderer->CreatePath();
- m_path = new wxGraphicsPath(path);
- }
-#endif
-}
-
-Path::~Path()
-{
-}
-
-Path::Path(const Path& path)
-{
- m_path = (PlatformPath*)&path.m_path;
-}
-
-bool Path::contains(const FloatPoint& point, const WindRule rule) const
-{
- return false;
-}
-
-void Path::translate(const FloatSize&)
-{
- notImplemented();
-}
-
-FloatRect Path::boundingRect() const
-{
-#if USE(WXGC)
- if (m_path) {
- return m_path->GetBox();
- }
-#endif
-
- return FloatRect();
-}
-
-Path& Path::operator=(const Path&)
-{
- notImplemented();
- return*this;
-}
-
-void Path::clear()
-{
- if (m_path)
- delete m_path;
-
-#if USE(WXGC)
- wxGraphicsRenderer* renderer = wxGraphicsRenderer::GetDefaultRenderer();
- if (renderer) {
- wxGraphicsPath path = renderer->CreatePath();
- m_path = new wxGraphicsPath(path);
- }
-#endif
-}
-
-void Path::moveTo(const FloatPoint& point)
-{
-#if USE(WXGC)
- if (m_path)
- m_path->MoveToPoint(point.x(), point.y());
-#endif
-}
-
-void Path::addLineTo(const FloatPoint&)
-{
- notImplemented();
-}
-
-void Path::addQuadCurveTo(const FloatPoint&, const FloatPoint&)
-{
- notImplemented();
-}
-
-void Path::addBezierCurveTo(const FloatPoint&, const FloatPoint&, const FloatPoint&)
-{
- notImplemented();
-}
-
-void Path::addArcTo(const FloatPoint&, const FloatPoint&, float)
-{
- notImplemented();
-}
-
-void Path::closeSubpath()
-{
- notImplemented();
-}
-
-void Path::addArc(const FloatPoint&, float, float, float, bool)
-{
- notImplemented();
-}
-
-void Path::addRect(const FloatRect&)
-{
- notImplemented();
-}
-
-void Path::addEllipse(const FloatRect&)
-{
- notImplemented();
-}
-
-void Path::transform(const AffineTransform&)
-{
- notImplemented();
-}
-
-void Path::apply(void* info, PathApplierFunction function) const
-{
- notImplemented();
-}
-
-bool Path::isEmpty() const
-{
- notImplemented();
- return false;
-}
-
-}
diff --git a/WebCore/platform/graphics/wx/PenWx.cpp b/WebCore/platform/graphics/wx/PenWx.cpp
deleted file mode 100644
index 5a131e3..0000000
--- a/WebCore/platform/graphics/wx/PenWx.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Pen.h"
-
-#include <wx/defs.h>
-#include <wx/pen.h>
-#include <wx/colour.h>
-
-namespace WebCore {
-
-// Pen style conversion functions
-static int penStyleToWxPenStyle(int p)
-{
- if (p == Pen::SolidLine)
- return wxSOLID;
- if (p == Pen::DotLine)
- return wxDOT;
- if (p == Pen::DashLine)
- return wxLONG_DASH;
- if (p == Pen::NoPen)
- return wxTRANSPARENT;
-
- return wxSOLID;
-}
-
-static Pen::PenStyle wxPenStyleToPenStyle(int p)
-{
- if (p == wxSOLID)
- return Pen::SolidLine;
- if (p == wxDOT)
- return Pen::DotLine;
- if (p == wxLONG_DASH || p == wxSHORT_DASH || p == wxDOT_DASH || p == wxUSER_DASH)
- return Pen::DashLine;
- if (p == wxTRANSPARENT)
- return Pen::NoPen;
-
- return Pen::SolidLine;
-}
-
-Pen::Pen(const wxPen& p)
-{
- wxColour color = p.GetColour();
- setColor(Color(color.Red(), color.Green(), color.Blue()));
- setWidth(p.GetWidth());
- setStyle(wxPenStyleToPenStyle(p.GetStyle()));
-}
-
-Pen::operator wxPen() const
-{
- return wxPen(wxColour(m_color.red(), m_color.blue(), m_color.green()), width(), penStyleToWxPenStyle(style()));
-}
-
-}
diff --git a/WebCore/platform/graphics/wx/SimpleFontDataWx.cpp b/WebCore/platform/graphics/wx/SimpleFontDataWx.cpp
deleted file mode 100755
index a509933..0000000
--- a/WebCore/platform/graphics/wx/SimpleFontDataWx.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "SimpleFontData.h"
-
-#include "FontCache.h"
-#include "FloatRect.h"
-#include "FontDescription.h"
-#include <wtf/MathExtras.h>
-#include <unicode/uchar.h>
-#include <unicode/unorm.h>
-
-#include <wx/defs.h>
-#include <wx/dcscreen.h>
-#include "fontprops.h"
-
-namespace WebCore
-{
-
-void SimpleFontData::platformInit()
-{
- wxFont font = m_font.font();
- wxFontProperties props = wxFontProperties(&font);
- m_ascent = props.GetAscent();
- m_descent = props.GetDescent();
- m_lineSpacing = props.GetLineSpacing();
- m_xHeight = props.GetXHeight();
- m_unitsPerEm = 1; // FIXME!
- m_lineGap = props.GetLineGap();
-}
-
-void SimpleFontData::platformDestroy()
-{
- delete m_smallCapsFontData;
-}
-
-SimpleFontData* SimpleFontData::smallCapsFontData(const FontDescription& fontDescription) const
-{
- if (!m_smallCapsFontData){
- FontDescription desc = FontDescription(fontDescription);
- desc.setSpecifiedSize(0.70f*fontDescription.computedSize());
- const FontPlatformData* pdata = new FontPlatformData(desc, desc.family().family());
- m_smallCapsFontData = new SimpleFontData(*pdata);
- }
- return m_smallCapsFontData;
-}
-
-bool SimpleFontData::containsCharacters(const UChar* characters, int length) const
-{
- // FIXME: We will need to implement this to load non-ASCII encoding sites
- return true;
-}
-
-void SimpleFontData::determinePitch()
-{
- if (m_font.font().Ok())
- m_treatAsFixedPitch = m_font.font().IsFixedWidth();
- else
- m_treatAsFixedPitch = false;
-}
-
-float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
-{
- // TODO: fix this! Make GetTextExtents a method of wxFont in 2.9
- int width = 10;
- GetTextExtent(m_font.font(), (wxChar)glyph, &width, NULL);
- return width;
-}
-
-}
diff --git a/WebCore/platform/gtk/ClipboardGtk.cpp b/WebCore/platform/gtk/ClipboardGtk.cpp
deleted file mode 100644
index 44aa7f7..0000000
--- a/WebCore/platform/gtk/ClipboardGtk.cpp
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "config.h"
-#include "ClipboardGtk.h"
-
-#include "NotImplemented.h"
-#include "StringHash.h"
-
-#include "Editor.h"
-
-namespace WebCore {
-
-PassRefPtr<Clipboard> Editor::newGeneralClipboard(ClipboardAccessPolicy policy)
-{
- return ClipboardGtk::create(policy, false);
-}
-
-ClipboardGtk::ClipboardGtk(ClipboardAccessPolicy policy, bool forDragging)
- : Clipboard(policy, forDragging)
-{
- notImplemented();
-}
-
-ClipboardGtk::~ClipboardGtk()
-{
- notImplemented();
-}
-
-void ClipboardGtk::clearData(const String&)
-{
- notImplemented();
-}
-
-void ClipboardGtk::clearAllData()
-{
- notImplemented();
-}
-
-String ClipboardGtk::getData(const String&, bool &success) const
-{
- notImplemented();
- success = false;
- return String();
-}
-
-bool ClipboardGtk::setData(const String&, const String&)
-{
- notImplemented();
- return false;
-}
-
-HashSet<String> ClipboardGtk::types() const
-{
- notImplemented();
- return HashSet<String>();
-}
-
-IntPoint ClipboardGtk::dragLocation() const
-{
- notImplemented();
- return IntPoint(0, 0);
-}
-
-CachedImage* ClipboardGtk::dragImage() const
-{
- notImplemented();
- return 0;
-}
-
-void ClipboardGtk::setDragImage(CachedImage*, const IntPoint&)
-{
- notImplemented();
-}
-
-Node* ClipboardGtk::dragImageElement()
-{
- notImplemented();
- return 0;
-}
-
-void ClipboardGtk::setDragImageElement(Node*, const IntPoint&)
-{
- notImplemented();
-}
-
-DragImageRef ClipboardGtk::createDragImage(IntPoint&) const
-{
- notImplemented();
- return 0;
-}
-
-void ClipboardGtk::declareAndWriteDragImage(Element*, const KURL&, const String&, Frame*)
-{
- notImplemented();
-}
-
-void ClipboardGtk::writeURL(const KURL&, const String&, Frame*)
-{
- notImplemented();
-}
-
-void ClipboardGtk::writeRange(Range*, Frame*)
-{
- notImplemented();
-}
-
-bool ClipboardGtk::hasData()
-{
- notImplemented();
- return false;
-}
-
-}
diff --git a/WebCore/platform/gtk/ClipboardGtk.h b/WebCore/platform/gtk/ClipboardGtk.h
deleted file mode 100644
index b8b4ddf..0000000
--- a/WebCore/platform/gtk/ClipboardGtk.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2007, Holger Hans Peter Freyther
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ClipboardGdk_h
-#define ClipboardGdk_h
-
-#include "Clipboard.h"
-
-namespace WebCore {
- class CachedImage;
-
- // State available during IE's events for drag and drop and copy/paste
- // Created from the EventHandlerGtk to be used by the dom
- class ClipboardGtk : public Clipboard {
- public:
- static PassRefPtr<ClipboardGtk> create(ClipboardAccessPolicy policy, bool isForDragging)
- {
- return adoptRef(new ClipboardGtk(policy, isForDragging));
- }
- virtual ~ClipboardGtk();
-
- void clearData(const String&);
- void clearAllData();
- String getData(const String&, bool&) const;
- bool setData(const String&, const String&);
-
- HashSet<String> types() const;
- IntPoint dragLocation() const;
- CachedImage* dragImage() const;
- void setDragImage(CachedImage*, const IntPoint&);
- Node* dragImageElement();
- void setDragImageElement(Node*, const IntPoint&);
-
- virtual DragImageRef createDragImage(IntPoint&) const;
- virtual void declareAndWriteDragImage(Element*, const KURL&, const String&, Frame*);
- virtual void writeURL(const KURL&, const String&, Frame*);
- virtual void writeRange(Range*, Frame*);
-
- virtual bool hasData();
-
- private:
- ClipboardGtk(ClipboardAccessPolicy, bool);
- };
-}
-
-#endif
diff --git a/WebCore/platform/gtk/ContextMenuGtk.cpp b/WebCore/platform/gtk/ContextMenuGtk.cpp
deleted file mode 100644
index 2365379..0000000
--- a/WebCore/platform/gtk/ContextMenuGtk.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2007 Holger Hans Peter Freyther
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "config.h"
-#include "ContextMenu.h"
-
-#include "ContextMenuController.h"
-
-#include <gtk/gtk.h>
-
-namespace WebCore {
-
-// TODO: ref-counting correctness checking.
-// See http://bugs.webkit.org/show_bug.cgi?id=16115
-
-static void menuItemActivated(GtkMenuItem* item, ContextMenuController* controller)
-{
- ContextMenuItem contextItem(item);
- controller->contextMenuItemSelected(&contextItem);
-}
-
-ContextMenu::ContextMenu(const HitTestResult& result)
- : m_hitTestResult(result)
-{
- m_platformDescription = GTK_MENU(gtk_menu_new());
-
-#if GLIB_CHECK_VERSION(2,10,0)
- g_object_ref_sink(G_OBJECT(m_platformDescription));
-#else
- g_object_ref(G_OBJECT(m_platformDescription));
- gtk_object_sink(GTK_OBJECT(m_platformDescription));
-#endif
-}
-
-ContextMenu::~ContextMenu()
-{
- if (m_platformDescription)
- g_object_unref(m_platformDescription);
-}
-
-void ContextMenu::appendItem(ContextMenuItem& item)
-{
- ASSERT(m_platformDescription);
- checkOrEnableIfNeeded(item);
-
- ContextMenuItemType type = item.type();
- GtkMenuItem* platformItem = ContextMenuItem::createNativeMenuItem(item.releasePlatformDescription());
- ASSERT(platformItem);
-
- if (type == ActionType || type == CheckableActionType)
- g_signal_connect(platformItem, "activate", G_CALLBACK(menuItemActivated), controller());
-
- gtk_menu_shell_append(GTK_MENU_SHELL(m_platformDescription), GTK_WIDGET(platformItem));
- gtk_widget_show(GTK_WIDGET(platformItem));
-}
-
-void ContextMenu::setPlatformDescription(PlatformMenuDescription menu)
-{
- ASSERT(menu);
- if (m_platformDescription)
- g_object_unref(m_platformDescription);
-
- m_platformDescription = menu;
- g_object_ref(m_platformDescription);
-}
-
-PlatformMenuDescription ContextMenu::platformDescription() const
-{
- return m_platformDescription;
-}
-
-PlatformMenuDescription ContextMenu::releasePlatformDescription()
-{
- PlatformMenuDescription description = m_platformDescription;
- m_platformDescription = 0;
-
- return description;
-}
-
-}
diff --git a/WebCore/platform/gtk/ContextMenuItemGtk.cpp b/WebCore/platform/gtk/ContextMenuItemGtk.cpp
deleted file mode 100644
index 84f78c0..0000000
--- a/WebCore/platform/gtk/ContextMenuItemGtk.cpp
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- * Copyright (C) 2007 Holger Hans Peter Freyther
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "config.h"
-#include "ContextMenu.h"
-#include "ContextMenuItem.h"
-#include "CString.h"
-#include "NotImplemented.h"
-
-#include <gtk/gtk.h>
-
-#define WEBKIT_CONTEXT_MENU_ACTION "webkit-context-menu"
-
-namespace WebCore {
-
-static const char* gtkStockIDFromContextMenuAction(const ContextMenuAction& action)
-{
- switch (action) {
- case ContextMenuItemTagCopyLinkToClipboard:
- case ContextMenuItemTagCopyImageToClipboard:
- case ContextMenuItemTagCopy:
- return GTK_STOCK_COPY;
- case ContextMenuItemTagOpenLinkInNewWindow:
- case ContextMenuItemTagOpenImageInNewWindow:
- case ContextMenuItemTagOpenFrameInNewWindow:
- return GTK_STOCK_OPEN;
- case ContextMenuItemTagDownloadLinkToDisk:
- case ContextMenuItemTagDownloadImageToDisk:
- return GTK_STOCK_SAVE;
- case ContextMenuItemTagGoBack:
- return GTK_STOCK_GO_BACK;
- case ContextMenuItemTagGoForward:
- return GTK_STOCK_GO_FORWARD;
- case ContextMenuItemTagStop:
- return GTK_STOCK_STOP;
- case ContextMenuItemTagReload:
- return GTK_STOCK_REFRESH;
- case ContextMenuItemTagCut:
- return GTK_STOCK_CUT;
- case ContextMenuItemTagPaste:
- return GTK_STOCK_PASTE;
- case ContextMenuItemTagDelete:
- return GTK_STOCK_DELETE;
-#if GTK_CHECK_VERSION(2, 10, 0)
- case ContextMenuItemTagSelectAll:
- return GTK_STOCK_SELECT_ALL;
-#endif
- case ContextMenuItemTagSpellingGuess:
- return GTK_STOCK_INFO;
- case ContextMenuItemTagIgnoreSpelling:
- return GTK_STOCK_NO;
- case ContextMenuItemTagLearnSpelling:
- return GTK_STOCK_OK;
- case ContextMenuItemTagOther:
- return GTK_STOCK_MISSING_IMAGE;
- case ContextMenuItemTagSearchInSpotlight:
- return GTK_STOCK_FIND;
- case ContextMenuItemTagSearchWeb:
- return GTK_STOCK_FIND;
- case ContextMenuItemTagOpenWithDefaultApplication:
- return GTK_STOCK_OPEN;
- case ContextMenuItemPDFZoomIn:
- return GTK_STOCK_ZOOM_IN;
- case ContextMenuItemPDFZoomOut:
- return GTK_STOCK_ZOOM_OUT;
- case ContextMenuItemPDFAutoSize:
- return GTK_STOCK_ZOOM_FIT;
- case ContextMenuItemPDFNextPage:
- return GTK_STOCK_GO_FORWARD;
- case ContextMenuItemPDFPreviousPage:
- return GTK_STOCK_GO_BACK;
- // New tags, not part of API
- case ContextMenuItemTagOpenLink:
- return GTK_STOCK_OPEN;
- case ContextMenuItemTagCheckSpelling:
- return GTK_STOCK_SPELL_CHECK;
- case ContextMenuItemTagFontMenu:
- return GTK_STOCK_SELECT_FONT;
- case ContextMenuItemTagShowFonts:
- return GTK_STOCK_SELECT_FONT;
- case ContextMenuItemTagBold:
- return GTK_STOCK_BOLD;
- case ContextMenuItemTagItalic:
- return GTK_STOCK_ITALIC;
- case ContextMenuItemTagUnderline:
- return GTK_STOCK_UNDERLINE;
- case ContextMenuItemTagShowColors:
- return GTK_STOCK_SELECT_COLOR;
- default:
- return NULL;
- }
-}
-
-// Extract the ActionType from the menu item
-ContextMenuItem::ContextMenuItem(GtkMenuItem* item)
- : m_platformDescription()
-{
- if (GTK_IS_SEPARATOR_MENU_ITEM(item))
- m_platformDescription.type = SeparatorType;
- else if (gtk_menu_item_get_submenu(item))
- m_platformDescription.type = SubmenuType;
- else if (GTK_IS_CHECK_MENU_ITEM(item)) {
- m_platformDescription.type = CheckableActionType;
- m_platformDescription.checked = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item));
- } else
- m_platformDescription.type = ActionType;
-
- m_platformDescription.action = *static_cast<ContextMenuAction*>(g_object_get_data(G_OBJECT(item), WEBKIT_CONTEXT_MENU_ACTION));
-
- m_platformDescription.subMenu = GTK_MENU(gtk_menu_item_get_submenu(item));
- if (m_platformDescription.subMenu)
- g_object_ref(m_platformDescription.subMenu);
-}
-
-ContextMenuItem::ContextMenuItem(ContextMenu*)
-{
- notImplemented();
-}
-
-ContextMenuItem::ContextMenuItem(ContextMenuItemType type, ContextMenuAction action, const String& title, ContextMenu* subMenu)
-{
- m_platformDescription.type = type;
- m_platformDescription.action = action;
- m_platformDescription.title = title;
-
- setSubMenu(subMenu);
-}
-
-ContextMenuItem::~ContextMenuItem()
-{
- if (m_platformDescription.subMenu)
- g_object_unref(m_platformDescription.subMenu);
-}
-
-GtkMenuItem* ContextMenuItem::createNativeMenuItem(const PlatformMenuItemDescription& menu)
-{
- GtkMenuItem* item = 0;
- if (menu.type == SeparatorType)
- item = GTK_MENU_ITEM(gtk_separator_menu_item_new());
- else {
- if (menu.type == CheckableActionType) {
- item = GTK_MENU_ITEM(gtk_check_menu_item_new_with_mnemonic(menu.title.utf8().data()));
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), menu.checked);
- } else {
- if (const gchar* stockID = gtkStockIDFromContextMenuAction(menu.action)) {
- item = GTK_MENU_ITEM(gtk_image_menu_item_new_with_mnemonic(menu.title.utf8().data()));
- GtkWidget* image = gtk_image_new_from_stock(stockID, GTK_ICON_SIZE_MENU);
- gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image);
- } else
- item = GTK_MENU_ITEM(gtk_menu_item_new_with_mnemonic(menu.title.utf8().data()));
- }
-
- ContextMenuAction* menuAction = static_cast<ContextMenuAction*>(malloc(sizeof(ContextMenuAction*)));
- *menuAction = menu.action;
- g_object_set_data(G_OBJECT(item), WEBKIT_CONTEXT_MENU_ACTION, menuAction);
-
- gtk_widget_set_sensitive(GTK_WIDGET(item), menu.enabled);
-
- if (menu.subMenu)
- gtk_menu_item_set_submenu(item, GTK_WIDGET(menu.subMenu));
- }
-
- return item;
-}
-
-PlatformMenuItemDescription ContextMenuItem::releasePlatformDescription()
-{
- PlatformMenuItemDescription description = m_platformDescription;
- m_platformDescription = PlatformMenuItemDescription();
- return description;
-}
-
-ContextMenuItemType ContextMenuItem::type() const
-{
- return m_platformDescription.type;
-}
-
-void ContextMenuItem::setType(ContextMenuItemType type)
-{
- m_platformDescription.type = type;
-}
-
-ContextMenuAction ContextMenuItem::action() const
-{
- return m_platformDescription.action;
-}
-
-void ContextMenuItem::setAction(ContextMenuAction action)
-{
- m_platformDescription.action = action;
-}
-
-String ContextMenuItem::title() const
-{
- notImplemented();
- return String();
-}
-
-void ContextMenuItem::setTitle(const String&)
-{
- notImplemented();
-}
-
-PlatformMenuDescription ContextMenuItem::platformSubMenu() const
-{
- return m_platformDescription.subMenu;
-}
-
-void ContextMenuItem::setSubMenu(ContextMenu* menu)
-{
- if (m_platformDescription.subMenu)
- g_object_unref(m_platformDescription.subMenu);
-
- if (!menu)
- return;
-
- m_platformDescription.subMenu = menu->releasePlatformDescription();
- m_platformDescription.type = SubmenuType;
-
-#if GLIB_CHECK_VERSION(2,10,0)
- g_object_ref_sink(G_OBJECT(m_platformDescription.subMenu));
-#else
- g_object_ref(G_OBJECT(m_platformDescription.subMenu));
- gtk_object_sink(GTK_OBJECT(m_platformDescription.subMenu));
-#endif
-}
-
-void ContextMenuItem::setChecked(bool shouldCheck)
-{
- m_platformDescription.checked = shouldCheck;
-}
-
-void ContextMenuItem::setEnabled(bool shouldEnable)
-{
- m_platformDescription.enabled = shouldEnable;
-}
-
-}
diff --git a/WebCore/platform/gtk/CursorGtk.cpp b/WebCore/platform/gtk/CursorGtk.cpp
deleted file mode 100644
index 76f6d00..0000000
--- a/WebCore/platform/gtk/CursorGtk.cpp
+++ /dev/null
@@ -1,341 +0,0 @@
-/*
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
- * Copyright (C) 2007 Christian Dywan <christian@twotoasts.de>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "CursorGtk.h"
-
-#include "NotImplemented.h"
-#include <wtf/Assertions.h>
-
-#include <gdk/gdk.h>
-#include <gtk/gtk.h>
-
-namespace WebCore {
-
-static GdkCursor* customCursorNew(CustomCursorType cursorType)
-{
- CustomCursor cursor = CustomCursors[cursorType];
- GdkCursor* c = gdk_cursor_new_from_name(gdk_display_get_default(), cursor.name);
- if (!c) {
- const GdkColor fg = { 0, 0, 0, 0 };
- const GdkColor bg = { 65535, 65535, 65535, 65535 };
-
- GdkPixmap* source = gdk_bitmap_create_from_data(NULL, cursor.bits, 32, 32);
- GdkPixmap* mask = gdk_bitmap_create_from_data(NULL, cursor.mask_bits, 32, 32);
- c = gdk_cursor_new_from_pixmap(source, mask, &fg, &bg, cursor.hot_x, cursor.hot_y);
- g_object_unref(source);
- g_object_unref(mask);
- }
- return c;
-}
-
-
-Cursor::Cursor(const Cursor& other)
- : m_impl(other.m_impl)
-{
- if (m_impl)
- gdk_cursor_ref(m_impl);
-}
-
-Cursor::Cursor(Image*, const IntPoint&)
-{
- notImplemented();
-}
-
-Cursor::~Cursor()
-{
- if (m_impl)
- gdk_cursor_unref(m_impl);
-}
-
-Cursor& Cursor::operator=(const Cursor& other)
-{
- gdk_cursor_ref(other.m_impl);
- gdk_cursor_unref(m_impl);
- m_impl = other.m_impl;
- return *this;
-}
-
-Cursor::Cursor(GdkCursor* c)
- : m_impl(c)
-{
- m_impl = c;
- ASSERT(c);
- gdk_cursor_ref(c);
-}
-
-const Cursor& pointerCursor()
-{
- static Cursor c = gdk_cursor_new(GDK_LEFT_PTR);
- return c;
-}
-
-const Cursor& crossCursor()
-{
- static Cursor c = gdk_cursor_new(GDK_CROSS);
- return c;
-}
-
-const Cursor& handCursor()
-{
- static Cursor c = gdk_cursor_new(GDK_HAND2);
- return c;
-}
-
-const Cursor& moveCursor()
-{
- static Cursor c = gdk_cursor_new(GDK_FLEUR);
- return c;
-}
-
-const Cursor& iBeamCursor()
-{
- static Cursor c = gdk_cursor_new(GDK_XTERM);
- return c;
-}
-
-const Cursor& waitCursor()
-{
- static Cursor c = gdk_cursor_new(GDK_WATCH);
- return c;
-}
-
-const Cursor& helpCursor()
-{
- static Cursor c = gdk_cursor_new(GDK_QUESTION_ARROW);
- return c;
-}
-
-const Cursor& eastResizeCursor()
-{
- static Cursor c = gdk_cursor_new(GDK_RIGHT_SIDE);
- return c;
-}
-
-const Cursor& northResizeCursor()
-{
- static Cursor c = gdk_cursor_new(GDK_TOP_SIDE);
- return c;
-}
-
-const Cursor& northEastResizeCursor()
-{
- static Cursor c = gdk_cursor_new(GDK_TOP_RIGHT_CORNER);
- return c;
-}
-
-const Cursor& northWestResizeCursor()
-{
- static Cursor c = gdk_cursor_new(GDK_TOP_LEFT_CORNER);
- return c;
-}
-
-const Cursor& southResizeCursor()
-{
- static Cursor c = gdk_cursor_new(GDK_BOTTOM_SIDE);
- return c;
-}
-
-const Cursor& southEastResizeCursor()
-{
- static Cursor c = gdk_cursor_new(GDK_BOTTOM_RIGHT_CORNER);
- return c;
-}
-
-const Cursor& southWestResizeCursor()
-{
- static Cursor c = gdk_cursor_new(GDK_BOTTOM_LEFT_CORNER);
- return c;
-}
-
-const Cursor& westResizeCursor()
-{
- static Cursor c = gdk_cursor_new(GDK_LEFT_SIDE);
- return c;
-}
-
-const Cursor& northSouthResizeCursor()
-{
- static Cursor c = gdk_cursor_new(GDK_TOP_TEE);
- return c;
-}
-
-const Cursor& eastWestResizeCursor()
-{
- static Cursor c = gdk_cursor_new(GDK_LEFT_SIDE);
- return c;
-}
-
-const Cursor& northEastSouthWestResizeCursor()
-{
- static Cursor c = gdk_cursor_new(GDK_SIZING);
- return c;
-}
-
-const Cursor& northWestSouthEastResizeCursor()
-{
- static Cursor c = gdk_cursor_new(GDK_SIZING);
- return c;
-}
-
-const Cursor& columnResizeCursor()
-{
- static Cursor c = gdk_cursor_new(GDK_DOUBLE_ARROW);
- return c;
-}
-
-const Cursor& rowResizeCursor()
-{
- static Cursor c = gdk_cursor_new(GDK_DOUBLE_ARROW);
- return c;
-}
-
-const Cursor& middlePanningCursor()
-{
- return moveCursor();
-}
-
-const Cursor& eastPanningCursor()
-{
- return eastResizeCursor();
-}
-
-const Cursor& northPanningCursor()
-{
- return northResizeCursor();
-}
-
-const Cursor& northEastPanningCursor()
-{
- return northEastResizeCursor();
-}
-
-const Cursor& northWestPanningCursor()
-{
- return northWestResizeCursor();
-}
-
-const Cursor& southPanningCursor()
-{
- return southResizeCursor();
-}
-
-const Cursor& southEastPanningCursor()
-{
- return southEastResizeCursor();
-}
-
-const Cursor& southWestPanningCursor()
-{
- return southWestResizeCursor();
-}
-
-const Cursor& westPanningCursor()
-{
- return westResizeCursor();
-}
-
-
-const Cursor& verticalTextCursor()
-{
- static Cursor c = customCursorNew(CustomCursorVerticalText);
- return c;
-}
-
-const Cursor& cellCursor()
-{
- notImplemented();
- return pointerCursor();
-}
-
-const Cursor& contextMenuCursor()
-{
- static Cursor c = customCursorNew(CustomCursorContextMenu);
- return c;
-}
-
-const Cursor& noDropCursor()
-{
- notImplemented();
- return pointerCursor();
-}
-
-const Cursor& copyCursor()
-{
- static Cursor c = customCursorNew(CustomCursorCopy);
- return c;
-}
-
-const Cursor& progressCursor()
-{
- notImplemented();
- return pointerCursor();
-}
-
-const Cursor& aliasCursor()
-{
- static Cursor c = customCursorNew(CustomCursorAlias);
- return c;
-}
-
-const Cursor& noneCursor()
-{
- notImplemented();
- return pointerCursor();
-}
-
-const Cursor& notAllowedCursor()
-{
- notImplemented();
- return pointerCursor();
-}
-
-const Cursor& zoomInCursor()
-{
- static Cursor c = customCursorNew(CustomCursorZoomIn);
- return c;
-}
-
-const Cursor& zoomOutCursor()
-{
- static Cursor c = customCursorNew(CustomCursorZoomOut);
- return c;
-}
-
-const Cursor& grabCursor()
-{
- notImplemented();
- return pointerCursor();
-}
-
-const Cursor& grabbingCursor()
-{
- notImplemented();
- return pointerCursor();
-}
-
-}
diff --git a/WebCore/platform/gtk/CursorGtk.h b/WebCore/platform/gtk/CursorGtk.h
deleted file mode 100644
index 73f05a9..0000000
--- a/WebCore/platform/gtk/CursorGtk.h
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- * Copyright (C) 2001 Tim Copperfield <timecop@network.email.ne.jp>
- * Copyright (C) 2007 Christian Dywan <christian@twotoasts.de>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef CursorGtk_h
-#define CursorGtk_h
-
-#include "Cursor.h"
-
-/*
- These cursors are copied from Mozilla code:
- http://lxr.mozilla.org/mozilla1.8/source/widget/src/gtk2/nsGtkCursors.h
-*/
-
-/* MOZ_CURSOR_VERTICAL_TEXT */
-static const char moz_vertical_text_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00,
- 0x06, 0x60, 0x00, 0x00, 0xfc, 0x3f, 0x00, 0x00, 0x06, 0x60, 0x00, 0x00,
- 0x02, 0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-static const char moz_vertical_text_mask_bits[] = {
- 0x07, 0xe0, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x00, 0x0f, 0xf0, 0x00, 0x00,
- 0xff, 0xff, 0x00, 0x00, 0xfe, 0x7f, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
- 0x0f, 0xf0, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-/* MOZ_CURSOR_CONTEXT_MENU */
-static const char moz_menu_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x0c, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00,
- 0x7c, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfc, 0xfd, 0x00, 0x00,
- 0xfc, 0xff, 0x00, 0x00, 0x7c, 0x84, 0x00, 0x00, 0x6c, 0xfc, 0x00, 0x00,
- 0xc4, 0x84, 0x00, 0x00, 0xc0, 0xfc, 0x00, 0x00, 0x80, 0x85, 0x00, 0x00,
- 0x80, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-static const char moz_menu_mask_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00,
- 0x1e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00,
- 0xfe, 0x00, 0x00, 0x00, 0xfe, 0xfd, 0x00, 0x00, 0xfe, 0xff, 0x01, 0x00,
- 0xfe, 0xff, 0x01, 0x00, 0xfe, 0xff, 0x01, 0x00, 0xfe, 0xfe, 0x01, 0x00,
- 0xee, 0xff, 0x01, 0x00, 0xe4, 0xff, 0x01, 0x00, 0xc0, 0xff, 0x01, 0x00,
- 0xc0, 0xff, 0x01, 0x00, 0x80, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-/* MOZ_CURSOR_COPY */
-static const char moz_copy_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x0c, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00,
- 0x7c, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfc, 0x01, 0x00, 0x00,
- 0xfc, 0x03, 0x00, 0x00, 0x7c, 0x30, 0x00, 0x00, 0x6c, 0x30, 0x00, 0x00,
- 0xc4, 0xfc, 0x00, 0x00, 0xc0, 0xfc, 0x00, 0x00, 0x80, 0x31, 0x00, 0x00,
- 0x80, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-static const char moz_copy_mask_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00,
- 0x1e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00,
- 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x01, 0x00, 0x00, 0xfe, 0x03, 0x00, 0x00,
- 0xfe, 0x37, 0x00, 0x00, 0xfe, 0x7b, 0x00, 0x00, 0xfe, 0xfc, 0x00, 0x00,
- 0xee, 0xff, 0x01, 0x00, 0xe4, 0xff, 0x01, 0x00, 0xc0, 0xff, 0x00, 0x00,
- 0xc0, 0x7b, 0x00, 0x00, 0x80, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-/* MOZ_CURSOR_ALIAS */
-static const char moz_alias_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x0c, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00,
- 0x7c, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfc, 0x01, 0x00, 0x00,
- 0xfc, 0x03, 0x00, 0x00, 0x7c, 0xf0, 0x00, 0x00, 0x6c, 0xe0, 0x00, 0x00,
- 0xc4, 0xf0, 0x00, 0x00, 0xc0, 0xb0, 0x00, 0x00, 0x80, 0x19, 0x00, 0x00,
- 0x80, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-static const char moz_alias_mask_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00,
- 0x1e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00,
- 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x01, 0x00, 0x00, 0xfe, 0x03, 0x00, 0x00,
- 0xfe, 0xf7, 0x00, 0x00, 0xfe, 0xfb, 0x01, 0x00, 0xfe, 0xf0, 0x01, 0x00,
- 0xee, 0xf9, 0x01, 0x00, 0xe4, 0xf9, 0x01, 0x00, 0xc0, 0xbf, 0x00, 0x00,
- 0xc0, 0x3f, 0x00, 0x00, 0x80, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-/* MOZ_CURSOR_ZOOM_IN */
-static const char moz_zoom_in_bits[] = {
- 0xf0, 0x00, 0x00, 0x00, 0x0c, 0x03, 0x00, 0x00, 0x02, 0x04, 0x00, 0x00,
- 0x62, 0x04, 0x00, 0x00, 0x61, 0x08, 0x00, 0x00, 0xf9, 0x09, 0x00, 0x00,
- 0xf9, 0x09, 0x00, 0x00, 0x61, 0x08, 0x00, 0x00, 0x62, 0x04, 0x00, 0x00,
- 0x02, 0x04, 0x00, 0x00, 0x0c, 0x0f, 0x00, 0x00, 0xf0, 0x1c, 0x00, 0x00,
- 0x00, 0x38, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00,
- 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-static const char moz_zoom_in_mask_bits[] = {
- 0xf0, 0x00, 0x00, 0x00, 0xfc, 0x03, 0x00, 0x00, 0xfe, 0x07, 0x00, 0x00,
- 0xfe, 0x07, 0x00, 0x00, 0xff, 0x0f, 0x00, 0x00, 0xff, 0x0f, 0x00, 0x00,
- 0xff, 0x0f, 0x00, 0x00, 0xff, 0x0f, 0x00, 0x00, 0xfe, 0x07, 0x00, 0x00,
- 0xfe, 0x07, 0x00, 0x00, 0xfc, 0x0f, 0x00, 0x00, 0xf0, 0x1c, 0x00, 0x00,
- 0x00, 0x38, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00,
- 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-/* MOZ_CURSOR_ZOOM_OUT */
-static const char moz_zoom_out_bits[] = {
- 0xf0, 0x00, 0x00, 0x00, 0x0c, 0x03, 0x00, 0x00, 0x02, 0x04, 0x00, 0x00,
- 0x02, 0x04, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0xf9, 0x09, 0x00, 0x00,
- 0xf9, 0x09, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0x02, 0x04, 0x00, 0x00,
- 0x02, 0x04, 0x00, 0x00, 0x0c, 0x0f, 0x00, 0x00, 0xf0, 0x1c, 0x00, 0x00,
- 0x00, 0x38, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00,
- 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-static const char moz_zoom_out_mask_bits[] = {
- 0xf0, 0x00, 0x00, 0x00, 0xfc, 0x03, 0x00, 0x00, 0xfe, 0x07, 0x00, 0x00,
- 0xfe, 0x07, 0x00, 0x00, 0xff, 0x0f, 0x00, 0x00, 0xff, 0x0f, 0x00, 0x00,
- 0xff, 0x0f, 0x00, 0x00, 0xff, 0x0f, 0x00, 0x00, 0xfe, 0x07, 0x00, 0x00,
- 0xfe, 0x07, 0x00, 0x00, 0xfc, 0x0f, 0x00, 0x00, 0xf0, 0x1c, 0x00, 0x00,
- 0x00, 0x38, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00,
- 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-enum CustomCursorType {
- CustomCursorCopy = 0,
- CustomCursorAlias,
- CustomCursorContextMenu,
- CustomCursorZoomIn,
- CustomCursorZoomOut,
- CustomCursorVerticalText
-} ;
-
-typedef struct {
- const char* name;
- const char* bits;
- const char* mask_bits;
- int hot_x;
- int hot_y;
-} CustomCursor;
-
-// create custom pixmap cursor from cursors in nsGTKCursorData.h
-static const CustomCursor CustomCursors[] = {
- { "copy", moz_copy_bits, moz_copy_mask_bits, 2, 2 },
- { "alias", moz_alias_bits, moz_alias_mask_bits, 2, 2 },
- { "context-menu", moz_menu_bits, moz_menu_mask_bits, 2, 2 },
- { "zoom-in", moz_zoom_in_bits, moz_zoom_in_mask_bits, 6, 6 },
- { "zoom-out", moz_zoom_out_bits, moz_zoom_out_mask_bits, 6, 6 },
- { "vertical-text", moz_vertical_text_bits, moz_vertical_text_mask_bits, 8, 4 },
-};
-
-#endif // CursorGtk_h
diff --git a/WebCore/platform/gtk/DragDataGtk.cpp b/WebCore/platform/gtk/DragDataGtk.cpp
deleted file mode 100644
index 69b3161..0000000
--- a/WebCore/platform/gtk/DragDataGtk.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "config.h"
-#include "DragData.h"
-
-#include "Clipboard.h"
-#include "Document.h"
-#include "DocumentFragment.h"
-
-namespace WebCore {
-
-bool DragData::canSmartReplace() const
-{
- return false;
-}
-
-bool DragData::containsColor() const
-{
- return false;
-}
-
-bool DragData::containsFiles() const
-{
- return false;
-}
-
-void DragData::asFilenames(Vector<String>& result) const
-{
-}
-
-bool DragData::containsPlainText() const
-{
- return false;
-}
-
-String DragData::asPlainText() const
-{
- return String();
-}
-
-Color DragData::asColor() const
-{
- return Color();
-}
-
-PassRefPtr<Clipboard> DragData::createClipboard(ClipboardAccessPolicy) const
-{
- return 0;
-}
-
-bool DragData::containsCompatibleContent() const
-{
- return false;
-}
-
-bool DragData::containsURL() const
-{
- return false;
-}
-
-String DragData::asURL(String* title) const
-{
- return String();
-}
-
-
-PassRefPtr<DocumentFragment> DragData::asFragment(Document*) const
-{
- return 0;
-}
-
-}
diff --git a/WebCore/platform/gtk/DragImageGtk.cpp b/WebCore/platform/gtk/DragImageGtk.cpp
deleted file mode 100644
index 4ddae3a..0000000
--- a/WebCore/platform/gtk/DragImageGtk.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "config.h"
-#include "DragImage.h"
-
-#include "CachedImage.h"
-#include "Image.h"
-
-namespace WebCore {
-
-IntSize dragImageSize(DragImageRef)
-{
- return IntSize(0, 0);
-}
-
-void deleteDragImage(DragImageRef)
-{
-}
-
-DragImageRef scaleDragImage(DragImageRef image, FloatSize)
-{
- return image;
-}
-
-DragImageRef dissolveDragImageToFraction(DragImageRef image, float)
-{
- return image;
-}
-
-DragImageRef createDragImageFromImage(Image*)
-{
- return 0;
-}
-
-DragImageRef createDragImageIconForCachedImage(CachedImage*)
-{
- return 0;
-}
-
-}
diff --git a/WebCore/platform/gtk/EventLoopGtk.cpp b/WebCore/platform/gtk/EventLoopGtk.cpp
deleted file mode 100644
index 4ef7b5c..0000000
--- a/WebCore/platform/gtk/EventLoopGtk.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2008 Nuanti Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-#include "EventLoop.h"
-
-#include <glib.h>
-
-namespace WebCore {
-
-void EventLoop::cycle()
-{
- g_main_context_iteration(NULL, FALSE);
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/gtk/FileChooserGtk.cpp b/WebCore/platform/gtk/FileChooserGtk.cpp
deleted file mode 100644
index e984718..0000000
--- a/WebCore/platform/gtk/FileChooserGtk.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2007 Holger Hans Peter Freyther
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FileChooser.h"
-
-#include "CString.h"
-#include "FileSystem.h"
-#include "Icon.h"
-#include "LocalizedStrings.h"
-#include "StringTruncator.h"
-
-#include <glib.h>
-#include <glib/gi18n.h>
-#include <gtk/gtk.h>
-
-namespace WebCore {
-
-static bool stringByAdoptingFileSystemRepresentation(gchar* systemFilename, String& result)
-{
- if (!systemFilename)
- return false;
-
- result = filenameToString(systemFilename);
- g_free(systemFilename);
-
- return true;
-}
-
-String FileChooser::basenameForWidth(const Font& font, int width) const
-{
- if (width <= 0)
- return String();
-
- String string = fileButtonNoFileSelectedLabel();
-
- if (m_filenames.size() == 1) {
- gchar* systemFilename = filenameFromString(m_filenames[0]);
- gchar* systemBasename = g_path_get_basename(systemFilename);
- g_free(systemFilename);
- stringByAdoptingFileSystemRepresentation(systemBasename, string);
- } else if (m_filenames.size() > 1)
- return StringTruncator::rightTruncate(multipleFileUploadText(m_filenames.size()), width, font, false);
-
- return StringTruncator::centerTruncate(string, width, font, false);
-}
-}
diff --git a/WebCore/platform/gtk/FileSystemGtk.cpp b/WebCore/platform/gtk/FileSystemGtk.cpp
deleted file mode 100644
index 965cea9..0000000
--- a/WebCore/platform/gtk/FileSystemGtk.cpp
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * Copyright (C) 2007 Holger Hans Peter Freyther
- * Copyright (C) 2008 Collabora, Ltd.
- * Copyright (C) 2008 Apple Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-#include "FileSystem.h"
-
-#include "guriescape.h"
-#include "NotImplemented.h"
-#include "PlatformString.h"
-#include "CString.h"
-
-#include <glib.h>
-#include <glib/gstdio.h>
-#include <glib/gutils.h>
-
-#include <unistd.h>
-
-namespace WebCore {
-
-/* On linux file names are just raw bytes, so also strings that cannot be encoded in any way
- * are valid file names. This mean that we cannot just store a file name as-is in a String
- * but we have to escape it.
- * On Windows the GLib file name encoding is always UTF-8 so we can optimize this case. */
-String filenameToString(const char* filename)
-{
- if (!filename)
- return String();
-
-#if PLATFORM(WIN_OS)
- return String::fromUTF8(filename);
-#else
- gchar* escapedString = g_uri_escape_string(filename, "/:", false);
- String string(escapedString);
- g_free(escapedString);
- return string;
-#endif
-}
-
-char* filenameFromString(const String& string)
-{
-#if PLATFORM(WIN_OS)
- return g_strdup(string.utf8().data());
-#else
- return g_uri_unescape_string(string.utf8().data(), 0);
-#endif
-}
-
-// Converts a string to something suitable to be displayed to the user.
-String filenameForDisplay(const String& string)
-{
-#if PLATFORM(WIN_OS)
- return string;
-#else
- gchar* filename = filenameFromString(string);
- gchar* display = g_filename_to_utf8(filename, 0, 0, 0, 0);
- g_free(filename);
- if (!display)
- return string;
-
- String displayString = String::fromUTF8(display);
- g_free(display);
-
- return displayString;
-#endif
-}
-
-bool fileExists(const String& path)
-{
- bool result = false;
- gchar* filename = filenameFromString(path);
-
- if (filename) {
- result = g_file_test(filename, G_FILE_TEST_EXISTS);
- g_free(filename);
- }
-
- return result;
-}
-
-bool deleteFile(const String& path)
-{
- bool result = false;
- gchar* filename = filenameFromString(path);
-
- if (filename) {
- result = g_remove(filename) == 0;
- g_free(filename);
- }
-
- return result;
-}
-
-bool deleteEmptyDirectory(const String& path)
-{
- bool result = false;
- gchar* filename = filenameFromString(path);
-
- if (filename) {
- result = g_rmdir(filename) == 0;
- g_free(filename);
- }
-
- return result;
-}
-
-bool getFileSize(const String& path, long long& resultSize)
-{
- gchar* filename = filenameFromString(path);
- if (!filename)
- return false;
-
- struct stat statResult;
- gint result = g_stat(filename, &statResult);
- g_free(filename);
- if (result != 0)
- return false;
-
- resultSize = statResult.st_size;
- return true;
-}
-
-bool getFileModificationTime(const String& path, time_t& modifiedTime)
-{
- gchar* filename = filenameFromString(path);
- if (!filename)
- return false;
-
- struct stat statResult;
- gint result = g_stat(filename, &statResult);
- g_free(filename);
- if (result != 0)
- return false;
-
- modifiedTime = statResult.st_mtime;
- return true;
-
-}
-
-String pathByAppendingComponent(const String& path, const String& component)
-{
- if (path.endsWith(G_DIR_SEPARATOR_S))
- return path + component;
- else
- return path + G_DIR_SEPARATOR_S + component;
-}
-
-bool makeAllDirectories(const String& path)
-{
- gchar* filename = filenameFromString(path);
- if (!filename)
- return false;
-
- gint result = g_mkdir_with_parents(filename, S_IRWXU);
- g_free(filename);
-
- return result == 0;
-}
-
-String homeDirectoryPath()
-{
- return filenameToString(g_get_home_dir());
-}
-
-String pathGetFileName(const String& pathName)
-{
- char* tmpFilename = filenameFromString(pathName);
- char* baseName = g_path_get_basename(tmpFilename);
- String fileName = String::fromUTF8(baseName);
- g_free(baseName);
- g_free(tmpFilename);
-
- return fileName;
-}
-
-String directoryName(const String& path)
-{
- notImplemented();
- return String();
-}
-
-Vector<String> listDirectory(const String& path, const String& filter)
-{
- Vector<String> entries;
-
- gchar* filename = filenameFromString(path);
- GDir* dir = g_dir_open(filename, 0, 0);
- if (!dir)
- return entries;
-
- GPatternSpec *pspec = g_pattern_spec_new((filter.utf8()).data());
- while (const char* name = g_dir_read_name(dir)) {
- if (!g_pattern_match_string(pspec, name))
- continue;
-
- gchar* entry = g_build_filename(filename, name, NULL);
- entries.append(filenameToString(entry));
- g_free(entry);
- }
- g_dir_close(dir);
- g_free(filename);
-
- return entries;
-}
-
-CString openTemporaryFile(const char* prefix, PlatformFileHandle& handle)
-{
- gchar* filename = g_strdup_printf("%sXXXXXX", prefix);
- gchar* tempPath = g_build_filename(g_get_tmp_dir(), filename, NULL);
- g_free(filename);
-
- int fileDescriptor = g_mkstemp(tempPath);
- if (!isHandleValid(fileDescriptor)) {
- LOG_ERROR("Can't create a temporary file.");
- g_free(tempPath);
- return 0;
- }
- CString tempFilePath = tempPath;
- g_free(tempPath);
-
- handle = fileDescriptor;
- return tempFilePath;
-}
-
-void closeFile(PlatformFileHandle& handle)
-{
- if (isHandleValid(handle)) {
- close(handle);
- handle = invalidPlatformFileHandle;
- }
-}
-
-int writeToFile(PlatformFileHandle handle, const char* data, int length)
-{
- int totalBytesWritten = 0;
- while (totalBytesWritten < length) {
- int bytesWritten = write(handle, data, length - totalBytesWritten);
- if (bytesWritten < 0)
- return -1;
- totalBytesWritten += bytesWritten;
- }
-
- return totalBytesWritten;
-}
-
-bool unloadModule(PlatformModule module)
-{
- return g_module_close(module);
-}
-}
diff --git a/WebCore/platform/gtk/KURLGtk.cpp b/WebCore/platform/gtk/KURLGtk.cpp
deleted file mode 100644
index 4858d3e..0000000
--- a/WebCore/platform/gtk/KURLGtk.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "config.h"
-#include "KURL.h"
-
-#include "CString.h"
-#include "FileSystem.h"
-
-#include <glib.h>
-
-namespace WebCore {
-
-String KURL::fileSystemPath() const
-{
- gchar* filename = g_filename_from_uri(m_string.utf8().data(), 0, 0);
- if (!filename)
- return String();
-
- String path = filenameToString(filename);
- g_free(filename);
- return path;
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/gtk/KeyEventGtk.cpp b/WebCore/platform/gtk/KeyEventGtk.cpp
deleted file mode 100644
index 153ef19..0000000
--- a/WebCore/platform/gtk/KeyEventGtk.cpp
+++ /dev/null
@@ -1,550 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
- * Copyright (C) 2007 Holger Hans Peter Freyther
- * Copyright (C) 2008 Collabora, Ltd. All rights reserved.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "PlatformKeyboardEvent.h"
-
-#include "KeyboardCodes.h"
-#include "NotImplemented.h"
-#include "TextEncoding.h"
-
-#include <gdk/gdk.h>
-#include <gdk/gdkkeysyms.h>
-#include <gtk/gtkversion.h>
-
-namespace WebCore {
-
-// FIXME: This is incomplete. We should change this to mirror
-// more like what Firefox does, and generate these switch statements
-// at build time.
-static String keyIdentifierForGdkKeyCode(guint keyCode)
-{
- switch (keyCode) {
- case GDK_Menu:
- case GDK_Alt_L:
- case GDK_Alt_R:
- return "Alt";
- case GDK_Clear:
- return "Clear";
- case GDK_Down:
- return "Down";
- // "End"
- case GDK_End:
- return "End";
- // "Enter"
- case GDK_ISO_Enter:
- case GDK_KP_Enter:
- case GDK_Return:
- return "Enter";
- case GDK_Execute:
- return "Execute";
- case GDK_F1:
- return "F1";
- case GDK_F2:
- return "F2";
- case GDK_F3:
- return "F3";
- case GDK_F4:
- return "F4";
- case GDK_F5:
- return "F5";
- case GDK_F6:
- return "F6";
- case GDK_F7:
- return "F7";
- case GDK_F8:
- return "F8";
- case GDK_F9:
- return "F9";
- case GDK_F10:
- return "F10";
- case GDK_F11:
- return "F11";
- case GDK_F12:
- return "F12";
- case GDK_F13:
- return "F13";
- case GDK_F14:
- return "F14";
- case GDK_F15:
- return "F15";
- case GDK_F16:
- return "F16";
- case GDK_F17:
- return "F17";
- case GDK_F18:
- return "F18";
- case GDK_F19:
- return "F19";
- case GDK_F20:
- return "F20";
- case GDK_F21:
- return "F21";
- case GDK_F22:
- return "F22";
- case GDK_F23:
- return "F23";
- case GDK_F24:
- return "F24";
- case GDK_Help:
- return "Help";
- case GDK_Home:
- return "Home";
- case GDK_Insert:
- return "Insert";
- case GDK_Left:
- return "Left";
- case GDK_Page_Down:
- return "PageDown";
- case GDK_Page_Up:
- return "PageUp";
- case GDK_Pause:
- return "Pause";
- case GDK_3270_PrintScreen:
- return "PrintScreen";
- case GDK_Right:
- return "Right";
- case GDK_Select:
- return "Select";
- case GDK_Up:
- return "Up";
- // Standard says that DEL becomes U+007F.
- case GDK_Delete:
- return "U+007F";
- case GDK_ISO_Left_Tab:
- case GDK_3270_BackTab:
- case GDK_Tab:
- return "U+0009";
- default:
- return String::format("U+%04X", gdk_keyval_to_unicode(gdk_keyval_to_upper(keyCode)));
- }
-}
-
-static int windowsKeyCodeForKeyEvent(unsigned int keycode)
-{
- switch (keycode) {
- case GDK_KP_0:
- return VK_NUMPAD0;// (60) Numeric keypad 0 key
- case GDK_KP_1:
- return VK_NUMPAD1;// (61) Numeric keypad 1 key
- case GDK_KP_2:
- return VK_NUMPAD2; // (62) Numeric keypad 2 key
- case GDK_KP_3:
- return VK_NUMPAD3; // (63) Numeric keypad 3 key
- case GDK_KP_4:
- return VK_NUMPAD4; // (64) Numeric keypad 4 key
- case GDK_KP_5:
- return VK_NUMPAD5; //(65) Numeric keypad 5 key
- case GDK_KP_6:
- return VK_NUMPAD6; // (66) Numeric keypad 6 key
- case GDK_KP_7:
- return VK_NUMPAD7; // (67) Numeric keypad 7 key
- case GDK_KP_8:
- return VK_NUMPAD8; // (68) Numeric keypad 8 key
- case GDK_KP_9:
- return VK_NUMPAD9; // (69) Numeric keypad 9 key
- case GDK_KP_Multiply:
- return VK_MULTIPLY; // (6A) Multiply key
- case GDK_KP_Add:
- return VK_ADD; // (6B) Add key
- case GDK_KP_Subtract:
- return VK_SUBTRACT; // (6D) Subtract key
- case GDK_KP_Decimal:
- return VK_DECIMAL; // (6E) Decimal key
- case GDK_KP_Divide:
- return VK_DIVIDE; // (6F) Divide key
-
- case GDK_BackSpace:
- return VK_BACK; // (08) BACKSPACE key
- case GDK_ISO_Left_Tab:
- case GDK_3270_BackTab:
- case GDK_Tab:
- return VK_TAB; // (09) TAB key
- case GDK_Clear:
- return VK_CLEAR; // (0C) CLEAR key
- case GDK_ISO_Enter:
- case GDK_KP_Enter:
- case GDK_Return:
- return VK_RETURN; //(0D) Return key
- case GDK_Shift_L:
- case GDK_Shift_R:
- return VK_SHIFT; // (10) SHIFT key
- case GDK_Control_L:
- case GDK_Control_R:
- return VK_CONTROL; // (11) CTRL key
- case GDK_Menu:
- case GDK_Alt_L:
- case GDK_Alt_R:
- return VK_MENU; // (12) ALT key
-
- case GDK_Pause:
- return VK_PAUSE; // (13) PAUSE key
- case GDK_Caps_Lock:
- return VK_CAPITAL; // (14) CAPS LOCK key
- case GDK_Kana_Lock:
- case GDK_Kana_Shift:
- return VK_KANA; // (15) Input Method Editor (IME) Kana mode
- case GDK_Hangul:
- return VK_HANGUL; // VK_HANGUL (15) IME Hangul mode
- // VK_JUNJA (17) IME Junja mode
- // VK_FINAL (18) IME final mode
- case GDK_Hangul_Hanja:
- return VK_HANJA; // (19) IME Hanja mode
- case GDK_Kanji:
- return VK_KANJI; // (19) IME Kanji mode
- case GDK_Escape:
- return VK_ESCAPE; // (1B) ESC key
- // VK_CONVERT (1C) IME convert
- // VK_NONCONVERT (1D) IME nonconvert
- // VK_ACCEPT (1E) IME accept
- // VK_MODECHANGE (1F) IME mode change request
- case GDK_space:
- return VK_SPACE; // (20) SPACEBAR
- case GDK_Page_Up:
- return VK_PRIOR; // (21) PAGE UP key
- case GDK_Page_Down:
- return VK_NEXT; // (22) PAGE DOWN key
- case GDK_End:
- return VK_END; // (23) END key
- case GDK_Home:
- return VK_HOME; // (24) HOME key
- case GDK_Left:
- return VK_LEFT; // (25) LEFT ARROW key
- case GDK_Up:
- return VK_UP; // (26) UP ARROW key
- case GDK_Right:
- return VK_RIGHT; // (27) RIGHT ARROW key
- case GDK_Down:
- return VK_DOWN; // (28) DOWN ARROW key
- case GDK_Select:
- return VK_SELECT; // (29) SELECT key
- case GDK_Print:
- return VK_PRINT; // (2A) PRINT key
- case GDK_Execute:
- return VK_EXECUTE;// (2B) EXECUTE key
- //dunno on this
- //case GDK_PrintScreen:
- // return VK_SNAPSHOT; // (2C) PRINT SCREEN key
- case GDK_Insert:
- return VK_INSERT; // (2D) INS key
- case GDK_Delete:
- return VK_DELETE; // (2E) DEL key
- case GDK_Help:
- return VK_HELP; // (2F) HELP key
- case GDK_0:
- case GDK_parenleft:
- return VK_0; // (30) 0) key
- case GDK_1:
- return VK_1; // (31) 1 ! key
- case GDK_2:
- case GDK_at:
- return VK_2; // (32) 2 & key
- case GDK_3:
- case GDK_numbersign:
- return VK_3; //case '3': case '#';
- case GDK_4:
- case GDK_dollar: // (34) 4 key '$';
- return VK_4;
- case GDK_5:
- case GDK_percent:
- return VK_5; // (35) 5 key '%'
- case GDK_6:
- case GDK_asciicircum:
- return VK_6; // (36) 6 key '^'
- case GDK_7:
- case GDK_ampersand:
- return VK_7; // (37) 7 key case '&'
- case GDK_8:
- case GDK_asterisk:
- return VK_8; // (38) 8 key '*'
- case GDK_9:
- case GDK_parenright:
- return VK_9; // (39) 9 key '('
- case GDK_a:
- case GDK_A:
- return VK_A; // (41) A key case 'a': case 'A': return 0x41;
- case GDK_b:
- case GDK_B:
- return VK_B; // (42) B key case 'b': case 'B': return 0x42;
- case GDK_c:
- case GDK_C:
- return VK_C; // (43) C key case 'c': case 'C': return 0x43;
- case GDK_d:
- case GDK_D:
- return VK_D; // (44) D key case 'd': case 'D': return 0x44;
- case GDK_e:
- case GDK_E:
- return VK_E; // (45) E key case 'e': case 'E': return 0x45;
- case GDK_f:
- case GDK_F:
- return VK_F; // (46) F key case 'f': case 'F': return 0x46;
- case GDK_g:
- case GDK_G:
- return VK_G; // (47) G key case 'g': case 'G': return 0x47;
- case GDK_h:
- case GDK_H:
- return VK_H; // (48) H key case 'h': case 'H': return 0x48;
- case GDK_i:
- case GDK_I:
- return VK_I; // (49) I key case 'i': case 'I': return 0x49;
- case GDK_j:
- case GDK_J:
- return VK_J; // (4A) J key case 'j': case 'J': return 0x4A;
- case GDK_k:
- case GDK_K:
- return VK_K; // (4B) K key case 'k': case 'K': return 0x4B;
- case GDK_l:
- case GDK_L:
- return VK_L; // (4C) L key case 'l': case 'L': return 0x4C;
- case GDK_m:
- case GDK_M:
- return VK_M; // (4D) M key case 'm': case 'M': return 0x4D;
- case GDK_n:
- case GDK_N:
- return VK_N; // (4E) N key case 'n': case 'N': return 0x4E;
- case GDK_o:
- case GDK_O:
- return VK_O; // (4F) O key case 'o': case 'O': return 0x4F;
- case GDK_p:
- case GDK_P:
- return VK_P; // (50) P key case 'p': case 'P': return 0x50;
- case GDK_q:
- case GDK_Q:
- return VK_Q; // (51) Q key case 'q': case 'Q': return 0x51;
- case GDK_r:
- case GDK_R:
- return VK_R; // (52) R key case 'r': case 'R': return 0x52;
- case GDK_s:
- case GDK_S:
- return VK_S; // (53) S key case 's': case 'S': return 0x53;
- case GDK_t:
- case GDK_T:
- return VK_T; // (54) T key case 't': case 'T': return 0x54;
- case GDK_u:
- case GDK_U:
- return VK_U; // (55) U key case 'u': case 'U': return 0x55;
- case GDK_v:
- case GDK_V:
- return VK_V; // (56) V key case 'v': case 'V': return 0x56;
- case GDK_w:
- case GDK_W:
- return VK_W; // (57) W key case 'w': case 'W': return 0x57;
- case GDK_x:
- case GDK_X:
- return VK_X; // (58) X key case 'x': case 'X': return 0x58;
- case GDK_y:
- case GDK_Y:
- return VK_Y; // (59) Y key case 'y': case 'Y': return 0x59;
- case GDK_z:
- case GDK_Z:
- return VK_Z; // (5A) Z key case 'z': case 'Z': return 0x5A;
- case GDK_Meta_L:
- return VK_LWIN; // (5B) Left Windows key (Microsoft Natural keyboard)
- case GDK_Meta_R:
- return VK_RWIN; // (5C) Right Windows key (Natural keyboard)
- // VK_APPS (5D) Applications key (Natural keyboard)
- // VK_SLEEP (5F) Computer Sleep key
- // VK_SEPARATOR (6C) Separator key
- // VK_SUBTRACT (6D) Subtract key
- // VK_DECIMAL (6E) Decimal key
- // VK_DIVIDE (6F) Divide key
- // handled by key code above
-
- case GDK_Num_Lock:
- return VK_NUMLOCK; // (90) NUM LOCK key
-
- case GDK_Scroll_Lock:
- return VK_SCROLL; // (91) SCROLL LOCK key
-
- // VK_LSHIFT (A0) Left SHIFT key
- // VK_RSHIFT (A1) Right SHIFT key
- // VK_LCONTROL (A2) Left CONTROL key
- // VK_RCONTROL (A3) Right CONTROL key
- // VK_LMENU (A4) Left MENU key
- // VK_RMENU (A5) Right MENU key
- // VK_BROWSER_BACK (A6) Windows 2000/XP: Browser Back key
- // VK_BROWSER_FORWARD (A7) Windows 2000/XP: Browser Forward key
- // VK_BROWSER_REFRESH (A8) Windows 2000/XP: Browser Refresh key
- // VK_BROWSER_STOP (A9) Windows 2000/XP: Browser Stop key
- // VK_BROWSER_SEARCH (AA) Windows 2000/XP: Browser Search key
- // VK_BROWSER_FAVORITES (AB) Windows 2000/XP: Browser Favorites key
- // VK_BROWSER_HOME (AC) Windows 2000/XP: Browser Start and Home key
- // VK_VOLUME_MUTE (AD) Windows 2000/XP: Volume Mute key
- // VK_VOLUME_DOWN (AE) Windows 2000/XP: Volume Down key
- // VK_VOLUME_UP (AF) Windows 2000/XP: Volume Up key
- // VK_MEDIA_NEXT_TRACK (B0) Windows 2000/XP: Next Track key
- // VK_MEDIA_PREV_TRACK (B1) Windows 2000/XP: Previous Track key
- // VK_MEDIA_STOP (B2) Windows 2000/XP: Stop Media key
- // VK_MEDIA_PLAY_PAUSE (B3) Windows 2000/XP: Play/Pause Media key
- // VK_LAUNCH_MAIL (B4) Windows 2000/XP: Start Mail key
- // VK_LAUNCH_MEDIA_SELECT (B5) Windows 2000/XP: Select Media key
- // VK_LAUNCH_APP1 (B6) Windows 2000/XP: Start Application 1 key
- // VK_LAUNCH_APP2 (B7) Windows 2000/XP: Start Application 2 key
-
- // VK_OEM_1 (BA) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ';:' key
- case GDK_semicolon:
- case GDK_colon:
- return VK_OEM_1; //case ';': case ':': return 0xBA;
- // VK_OEM_PLUS (BB) Windows 2000/XP: For any country/region, the '+' key
- case GDK_plus:
- case GDK_equal:
- return VK_OEM_PLUS; //case '=': case '+': return 0xBB;
- // VK_OEM_COMMA (BC) Windows 2000/XP: For any country/region, the ',' key
- case GDK_comma:
- case GDK_less:
- return VK_OEM_COMMA; //case ',': case '<': return 0xBC;
- // VK_OEM_MINUS (BD) Windows 2000/XP: For any country/region, the '-' key
- case GDK_minus:
- case GDK_underscore:
- return VK_OEM_MINUS; //case '-': case '_': return 0xBD;
- // VK_OEM_PERIOD (BE) Windows 2000/XP: For any country/region, the '.' key
- case GDK_period:
- case GDK_greater:
- return VK_OEM_PERIOD; //case '.': case '>': return 0xBE;
- // VK_OEM_2 (BF) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '/?' key
- case GDK_slash:
- case GDK_question:
- return VK_OEM_2; //case '/': case '?': return 0xBF;
- // VK_OEM_3 (C0) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '`~' key
- case GDK_asciitilde:
- case GDK_quoteleft:
- return VK_OEM_3; //case '`': case '~': return 0xC0;
- // VK_OEM_4 (DB) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '[{' key
- case GDK_bracketleft:
- case GDK_braceleft:
- return VK_OEM_4; //case '[': case '{': return 0xDB;
- // VK_OEM_5 (DC) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '\|' key
- case GDK_backslash:
- case GDK_bar:
- return VK_OEM_5; //case '\\': case '|': return 0xDC;
- // VK_OEM_6 (DD) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ']}' key
- case GDK_bracketright:
- case GDK_braceright:
- return VK_OEM_6; // case ']': case '}': return 0xDD;
- // VK_OEM_7 (DE) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the 'single-quote/double-quote' key
- case GDK_quoteright:
- case GDK_quotedbl:
- return VK_OEM_7; // case '\'': case '"': return 0xDE;
- // VK_OEM_8 (DF) Used for miscellaneous characters; it can vary by keyboard.
- // VK_OEM_102 (E2) Windows 2000/XP: Either the angle bracket key or the backslash key on the RT 102-key keyboard
- // VK_PROCESSKEY (E5) Windows 95/98/Me, Windows NT 4.0, Windows 2000/XP: IME PROCESS key
- // VK_PACKET (E7) Windows 2000/XP: Used to pass Unicode characters as if they were keystrokes. The VK_PACKET key is the low word of a 32-bit Virtual Key value used for non-keyboard input methods. For more information, see Remark in KEYBDINPUT,SendInput, WM_KEYDOWN, and WM_KEYUP
- // VK_ATTN (F6) Attn key
- // VK_CRSEL (F7) CrSel key
- // VK_EXSEL (F8) ExSel key
- // VK_EREOF (F9) Erase EOF key
- // VK_PLAY (FA) Play key
- // VK_ZOOM (FB) Zoom key
- // VK_NONAME (FC) Reserved for future use
- // VK_PA1 (FD) PA1 key
- // VK_OEM_CLEAR (FE) Clear key
- default:
- return 0;
- }
-
-}
-
-static String singleCharacterString(guint val)
-{
- switch (val) {
- case GDK_ISO_Enter:
- case GDK_KP_Enter:
- case GDK_Return:
- return String("\r");
- default:
- gunichar c = gdk_keyval_to_unicode(val);
- glong nwc;
- gunichar2* uchar16 = g_ucs4_to_utf16(&c, 1, 0, &nwc, 0);
-
- String retVal;
- if (uchar16)
- retVal = String((UChar*)uchar16, nwc);
- else
- retVal = String();
-
- g_free(uchar16);
-
- return retVal;
- }
-}
-
-// Keep this in sync with the other platform event constructors
-// TODO: m_gdkEventKey should be refcounted
-PlatformKeyboardEvent::PlatformKeyboardEvent(GdkEventKey* event)
- : m_type((event->type == GDK_KEY_RELEASE) ? KeyUp : KeyDown)
- , m_text(singleCharacterString(event->keyval))
- , m_unmodifiedText(singleCharacterString(event->keyval))
- , m_keyIdentifier(keyIdentifierForGdkKeyCode(event->keyval))
- , m_autoRepeat(false)
- , m_windowsVirtualKeyCode(windowsKeyCodeForKeyEvent(event->keyval))
- , m_nativeVirtualKeyCode(event->keyval)
- , m_isKeypad(event->keyval >= GDK_KP_Space && event->keyval <= GDK_KP_9)
- , m_shiftKey((event->state & GDK_SHIFT_MASK) || (event->keyval == GDK_3270_BackTab))
- , m_ctrlKey(event->state & GDK_CONTROL_MASK)
- , m_altKey(event->state & GDK_MOD1_MASK)
-#if GTK_CHECK_VERSION(2,10,0)
- , m_metaKey(event->state & GDK_META_MASK)
-#else
- // GDK_MOD2_MASK doesn't always mean meta so we can't use it
- , m_metaKey(false)
-#endif
- , m_gdkEventKey(event)
-{
-}
-
-void PlatformKeyboardEvent::disambiguateKeyDownEvent(Type type, bool backwardCompatibilityMode)
-{
- // Can only change type from KeyDown to RawKeyDown or Char, as we lack information for other conversions.
- ASSERT(m_type == KeyDown);
- m_type = type;
-
- if (backwardCompatibilityMode)
- return;
-
- if (type == RawKeyDown) {
- m_text = String();
- m_unmodifiedText = String();
- } else {
- m_keyIdentifier = String();
- m_windowsVirtualKeyCode = 0;
- }
-}
-
-bool PlatformKeyboardEvent::currentCapsLockState()
-{
- notImplemented();
- return false;
-}
-
-GdkEventKey* PlatformKeyboardEvent::gdkEventKey() const
-{
- return m_gdkEventKey;
-}
-
-}
diff --git a/WebCore/platform/gtk/KeyboardCodes.h b/WebCore/platform/gtk/KeyboardCodes.h
deleted file mode 100644
index 3ad1243..0000000
--- a/WebCore/platform/gtk/KeyboardCodes.h
+++ /dev/null
@@ -1,543 +0,0 @@
-/*
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef KeyboardCodes_h
-#define KeyboardCodes_h
-
-namespace WebCore {
-
-// VK_LBUTTON (01) Left mouse button
-// VK_RBUTTON (02) Right mouse button
-// VK_CANCEL (03) Control-break processing
-// VK_MBUTTON (04) Middle mouse button (three-button mouse)
-// VK_XBUTTON1 (05)
-// VK_XBUTTON2 (06)
-
-// VK_BACK (08) BACKSPACE key
-const int VK_BACK = 0x08;
-
-// VK_TAB (09) TAB key
-const int VK_TAB = 0x09;
-
-// VK_CLEAR (0C) CLEAR key
-const int VK_CLEAR = 0x0C;
-
-// VK_RETURN (0D)
-const int VK_RETURN = 0x0D;
-
-// VK_SHIFT (10) SHIFT key
-const int VK_SHIFT = 0x10;
-
-// VK_CONTROL (11) CTRL key
-const int VK_CONTROL = 0x11;
-
-// VK_MENU (12) ALT key
-const int VK_MENU = 0x12;
-
-// VK_PAUSE (13) PAUSE key
-const int VK_PAUSE = 0x13;
-
-// VK_CAPITAL (14) CAPS LOCK key
-const int VK_CAPITAL = 0x14;
-
-// VK_KANA (15) Input Method Editor (IME) Kana mode
-const int VK_KANA = 0x15;
-
-// VK_HANGUEL (15) IME Hanguel mode (maintained for compatibility; use VK_HANGUL)
-// VK_HANGUL (15) IME Hangul mode
-const int VK_HANGUL = 0x15;
-
-// VK_JUNJA (17) IME Junja mode
-const int VK_JUNJA = 0x17;
-
-// VK_FINAL (18) IME final mode
-const int VK_FINAL = 0x18;
-
-// VK_HANJA (19) IME Hanja mode
-const int VK_HANJA = 0x19;
-
-// VK_KANJI (19) IME Kanji mode
-const int VK_KANJI = 0x19;
-
-// VK_ESCAPE (1B) ESC key
-const int VK_ESCAPE = 0x1B;
-
-// VK_CONVERT (1C) IME convert
-const int VK_CONVERT = 0x1C;
-
-// VK_NONCONVERT (1D) IME nonconvert
-const int VK_NONCONVERT = 0x1D;
-
-// VK_ACCEPT (1E) IME accept
-const int VK_ACCEPT = 0x1E;
-
-// VK_MODECHANGE (1F) IME mode change request
-const int VK_MODECHANGE = 0x1F;
-
-// VK_SPACE (20) SPACEBAR
-const int VK_SPACE = 0x20;
-
-// VK_PRIOR (21) PAGE UP key
-const int VK_PRIOR = 0x21;
-
-// VK_NEXT (22) PAGE DOWN key
-const int VK_NEXT = 0x22;
-
-// VK_END (23) END key
-const int VK_END = 0x23;
-
-// VK_HOME (24) HOME key
-const int VK_HOME = 0x24;
-
-// VK_LEFT (25) LEFT ARROW key
-const int VK_LEFT = 0x25;
-
-// VK_UP (26) UP ARROW key
-const int VK_UP = 0x26;
-
-// VK_RIGHT (27) RIGHT ARROW key
-const int VK_RIGHT = 0x27;
-
-// VK_DOWN (28) DOWN ARROW key
-const int VK_DOWN = 0x28;
-
-// VK_SELECT (29) SELECT key
-const int VK_SELECT = 0x29;
-
-// VK_PRINT (2A) PRINT key
-const int VK_PRINT = 0x2A;
-
-// VK_EXECUTE (2B) EXECUTE key
-const int VK_EXECUTE = 0x2B;
-
-// VK_SNAPSHOT (2C) PRINT SCREEN key
-const int VK_SNAPSHOT = 0x2C;
-
-// VK_INSERT (2D) INS key
-const int VK_INSERT = 0x2D;
-
-// VK_DELETE (2E) DEL key
-const int VK_DELETE = 0x2E;
-
-// VK_HELP (2F) HELP key
-const int VK_HELP = 0x2F;
-
-// (30) 0 key
-const int VK_0 = 0x30;
-
-// (31) 1 key
-const int VK_1 = 0x31;
-
-// (32) 2 key
-const int VK_2 = 0x32;
-
-// (33) 3 key
-const int VK_3 = 0x33;
-
-// (34) 4 key
-const int VK_4 = 0x34;
-
-// (35) 5 key;
-
-const int VK_5 = 0x35;
-
-// (36) 6 key
-const int VK_6 = 0x36;
-
-// (37) 7 key
-const int VK_7 = 0x37;
-
-// (38) 8 key
-const int VK_8 = 0x38;
-
-// (39) 9 key
-const int VK_9 = 0x39;
-
-// (41) A key
-const int VK_A = 0x41;
-
-// (42) B key
-const int VK_B = 0x42;
-
-// (43) C key
-const int VK_C = 0x43;
-
-// (44) D key
-const int VK_D = 0x44;
-
-// (45) E key
-const int VK_E = 0x45;
-
-// (46) F key
-const int VK_F = 0x46;
-
-// (47) G key
-const int VK_G = 0x47;
-
-// (48) H key
-const int VK_H = 0x48;
-
-// (49) I key
-const int VK_I = 0x49;
-
-// (4A) J key
-const int VK_J = 0x4A;
-
-// (4B) K key
-const int VK_K = 0x4B;
-
-// (4C) L key
-const int VK_L = 0x4C;
-
-// (4D) M key
-const int VK_M = 0x4D;
-
-// (4E) N key
-const int VK_N = 0x4E;
-
-// (4F) O key
-const int VK_O = 0x4F;
-
-// (50) P key
-const int VK_P = 0x50;
-
-// (51) Q key
-const int VK_Q = 0x51;
-
-// (52) R key
-const int VK_R = 0x52;
-
-// (53) S key
-const int VK_S = 0x53;
-
-// (54) T key
-const int VK_T = 0x54;
-
-// (55) U key
-const int VK_U = 0x55;
-
-// (56) V key
-const int VK_V = 0x56;
-
-// (57) W key
-const int VK_W = 0x57;
-
-// (58) X key
-const int VK_X = 0x58;
-
-// (59) Y key
-const int VK_Y = 0x59;
-
-// (5A) Z key
-const int VK_Z = 0x5A;
-
-// VK_LWIN (5B) Left Windows key (Microsoft Natural keyboard)
-const int VK_LWIN = 0x5B;
-
-// VK_RWIN (5C) Right Windows key (Natural keyboard)
-const int VK_RWIN = 0x5C;
-
-// VK_APPS (5D) Applications key (Natural keyboard)
-const int VK_APPS = 0x5D;
-
-// VK_SLEEP (5F) Computer Sleep key
-const int VK_SLEEP = 0x5F;
-
-// VK_NUMPAD0 (60) Numeric keypad 0 key
-const int VK_NUMPAD0 = 0x60;
-
-// VK_NUMPAD1 (61) Numeric keypad 1 key
-const int VK_NUMPAD1 = 0x61;
-
-// VK_NUMPAD2 (62) Numeric keypad 2 key
-const int VK_NUMPAD2 = 0x62;
-
-// VK_NUMPAD3 (63) Numeric keypad 3 key
-const int VK_NUMPAD3 = 0x63;
-
-// VK_NUMPAD4 (64) Numeric keypad 4 key
-const int VK_NUMPAD4 = 0x64;
-
-// VK_NUMPAD5 (65) Numeric keypad 5 key
-const int VK_NUMPAD5 = 0x65;
-
-// VK_NUMPAD6 (66) Numeric keypad 6 key
-const int VK_NUMPAD6 = 0x66;
-
-// VK_NUMPAD7 (67) Numeric keypad 7 key
-const int VK_NUMPAD7 = 0x67;
-
-// VK_NUMPAD8 (68) Numeric keypad 8 key
-const int VK_NUMPAD8 = 0x68;
-
-// VK_NUMPAD9 (69) Numeric keypad 9 key
-const int VK_NUMPAD9 = 0x69;
-
-// VK_MULTIPLY (6A) Multiply key
-const int VK_MULTIPLY = 0x6A;
-
-// VK_ADD (6B) Add key
-const int VK_ADD = 0x6B;
-
-// VK_SEPARATOR (6C) Separator key
-const int VK_SEPARATOR = 0x6C;
-
-// VK_SUBTRACT (6D) Subtract key
-const int VK_SUBTRACT = 0x6D;
-
-// VK_DECIMAL (6E) Decimal key
-const int VK_DECIMAL = 0x6E;
-
-// VK_DIVIDE (6F) Divide key
-const int VK_DIVIDE = 0x6F;
-
-// VK_F1 (70) F1 key
-const int VK_F1 = 0x70;
-
-// VK_F2 (71) F2 key
-const int VK_F2 = 0x71;
-
-// VK_F3 (72) F3 key
-const int VK_F3 = 0x72;
-
-// VK_F4 (73) F4 key
-const int VK_F4 = 0x73;
-
-// VK_F5 (74) F5 key
-const int VK_F5 = 0x74;
-
-// VK_F6 (75) F6 key
-const int VK_F6 = 0x75;
-
-// VK_F7 (76) F7 key
-const int VK_F7 = 0x76;
-
-// VK_F8 (77) F8 key
-const int VK_F8 = 0x77;
-
-// VK_F9 (78) F9 key
-const int VK_F9 = 0x78;
-
-// VK_F10 (79) F10 key
-const int VK_F10 = 0x79;
-
-// VK_F11 (7A) F11 key
-const int VK_F11 = 0x7A;
-
-// VK_F12 (7B) F12 key
-const int VK_F12 = 0x7B;
-
-// VK_F13 (7C) F13 key
-const int VK_F13 = 0x7C;
-
-// VK_F14 (7D) F14 key
-const int VK_F14 = 0x7D;
-
-// VK_F15 (7E) F15 key
-const int VK_F15 = 0x7E;
-
-// VK_F16 (7F) F16 key
-const int VK_F16 = 0x7F;
-
-// VK_F17 (80H) F17 key
-const int VK_F17 = 0x80;
-
-// VK_F18 (81H) F18 key
-const int VK_F18 = 0x81;
-
-// VK_F19 (82H) F19 key
-const int VK_F19 = 0x82;
-
-// VK_F20 (83H) F20 key
-const int VK_F20 = 0x83;
-
-// VK_F21 (84H) F21 key
-const int VK_F21 = 0x84;
-
-// VK_F22 (85H) F22 key
-const int VK_F22 = 0x85;
-
-// VK_F23 (86H) F23 key
-const int VK_F23 = 0x86;
-
-// VK_F24 (87H) F24 key
-const int VK_F24 = 0x87;
-
-// VK_NUMLOCK (90) NUM LOCK key
-const int VK_NUMLOCK = 0x90;
-
-// VK_SCROLL (91) SCROLL LOCK key
-const int VK_SCROLL = 0x91;
-
-// VK_LSHIFT (A0) Left SHIFT key
-const int VK_LSHIFT = 0xA0;
-
-// VK_RSHIFT (A1) Right SHIFT key
-const int VK_RSHIFT = 0xA1;
-
-// VK_LCONTROL (A2) Left CONTROL key
-const int VK_LCONTROL = 0xA2;
-
-// VK_RCONTROL (A3) Right CONTROL key
-const int VK_RCONTROL = 0xA3;
-
-// VK_LMENU (A4) Left MENU key
-const int VK_LMENU = 0xA4;
-
-// VK_RMENU (A5) Right MENU key
-const int VK_RMENU = 0xA5;
-
-// VK_BROWSER_BACK (A6) Windows 2000/XP: Browser Back key
-const int VK_BROWSER_BACK = 0xA6;
-
-// VK_BROWSER_FORWARD (A7) Windows 2000/XP: Browser Forward key
-const int VK_BROWSER_FORWARD = 0xA7;
-
-// VK_BROWSER_REFRESH (A8) Windows 2000/XP: Browser Refresh key
-const int VK_BROWSER_REFRESH = 0xA8;
-
-// VK_BROWSER_STOP (A9) Windows 2000/XP: Browser Stop key
-const int VK_BROWSER_STOP = 0xA9;
-
-// VK_BROWSER_SEARCH (AA) Windows 2000/XP: Browser Search key
-const int VK_BROWSER_SEARCH = 0xAA;
-
-// VK_BROWSER_FAVORITES (AB) Windows 2000/XP: Browser Favorites key
-const int VK_BROWSER_FAVORITES = 0xAB;
-
-// VK_BROWSER_HOME (AC) Windows 2000/XP: Browser Start and Home key
-const int VK_BROWSER_HOME = 0xAC;
-
-// VK_VOLUME_MUTE (AD) Windows 2000/XP: Volume Mute key
-const int VK_VOLUME_MUTE = 0xAD;
-
-// VK_VOLUME_DOWN (AE) Windows 2000/XP: Volume Down key
-const int VK_VOLUME_DOWN = 0xAE;
-
-// VK_VOLUME_UP (AF) Windows 2000/XP: Volume Up key
-const int VK_VOLUME_UP = 0xAF;
-
-// VK_MEDIA_NEXT_TRACK (B0) Windows 2000/XP: Next Track key
-const int VK_MEDIA_NEXT_TRACK = 0xB0;
-
-// VK_MEDIA_PREV_TRACK (B1) Windows 2000/XP: Previous Track key
-const int VK_MEDIA_PREV_TRACK = 0xB1;
-
-// VK_MEDIA_STOP (B2) Windows 2000/XP: Stop Media key
-const int VK_MEDIA_STOP = 0xB2;
-
-// VK_MEDIA_PLAY_PAUSE (B3) Windows 2000/XP: Play/Pause Media key
-const int VK_MEDIA_PLAY_PAUSE = 0xB3;
-
-// VK_LAUNCH_MAIL (B4) Windows 2000/XP: Start Mail key
-const int VK_MEDIA_LAUNCH_MAIL = 0xB4;
-
-// VK_LAUNCH_MEDIA_SELECT (B5) Windows 2000/XP: Select Media key
-const int VK_MEDIA_LAUNCH_MEDIA_SELECT = 0xB5;
-
-// VK_LAUNCH_APP1 (B6) Windows 2000/XP: Start Application 1 key
-const int VK_MEDIA_LAUNCH_APP1 = 0xB6;
-
-// VK_LAUNCH_APP2 (B7) Windows 2000/XP: Start Application 2 key
-const int VK_MEDIA_LAUNCH_APP2 = 0xB7;
-
-// VK_OEM_1 (BA) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ';:' key
-const int VK_OEM_1 = 0xBA;
-
-// VK_OEM_PLUS (BB) Windows 2000/XP: For any country/region, the '+' key
-const int VK_OEM_PLUS = 0xBB;
-
-// VK_OEM_COMMA (BC) Windows 2000/XP: For any country/region, the ',' key
-const int VK_OEM_COMMA = 0xBC;
-
-// VK_OEM_MINUS (BD) Windows 2000/XP: For any country/region, the '-' key
-const int VK_OEM_MINUS = 0xBD;
-
-// VK_OEM_PERIOD (BE) Windows 2000/XP: For any country/region, the '.' key
-const int VK_OEM_PERIOD = 0xBE;
-
-// VK_OEM_2 (BF) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '/?' key
-const int VK_OEM_2 = 0xBF;
-
-// VK_OEM_3 (C0) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '`~' key
-const int VK_OEM_3 = 0xC0;
-
-// VK_OEM_4 (DB) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '[{' key
-const int VK_OEM_4 = 0xDB;
-
-// VK_OEM_5 (DC) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '\|' key
-const int VK_OEM_5 = 0xDC;
-
-// VK_OEM_6 (DD) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ']}' key
-const int VK_OEM_6 = 0xDD;
-
-// VK_OEM_7 (DE) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the 'single-quote/double-quote' key
-const int VK_OEM_7 = 0xDE;
-
-// VK_OEM_8 (DF) Used for miscellaneous characters; it can vary by keyboard.
-const int VK_OEM_8 = 0xDF;
-
-// VK_OEM_102 (E2) Windows 2000/XP: Either the angle bracket key or the backslash key on the RT 102-key keyboard
-const int VK_OEM_102 = 0xE2;
-
-// VK_PROCESSKEY (E5) Windows 95/98/Me, Windows NT 4.0, Windows 2000/XP: IME PROCESS key
-const int VK_PROCESSKEY = 0xE5;
-
-// VK_PACKET (E7) Windows 2000/XP: Used to pass Unicode characters as if they were keystrokes. The VK_PACKET key is the low word of a 32-bit Virtual Key value used for non-keyboard input methods. For more information, see Remark in KEYBDINPUT,SendInput, WM_KEYDOWN, and WM_KEYUP
-const int VK_PACKET = 0xE7;
-
-// VK_ATTN (F6) Attn key
-const int VK_ATTN = 0xF6;
-
-// VK_CRSEL (F7) CrSel key
-const int VK_CRSEL = 0xF7;
-
-// VK_EXSEL (F8) ExSel key
-const int VK_EXSEL = 0xF8;
-
-// VK_EREOF (F9) Erase EOF key
-const int VK_EREOF = 0xF9;
-
-// VK_PLAY (FA) Play key
-const int VK_PLAY = 0xFA;
-
-// VK_ZOOM (FB) Zoom key
-const int VK_ZOOM = 0xFB;
-
-// VK_NONAME (FC) Reserved for future use
-const int VK_NONAME = 0xFC;
-
-// VK_PA1 (FD) PA1 key
-const int VK_PA1 = 0xFD;
-
-// VK_OEM_CLEAR (FE) Clear key
-const int VK_OEM_CLEAR = 0xFE;
-
-const int VK_UNKNOWN = 0;
-
-}
-
-#endif
diff --git a/WebCore/platform/gtk/Language.cpp b/WebCore/platform/gtk/Language.cpp
deleted file mode 100644
index 6ae7305..0000000
--- a/WebCore/platform/gtk/Language.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2007 Alp Toker <alp@atoker.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-#include "Language.h"
-
-#include "CString.h"
-#include "PlatformString.h"
-
-#include <gtk/gtk.h>
-#include <pango/pango.h>
-
-#if !defined(PANGO_VERSION_CHECK)
-// PANGO_VERSION_CHECK() and pango_language_get_default() appeared in 1.5.2
-#include <locale.h>
-
-static gchar *
-_pango_get_lc_ctype (void)
-{
- return g_strdup (setlocale (LC_CTYPE, NULL));
-}
-
-static PangoLanguage *
-pango_language_get_default (void)
-{
- static PangoLanguage *result = NULL;
- if (G_UNLIKELY (!result))
- {
- gchar *lang = _pango_get_lc_ctype ();
- result = pango_language_from_string (lang);
- g_free (lang);
- }
- return result;
-}
-#endif
-
-namespace WebCore {
-
-String defaultLanguage()
-{
- return pango_language_to_string(gtk_get_default_language());
-}
-
-}
diff --git a/WebCore/platform/gtk/LocalizedStringsGtk.cpp b/WebCore/platform/gtk/LocalizedStringsGtk.cpp
deleted file mode 100644
index 52d4f5f..0000000
--- a/WebCore/platform/gtk/LocalizedStringsGtk.cpp
+++ /dev/null
@@ -1,346 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
- * Copyright (C) 2007 Holger Hans Peter Freyther
- * Copyright (C) 2008 Christian Dywan <christian@imendio.com>
- * Copyright (C) 2008 Nuanti Ltd.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "LocalizedStrings.h"
-#include "NotImplemented.h"
-#include "PlatformString.h"
-
-#include <gtk/gtk.h>
-#include <glib/gi18n.h>
-
-namespace WebCore {
-
-static const char* gtkStockLabel(const char* stockID)
-{
- GtkStockItem item;
- if (!gtk_stock_lookup(stockID, &item))
- return stockID;
- return item.label;
-}
-
-String submitButtonDefaultLabel()
-{
- return String::fromUTF8(_("Submit"));
-}
-
-String inputElementAltText()
-{
- return String::fromUTF8(_("Submit"));
-}
-
-String resetButtonDefaultLabel()
-{
- return String::fromUTF8(_("Reset"));
-}
-
-String searchableIndexIntroduction()
-{
- return String::fromUTF8(_("_Searchable Index"));
-}
-
-String fileButtonChooseFileLabel()
-{
- return String::fromUTF8(_("Choose File"));
-}
-
-String fileButtonNoFileSelectedLabel()
-{
- return String::fromUTF8(_("(None)"));
-}
-
-String contextMenuItemTagOpenLinkInNewWindow()
-{
- return String::fromUTF8(_("Open Link in New _Window"));
-}
-
-String contextMenuItemTagDownloadLinkToDisk()
-{
- return String::fromUTF8(_("_Download Linked File"));
-}
-
-String contextMenuItemTagCopyLinkToClipboard()
-{
- return String::fromUTF8(_("Copy Link Loc_ation"));
-}
-
-String contextMenuItemTagOpenImageInNewWindow()
-{
- return String::fromUTF8(_("Open _Image in New Window"));
-}
-
-String contextMenuItemTagDownloadImageToDisk()
-{
- return String::fromUTF8(_("Sa_ve Image As"));
-}
-
-String contextMenuItemTagCopyImageToClipboard()
-{
- return String::fromUTF8(_("Cop_y Image"));
-}
-
-String contextMenuItemTagOpenFrameInNewWindow()
-{
- return String::fromUTF8(_("Open _Frame in New Window"));
-}
-
-String contextMenuItemTagCopy()
-{
- static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_COPY));
- return stockLabel;
-}
-
-String contextMenuItemTagDelete()
-{
- static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_DELETE));
- return stockLabel;
-}
-
-String contextMenuItemTagSelectAll()
-{
-#if GTK_CHECK_VERSION(2,10,0)
- static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_SELECT_ALL));
-#else
- static String stockLabel = String::fromUTF8(_("Select _All"));
-#endif
- return stockLabel;
-}
-
-String contextMenuItemTagUnicode()
-{
- return String::fromUTF8(_("_Insert Unicode Control Character"));
-}
-
-String contextMenuItemTagInputMethods()
-{
- return String::fromUTF8(_("Input _Methods"));
-}
-
-String contextMenuItemTagGoBack()
-{
- static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_GO_BACK));
- return stockLabel;
-}
-
-String contextMenuItemTagGoForward()
-{
- static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_GO_FORWARD));
- return stockLabel;
-}
-
-String contextMenuItemTagStop()
-{
- static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_STOP));
- return stockLabel;
-}
-
-String contextMenuItemTagReload()
-{
- return String::fromUTF8(_("_Reload"));
-}
-
-String contextMenuItemTagCut()
-{
- static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_CUT));
- return stockLabel;
-}
-
-String contextMenuItemTagPaste()
-{
- static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_PASTE));
- return stockLabel;
-}
-
-String contextMenuItemTagNoGuessesFound()
-{
- return String::fromUTF8(_("No Guesses Found"));
-}
-
-String contextMenuItemTagIgnoreSpelling()
-{
- return String::fromUTF8(_("_Ignore Spelling"));
-}
-
-String contextMenuItemTagLearnSpelling()
-{
- return String::fromUTF8(_("_Learn Spelling"));
-}
-
-String contextMenuItemTagSearchWeb()
-{
- return String::fromUTF8(_("_Search the Web"));
-}
-
-String contextMenuItemTagLookUpInDictionary()
-{
- return String::fromUTF8(_("_Look Up in Dictionary"));
-}
-
-String contextMenuItemTagOpenLink()
-{
- return String::fromUTF8(_("_Open Link"));
-}
-
-String contextMenuItemTagIgnoreGrammar()
-{
- return String::fromUTF8(_("Ignore _Grammar"));
-}
-
-String contextMenuItemTagSpellingMenu()
-{
- return String::fromUTF8(_("Spelling and _Grammar"));
-}
-
-String contextMenuItemTagShowSpellingPanel(bool show)
-{
- return String::fromUTF8(show ? _("_Show Spelling and Grammar") : _("_Hide Spelling and Grammar"));
-}
-
-String contextMenuItemTagCheckSpelling()
-{
- return String::fromUTF8(_("_Check Document Now"));
-}
-
-String contextMenuItemTagCheckSpellingWhileTyping()
-{
- return String::fromUTF8(_("Check Spelling While _Typing"));
-}
-
-String contextMenuItemTagCheckGrammarWithSpelling()
-{
- return String::fromUTF8(_("Check _Grammar With Spelling"));
-}
-
-String contextMenuItemTagFontMenu()
-{
- return String::fromUTF8(_("_Font"));
-}
-
-String contextMenuItemTagBold()
-{
- static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_BOLD));
- return stockLabel;
-}
-
-String contextMenuItemTagItalic()
-{
- static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_ITALIC));
- return stockLabel;
-}
-
-String contextMenuItemTagUnderline()
-{
- static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_UNDERLINE));
- return stockLabel;
-}
-
-String contextMenuItemTagOutline()
-{
- return String::fromUTF8(_("_Outline"));
-}
-
-String contextMenuItemTagInspectElement()
-{
- return String::fromUTF8(_("Inspect _Element"));
-}
-
-String searchMenuNoRecentSearchesText()
-{
- return String::fromUTF8(_("No recent searches"));
-}
-
-String searchMenuRecentSearchesText()
-{
- return String::fromUTF8(_("Recent searches"));
-}
-
-String searchMenuClearRecentSearchesText()
-{
- return String::fromUTF8(_("_Clear recent searches"));
-}
-
-String AXDefinitionListTermText()
-{
- return String::fromUTF8(_("term"));
-}
-
-String AXDefinitionListDefinitionText()
-{
- return String::fromUTF8(_("definition"));
-}
-
-String AXButtonActionVerb()
-{
- return String::fromUTF8(_("press"));
-}
-
-String AXRadioButtonActionVerb()
-{
- return String::fromUTF8(_("select"));
-}
-
-String AXTextFieldActionVerb()
-{
- return String::fromUTF8(_("activate"));
-}
-
-String AXCheckedCheckBoxActionVerb()
-{
- return String::fromUTF8(_("uncheck"));
-}
-
-String AXUncheckedCheckBoxActionVerb()
-{
- return String::fromUTF8(_("check"));
-}
-
-String AXLinkActionVerb()
-{
- return String::fromUTF8(_("jump"));
-}
-
-String multipleFileUploadText(unsigned numberOfFiles)
-{
- // FIXME: If this file gets localized, this should really be localized as one string with a wildcard for the number.
- return String::number(numberOfFiles) + String::fromUTF8(_(" files"));
-}
-
-String unknownFileSizeText()
-{
- return String::fromUTF8(_("Unknown"));
-}
-
-String imageTitle(const String& filename, const IntSize& size)
-{
- notImplemented();
- return String();
-}
-
-}
diff --git a/WebCore/platform/gtk/LoggingGtk.cpp b/WebCore/platform/gtk/LoggingGtk.cpp
deleted file mode 100644
index 5bc1559..0000000
--- a/WebCore/platform/gtk/LoggingGtk.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2007 Alp Toker <alp@atoker.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-#include "Logging.h"
-
-namespace WebCore {
-
-void InitializeLoggingChannelsIfNecessary()
-{
- // FIXME: Add a way for the user to specify which
- // logs he/she would like turned on.
- LogNotYetImplemented.state = WTFLogChannelOn;
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/gtk/MIMETypeRegistryGtk.cpp b/WebCore/platform/gtk/MIMETypeRegistryGtk.cpp
deleted file mode 100644
index 20fe0cb..0000000
--- a/WebCore/platform/gtk/MIMETypeRegistryGtk.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2006 Zack Rusin <zack@kde.org>
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "MIMETypeRegistry.h"
-
-namespace WebCore {
-
-struct ExtensionMap {
- const char* extension;
- const char* mimeType;
-};
-
-static const ExtensionMap extensionMap [] = {
- { "bmp", "image/bmp" },
- { "css", "text/css" },
- { "gif", "image/gif" },
- { "html", "text/html" },
- { "ico", "image/x-icon" },
- { "jpeg", "image/jpeg" },
- { "jpg", "image/jpeg" },
- { "js", "application/x-javascript" },
- { "pdf", "application/pdf" },
- { "png", "image/png" },
- { "rss", "application/rss+xml" },
- { "svg", "image/svg+xml" },
- { "text", "text/plain" },
- { "txt", "text/plain" },
- { "xbm", "image/x-xbitmap" },
- { "xml", "text/xml" },
- { "xsl", "text/xsl" },
- { "xhtml", "application/xhtml+xml" },
- { 0, 0 }
-};
-
-String MIMETypeRegistry::getMIMETypeForExtension(const String &ext)
-{
- String s = ext.lower();
- const ExtensionMap *e = extensionMap;
- while (e->extension) {
- if (s == e->extension)
- return e->mimeType;
- ++e;
- }
-
- return String();
-}
-
-}
diff --git a/WebCore/platform/gtk/MouseEventGtk.cpp b/WebCore/platform/gtk/MouseEventGtk.cpp
deleted file mode 100644
index f441f00..0000000
--- a/WebCore/platform/gtk/MouseEventGtk.cpp
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
-* Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions
-* are met:
-* 1. Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* 2. Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-*
-* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
-* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
-* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
-* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#include "config.h"
-#include "PlatformMouseEvent.h"
-
-#include "SystemTime.h"
-#include "Assertions.h"
-
-#include <gdk/gdk.h>
-#include <gtk/gtkversion.h>
-
-namespace WebCore {
-
-// FIXME: Would be even better to figure out which modifier is Alt instead of always using GDK_MOD1_MASK.
-
-// Keep this in sync with the other platform event constructors
-PlatformMouseEvent::PlatformMouseEvent(GdkEventButton* event)
-{
- m_timestamp = event->time;
- m_position = IntPoint((int)event->x, (int)event->y);
- m_globalPosition = IntPoint((int)event->x_root, (int)event->y_root);
- m_shiftKey = event->state & GDK_SHIFT_MASK;
- m_ctrlKey = event->state & GDK_CONTROL_MASK;
- m_altKey = event->state & GDK_MOD1_MASK;
-#if GTK_CHECK_VERSION(2,10,0)
- m_metaKey = event->state & GDK_META_MASK;
-#else
- // GDK_MOD2_MASK doesn't always mean meta so we can't use it
- m_metaKey = false;
-#endif
-
- switch (event->type) {
- case GDK_BUTTON_PRESS:
- case GDK_2BUTTON_PRESS:
- case GDK_3BUTTON_PRESS:
- case GDK_BUTTON_RELEASE:
- m_eventType = MouseEventPressed;
- if (event->type == GDK_BUTTON_RELEASE) {
- m_eventType = MouseEventReleased;
- m_clickCount = 0;
- } else if (event->type == GDK_BUTTON_PRESS)
- m_clickCount = 1;
- else if (event->type == GDK_2BUTTON_PRESS)
- m_clickCount = 2;
- else if (event->type == GDK_3BUTTON_PRESS)
- m_clickCount = 3;
-
- if (event->button == 1)
- m_button = LeftButton;
- else if (event->button == 2)
- m_button = MiddleButton;
- else if (event->button == 3)
- m_button = RightButton;
- break;
-
- default:
- ASSERT_NOT_REACHED();
- };
-}
-
-PlatformMouseEvent::PlatformMouseEvent(GdkEventMotion* motion)
-{
- m_timestamp = motion->time;
- m_position = IntPoint((int)motion->x, (int)motion->y);
- m_globalPosition = IntPoint((int)motion->x_root, (int)motion->y_root);
- m_shiftKey = motion->state & GDK_SHIFT_MASK;
- m_ctrlKey = motion->state & GDK_CONTROL_MASK;
- m_altKey = motion->state & GDK_MOD1_MASK;
- m_metaKey = motion->state & GDK_MOD2_MASK;
-
- switch (motion->type) {
- case GDK_MOTION_NOTIFY:
- m_eventType = MouseEventMoved;
- m_button = NoButton;
- m_clickCount = 0;
- break;
- default:
- ASSERT_NOT_REACHED();
- };
-
- if (motion->state & GDK_BUTTON1_MASK)
- m_button = LeftButton;
- else if (motion->state & GDK_BUTTON2_MASK)
- m_button = MiddleButton;
- else if (motion->state & GDK_BUTTON3_MASK)
- m_button = RightButton;
-}
-}
diff --git a/WebCore/platform/gtk/PasteboardGtk.cpp b/WebCore/platform/gtk/PasteboardGtk.cpp
deleted file mode 100644
index 15a7e64..0000000
--- a/WebCore/platform/gtk/PasteboardGtk.cpp
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * Copyright (C) 2007 Holger Hans Peter Freyther
- * Copyright (C) 2007 Alp Toker <alp@atoker.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "config.h"
-#include "Pasteboard.h"
-
-#include "CString.h"
-#include "DocumentFragment.h"
-#include "Frame.h"
-#include "NotImplemented.h"
-#include "PlatformString.h"
-#include "Image.h"
-#include "RenderImage.h"
-#include "KURL.h"
-#include "markup.h"
-
-#include <gtk/gtk.h>
-
-namespace WebCore {
-
-/* FIXME: we must get rid of this and use the enum in webkitwebview.h someway */
-typedef enum
-{
- WEBKIT_WEB_VIEW_TARGET_INFO_HTML = - 1,
- WEBKIT_WEB_VIEW_TARGET_INFO_TEXT = - 2
-} WebKitWebViewTargetInfo;
-
-class PasteboardSelectionData {
-public:
- PasteboardSelectionData(gchar* text, gchar* markup)
- : m_text(text)
- , m_markup(markup) { }
-
- ~PasteboardSelectionData() {
- g_free(m_text);
- g_free(m_markup);
- }
-
- const gchar* text() const { return m_text; }
- const gchar* markup() const { return m_markup; }
-
-private:
- gchar* m_text;
- gchar* m_markup;
-};
-
-static void clipboard_get_contents_cb(GtkClipboard *clipboard, GtkSelectionData *selection_data,
- guint info, gpointer data) {
- PasteboardSelectionData* clipboardData = reinterpret_cast<PasteboardSelectionData*>(data);
- ASSERT(clipboardData);
- if ((gint)info == WEBKIT_WEB_VIEW_TARGET_INFO_HTML) {
- gtk_selection_data_set(selection_data, selection_data->target, 8,
- reinterpret_cast<const guchar*>(clipboardData->markup()),
- g_utf8_strlen(clipboardData->markup(), -1));
- } else
- gtk_selection_data_set_text(selection_data, clipboardData->text(), -1);
-}
-
-static void clipboard_clear_contents_cb(GtkClipboard *clipboard, gpointer data) {
- PasteboardSelectionData* clipboardData = reinterpret_cast<PasteboardSelectionData*>(data);
- ASSERT(clipboardData);
- delete clipboardData;
-}
-
-
-Pasteboard* Pasteboard::generalPasteboard()
-{
- static Pasteboard* pasteboard = new Pasteboard();
- return pasteboard;
-}
-
-Pasteboard::Pasteboard()
-{
- notImplemented();
-}
-
-Pasteboard::~Pasteboard()
-{
- delete m_helper;
-}
-
-void Pasteboard::setHelper(PasteboardHelper* helper)
-{
- m_helper = helper;
-}
-
-void Pasteboard::writeSelection(Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame)
-{
- GtkClipboard* clipboard = m_helper->getClipboard(frame);
-#if GTK_CHECK_VERSION(2,10,0)
- gchar* text = g_strdup(frame->selectedText().utf8().data());
- gchar* markup = g_strdup(createMarkup(selectedRange, 0, AnnotateForInterchange).utf8().data());
- PasteboardSelectionData* data = new PasteboardSelectionData(text, markup);
-
- gint n_targets;
- GtkTargetEntry* targets = gtk_target_table_new_from_list(m_helper->getCopyTargetList(frame), &n_targets);
- gtk_clipboard_set_with_data(clipboard, targets, n_targets,
- clipboard_get_contents_cb, clipboard_clear_contents_cb, data);
- gtk_target_table_free(targets, n_targets);
-#else
- gtk_clipboard_set_text(clipboard, frame->selectedText().utf8().data(), frame->selectedText().utf8().length());
-#endif
-}
-
-void Pasteboard::writeURL(const KURL& url, const String&, Frame* frame)
-{
- if (url.isEmpty())
- return;
-
- GtkClipboard* clipboard = m_helper->getClipboard(frame);
- gtk_clipboard_set_text(clipboard, url.string().utf8().data(), url.string().utf8().length());
-}
-
-void Pasteboard::writeImage(Node* node, const KURL&, const String&)
-{
- // TODO: Enable this when Image gets GdkPixbuf support
-
- /*
- GtkClipboard* clipboard = gtk_clipboard_get_for_display(gdk_display_get_default(), GDK_SELECTION_CLIPBOARD);
-
- ASSERT(node && node->renderer() && node->renderer()->isImage());
- RenderImage* renderer = static_cast<RenderImage*>(node->renderer());
- CachedImage* cachedImage = static_cast<CachedImage*>(renderer->cachedImage());
- ASSERT(cachedImage);
- Image* image = cachedImage->image();
- ASSERT(image);
-
- gtk_clipboard_set_image(clipboard, image->pixbuf());
- */
-
- notImplemented();
-}
-
-void Pasteboard::clear()
-{
- GtkClipboard* clipboard = gtk_clipboard_get_for_display(gdk_display_get_default(), GDK_SELECTION_CLIPBOARD);
-
- gtk_clipboard_clear(clipboard);
-}
-
-bool Pasteboard::canSmartReplace()
-{
- notImplemented();
- return false;
-}
-
-PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefPtr<Range> context,
- bool allowPlainText, bool& chosePlainText)
-{
-#if GTK_CHECK_VERSION(2,10,0)
- GdkAtom textHtml = gdk_atom_intern_static_string("text/html");
-#else
- GdkAtom textHtml = gdk_atom_intern("text/html", false);
-#endif
- GtkClipboard* clipboard = m_helper->getClipboard(frame);
- chosePlainText = false;
-
- if (GtkSelectionData* data = gtk_clipboard_wait_for_contents(clipboard, textHtml)) {
- ASSERT(data->data);
- String html = String::fromUTF8(reinterpret_cast<gchar*>(data->data), data->length * data->format / 8);
- gtk_selection_data_free(data);
-
- if (!html.isEmpty()) {
- RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(frame->document(), html, "");
- if (fragment)
- return fragment.release();
- }
- }
-
- if (!allowPlainText)
- return 0;
-
- if (gchar* utf8 = gtk_clipboard_wait_for_text(clipboard)) {
- String text = String::fromUTF8(utf8);
- g_free(utf8);
-
- chosePlainText = true;
- RefPtr<DocumentFragment> fragment = createFragmentFromText(context.get(), text);
- if (fragment)
- return fragment.release();
- }
-
- return 0;
-}
-
-String Pasteboard::plainText(Frame* frame)
-{
- GtkClipboard* clipboard = m_helper->getClipboard(frame);
-
- gchar* utf8 = gtk_clipboard_wait_for_text(clipboard);
-
- if (!utf8)
- return String();
-
- String text = String::fromUTF8(utf8);
- g_free(utf8);
-
- return text;
-}
-
-}
diff --git a/WebCore/platform/gtk/PasteboardHelper.h b/WebCore/platform/gtk/PasteboardHelper.h
deleted file mode 100644
index 6bdc05e..0000000
--- a/WebCore/platform/gtk/PasteboardHelper.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2007 Luca Bruno <lethalman88@gmail.com>
- * All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef PasteboardHelper_h
-#define PasteboardHelper_h
-
-/*
- * FIXME: this is for WebCore support and must be removed once
- * a better solution is found
- */
-
-#include "Frame.h"
-
-#include <gtk/gtk.h>
-
-namespace WebCore {
-
-class PasteboardHelper {
-public:
- virtual ~PasteboardHelper() {};
-
- virtual GtkClipboard* getClipboard(Frame*) const = 0;
- virtual GtkTargetList* getCopyTargetList(Frame*) const = 0;
- virtual GtkTargetList* getPasteTargetList(Frame*) const = 0;
-};
-
-}
-
-#endif // PasteboardHelper_h
diff --git a/WebCore/platform/gtk/PlatformScreenGtk.cpp b/WebCore/platform/gtk/PlatformScreenGtk.cpp
deleted file mode 100644
index 9788253..0000000
--- a/WebCore/platform/gtk/PlatformScreenGtk.cpp
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
- * Copyright (C) 2008 Christian Dywan <christian@imendio.com>
- * Copyright (C) 2008 Collabora Ltd.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "PlatformScreen.h"
-
-#include "HostWindow.h"
-#include "NotImplemented.h"
-#include "ScrollView.h"
-#include "Widget.h"
-
-#include <gtk/gtk.h>
-
-#if PLATFORM(X11)
-#include <gdk/gdkx.h>
-#include <X11/Xatom.h>
-#endif
-
-namespace WebCore {
-
-int screenDepth(Widget* widget)
-{
- GtkWidget* container = GTK_WIDGET(widget->root()->hostWindow()->platformWindow());
- if (!container)
- return 24;
-
- GdkVisual* visual = gdk_drawable_get_visual(GDK_DRAWABLE(GTK_WIDGET(widget->root()->hostWindow()->platformWindow())->window));
- return visual->depth;
-}
-
-int screenDepthPerComponent(Widget* widget)
-{
- GtkWidget* container = GTK_WIDGET(widget->root()->hostWindow()->platformWindow());
- if (!container)
- return 8;
-
- GdkVisual* visual = gdk_drawable_get_visual(GDK_DRAWABLE(GTK_WIDGET(widget->root()->hostWindow()->platformWindow())->window));
- return visual->bits_per_rgb;
-}
-
-bool screenIsMonochrome(Widget* widget)
-{
- GtkWidget* container = GTK_WIDGET(widget->root()->hostWindow()->platformWindow());
- if (!container)
- return false;
-
- return screenDepth(widget) < 2;
-}
-
-FloatRect screenRect(Widget* widget)
-{
- GtkWidget* container = GTK_WIDGET(widget->root()->hostWindow()->platformWindow());
- if (!container)
- return FloatRect();
-
- GdkScreen* screen = gtk_widget_has_screen(container) ? gtk_widget_get_screen(container) : gdk_screen_get_default();
- if (!screen)
- return FloatRect();
-
- gint monitor = gdk_screen_get_monitor_at_window(screen, GTK_WIDGET(container)->window);
- GdkRectangle geometry;
- gdk_screen_get_monitor_geometry(screen, monitor, &geometry);
-
- return FloatRect(geometry.x, geometry.y, geometry.width, geometry.height);
-}
-
-FloatRect screenAvailableRect(Widget* widget)
-{
-#if PLATFORM(X11)
- GtkWidget* container = GTK_WIDGET(widget->root()->hostWindow()->platformWindow());
- if (!container)
- return FloatRect();
-
- if (!GTK_WIDGET_REALIZED(container))
- return screenRect(widget);
-
- GdkDrawable* rootWindow = GDK_DRAWABLE(gtk_widget_get_root_window(container));
- GdkDisplay* display = gdk_drawable_get_display(rootWindow);
- Atom xproperty = gdk_x11_get_xatom_by_name_for_display(display, "_NET_WORKAREA");
-
- Atom retType;
- int retFormat;
- long *workAreaPos = NULL;
- unsigned long retNItems;
- unsigned long retAfter;
- int xRes = XGetWindowProperty(GDK_DISPLAY_XDISPLAY(display), GDK_WINDOW_XWINDOW(rootWindow), xproperty,
- 0, 4, FALSE, XA_CARDINAL, &retType, &retFormat, &retNItems, &retAfter, (guchar**)&workAreaPos);
-
- FloatRect rect;
- if (xRes == Success && workAreaPos != NULL && retType == XA_CARDINAL && retNItems == 4 && retFormat == 32) {
- rect = FloatRect(workAreaPos[0], workAreaPos[1], workAreaPos[2], workAreaPos[3]);
- // rect contains the available space in the whole screen not just in the monitor
- // containing the widget, so we intersect it with the monitor rectangle.
- rect.intersect(screenRect(widget));
- } else
- rect = screenRect(widget);
-
- if (workAreaPos)
- XFree(workAreaPos);
-
- return rect;
-#else
- return screenRect(widget);
-#endif
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/gtk/PopupMenuGtk.cpp b/WebCore/platform/gtk/PopupMenuGtk.cpp
deleted file mode 100644
index 85c5aa0..0000000
--- a/WebCore/platform/gtk/PopupMenuGtk.cpp
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * This file is part of the popup menu implementation for <select> elements in WebCore.
- *
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
- * Copyright (C) 2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "PopupMenu.h"
-
-#include "CString.h"
-#include "FrameView.h"
-#include "HostWindow.h"
-#include "NotImplemented.h"
-#include "PlatformString.h"
-#include <gtk/gtk.h>
-
-namespace WebCore {
-
-PopupMenu::PopupMenu(PopupMenuClient* client)
- : m_popupClient(client)
- , m_popup(0)
-{
-}
-
-PopupMenu::~PopupMenu()
-{
- if (m_popup)
- g_object_unref(m_popup);
-}
-
-void PopupMenu::show(const IntRect& rect, FrameView* view, int index)
-{
- ASSERT(client());
-
- if (!m_popup) {
- m_popup = GTK_MENU(gtk_menu_new());
-#if GLIB_CHECK_VERSION(2,10,0)
- g_object_ref_sink(G_OBJECT(m_popup));
-#else
- g_object_ref(G_OBJECT(m_popup));
- gtk_object_sink(GTK_OBJECT(m_popup));
-#endif
- g_signal_connect(m_popup, "unmap", G_CALLBACK(menuUnmapped), this);
- } else
- gtk_container_foreach(GTK_CONTAINER(m_popup), reinterpret_cast<GtkCallback>(menuRemoveItem), this);
-
- int x, y;
- gdk_window_get_origin(GTK_WIDGET(view->hostWindow()->platformWindow())->window, &x, &y);
- m_menuPosition = view->contentsToWindow(rect.location());
- m_menuPosition = IntPoint(m_menuPosition.x() + x, m_menuPosition.y() + y + rect.height());
- m_indexMap.clear();
-
- const int size = client()->listSize();
- for (int i = 0; i < size; ++i) {
- GtkWidget* item;
- if (client()->itemIsSeparator(i))
- item = gtk_separator_menu_item_new();
- else
- item = gtk_menu_item_new_with_label(client()->itemText(i).utf8().data());
-
- m_indexMap.add(item, i);
- g_signal_connect(item, "activate", G_CALLBACK(menuItemActivated), this);
-
- // FIXME: Apply the PopupMenuStyle from client()->itemStyle(i)
- gtk_widget_set_sensitive(item, client()->itemIsEnabled(i));
- gtk_menu_shell_append(GTK_MENU_SHELL(m_popup), item);
- gtk_widget_show(item);
- }
-
- gtk_menu_set_active(m_popup, index);
-
-
- // The size calls are directly copied from gtkcombobox.c which is LGPL
- GtkRequisition requisition;
- gtk_widget_set_size_request(GTK_WIDGET(m_popup), -1, -1);
- gtk_widget_size_request(GTK_WIDGET(m_popup), &requisition);
- gtk_widget_set_size_request(GTK_WIDGET(m_popup), MAX(rect.width(), requisition.width), -1);
-
- GList* children = GTK_MENU_SHELL(m_popup)->children;
- if (size)
- for (int i = 0; i < size; i++) {
- if (i > index)
- break;
-
- GtkWidget* item = reinterpret_cast<GtkWidget*>(children->data);
- GtkRequisition itemRequisition;
- gtk_widget_get_child_requisition(item, &itemRequisition);
- m_menuPosition.setY(m_menuPosition.y() - itemRequisition.height);
-
- children = g_list_next(children);
- }
- else
- // Center vertically the empty popup in the combo box area
- m_menuPosition.setY(m_menuPosition.y() - rect.height() / 2);
-
- gtk_menu_popup(m_popup, NULL, NULL, reinterpret_cast<GtkMenuPositionFunc>(menuPositionFunction), this, 0, gtk_get_current_event_time());
-}
-
-void PopupMenu::hide()
-{
- ASSERT(m_popup);
- gtk_menu_popdown(m_popup);
-}
-
-void PopupMenu::updateFromElement()
-{
- client()->setTextFromItem(client()->selectedIndex());
-}
-
-bool PopupMenu::itemWritingDirectionIsNatural()
-{
- return true;
-}
-
-void PopupMenu::menuItemActivated(GtkMenuItem* item, PopupMenu* that)
-{
- ASSERT(that->client());
- ASSERT(that->m_indexMap.contains(GTK_WIDGET(item)));
- that->client()->valueChanged(that->m_indexMap.get(GTK_WIDGET(item)));
-}
-
-void PopupMenu::menuUnmapped(GtkWidget*, PopupMenu* that)
-{
- ASSERT(that->client());
- that->client()->hidePopup();
-}
-
-void PopupMenu::menuPositionFunction(GtkMenu*, gint* x, gint* y, gboolean* pushIn, PopupMenu* that)
-{
- *x = that->m_menuPosition.x();
- *y = that->m_menuPosition.y();
- *pushIn = true;
-}
-
-void PopupMenu::menuRemoveItem(GtkWidget* widget, PopupMenu* that)
-{
- ASSERT(that->m_popup);
- gtk_container_remove(GTK_CONTAINER(that->m_popup), widget);
-}
-
-}
-
diff --git a/WebCore/platform/gtk/RenderThemeGtk.cpp b/WebCore/platform/gtk/RenderThemeGtk.cpp
deleted file mode 100644
index bf8b8d7..0000000
--- a/WebCore/platform/gtk/RenderThemeGtk.cpp
+++ /dev/null
@@ -1,478 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc.
- * Copyright (C) 2007 Alp Toker <alp@atoker.com>
- * Copyright (C) 2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "RenderThemeGtk.h"
-
-#include "AffineTransform.h"
-#include "GraphicsContext.h"
-#include "NotImplemented.h"
-#include "RenderObject.h"
-#include "gtkdrawing.h"
-
-#include <gdk/gdk.h>
-
-namespace WebCore {
-
-RenderTheme* theme()
-{
- static RenderThemeGtk gtkTheme;
- return &gtkTheme;
-}
-
-static bool mozGtkInitialized = false;
-
-RenderThemeGtk::RenderThemeGtk()
- : m_gtkWindow(0)
- , m_gtkContainer(0)
- , m_gtkEntry(0)
- , m_gtkTreeView(0)
-{
- if (!mozGtkInitialized) {
- mozGtkInitialized = true;
- moz_gtk_init();
- }
-}
-
-static bool supportsFocus(ControlPart appearance)
-{
- switch (appearance) {
- case PushButtonPart:
- case ButtonPart:
- case TextFieldPart:
- case TextAreaPart:
- case SearchFieldPart:
- case MenulistPart:
- case RadioPart:
- case CheckboxPart:
- return true;
- default:
- return false;
- }
-}
-
-bool RenderThemeGtk::supportsFocusRing(const RenderStyle* style) const
-{
- return supportsFocus(style->appearance());
-}
-
-bool RenderThemeGtk::controlSupportsTints(const RenderObject* o) const
-{
- return isEnabled(o);
-}
-
-int RenderThemeGtk::baselinePosition(const RenderObject* o) const
-{
- // FIXME: This strategy is possibly incorrect for the GTK+ port.
- if (o->style()->appearance() == CheckboxPart ||
- o->style()->appearance() == RadioPart)
- return o->marginTop() + o->height() - 2;
- return RenderTheme::baselinePosition(o);
-}
-
-static GtkTextDirection gtkTextDirection(TextDirection direction)
-{
- switch (direction) {
- case RTL:
- return GTK_TEXT_DIR_RTL;
- case LTR:
- return GTK_TEXT_DIR_LTR;
- default:
- return GTK_TEXT_DIR_NONE;
- }
-}
-
-static void adjustMozStyle(RenderStyle* style, GtkThemeWidgetType type)
-{
- gint left, top, right, bottom;
- GtkTextDirection direction = gtkTextDirection(style->direction());
- gboolean inhtml = true;
-
- if (moz_gtk_get_widget_border(type, &left, &top, &right, &bottom, direction, inhtml) != MOZ_GTK_SUCCESS)
- return;
-
- // FIXME: This approach is likely to be incorrect. See other ports and layout tests to see the problem.
- const int xpadding = 1;
- const int ypadding = 1;
-
- style->setPaddingLeft(Length(xpadding + left, Fixed));
- style->setPaddingTop(Length(ypadding + top, Fixed));
- style->setPaddingRight(Length(xpadding + right, Fixed));
- style->setPaddingBottom(Length(ypadding + bottom, Fixed));
-}
-
-static void setMozState(RenderTheme* theme, GtkWidgetState* state, RenderObject* o)
-{
- state->active = theme->isPressed(o);
- state->focused = theme->isFocused(o);
- state->inHover = theme->isHovered(o);
- // FIXME: Disabled does not always give the correct appearance for ReadOnly
- state->disabled = !theme->isEnabled(o) || theme->isReadOnlyControl(o);
- state->isDefault = false;
- state->canDefault = false;
- state->depressed = false;
-}
-
-static bool paintMozWidget(RenderTheme* theme, GtkThemeWidgetType type, RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect)
-{
- // No GdkWindow to render to, so return true to fall back
- if (!i.context->gdkDrawable())
- return true;
-
- // Painting is disabled so just claim to have succeeded
- if (i.context->paintingDisabled())
- return false;
-
- GtkWidgetState mozState;
- setMozState(theme, &mozState, o);
-
- int flags;
-
- // We might want to make setting flags the caller's job at some point rather than doing it here.
- switch (type) {
- case MOZ_GTK_BUTTON:
- flags = GTK_RELIEF_NORMAL;
- break;
- case MOZ_GTK_CHECKBUTTON:
- case MOZ_GTK_RADIOBUTTON:
- flags = theme->isChecked(o);
- break;
- default:
- flags = 0;
- break;
- }
-
- AffineTransform ctm = i.context->getCTM();
-
- IntPoint pos = ctm.mapPoint(rect.location());
- GdkRectangle gdkRect = IntRect(pos.x(), pos.y(), rect.width(), rect.height());
- GtkTextDirection direction = gtkTextDirection(o->style()->direction());
-
-#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1,4,0)
- // Find the clip rectangle
- cairo_t *cr = i.context->platformContext();
- double clipX1, clipX2, clipY1, clipY2;
- cairo_clip_extents(cr, &clipX1, &clipY1, &clipX2, &clipY2);
-
- GdkRectangle gdkClipRect;
- gdkClipRect.width = clipX2 - clipX1;
- gdkClipRect.height = clipY2 - clipY1;
- IntPoint clipPos = ctm.mapPoint(IntPoint(clipX1, clipY1));
- gdkClipRect.x = clipPos.x();
- gdkClipRect.y = clipPos.y();
-
- gdk_rectangle_intersect(&gdkRect, &gdkClipRect, &gdkClipRect);
-#else
- GdkRectangle gdkClipRect = gdkRect;
-#endif
-
- return moz_gtk_widget_paint(type, i.context->gdkDrawable(), &gdkRect, &gdkClipRect, &mozState, flags, direction) != MOZ_GTK_SUCCESS;
-}
-
-static void setButtonPadding(RenderStyle* style)
-{
- // FIXME: This looks incorrect.
- const int padding = 8;
- style->setPaddingLeft(Length(padding, Fixed));
- style->setPaddingRight(Length(padding, Fixed));
- style->setPaddingTop(Length(padding / 2, Fixed));
- style->setPaddingBottom(Length(padding / 2, Fixed));
-}
-
-static void setToggleSize(RenderStyle* style, ControlPart appearance)
-{
- // The width and height are both specified, so we shouldn't change them.
- if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto())
- return;
-
- // FIXME: This is probably not correct use of indicator_size and indicator_spacing.
- gint indicator_size, indicator_spacing;
-
- switch (appearance) {
- case CheckboxPart:
- if (moz_gtk_checkbox_get_metrics(&indicator_size, &indicator_spacing) != MOZ_GTK_SUCCESS)
- return;
- break;
- case RadioPart:
- if (moz_gtk_radio_get_metrics(&indicator_size, &indicator_spacing) != MOZ_GTK_SUCCESS)
- return;
- break;
- default:
- return;
- }
-
- // Other ports hard-code this to 13, but GTK+ users tend to demand the native look.
- // It could be made a configuration option values other than 13 actually break site compatibility.
- int length = indicator_size + indicator_spacing;
- if (style->width().isIntrinsicOrAuto())
- style->setWidth(Length(length, Fixed));
-
- if (style->height().isAuto())
- style->setHeight(Length(length, Fixed));
-}
-
-void RenderThemeGtk::setCheckboxSize(RenderStyle* style) const
-{
- setToggleSize(style, RadioPart);
-}
-
-bool RenderThemeGtk::paintCheckbox(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect)
-{
- return paintMozWidget(this, MOZ_GTK_CHECKBUTTON, o, i, rect);
-}
-
-void RenderThemeGtk::setRadioSize(RenderStyle* style) const
-{
- setToggleSize(style, RadioPart);
-}
-
-bool RenderThemeGtk::paintRadio(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect)
-{
- return paintMozWidget(this, MOZ_GTK_RADIOBUTTON, o, i, rect);
-}
-
-void RenderThemeGtk::adjustButtonStyle(CSSStyleSelector* selector, RenderStyle* style, WebCore::Element* e) const
-{
- // FIXME: Is this condition necessary?
- if (style->appearance() == PushButtonPart) {
- style->resetBorder();
- style->setHeight(Length(Auto));
- style->setWhiteSpace(PRE);
- setButtonPadding(style);
- } else {
- // FIXME: This should not be hard-coded.
- style->setMinHeight(Length(14, Fixed));
- style->resetBorderTop();
- style->resetBorderBottom();
- }
-}
-
-bool RenderThemeGtk::paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect)
-{
- return paintMozWidget(this, MOZ_GTK_BUTTON, o, i, rect);
-}
-
-void RenderThemeGtk::adjustMenuListStyle(CSSStyleSelector* selector, RenderStyle* style, WebCore::Element* e) const
-{
- style->resetBorder();
- style->resetPadding();
- style->setHeight(Length(Auto));
- style->setWhiteSpace(PRE);
- adjustMozStyle(style, MOZ_GTK_DROPDOWN);
-}
-
-bool RenderThemeGtk::paintMenuList(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect)
-{
- return paintMozWidget(this, MOZ_GTK_DROPDOWN, o, i, rect);
-}
-
-void RenderThemeGtk::adjustTextFieldStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
-{
- style->resetBorder();
- style->resetPadding();
- style->setHeight(Length(Auto));
- style->setWhiteSpace(PRE);
- adjustMozStyle(style, MOZ_GTK_ENTRY);
-}
-
-bool RenderThemeGtk::paintTextField(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect)
-{
- return paintMozWidget(this, MOZ_GTK_ENTRY, o, i, rect);
-}
-
-void RenderThemeGtk::adjustTextAreaStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
-{
- adjustTextFieldStyle(selector, style, e);
-}
-
-bool RenderThemeGtk::paintTextArea(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
-{
- return paintTextField(o, i, r);
-}
-
-void RenderThemeGtk::adjustSearchFieldResultsButtonStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
-{
- adjustSearchFieldCancelButtonStyle(selector, style, e);
-}
-
-bool RenderThemeGtk::paintSearchFieldResultsButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect)
-{
- return paintMozWidget(this, MOZ_GTK_DROPDOWN_ARROW, o, i, rect);
-}
-
-void RenderThemeGtk::adjustSearchFieldResultsDecorationStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
-{
- style->resetBorder();
- style->resetPadding();
-
- // FIXME: This should not be hard-coded.
- IntSize size = IntSize(14, 14);
- style->setWidth(Length(size.width(), Fixed));
- style->setHeight(Length(size.height(), Fixed));
-}
-
-bool RenderThemeGtk::paintSearchFieldResultsDecoration(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect)
-{
- return paintMozWidget(this, MOZ_GTK_CHECKMENUITEM, o, i, rect);
-}
-
-void RenderThemeGtk::adjustSearchFieldCancelButtonStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
-{
- style->resetBorder();
- style->resetPadding();
-
- // FIXME: This should not be hard-coded.
- IntSize size = IntSize(14, 14);
- style->setWidth(Length(size.width(), Fixed));
- style->setHeight(Length(size.height(), Fixed));
-}
-
-bool RenderThemeGtk::paintSearchFieldCancelButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect)
-{
- return paintMozWidget(this, MOZ_GTK_CHECKMENUITEM, o, i, rect);
-}
-
-void RenderThemeGtk::adjustSearchFieldStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
-{
- adjustTextFieldStyle(selector, style, e);
-}
-
-bool RenderThemeGtk::paintSearchField(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect)
-{
- return paintTextField(o, i, rect);
-}
-
-Color RenderThemeGtk::platformActiveSelectionBackgroundColor() const
-{
- GtkWidget* widget = gtkEntry();
- return widget->style->base[GTK_STATE_SELECTED];
-}
-
-Color RenderThemeGtk::platformInactiveSelectionBackgroundColor() const
-{
- GtkWidget* widget = gtkEntry();
- return widget->style->base[GTK_STATE_ACTIVE];
-}
-
-Color RenderThemeGtk::platformActiveSelectionForegroundColor() const
-{
- GtkWidget* widget = gtkEntry();
- return widget->style->text[GTK_STATE_SELECTED];
-}
-
-Color RenderThemeGtk::platformInactiveSelectionForegroundColor() const
-{
- GtkWidget* widget = gtkEntry();
- return widget->style->text[GTK_STATE_ACTIVE];
-}
-
-Color RenderThemeGtk::activeListBoxSelectionBackgroundColor() const
-{
- GtkWidget* widget = gtkTreeView();
- return widget->style->base[GTK_STATE_SELECTED];
-}
-
-Color RenderThemeGtk::inactiveListBoxSelectionBackgroundColor() const
-{
- GtkWidget* widget = gtkTreeView();
- return widget->style->base[GTK_STATE_ACTIVE];
-}
-
-Color RenderThemeGtk::activeListBoxSelectionForegroundColor() const
-{
- GtkWidget* widget = gtkTreeView();
- return widget->style->text[GTK_STATE_SELECTED];
-}
-
-Color RenderThemeGtk::inactiveListBoxSelectionForegroundColor() const
-{
- GtkWidget* widget = gtkTreeView();
- return widget->style->text[GTK_STATE_ACTIVE];
-}
-
-double RenderThemeGtk::caretBlinkFrequency() const
-{
- GtkSettings* settings = gtk_settings_get_default();
-
- gboolean shouldBlink;
- gint time;
-
- g_object_get(settings, "gtk-cursor-blink", &shouldBlink, "gtk-cursor-blink-time", &time, NULL);
-
- if (!shouldBlink)
- return 0;
-
- return time / 2000.;
-}
-
-void RenderThemeGtk::systemFont(int, FontDescription&) const
-{
- // If you remove this notImplemented(), replace it with an comment that explains why.
- notImplemented();
-}
-
-static void gtkStyleSetCallback(GtkWidget* widget, GtkStyle* previous, RenderTheme* renderTheme)
-{
- // FIXME: Make sure this function doesn't get called many times for a single GTK+ style change signal.
- renderTheme->platformColorsDidChange();
-}
-
-GtkContainer* RenderThemeGtk::gtkContainer() const
-{
- if (m_gtkContainer)
- return m_gtkContainer;
-
- m_gtkWindow = gtk_window_new(GTK_WINDOW_POPUP);
- m_gtkContainer = GTK_CONTAINER(gtk_fixed_new());
- gtk_container_add(GTK_CONTAINER(m_gtkWindow), GTK_WIDGET(m_gtkContainer));
- gtk_widget_realize(m_gtkWindow);
-
- return m_gtkContainer;
-}
-
-GtkWidget* RenderThemeGtk::gtkEntry() const
-{
- if (m_gtkEntry)
- return m_gtkEntry;
-
- m_gtkEntry = gtk_entry_new();
- g_signal_connect(m_gtkEntry, "style-set", G_CALLBACK(gtkStyleSetCallback), theme());
- gtk_container_add(gtkContainer(), m_gtkEntry);
- gtk_widget_realize(m_gtkEntry);
-
- return m_gtkEntry;
-}
-
-GtkWidget* RenderThemeGtk::gtkTreeView() const
-{
- if (m_gtkTreeView)
- return m_gtkTreeView;
-
- m_gtkTreeView = gtk_tree_view_new();
- g_signal_connect(m_gtkTreeView, "style-set", G_CALLBACK(gtkStyleSetCallback), theme());
- gtk_container_add(gtkContainer(), m_gtkTreeView);
- gtk_widget_realize(m_gtkTreeView);
-
- return m_gtkTreeView;
-}
-
-}
diff --git a/WebCore/platform/gtk/RenderThemeGtk.h b/WebCore/platform/gtk/RenderThemeGtk.h
deleted file mode 100644
index dda8bc8..0000000
--- a/WebCore/platform/gtk/RenderThemeGtk.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * This file is part of the WebKit project.
- *
- * Copyright (C) 2006 Apple Computer, Inc.
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
- * Copyright (C) 2007 Holger Hans Peter Freyther
- * Copyright (C) 2007 Alp Toker <alp@atoker.com>
- * All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef RenderThemeGdk_h
-#define RenderThemeGdk_h
-
-#include "RenderTheme.h"
-
-#include <gtk/gtk.h>
-
-namespace WebCore {
-
-class RenderThemeGtk : public RenderTheme {
-public:
- RenderThemeGtk();
-
- // A method asking if the theme's controls actually care about redrawing when hovered.
- virtual bool supportsHover(const RenderStyle* style) const { return true; }
-
- // A method asking if the theme is able to draw the focus ring.
- virtual bool supportsFocusRing(const RenderStyle*) const;
-
- // A method asking if the control changes its tint when the window has focus or not.
- virtual bool controlSupportsTints(const RenderObject*) const;
-
- // A general method asking if any control tinting is supported at all.
- virtual bool supportsControlTints() const { return true; }
-
- // A method to obtain the baseline position for a "leaf" control. This will only be used if a baseline
- // position cannot be determined by examining child content. Checkboxes and radio buttons are examples of
- // controls that need to do this.
- virtual int baselinePosition(const RenderObject*) const;
-
- // The platform selection color.
- virtual Color platformActiveSelectionBackgroundColor() const;
- virtual Color platformInactiveSelectionBackgroundColor() const;
- virtual Color platformActiveSelectionForegroundColor() const;
- virtual Color platformInactiveSelectionForegroundColor() const;
-
- // List Box selection color
- virtual Color activeListBoxSelectionBackgroundColor() const;
- virtual Color activeListBoxSelectionForegroundColor() const;
- virtual Color inactiveListBoxSelectionBackgroundColor() const;
- virtual Color inactiveListBoxSelectionForegroundColor() const;
-
- virtual double caretBlinkFrequency() const;
-
- // System fonts.
- virtual void systemFont(int propId, FontDescription&) const;
-
-protected:
- virtual bool paintCheckbox(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r);
- virtual void setCheckboxSize(RenderStyle* style) const;
-
- virtual bool paintRadio(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r);
- virtual void setRadioSize(RenderStyle* style) const;
-
- virtual void adjustButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
- virtual bool paintButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
-
- virtual void adjustTextFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
- virtual bool paintTextField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
-
- virtual void adjustTextAreaStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
- virtual bool paintTextArea(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
-
- virtual void adjustMenuListStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
- virtual bool paintMenuList(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
-
- virtual void adjustSearchFieldResultsDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
- virtual bool paintSearchFieldResultsDecoration(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
-
- virtual void adjustSearchFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
- virtual bool paintSearchField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
-
- virtual void adjustSearchFieldResultsButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
- virtual bool paintSearchFieldResultsButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
-
- virtual void adjustSearchFieldCancelButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
- virtual bool paintSearchFieldCancelButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
-
-
-private:
- /*
- * hold the state
- */
- GtkWidget* gtkEntry() const;
- GtkWidget* gtkTreeView() const;
-
- /*
- * unmapped GdkWindow having a container. This is holding all
- * our fake widgets
- */
- GtkContainer* gtkContainer() const;
-
-private:
- mutable GtkWidget* m_gtkWindow;
- mutable GtkContainer* m_gtkContainer;
- mutable GtkWidget* m_gtkEntry;
- mutable GtkWidget* m_gtkTreeView;
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/gtk/ScrollViewGtk.cpp b/WebCore/platform/gtk/ScrollViewGtk.cpp
deleted file mode 100644
index e1316ee..0000000
--- a/WebCore/platform/gtk/ScrollViewGtk.cpp
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
- * Copyright (C) 2007 Holger Hans Peter Freyther
- * Copyright (C) 2008 Collabora Ltd.
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ScrollView.h"
-
-#include "FloatRect.h"
-#include "GraphicsContext.h"
-#include "HostWindow.h"
-#include "IntRect.h"
-#include "NotImplemented.h"
-#include "PlatformMouseEvent.h"
-#include "PlatformWheelEvent.h"
-#include "ScrollbarGtk.h"
-#include "ScrollbarTheme.h"
-
-#include <gtk/gtk.h>
-
-using namespace std;
-
-namespace WebCore {
-
-static void adjustmentChanged(GtkAdjustment* adjustment, gpointer _that)
-{
- ScrollView* that = reinterpret_cast<ScrollView*>(_that);
-
- // Figure out if we really moved.
- IntSize newOffset = that->scrollOffset();
- if (adjustment == that->m_horizontalAdjustment)
- newOffset.setWidth(static_cast<int>(gtk_adjustment_get_value(adjustment)));
- else if (adjustment == that->m_verticalAdjustment)
- newOffset.setHeight(static_cast<int>(gtk_adjustment_get_value(adjustment)));
-
- IntSize scrollDelta = newOffset - that->scrollOffset();
- if (scrollDelta == IntSize())
- return;
- that->setScrollOffset(newOffset);
-
- if (that->scrollbarsSuppressed())
- return;
-
- that->scrollContents(scrollDelta);
-}
-
-void ScrollView::platformInit()
-{
- m_horizontalAdjustment = 0;
- m_verticalAdjustment = 0;
-}
-
-void ScrollView::platformDestroy()
-{
- if (m_horizontalAdjustment) {
- g_signal_handlers_disconnect_by_func(G_OBJECT(m_horizontalAdjustment), (gpointer)adjustmentChanged, this);
- g_object_unref(m_horizontalAdjustment);
- }
-
- if (m_verticalAdjustment) {
- g_signal_handlers_disconnect_by_func(G_OBJECT(m_verticalAdjustment), (gpointer)adjustmentChanged, this);
- g_object_unref(m_verticalAdjustment);
- }
-}
-
-/*
- * The following is assumed:
- * (hadj && vadj) || (!hadj && !vadj)
- */
-void ScrollView::setGtkAdjustments(GtkAdjustment* hadj, GtkAdjustment* vadj)
-{
- ASSERT(!hadj == !vadj);
-
- if (m_horizontalAdjustment) {
- g_signal_handlers_disconnect_by_func(G_OBJECT(m_horizontalAdjustment), (gpointer)adjustmentChanged, this);
- g_signal_handlers_disconnect_by_func(G_OBJECT(m_verticalAdjustment), (gpointer)adjustmentChanged, this);
- g_object_unref(m_horizontalAdjustment);
- g_object_unref(m_verticalAdjustment);
- }
-
- m_horizontalAdjustment = hadj;
- m_verticalAdjustment = vadj;
-
- if (m_horizontalAdjustment) {
- g_signal_connect(m_horizontalAdjustment, "value-changed", G_CALLBACK(adjustmentChanged), this);
- g_signal_connect(m_verticalAdjustment, "value-changed", G_CALLBACK(adjustmentChanged), this);
-
- /*
- * disable the scrollbars (if we have any) as the GtkAdjustment over
- */
- setHasVerticalScrollbar(false);
- setHasHorizontalScrollbar(false);
-
- g_object_ref(m_horizontalAdjustment);
- g_object_ref(m_verticalAdjustment);
- }
-
- updateScrollbars(m_scrollOffset);
-}
-
-void ScrollView::platformAddChild(Widget* child)
-{
- if (!GTK_IS_SOCKET(child->platformWidget()))
- gtk_container_add(GTK_CONTAINER(hostWindow()->platformWindow()), child->platformWidget());
-}
-
-void ScrollView::platformRemoveChild(Widget* child)
-{
- GtkWidget* parent;
-
- // HostWindow can be NULL here. If that's the case
- // let's grab the child's parent instead.
- if (hostWindow())
- parent = GTK_WIDGET(hostWindow()->platformWindow());
- else
- parent = GTK_WIDGET(child->platformWidget()->parent);
-
- if (GTK_IS_CONTAINER(parent) && parent == child->platformWidget()->parent)
- gtk_container_remove(GTK_CONTAINER(parent), child->platformWidget());
-}
-
-bool ScrollView::platformHandleHorizontalAdjustment(const IntSize& scroll)
-{
- if (m_horizontalAdjustment) {
- m_horizontalAdjustment->page_size = visibleWidth();
- m_horizontalAdjustment->step_increment = visibleWidth() / 10.0;
- m_horizontalAdjustment->page_increment = visibleWidth() * 0.9;
- m_horizontalAdjustment->lower = 0;
- m_horizontalAdjustment->upper = contentsWidth();
- gtk_adjustment_changed(m_horizontalAdjustment);
-
- if (m_scrollOffset.width() != scroll.width()) {
- m_horizontalAdjustment->value = scroll.width();
- gtk_adjustment_value_changed(m_horizontalAdjustment);
- }
- return true;
- }
- return false;
-}
-
-bool ScrollView::platformHandleVerticalAdjustment(const IntSize& scroll)
-{
- if (m_verticalAdjustment) {
- m_verticalAdjustment->page_size = visibleHeight();
- m_verticalAdjustment->step_increment = visibleHeight() / 10.0;
- m_verticalAdjustment->page_increment = visibleHeight() * 0.9;
- m_verticalAdjustment->lower = 0;
- m_verticalAdjustment->upper = contentsHeight();
- gtk_adjustment_changed(m_verticalAdjustment);
-
- if (m_scrollOffset.height() != scroll.height()) {
- m_verticalAdjustment->value = scroll.height();
- gtk_adjustment_value_changed(m_verticalAdjustment);
- }
- return true;
- }
- return false;
-}
-
-bool ScrollView::platformHasHorizontalAdjustment() const
-{
- return m_horizontalAdjustment != 0;
-}
-
-bool ScrollView::platformHasVerticalAdjustment() const
-{
- return m_verticalAdjustment != 0;
-}
-
-}
diff --git a/WebCore/platform/gtk/ScrollbarGtk.cpp b/WebCore/platform/gtk/ScrollbarGtk.cpp
deleted file mode 100644
index 099895d..0000000
--- a/WebCore/platform/gtk/ScrollbarGtk.cpp
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Copyright (C) 2007 Holger Hans Peter Freyther zecke@selfish.org
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "config.h"
-#include "ScrollbarGtk.h"
-
-#include "IntRect.h"
-#include "GraphicsContext.h"
-#include "FrameView.h"
-#include "NotImplemented.h"
-#include "ScrollbarTheme.h"
-#include "gtkdrawing.h"
-
-#include <gtk/gtk.h>
-
-using namespace WebCore;
-
-PassRefPtr<Scrollbar> Scrollbar::createNativeScrollbar(ScrollbarClient* client, ScrollbarOrientation orientation, ScrollbarControlSize size)
-{
- return adoptRef(new ScrollbarGtk(client, orientation, size));
-}
-
-static gboolean gtkScrollEventCallback(GtkWidget* widget, GdkEventScroll* event, ScrollbarGtk*)
-{
- /* Scroll only if our parent rejects the scroll event. The rationale for
- * this is that we want the main frame to scroll when we move the mouse
- * wheel over a child scrollbar in most cases. */
- return gtk_widget_event(gtk_widget_get_parent(widget), reinterpret_cast<GdkEvent*>(event));
-}
-
-ScrollbarGtk::ScrollbarGtk(ScrollbarClient* client, ScrollbarOrientation orientation,
- ScrollbarControlSize controlSize)
- : Scrollbar(client, orientation, controlSize)
- , m_adjustment(GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0)))
-{
- GtkScrollbar* scrollBar = orientation == HorizontalScrollbar ?
- GTK_SCROLLBAR(::gtk_hscrollbar_new(m_adjustment)) :
- GTK_SCROLLBAR(::gtk_vscrollbar_new(m_adjustment));
- gtk_widget_show(GTK_WIDGET(scrollBar));
- g_object_ref(G_OBJECT(scrollBar));
- g_signal_connect(G_OBJECT(scrollBar), "value-changed", G_CALLBACK(ScrollbarGtk::gtkValueChanged), this);
- g_signal_connect(G_OBJECT(scrollBar), "scroll-event", G_CALLBACK(gtkScrollEventCallback), this);
-
- setPlatformWidget(GTK_WIDGET(scrollBar));
-
- /*
- * assign a sane default width and height to the Scrollbar, otherwise
- * we will end up with a 0 width scrollbar.
- */
- resize(ScrollbarTheme::nativeTheme()->scrollbarThickness(),
- ScrollbarTheme::nativeTheme()->scrollbarThickness());
-}
-
-ScrollbarGtk::~ScrollbarGtk()
-{
- /*
- * the Widget does not take over ownership.
- */
- g_signal_handlers_disconnect_by_func(G_OBJECT(platformWidget()), (gpointer)ScrollbarGtk::gtkValueChanged, this);
- g_signal_handlers_disconnect_by_func(G_OBJECT(platformWidget()), (gpointer)gtkScrollEventCallback, this);
- g_object_unref(G_OBJECT(platformWidget()));
-}
-
-void ScrollbarGtk::frameRectsChanged() const
-{
- if (!parent() || !parent()->isScrollViewScrollbar(this))
- return;
-
- IntPoint loc = parent()->convertToContainingWindow(frameRect().location());
-
- // Don't allow the allocation size to be negative
- IntSize sz = frameRect().size();
- sz.clampNegativeToZero();
-
- GtkAllocation allocation = { loc.x(), loc.y(), sz.width(), sz.height() };
- gtk_widget_size_allocate(platformWidget(), &allocation);
-}
-
-void ScrollbarGtk::updateThumbPosition()
-{
- if (m_adjustment->value != m_currentPos) {
- m_adjustment->value = m_currentPos;
- gtk_adjustment_value_changed(m_adjustment);
- }
-}
-
-void ScrollbarGtk::updateThumbProportion()
-{
- m_adjustment->step_increment = m_lineStep;
- m_adjustment->page_increment = m_pageStep;
- m_adjustment->page_size = m_visibleSize;
- m_adjustment->upper = m_totalSize;
- gtk_adjustment_changed(m_adjustment);
-}
-
-void ScrollbarGtk::setFrameRect(const IntRect& rect)
-{
- Widget::setFrameRect(rect);
- frameRectsChanged();
-}
-
-void ScrollbarGtk::frameRectsChanged()
-{
- if (!parent())
- return;
-
- ASSERT(parent()->isFrameView());
-
- FrameView* frameView = static_cast<FrameView*>(parent());
- IntRect windowRect = IntRect(frameView->contentsToWindow(frameRect().location()), frameRect().size());
-
- IntSize sz = frameRect().size();
- sz.clampNegativeToZero();
-
- GtkAllocation allocation = { windowRect.x(), windowRect.y(), sz.width(), sz.height() };
- gtk_widget_size_allocate(platformWidget(), &allocation);
-}
-
-void ScrollbarGtk::gtkValueChanged(GtkAdjustment*, ScrollbarGtk* that)
-{
- that->setValue(static_cast<int>(gtk_adjustment_get_value(that->m_adjustment)));
-}
-
-void ScrollbarGtk::setEnabled(bool shouldEnable)
-{
- if (enabled() == shouldEnable)
- return;
-
- Scrollbar::setEnabled(shouldEnable);
- if (platformWidget())
- gtk_widget_set_sensitive(platformWidget(), shouldEnable);
-}
-
-
-
diff --git a/WebCore/platform/gtk/ScrollbarGtk.h b/WebCore/platform/gtk/ScrollbarGtk.h
deleted file mode 100644
index 50e9184..0000000
--- a/WebCore/platform/gtk/ScrollbarGtk.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ScrollbarGtk_h
-#define ScrollbarGtk_h
-
-#include "Scrollbar.h"
-#include <wtf/PassRefPtr.h>
-
-typedef struct _GtkAdjustment GtkAdjustment;
-
-namespace WebCore {
-
-class ScrollbarGtk : public Scrollbar {
-public:
- friend class Scrollbar;
-
- virtual ~ScrollbarGtk();
-
- virtual void setFrameRect(const IntRect&);
-
- virtual bool handleMouseMoveEvent(const PlatformMouseEvent&) { return false; }
- virtual bool handleMouseOutEvent(const PlatformMouseEvent&) { return false; }
- virtual bool handleMousePressEvent(const PlatformMouseEvent&) { return false; }
- virtual bool handleMouseReleaseEvent(const PlatformMouseEvent&) { return false; }
-
- virtual void setEnabled(bool);
-
- virtual void frameRectsChanged() const;
-
-protected:
- ScrollbarGtk(ScrollbarClient*, ScrollbarOrientation, ScrollbarControlSize);
-
- virtual void updateThumbPosition();
- virtual void updateThumbProportion();
- virtual void frameRectsChanged();
-
-private:
- static void gtkValueChanged(GtkAdjustment*, ScrollbarGtk*);
- GtkAdjustment* m_adjustment;
-};
-
-}
-
-#endif // ScrollbarGtk_h
diff --git a/WebCore/platform/gtk/ScrollbarThemeGtk.cpp b/WebCore/platform/gtk/ScrollbarThemeGtk.cpp
deleted file mode 100644
index fee2c70..0000000
--- a/WebCore/platform/gtk/ScrollbarThemeGtk.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ScrollbarThemeGtk.h"
-
-#include "gtkdrawing.h"
-#include <gtk/gtk.h>
-
-namespace WebCore {
-
-ScrollbarTheme* ScrollbarTheme::nativeTheme()
-{
- static ScrollbarThemeGtk theme;
- return &theme;
-}
-
-ScrollbarThemeGtk::~ScrollbarThemeGtk()
-{
-}
-
-int ScrollbarThemeGtk::scrollbarThickness(ScrollbarControlSize controlSize)
-{
- static int size;
- if (!size) {
- MozGtkScrollbarMetrics metrics;
- moz_gtk_get_scrollbar_metrics(&metrics);
- size = metrics.slider_width;
- }
- return size;
-}
-
-}
-
diff --git a/WebCore/platform/gtk/ScrollbarThemeGtk.h b/WebCore/platform/gtk/ScrollbarThemeGtk.h
deleted file mode 100644
index 21ccb43..0000000
--- a/WebCore/platform/gtk/ScrollbarThemeGtk.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ScrollbarThemeGtk_h
-#define ScrollbarThemeGtk_h
-
-#include "ScrollbarTheme.h"
-
-namespace WebCore {
-
-class ScrollbarThemeGtk : public ScrollbarTheme {
-public:
- virtual ~ScrollbarThemeGtk();
-
- virtual int scrollbarThickness(ScrollbarControlSize = RegularScrollbar);
-};
-
-}
-#endif
diff --git a/WebCore/platform/gtk/SearchPopupMenuGtk.cpp b/WebCore/platform/gtk/SearchPopupMenuGtk.cpp
deleted file mode 100644
index fbaa527..0000000
--- a/WebCore/platform/gtk/SearchPopupMenuGtk.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "config.h"
-#include "SearchPopupMenu.h"
-
-#include "NotImplemented.h"
-
-namespace WebCore {
-
-SearchPopupMenu::SearchPopupMenu(PopupMenuClient* client)
- : PopupMenu(client)
-{
- notImplemented();
-}
-
-void SearchPopupMenu::saveRecentSearches(const AtomicString&, const Vector<String>&)
-{
- notImplemented();
-}
-
-void SearchPopupMenu::loadRecentSearches(const AtomicString&, Vector<String>&)
-{
- notImplemented();
-}
-
-bool SearchPopupMenu::enabled()
-{
- notImplemented();
- return false;
-}
-
-}
diff --git a/WebCore/platform/gtk/SharedBufferGtk.cpp b/WebCore/platform/gtk/SharedBufferGtk.cpp
deleted file mode 100644
index 783fec6..0000000
--- a/WebCore/platform/gtk/SharedBufferGtk.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "config.h"
-#include "SharedBuffer.h"
-
-#include "CString.h"
-#include "FileSystem.h"
-
-#include <glib.h>
-
-
-namespace WebCore {
-
-PassRefPtr<SharedBuffer> SharedBuffer::createWithContentsOfFile(const String& filePath)
-{
- if (filePath.isEmpty())
- return 0;
-
- gchar* filename = filenameFromString(filePath);
- gchar* contents;
- gsize size;
- GError* error = 0;
- if (!g_file_get_contents(filename, &contents, &size, &error)) {
- LOG_ERROR("Failed to fully read contents of file %s - %s", filenameForDisplay(filePath).utf8().data(), error->message);
- g_error_free(error);
- g_free(filename);
- return 0;
- }
-
- RefPtr<SharedBuffer> result = SharedBuffer::create(contents, size);
- g_free(filename);
- g_free(contents);
-
- return result.release();
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/gtk/SharedTimerGtk.cpp b/WebCore/platform/gtk/SharedTimerGtk.cpp
deleted file mode 100644
index e0a5b60..0000000
--- a/WebCore/platform/gtk/SharedTimerGtk.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "SharedTimer.h"
-
-#include "SystemTime.h"
-#include <wtf/Assertions.h>
-#include <glib.h>
-
-namespace WebCore {
-
-static guint sharedTimer;
-static void (*sharedTimerFiredFunction)();
-
-void setSharedTimerFiredFunction(void (*f)())
-{
- sharedTimerFiredFunction = f;
-}
-
-static gboolean timeout_cb(gpointer)
-{
- if (sharedTimerFiredFunction)
- sharedTimerFiredFunction();
- return FALSE;
-}
-
-void setSharedTimerFireTime(double fireTime)
-{
- ASSERT(sharedTimerFiredFunction);
-
- double interval = fireTime - currentTime();
- guint intervalInMS;
- if (interval < 0)
- intervalInMS = 0;
- else {
- interval *= 1000;
- intervalInMS = (guint)interval;
- }
-
- stopSharedTimer();
- if (intervalInMS == 0)
- sharedTimer = g_idle_add(timeout_cb, NULL);
- else
- sharedTimer = g_timeout_add_full(G_PRIORITY_DEFAULT, intervalInMS, timeout_cb, NULL, NULL);
-}
-
-void stopSharedTimer()
-{
- gboolean s = FALSE;
- if (sharedTimer == 0)
- return;
-
- s = g_source_remove(sharedTimer);
- ASSERT(s);
- sharedTimer = 0;
-}
-
-}
diff --git a/WebCore/platform/gtk/SoundGtk.cpp b/WebCore/platform/gtk/SoundGtk.cpp
deleted file mode 100644
index 2f7316c..0000000
--- a/WebCore/platform/gtk/SoundGtk.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2007 Alp Toker <alp@atoker.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-
-#include "Sound.h"
-
-#include <gdk/gdk.h>
-
-namespace WebCore {
-
-void systemBeep()
-{
- gdk_beep();
-}
-
-}
-
-// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/gtk/SystemTimeGtk.cpp b/WebCore/platform/gtk/SystemTimeGtk.cpp
deleted file mode 100644
index 9d26d41..0000000
--- a/WebCore/platform/gtk/SystemTimeGtk.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2007 Alp Toker <alp@atoker.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-#include <glib.h>
-
-namespace WebCore {
-
-double currentTime()
-{
- GTimeVal now;
- g_get_current_time(&now);
- return static_cast<double>(now.tv_sec) + static_cast<double>(now.tv_usec / 1000000.0);
-}
-
-}
diff --git a/WebCore/platform/gtk/SystemTimeLinux.cpp b/WebCore/platform/gtk/SystemTimeLinux.cpp
deleted file mode 100644
index 45caddd..0000000
--- a/WebCore/platform/gtk/SystemTimeLinux.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "SystemTime.h"
-
-#include <sys/time.h>
-
-namespace WebCore {
-
-double currentTime()
-{
- struct timeval aTimeval;
- struct timezone aTimezone;
-
- gettimeofday( &aTimeval, &aTimezone );
- return (double)aTimeval.tv_sec + (double)(aTimeval.tv_usec / 1000000.0 );
-}
-
-}
diff --git a/WebCore/platform/gtk/TemporaryLinkStubs.cpp b/WebCore/platform/gtk/TemporaryLinkStubs.cpp
deleted file mode 100644
index 5093794..0000000
--- a/WebCore/platform/gtk/TemporaryLinkStubs.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "AXObjectCache.h"
-#include "DNS.h"
-#include "Editor.h"
-#include "FrameView.h"
-#include "FTPDirectoryDocument.h"
-#include "NotImplemented.h"
-#include "PluginView.h"
-#include <float.h>
-
-using namespace WebCore;
-
-// This function loads resources from WebKit
-// This does not belong here and I'm not sure where
-// it should go
-// I don't know what the plans or design is
-// for none code resources
-Vector<char> loadResourceIntoArray(const char* resourceName)
-{
- Vector<char> resource;
- //if (strcmp(resourceName,"missingImage") == 0) {
- //}
- return resource;
-}
-
-
-/********************************************************/
-/* Completely empty stubs (mostly to allow DRT to run): */
-/********************************************************/
-
-void PluginView::invalidateRegion(NPRegion) { notImplemented(); }
-
-Color WebCore::focusRingColor() { return Color(); }
-
-namespace WebCore {
-void getSupportedKeySizes(Vector<String>&) { notImplemented(); }
-String signedPublicKeyAndChallengeString(unsigned keySizeIndex, const String &challengeString, const KURL &url) { return String(); }
-float userIdleTime() { notImplemented(); return FLT_MAX; } // return an arbitrarily high userIdleTime so that releasing pages from the page cache isn't postponed
-
-}
diff --git a/WebCore/platform/gtk/WheelEventGtk.cpp b/WebCore/platform/gtk/WheelEventGtk.cpp
deleted file mode 100644
index fbe31f7..0000000
--- a/WebCore/platform/gtk/WheelEventGtk.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "PlatformWheelEvent.h"
-
-#include <gdk/gdk.h>
-#include <gtk/gtkversion.h>
-
-namespace WebCore {
-
-// Keep this in sync with the other platform event constructors
-PlatformWheelEvent::PlatformWheelEvent(GdkEventScroll* event)
-{
- static const float delta = 1;
-
- m_deltaX = 0;
- m_deltaY = 0;
-
- // Docs say an upwards scroll (away from the user) has a positive delta
- switch (event->direction) {
- case GDK_SCROLL_UP:
- m_deltaY = delta;
- break;
- case GDK_SCROLL_DOWN:
- m_deltaY = -delta;
- break;
- case GDK_SCROLL_LEFT:
- m_deltaX = -delta;
- break;
- case GDK_SCROLL_RIGHT:
- m_deltaX = delta;
- break;
- }
-
- m_position = IntPoint((int)event->x, (int)event->y);
- m_globalPosition = IntPoint((int)event->x_root, (int)event->y_root);
- m_granularity = ScrollByLineWheelEvent;
- m_isAccepted = false;
- m_shiftKey = event->state & GDK_SHIFT_MASK;
- m_ctrlKey = event->state & GDK_CONTROL_MASK;
- m_altKey = event->state & GDK_MOD1_MASK;
-#if GTK_CHECK_VERSION(2,10,0)
- m_metaKey = event->state & GDK_META_MASK;
-#else
- // GDK_MOD2_MASK doesn't always mean meta so we can't use it
- m_metaKey = false;
-#endif
-
- // FIXME: retrieve the user setting for the number of lines to scroll on each wheel event
- m_deltaX *= horizontalLineMultiplier();
- m_deltaY *= verticalLineMultiplier();
-}
-
-}
diff --git a/WebCore/platform/gtk/WidgetGtk.cpp b/WebCore/platform/gtk/WidgetGtk.cpp
deleted file mode 100644
index 82fed74..0000000
--- a/WebCore/platform/gtk/WidgetGtk.cpp
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
- * Copyright (C) 2007 Holger Hans Peter Freyther
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Widget.h"
-
-#include "Cursor.h"
-#include "FrameView.h"
-#include "GraphicsContext.h"
-#include "HostWindow.h"
-#include "IntRect.h"
-#include "NotImplemented.h"
-#include "RenderObject.h"
-
-#include <gdk/gdk.h>
-#include <gtk/gtk.h>
-
-namespace WebCore {
-
-class WidgetPrivate {
-public:
- GdkCursor* cursor;
-};
-
-Widget::Widget(PlatformWidget widget)
- : m_data(new WidgetPrivate)
-{
- init(widget);
- m_data->cursor = 0;
-}
-
-Widget::~Widget()
-{
- ASSERT(!parent());
- releasePlatformWidget();
- delete m_data;
-}
-
-void Widget::setFocus()
-{
- gtk_widget_grab_focus(platformWidget() ? platformWidget() : GTK_WIDGET(root()->hostWindow()->platformWindow()));
-}
-
-Cursor Widget::cursor()
-{
- return Cursor(m_data->cursor);
-}
-
-static GdkDrawable* gdkDrawable(PlatformWidget widget)
-{
- return widget ? widget->window : 0;
-}
-
-void Widget::setCursor(const Cursor& cursor)
-{
- GdkCursor* pcur = cursor.impl();
-
- // http://bugs.webkit.org/show_bug.cgi?id=16388
- // [GTK] Widget::setCursor() gets called frequently
- //
- // gdk_window_set_cursor() in certain GDK backends seems to be an
- // expensive operation, so avoid it if possible.
-
- if (pcur == m_data->cursor)
- return;
-
- gdk_window_set_cursor(gdkDrawable(platformWidget()) ? GDK_WINDOW(gdkDrawable(platformWidget())) : GTK_WIDGET(root()->hostWindow()->platformWindow())->window, pcur);
- m_data->cursor = pcur;
-}
-
-void Widget::show()
-{
- if (!platformWidget())
- return;
- gtk_widget_show(platformWidget());
-}
-
-void Widget::hide()
-{
- if (!platformWidget())
- return;
- gtk_widget_hide(platformWidget());
-}
-
-/*
- * Strategy to painting a Widget:
- * 1.) do not paint if there is no GtkWidget set
- * 2.) We assume that GTK_NO_WINDOW is set and that frameRectsChanged positioned
- * the widget correctly. ATM we do not honor the GraphicsContext translation.
- */
-void Widget::paint(GraphicsContext* context, const IntRect&)
-{
- if (!platformWidget())
- return;
-
- if (!context->gdkExposeEvent())
- return;
-
- GtkWidget* widget = platformWidget();
- ASSERT(GTK_WIDGET_NO_WINDOW(widget));
-
- GdkEvent* event = gdk_event_new(GDK_EXPOSE);
- event->expose = *context->gdkExposeEvent();
- event->expose.region = gtk_widget_region_intersect(widget, event->expose.region);
-
- /*
- * This will be unref'ed by gdk_event_free.
- */
- g_object_ref(event->expose.window);
-
- /*
- * If we are going to paint do the translation and GtkAllocation manipulation.
- */
- if (!gdk_region_empty(event->expose.region)) {
- gdk_region_get_clipbox(event->expose.region, &event->expose.area);
- gtk_widget_send_expose(widget, event);
- }
-
- gdk_event_free(event);
-}
-
-void Widget::setIsSelected(bool)
-{
- notImplemented();
-}
-
-IntRect Widget::frameRect() const
-{
- return m_frame;
-}
-
-void Widget::setFrameRect(const IntRect& rect)
-{
- m_frame = rect;
-}
-
-void Widget::releasePlatformWidget()
-{
- if (!platformWidget())
- return;
- g_object_unref(platformWidget());
-}
-
-void Widget::retainPlatformWidget()
-{
- if (!platformWidget())
- return;
-#if GLIB_CHECK_VERSION(2,10,0)
- g_object_ref_sink(platformWidget());
-#else
- g_object_ref(platformWidget());
- gtk_object_sink(GTK_OBJECT(platformWidget()));
-#endif
-}
-
-}
diff --git a/WebCore/platform/gtk/gtk2drawing.c b/WebCore/platform/gtk/gtk2drawing.c
deleted file mode 100644
index 83b4cb4..0000000
--- a/WebCore/platform/gtk/gtk2drawing.c
+++ /dev/null
@@ -1,3311 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Brian Ryner <bryner@brianryner.com> (Original Author)
- * Pierre Chanial <p_ch@verizon.net>
- * Michael Ventnor <m.ventnor@gmail.com>
- * Alp Toker <alp@nuanti.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-/*
- * This file contains painting functions for each of the gtk2 widgets.
- * Adapted from the gtkdrawing.c, and gtk+2.0 source.
- */
-
-#include <gtk/gtk.h>
-#include <gdk/gdkprivate.h>
-#include <string.h>
-#include "gtkdrawing.h"
-
-#include <math.h>
-
-#define XTHICKNESS(style) (style->xthickness)
-#define YTHICKNESS(style) (style->ythickness)
-#define WINDOW_IS_MAPPED(window) ((window) && GDK_IS_WINDOW(window) && gdk_window_is_visible(window))
-
-static GtkWidget* gProtoWindow;
-static GtkWidget* gButtonWidget;
-static GtkWidget* gToggleButtonWidget;
-static GtkWidget* gButtonArrowWidget;
-static GtkWidget* gCheckboxWidget;
-static GtkWidget* gRadiobuttonWidget;
-static GtkWidget* gHorizScrollbarWidget;
-static GtkWidget* gVertScrollbarWidget;
-static GtkWidget* gSpinWidget;
-static GtkWidget* gHScaleWidget;
-static GtkWidget* gVScaleWidget;
-static GtkWidget* gEntryWidget;
-static GtkWidget* gComboBoxWidget;
-static GtkWidget* gComboBoxButtonWidget;
-static GtkWidget* gComboBoxArrowWidget;
-static GtkWidget* gComboBoxSeparatorWidget;
-static GtkWidget* gComboBoxEntryWidget;
-static GtkWidget* gComboBoxEntryTextareaWidget;
-static GtkWidget* gComboBoxEntryButtonWidget;
-static GtkWidget* gComboBoxEntryArrowWidget;
-static GtkWidget* gHandleBoxWidget;
-static GtkWidget* gToolbarWidget;
-static GtkWidget* gFrameWidget;
-static GtkWidget* gStatusbarWidget;
-static GtkWidget* gProgressWidget;
-static GtkWidget* gTabWidget;
-static GtkWidget* gTooltipWidget;
-static GtkWidget* gMenuBarWidget;
-static GtkWidget* gMenuBarItemWidget;
-static GtkWidget* gMenuPopupWidget;
-static GtkWidget* gMenuItemWidget;
-static GtkWidget* gImageMenuItemWidget;
-static GtkWidget* gCheckMenuItemWidget;
-static GtkWidget* gTreeViewWidget;
-static GtkWidget* gMiddleTreeViewColumn;
-static GtkWidget* gTreeHeaderCellWidget;
-static GtkWidget* gTreeHeaderSortArrowWidget;
-static GtkWidget* gExpanderWidget;
-static GtkWidget* gToolbarSeparatorWidget;
-static GtkWidget* gMenuSeparatorWidget;
-static GtkWidget* gHPanedWidget;
-static GtkWidget* gVPanedWidget;
-static GtkWidget* gScrolledWindowWidget;
-
-static style_prop_t style_prop_func;
-static gboolean have_arrow_scaling;
-static gboolean have_2_10;
-static gboolean is_initialized;
-
-/* Because we have such an unconventional way of drawing widgets, signal to the GTK theme engine
- that they are drawing for Mozilla instead of a conventional GTK app so they can do any specific
- things they may want to do. */
-static void
-moz_gtk_set_widget_name(GtkWidget* widget)
-{
- gtk_widget_set_name(widget, "MozillaGtkWidget");
-}
-
-gint
-moz_gtk_enable_style_props(style_prop_t styleGetProp)
-{
- style_prop_func = styleGetProp;
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_window_widget()
-{
- if (!gProtoWindow) {
- gProtoWindow = gtk_window_new(GTK_WINDOW_POPUP);
- gtk_widget_realize(gProtoWindow);
- moz_gtk_set_widget_name(gProtoWindow);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-setup_widget_prototype(GtkWidget* widget)
-{
- static GtkWidget* protoLayout;
- ensure_window_widget();
- if (!protoLayout) {
- protoLayout = gtk_fixed_new();
- gtk_container_add(GTK_CONTAINER(gProtoWindow), protoLayout);
- }
-
- gtk_container_add(GTK_CONTAINER(protoLayout), widget);
- gtk_widget_realize(widget);
- g_object_set_data(G_OBJECT(widget), "transparent-bg-hint", TRUE);
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_button_widget()
-{
- if (!gButtonWidget) {
- gButtonWidget = gtk_button_new_with_label("M");
- setup_widget_prototype(gButtonWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_hpaned_widget()
-{
- if (!gHPanedWidget) {
- gHPanedWidget = gtk_hpaned_new();
- setup_widget_prototype(gHPanedWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_vpaned_widget()
-{
- if (!gVPanedWidget) {
- gVPanedWidget = gtk_vpaned_new();
- setup_widget_prototype(gVPanedWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_toggle_button_widget()
-{
- if (!gToggleButtonWidget) {
- gToggleButtonWidget = gtk_toggle_button_new();
- setup_widget_prototype(gToggleButtonWidget);
- /* toggle button must be set active to get the right style on hover. */
- GTK_TOGGLE_BUTTON(gToggleButtonWidget)->active = TRUE;
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_button_arrow_widget()
-{
- if (!gButtonArrowWidget) {
- ensure_toggle_button_widget();
-
- gButtonArrowWidget = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_OUT);
- gtk_container_add(GTK_CONTAINER(gToggleButtonWidget), gButtonArrowWidget);
- gtk_widget_realize(gButtonArrowWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_checkbox_widget()
-{
- if (!gCheckboxWidget) {
- gCheckboxWidget = gtk_check_button_new_with_label("M");
- setup_widget_prototype(gCheckboxWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_radiobutton_widget()
-{
- if (!gRadiobuttonWidget) {
- gRadiobuttonWidget = gtk_radio_button_new_with_label(NULL, "M");
- setup_widget_prototype(gRadiobuttonWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_scrollbar_widget()
-{
- if (!gVertScrollbarWidget) {
- gVertScrollbarWidget = gtk_vscrollbar_new(NULL);
- setup_widget_prototype(gVertScrollbarWidget);
- }
- if (!gHorizScrollbarWidget) {
- gHorizScrollbarWidget = gtk_hscrollbar_new(NULL);
- setup_widget_prototype(gHorizScrollbarWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_spin_widget()
-{
- if (!gSpinWidget) {
- gSpinWidget = gtk_spin_button_new(NULL, 1, 0);
- setup_widget_prototype(gSpinWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_scale_widget()
-{
- if (!gHScaleWidget) {
- gHScaleWidget = gtk_hscale_new(NULL);
- setup_widget_prototype(gHScaleWidget);
- }
- if (!gVScaleWidget) {
- gVScaleWidget = gtk_vscale_new(NULL);
- setup_widget_prototype(gVScaleWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_entry_widget()
-{
- if (!gEntryWidget) {
- gEntryWidget = gtk_entry_new();
- setup_widget_prototype(gEntryWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-/* We need to have pointers to the inner widgets (button, separator, arrow)
- * of the ComboBox to get the correct rendering from theme engines which
- * special cases their look. Since the inner layout can change, we ask GTK
- * to NULL our pointers when they are about to become invalid because the
- * corresponding widgets don't exist anymore. It's the role of
- * g_object_add_weak_pointer().
- * Note that if we don't find the inner widgets (which shouldn't happen), we
- * fallback to use generic "non-inner" widgets, and they don't need that kind
- * of weak pointer since they are explicit children of gProtoWindow and as
- * such GTK holds a strong reference to them. */
-static void
-moz_gtk_get_combo_box_inner_button(GtkWidget *widget, gpointer client_data)
-{
- if (GTK_IS_TOGGLE_BUTTON(widget)) {
- gComboBoxButtonWidget = widget;
- g_object_add_weak_pointer(G_OBJECT(widget),
- (gpointer) &gComboBoxButtonWidget);
- gtk_widget_realize(widget);
- g_object_set_data(G_OBJECT(widget), "transparent-bg-hint", TRUE);
- }
-}
-
-static void
-moz_gtk_get_combo_box_button_inner_widgets(GtkWidget *widget,
- gpointer client_data)
-{
- if (GTK_IS_SEPARATOR(widget)) {
- gComboBoxSeparatorWidget = widget;
- g_object_add_weak_pointer(G_OBJECT(widget),
- (gpointer) &gComboBoxSeparatorWidget);
- } else if (GTK_IS_ARROW(widget)) {
- gComboBoxArrowWidget = widget;
- g_object_add_weak_pointer(G_OBJECT(widget),
- (gpointer) &gComboBoxArrowWidget);
- } else
- return;
- gtk_widget_realize(widget);
- g_object_set_data(G_OBJECT(widget), "transparent-bg-hint", TRUE);
-}
-
-static gint
-ensure_combo_box_widgets()
-{
- GtkWidget* buttonChild;
-
- if (gComboBoxButtonWidget && gComboBoxArrowWidget)
- return MOZ_GTK_SUCCESS;
-
- /* Create a ComboBox if needed */
- if (!gComboBoxWidget) {
- gComboBoxWidget = gtk_combo_box_new();
- setup_widget_prototype(gComboBoxWidget);
- }
-
- /* Get its inner Button */
- gtk_container_forall(GTK_CONTAINER(gComboBoxWidget),
- moz_gtk_get_combo_box_inner_button,
- NULL);
-
- if (gComboBoxButtonWidget) {
- /* Get the widgets inside the Button */
- buttonChild = GTK_BIN(gComboBoxButtonWidget)->child;
- if (GTK_IS_HBOX(buttonChild)) {
- /* appears-as-list = FALSE, cell-view = TRUE; the button
- * contains an hbox. This hbox is there because the ComboBox
- * needs to place a cell renderer, a separator, and an arrow in
- * the button when appears-as-list is FALSE. */
- gtk_container_forall(GTK_CONTAINER(buttonChild),
- moz_gtk_get_combo_box_button_inner_widgets,
- NULL);
- } else if(GTK_IS_ARROW(buttonChild)) {
- /* appears-as-list = TRUE, or cell-view = FALSE;
- * the button only contains an arrow */
- gComboBoxArrowWidget = buttonChild;
- g_object_add_weak_pointer(G_OBJECT(buttonChild), (gpointer)
- &gComboBoxArrowWidget);
- gtk_widget_realize(gComboBoxArrowWidget);
- g_object_set_data(G_OBJECT(gComboBoxArrowWidget),
- "transparent-bg-hint", TRUE);
- }
- } else {
- /* Shouldn't be reached with current internal gtk implementation; we
- * use a generic toggle button as last resort fallback to avoid
- * crashing. */
- ensure_toggle_button_widget();
- gComboBoxButtonWidget = gToggleButtonWidget;
- }
-
- if (!gComboBoxArrowWidget) {
- /* Shouldn't be reached with current internal gtk implementation;
- * we gButtonArrowWidget as last resort fallback to avoid
- * crashing. */
- ensure_button_arrow_widget();
- gComboBoxArrowWidget = gButtonArrowWidget;
- }
-
- /* We don't test the validity of gComboBoxSeparatorWidget since there
- * is none when "appears-as-list" = TRUE or "cell-view" = FALSE; if it
- * is invalid we just won't paint it. */
-
- return MOZ_GTK_SUCCESS;
-}
-
-/* We need to have pointers to the inner widgets (entry, button, arrow) of
- * the ComboBoxEntry to get the correct rendering from theme engines which
- * special cases their look. Since the inner layout can change, we ask GTK
- * to NULL our pointers when they are about to become invalid because the
- * corresponding widgets don't exist anymore. It's the role of
- * g_object_add_weak_pointer().
- * Note that if we don't find the inner widgets (which shouldn't happen), we
- * fallback to use generic "non-inner" widgets, and they don't need that kind
- * of weak pointer since they are explicit children of gProtoWindow and as
- * such GTK holds a strong reference to them. */
-static void
-moz_gtk_get_combo_box_entry_inner_widgets(GtkWidget *widget,
- gpointer client_data)
-{
- if (GTK_IS_TOGGLE_BUTTON(widget)) {
- gComboBoxEntryButtonWidget = widget;
- g_object_add_weak_pointer(G_OBJECT(widget),
- (gpointer) &gComboBoxEntryButtonWidget);
- } else if (GTK_IS_ENTRY(widget)) {
- gComboBoxEntryTextareaWidget = widget;
- g_object_add_weak_pointer(G_OBJECT(widget),
- (gpointer) &gComboBoxEntryTextareaWidget);
- } else
- return;
- gtk_widget_realize(widget);
- g_object_set_data(G_OBJECT(widget), "transparent-bg-hint", TRUE);
-}
-
-static void
-moz_gtk_get_combo_box_entry_arrow(GtkWidget *widget, gpointer client_data)
-{
- if (GTK_IS_ARROW(widget)) {
- gComboBoxEntryArrowWidget = widget;
- g_object_add_weak_pointer(G_OBJECT(widget),
- (gpointer) &gComboBoxEntryArrowWidget);
- gtk_widget_realize(widget);
- g_object_set_data(G_OBJECT(widget), "transparent-bg-hint", TRUE);
- }
-}
-
-static gint
-ensure_combo_box_entry_widgets()
-{
- GtkWidget* buttonChild;
-
- if (gComboBoxEntryTextareaWidget &&
- gComboBoxEntryButtonWidget &&
- gComboBoxEntryArrowWidget)
- return MOZ_GTK_SUCCESS;
-
- /* Create a ComboBoxEntry if needed */
- if (!gComboBoxEntryWidget) {
- gComboBoxEntryWidget = gtk_combo_box_entry_new();
- setup_widget_prototype(gComboBoxEntryWidget);
- }
-
- /* Get its inner Entry and Button */
- gtk_container_forall(GTK_CONTAINER(gComboBoxEntryWidget),
- moz_gtk_get_combo_box_entry_inner_widgets,
- NULL);
-
- if (!gComboBoxEntryTextareaWidget) {
- ensure_entry_widget();
- gComboBoxEntryTextareaWidget = gEntryWidget;
- }
-
- if (gComboBoxEntryButtonWidget) {
- /* Get the Arrow inside the Button */
- buttonChild = GTK_BIN(gComboBoxEntryButtonWidget)->child;
- if (GTK_IS_HBOX(buttonChild)) {
- /* appears-as-list = FALSE, cell-view = TRUE; the button
- * contains an hbox. This hbox is there because ComboBoxEntry
- * inherits from ComboBox which needs to place a cell renderer,
- * a separator, and an arrow in the button when appears-as-list
- * is FALSE. Here the hbox should only contain an arrow, since
- * a ComboBoxEntry doesn't need all those widgets in the
- * button. */
- gtk_container_forall(GTK_CONTAINER(buttonChild),
- moz_gtk_get_combo_box_entry_arrow,
- NULL);
- } else if(GTK_IS_ARROW(buttonChild)) {
- /* appears-as-list = TRUE, or cell-view = FALSE;
- * the button only contains an arrow */
- gComboBoxEntryArrowWidget = buttonChild;
- g_object_add_weak_pointer(G_OBJECT(buttonChild), (gpointer)
- &gComboBoxEntryArrowWidget);
- gtk_widget_realize(gComboBoxEntryArrowWidget);
- g_object_set_data(G_OBJECT(gComboBoxEntryArrowWidget),
- "transparent-bg-hint", TRUE);
- }
- } else {
- /* Shouldn't be reached with current internal gtk implementation;
- * we use a generic toggle button as last resort fallback to avoid
- * crashing. */
- ensure_toggle_button_widget();
- gComboBoxEntryButtonWidget = gToggleButtonWidget;
- }
-
- if (!gComboBoxEntryArrowWidget) {
- /* Shouldn't be reached with current internal gtk implementation;
- * we gButtonArrowWidget as last resort fallback to avoid
- * crashing. */
- ensure_button_arrow_widget();
- gComboBoxEntryArrowWidget = gButtonArrowWidget;
- }
-
- return MOZ_GTK_SUCCESS;
-}
-
-
-static gint
-ensure_handlebox_widget()
-{
- if (!gHandleBoxWidget) {
- gHandleBoxWidget = gtk_handle_box_new();
- setup_widget_prototype(gHandleBoxWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_toolbar_widget()
-{
- if (!gToolbarWidget) {
- ensure_handlebox_widget();
- gToolbarWidget = gtk_toolbar_new();
- gtk_container_add(GTK_CONTAINER(gHandleBoxWidget), gToolbarWidget);
- gtk_widget_realize(gToolbarWidget);
- g_object_set_data(G_OBJECT(gToolbarWidget), "transparent-bg-hint", TRUE);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_toolbar_separator_widget()
-{
- if (!gToolbarSeparatorWidget) {
- ensure_toolbar_widget();
- gToolbarSeparatorWidget = GTK_WIDGET(gtk_separator_tool_item_new());
- setup_widget_prototype(gToolbarSeparatorWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_tooltip_widget()
-{
- if (!gTooltipWidget) {
- gTooltipWidget = gtk_window_new(GTK_WINDOW_POPUP);
- gtk_widget_realize(gTooltipWidget);
- moz_gtk_set_widget_name(gTooltipWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_tab_widget()
-{
- if (!gTabWidget) {
- gTabWidget = gtk_notebook_new();
- setup_widget_prototype(gTabWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_progress_widget()
-{
- if (!gProgressWidget) {
- gProgressWidget = gtk_progress_bar_new();
- setup_widget_prototype(gProgressWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_statusbar_widget()
-{
- if (!gStatusbarWidget) {
- gStatusbarWidget = gtk_statusbar_new();
- setup_widget_prototype(gStatusbarWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_frame_widget()
-{
- if (!gFrameWidget) {
- ensure_statusbar_widget();
- gFrameWidget = gtk_frame_new(NULL);
- gtk_container_add(GTK_CONTAINER(gStatusbarWidget), gFrameWidget);
- gtk_widget_realize(gFrameWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_menu_bar_widget()
-{
- if (!gMenuBarWidget) {
- gMenuBarWidget = gtk_menu_bar_new();
- setup_widget_prototype(gMenuBarWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_menu_bar_item_widget()
-{
- if (!gMenuBarItemWidget) {
- ensure_menu_bar_widget();
- gMenuBarItemWidget = gtk_menu_item_new();
- gtk_menu_shell_append(GTK_MENU_SHELL(gMenuBarWidget),
- gMenuBarItemWidget);
- gtk_widget_realize(gMenuBarItemWidget);
- g_object_set_data(G_OBJECT(gMenuBarItemWidget),
- "transparent-bg-hint", TRUE);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_menu_popup_widget()
-{
- if (!gMenuPopupWidget) {
- ensure_menu_bar_item_widget();
- gMenuPopupWidget = gtk_menu_new();
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(gMenuBarItemWidget),
- gMenuPopupWidget);
- gtk_widget_realize(gMenuPopupWidget);
- g_object_set_data(G_OBJECT(gMenuPopupWidget),
- "transparent-bg-hint", TRUE);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_menu_item_widget()
-{
- if (!gMenuItemWidget) {
- ensure_menu_popup_widget();
- gMenuItemWidget = gtk_menu_item_new_with_label("M");
- gtk_menu_shell_append(GTK_MENU_SHELL(gMenuPopupWidget),
- gMenuItemWidget);
- gtk_widget_realize(gMenuItemWidget);
- g_object_set_data(G_OBJECT(gMenuItemWidget),
- "transparent-bg-hint", TRUE);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_image_menu_item_widget()
-{
- if (!gImageMenuItemWidget) {
- ensure_menu_popup_widget();
- gImageMenuItemWidget = gtk_image_menu_item_new();
- gtk_menu_shell_append(GTK_MENU_SHELL(gMenuPopupWidget),
- gImageMenuItemWidget);
- gtk_widget_realize(gImageMenuItemWidget);
- g_object_set_data(G_OBJECT(gImageMenuItemWidget),
- "transparent-bg-hint", TRUE);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_menu_separator_widget()
-{
- if (!gMenuSeparatorWidget) {
- ensure_menu_popup_widget();
- gMenuSeparatorWidget = gtk_separator_menu_item_new();
- gtk_menu_shell_append(GTK_MENU_SHELL(gMenuPopupWidget),
- gMenuSeparatorWidget);
- gtk_widget_realize(gMenuSeparatorWidget);
- g_object_set_data(G_OBJECT(gMenuSeparatorWidget),
- "transparent-bg-hint", TRUE);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_check_menu_item_widget()
-{
- if (!gCheckMenuItemWidget) {
- ensure_menu_popup_widget();
- gCheckMenuItemWidget = gtk_check_menu_item_new_with_label("M");
- gtk_menu_shell_append(GTK_MENU_SHELL(gMenuPopupWidget),
- gCheckMenuItemWidget);
- gtk_widget_realize(gCheckMenuItemWidget);
- g_object_set_data(G_OBJECT(gCheckMenuItemWidget),
- "transparent-bg-hint", TRUE);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_tree_view_widget()
-{
- if (!gTreeViewWidget) {
- gTreeViewWidget = gtk_tree_view_new();
- setup_widget_prototype(gTreeViewWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_tree_header_cell_widget()
-{
- if(!gTreeHeaderCellWidget) {
- /*
- * Some GTK engines paint the first and last cell
- * of a TreeView header with a highlight.
- * Since we do not know where our widget will be relative
- * to the other buttons in the TreeView header, we must
- * paint it as a button that is between two others,
- * thus ensuring it is neither the first or last button
- * in the header.
- * GTK doesn't give us a way to do this explicitly,
- * so we must paint with a button that is between two
- * others.
- */
-
- GtkTreeViewColumn* firstTreeViewColumn;
- GtkTreeViewColumn* lastTreeViewColumn;
-
- ensure_tree_view_widget();
-
- /* Create and append our three columns */
- firstTreeViewColumn = gtk_tree_view_column_new();
- gtk_tree_view_column_set_title(firstTreeViewColumn, "M");
- gtk_tree_view_append_column(GTK_TREE_VIEW(gTreeViewWidget), firstTreeViewColumn);
-
- gMiddleTreeViewColumn = gtk_tree_view_column_new();
- gtk_tree_view_column_set_title(GTK_TREE_VIEW_COLUMN(gMiddleTreeViewColumn), "M");
- gtk_tree_view_append_column(GTK_TREE_VIEW(gTreeViewWidget),
- GTK_TREE_VIEW_COLUMN(gMiddleTreeViewColumn));
-
- lastTreeViewColumn = gtk_tree_view_column_new();
- gtk_tree_view_column_set_title(lastTreeViewColumn, "M");
- gtk_tree_view_append_column(GTK_TREE_VIEW(gTreeViewWidget), lastTreeViewColumn);
-
- /* Use the middle column's header for our button */
- gTreeHeaderCellWidget = GTK_TREE_VIEW_COLUMN(gMiddleTreeViewColumn)->button;
- gTreeHeaderSortArrowWidget = GTK_TREE_VIEW_COLUMN(gMiddleTreeViewColumn)->arrow;
- g_object_set_data(G_OBJECT(gTreeHeaderCellWidget),
- "transparent-bg-hint", TRUE);
- g_object_set_data(G_OBJECT(gTreeHeaderSortArrowWidget),
- "transparent-bg-hint", TRUE);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_expander_widget()
-{
- if (!gExpanderWidget) {
- gExpanderWidget = gtk_expander_new("M");
- setup_widget_prototype(gExpanderWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-ensure_scrolled_window_widget()
-{
- if (!gScrolledWindowWidget) {
- gScrolledWindowWidget = gtk_scrolled_window_new(NULL, NULL);
- setup_widget_prototype(gScrolledWindowWidget);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-static GtkStateType
-ConvertGtkState(GtkWidgetState* state)
-{
- if (state->disabled)
- return GTK_STATE_INSENSITIVE;
- else if (state->depressed)
- return (state->inHover ? GTK_STATE_PRELIGHT : GTK_STATE_ACTIVE);
- else if (state->inHover)
- return (state->active ? GTK_STATE_ACTIVE : GTK_STATE_PRELIGHT);
- else
- return GTK_STATE_NORMAL;
-}
-
-static gint
-TSOffsetStyleGCArray(GdkGC** gcs, gint xorigin, gint yorigin)
-{
- int i;
- /* there are 5 gc's in each array, for each of the widget states */
- for (i = 0; i < 5; ++i)
- gdk_gc_set_ts_origin(gcs[i], xorigin, yorigin);
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-TSOffsetStyleGCs(GtkStyle* style, gint xorigin, gint yorigin)
-{
- TSOffsetStyleGCArray(style->fg_gc, xorigin, yorigin);
- TSOffsetStyleGCArray(style->bg_gc, xorigin, yorigin);
- TSOffsetStyleGCArray(style->light_gc, xorigin, yorigin);
- TSOffsetStyleGCArray(style->dark_gc, xorigin, yorigin);
- TSOffsetStyleGCArray(style->mid_gc, xorigin, yorigin);
- TSOffsetStyleGCArray(style->text_gc, xorigin, yorigin);
- TSOffsetStyleGCArray(style->base_gc, xorigin, yorigin);
- gdk_gc_set_ts_origin(style->black_gc, xorigin, yorigin);
- gdk_gc_set_ts_origin(style->white_gc, xorigin, yorigin);
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_button_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state,
- GtkReliefStyle relief, GtkWidget* widget,
- GtkTextDirection direction)
-{
- GtkShadowType shadow_type;
- GtkStyle* style = widget->style;
- GtkStateType button_state = ConvertGtkState(state);
- gint x = rect->x, y=rect->y, width=rect->width, height=rect->height;
-
- gboolean interior_focus;
- gint focus_width, focus_pad;
-
- moz_gtk_widget_get_focus(widget, &interior_focus, &focus_width, &focus_pad);
-
- if (WINDOW_IS_MAPPED(drawable)) {
- gdk_window_set_back_pixmap(drawable, NULL, TRUE);
- gdk_window_clear_area(drawable, cliprect->x, cliprect->y,
- cliprect->width, cliprect->height);
- }
-
- gtk_widget_set_state(widget, button_state);
- gtk_widget_set_direction(widget, direction);
-
- if (state->isDefault)
- GTK_WIDGET_SET_FLAGS(widget, GTK_HAS_DEFAULT);
-
- GTK_BUTTON(widget)->relief = relief;
-
- /* Some theme engines love to cause us pain in that gtk_paint_focus is a
- no-op on buttons and button-like widgets. They only listen to this flag. */
- if (state->focused && !state->disabled)
- GTK_WIDGET_SET_FLAGS(widget, GTK_HAS_FOCUS);
-
- if (!interior_focus && state->focused) {
- x += focus_width + focus_pad;
- y += focus_width + focus_pad;
- width -= 2 * (focus_width + focus_pad);
- height -= 2 * (focus_width + focus_pad);
- }
-
- shadow_type = button_state == GTK_STATE_ACTIVE ||
- state->depressed ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
-
- if (state->isDefault && relief == GTK_RELIEF_NORMAL) {
- gtk_paint_box(style, drawable, button_state, shadow_type, cliprect,
- widget, "buttondefault", x, y, width, height);
- }
-
- if (relief != GTK_RELIEF_NONE || state->depressed ||
- (button_state != GTK_STATE_NORMAL &&
- button_state != GTK_STATE_INSENSITIVE)) {
- TSOffsetStyleGCs(style, x, y);
- /* the following line can trigger an assertion (Crux theme)
- file ../../gdk/gdkwindow.c: line 1846 (gdk_window_clear_area):
- assertion `GDK_IS_WINDOW (window)' failed */
- gtk_paint_box(style, drawable, button_state, shadow_type, cliprect,
- widget, "button", x, y, width, height);
- }
-
- if (state->focused) {
- if (interior_focus) {
- x += widget->style->xthickness + focus_pad;
- y += widget->style->ythickness + focus_pad;
- width -= 2 * (widget->style->xthickness + focus_pad);
- height -= 2 * (widget->style->ythickness + focus_pad);
- } else {
- x -= focus_width + focus_pad;
- y -= focus_width + focus_pad;
- width += 2 * (focus_width + focus_pad);
- height += 2 * (focus_width + focus_pad);
- }
-
- TSOffsetStyleGCs(style, x, y);
- gtk_paint_focus(style, drawable, button_state, cliprect,
- widget, "button", x, y, width, height);
- }
-
- GTK_WIDGET_UNSET_FLAGS(widget, GTK_HAS_DEFAULT);
- GTK_WIDGET_UNSET_FLAGS(widget, GTK_HAS_FOCUS);
- return MOZ_GTK_SUCCESS;
-}
-
-gint
-moz_gtk_init()
-{
- GtkWidgetClass *entry_class;
-
- is_initialized = TRUE;
- have_arrow_scaling = (gtk_major_version > 2 ||
- (gtk_major_version == 2 && gtk_minor_version >= 12));
-
- have_2_10 = (gtk_major_version > 2 ||
- (gtk_major_version == 2 && gtk_minor_version >= 10));
-
- /* Add style property to GtkEntry.
- * Adding the style property to the normal GtkEntry class means that it
- * will work without issues inside GtkComboBox and for Spinbuttons. */
- entry_class = g_type_class_ref(GTK_TYPE_ENTRY);
- gtk_widget_class_install_style_property(entry_class,
- g_param_spec_boolean("honors-transparent-bg-hint",
- "Transparent BG enabling flag",
- "If TRUE, the theme is able to draw the GtkEntry on non-prefilled background.",
- FALSE,
- G_PARAM_READWRITE));
-
- return MOZ_GTK_SUCCESS;
-}
-
-gint
-moz_gtk_checkbox_get_metrics(gint* indicator_size, gint* indicator_spacing)
-{
- ensure_checkbox_widget();
-
- gtk_widget_style_get (gCheckboxWidget,
- "indicator_size", indicator_size,
- "indicator_spacing", indicator_spacing,
- NULL);
-
- return MOZ_GTK_SUCCESS;
-}
-
-gint
-moz_gtk_radio_get_metrics(gint* indicator_size, gint* indicator_spacing)
-{
- ensure_radiobutton_widget();
-
- gtk_widget_style_get (gRadiobuttonWidget,
- "indicator_size", indicator_size,
- "indicator_spacing", indicator_spacing,
- NULL);
-
- return MOZ_GTK_SUCCESS;
-}
-
-gint
-moz_gtk_widget_get_focus(GtkWidget* widget, gboolean* interior_focus,
- gint* focus_width, gint* focus_pad)
-{
- gtk_widget_style_get (widget,
- "interior-focus", interior_focus,
- "focus-line-width", focus_width,
- "focus-padding", focus_pad,
- NULL);
-
- return MOZ_GTK_SUCCESS;
-}
-
-gint
-moz_gtk_splitter_get_metrics(gint orientation, gint* size)
-{
- if (orientation == GTK_ORIENTATION_HORIZONTAL) {
- ensure_hpaned_widget();
- gtk_widget_style_get(gHPanedWidget, "handle_size", size, NULL);
- } else {
- ensure_vpaned_widget();
- gtk_widget_style_get(gVPanedWidget, "handle_size", size, NULL);
- }
- return MOZ_GTK_SUCCESS;
-}
-
-gint
-moz_gtk_button_get_inner_border(GtkWidget* widget, GtkBorder* inner_border)
-{
- static const GtkBorder default_inner_border = { 1, 1, 1, 1 };
- GtkBorder *tmp_border = NULL;
-
- if (have_2_10)
- gtk_widget_style_get (widget, "inner-border", &tmp_border, NULL);
-
- if (tmp_border) {
- *inner_border = *tmp_border;
- gtk_border_free(tmp_border);
- }
- else
- *inner_border = default_inner_border;
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_toggle_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state,
- gboolean selected, gboolean isradio,
- GtkTextDirection direction)
-{
- GtkStateType state_type = ConvertGtkState(state);
- GtkShadowType shadow_type = (selected)?GTK_SHADOW_IN:GTK_SHADOW_OUT;
- gint indicator_size, indicator_spacing;
- gint x, y, width, height;
- gint focus_x, focus_y, focus_width, focus_height;
- GtkWidget *w;
- GtkStyle *style;
-
- if (isradio) {
- moz_gtk_radio_get_metrics(&indicator_size, &indicator_spacing);
- w = gRadiobuttonWidget;
- } else {
- moz_gtk_checkbox_get_metrics(&indicator_size, &indicator_spacing);
- w = gCheckboxWidget;
- }
-
- /*
- * vertically center in the box, since XUL sometimes ignores our
- * GetMinimumWidgetSize in the vertical dimension
- */
- x = rect->x;
- y = rect->y + (rect->height - indicator_size) / 2;
- width = indicator_size;
- height = indicator_size;
-
- focus_x = x - indicator_spacing;
- focus_y = y - indicator_spacing;
- focus_width = width + 2 * indicator_spacing;
- focus_height = height + 2 * indicator_spacing;
-
- style = w->style;
- TSOffsetStyleGCs(style, x, y);
-
- gtk_widget_set_sensitive(w, !state->disabled);
- gtk_widget_set_direction(w, direction);
- GTK_TOGGLE_BUTTON(w)->active = selected;
-
- if (isradio) {
- gtk_paint_option(style, drawable, state_type, shadow_type, cliprect,
- gRadiobuttonWidget, "radiobutton", x, y,
- width, height);
- if (state->focused) {
- gtk_paint_focus(style, drawable, GTK_STATE_ACTIVE, cliprect,
- gRadiobuttonWidget, "radiobutton", focus_x, focus_y,
- focus_width, focus_height);
- }
- }
- else {
- gtk_paint_check(style, drawable, state_type, shadow_type, cliprect,
- gCheckboxWidget, "checkbutton", x, y, width, height);
- if (state->focused) {
- gtk_paint_focus(style, drawable, GTK_STATE_ACTIVE, cliprect,
- gCheckboxWidget, "checkbutton", focus_x, focus_y,
- focus_width, focus_height);
- }
- }
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-calculate_button_inner_rect(GtkWidget* button, GdkRectangle* rect,
- GdkRectangle* inner_rect,
- GtkTextDirection direction,
- gboolean ignore_focus)
-{
- GtkBorder inner_border;
- gboolean interior_focus;
- gint focus_width, focus_pad;
- GtkStyle* style;
-
- style = button->style;
-
- /* This mirrors gtkbutton's child positioning */
- moz_gtk_button_get_inner_border(button, &inner_border);
- moz_gtk_widget_get_focus(button, &interior_focus,
- &focus_width, &focus_pad);
-
- if (ignore_focus)
- focus_width = focus_pad = 0;
-
- inner_rect->x = rect->x + XTHICKNESS(style) + focus_width + focus_pad;
- inner_rect->x += direction == GTK_TEXT_DIR_LTR ?
- inner_border.left : inner_border.right;
- inner_rect->y = rect->y + inner_border.top + YTHICKNESS(style) +
- focus_width + focus_pad;
- inner_rect->width = MAX(1, rect->width - inner_border.left -
- inner_border.right - (XTHICKNESS(style) + focus_pad + focus_width) * 2);
- inner_rect->height = MAX(1, rect->height - inner_border.top -
- inner_border.bottom - (YTHICKNESS(style) + focus_pad + focus_width) * 2);
-
- return MOZ_GTK_SUCCESS;
-}
-
-
-static gint
-calculate_arrow_rect(GtkWidget* arrow, GdkRectangle* rect,
- GdkRectangle* arrow_rect, GtkTextDirection direction)
-{
- /* defined in gtkarrow.c */
- gfloat arrow_scaling = 0.7;
- gfloat xalign, xpad;
- gint extent;
- GtkMisc* misc = GTK_MISC(arrow);
-
- if (have_arrow_scaling)
- gtk_widget_style_get(arrow, "arrow_scaling", &arrow_scaling, NULL);
-
- extent = MIN((rect->width - misc->xpad * 2),
- (rect->height - misc->ypad * 2)) * arrow_scaling;
-
- xalign = direction == GTK_TEXT_DIR_LTR ? misc->xalign : 1.0 - misc->xalign;
- xpad = misc->xpad + (rect->width - extent) * xalign;
-
- arrow_rect->x = direction == GTK_TEXT_DIR_LTR ?
- floor(rect->x + xpad) : ceil(rect->x + xpad);
- arrow_rect->y = floor(rect->y + misc->ypad +
- ((rect->height - extent) * misc->yalign));
-
- arrow_rect->width = arrow_rect->height = extent;
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_scrollbar_button_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state,
- GtkScrollbarButtonFlags flags,
- GtkTextDirection direction)
-{
- GtkStateType state_type = ConvertGtkState(state);
- GtkShadowType shadow_type = (state->active) ?
- GTK_SHADOW_IN : GTK_SHADOW_OUT;
- GdkRectangle arrow_rect;
- GtkStyle* style;
- GtkWidget *scrollbar;
- GtkArrowType arrow_type;
- gint arrow_displacement_x, arrow_displacement_y;
- const char* detail = (flags & MOZ_GTK_STEPPER_VERTICAL) ?
- "vscrollbar" : "hscrollbar";
-
- ensure_scrollbar_widget();
-
- if (flags & MOZ_GTK_STEPPER_VERTICAL)
- scrollbar = gVertScrollbarWidget;
- else
- scrollbar = gHorizScrollbarWidget;
-
- gtk_widget_set_direction(scrollbar, direction);
-
- /* Some theme engines (i.e., ClearLooks) check the scrollbar's allocation
- to determine where it should paint rounded corners on the buttons.
- We need to trick them into drawing the buttons the way we want them. */
-
- scrollbar->allocation.x = rect->x;
- scrollbar->allocation.y = rect->y;
- scrollbar->allocation.width = rect->width;
- scrollbar->allocation.height = rect->height;
-
- if (flags & MOZ_GTK_STEPPER_VERTICAL) {
- scrollbar->allocation.height *= 5;
- if (flags & MOZ_GTK_STEPPER_DOWN) {
- arrow_type = GTK_ARROW_DOWN;
- if (flags & MOZ_GTK_STEPPER_BOTTOM)
- scrollbar->allocation.y -= 4 * rect->height;
- else
- scrollbar->allocation.y -= rect->height;
-
- } else {
- arrow_type = GTK_ARROW_UP;
- if (flags & MOZ_GTK_STEPPER_BOTTOM)
- scrollbar->allocation.y -= 3 * rect->height;
- }
- } else {
- scrollbar->allocation.width *= 5;
- if (flags & MOZ_GTK_STEPPER_DOWN) {
- arrow_type = GTK_ARROW_RIGHT;
- if (flags & MOZ_GTK_STEPPER_BOTTOM)
- scrollbar->allocation.x -= 4 * rect->width;
- else
- scrollbar->allocation.x -= rect->width;
- } else {
- arrow_type = GTK_ARROW_LEFT;
- if (flags & MOZ_GTK_STEPPER_BOTTOM)
- scrollbar->allocation.x -= 3 * rect->width;
- }
- }
-
- style = scrollbar->style;
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
-
- gtk_paint_box(style, drawable, state_type, shadow_type, cliprect,
- scrollbar, detail, rect->x, rect->y,
- rect->width, rect->height);
-
- arrow_rect.width = rect->width / 2;
- arrow_rect.height = rect->height / 2;
- arrow_rect.x = rect->x + (rect->width - arrow_rect.width) / 2;
- arrow_rect.y = rect->y + (rect->height - arrow_rect.height) / 2;
-
- if (state_type == GTK_STATE_ACTIVE) {
- gtk_widget_style_get(scrollbar,
- "arrow-displacement-x", &arrow_displacement_x,
- "arrow-displacement-y", &arrow_displacement_y,
- NULL);
-
- arrow_rect.x += arrow_displacement_x;
- arrow_rect.y += arrow_displacement_y;
- }
-
- gtk_paint_arrow(style, drawable, state_type, shadow_type, cliprect,
- scrollbar, detail, arrow_type, TRUE, arrow_rect.x,
- arrow_rect.y, arrow_rect.width, arrow_rect.height);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_scrollbar_trough_paint(GtkThemeWidgetType widget,
- GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state,
- GtkTextDirection direction)
-{
- GtkStyle* style;
- GtkScrollbar *scrollbar;
-
- ensure_scrollbar_widget();
-
- if (widget == MOZ_GTK_SCROLLBAR_TRACK_HORIZONTAL)
- scrollbar = GTK_SCROLLBAR(gHorizScrollbarWidget);
- else
- scrollbar = GTK_SCROLLBAR(gVertScrollbarWidget);
-
- gtk_widget_set_direction(GTK_WIDGET(scrollbar), direction);
-
- style = GTK_WIDGET(scrollbar)->style;
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
- gtk_style_apply_default_background(style, drawable, TRUE, GTK_STATE_ACTIVE,
- cliprect, rect->x, rect->y,
- rect->width, rect->height);
-
- gtk_paint_box(style, drawable, GTK_STATE_ACTIVE, GTK_SHADOW_IN, cliprect,
- GTK_WIDGET(scrollbar), "trough", rect->x, rect->y,
- rect->width, rect->height);
-
- if (state->focused) {
- gtk_paint_focus(style, drawable, GTK_STATE_ACTIVE, cliprect,
- GTK_WIDGET(scrollbar), "trough",
- rect->x, rect->y, rect->width, rect->height);
- }
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_scrollbar_thumb_paint(GtkThemeWidgetType widget,
- GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state,
- GtkTextDirection direction)
-{
- GtkStateType state_type = (state->inHover || state->active) ?
- GTK_STATE_PRELIGHT : GTK_STATE_NORMAL;
- GtkShadowType shadow_type = GTK_SHADOW_OUT;
- GtkStyle* style;
- GtkScrollbar *scrollbar;
- GtkAdjustment *adj;
- gboolean activate_slider;
-
- ensure_scrollbar_widget();
-
- if (widget == MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL)
- scrollbar = GTK_SCROLLBAR(gHorizScrollbarWidget);
- else
- scrollbar = GTK_SCROLLBAR(gVertScrollbarWidget);
-
- gtk_widget_set_direction(GTK_WIDGET(scrollbar), direction);
-
- /* Make sure to set the scrollbar range before painting so that
- everything is drawn properly. At least the bluecurve (and
- maybe other) themes don't draw the top or bottom black line
- surrounding the scrollbar if the theme thinks that it's butted
- up against the scrollbar arrows. Note the increases of the
- clip rect below. */
- /* Changing the cliprect is pretty bogus. This lets themes draw
- outside the frame, which means we don't invalidate them
- correctly. See bug 297508. But some themes do seem to need
- it. So we modify the frame's overflow area to account for what
- we're doing here; see nsNativeThemeGTK::GetWidgetOverflow. */
- adj = gtk_range_get_adjustment(GTK_RANGE(scrollbar));
-
- if (widget == MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL) {
- cliprect->x -= 1;
- cliprect->width += 2;
- adj->page_size = rect->width;
- }
- else {
- cliprect->y -= 1;
- cliprect->height += 2;
- adj->page_size = rect->height;
- }
-
- adj->lower = 0;
- adj->value = state->curpos;
- adj->upper = state->maxpos;
- gtk_adjustment_changed(adj);
-
- style = GTK_WIDGET(scrollbar)->style;
-
- gtk_widget_style_get(GTK_WIDGET(scrollbar), "activate-slider",
- &activate_slider, NULL);
-
- if (activate_slider && state->active) {
- shadow_type = GTK_SHADOW_IN;
- state_type = GTK_STATE_ACTIVE;
- }
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
-
- gtk_paint_slider(style, drawable, state_type, shadow_type, cliprect,
- GTK_WIDGET(scrollbar), "slider", rect->x, rect->y,
- rect->width, rect->height,
- (widget == MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL) ?
- GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_spin_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GtkTextDirection direction)
-{
- GtkStyle* style;
-
- ensure_spin_widget();
- gtk_widget_set_direction(gSpinWidget, direction);
- style = gSpinWidget->style;
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
- gtk_paint_box(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_IN, NULL,
- gSpinWidget, "spinbutton",
- rect->x, rect->y, rect->width, rect->height);
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_spin_updown_paint(GdkDrawable* drawable, GdkRectangle* rect,
- gboolean isDown, GtkWidgetState* state,
- GtkTextDirection direction)
-{
- GdkRectangle arrow_rect;
- GtkStateType state_type = ConvertGtkState(state);
- GtkShadowType shadow_type = state_type == GTK_STATE_ACTIVE ?
- GTK_SHADOW_IN : GTK_SHADOW_OUT;
- GtkStyle* style;
-
- ensure_spin_widget();
- style = gSpinWidget->style;
- gtk_widget_set_direction(gSpinWidget, direction);
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
- gtk_paint_box(style, drawable, state_type, shadow_type, NULL, gSpinWidget,
- isDown ? "spinbutton_down" : "spinbutton_up",
- rect->x, rect->y, rect->width, rect->height);
-
- /* hard code these values */
- arrow_rect.width = 6;
- arrow_rect.height = 6;
- arrow_rect.x = rect->x + (rect->width - arrow_rect.width) / 2;
- arrow_rect.y = rect->y + (rect->height - arrow_rect.height) / 2;
- arrow_rect.y += isDown ? -1 : 1;
-
- gtk_paint_arrow(style, drawable, state_type, shadow_type, NULL,
- gSpinWidget, "spinbutton",
- isDown ? GTK_ARROW_DOWN : GTK_ARROW_UP, TRUE,
- arrow_rect.x, arrow_rect.y,
- arrow_rect.width, arrow_rect.height);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_scale_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state,
- GtkOrientation flags, GtkTextDirection direction)
-{
- gint x = 0, y = 0;
- GtkStateType state_type = ConvertGtkState(state);
- GtkStyle* style;
- GtkWidget* widget;
-
- ensure_scale_widget();
- widget = ((flags == GTK_ORIENTATION_HORIZONTAL) ? gHScaleWidget : gVScaleWidget);
- gtk_widget_set_direction(widget, direction);
-
- style = widget->style;
-
- if (flags == GTK_ORIENTATION_HORIZONTAL) {
- x = XTHICKNESS(style);
- y++;
- }
- else {
- x++;
- y = YTHICKNESS(style);
- }
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
- gtk_style_apply_default_background(style, drawable, TRUE, GTK_STATE_NORMAL,
- cliprect, rect->x, rect->y,
- rect->width, rect->height);
-
- gtk_paint_box(style, drawable, GTK_STATE_ACTIVE, GTK_SHADOW_IN, cliprect,
- widget, "trough", rect->x + x, rect->y + y,
- rect->width - 2*x, rect->height - 2*y);
-
- if (state->focused)
- gtk_paint_focus(style, drawable, state_type, cliprect, widget, "trough",
- rect->x, rect->y, rect->width, rect->height);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_scale_thumb_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state,
- GtkOrientation flags, GtkTextDirection direction)
-{
- GtkStateType state_type = ConvertGtkState(state);
- GtkStyle* style;
- GtkWidget* widget;
- gint thumb_width, thumb_height, x, y;
-
- ensure_scale_widget();
- widget = ((flags == GTK_ORIENTATION_HORIZONTAL) ? gHScaleWidget : gVScaleWidget);
- gtk_widget_set_direction(widget, direction);
-
- style = widget->style;
-
- /* determine the thumb size, and position the thumb in the center in the opposite axis */
- if (flags == GTK_ORIENTATION_HORIZONTAL) {
- moz_gtk_get_scalethumb_metrics(GTK_ORIENTATION_HORIZONTAL, &thumb_width, &thumb_height);
- x = rect->x;
- y = rect->y + (rect->height - thumb_height) / 2;
- }
- else {
- moz_gtk_get_scalethumb_metrics(GTK_ORIENTATION_VERTICAL, &thumb_height, &thumb_width);
- x = rect->x + (rect->width - thumb_width) / 2;
- y = rect->y;
- }
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
- gtk_paint_slider(style, drawable, state_type, GTK_SHADOW_OUT, cliprect,
- widget, (flags == GTK_ORIENTATION_HORIZONTAL) ? "hscale" : "vscale",
- x, y, thumb_width, thumb_height, flags);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_gripper_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state,
- GtkTextDirection direction)
-{
- GtkStateType state_type = ConvertGtkState(state);
- GtkShadowType shadow_type;
- GtkStyle* style;
-
- ensure_handlebox_widget();
- gtk_widget_set_direction(gHandleBoxWidget, direction);
-
- style = gHandleBoxWidget->style;
- shadow_type = GTK_HANDLE_BOX(gHandleBoxWidget)->shadow_type;
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
- gtk_paint_box(style, drawable, state_type, shadow_type, cliprect,
- gHandleBoxWidget, "handlebox_bin", rect->x, rect->y,
- rect->width, rect->height);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_hpaned_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state)
-{
- GtkStateType hpaned_state = ConvertGtkState(state);
-
- ensure_hpaned_widget();
- gtk_paint_handle(gHPanedWidget->style, drawable, hpaned_state,
- GTK_SHADOW_NONE, cliprect, gHPanedWidget, "paned",
- rect->x, rect->y, rect->width, rect->height,
- GTK_ORIENTATION_VERTICAL);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_vpaned_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state)
-{
- GtkStateType vpaned_state = ConvertGtkState(state);
-
- ensure_vpaned_widget();
- gtk_paint_handle(gVPanedWidget->style, drawable, vpaned_state,
- GTK_SHADOW_NONE, cliprect, gVPanedWidget, "paned",
- rect->x, rect->y, rect->width, rect->height,
- GTK_ORIENTATION_HORIZONTAL);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_caret_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkTextDirection direction)
-{
- ensure_entry_widget();
- gtk_draw_insertion_cursor(gEntryWidget, drawable, cliprect,
- rect, TRUE, direction, FALSE);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_entry_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state,
- GtkWidget* widget, GtkTextDirection direction)
-{
- GtkStateType bg_state = state->disabled ?
- GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL;
- gint x, y, width = rect->width, height = rect->height;
- GtkStyle* style;
- gboolean interior_focus;
- gboolean theme_honors_transparency = FALSE;
- gint focus_width;
-
- gtk_widget_set_direction(widget, direction);
-
- style = widget->style;
-
- gtk_widget_style_get(widget,
- "interior-focus", &interior_focus,
- "focus-line-width", &focus_width,
- "honors-transparent-bg-hint", &theme_honors_transparency,
- NULL);
-
- /* gtkentry.c uses two windows, one for the entire widget and one for the
- * text area inside it. The background of both windows is set to the "base"
- * color of the new state in gtk_entry_state_changed, but only the inner
- * textarea window uses gtk_paint_flat_box when exposed */
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
-
- /* This gets us a lovely greyish disabledish look */
- gtk_widget_set_sensitive(widget, !state->disabled);
-
- /* GTK fills the outer widget window with the base color before drawing the widget.
- * Some older themes rely on this behavior, but many themes nowadays use rounded
- * corners on their widgets. While most GTK apps are blissfully unaware of this
- * problem due to their use of the default window background, we render widgets on
- * many kinds of backgrounds on the web.
- * If the theme is able to cope with transparency, then we can skip pre-filling
- * and notify the theme it will paint directly on the canvas. */
- if (theme_honors_transparency) {
- g_object_set_data(G_OBJECT(widget), "transparent-bg-hint", TRUE);
- } else {
- gdk_draw_rectangle(drawable, style->base_gc[bg_state], TRUE,
- cliprect->x, cliprect->y, cliprect->width, cliprect->height);
- g_object_set_data(G_OBJECT(widget), "transparent-bg-hint", FALSE);
- }
-
- /* Get the position of the inner window, see _gtk_entry_get_borders */
- x = XTHICKNESS(style);
- y = YTHICKNESS(style);
-
- if (!interior_focus) {
- x += focus_width;
- y += focus_width;
- }
-
- /* Simulate an expose of the inner window */
- gtk_paint_flat_box(style, drawable, bg_state, GTK_SHADOW_NONE,
- cliprect, widget, "entry_bg", rect->x + x,
- rect->y + y, rect->width - 2*x, rect->height - 2*y);
-
- /* Now paint the shadow and focus border.
- * We do like in gtk_entry_draw_frame, we first draw the shadow, a tad
- * smaller when focused if the focus is not interior, then the focus. */
- x = rect->x;
- y = rect->y;
-
- if (state->focused && !state->disabled) {
- /* This will get us the lit borders that focused textboxes enjoy on
- * some themes. */
- GTK_WIDGET_SET_FLAGS(widget, GTK_HAS_FOCUS);
-
- if (!interior_focus) {
- /* Indent the border a little bit if we have exterior focus
- (this is what GTK does to draw native entries) */
- x += focus_width;
- y += focus_width;
- width -= 2 * focus_width;
- height -= 2 * focus_width;
- }
- }
-
- gtk_paint_shadow(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_IN,
- cliprect, widget, "entry", x, y, width, height);
-
- if (state->focused && !state->disabled) {
- if (!interior_focus) {
- gtk_paint_focus(style, drawable, GTK_STATE_NORMAL, cliprect,
- widget, "entry",
- rect->x, rect->y, rect->width, rect->height);
- }
-
- /* Now unset the focus flag. We don't want other entries to look
- * like they're focused too! */
- GTK_WIDGET_UNSET_FLAGS(widget, GTK_HAS_FOCUS);
- }
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_treeview_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state,
- GtkTextDirection direction)
-{
- gint xthickness, ythickness;
-
- GtkStyle *style;
- GtkStateType state_type;
-
- ensure_tree_view_widget();
- ensure_scrolled_window_widget();
-
- gtk_widget_set_direction(gTreeViewWidget, direction);
- gtk_widget_set_direction(gScrolledWindowWidget, direction);
-
- /* only handle disabled and normal states, otherwise the whole background
- * area will be painted differently with other states */
- state_type = state->disabled ? GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL;
-
- /* In GTK the treeview sets the background of the window
- * which contains the cells to the treeview base color.
- * If we don't set it here the background color will not be correct.*/
- gtk_widget_modify_bg(gTreeViewWidget, state_type,
- &gTreeViewWidget->style->base[state_type]);
-
- style = gScrolledWindowWidget->style;
- xthickness = XTHICKNESS(style);
- ythickness = YTHICKNESS(style);
-
- TSOffsetStyleGCs(gTreeViewWidget->style, rect->x, rect->y);
- TSOffsetStyleGCs(style, rect->x, rect->y);
-
- gtk_paint_flat_box(gTreeViewWidget->style, drawable, state_type,
- GTK_SHADOW_NONE, cliprect, gTreeViewWidget, "treeview",
- rect->x + xthickness, rect->y + ythickness,
- rect->width - 2 * xthickness,
- rect->height - 2 * ythickness);
-
- gtk_paint_shadow(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_IN,
- cliprect, gScrolledWindowWidget, "scrolled_window",
- rect->x, rect->y, rect->width, rect->height);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_tree_header_cell_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state,
- gboolean isSorted, GtkTextDirection direction)
-{
- gtk_tree_view_column_set_sort_indicator(GTK_TREE_VIEW_COLUMN(gMiddleTreeViewColumn),
- isSorted);
-
- moz_gtk_button_paint(drawable, rect, cliprect, state, GTK_RELIEF_NORMAL,
- gTreeHeaderCellWidget, direction);
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_tree_header_sort_arrow_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect,
- GtkWidgetState* state, GtkArrowType flags,
- GtkTextDirection direction)
-{
- GdkRectangle arrow_rect;
- GtkStateType state_type = ConvertGtkState(state);
- GtkShadowType shadow_type = GTK_SHADOW_IN;
- GtkArrowType arrow_type = flags;
- GtkStyle* style;
-
- ensure_tree_header_cell_widget();
- gtk_widget_set_direction(gTreeHeaderSortArrowWidget, direction);
-
- /* hard code these values */
- arrow_rect.width = 11;
- arrow_rect.height = 11;
- arrow_rect.x = rect->x + (rect->width - arrow_rect.width) / 2;
- arrow_rect.y = rect->y + (rect->height - arrow_rect.height) / 2;
-
- style = gTreeHeaderSortArrowWidget->style;
- TSOffsetStyleGCs(style, arrow_rect.x, arrow_rect.y);
-
- gtk_paint_arrow(style, drawable, state_type, shadow_type, cliprect,
- gTreeHeaderSortArrowWidget, "arrow", arrow_type, TRUE,
- arrow_rect.x, arrow_rect.y,
- arrow_rect.width, arrow_rect.height);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_treeview_expander_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state,
- GtkExpanderStyle expander_state,
- GtkTextDirection direction)
-{
- GtkStyle *style;
- GtkStateType state_type;
-
- ensure_tree_view_widget();
- gtk_widget_set_direction(gTreeViewWidget, direction);
-
- style = gTreeViewWidget->style;
-
- /* Because the frame we get is of the entire treeview, we can't get the precise
- * event state of one expander, thus rendering hover and active feedback useless. */
- state_type = state->disabled ? GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL;
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
- gtk_paint_expander(style, drawable, state_type, cliprect, gTreeViewWidget, "treeview",
- rect->x + rect->width / 2, rect->y + rect->height / 2, expander_state);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_expander_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state,
- GtkExpanderStyle expander_state,
- GtkTextDirection direction)
-{
- GtkStyle *style;
- GtkStateType state_type = ConvertGtkState(state);
-
- ensure_expander_widget();
- gtk_widget_set_direction(gExpanderWidget, direction);
-
- style = gExpanderWidget->style;
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
- gtk_paint_expander(style, drawable, state_type, cliprect, gExpanderWidget, "expander",
- rect->x + rect->width / 2, rect->y + rect->height / 2, expander_state);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_combo_box_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state,
- gboolean ishtml, GtkTextDirection direction)
-{
- GdkRectangle arrow_rect, real_arrow_rect;
- gint arrow_size, separator_width = 0;
- gboolean wide_separators = FALSE;
- GtkStateType state_type = ConvertGtkState(state);
- GtkShadowType shadow_type = state->active ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
- GtkStyle* style;
- GtkRequisition arrow_req;
-
- ensure_combo_box_widgets();
-
- /* Also sets the direction on gComboBoxButtonWidget, which is then
- * inherited by the separator and arrow */
- moz_gtk_button_paint(drawable, rect, cliprect, state, GTK_RELIEF_NORMAL,
- gComboBoxButtonWidget, direction);
-
- calculate_button_inner_rect(gComboBoxButtonWidget,
- rect, &arrow_rect, direction, ishtml);
- /* Now arrow_rect contains the inner rect ; we want to correct the width
- * to what the arrow needs (see gtk_combo_box_size_allocate) */
- gtk_widget_size_request(gComboBoxArrowWidget, &arrow_req);
- if (direction == GTK_TEXT_DIR_LTR)
- arrow_rect.x += arrow_rect.width - arrow_req.width;
- arrow_rect.width = arrow_req.width;
-
- calculate_arrow_rect(gComboBoxArrowWidget,
- &arrow_rect, &real_arrow_rect, direction);
-
- style = gComboBoxArrowWidget->style;
- TSOffsetStyleGCs(style, rect->x, rect->y);
-
- gtk_widget_size_allocate(gComboBoxWidget, rect);
-
- gtk_paint_arrow(style, drawable, state_type, shadow_type, cliprect,
- gComboBoxArrowWidget, "arrow", GTK_ARROW_DOWN, TRUE,
- real_arrow_rect.x, real_arrow_rect.y,
- real_arrow_rect.width, real_arrow_rect.height);
-
-
- /* If there is no separator in the theme, there's nothing left to do. */
- if (!gComboBoxSeparatorWidget)
- return MOZ_GTK_SUCCESS;
-
- style = gComboBoxSeparatorWidget->style;
- TSOffsetStyleGCs(style, rect->x, rect->y);
-
- if (have_2_10)
- gtk_widget_style_get(gComboBoxSeparatorWidget,
- "wide-separators", &wide_separators,
- "separator-width", &separator_width,
- NULL);
-
- if (wide_separators) {
- if (direction == GTK_TEXT_DIR_LTR)
- arrow_rect.x -= separator_width;
- else
- arrow_rect.x += arrow_rect.width;
-
- gtk_paint_box(style, drawable,
- GTK_STATE_NORMAL, GTK_SHADOW_ETCHED_OUT,
- cliprect, gComboBoxSeparatorWidget, "vseparator",
- arrow_rect.x, arrow_rect.y,
- separator_width, arrow_rect.height);
- } else {
- if (direction == GTK_TEXT_DIR_LTR)
- arrow_rect.x -= XTHICKNESS(style);
- else
- arrow_rect.x += arrow_rect.width;
-
- gtk_paint_vline(style, drawable, GTK_STATE_NORMAL, cliprect,
- gComboBoxSeparatorWidget, "vseparator",
- arrow_rect.y, arrow_rect.y + arrow_rect.height,
- arrow_rect.x);
- }
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_downarrow_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state)
-{
- GtkStyle* style;
- GtkStateType state_type = ConvertGtkState(state);
- GtkShadowType shadow_type = state->active ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
- GdkRectangle arrow_rect;
-
- ensure_button_arrow_widget();
- style = gButtonArrowWidget->style;
-
- calculate_arrow_rect(gButtonArrowWidget, rect, &arrow_rect,
- GTK_TEXT_DIR_LTR);
-
- TSOffsetStyleGCs(style, arrow_rect.x, arrow_rect.y);
- gtk_paint_arrow(style, drawable, state_type, shadow_type, cliprect,
- gButtonArrowWidget, "arrow", GTK_ARROW_DOWN, TRUE,
- arrow_rect.x, arrow_rect.y, arrow_rect.width, arrow_rect.height);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_combo_box_entry_button_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect,
- GtkWidgetState* state,
- gboolean input_focus,
- GtkTextDirection direction)
-{
- gint x_displacement, y_displacement;
- GdkRectangle arrow_rect, real_arrow_rect;
- GtkStateType state_type = ConvertGtkState(state);
- GtkShadowType shadow_type = state->active ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
- GtkStyle* style;
-
- ensure_combo_box_entry_widgets();
-
- if (input_focus) {
- /* Some themes draw a complementary focus ring for the dropdown button
- * when the dropdown entry has focus */
- GTK_WIDGET_SET_FLAGS(gComboBoxEntryTextareaWidget, GTK_HAS_FOCUS);
- }
-
- moz_gtk_button_paint(drawable, rect, cliprect, state, GTK_RELIEF_NORMAL,
- gComboBoxEntryButtonWidget, direction);
-
- if (input_focus)
- GTK_WIDGET_UNSET_FLAGS(gComboBoxEntryTextareaWidget, GTK_HAS_FOCUS);
-
- calculate_button_inner_rect(gComboBoxEntryButtonWidget,
- rect, &arrow_rect, direction, FALSE);
- if (state_type == GTK_STATE_ACTIVE) {
- gtk_widget_style_get(gComboBoxEntryButtonWidget,
- "child-displacement-x", &x_displacement,
- "child-displacement-y", &y_displacement,
- NULL);
- arrow_rect.x += x_displacement;
- arrow_rect.y += y_displacement;
- }
-
- calculate_arrow_rect(gComboBoxEntryArrowWidget,
- &arrow_rect, &real_arrow_rect, direction);
-
- style = gComboBoxEntryArrowWidget->style;
- TSOffsetStyleGCs(style, real_arrow_rect.x, real_arrow_rect.y);
-
- gtk_paint_arrow(style, drawable, state_type, shadow_type, cliprect,
- gComboBoxEntryArrowWidget, "arrow", GTK_ARROW_DOWN, TRUE,
- real_arrow_rect.x, real_arrow_rect.y,
- real_arrow_rect.width, real_arrow_rect.height);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_container_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state,
- gboolean isradio, GtkTextDirection direction)
-{
- GtkStateType state_type = ConvertGtkState(state);
- GtkStyle* style;
- GtkWidget *widget;
- gboolean interior_focus;
- gint focus_width, focus_pad;
-
- if (isradio) {
- ensure_radiobutton_widget();
- widget = gRadiobuttonWidget;
- } else {
- ensure_checkbox_widget();
- widget = gCheckboxWidget;
- }
- gtk_widget_set_direction(widget, direction);
-
- style = widget->style;
- moz_gtk_widget_get_focus(widget, &interior_focus, &focus_width,
- &focus_pad);
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
-
- /* The detail argument for the gtk_paint_* calls below are "checkbutton"
- even for radio buttons, to match what gtk does. */
-
- /* this is for drawing a prelight box */
- if (state_type == GTK_STATE_PRELIGHT || state_type == GTK_STATE_ACTIVE) {
- gtk_paint_flat_box(style, drawable, GTK_STATE_PRELIGHT,
- GTK_SHADOW_ETCHED_OUT, cliprect, widget,
- "checkbutton",
- rect->x, rect->y, rect->width, rect->height);
- }
-
- if (state_type != GTK_STATE_NORMAL && state_type != GTK_STATE_PRELIGHT)
- state_type = GTK_STATE_NORMAL;
-
- if (state->focused && !interior_focus) {
- gtk_paint_focus(style, drawable, state_type, cliprect, widget,
- "checkbutton",
- rect->x, rect->y, rect->width, rect->height);
- }
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_toggle_label_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state,
- gboolean isradio, GtkTextDirection direction)
-{
- GtkStateType state_type;
- GtkStyle *style;
- GtkWidget *widget;
- gboolean interior_focus;
-
- if (!state->focused)
- return MOZ_GTK_SUCCESS;
-
- if (isradio) {
- ensure_radiobutton_widget();
- widget = gRadiobuttonWidget;
- } else {
- ensure_checkbox_widget();
- widget = gCheckboxWidget;
- }
- gtk_widget_set_direction(widget, direction);
-
- gtk_widget_style_get(widget, "interior-focus", &interior_focus, NULL);
- if (!interior_focus)
- return MOZ_GTK_SUCCESS;
-
- state_type = ConvertGtkState(state);
-
- style = widget->style;
- TSOffsetStyleGCs(style, rect->x, rect->y);
-
- /* Always "checkbutton" to match gtkcheckbutton.c */
- gtk_paint_focus(style, drawable, state_type, cliprect, widget,
- "checkbutton",
- rect->x, rect->y, rect->width, rect->height);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_toolbar_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkTextDirection direction)
-{
- GtkStyle* style;
- GtkShadowType shadow_type;
-
- ensure_toolbar_widget();
- gtk_widget_set_direction(gToolbarWidget, direction);
-
- style = gToolbarWidget->style;
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
-
- gtk_style_apply_default_background(style, drawable, TRUE,
- GTK_STATE_NORMAL,
- cliprect, rect->x, rect->y,
- rect->width, rect->height);
-
- gtk_widget_style_get(gToolbarWidget, "shadow-type", &shadow_type, NULL);
-
- gtk_paint_box (style, drawable, GTK_STATE_NORMAL, shadow_type,
- cliprect, gToolbarWidget, "toolbar",
- rect->x, rect->y, rect->width, rect->height);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_toolbar_separator_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect,
- GtkTextDirection direction)
-{
- GtkStyle* style;
- gint separator_width = 0;
- gint paint_width;
- gboolean wide_separators = FALSE;
-
- /* Defined as constants in GTK+ 2.10.14 */
- const double start_fraction = 0.2;
- const double end_fraction = 0.8;
-
- ensure_toolbar_separator_widget();
- gtk_widget_set_direction(gToolbarSeparatorWidget, direction);
-
- style = gToolbarSeparatorWidget->style;
-
- if (have_2_10)
- gtk_widget_style_get(gToolbarWidget,
- "wide-separators", &wide_separators,
- "separator-width", &separator_width,
- NULL);
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
-
- if (wide_separators) {
- if (separator_width > rect->width)
- separator_width = rect->width;
-
- gtk_paint_box(style, drawable,
- GTK_STATE_NORMAL, GTK_SHADOW_ETCHED_OUT,
- cliprect, gToolbarWidget, "vseparator",
- rect->x + (rect->width - separator_width) / 2,
- rect->y + rect->height * start_fraction,
- separator_width,
- rect->height * (end_fraction - start_fraction));
-
- } else {
- paint_width = style->xthickness;
-
- if (paint_width > rect->width)
- paint_width = rect->width;
-
- gtk_paint_vline(style, drawable,
- GTK_STATE_NORMAL, cliprect, gToolbarSeparatorWidget,
- "toolbar",
- rect->y + rect->height * start_fraction,
- rect->y + rect->height * end_fraction,
- rect->x + (rect->width - paint_width) / 2);
- }
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_tooltip_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkTextDirection direction)
-{
- GtkStyle* style;
-
- ensure_tooltip_widget();
- gtk_widget_set_direction(gTooltipWidget, direction);
-
- style = gtk_rc_get_style_by_paths(gtk_settings_get_default(),
- "gtk-tooltips", "GtkWindow",
- GTK_TYPE_WINDOW);
-
- style = gtk_style_attach(style, gTooltipWidget->window);
- TSOffsetStyleGCs(style, rect->x, rect->y);
- gtk_paint_flat_box(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
- cliprect, gTooltipWidget, "tooltip",
- rect->x, rect->y, rect->width, rect->height);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_resizer_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state,
- GtkTextDirection direction)
-{
- GtkStyle* style;
- GtkStateType state_type = ConvertGtkState(state);
-
- ensure_window_widget();
- gtk_widget_set_direction(gProtoWindow, direction);
-
- style = gProtoWindow->style;
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
-
- gtk_paint_resize_grip(style, drawable, state_type, cliprect, gProtoWindow,
- NULL, (direction == GTK_TEXT_DIR_LTR) ?
- GDK_WINDOW_EDGE_SOUTH_EAST :
- GDK_WINDOW_EDGE_SOUTH_WEST,
- rect->x, rect->y, rect->width, rect->height);
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_frame_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkTextDirection direction)
-{
- GtkStyle* style;
- GtkShadowType shadow_type;
-
- ensure_frame_widget();
- gtk_widget_set_direction(gFrameWidget, direction);
-
- style = gFrameWidget->style;
-
- gtk_widget_style_get(gStatusbarWidget, "shadow-type", &shadow_type, NULL);
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
- gtk_paint_shadow(style, drawable, GTK_STATE_NORMAL, shadow_type,
- cliprect, gFrameWidget, "frame", rect->x, rect->y,
- rect->width, rect->height);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_progressbar_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkTextDirection direction)
-{
- GtkStyle* style;
-
- ensure_progress_widget();
- gtk_widget_set_direction(gProgressWidget, direction);
-
- style = gProgressWidget->style;
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
- gtk_paint_box(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_IN,
- cliprect, gProgressWidget, "trough", rect->x, rect->y,
- rect->width, rect->height);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_progress_chunk_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkTextDirection direction)
-{
- GtkStyle* style;
-
- ensure_progress_widget();
- gtk_widget_set_direction(gProgressWidget, direction);
-
- style = gProgressWidget->style;
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
- gtk_paint_box(style, drawable, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT,
- cliprect, gProgressWidget, "bar", rect->x, rect->y,
- rect->width, rect->height);
-
- return MOZ_GTK_SUCCESS;
-}
-
-gint
-moz_gtk_get_tab_thickness(void)
-{
- ensure_tab_widget();
- if (YTHICKNESS(gTabWidget->style) < 2)
- return 2; /* some themes don't set ythickness correctly */
-
- return YTHICKNESS(gTabWidget->style);
-}
-
-static gint
-moz_gtk_tab_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkTabFlags flags,
- GtkTextDirection direction)
-{
- /* When the tab isn't selected, we just draw a notebook extension.
- * When it is selected, we overwrite the adjacent border of the tabpanel
- * touching the tab with a pierced border (called "the gap") to make the
- * tab appear physically attached to the tabpanel; see details below. */
-
- GtkStyle* style;
-
- ensure_tab_widget();
- gtk_widget_set_direction(gTabWidget, direction);
-
- style = gTabWidget->style;
- TSOffsetStyleGCs(style, rect->x, rect->y);
-
- if ((flags & MOZ_GTK_TAB_SELECTED) == 0) {
- /* Only draw the tab */
- gtk_paint_extension(style, drawable, GTK_STATE_ACTIVE, GTK_SHADOW_OUT,
- cliprect, gTabWidget, "tab",
- rect->x, rect->y, rect->width, rect->height,
- (flags & MOZ_GTK_TAB_BOTTOM) ?
- GTK_POS_TOP : GTK_POS_BOTTOM );
- } else {
- /* Draw the tab and the gap
- * We want the gap to be positionned exactly on the tabpanel top
- * border; since tabbox.css may set a negative margin so that the tab
- * frame rect already overlaps the tabpanel frame rect, we need to take
- * that into account when drawing. To that effect, nsNativeThemeGTK
- * passes us this negative margin (bmargin in the graphic below) in the
- * lowest bits of |flags|. We use it to set gap_voffset, the distance
- * between the top of the gap and the bottom of the tab (resp. the
- * bottom of the gap and the top of the tab when we draw a bottom tab),
- * while ensuring that the gap always touches the border of the tab,
- * i.e. 0 <= gap_voffset <= gap_height, to avoid surprinsing results
- * with big negative or positive margins.
- * Here is a graphical explanation in the case of top tabs:
- * ___________________________
- * / \
- * | T A B |
- * ----------|. . . . . . . . . . . . . . .|----- top of tabpanel
- * : ^ bmargin : ^
- * : | (-negative margin, : |
- * bottom : v passed in flags) : | gap_height
- * of -> :.............................: | (the size of the
- * the tab . part of the gap . | tabpanel top border)
- * . outside of the tab . v
- * ----------------------------------------------
- *
- * To draw the gap, we use gtk_paint_box_gap(), see comment in
- * moz_gtk_tabpanels_paint(). This box_gap is made 3 * gap_height tall,
- * which should suffice to ensure that the only visible border is the
- * pierced one. If the tab is in the middle, we make the box_gap begin
- * a bit to the left of the tab and end a bit to the right, adjusting
- * the gap position so it still is under the tab, because we want the
- * rendering of a gap in the middle of a tabpanel. This is the role of
- * the gints gap_{l,r}_offset. On the contrary, if the tab is the
- * first, we align the start border of the box_gap with the start
- * border of the tab (left if LTR, right if RTL), by setting the
- * appropriate offset to 0.*/
- gint gap_loffset, gap_roffset, gap_voffset, gap_height;
-
- /* Get height needed by the gap */
- gap_height = moz_gtk_get_tab_thickness();
-
- /* Extract gap_voffset from the first bits of flags */
- gap_voffset = flags & MOZ_GTK_TAB_MARGIN_MASK;
- if (gap_voffset > gap_height)
- gap_voffset = gap_height;
-
- /* Set gap_{l,r}_offset to appropriate values */
- gap_loffset = gap_roffset = 20; /* should be enough */
- if (flags & MOZ_GTK_TAB_FIRST) {
- if (direction == GTK_TEXT_DIR_RTL)
- gap_roffset = 0;
- else
- gap_loffset = 0;
- }
-
- if (flags & MOZ_GTK_TAB_BOTTOM) {
- /* Enlarge the cliprect to have room for the full gap height */
- cliprect->height += gap_height - gap_voffset;
- cliprect->y -= gap_height - gap_voffset;
-
- /* Draw the tab */
- gtk_paint_extension(style, drawable, GTK_STATE_NORMAL,
- GTK_SHADOW_OUT, cliprect, gTabWidget, "tab",
- rect->x, rect->y + gap_voffset, rect->width,
- rect->height - gap_voffset, GTK_POS_TOP);
-
- /* Draw the gap; erase with background color before painting in
- * case theme does not */
- gtk_style_apply_default_background(style, drawable, TRUE,
- GTK_STATE_NORMAL, cliprect,
- rect->x,
- rect->y + gap_voffset
- - gap_height,
- rect->width, gap_height);
- gtk_paint_box_gap(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
- cliprect, gTabWidget, "notebook",
- rect->x - gap_loffset,
- rect->y + gap_voffset - 3 * gap_height,
- rect->width + gap_loffset + gap_roffset,
- 3 * gap_height, GTK_POS_BOTTOM,
- gap_loffset, rect->width);
- } else {
- /* Enlarge the cliprect to have room for the full gap height */
- cliprect->height += gap_height - gap_voffset;
-
- /* Draw the tab */
- gtk_paint_extension(style, drawable, GTK_STATE_NORMAL,
- GTK_SHADOW_OUT, cliprect, gTabWidget, "tab",
- rect->x, rect->y, rect->width,
- rect->height - gap_voffset, GTK_POS_BOTTOM);
-
- /* Draw the gap; erase with background color before painting in
- * case theme does not */
- gtk_style_apply_default_background(style, drawable, TRUE,
- GTK_STATE_NORMAL, cliprect,
- rect->x,
- rect->y + rect->height
- - gap_voffset,
- rect->width, gap_height);
- gtk_paint_box_gap(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
- cliprect, gTabWidget, "notebook",
- rect->x - gap_loffset,
- rect->y + rect->height - gap_voffset,
- rect->width + gap_loffset + gap_roffset,
- 3 * gap_height, GTK_POS_TOP,
- gap_loffset, rect->width);
- }
-
- }
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_tabpanels_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkTextDirection direction)
-{
- /* We use gtk_paint_box_gap() to draw the tabpanels widget. gtk_paint_box()
- * draws an all-purpose box, which a lot of themes render differently.
- * A zero-width gap is still visible in most themes, so we hide it to the
- * left (10px should be enough) */
- GtkStyle* style;
-
- ensure_tab_widget();
- gtk_widget_set_direction(gTabWidget, direction);
-
- style = gTabWidget->style;
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
- gtk_paint_box_gap(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
- cliprect, gTabWidget, "notebook", rect->x, rect->y,
- rect->width, rect->height,
- GTK_POS_TOP, -10, 0);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_tab_scroll_arrow_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state,
- GtkArrowType arrow_type,
- GtkTextDirection direction)
-{
- GtkStateType state_type = ConvertGtkState(state);
- GtkShadowType shadow_type = state->active ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
- GtkStyle* style;
- gint arrow_size = MIN(rect->width, rect->height);
- gint x = rect->x + (rect->width - arrow_size) / 2;
- gint y = rect->y + (rect->height - arrow_size) / 2;
-
- ensure_tab_widget();
-
- style = gTabWidget->style;
- TSOffsetStyleGCs(style, rect->x, rect->y);
-
- if (direction == GTK_TEXT_DIR_RTL) {
- arrow_type = (arrow_type == GTK_ARROW_LEFT) ?
- GTK_ARROW_RIGHT : GTK_ARROW_LEFT;
- }
-
- gtk_paint_arrow(style, drawable, state_type, shadow_type, NULL,
- gTabWidget, "notebook", arrow_type, TRUE,
- x, y, arrow_size, arrow_size);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_menu_bar_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkTextDirection direction)
-{
- GtkStyle* style;
- GtkShadowType shadow_type;
- ensure_menu_bar_widget();
- gtk_widget_set_direction(gMenuBarWidget, direction);
-
- gtk_widget_style_get(gMenuBarWidget, "shadow-type", &shadow_type, NULL);
-
- style = gMenuBarWidget->style;
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
- gtk_style_apply_default_background(style, drawable, TRUE, GTK_STATE_NORMAL,
- cliprect, rect->x, rect->y,
- rect->width, rect->height);
-
- gtk_paint_box(style, drawable, GTK_STATE_NORMAL, shadow_type,
- cliprect, gMenuBarWidget, "menubar", rect->x, rect->y,
- rect->width, rect->height);
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_menu_popup_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkTextDirection direction)
-{
- GtkStyle* style;
- ensure_menu_popup_widget();
- gtk_widget_set_direction(gMenuPopupWidget, direction);
-
- style = gMenuPopupWidget->style;
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
- gtk_style_apply_default_background(style, drawable, TRUE, GTK_STATE_NORMAL,
- cliprect, rect->x, rect->y,
- rect->width, rect->height);
- gtk_paint_box(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
- cliprect, gMenuPopupWidget, "menu",
- rect->x, rect->y, rect->width, rect->height);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_menu_separator_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkTextDirection direction)
-{
- GtkStyle* style;
- gboolean wide_separators = FALSE;
- gint separator_height = 0;
- guint horizontal_padding = 0;
- gint paint_height;
-
- ensure_menu_separator_widget();
- gtk_widget_set_direction(gMenuSeparatorWidget, direction);
-
- style = gMenuSeparatorWidget->style;
-
- if (have_2_10)
- gtk_widget_style_get(gMenuSeparatorWidget,
- "wide-separators", &wide_separators,
- "separator-height", &separator_height,
- NULL);
-
- gtk_widget_style_get(gMenuSeparatorWidget,
- "horizontal-padding", &horizontal_padding,
- NULL);
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
-
- if (wide_separators) {
- if (separator_height > rect->height)
- separator_height = rect->height;
-
- gtk_paint_box(style, drawable,
- GTK_STATE_NORMAL, GTK_SHADOW_ETCHED_OUT,
- cliprect, gMenuSeparatorWidget, "hseparator",
- rect->x + horizontal_padding + style->xthickness,
- rect->y + (rect->height - separator_height - style->ythickness) / 2,
- rect->width - 2 * (horizontal_padding + style->xthickness),
- separator_height);
- } else {
- paint_height = style->ythickness;
- if (paint_height > rect->height)
- paint_height = rect->height;
-
- gtk_paint_hline(style, drawable,
- GTK_STATE_NORMAL, cliprect, gMenuSeparatorWidget,
- "menuitem",
- rect->x + horizontal_padding + style->xthickness,
- rect->x + rect->width - horizontal_padding - style->xthickness - 1,
- rect->y + (rect->height - style->ythickness) / 2);
- }
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_menu_item_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state,
- gint flags, GtkTextDirection direction)
-{
- GtkStyle* style;
- GtkShadowType shadow_type;
- GtkWidget* item_widget;
-
- if (state->inHover && !state->disabled) {
- if (flags & MOZ_TOPLEVEL_MENU_ITEM) {
- ensure_menu_bar_item_widget();
- item_widget = gMenuBarItemWidget;
- } else {
- ensure_menu_item_widget();
- item_widget = gMenuItemWidget;
- }
- gtk_widget_set_direction(item_widget, direction);
-
- style = item_widget->style;
- TSOffsetStyleGCs(style, rect->x, rect->y);
-
- gtk_widget_style_get(item_widget, "selected-shadow-type",
- &shadow_type, NULL);
-
- gtk_paint_box(style, drawable, GTK_STATE_PRELIGHT, shadow_type,
- cliprect, item_widget, "menuitem", rect->x, rect->y,
- rect->width, rect->height);
- }
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_menu_arrow_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state,
- GtkTextDirection direction)
-{
- GtkStyle* style;
- GtkStateType state_type = ConvertGtkState(state);
-
- ensure_menu_item_widget();
- gtk_widget_set_direction(gMenuItemWidget, direction);
-
- style = gMenuItemWidget->style;
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
- gtk_paint_arrow(style, drawable, state_type,
- (state_type == GTK_STATE_PRELIGHT) ? GTK_SHADOW_IN : GTK_SHADOW_OUT,
- cliprect, gMenuItemWidget, "menuitem",
- (direction == GTK_TEXT_DIR_LTR) ? GTK_ARROW_RIGHT : GTK_ARROW_LEFT,
- TRUE, rect->x, rect->y, rect->width, rect->height);
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_check_menu_item_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkWidgetState* state,
- gboolean checked, gboolean isradio,
- GtkTextDirection direction)
-{
- GtkStateType state_type = ConvertGtkState(state);
- GtkStyle* style;
- GtkShadowType shadow_type = (checked)?GTK_SHADOW_IN:GTK_SHADOW_OUT;
- gint offset;
- gint indicator_size;
- gint x, y;
-
- moz_gtk_menu_item_paint(drawable, rect, cliprect, state, FALSE, direction);
-
- ensure_check_menu_item_widget();
- gtk_widget_set_direction(gCheckMenuItemWidget, direction);
-
- gtk_widget_style_get (gCheckMenuItemWidget,
- "indicator-size", &indicator_size,
- NULL);
-
- if (checked || GTK_CHECK_MENU_ITEM(gCheckMenuItemWidget)->always_show_toggle) {
- style = gCheckMenuItemWidget->style;
-
- offset = GTK_CONTAINER(gCheckMenuItemWidget)->border_width +
- gCheckMenuItemWidget->style->xthickness + 2;
-
- /* while normally this "3" would be the horizontal-padding style value, passing it to Gecko
- as the value of menuitem padding causes problems with dropdowns (bug 406129), so in the menu.css
- file this is hardcoded as 3px. Yes it sucks, but we don't really have a choice. */
- x = (direction == GTK_TEXT_DIR_RTL) ?
- rect->width - indicator_size - offset - 3: rect->x + offset + 3;
- y = rect->y + (rect->height - indicator_size) / 2;
-
- TSOffsetStyleGCs(style, x, y);
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gCheckMenuItemWidget),
- checked);
-
- if (isradio) {
- gtk_paint_option(style, drawable, state_type, shadow_type, cliprect,
- gCheckMenuItemWidget, "option",
- x, y, indicator_size, indicator_size);
- } else {
- gtk_paint_check(style, drawable, state_type, shadow_type, cliprect,
- gCheckMenuItemWidget, "check",
- x, y, indicator_size, indicator_size);
- }
- }
-
- return MOZ_GTK_SUCCESS;
-}
-
-static gint
-moz_gtk_window_paint(GdkDrawable* drawable, GdkRectangle* rect,
- GdkRectangle* cliprect, GtkTextDirection direction)
-{
- GtkStyle* style;
-
- ensure_window_widget();
- gtk_widget_set_direction(gProtoWindow, direction);
-
- style = gProtoWindow->style;
-
- TSOffsetStyleGCs(style, rect->x, rect->y);
- gtk_style_apply_default_background(style, drawable, TRUE,
- GTK_STATE_NORMAL,
- cliprect, rect->x, rect->y,
- rect->width, rect->height);
- return MOZ_GTK_SUCCESS;
-}
-
-gint
-moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top,
- gint* right, gint* bottom, GtkTextDirection direction,
- gboolean inhtml)
-{
- GtkWidget* w;
-
- switch (widget) {
- case MOZ_GTK_BUTTON:
- {
- GtkBorder inner_border;
- gboolean interior_focus;
- gint focus_width, focus_pad;
-
- ensure_button_widget();
- *left = *top = *right = *bottom = GTK_CONTAINER(gButtonWidget)->border_width;
-
- /* Don't add this padding in HTML, otherwise the buttons will
- become too big and stuff the layout. */
- if (!inhtml) {
- moz_gtk_widget_get_focus(gButtonWidget, &interior_focus, &focus_width, &focus_pad);
- moz_gtk_button_get_inner_border(gButtonWidget, &inner_border);
- *left += focus_width + focus_pad + inner_border.left;
- *right += focus_width + focus_pad + inner_border.right;
- *top += focus_width + focus_pad + inner_border.top;
- *bottom += focus_width + focus_pad + inner_border.bottom;
- }
-
- *left += gButtonWidget->style->xthickness;
- *right += gButtonWidget->style->xthickness;
- *top += gButtonWidget->style->ythickness;
- *bottom += gButtonWidget->style->ythickness;
- return MOZ_GTK_SUCCESS;
- }
- case MOZ_GTK_ENTRY:
- ensure_entry_widget();
- w = gEntryWidget;
- break;
- case MOZ_GTK_TREEVIEW:
- ensure_tree_view_widget();
- w = gTreeViewWidget;
- break;
- case MOZ_GTK_TREE_HEADER_CELL:
- {
- /* A Tree Header in GTK is just a different styled button
- * It must be placed in a TreeView for getting the correct style
- * assigned.
- * That is why the following code is the same as for MOZ_GTK_BUTTON.
- * */
-
- GtkBorder inner_border;
- gboolean interior_focus;
- gint focus_width, focus_pad;
-
- ensure_tree_header_cell_widget();
- *left = *top = *right = *bottom = GTK_CONTAINER(gTreeHeaderCellWidget)->border_width;
-
- moz_gtk_widget_get_focus(gTreeHeaderCellWidget, &interior_focus, &focus_width, &focus_pad);
- moz_gtk_button_get_inner_border(gTreeHeaderCellWidget, &inner_border);
- *left += focus_width + focus_pad + inner_border.left;
- *right += focus_width + focus_pad + inner_border.right;
- *top += focus_width + focus_pad + inner_border.top;
- *bottom += focus_width + focus_pad + inner_border.bottom;
-
- *left += gTreeHeaderCellWidget->style->xthickness;
- *right += gTreeHeaderCellWidget->style->xthickness;
- *top += gTreeHeaderCellWidget->style->ythickness;
- *bottom += gTreeHeaderCellWidget->style->ythickness;
- return MOZ_GTK_SUCCESS;
- }
- case MOZ_GTK_TREE_HEADER_SORTARROW:
- ensure_tree_header_cell_widget();
- w = gTreeHeaderSortArrowWidget;
- break;
- case MOZ_GTK_DROPDOWN_ENTRY:
- ensure_combo_box_entry_widgets();
- w = gComboBoxEntryTextareaWidget;
- break;
- case MOZ_GTK_DROPDOWN_ARROW:
- ensure_combo_box_entry_widgets();
- w = gComboBoxEntryButtonWidget;
- break;
- case MOZ_GTK_DROPDOWN:
- {
- /* We need to account for the arrow on the dropdown, so text
- * doesn't come too close to the arrow, or in some cases spill
- * into the arrow. */
- gboolean ignored_interior_focus, wide_separators = FALSE;
- gint focus_width, focus_pad, separator_width;
- GtkRequisition arrow_req;
-
- ensure_combo_box_widgets();
-
- *left = GTK_CONTAINER(gComboBoxButtonWidget)->border_width;
-
- if (!inhtml) {
- moz_gtk_widget_get_focus(gComboBoxButtonWidget,
- &ignored_interior_focus,
- &focus_width, &focus_pad);
- *left += focus_width + focus_pad;
- }
-
- *top = *left + gComboBoxButtonWidget->style->ythickness;
- *left += gComboBoxButtonWidget->style->xthickness;
-
- *right = *left; *bottom = *top;
-
- /* If there is no separator, don't try to count its width. */
- separator_width = 0;
- if (gComboBoxSeparatorWidget) {
- if (have_2_10)
- gtk_widget_style_get(gComboBoxSeparatorWidget,
- "wide-separators", &wide_separators,
- "separator-width", &separator_width,
- NULL);
-
- if (!wide_separators)
- separator_width =
- XTHICKNESS(gComboBoxSeparatorWidget->style);
- }
-
- gtk_widget_size_request(gComboBoxArrowWidget, &arrow_req);
-
- if (direction == GTK_TEXT_DIR_RTL)
- *left += separator_width + arrow_req.width;
- else
- *right += separator_width + arrow_req.width;
-
- return MOZ_GTK_SUCCESS;
- }
- case MOZ_GTK_TABPANELS:
- ensure_tab_widget();
- w = gTabWidget;
- break;
- case MOZ_GTK_PROGRESSBAR:
- ensure_progress_widget();
- w = gProgressWidget;
- break;
- case MOZ_GTK_SPINBUTTON_ENTRY:
- case MOZ_GTK_SPINBUTTON_UP:
- case MOZ_GTK_SPINBUTTON_DOWN:
- ensure_spin_widget();
- w = gSpinWidget;
- break;
- case MOZ_GTK_SCALE_HORIZONTAL:
- ensure_scale_widget();
- w = gHScaleWidget;
- break;
- case MOZ_GTK_SCALE_VERTICAL:
- ensure_scale_widget();
- w = gVScaleWidget;
- break;
- case MOZ_GTK_FRAME:
- ensure_frame_widget();
- w = gFrameWidget;
- break;
- case MOZ_GTK_CHECKBUTTON_LABEL:
- case MOZ_GTK_RADIOBUTTON_LABEL:
- {
- gboolean interior_focus;
- gint focus_width, focus_pad;
-
- /* If the focus is interior, then the label has a border of
- (focus_width + focus_pad). */
- if (widget == MOZ_GTK_CHECKBUTTON_LABEL) {
- ensure_checkbox_widget();
- moz_gtk_widget_get_focus(gCheckboxWidget, &interior_focus,
- &focus_width, &focus_pad);
- }
- else {
- ensure_radiobutton_widget();
- moz_gtk_widget_get_focus(gRadiobuttonWidget, &interior_focus,
- &focus_width, &focus_pad);
- }
-
- if (interior_focus)
- *left = *top = *right = *bottom = (focus_width + focus_pad);
- else
- *left = *top = *right = *bottom = 0;
-
- return MOZ_GTK_SUCCESS;
- }
-
- case MOZ_GTK_CHECKBUTTON_CONTAINER:
- case MOZ_GTK_RADIOBUTTON_CONTAINER:
- {
- gboolean interior_focus;
- gint focus_width, focus_pad;
-
- /* If the focus is _not_ interior, then the container has a border
- of (focus_width + focus_pad). */
- if (widget == MOZ_GTK_CHECKBUTTON_CONTAINER) {
- ensure_checkbox_widget();
- moz_gtk_widget_get_focus(gCheckboxWidget, &interior_focus,
- &focus_width, &focus_pad);
- w = gCheckboxWidget;
- } else {
- ensure_radiobutton_widget();
- moz_gtk_widget_get_focus(gRadiobuttonWidget, &interior_focus,
- &focus_width, &focus_pad);
- w = gRadiobuttonWidget;
- }
-
- *left = *top = *right = *bottom = GTK_CONTAINER(w)->border_width;
-
- if (!interior_focus) {
- *left += (focus_width + focus_pad);
- *right += (focus_width + focus_pad);
- *top += (focus_width + focus_pad);
- *bottom += (focus_width + focus_pad);
- }
-
- return MOZ_GTK_SUCCESS;
- }
- case MOZ_GTK_MENUPOPUP:
- ensure_menu_popup_widget();
- w = gMenuPopupWidget;
- break;
- case MOZ_GTK_MENUITEM:
- ensure_menu_item_widget();
- ensure_menu_bar_item_widget();
- w = gMenuItemWidget;
- break;
- case MOZ_GTK_CHECKMENUITEM:
- case MOZ_GTK_RADIOMENUITEM:
- ensure_check_menu_item_widget();
- w = gCheckMenuItemWidget;
- break;
- case MOZ_GTK_TAB:
- ensure_tab_widget();
- w = gTabWidget;
- break;
- /* These widgets have no borders, since they are not containers. */
- case MOZ_GTK_SPLITTER_HORIZONTAL:
- case MOZ_GTK_SPLITTER_VERTICAL:
- case MOZ_GTK_CHECKBUTTON:
- case MOZ_GTK_RADIOBUTTON:
- case MOZ_GTK_SCROLLBAR_BUTTON:
- case MOZ_GTK_SCROLLBAR_TRACK_HORIZONTAL:
- case MOZ_GTK_SCROLLBAR_TRACK_VERTICAL:
- case MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL:
- case MOZ_GTK_SCROLLBAR_THUMB_VERTICAL:
- case MOZ_GTK_SCALE_THUMB_HORIZONTAL:
- case MOZ_GTK_SCALE_THUMB_VERTICAL:
- case MOZ_GTK_GRIPPER:
- case MOZ_GTK_PROGRESS_CHUNK:
- case MOZ_GTK_EXPANDER:
- case MOZ_GTK_TREEVIEW_EXPANDER:
- case MOZ_GTK_TOOLBAR_SEPARATOR:
- case MOZ_GTK_MENUSEPARATOR:
- /* These widgets have no borders.*/
- case MOZ_GTK_SPINBUTTON:
- case MOZ_GTK_TOOLTIP:
- case MOZ_GTK_WINDOW:
- case MOZ_GTK_RESIZER:
- case MOZ_GTK_MENUARROW:
- case MOZ_GTK_TOOLBARBUTTON_ARROW:
- case MOZ_GTK_TOOLBAR:
- case MOZ_GTK_MENUBAR:
- case MOZ_GTK_TAB_SCROLLARROW:
- case MOZ_GTK_ENTRY_CARET:
- *left = *top = *right = *bottom = 0;
- return MOZ_GTK_SUCCESS;
- default:
- g_warning("Unsupported widget type: %d", widget);
- return MOZ_GTK_UNKNOWN_WIDGET;
- }
-
- *right = *left = XTHICKNESS(w->style);
- *bottom = *top = YTHICKNESS(w->style);
-
- return MOZ_GTK_SUCCESS;
-}
-
-gint
-moz_gtk_get_combo_box_entry_button_size(gint* width, gint* height)
-{
- /*
- * We get the requisition of the drop down button, which includes
- * all padding, border and focus line widths the button uses,
- * as well as the minimum arrow size and its padding
- * */
- GtkRequisition requisition;
- ensure_combo_box_entry_widgets();
-
- gtk_widget_size_request(gComboBoxEntryButtonWidget, &requisition);
- *width = requisition.width;
- *height = requisition.height;
-
- return MOZ_GTK_SUCCESS;
-}
-
-gint
-moz_gtk_get_tab_scroll_arrow_size(gint* width, gint* height)
-{
- gint arrow_size = 16;
-
- ensure_tab_widget();
- if (have_2_10)
- gtk_widget_style_get(gTabWidget,
- "scroll-arrow-hlength", &arrow_size,
- NULL);
-
- *height = *width = arrow_size;
-
- return MOZ_GTK_SUCCESS;
-}
-
-gint
-moz_gtk_get_downarrow_size(gint* width, gint* height)
-{
- GtkRequisition requisition;
- ensure_button_arrow_widget();
-
- gtk_widget_size_request(gButtonArrowWidget, &requisition);
- *width = requisition.width;
- *height = requisition.height;
-
- return MOZ_GTK_SUCCESS;
-}
-
-gint
-moz_gtk_get_toolbar_separator_width(gint* size)
-{
- gboolean wide_separators = FALSE;
- gint separator_width = 0;
- GtkStyle* style;
-
- ensure_toolbar_widget();
-
- style = gToolbarWidget->style;
-
- if (have_2_10)
- gtk_widget_style_get(gToolbarWidget,
- "wide-separators", &wide_separators,
- "separator-width", &separator_width,
- NULL);
-
- gtk_widget_style_get(gToolbarWidget,
- "space-size", size,
- NULL);
-
- /* Just in case... */
- *size = MAX(*size, (wide_separators ? separator_width : style->xthickness));
-
- return MOZ_GTK_SUCCESS;
-}
-
-gint
-moz_gtk_get_expander_size(gint* size)
-{
- ensure_expander_widget();
- gtk_widget_style_get(gExpanderWidget,
- "expander-size", size,
- NULL);
-
- return MOZ_GTK_SUCCESS;
-}
-
-gint
-moz_gtk_get_treeview_expander_size(gint* size)
-{
- ensure_tree_view_widget();
- gtk_widget_style_get(gTreeViewWidget,
- "expander-size", size,
- NULL);
-
- return MOZ_GTK_SUCCESS;
-}
-
-gint
-moz_gtk_get_menu_separator_height(gint *size)
-{
- gboolean wide_separators = FALSE;
- gint separator_height = 0;
-
- ensure_menu_separator_widget();
-
- if (have_2_10)
- gtk_widget_style_get(gMenuSeparatorWidget,
- "wide-separators", &wide_separators,
- "separator-height", &separator_height,
- NULL);
-
- if (wide_separators)
- *size = separator_height + gMenuSeparatorWidget->style->ythickness;
- else
- *size = gMenuSeparatorWidget->style->ythickness * 2;
-
- return MOZ_GTK_SUCCESS;
-}
-
-gint
-moz_gtk_get_scalethumb_metrics(GtkOrientation orient, gint* thumb_length, gint* thumb_height)
-{
- GtkWidget* widget;
-
- ensure_scale_widget();
- widget = ((orient == GTK_ORIENTATION_HORIZONTAL) ? gHScaleWidget : gVScaleWidget);
-
- gtk_widget_style_get (widget,
- "slider_length", thumb_length,
- "slider_width", thumb_height,
- NULL);
-
- return MOZ_GTK_SUCCESS;
-}
-
-gint
-moz_gtk_get_scrollbar_metrics(MozGtkScrollbarMetrics *metrics)
-{
- ensure_scrollbar_widget();
-
- gtk_widget_style_get (gHorizScrollbarWidget,
- "slider_width", &metrics->slider_width,
- "trough_border", &metrics->trough_border,
- "stepper_size", &metrics->stepper_size,
- "stepper_spacing", &metrics->stepper_spacing,
- NULL);
-
- metrics->min_slider_size =
- GTK_RANGE(gHorizScrollbarWidget)->min_slider_size;
-
- return MOZ_GTK_SUCCESS;
-}
-
-gboolean
-moz_gtk_images_in_menus()
-{
- gboolean result;
- GtkSettings* settings;
-
- ensure_image_menu_item_widget();
- settings = gtk_widget_get_settings(gImageMenuItemWidget);
-
- g_object_get(settings, "gtk-menu-images", &result, NULL);
- return result;
-}
-
-gint
-moz_gtk_widget_paint(GtkThemeWidgetType widget, GdkDrawable* drawable,
- GdkRectangle* rect, GdkRectangle* cliprect,
- GtkWidgetState* state, gint flags,
- GtkTextDirection direction)
-{
- switch (widget) {
- case MOZ_GTK_BUTTON:
- if (state->depressed) {
- ensure_toggle_button_widget();
- return moz_gtk_button_paint(drawable, rect, cliprect, state,
- (GtkReliefStyle) flags,
- gToggleButtonWidget, direction);
- }
- ensure_button_widget();
- return moz_gtk_button_paint(drawable, rect, cliprect, state,
- (GtkReliefStyle) flags, gButtonWidget,
- direction);
- break;
- case MOZ_GTK_CHECKBUTTON:
- case MOZ_GTK_RADIOBUTTON:
- return moz_gtk_toggle_paint(drawable, rect, cliprect, state,
- (gboolean) flags,
- (widget == MOZ_GTK_RADIOBUTTON),
- direction);
- break;
- case MOZ_GTK_SCROLLBAR_BUTTON:
- return moz_gtk_scrollbar_button_paint(drawable, rect, cliprect, state,
- (GtkScrollbarButtonFlags) flags,
- direction);
- break;
- case MOZ_GTK_SCROLLBAR_TRACK_HORIZONTAL:
- case MOZ_GTK_SCROLLBAR_TRACK_VERTICAL:
- return moz_gtk_scrollbar_trough_paint(widget, drawable, rect,
- cliprect, state, direction);
- break;
- case MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL:
- case MOZ_GTK_SCROLLBAR_THUMB_VERTICAL:
- return moz_gtk_scrollbar_thumb_paint(widget, drawable, rect,
- cliprect, state, direction);
- break;
- case MOZ_GTK_SCALE_HORIZONTAL:
- case MOZ_GTK_SCALE_VERTICAL:
- return moz_gtk_scale_paint(drawable, rect, cliprect, state,
- (GtkOrientation) flags, direction);
- break;
- case MOZ_GTK_SCALE_THUMB_HORIZONTAL:
- case MOZ_GTK_SCALE_THUMB_VERTICAL:
- return moz_gtk_scale_thumb_paint(drawable, rect, cliprect, state,
- (GtkOrientation) flags, direction);
- break;
- case MOZ_GTK_SPINBUTTON:
- return moz_gtk_spin_paint(drawable, rect, direction);
- break;
- case MOZ_GTK_SPINBUTTON_UP:
- case MOZ_GTK_SPINBUTTON_DOWN:
- return moz_gtk_spin_updown_paint(drawable, rect,
- (widget == MOZ_GTK_SPINBUTTON_DOWN),
- state, direction);
- break;
- case MOZ_GTK_SPINBUTTON_ENTRY:
- ensure_spin_widget();
- return moz_gtk_entry_paint(drawable, rect, cliprect, state,
- gSpinWidget, direction);
- break;
- case MOZ_GTK_GRIPPER:
- return moz_gtk_gripper_paint(drawable, rect, cliprect, state,
- direction);
- break;
- case MOZ_GTK_TREEVIEW:
- return moz_gtk_treeview_paint(drawable, rect, cliprect, state,
- direction);
- break;
- case MOZ_GTK_TREE_HEADER_CELL:
- return moz_gtk_tree_header_cell_paint(drawable, rect, cliprect, state,
- flags, direction);
- break;
- case MOZ_GTK_TREE_HEADER_SORTARROW:
- return moz_gtk_tree_header_sort_arrow_paint(drawable, rect, cliprect,
- state,
- (GtkArrowType) flags,
- direction);
- break;
- case MOZ_GTK_TREEVIEW_EXPANDER:
- return moz_gtk_treeview_expander_paint(drawable, rect, cliprect, state,
- (GtkExpanderStyle) flags, direction);
- break;
- case MOZ_GTK_EXPANDER:
- return moz_gtk_expander_paint(drawable, rect, cliprect, state,
- (GtkExpanderStyle) flags, direction);
- break;
- case MOZ_GTK_ENTRY:
- ensure_entry_widget();
- return moz_gtk_entry_paint(drawable, rect, cliprect, state,
- gEntryWidget, direction);
- break;
- case MOZ_GTK_ENTRY_CARET:
- return moz_gtk_caret_paint(drawable, rect, cliprect, direction);
- break;
- case MOZ_GTK_DROPDOWN:
- return moz_gtk_combo_box_paint(drawable, rect, cliprect, state,
- (gboolean) flags, direction);
- break;
- case MOZ_GTK_DROPDOWN_ARROW:
- return moz_gtk_combo_box_entry_button_paint(drawable, rect, cliprect,
- state, flags, direction);
- break;
- case MOZ_GTK_DROPDOWN_ENTRY:
- ensure_combo_box_entry_widgets();
- return moz_gtk_entry_paint(drawable, rect, cliprect, state,
- gComboBoxEntryTextareaWidget, direction);
- break;
- case MOZ_GTK_CHECKBUTTON_CONTAINER:
- case MOZ_GTK_RADIOBUTTON_CONTAINER:
- return moz_gtk_container_paint(drawable, rect, cliprect, state,
- (widget == MOZ_GTK_RADIOBUTTON_CONTAINER),
- direction);
- break;
- case MOZ_GTK_CHECKBUTTON_LABEL:
- case MOZ_GTK_RADIOBUTTON_LABEL:
- return moz_gtk_toggle_label_paint(drawable, rect, cliprect, state,
- (widget == MOZ_GTK_RADIOBUTTON_LABEL),
- direction);
- break;
- case MOZ_GTK_TOOLBAR:
- return moz_gtk_toolbar_paint(drawable, rect, cliprect, direction);
- break;
- case MOZ_GTK_TOOLBAR_SEPARATOR:
- return moz_gtk_toolbar_separator_paint(drawable, rect, cliprect,
- direction);
- break;
- case MOZ_GTK_TOOLTIP:
- return moz_gtk_tooltip_paint(drawable, rect, cliprect, direction);
- break;
- case MOZ_GTK_FRAME:
- return moz_gtk_frame_paint(drawable, rect, cliprect, direction);
- break;
- case MOZ_GTK_RESIZER:
- return moz_gtk_resizer_paint(drawable, rect, cliprect, state,
- direction);
- break;
- case MOZ_GTK_PROGRESSBAR:
- return moz_gtk_progressbar_paint(drawable, rect, cliprect, direction);
- break;
- case MOZ_GTK_PROGRESS_CHUNK:
- return moz_gtk_progress_chunk_paint(drawable, rect, cliprect,
- direction);
- break;
- case MOZ_GTK_TAB:
- return moz_gtk_tab_paint(drawable, rect, cliprect,
- (GtkTabFlags) flags, direction);
- break;
- case MOZ_GTK_TABPANELS:
- return moz_gtk_tabpanels_paint(drawable, rect, cliprect, direction);
- break;
- case MOZ_GTK_TAB_SCROLLARROW:
- return moz_gtk_tab_scroll_arrow_paint(drawable, rect, cliprect, state,
- (GtkArrowType) flags, direction);
- break;
- case MOZ_GTK_MENUBAR:
- return moz_gtk_menu_bar_paint(drawable, rect, cliprect, direction);
- break;
- case MOZ_GTK_MENUPOPUP:
- return moz_gtk_menu_popup_paint(drawable, rect, cliprect, direction);
- break;
- case MOZ_GTK_MENUSEPARATOR:
- return moz_gtk_menu_separator_paint(drawable, rect, cliprect,
- direction);
- break;
- case MOZ_GTK_MENUITEM:
- return moz_gtk_menu_item_paint(drawable, rect, cliprect, state, flags,
- direction);
- break;
- case MOZ_GTK_MENUARROW:
- return moz_gtk_menu_arrow_paint(drawable, rect, cliprect, state,
- direction);
- break;
- case MOZ_GTK_TOOLBARBUTTON_ARROW:
- return moz_gtk_downarrow_paint(drawable, rect, cliprect, state);
- break;
- case MOZ_GTK_CHECKMENUITEM:
- case MOZ_GTK_RADIOMENUITEM:
- return moz_gtk_check_menu_item_paint(drawable, rect, cliprect, state,
- (gboolean) flags,
- (widget == MOZ_GTK_RADIOMENUITEM),
- direction);
- break;
- case MOZ_GTK_SPLITTER_HORIZONTAL:
- return moz_gtk_vpaned_paint(drawable, rect, cliprect, state);
- break;
- case MOZ_GTK_SPLITTER_VERTICAL:
- return moz_gtk_hpaned_paint(drawable, rect, cliprect, state);
- break;
- case MOZ_GTK_WINDOW:
- return moz_gtk_window_paint(drawable, rect, cliprect, direction);
- break;
- default:
- g_warning("Unknown widget type: %d", widget);
- }
-
- return MOZ_GTK_UNKNOWN_WIDGET;
-}
-
-GtkWidget* moz_gtk_get_scrollbar_widget(void)
-{
- if (!is_initialized)
- return NULL;
- ensure_scrollbar_widget();
- return gHorizScrollbarWidget;
-}
-
-gint
-moz_gtk_shutdown()
-{
- GtkWidgetClass *entry_class;
-
- if (gTooltipWidget)
- gtk_widget_destroy(gTooltipWidget);
- /* This will destroy all of our widgets */
- if (gProtoWindow)
- gtk_widget_destroy(gProtoWindow);
-
- gProtoWindow = NULL;
- gButtonWidget = NULL;
- gToggleButtonWidget = NULL;
- gButtonArrowWidget = NULL;
- gCheckboxWidget = NULL;
- gRadiobuttonWidget = NULL;
- gHorizScrollbarWidget = NULL;
- gVertScrollbarWidget = NULL;
- gSpinWidget = NULL;
- gHScaleWidget = NULL;
- gVScaleWidget = NULL;
- gEntryWidget = NULL;
- gComboBoxWidget = NULL;
- gComboBoxButtonWidget = NULL;
- gComboBoxSeparatorWidget = NULL;
- gComboBoxArrowWidget = NULL;
- gComboBoxEntryWidget = NULL;
- gComboBoxEntryButtonWidget = NULL;
- gComboBoxEntryArrowWidget = NULL;
- gComboBoxEntryTextareaWidget = NULL;
- gHandleBoxWidget = NULL;
- gToolbarWidget = NULL;
- gStatusbarWidget = NULL;
- gFrameWidget = NULL;
- gProgressWidget = NULL;
- gTabWidget = NULL;
- gTooltipWidget = NULL;
- gMenuBarWidget = NULL;
- gMenuBarItemWidget = NULL;
- gMenuPopupWidget = NULL;
- gMenuItemWidget = NULL;
- gImageMenuItemWidget = NULL;
- gCheckMenuItemWidget = NULL;
- gTreeViewWidget = NULL;
- gMiddleTreeViewColumn = NULL;
- gTreeHeaderCellWidget = NULL;
- gTreeHeaderSortArrowWidget = NULL;
- gExpanderWidget = NULL;
- gToolbarSeparatorWidget = NULL;
- gMenuSeparatorWidget = NULL;
- gHPanedWidget = NULL;
- gVPanedWidget = NULL;
- gScrolledWindowWidget = NULL;
-
- entry_class = g_type_class_peek(GTK_TYPE_ENTRY);
- g_type_class_unref(entry_class);
-
- is_initialized = FALSE;
-
- return MOZ_GTK_SUCCESS;
-}
diff --git a/WebCore/platform/gtk/gtkdrawing.h b/WebCore/platform/gtk/gtkdrawing.h
deleted file mode 100644
index 6e44d4a..0000000
--- a/WebCore/platform/gtk/gtkdrawing.h
+++ /dev/null
@@ -1,428 +0,0 @@
-/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Brian Ryner <bryner@brianryner.com> (Original Author)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-/**
- * gtkdrawing.h: GTK widget rendering utilities
- *
- * gtkdrawing provides an API for rendering GTK widgets in the
- * current theme to a pixmap or window, without requiring an actual
- * widget instantiation, similar to the Macintosh Appearance Manager
- * or Windows XP's DrawThemeBackground() API.
- */
-
-#ifndef _GTK_DRAWING_H_
-#define _GTK_DRAWING_H_
-
-#include <gdk/gdk.h>
-#include <gtk/gtkstyle.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/*** type definitions ***/
-typedef struct {
- guint8 active;
- guint8 focused;
- guint8 inHover;
- guint8 disabled;
- guint8 isDefault;
- guint8 canDefault;
- /* The depressed state is for buttons which remain active for a longer period:
- * activated toggle buttons or buttons showing a popup menu. */
- guint8 depressed;
- gint32 curpos; /* curpos and maxpos are used for scrollbars */
- gint32 maxpos;
-} GtkWidgetState;
-
-typedef struct {
- gint slider_width;
- gint trough_border;
- gint stepper_size;
- gint stepper_spacing;
- gint min_slider_size;
-} MozGtkScrollbarMetrics;
-
-typedef enum {
- MOZ_GTK_STEPPER_DOWN = 1 << 0,
- MOZ_GTK_STEPPER_BOTTOM = 1 << 1,
- MOZ_GTK_STEPPER_VERTICAL = 1 << 2
-} GtkScrollbarButtonFlags;
-
-/** flags for tab state **/
-typedef enum {
- /* first eight bits are used to pass a margin */
- MOZ_GTK_TAB_MARGIN_MASK = 0xFF,
- /* bottom tabs */
- MOZ_GTK_TAB_BOTTOM = 1 << 8,
- /* the first tab in the group */
- MOZ_GTK_TAB_FIRST = 1 << 9,
- /* the selected tab */
- MOZ_GTK_TAB_SELECTED = 1 << 10
-} GtkTabFlags;
-
-/** flags for menuitems **/
-typedef enum {
- /* menuitem is part of the menubar */
- MOZ_TOPLEVEL_MENU_ITEM = 1 << 0
-} GtkMenuItemFlags;
-
-/* function type for moz_gtk_enable_style_props */
-typedef gint (*style_prop_t)(GtkStyle*, const gchar*, gint);
-
-/*** result/error codes ***/
-#define MOZ_GTK_SUCCESS 0
-#define MOZ_GTK_UNKNOWN_WIDGET -1
-#define MOZ_GTK_UNSAFE_THEME -2
-
-/*** widget type constants ***/
-typedef enum {
- /* Paints a GtkButton. flags is a GtkReliefStyle. */
- MOZ_GTK_BUTTON,
- /* Paints a GtkCheckButton. flags is a boolean, 1=checked, 0=not checked. */
- MOZ_GTK_CHECKBUTTON,
- /* Paints a GtkRadioButton. flags is a boolean, 1=checked, 0=not checked. */
- MOZ_GTK_RADIOBUTTON,
- /**
- * Paints the button of a GtkScrollbar. flags is a GtkArrowType giving
- * the arrow direction.
- */
- MOZ_GTK_SCROLLBAR_BUTTON,
- /* Paints the trough (track) of a GtkScrollbar. */
- MOZ_GTK_SCROLLBAR_TRACK_HORIZONTAL,
- MOZ_GTK_SCROLLBAR_TRACK_VERTICAL,
- /* Paints the slider (thumb) of a GtkScrollbar. */
- MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL,
- MOZ_GTK_SCROLLBAR_THUMB_VERTICAL,
- /* Paints a GtkScale. */
- MOZ_GTK_SCALE_HORIZONTAL,
- MOZ_GTK_SCALE_VERTICAL,
- /* Paints a GtkScale thumb. */
- MOZ_GTK_SCALE_THUMB_HORIZONTAL,
- MOZ_GTK_SCALE_THUMB_VERTICAL,
- /* Paints a GtkSpinButton */
- MOZ_GTK_SPINBUTTON,
- MOZ_GTK_SPINBUTTON_UP,
- MOZ_GTK_SPINBUTTON_DOWN,
- MOZ_GTK_SPINBUTTON_ENTRY,
- /* Paints the gripper of a GtkHandleBox. */
- MOZ_GTK_GRIPPER,
- /* Paints a GtkEntry. */
- MOZ_GTK_ENTRY,
- /* Paints the native caret (or in GTK-speak: insertion cursor) */
- MOZ_GTK_ENTRY_CARET,
- /* Paints a GtkOptionMenu. */
- MOZ_GTK_DROPDOWN,
- /* Paints a dropdown arrow (a GtkButton containing a down GtkArrow). */
- MOZ_GTK_DROPDOWN_ARROW,
- /* Paints an entry in an editable option menu */
- MOZ_GTK_DROPDOWN_ENTRY,
- /* Paints the container part of a GtkCheckButton. */
- MOZ_GTK_CHECKBUTTON_CONTAINER,
- /* Paints the container part of a GtkRadioButton. */
- MOZ_GTK_RADIOBUTTON_CONTAINER,
- /* Paints the label of a GtkCheckButton (focus outline) */
- MOZ_GTK_CHECKBUTTON_LABEL,
- /* Paints the label of a GtkRadioButton (focus outline) */
- MOZ_GTK_RADIOBUTTON_LABEL,
- /* Paints the background of a GtkHandleBox. */
- MOZ_GTK_TOOLBAR,
- /* Paints a toolbar separator */
- MOZ_GTK_TOOLBAR_SEPARATOR,
- /* Paints a GtkToolTip */
- MOZ_GTK_TOOLTIP,
- /* Paints a GtkFrame (e.g. a status bar panel). */
- MOZ_GTK_FRAME,
- /* Paints a resize grip for a GtkWindow */
- MOZ_GTK_RESIZER,
- /* Paints a GtkProgressBar. */
- MOZ_GTK_PROGRESSBAR,
- /* Paints a progress chunk of a GtkProgressBar. */
- MOZ_GTK_PROGRESS_CHUNK,
- /* Paints a tab of a GtkNotebook. flags is a GtkTabFlags, defined above. */
- MOZ_GTK_TAB,
- /* Paints the background and border of a GtkNotebook. */
- MOZ_GTK_TABPANELS,
- /* Paints a GtkArrow for a GtkNotebook. flags is a GtkArrowType. */
- MOZ_GTK_TAB_SCROLLARROW,
- /* Paints the background and border of a GtkTreeView */
- MOZ_GTK_TREEVIEW,
- /* Paints treeheader cells */
- MOZ_GTK_TREE_HEADER_CELL,
- /* Paints sort arrows in treeheader cells */
- MOZ_GTK_TREE_HEADER_SORTARROW,
- /* Paints an expander for a GtkTreeView */
- MOZ_GTK_TREEVIEW_EXPANDER,
- /* Paints a GtkExpander */
- MOZ_GTK_EXPANDER,
- /* Paints the background of the menu bar. */
- MOZ_GTK_MENUBAR,
- /* Paints the background of menus, context menus. */
- MOZ_GTK_MENUPOPUP,
- /* Paints the arrow of menuitems that contain submenus */
- MOZ_GTK_MENUARROW,
- /* Paints an arrow that points down */
- MOZ_GTK_TOOLBARBUTTON_ARROW,
- /* Paints items of menubar and popups. */
- MOZ_GTK_MENUITEM,
- MOZ_GTK_CHECKMENUITEM,
- MOZ_GTK_RADIOMENUITEM,
- MOZ_GTK_MENUSEPARATOR,
- /* Paints a GtkVPaned separator */
- MOZ_GTK_SPLITTER_HORIZONTAL,
- /* Paints a GtkHPaned separator */
- MOZ_GTK_SPLITTER_VERTICAL,
- /* Paints the background of a window, dialog or page. */
- MOZ_GTK_WINDOW
-} GtkThemeWidgetType;
-
-/*** General library functions ***/
-/**
- * Initializes the drawing library. You must call this function
- * prior to using any other functionality.
- * returns: MOZ_GTK_SUCCESS if there were no errors
- * MOZ_GTK_UNSAFE_THEME if the current theme engine is known
- * to crash with gtkdrawing.
- */
-gint moz_gtk_init();
-
-/**
- * Enable GTK+ 1.2.9+ theme enhancements. You must provide a pointer
- * to the GTK+ 1.2.9+ function "gtk_style_get_prop_experimental".
- * styleGetProp: pointer to gtk_style_get_prop_experimental
- *
- * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
- */
-gint moz_gtk_enable_style_props(style_prop_t styleGetProp);
-
-/**
- * Perform cleanup of the drawing library. You should call this function
- * when your program exits, or you no longer need the library.
- *
- * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
- */
-gint moz_gtk_shutdown();
-
-
-/*** Widget drawing ***/
-/**
- * Paint a widget in the current theme.
- * widget: a constant giving the widget to paint
- * rect: the bounding rectangle for the widget
- * cliprect: a clipprect rectangle for this painting operation
- * state: the state of the widget. ignored for some widgets.
- * flags: widget-dependant flags; see the GtkThemeWidgetType definition.
- * direction: the text direction, to draw the widget correctly LTR and RTL.
- */
-gint
-moz_gtk_widget_paint(GtkThemeWidgetType widget, GdkDrawable* drawable,
- GdkRectangle* rect, GdkRectangle* cliprect,
- GtkWidgetState* state, gint flags,
- GtkTextDirection direction);
-
-
-/*** Widget metrics ***/
-/**
- * Get the border size of a widget
- * left/right: [OUT] the widget's left/right border
- * top/bottom: [OUT] the widget's top/bottom border
- * direction: the text direction for the widget
- * inhtml: boolean indicating whether this widget will be drawn as a HTML form control,
- * in order to workaround a size issue (MOZ_GTK_BUTTON only, ignored otherwise)
- *
- * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
- */
-gint moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top,
- gint* right, gint* bottom, GtkTextDirection direction,
- gboolean inhtml);
-
-/**
- * Get the desired size of a GtkCheckButton
- * indicator_size: [OUT] the indicator size
- * indicator_spacing: [OUT] the spacing between the indicator and its
- * container
- *
- * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
- */
-gint
-moz_gtk_checkbox_get_metrics(gint* indicator_size, gint* indicator_spacing);
-
-/**
- * Get the desired size of a GtkRadioButton
- * indicator_size: [OUT] the indicator size
- * indicator_spacing: [OUT] the spacing between the indicator and its
- * container
- *
- * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
- */
-gint
-moz_gtk_radio_get_metrics(gint* indicator_size, gint* indicator_spacing);
-
-/**
- * Get the inner-border value for a GtkButton widget (button or tree header)
- * widget: [IN] the widget to get the border value for
- * inner_border: [OUT] the inner border
- *
- * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
- */
-gint
-moz_gtk_button_get_inner_border(GtkWidget* widget, GtkBorder* inner_border);
-
-/** Get the focus metrics for a treeheadercell, button, checkbox, or radio button.
- * widget: [IN] the widget to get the focus metrics for
- * interior_focus: [OUT] whether the focus is drawn around the
- * label (TRUE) or around the whole container (FALSE)
- * focus_width: [OUT] the width of the focus line
- * focus_pad: [OUT] the padding between the focus line and children
- *
- * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
- */
-gint
-moz_gtk_widget_get_focus(GtkWidget* widget, gboolean* interior_focus,
- gint* focus_width, gint* focus_pad);
-
-/**
- * Get the desired size of a GtkScale thumb
- * orient: [IN] the scale orientation
- * thumb_length: [OUT] the length of the thumb
- * thumb_height: [OUT] the height of the thumb
- *
- * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
- */
-gint
-moz_gtk_get_scalethumb_metrics(GtkOrientation orient, gint* thumb_length, gint* thumb_height);
-
-/**
- * Get the desired metrics for a GtkScrollbar
- * metrics: [IN] struct which will contain the metrics
- *
- * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
- */
-gint
-moz_gtk_get_scrollbar_metrics(MozGtkScrollbarMetrics* metrics);
-
-/**
- * Get the desired size of a dropdown arrow button
- * width: [OUT] the desired width
- * height: [OUT] the desired height
- *
- * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
- */
-gint moz_gtk_get_combo_box_entry_button_size(gint* width, gint* height);
-
-/**
- * Get the desired size of a scroll arrow widget
- * width: [OUT] the desired width
- * height: [OUT] the desired height
- *
- * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
- */
-gint moz_gtk_get_tab_scroll_arrow_size(gint* width, gint* height);
-
-/**
- * Get the desired size of a toolbar button dropdown arrow
- * width: [OUT] the desired width
- * height: [OUT] the desired height
- *
- * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
- */
-gint moz_gtk_get_downarrow_size(gint* width, gint* height);
-
-/**
- * Get the desired size of a toolbar separator
- * size: [OUT] the desired width
- *
- * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
- */
-gint moz_gtk_get_toolbar_separator_width(gint* size);
-
-/**
- * Get the size of a regular GTK expander that shows/hides content
- * size: [OUT] the size of the GTK expander, size = width = height.
- *
- * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
- */
-gint moz_gtk_get_expander_size(gint* size);
-
-/**
- * Get the size of a treeview's expander (we call them twisties)
- * size: [OUT] the size of the GTK expander, size = width = height.
- *
- * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
- */
-gint moz_gtk_get_treeview_expander_size(gint* size);
-
-/**
- * Get the desired height of a menu separator
- * size: [OUT] the desired height
- *
- * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
- */
-gint moz_gtk_get_menu_separator_height(gint* size);
-
-/**
- * Get the desired size of a splitter
- * orientation: [IN] GTK_ORIENTATION_HORIZONTAL or GTK_ORIENTATION_VERTICAL
- * size: [OUT] width or height of the splitter handle
- *
- * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
- */
-gint moz_gtk_splitter_get_metrics(gint orientation, gint* size);
-
-/**
- * Retrieve an actual GTK scrollbar widget for style analysis. It will not
- * be modified.
- */
-GtkWidget* moz_gtk_get_scrollbar_widget(void);
-
-/**
- * Get the YTHICKNESS of a tab (notebook extension).
- */
-gint moz_gtk_get_tab_thickness(void);
-
-/**
- * Get a boolean which indicates whether or not to use images in menus.
- * If TRUE, use images in menus.
- */
-gboolean moz_gtk_images_in_menus(void);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif
diff --git a/WebCore/platform/gtk/guriescape.c b/WebCore/platform/gtk/guriescape.c
deleted file mode 100644
index 0792587..0000000
--- a/WebCore/platform/gtk/guriescape.c
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * Copyright (C) 2008 Collabora, Ltd.
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- * Copyright (C) 1997-2000 The GLib Team
- * Copyright (C) 2006-2007 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-#include "guriescape.h"
-
-#include <string.h>
-
-#if !PLATFORM(WIN_OS) && !GLIB_CHECK_VERSION(2,16,0)
-
-/* is_valid, gunichar_ok and g_string_append_uri_escaped were copied for glib/gstring.c
- * in the glib package.
- *
- * Original copyright:
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * Modified by the GLib Team and others 1997-2000. See the AUTHORS
- * file for a list of people on the GLib Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GLib at ftp://ftp.gtk.org/pub/gtk/.
- *
- * Please don't change the indentation so it's easier to update these functions
- * if they are changed in glib.
- */
-static gboolean
-is_valid (char c, const char *reserved_chars_allowed)
-{
- if (g_ascii_isalnum (c) ||
- c == '-' ||
- c == '.' ||
- c == '_' ||
- c == '~')
- return TRUE;
-
- if (reserved_chars_allowed &&
- strchr (reserved_chars_allowed, c) != NULL)
- return TRUE;
-
- return FALSE;
-}
-
-static gboolean
-gunichar_ok (gunichar c)
-{
- return
- (c != (gunichar) -2) &&
- (c != (gunichar) -1);
-}
-
-static GString *
-_webcore_g_string_append_uri_escaped (GString *string,
- const char *unescaped,
- const char *reserved_chars_allowed,
- gboolean allow_utf8)
-{
- unsigned char c;
- const char *end;
- static const gchar hex[16] = "0123456789ABCDEF";
-
- g_return_val_if_fail (string != NULL, NULL);
- g_return_val_if_fail (unescaped != NULL, NULL);
-
- end = unescaped + strlen (unescaped);
-
- while ((c = *unescaped) != 0)
- {
- if (c >= 0x80 && allow_utf8 &&
- gunichar_ok (g_utf8_get_char_validated (unescaped, end - unescaped)))
- {
- int len = g_utf8_skip [c];
- g_string_append_len (string, unescaped, len);
- unescaped += len;
- }
- else if (is_valid (c, reserved_chars_allowed))
- {
- g_string_append_c (string, c);
- unescaped++;
- }
- else
- {
- g_string_append_c (string, '%');
- g_string_append_c (string, hex[((guchar)c) >> 4]);
- g_string_append_c (string, hex[((guchar)c) & 0xf]);
- unescaped++;
- }
- }
-
- return string;
-}
-
-/* g_uri_escape_string, unescape_character, g_uri_unescape_segment and
- * g_uri_unescape_string were copied for glib/gurifuncs.c in the glib package
- * and prefixed with _webcore (if necessary) to avoid exporting a symbol with
- * the "g_" prefix.
- *
- * Original copyright:
- * Copyright (C) 2006-2007 Red Hat, Inc.
- * Author: Alexander Larsson <alexl@redhat.com>
- *
- * Please don't change the indentation so it's easier to update this function
- * if it's changed in glib.
- */
-char *
-_webcore_g_uri_escape_string (const char *unescaped,
- const char *reserved_chars_allowed,
- gboolean allow_utf8)
-{
- GString *s;
-
- g_return_val_if_fail (unescaped != NULL, NULL);
-
- s = g_string_sized_new (strlen (unescaped) + 10);
-
- _webcore_g_string_append_uri_escaped (s, unescaped, reserved_chars_allowed, allow_utf8);
-
- return g_string_free (s, FALSE);
-}
-
-static int
-unescape_character (const char *scanner)
-{
- int first_digit;
- int second_digit;
-
- first_digit = g_ascii_xdigit_value (*scanner++);
- if (first_digit < 0)
- return -1;
-
- second_digit = g_ascii_xdigit_value (*scanner++);
- if (second_digit < 0)
- return -1;
-
- return (first_digit << 4) | second_digit;
-}
-
-
-
-static char *
-_webcore_g_uri_unescape_segment (const char *escaped_string,
- const char *escaped_string_end,
- const char *illegal_characters)
-{
- const char *in;
- char *out, *result;
- gint character;
-
- if (escaped_string == NULL)
- return NULL;
-
- if (escaped_string_end == NULL)
- escaped_string_end = escaped_string + strlen (escaped_string);
-
- result = g_malloc (escaped_string_end - escaped_string + 1);
-
- out = result;
- for (in = escaped_string; in < escaped_string_end; in++)
- {
- character = *in;
-
- if (*in == '%')
- {
- in++;
-
- if (escaped_string_end - in < 2)
- {
- /* Invalid escaped char (to short) */
- g_free (result);
- return NULL;
- }
-
- character = unescape_character (in);
-
- /* Check for an illegal character. We consider '\0' illegal here. */
- if (character <= 0 ||
- (illegal_characters != NULL &&
- strchr (illegal_characters, (char)character) != NULL))
- {
- g_free (result);
- return NULL;
- }
-
- in++; /* The other char will be eaten in the loop header */
- }
- *out++ = (char)character;
- }
-
- *out = '\0';
-
- return result;
-}
-
-
-char *
-_webcore_g_uri_unescape_string (const char *escaped_string,
- const char *illegal_characters)
-{
- return _webcore_g_uri_unescape_segment (escaped_string, NULL, illegal_characters);
-}
-
-#endif /* #if !PLATFORM(WIN_OS) && !GLIB_CHECK_VERSION(2,16,0) */
diff --git a/WebCore/platform/gtk/guriescape.h b/WebCore/platform/gtk/guriescape.h
deleted file mode 100644
index 8c6662a..0000000
--- a/WebCore/platform/gtk/guriescape.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2008 Collabora, Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef guriescape_h
-#define guriescape_h
-
-#include <glib.h>
-#include <wtf/Platform.h>
-
-G_BEGIN_DECLS
-
-#if !PLATFORM(WIN_OS) && !GLIB_CHECK_VERSION(2,16,0)
-
-#define g_uri_escape_string _webcore_g_uri_escape_string
-#define g_uri_unescape_string _webcore_g_uri_unescape_string
-
-char *_webcore_g_uri_escape_string (const char *unescaped,
- const char *reserved_chars_allowed,
- gboolean allow_utf8);
-
-char *_webcore_g_uri_unescape_string (const char *escaped_string,
- const char *illegal_characters);
-
-#endif
-
-G_END_DECLS
-
-#endif /* guriescape_h */
diff --git a/WebCore/platform/image-decoders/ImageDecoder.h b/WebCore/platform/image-decoders/ImageDecoder.h
deleted file mode 100644
index 3df2e88..0000000
--- a/WebCore/platform/image-decoders/ImageDecoder.h
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef IMAGE_DECODER_H_
-#define IMAGE_DECODER_H_
-
-#include "IntRect.h"
-#include "ImageSource.h"
-#include "SharedBuffer.h"
-#include <wtf/Vector.h>
-
-namespace WebCore {
-
-typedef Vector<unsigned> RGBA32Array;
-
-// The RGBA32Buffer object represents the decoded image data in RGBA32 format. This buffer is what all
-// decoders write a single frame into. Frames are then instantiated for drawing by being handed this buffer.
-class RGBA32Buffer
-{
-public:
- enum FrameStatus { FrameEmpty, FramePartial, FrameComplete };
- enum FrameDisposalMethod {
- // If you change the numeric values of these, make sure you audit all
- // users, as some users may cast raw values to/from these constants.
- DisposeNotSpecified = 0, // Leave frame in framebuffer
- DisposeKeep = 1, // Leave frame in framebuffer
- DisposeOverwriteBgcolor = 2, // Clear frame to transparent
- DisposeOverwritePrevious = 3, // Clear frame to previous framebuffer contents
- };
-
- RGBA32Buffer() : m_height(0), m_status(FrameEmpty), m_duration(0),
- m_disposalMethod(DisposeNotSpecified), m_hasAlpha(false)
- {}
-
- const RGBA32Array& bytes() const { return m_bytes; }
- RGBA32Array& bytes() { return m_bytes; }
- const IntRect& rect() const { return m_rect; }
- unsigned height() const { return m_height; }
- FrameStatus status() const { return m_status; }
- unsigned duration() const { return m_duration; }
- FrameDisposalMethod disposalMethod() const { return m_disposalMethod; }
- bool hasAlpha() const { return m_hasAlpha; }
-
- void setRect(const IntRect& r) { m_rect = r; }
- void ensureHeight(unsigned rowIndex) { if (rowIndex > m_height) m_height = rowIndex; }
- void setStatus(FrameStatus s) { m_status = s; }
- void setDuration(unsigned duration) { m_duration = duration; }
- void setDisposalMethod(FrameDisposalMethod method) { m_disposalMethod = method; }
- void setHasAlpha(bool alpha) { m_hasAlpha = alpha; }
-
- static void setRGBA(unsigned& pos, unsigned r, unsigned g, unsigned b, unsigned a)
- {
- // We store this data pre-multiplied.
- if (a == 0)
- pos = 0;
- else {
- if (a < 255) {
- float alphaPercent = a / 255.0f;
- r = static_cast<unsigned>(r * alphaPercent);
- g = static_cast<unsigned>(g * alphaPercent);
- b = static_cast<unsigned>(b * alphaPercent);
- }
- pos = (a << 24 | r << 16 | g << 8 | b);
- }
- }
-
-private:
- RGBA32Array m_bytes;
- IntRect m_rect; // The rect of the original specified frame within the overall buffer.
- // This will always just be the entire buffer except for GIF frames
- // whose original rect was smaller than the overall image size.
- unsigned m_height; // The height (the number of rows we've fully decoded).
- FrameStatus m_status; // Whether or not this frame is completely finished decoding.
- unsigned m_duration; // The animation delay.
- FrameDisposalMethod m_disposalMethod; // What to do with this frame's data when initializing the next frame.
- bool m_hasAlpha; // Whether or not any of the pixels in the buffer have transparency.
-};
-
-// The ImageDecoder class represents a base class for specific image format decoders
-// (e.g., GIF, JPG, PNG, ICO) to derive from. All decoders decode into RGBA32 format
-// and the base class manages the RGBA32 frame cache.
-class ImageDecoder
-{
-public:
- ImageDecoder() :m_sizeAvailable(false), m_failed(false) {}
- virtual ~ImageDecoder() {}
-
- // All specific decoder plugins must do something with the data they are given.
- virtual void setData(SharedBuffer* data, bool allDataReceived) { m_data = data; }
-
- // Whether or not the size information has been decoded yet.
- virtual bool isSizeAvailable() const = 0;
-
- // Requests the size.
- virtual IntSize size() const { return m_size; }
-
- // The total number of frames for the image. Classes that support multiple frames
- // will scan the image data for the answer if they need to (without necessarily
- // decoding all of the individual frames).
- virtual int frameCount() { return 1; }
-
- // The number of repetitions to perform for an animation loop.
- virtual int repetitionCount() const { return cAnimationNone; }
-
- // Called to obtain the RGBA32Buffer full of decoded data for rendering. The
- // decoder plugin will decode as much of the frame as it can before handing
- // back the buffer.
- virtual RGBA32Buffer* frameBufferAtIndex(size_t index) = 0;
-
- // Whether or not the underlying image format even supports alpha transparency.
- virtual bool supportsAlpha() const { return true; }
-
- bool failed() const { return m_failed; }
- void setFailed() { m_failed = true; }
-
-protected:
- RefPtr<SharedBuffer> m_data; // The encoded data.
- Vector<RGBA32Buffer> m_frameBufferCache;
- bool m_sizeAvailable;
- mutable bool m_failed;
- IntSize m_size;
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/image-decoders/bmp/BMPImageDecoder.cpp b/WebCore/platform/image-decoders/bmp/BMPImageDecoder.cpp
deleted file mode 100644
index cfc141c..0000000
--- a/WebCore/platform/image-decoders/bmp/BMPImageDecoder.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "BMPImageDecoder.h"
-
-#if PLATFORM(CAIRO) || PLATFORM(QT) || PLATFORM(WX)
-
-namespace WebCore
-{
-
-bool BMPImageDecoder::isSizeAvailable() const
-{
- return false;
-}
-
-RGBA32Buffer* BMPImageDecoder::frameBufferAtIndex(size_t index)
-{
- return 0;
-}
-
-}
-
-#endif // PLATFORM(CAIRO)
diff --git a/WebCore/platform/image-decoders/bmp/BMPImageDecoder.h b/WebCore/platform/image-decoders/bmp/BMPImageDecoder.h
deleted file mode 100644
index 0f515f0..0000000
--- a/WebCore/platform/image-decoders/bmp/BMPImageDecoder.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef BMP_DECODER_H_
-#define BMP_DECODER_H_
-
-#include "ImageDecoder.h"
-
-namespace WebCore {
-
-class BMPImageReader;
-
-// This class decodes the BMP image format.
-class BMPImageDecoder : public ImageDecoder
-{
-public:
- // Whether or not the size information has been decoded yet.
- virtual bool isSizeAvailable() const;
-
- virtual RGBA32Buffer* frameBufferAtIndex(size_t index);
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp b/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp
deleted file mode 100644
index 22a6f09..0000000
--- a/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp
+++ /dev/null
@@ -1,416 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "GIFImageDecoder.h"
-#include "GIFImageReader.h"
-
-#if PLATFORM(CAIRO) || PLATFORM(QT) || PLATFORM(WX)
-
-namespace WebCore {
-
-class GIFImageDecoderPrivate
-{
-public:
- GIFImageDecoderPrivate(GIFImageDecoder* decoder = 0)
- : m_reader(decoder)
- {
- m_readOffset = 0;
- }
-
- ~GIFImageDecoderPrivate()
- {
- m_reader.close();
- }
-
- bool decode(const Vector<char>& data,
- GIFImageDecoder::GIFQuery query = GIFImageDecoder::GIFFullQuery,
- unsigned int haltFrame = -1)
- {
- return m_reader.read((const unsigned char*)data.data() + m_readOffset, data.size() - m_readOffset,
- query,
- haltFrame);
- }
-
- unsigned frameCount() const { return m_reader.images_count; }
- int repetitionCount() const { return m_reader.loop_count; }
-
- void setReadOffset(unsigned o) { m_readOffset = o; }
-
- bool isTransparent() const { return m_reader.frame_reader->is_transparent; }
-
- void getColorMap(unsigned char*& map, unsigned& size) const {
- if (m_reader.frame_reader->is_local_colormap_defined) {
- map = m_reader.frame_reader->local_colormap;
- size = (unsigned)m_reader.frame_reader->local_colormap_size;
- } else {
- map = m_reader.global_colormap;
- size = m_reader.global_colormap_size;
- }
- }
-
- unsigned frameXOffset() const { return m_reader.frame_reader->x_offset; }
- unsigned frameYOffset() const { return m_reader.frame_reader->y_offset; }
- unsigned frameWidth() const { return m_reader.frame_reader->width; }
- unsigned frameHeight() const { return m_reader.frame_reader->height; }
-
- int transparentPixel() const { return m_reader.frame_reader->tpixel; }
-
- unsigned duration() const { return m_reader.frame_reader->delay_time; }
-
-private:
- GIFImageReader m_reader;
- unsigned m_readOffset;
-};
-
-GIFImageDecoder::GIFImageDecoder()
-: m_frameCountValid(true), m_repetitionCount(cAnimationLoopOnce), m_reader(0)
-{}
-
-GIFImageDecoder::~GIFImageDecoder()
-{
- delete m_reader;
-}
-
-// Take the data and store it.
-void GIFImageDecoder::setData(SharedBuffer* data, bool allDataReceived)
-{
- if (m_failed)
- return;
-
- // Cache our new data.
- ImageDecoder::setData(data, allDataReceived);
-
- // Our frame count is now unknown.
- m_frameCountValid = false;
-
- // Create the GIF reader.
- if (!m_reader && !m_failed)
- m_reader = new GIFImageDecoderPrivate(this);
-}
-
-// Whether or not the size information has been decoded yet.
-bool GIFImageDecoder::isSizeAvailable() const
-{
- // If we have pending data to decode, send it to the GIF reader now.
- if (!m_sizeAvailable && m_reader) {
- if (m_failed)
- return false;
-
- // The decoder will go ahead and aggressively consume everything up until the first
- // size is encountered.
- decode(GIFSizeQuery, 0);
- }
-
- return m_sizeAvailable;
-}
-
-// The total number of frames for the image. Will scan the image data for the answer
-// (without necessarily decoding all of the individual frames).
-int GIFImageDecoder::frameCount()
-{
- // If the decoder had an earlier error, we will just return what we had decoded
- // so far.
- if (!m_frameCountValid) {
- // FIXME: Scanning all the data has O(n^2) behavior if the data were to come in really
- // slowly. Might be interesting to try to clone our existing read session to preserve
- // state, but for now we just crawl all the data. Note that this is no worse than what
- // ImageIO does on Mac right now (it also crawls all the data again).
- GIFImageDecoderPrivate reader;
- reader.decode(m_data->buffer(), GIFFrameCountQuery);
- m_frameCountValid = true;
- m_frameBufferCache.resize(reader.frameCount());
- }
-
- return m_frameBufferCache.size();
-}
-
-// The number of repetitions to perform for an animation loop.
-int GIFImageDecoder::repetitionCount() const
-{
- // This value can arrive at any point in the image data stream. Most GIFs
- // in the wild declare it near the beginning of the file, so it usually is
- // set by the time we've decoded the size, but (depending on the GIF and the
- // packets sent back by the webserver) not always. Our caller is
- // responsible for waiting until image decoding has finished to ask this if
- // it needs an authoritative answer. In the meantime, we should default to
- // "loop once", both in the reader and here.
- if (m_reader)
- m_repetitionCount = m_reader->repetitionCount();
- return m_repetitionCount;
-}
-
-RGBA32Buffer* GIFImageDecoder::frameBufferAtIndex(size_t index)
-{
- if (index >= frameCount())
- return 0;
-
- RGBA32Buffer& frame = m_frameBufferCache[index];
- if (frame.status() != RGBA32Buffer::FrameComplete && m_reader)
- // Decode this frame.
- decode(GIFFullQuery, index+1);
- return &frame;
-}
-
-// Feed data to the GIF reader.
-void GIFImageDecoder::decode(GIFQuery query, unsigned haltAtFrame) const
-{
- if (m_failed)
- return;
-
- m_failed = !m_reader->decode(m_data->buffer(), query, haltAtFrame);
-
- if (m_failed) {
- delete m_reader;
- m_reader = 0;
- }
-}
-
-// Callbacks from the GIF reader.
-void GIFImageDecoder::sizeNowAvailable(unsigned width, unsigned height)
-{
- m_size = IntSize(width, height);
- m_sizeAvailable = true;
-}
-
-void GIFImageDecoder::decodingHalted(unsigned bytesLeft)
-{
- m_reader->setReadOffset(m_data->size() - bytesLeft);
-}
-
-void GIFImageDecoder::initFrameBuffer(unsigned frameIndex)
-{
- // Initialize the frame rect in our buffer.
- IntRect frameRect(m_reader->frameXOffset(), m_reader->frameYOffset(),
- m_reader->frameWidth(), m_reader->frameHeight());
-
- // Make sure the frameRect doesn't extend past the bottom-right of the buffer.
- if (frameRect.right() > m_size.width())
- frameRect.setWidth(m_size.width() - m_reader->frameXOffset());
- if (frameRect.bottom() > m_size.height())
- frameRect.setHeight(m_size.height() - m_reader->frameYOffset());
-
- RGBA32Buffer* const buffer = &m_frameBufferCache[frameIndex];
- buffer->setRect(frameRect);
-
- if (frameIndex == 0) {
- // This is the first frame, so we're not relying on any previous data.
- prepEmptyFrameBuffer(buffer);
- } else {
- // The starting state for this frame depends on the previous frame's
- // disposal method.
- //
- // Frames that use the DisposeOverwritePrevious method are effectively
- // no-ops in terms of changing the starting state of a frame compared to
- // the starting state of the previous frame, so skip over them. (If the
- // first frame specifies this method, it will get treated like
- // DisposeOverwriteBgcolor below and reset to a completely empty image.)
- const RGBA32Buffer* prevBuffer = &m_frameBufferCache[--frameIndex];
- RGBA32Buffer::FrameDisposalMethod prevMethod =
- prevBuffer->disposalMethod();
- while ((frameIndex > 0) &&
- (prevMethod == RGBA32Buffer::DisposeOverwritePrevious)) {
- prevBuffer = &m_frameBufferCache[--frameIndex];
- prevMethod = prevBuffer->disposalMethod();
- }
-
- if ((prevMethod == RGBA32Buffer::DisposeNotSpecified) ||
- (prevMethod == RGBA32Buffer::DisposeKeep)) {
- // Preserve the last frame as the starting state for this frame.
- buffer->bytes() = prevBuffer->bytes();
- buffer->setHasAlpha(prevBuffer->hasAlpha());
- } else {
- // We want to clear the previous frame to transparent, without
- // affecting pixels in the image outside of the frame.
- const IntRect& prevRect = prevBuffer->rect();
- if ((frameIndex == 0) ||
- prevRect.contains(IntRect(IntPoint(0, 0), m_size))) {
- // Clearing the first frame, or a frame the size of the whole
- // image, results in a completely empty image.
- prepEmptyFrameBuffer(buffer);
- } else {
- // Copy the whole previous buffer, then clear just its frame.
- buffer->bytes() = prevBuffer->bytes();
- buffer->setHasAlpha(prevBuffer->hasAlpha());
- for (int y = prevRect.y(); y < prevRect.bottom(); ++y) {
- unsigned* const currentRow =
- buffer->bytes().data() + (y * m_size.width());
- for (int x = prevRect.x(); x < prevRect.right(); ++x)
- buffer->setRGBA(*(currentRow + x), 0, 0, 0, 0);
- }
- if ((prevRect.width() > 0) && (prevRect.height() > 0))
- buffer->setHasAlpha(true);
- }
- }
- }
-
- // Update our status to be partially complete.
- buffer->setStatus(RGBA32Buffer::FramePartial);
-
- // Reset the alpha pixel tracker for this frame.
- m_currentBufferSawAlpha = false;
-}
-
-void GIFImageDecoder::prepEmptyFrameBuffer(RGBA32Buffer* buffer) const
-{
- buffer->bytes().resize(m_size.width() * m_size.height());
- buffer->bytes().fill(0);
- buffer->setHasAlpha(true);
-}
-
-void GIFImageDecoder::haveDecodedRow(unsigned frameIndex,
- unsigned char* rowBuffer, // Pointer to single scanline temporary buffer
- unsigned char* rowEnd,
- unsigned rowNumber, // The row index
- unsigned repeatCount, // How many times to repeat the row
- bool writeTransparentPixels)
-{
- // Initialize the frame if necessary.
- RGBA32Buffer& buffer = m_frameBufferCache[frameIndex];
- if (buffer.status() == RGBA32Buffer::FrameEmpty)
- initFrameBuffer(frameIndex);
-
- // Do nothing for bogus data.
- if (rowBuffer == 0 || static_cast<int>(m_reader->frameYOffset() + rowNumber) >= m_size.height())
- return;
-
- unsigned colorMapSize;
- unsigned char* colorMap;
- m_reader->getColorMap(colorMap, colorMapSize);
- if (!colorMap)
- return;
-
- // The buffers that we draw are the entire image's width and height, so a final output frame is
- // width * height RGBA32 values in size.
- //
- // A single GIF frame, however, can be smaller than the entire image, i.e., it can represent some sub-rectangle
- // within the overall image. The rows we are decoding are within this
- // sub-rectangle. This means that if the GIF frame's sub-rectangle is (x,y,w,h) then row 0 is really row
- // y, and each row goes from x to x+w.
- unsigned dstPos = (m_reader->frameYOffset() + rowNumber) * m_size.width() + m_reader->frameXOffset();
- unsigned* dst = buffer.bytes().data() + dstPos;
- unsigned* dstEnd = dst + m_size.width() - m_reader->frameXOffset();
- unsigned* currDst = dst;
- unsigned char* currentRowByte = rowBuffer;
-
- while (currentRowByte != rowEnd && currDst < dstEnd) {
- if ((!m_reader->isTransparent() || *currentRowByte != m_reader->transparentPixel()) && *currentRowByte < colorMapSize) {
- unsigned colorIndex = *currentRowByte * 3;
- unsigned red = colorMap[colorIndex];
- unsigned green = colorMap[colorIndex + 1];
- unsigned blue = colorMap[colorIndex + 2];
- RGBA32Buffer::setRGBA(*currDst, red, green, blue, 255);
- } else {
- m_currentBufferSawAlpha = true;
- // We may or may not need to write transparent pixels to the buffer.
- // If we're compositing against a previous image, it's wrong, and if
- // we're writing atop a cleared, fully transparent buffer, it's
- // unnecessary; but if we're decoding an interlaced gif and
- // displaying it "Haeberli"-style, we must write these for passes
- // beyond the first, or the initial passes will "show through" the
- // later ones.
- if (writeTransparentPixels)
- RGBA32Buffer::setRGBA(*currDst, 0, 0, 0, 0);
- }
- currDst++;
- currentRowByte++;
- }
-
- if (repeatCount > 1) {
- // Copy the row |repeatCount|-1 times.
- unsigned num = currDst - dst;
- unsigned size = num * sizeof(unsigned);
- unsigned width = m_size.width();
- unsigned* end = buffer.bytes().data() + width * m_size.height();
- currDst = dst + width;
- for (unsigned i = 1; i < repeatCount; i++) {
- if (currDst + num > end) // Protect against a buffer overrun from a bogus repeatCount.
- break;
- memcpy(currDst, dst, size);
- currDst += width;
- }
- }
-
- // Our partial height is rowNumber + 1, e.g., row 2 is the 3rd row, so that's a height of 3.
- // Adding in repeatCount - 1 to rowNumber + 1 works out to just be rowNumber + repeatCount.
- buffer.ensureHeight(rowNumber + repeatCount);
-}
-
-void GIFImageDecoder::frameComplete(unsigned frameIndex, unsigned frameDuration, RGBA32Buffer::FrameDisposalMethod disposalMethod)
-{
- RGBA32Buffer& buffer = m_frameBufferCache[frameIndex];
- buffer.ensureHeight(m_size.height());
- buffer.setStatus(RGBA32Buffer::FrameComplete);
- buffer.setDuration(frameDuration);
- buffer.setDisposalMethod(disposalMethod);
-
- if (!m_currentBufferSawAlpha) {
- // The whole frame was non-transparent, so it's possible that the entire
- // resulting buffer was non-transparent, and we can setHasAlpha(false).
- if (buffer.rect().contains(IntRect(IntPoint(0, 0), m_size))) {
- buffer.setHasAlpha(false);
- } else if (frameIndex > 0) {
- // Tricky case. This frame does not have alpha only if everywhere
- // outside its rect doesn't have alpha. To know whether this is
- // true, we check the start state of the frame -- if it doesn't have
- // alpha, we're safe.
- //
- // First skip over prior DisposeOverwritePrevious frames (since they
- // don't affect the start state of this frame) the same way we do in
- // initFrameBuffer().
- const RGBA32Buffer* prevBuffer = &m_frameBufferCache[--frameIndex];
- while ((frameIndex > 0) &&
- (prevBuffer->disposalMethod() ==
- RGBA32Buffer::DisposeOverwritePrevious))
- prevBuffer = &m_frameBufferCache[--frameIndex];
-
- // Now, if we're at a DisposeNotSpecified or DisposeKeep frame, then
- // we can say we have no alpha if that frame had no alpha. But
- // since in initFrameBuffer() we already copied that frame's alpha
- // state into the current frame's, we need do nothing at all here.
- //
- // The only remaining case is a DisposeOverwriteBgcolor frame. If
- // it had no alpha, and its rect is contained in the current frame's
- // rect, we know the current frame has no alpha.
- if ((prevBuffer->disposalMethod() ==
- RGBA32Buffer::DisposeOverwriteBgcolor) &&
- !prevBuffer->hasAlpha() &&
- buffer.rect().contains(prevBuffer->rect()))
- buffer.setHasAlpha(false);
- }
- }
-}
-
-void GIFImageDecoder::gifComplete()
-{
- if (m_reader)
- m_repetitionCount = m_reader->repetitionCount();
- delete m_reader;
- m_reader = 0;
-}
-
-}
-
-#endif // PLATFORM(CAIRO)
diff --git a/WebCore/platform/image-decoders/gif/GIFImageDecoder.h b/WebCore/platform/image-decoders/gif/GIFImageDecoder.h
deleted file mode 100644
index b407b8d..0000000
--- a/WebCore/platform/image-decoders/gif/GIFImageDecoder.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GIF_DECODER_H_
-#define GIF_DECODER_H_
-
-#include "ImageDecoder.h"
-
-namespace WebCore {
-
-class GIFImageDecoderPrivate;
-
-// This class decodes the GIF image format.
-class GIFImageDecoder : public ImageDecoder
-{
-public:
- GIFImageDecoder();
- ~GIFImageDecoder();
-
- // Take the data and store it.
- virtual void setData(SharedBuffer* data, bool allDataReceived);
-
- // Whether or not the size information has been decoded yet.
- virtual bool isSizeAvailable() const;
-
- // The total number of frames for the image. Will scan the image data for the answer
- // (without necessarily decoding all of the individual frames).
- virtual int frameCount();
-
- // The number of repetitions to perform for an animation loop.
- virtual int repetitionCount() const;
-
- virtual RGBA32Buffer* frameBufferAtIndex(size_t index);
-
- virtual unsigned frameDurationAtIndex(size_t index) { return 0; }
-
- enum GIFQuery { GIFFullQuery, GIFSizeQuery, GIFFrameCountQuery };
-
- void decode(GIFQuery query, unsigned haltAtFrame) const;
-
- // Callbacks from the GIF reader.
- void sizeNowAvailable(unsigned width, unsigned height);
- void decodingHalted(unsigned bytesLeft);
- void haveDecodedRow(unsigned frameIndex, unsigned char* rowBuffer, unsigned char* rowEnd, unsigned rowNumber,
- unsigned repeatCount, bool writeTransparentPixels);
- void frameComplete(unsigned frameIndex, unsigned frameDuration, RGBA32Buffer::FrameDisposalMethod disposalMethod);
- void gifComplete();
-
-private:
- // Called to initialize the frame buffer with the given index, based on the
- // previous frame's disposal method.
- void initFrameBuffer(unsigned frameIndex);
-
- // A helper for initFrameBuffer(), this sets the size of the buffer, and
- // fills it with transparent pixels.
- void prepEmptyFrameBuffer(RGBA32Buffer* buffer) const;
-
- bool m_frameCountValid;
- bool m_currentBufferSawAlpha;
- mutable int m_repetitionCount;
- mutable GIFImageDecoderPrivate* m_reader;
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/image-decoders/gif/GIFImageReader.cpp b/WebCore/platform/image-decoders/gif/GIFImageReader.cpp
deleted file mode 100644
index 04347af..0000000
--- a/WebCore/platform/image-decoders/gif/GIFImageReader.cpp
+++ /dev/null
@@ -1,943 +0,0 @@
-/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Chris Saari <saari@netscape.com>
- * Apple Computer
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-/*
-The Graphics Interchange Format(c) is the copyright property of CompuServe
-Incorporated. Only CompuServe Incorporated is authorized to define, redefine,
-enhance, alter, modify or change in any way the definition of the format.
-
-CompuServe Incorporated hereby grants a limited, non-exclusive, royalty-free
-license for the use of the Graphics Interchange Format(sm) in computer
-software; computer software utilizing GIF(sm) must acknowledge ownership of the
-Graphics Interchange Format and its Service Mark by CompuServe Incorporated, in
-User and Technical Documentation. Computer software utilizing GIF, which is
-distributed or may be distributed without User or Technical Documentation must
-display to the screen or printer a message acknowledging ownership of the
-Graphics Interchange Format and the Service Mark by CompuServe Incorporated; in
-this case, the acknowledgement may be displayed in an opening screen or leading
-banner, or a closing screen or trailing banner. A message such as the following
-may be used:
-
- "The Graphics Interchange Format(c) is the Copyright property of
- CompuServe Incorporated. GIF(sm) is a Service Mark property of
- CompuServe Incorporated."
-
-For further information, please contact :
-
- CompuServe Incorporated
- Graphics Technology Department
- 5000 Arlington Center Boulevard
- Columbus, Ohio 43220
- U. S. A.
-
-CompuServe Incorporated maintains a mailing list with all those individuals and
-organizations who wish to receive copies of this document when it is corrected
-or revised. This service is offered free of charge; please provide us with your
-mailing address.
-*/
-
-#include "config.h"
-#include "GIFImageReader.h"
-
-#include <string.h>
-#include "GIFImageDecoder.h"
-
-#if PLATFORM(CAIRO) || PLATFORM(QT) || PLATFORM(WX)
-
-using WebCore::GIFImageDecoder;
-
-// Define the Mozilla macro setup so that we can leave the macros alone.
-#define PR_BEGIN_MACRO do {
-#define PR_END_MACRO } while (0)
-
-/*
- * GETN(n, s) requests at least 'n' bytes available from 'q', at start of state 's'
- *
- * Note, the hold will never need to be bigger than 256 bytes to gather up in the hold,
- * as each GIF block (except colormaps) can never be bigger than 256 bytes.
- * Colormaps are directly copied in the resp. global_colormap or dynamically allocated local_colormap.
- * So a fixed buffer in GIFImageReader is good enough.
- * This buffer is only needed to copy left-over data from one GifWrite call to the next
- */
-#define GETN(n,s) \
- PR_BEGIN_MACRO \
- bytes_to_consume = (n); \
- state = (s); \
- PR_END_MACRO
-
-/* Get a 16-bit value stored in little-endian format */
-#define GETINT16(p) ((p)[1]<<8|(p)[0])
-
-//******************************************************************************
-// Send the data to the display front-end.
-void GIFImageReader::output_row()
-{
- GIFFrameReader* gs = frame_reader;
-
- int drow_start, drow_end;
-
- drow_start = drow_end = gs->irow;
-
- /*
- * Haeberli-inspired hack for interlaced GIFs: Replicate lines while
- * displaying to diminish the "venetian-blind" effect as the image is
- * loaded. Adjust pixel vertical positions to avoid the appearance of the
- * image crawling up the screen as successive passes are drawn.
- */
- if (gs->progressive_display && gs->interlaced && gs->ipass < 4) {
- unsigned row_dup = 0, row_shift = 0;
-
- switch (gs->ipass) {
- case 1:
- row_dup = 7;
- row_shift = 3;
- break;
- case 2:
- row_dup = 3;
- row_shift = 1;
- break;
- case 3:
- row_dup = 1;
- row_shift = 0;
- break;
- default:
- break;
- }
-
- drow_start -= row_shift;
- drow_end = drow_start + row_dup;
-
- /* Extend if bottom edge isn't covered because of the shift upward. */
- if (((gs->height - 1) - drow_end) <= row_shift)
- drow_end = gs->height - 1;
-
- /* Clamp first and last rows to upper and lower edge of image. */
- if (drow_start < 0)
- drow_start = 0;
- if ((unsigned)drow_end >= gs->height)
- drow_end = gs->height - 1;
- }
-
- /* Protect against too much image data */
- if ((unsigned)drow_start >= gs->height)
- return;
-
- // CALLBACK: Let the client know we have decoded a row.
- if (clientptr && frame_reader)
- clientptr->haveDecodedRow(images_count - 1, frame_reader->rowbuf, frame_reader->rowend,
- drow_start, drow_end - drow_start + 1,
- gs->progressive_display && gs->interlaced && gs->ipass > 1);
-
- gs->rowp = gs->rowbuf;
-
- if (!gs->interlaced)
- gs->irow++;
- else {
- do {
- switch (gs->ipass)
- {
- case 1:
- gs->irow += 8;
- if (gs->irow >= gs->height) {
- gs->ipass++;
- gs->irow = 4;
- }
- break;
-
- case 2:
- gs->irow += 8;
- if (gs->irow >= gs->height) {
- gs->ipass++;
- gs->irow = 2;
- }
- break;
-
- case 3:
- gs->irow += 4;
- if (gs->irow >= gs->height) {
- gs->ipass++;
- gs->irow = 1;
- }
- break;
-
- case 4:
- gs->irow += 2;
- if (gs->irow >= gs->height){
- gs->ipass++;
- gs->irow = 0;
- }
- break;
-
- default:
- break;
- }
- } while (gs->irow > (gs->height - 1));
- }
-}
-
-//******************************************************************************
-/* Perform Lempel-Ziv-Welch decoding */
-int GIFImageReader::do_lzw(const unsigned char *q)
-{
- GIFFrameReader* gs = frame_reader;
- if (!gs)
- return 0;
-
- int code;
- int incode;
- const unsigned char *ch;
-
- /* Copy all the decoder state variables into locals so the compiler
- * won't worry about them being aliased. The locals will be homed
- * back into the GIF decoder structure when we exit.
- */
- int avail = gs->avail;
- int bits = gs->bits;
- int cnt = count;
- int codesize = gs->codesize;
- int codemask = gs->codemask;
- int oldcode = gs->oldcode;
- int clear_code = gs->clear_code;
- unsigned char firstchar = gs->firstchar;
- int datum = gs->datum;
-
- if (!gs->prefix) {
- gs->prefix = new unsigned short[MAX_BITS];
- memset(gs->prefix, 0, MAX_BITS * sizeof(short));
- }
-
- unsigned short *prefix = gs->prefix;
- unsigned char *stackp = gs->stackp;
- unsigned char *suffix = gs->suffix;
- unsigned char *stack = gs->stack;
- unsigned char *rowp = gs->rowp;
- unsigned char *rowend = gs->rowend;
- unsigned rows_remaining = gs->rows_remaining;
-
- if (rowp == rowend)
- return 0;
-
-#define OUTPUT_ROW \
- PR_BEGIN_MACRO \
- output_row(); \
- rows_remaining--; \
- rowp = frame_reader->rowp; \
- if (!rows_remaining) \
- goto END; \
- PR_END_MACRO
-
- for (ch = q; cnt-- > 0; ch++)
- {
- /* Feed the next byte into the decoder's 32-bit input buffer. */
- datum += ((int) *ch) << bits;
- bits += 8;
-
- /* Check for underflow of decoder's 32-bit input buffer. */
- while (bits >= codesize)
- {
- /* Get the leading variable-length symbol from the data stream */
- code = datum & codemask;
- datum >>= codesize;
- bits -= codesize;
-
- /* Reset the dictionary to its original state, if requested */
- if (code == clear_code) {
- codesize = gs->datasize + 1;
- codemask = (1 << codesize) - 1;
- avail = clear_code + 2;
- oldcode = -1;
- continue;
- }
-
- /* Check for explicit end-of-stream code */
- if (code == (clear_code + 1)) {
- /* end-of-stream should only appear after all image data */
- if (rows_remaining != 0)
- return -1;
- return 0;
- }
-
- if (oldcode == -1) {
- *rowp++ = suffix[code];
- if (rowp == rowend)
- OUTPUT_ROW;
-
- firstchar = oldcode = code;
- continue;
- }
-
- incode = code;
- if (code >= avail) {
- *stackp++ = firstchar;
- code = oldcode;
-
- if (stackp == stack + MAX_BITS)
- return -1;
- }
-
- while (code >= clear_code)
- {
- if (code == prefix[code])
- return -1;
-
- *stackp++ = suffix[code];
- code = prefix[code];
-
- if (stackp == stack + MAX_BITS)
- return -1;
- }
-
- *stackp++ = firstchar = suffix[code];
-
- /* Define a new codeword in the dictionary. */
- if (avail < 4096) {
- prefix[avail] = oldcode;
- suffix[avail] = firstchar;
- avail++;
-
- /* If we've used up all the codewords of a given length
- * increase the length of codewords by one bit, but don't
- * exceed the specified maximum codeword size of 12 bits.
- */
- if (((avail & codemask) == 0) && (avail < 4096)) {
- codesize++;
- codemask += avail;
- }
- }
- oldcode = incode;
-
- /* Copy the decoded data out to the scanline buffer. */
- do {
- *rowp++ = *--stackp;
- if (rowp == rowend) {
- OUTPUT_ROW;
- }
- } while (stackp > stack);
- }
- }
-
- END:
-
- /* Home the local copies of the GIF decoder state variables */
- gs->avail = avail;
- gs->bits = bits;
- gs->codesize = codesize;
- gs->codemask = codemask;
- count = cnt;
- gs->oldcode = oldcode;
- gs->firstchar = firstchar;
- gs->datum = datum;
- gs->stackp = stackp;
- gs->rowp = rowp;
- gs->rows_remaining = rows_remaining;
-
- return 0;
-}
-
-
-/******************************************************************************/
-/*
- * process data arriving from the stream for the gif decoder
- */
-
-bool GIFImageReader::read(const unsigned char *buf, unsigned len,
- GIFImageDecoder::GIFQuery query, unsigned haltAtFrame)
-{
- if (!len) {
- // No new data has come in since the last call, just ignore this call.
- return true;
- }
-
- const unsigned char *q = buf;
-
- // Add what we have so far to the block
- // If previous call to me left something in the hold first complete current block
- // Or if we are filling the colormaps, first complete the colormap
- unsigned char* p = 0;
- if (state == gif_global_colormap)
- p = global_colormap;
- else if (state == gif_image_colormap)
- p = frame_reader ? frame_reader->local_colormap : 0;
- else if (bytes_in_hold)
- p = hold;
- else
- p = 0;
-
- if (p || (state == gif_global_colormap) || (state == gif_image_colormap)) {
- // Add what we have sofar to the block
- unsigned l = len < bytes_to_consume ? len : bytes_to_consume;
- if (p)
- memcpy(p + bytes_in_hold, buf, l);
-
- if (l < bytes_to_consume) {
- // Not enough in 'buf' to complete current block, get more
- bytes_in_hold += l;
- bytes_to_consume -= l;
- if (clientptr)
- clientptr->decodingHalted(0);
- return true;
- }
- // Reset hold buffer count
- bytes_in_hold = 0;
- // Point 'q' to complete block in hold (or in colormap)
- q = p;
- }
-
- // Invariant:
- // 'q' is start of current to be processed block (hold, colormap or buf)
- // 'bytes_to_consume' is number of bytes to consume from 'buf'
- // 'buf' points to the bytes to be consumed from the input buffer
- // 'len' is number of bytes left in input buffer from position 'buf'.
- // At entrance of the for loop will 'buf' will be moved 'bytes_to_consume'
- // to point to next buffer, 'len' is adjusted accordingly.
- // So that next round in for loop, q gets pointed to the next buffer.
-
- for (;len >= bytes_to_consume; q=buf) {
- // Eat the current block from the buffer, q keeps pointed at current block
- buf += bytes_to_consume;
- len -= bytes_to_consume;
-
- switch (state)
- {
- case gif_lzw:
- if (do_lzw(q) < 0) {
- state = gif_error;
- break;
- }
- GETN(1, gif_sub_block);
- break;
-
- case gif_lzw_start:
- {
- /* Initialize LZW parser/decoder */
- int datasize = *q;
- if (datasize > MAX_LZW_BITS) {
- state = gif_error;
- break;
- }
- int clear_code = 1 << datasize;
- if (clear_code >= MAX_BITS) {
- state = gif_error;
- break;
- }
-
- if (frame_reader) {
- frame_reader->datasize = datasize;
- frame_reader->clear_code = clear_code;
- frame_reader->avail = frame_reader->clear_code + 2;
- frame_reader->oldcode = -1;
- frame_reader->codesize = frame_reader->datasize + 1;
- frame_reader->codemask = (1 << frame_reader->codesize) - 1;
-
- frame_reader->datum = frame_reader->bits = 0;
-
- /* init the tables */
- if (!frame_reader->suffix)
- frame_reader->suffix = new unsigned char[MAX_BITS];
- for (int i = 0; i < frame_reader->clear_code; i++)
- frame_reader->suffix[i] = i;
-
- if (!frame_reader->stack)
- frame_reader->stack = new unsigned char[MAX_BITS];
- frame_reader->stackp = frame_reader->stack;
- }
-
- GETN(1, gif_sub_block);
- }
- break;
-
- /* All GIF files begin with "GIF87a" or "GIF89a" */
- case gif_type:
- {
- if (!strncmp((char*)q, "GIF89a", 6)) {
- version = 89;
- } else if (!strncmp((char*)q, "GIF87a", 6)) {
- version = 87;
- } else {
- state = gif_error;
- break;
- }
- GETN(7, gif_global_header);
- }
- break;
-
- case gif_global_header:
- {
- /* This is the height and width of the "screen" or
- * frame into which images are rendered. The
- * individual images can be smaller than the
- * screen size and located with an origin anywhere
- * within the screen.
- */
-
- screen_width = GETINT16(q);
- screen_height = GETINT16(q + 2);
-
- // CALLBACK: Inform the decoderplugin of our size.
- if (clientptr)
- clientptr->sizeNowAvailable(screen_width, screen_height);
-
- screen_bgcolor = q[5];
- global_colormap_size = 2<<(q[4]&0x07);
-
- if ((q[4] & 0x80) && global_colormap_size > 0) { /* global map */
- // Get the global colormap
- const unsigned size = 3*global_colormap_size;
-
- // Malloc the color map, but only if we're not just counting frames.
- if (query != GIFImageDecoder::GIFFrameCountQuery)
- global_colormap = new unsigned char[size];
-
- if (len < size) {
- // Use 'hold' pattern to get the global colormap
- GETN(size, gif_global_colormap);
- break;
- }
-
- // Copy everything and go directly to gif_image_start.
- if (global_colormap)
- memcpy(global_colormap, buf, size);
- buf += size;
- len -= size;
- }
-
- GETN(1, gif_image_start);
-
- // q[6] = Pixel Aspect Ratio
- // Not used
- // float aspect = (float)((q[6] + 15) / 64.0);
- }
- break;
-
- case gif_global_colormap:
- // Everything is already copied into global_colormap
- GETN(1, gif_image_start);
- break;
-
- case gif_image_start:
- {
- if (*q == ';') { /* terminator */
- state = gif_done;
- break;
- }
-
- if (*q == '!') { /* extension */
- GETN(2, gif_extension);
- break;
- }
-
- /* If we get anything other than ',' (image separator), '!'
- * (extension), or ';' (trailer), there is extraneous data
- * between blocks. The GIF87a spec tells us to keep reading
- * until we find an image separator, but GIF89a says such
- * a file is corrupt. We follow GIF89a and bail out. */
- if (*q != ',') {
- if (images_decoded > 0) {
- /* The file is corrupt, but one or more images have
- * been decoded correctly. In this case, we proceed
- * as if the file were correctly terminated and set
- * the state to gif_done, so the GIF will display.
- */
- state = gif_done;
- } else {
- /* No images decoded, there is nothing to display. */
- state = gif_error;
- }
- break;
- } else
- GETN(9, gif_image_header);
- }
- break;
-
- case gif_extension:
- {
- int len = count = q[1];
- gstate es = gif_skip_block;
-
- switch (*q)
- {
- case 0xf9:
- es = gif_control_extension;
- break;
-
- case 0x01:
- // ignoring plain text extension
- break;
-
- case 0xff:
- es = gif_application_extension;
- break;
-
- case 0xfe:
- es = gif_consume_comment;
- break;
- }
-
- if (len)
- GETN(len, es);
- else
- GETN(1, gif_image_start);
- }
- break;
-
- case gif_consume_block:
- if (!*q)
- GETN(1, gif_image_start);
- else
- GETN(*q, gif_skip_block);
- break;
-
- case gif_skip_block:
- GETN(1, gif_consume_block);
- break;
-
- case gif_control_extension:
- {
- if (query != GIFImageDecoder::GIFFrameCountQuery) {
- if (!frame_reader)
- frame_reader = new GIFFrameReader();
- }
-
- if (frame_reader) {
- if (*q & 0x1) {
- frame_reader->tpixel = q[3];
- frame_reader->is_transparent = true;
- } else {
- frame_reader->is_transparent = false;
- // ignoring gfx control extension
- }
- // NOTE: This relies on the values in the FrameDisposalMethod enum
- // matching those in the GIF spec!
- frame_reader->disposal_method = (WebCore::RGBA32Buffer::FrameDisposalMethod)(((*q) >> 2) & 0x7);
- // Some specs say 3rd bit (value 4), other specs say value 3
- // Let's choose 3 (the more popular)
- if (frame_reader->disposal_method == 4)
- frame_reader->disposal_method = WebCore::RGBA32Buffer::DisposeOverwritePrevious;
- frame_reader->delay_time = GETINT16(q + 1) * 10;
- }
- GETN(1, gif_consume_block);
- }
- break;
-
- case gif_comment_extension:
- {
- if (*q)
- GETN(*q, gif_consume_comment);
- else
- GETN(1, gif_image_start);
- }
- break;
-
- case gif_consume_comment:
- GETN(1, gif_comment_extension);
- break;
-
- case gif_application_extension:
- /* Check for netscape application extension */
- if (!strncmp((char*)q, "NETSCAPE2.0", 11) ||
- !strncmp((char*)q, "ANIMEXTS1.0", 11))
- GETN(1, gif_netscape_extension_block);
- else
- GETN(1, gif_consume_block);
- break;
-
- /* Netscape-specific GIF extension: animation looping */
- case gif_netscape_extension_block:
- if (*q)
- GETN(*q, gif_consume_netscape_extension);
- else
- GETN(1, gif_image_start);
- break;
-
- /* Parse netscape-specific application extensions */
- case gif_consume_netscape_extension:
- {
- int netscape_extension = q[0] & 7;
-
- /* Loop entire animation specified # of times. Only read the
- loop count during the first iteration. */
- if (netscape_extension == 1) {
- loop_count = GETINT16(q + 1);
-
- GETN(1, gif_netscape_extension_block);
- }
- /* Wait for specified # of bytes to enter buffer */
- else if (netscape_extension == 2) {
- // Don't do this, this extension doesn't exist (isn't used at all)
- // and doesn't do anything, as our streaming/buffering takes care of it all...
- // See: http://semmix.pl/color/exgraf/eeg24.htm
- GETN(1, gif_netscape_extension_block);
- } else
- state = gif_error; // 0,3-7 are yet to be defined netscape
- // extension codes
-
- break;
- }
-
- case gif_image_header:
- {
- unsigned height, width, x_offset, y_offset;
-
- /* Get image offsets, with respect to the screen origin */
- x_offset = GETINT16(q);
- y_offset = GETINT16(q + 2);
-
- /* Get image width and height. */
- width = GETINT16(q + 4);
- height = GETINT16(q + 6);
-
- /* Work around broken GIF files where the logical screen
- * size has weird width or height. We assume that GIF87a
- * files don't contain animations.
- */
- if ((images_decoded == 0) &&
- ((screen_height < height) || (screen_width < width) ||
- (version == 87)))
- {
- screen_height = height;
- screen_width = width;
- x_offset = 0;
- y_offset = 0;
-
- // CALLBACK: Inform the decoderplugin of our size.
- if (clientptr)
- clientptr->sizeNowAvailable(screen_width, screen_height);
- }
-
- /* Work around more broken GIF files that have zero image
- width or height */
- if (!height || !width) {
- height = screen_height;
- width = screen_width;
- if (!height || !width) {
- state = gif_error;
- break;
- }
- }
-
- if (query == GIFImageDecoder::GIFSizeQuery || haltAtFrame == images_decoded) {
- // The decoder needs to stop. Hand back the number of bytes we consumed from
- // buffer minus 9 (the amount we consumed to read the header).
- if (clientptr)
- clientptr->decodingHalted(len + 9);
- GETN(9, gif_image_header);
- return true;
- }
-
- images_count = images_decoded + 1;
-
- if (query == GIFImageDecoder::GIFFullQuery && !frame_reader)
- frame_reader = new GIFFrameReader();
-
- if (frame_reader) {
- frame_reader->x_offset = x_offset;
- frame_reader->y_offset = y_offset;
- frame_reader->height = height;
- frame_reader->width = width;
-
- /* This case will never be taken if this is the first image */
- /* being decoded. If any of the later images are larger */
- /* than the screen size, we need to reallocate buffers. */
- if (screen_width < width) {
- /* XXX Deviant! */
-
- delete []frame_reader->rowbuf;
- screen_width = width;
- frame_reader->rowbuf = new unsigned char[screen_width];
- } else if (!frame_reader->rowbuf) {
- frame_reader->rowbuf = new unsigned char[screen_width];
- }
-
- if (!frame_reader->rowbuf) {
- state = gif_oom;
- break;
- }
- if (screen_height < height)
- screen_height = height;
-
- if (q[8] & 0x40) {
- frame_reader->interlaced = true;
- frame_reader->ipass = 1;
- } else {
- frame_reader->interlaced = false;
- frame_reader->ipass = 0;
- }
-
- if (images_decoded == 0) {
- frame_reader->progressive_display = true;
- } else {
- /* Overlaying interlaced, transparent GIFs over
- existing image data using the Haeberli display hack
- requires saving the underlying image in order to
- avoid jaggies at the transparency edges. We are
- unprepared to deal with that, so don't display such
- images progressively */
- frame_reader->progressive_display = false;
- }
-
- /* Clear state from last image */
- frame_reader->irow = 0;
- frame_reader->rows_remaining = frame_reader->height;
- frame_reader->rowend = frame_reader->rowbuf + frame_reader->width;
- frame_reader->rowp = frame_reader->rowbuf;
-
- /* bits per pixel is q[8]&0x07 */
- }
-
- if (q[8] & 0x80) /* has a local colormap? */
- {
- int num_colors = 2 << (q[8] & 0x7);
- const unsigned size = 3*num_colors;
- unsigned char *map = frame_reader ? frame_reader->local_colormap : 0;
- if (frame_reader && (!map || (num_colors > frame_reader->local_colormap_size))) {
- delete []map;
- map = new unsigned char[size];
- if (!map) {
- state = gif_oom;
- break;
- }
- }
-
- /* Switch to the new local palette after it loads */
- if (frame_reader) {
- frame_reader->local_colormap = map;
- frame_reader->local_colormap_size = num_colors;
- frame_reader->is_local_colormap_defined = true;
- }
-
- if (len < size) {
- // Use 'hold' pattern to get the image colormap
- GETN(size, gif_image_colormap);
- break;
- }
- // Copy everything and directly go to gif_lzw_start
- if (frame_reader)
- memcpy(frame_reader->local_colormap, buf, size);
- buf += size;
- len -= size;
- } else if (frame_reader) {
- /* Switch back to the global palette */
- frame_reader->is_local_colormap_defined = false;
- }
- GETN(1, gif_lzw_start);
- }
- break;
-
- case gif_image_colormap:
- // Everything is already copied into local_colormap
- GETN(1, gif_lzw_start);
- break;
-
- case gif_sub_block:
- {
- if ((count = *q) != 0)
- /* Still working on the same image: Process next LZW data block */
- {
- /* Make sure there are still rows left. If the GIF data */
- /* is corrupt, we may not get an explicit terminator. */
- if (frame_reader && frame_reader->rows_remaining == 0) {
- /* This is an illegal GIF, but we remain tolerant. */
- GETN(1, gif_sub_block);
- }
- GETN(count, gif_lzw);
- }
- else
- /* See if there are any more images in this sequence. */
- {
- images_decoded++;
-
- // CALLBACK: The frame is now complete.
- if (clientptr && frame_reader)
- clientptr->frameComplete(images_decoded - 1, frame_reader->delay_time,
- frame_reader->disposal_method);
-
- /* Clear state from this image */
- if (frame_reader) {
- frame_reader->is_local_colormap_defined = false;
- frame_reader->is_transparent = false;
- }
-
- GETN(1, gif_image_start);
- }
- }
- break;
-
- case gif_done:
- // When the GIF is done, we can stop.
- if (clientptr)
- clientptr->gifComplete();
- return true;
-
- // Handle out of memory errors
- case gif_oom:
- return false;
-
- // Handle general errors
- case gif_error:
- // nsGIFDecoder2::EndGIF(gs->clientptr, gs->loop_count);
- return false;
-
- // We shouldn't ever get here.
- default:
- break;
- }
- }
-
- // Copy the leftover into gs->hold
- bytes_in_hold = len;
- if (len) {
- // Add what we have sofar to the block
- unsigned char* p;
- if (state == gif_global_colormap)
- p = global_colormap;
- else if (state == gif_image_colormap)
- p = frame_reader ? frame_reader->local_colormap : 0;
- else
- p = hold;
- if (p)
- memcpy(p, buf, len);
- bytes_to_consume -= len;
- }
-
- if (clientptr)
- clientptr->decodingHalted(0);
- return true;
-}
-
-#endif // PLATFORM(CAIRO)
diff --git a/WebCore/platform/image-decoders/gif/GIFImageReader.h b/WebCore/platform/image-decoders/gif/GIFImageReader.h
deleted file mode 100644
index faa08d2..0000000
--- a/WebCore/platform/image-decoders/gif/GIFImageReader.h
+++ /dev/null
@@ -1,214 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Communicator client code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef _GIF_H_
-#define _GIF_H_
-
-// Define ourselves as the clientPtr. Mozilla just hacked their C++ callback class into this old C decoder,
-// so we will too.
-#include "GIFImageDecoder.h"
-
-#define MAX_LZW_BITS 12
-#define MAX_BITS 4097 /* 2^MAX_LZW_BITS+1 */
-#define MAX_COLORS 256
-#define MAX_HOLD_SIZE 256
-
-/* gif2.h
- The interface for the GIF87/89a decoder.
-*/
-// List of possible parsing states
-typedef enum {
- gif_type,
- gif_global_header,
- gif_global_colormap,
- gif_image_start,
- gif_image_header,
- gif_image_colormap,
- gif_image_body,
- gif_lzw_start,
- gif_lzw,
- gif_sub_block,
- gif_extension,
- gif_control_extension,
- gif_consume_block,
- gif_skip_block,
- gif_done,
- gif_oom,
- gif_error,
- gif_comment_extension,
- gif_application_extension,
- gif_netscape_extension_block,
- gif_consume_netscape_extension,
- gif_consume_comment
-} gstate;
-
-struct GIFFrameReader {
- /* LZW decoder state machine */
- unsigned char *stackp; /* Current stack pointer */
- int datasize;
- int codesize;
- int codemask;
- int clear_code; /* Codeword used to trigger dictionary reset */
- int avail; /* Index of next available slot in dictionary */
- int oldcode;
- unsigned char firstchar;
- int bits; /* Number of unread bits in "datum" */
- int datum; /* 32-bit input buffer */
-
- /* Output state machine */
- int ipass; /* Interlace pass; Ranges 1-4 if interlaced. */
- unsigned int rows_remaining; /* Rows remaining to be output */
- unsigned int irow; /* Current output row, starting at zero */
- unsigned char *rowbuf; /* Single scanline temporary buffer */
- unsigned char *rowend; /* Pointer to end of rowbuf */
- unsigned char *rowp; /* Current output pointer */
-
- /* Parameters for image frame currently being decoded */
- unsigned int x_offset, y_offset; /* With respect to "screen" origin */
- unsigned int height, width;
- int tpixel; /* Index of transparent pixel */
- WebCore::RGBA32Buffer::FrameDisposalMethod disposal_method; /* Restore to background, leave in place, etc.*/
- unsigned char *local_colormap; /* Per-image colormap */
- int local_colormap_size; /* Size of local colormap array. */
-
- bool is_local_colormap_defined : 1;
- bool progressive_display : 1; /* If TRUE, do Haeberli interlace hack */
- bool interlaced : 1; /* TRUE, if scanlines arrive interlaced order */
- bool is_transparent : 1; /* TRUE, if tpixel is valid */
-
- unsigned delay_time; /* Display time, in milliseconds,
- for this image in a multi-image GIF */
-
-
- unsigned short* prefix; /* LZW decoding tables */
- unsigned char* suffix; /* LZW decoding tables */
- unsigned char* stack; /* Base of LZW decoder stack */
-
-
- GIFFrameReader() {
- stackp = 0;
- datasize = codesize = codemask = clear_code = avail = oldcode = 0;
- firstchar = 0;
- bits = datum = 0;
- ipass = 0;
- rows_remaining = irow = 0;
- rowbuf = rowend = rowp = 0;
-
- x_offset = y_offset = width = height = 0;
- tpixel = 0;
- disposal_method = WebCore::RGBA32Buffer::DisposeNotSpecified;
-
- local_colormap = 0;
- local_colormap_size = 0;
- is_local_colormap_defined = progressive_display = is_transparent = interlaced = false;
-
- delay_time = 0;
-
- prefix = 0;
- suffix = stack = 0;
- }
-
- ~GIFFrameReader() {
- delete []rowbuf;
- delete []local_colormap;
- delete []prefix;
- delete []suffix;
- delete []stack;
- }
-};
-
-struct GIFImageReader {
- WebCore::GIFImageDecoder* clientptr;
- /* Parsing state machine */
- gstate state; /* Current decoder master state */
- unsigned bytes_to_consume; /* Number of bytes to accumulate */
- unsigned bytes_in_hold; /* bytes accumulated so far*/
- unsigned char hold[MAX_HOLD_SIZE]; /* Accumulation buffer */
- unsigned char* global_colormap; /* (3* MAX_COLORS in size) Default colormap if local not supplied, 3 bytes for each color */
-
- /* Global (multi-image) state */
- int screen_bgcolor; /* Logical screen background color */
- int version; /* Either 89 for GIF89 or 87 for GIF87 */
- unsigned screen_width; /* Logical screen width & height */
- unsigned screen_height;
- int global_colormap_size; /* Size of global colormap array. */
- int images_decoded; /* Counts completed frames for animated GIFs */
- int images_count; /* Counted all frames seen so far (including incomplete frames) */
- int loop_count; /* Netscape specific extension block to control
- the number of animation loops a GIF renders. */
-
- // Not really global, but convenient to locate here.
- int count; /* Remaining # bytes in sub-block */
-
- GIFFrameReader* frame_reader;
-
- GIFImageReader(WebCore::GIFImageDecoder* client = 0) {
- clientptr = client;
- state = gif_type;
- bytes_to_consume = 6;
- bytes_in_hold = 0;
- frame_reader = 0;
- global_colormap = 0;
-
- screen_bgcolor = version = 0;
- screen_width = screen_height = 0;
- global_colormap_size = images_decoded = images_count = 0;
- loop_count = -1;
- count = 0;
- }
-
- ~GIFImageReader() {
- close();
- }
-
- void close() {
- delete []global_colormap;
- global_colormap = 0;
- delete frame_reader;
- frame_reader = 0;
- }
-
- bool read(const unsigned char * buf, unsigned int numbytes,
- WebCore::GIFImageDecoder::GIFQuery query = WebCore::GIFImageDecoder::GIFFullQuery, unsigned haltAtFrame = -1);
-
-private:
- void output_row();
- int do_lzw(const unsigned char *q);
-};
-
-#endif
-
diff --git a/WebCore/platform/image-decoders/ico/ICOImageDecoder.cpp b/WebCore/platform/image-decoders/ico/ICOImageDecoder.cpp
deleted file mode 100644
index 019340d..0000000
--- a/WebCore/platform/image-decoders/ico/ICOImageDecoder.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ICOImageDecoder.h"
-
-#if PLATFORM(CAIRO) || PLATFORM(QT) || PLATFORM(WX)
-
-namespace WebCore
-{
-
-bool ICOImageDecoder::isSizeAvailable() const
-{
- return false;
-}
-
-RGBA32Buffer* ICOImageDecoder::frameBufferAtIndex(size_t index)
-{
- return 0;
-}
-
-}
-
-#endif // PLATFORM(CAIRO)
diff --git a/WebCore/platform/image-decoders/ico/ICOImageDecoder.h b/WebCore/platform/image-decoders/ico/ICOImageDecoder.h
deleted file mode 100644
index 6571b99..0000000
--- a/WebCore/platform/image-decoders/ico/ICOImageDecoder.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ICO_DECODER_H_
-#define ICO_DECODER_H_
-
-#include "ImageDecoder.h"
-
-namespace WebCore {
-
-class ICOImageReader;
-
-// This class decodes the ICO and CUR image formats.
-class ICOImageDecoder : public ImageDecoder
-{
-public:
- // Whether or not the size information has been decoded yet.
- virtual bool isSizeAvailable() const;
-
- virtual RGBA32Buffer* frameBufferAtIndex(size_t index);
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp b/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
deleted file mode 100644
index 44e0e4c..0000000
--- a/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
+++ /dev/null
@@ -1,531 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc.
- *
- * Portions are Copyright (C) 2001-6 mozilla.org
- *
- * Other contributors:
- * Stuart Parmenter <stuart@mozilla.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Alternatively, the contents of this file may be used under the terms
- * of either the Mozilla Public License Version 1.1, found at
- * http://www.mozilla.org/MPL/ (the "MPL") or the GNU General Public
- * License Version 2.0, found at http://www.fsf.org/copyleft/gpl.html
- * (the "GPL"), in which case the provisions of the MPL or the GPL are
- * applicable instead of those above. If you wish to allow use of your
- * version of this file only under the terms of one of those two
- * licenses (the MPL or the GPL) and not to allow others to use your
- * version of this file under the LGPL, indicate your decision by
- * deletingthe provisions above and replace them with the notice and
- * other provisions required by the MPL or the GPL, as the case may be.
- * If you do not delete the provisions above, a recipient may use your
- * version of this file under any of the LGPL, the MPL or the GPL.
- */
-
-#include "config.h"
-#include "JPEGImageDecoder.h"
-#include <assert.h>
-#include <stdio.h>
-
-#if PLATFORM(CAIRO) || PLATFORM(QT) || PLATFORM(WX)
-
-#if COMPILER(MSVC)
-// Remove warnings from warning level 4.
-#pragma warning(disable : 4611) // warning C4611: interaction between '_setjmp' and C++ object destruction is non-portable
-
-// if ADDRESS_TAG_BIT is dfined, INT32 has been declared as a typedef in the PlatformSDK (BaseTsd.h),
-// so we need to stop jpeglib.h from trying to #define it
-// see here for more info: http://www.cygwin.com/ml/cygwin/2004-07/msg01051.html
-# if defined(ADDRESS_TAG_BIT) && !defined(XMD_H)
-# define XMD_H
-# define VTK_JPEG_XMD_H
-# endif
-#endif // COMPILER(MSVC)
-
-extern "C" {
-#include "jpeglib.h"
-}
-
-#if COMPILER(MSVC)
-# if defined(VTK_JPEG_XMD_H)
-# undef VTK_JPEG_XMD_H
-# undef XMD_H
-# endif
-#endif // COMPILER(MSVC)
-
-#include <setjmp.h>
-
-namespace WebCore {
-
-struct decoder_error_mgr {
- struct jpeg_error_mgr pub; /* "public" fields for IJG library*/
- jmp_buf setjmp_buffer; /* For handling catastropic errors */
-};
-
-enum jstate {
- JPEG_HEADER, /* Reading JFIF headers */
- JPEG_START_DECOMPRESS,
- JPEG_DECOMPRESS_PROGRESSIVE, /* Output progressive pixels */
- JPEG_DECOMPRESS_SEQUENTIAL, /* Output sequential pixels */
- JPEG_DONE,
- JPEG_SINK_NON_JPEG_TRAILER, /* Some image files have a */
- /* non-JPEG trailer */
- JPEG_ERROR
-};
-
-void init_source(j_decompress_ptr jd);
-boolean fill_input_buffer(j_decompress_ptr jd);
-void skip_input_data(j_decompress_ptr jd, long num_bytes);
-void term_source(j_decompress_ptr jd);
-void error_exit(j_common_ptr cinfo);
-
-/*
- * Implementation of a JPEG src object that understands our state machine
- */
-struct decoder_source_mgr {
- /* public fields; must be first in this struct! */
- struct jpeg_source_mgr pub;
-
- JPEGImageReader *decoder;
-};
-
-class JPEGImageReader
-{
-public:
- JPEGImageReader(JPEGImageDecoder* decoder)
- : m_decoder(decoder)
- , m_bufferLength(0)
- , m_bytesToSkip(0)
- , m_state(JPEG_HEADER)
- , m_samples(0)
- {
- memset(&m_info, 0, sizeof(jpeg_decompress_struct));
-
- /* We set up the normal JPEG error routines, then override error_exit. */
- m_info.err = jpeg_std_error(&m_err.pub);
- m_err.pub.error_exit = error_exit;
-
- /* Allocate and initialize JPEG decompression object */
- jpeg_create_decompress(&m_info);
-
- decoder_source_mgr* src = 0;
- if (!m_info.src) {
- src = (decoder_source_mgr*)fastCalloc(sizeof(decoder_source_mgr), 1);
- if (!src) {
- m_state = JPEG_ERROR;
- return;
- }
- }
-
- m_info.src = (jpeg_source_mgr*)src;
-
- /* Set up callback functions. */
- src->pub.init_source = init_source;
- src->pub.fill_input_buffer = fill_input_buffer;
- src->pub.skip_input_data = skip_input_data;
- src->pub.resync_to_restart = jpeg_resync_to_restart;
- src->pub.term_source = term_source;
- src->decoder = this;
- }
-
- ~JPEGImageReader()
- {
- close();
- }
-
- void close() {
- decoder_source_mgr* src = (decoder_source_mgr*)m_info.src;
- if (src)
- fastFree(src);
- m_info.src = 0;
-
- jpeg_destroy_decompress(&m_info);
- }
-
- void skipBytes(long num_bytes) {
- decoder_source_mgr* src = (decoder_source_mgr*)m_info.src;
- long bytesToSkip = std::min(num_bytes, (long)src->pub.bytes_in_buffer);
- src->pub.bytes_in_buffer -= (size_t)bytesToSkip;
- src->pub.next_input_byte += bytesToSkip;
-
- if (num_bytes > bytesToSkip)
- m_bytesToSkip = (size_t)(num_bytes - bytesToSkip);
- else
- m_bytesToSkip = 0;
- }
-
- bool decode(const Vector<char>& data, bool sizeOnly) {
- m_decodingSizeOnly = sizeOnly;
-
- unsigned newByteCount = data.size() - m_bufferLength;
- unsigned readOffset = m_bufferLength - m_info.src->bytes_in_buffer;
-
- m_info.src->bytes_in_buffer += newByteCount;
- m_info.src->next_input_byte = (JOCTET*)(data.data()) + readOffset;
-
- // If we still have bytes to skip, try to skip those now.
- if (m_bytesToSkip)
- skipBytes(m_bytesToSkip);
-
- m_bufferLength = data.size();
-
- // We need to do the setjmp here. Otherwise bad things will happen
- if (setjmp(m_err.setjmp_buffer)) {
- m_state = JPEG_SINK_NON_JPEG_TRAILER;
- close();
- return false;
- }
-
- switch (m_state) {
- case JPEG_HEADER:
- {
- /* Read file parameters with jpeg_read_header() */
- if (jpeg_read_header(&m_info, true) == JPEG_SUSPENDED)
- return true; /* I/O suspension */
-
- /* let libjpeg take care of gray->RGB and YCbCr->RGB conversions */
- switch (m_info.jpeg_color_space) {
- case JCS_GRAYSCALE:
- case JCS_RGB:
- case JCS_YCbCr:
- m_info.out_color_space = JCS_RGB;
- break;
- case JCS_CMYK:
- case JCS_YCCK:
- default:
- m_state = JPEG_ERROR;
- return false;
- }
-
- /*
- * Don't allocate a giant and superfluous memory buffer
- * when the image is a sequential JPEG.
- */
- m_info.buffered_image = jpeg_has_multiple_scans(&m_info);
-
- /* Used to set up image size so arrays can be allocated */
- jpeg_calc_output_dimensions(&m_info);
-
- /*
- * Make a one-row-high sample array that will go away
- * when done with image. Always make it big enough to
- * hold an RGB row. Since this uses the IJG memory
- * manager, it must be allocated before the call to
- * jpeg_start_compress().
- */
- int row_stride = m_info.output_width * 4; // RGBA buffer
-
-
- m_samples = (*m_info.mem->alloc_sarray)((j_common_ptr) &m_info,
- JPOOL_IMAGE,
- row_stride, 1);
-
- m_state = JPEG_START_DECOMPRESS;
-
- // We can fill in the size now that the header is available.
- m_decoder->setSize(m_info.image_width, m_info.image_height);
-
- if (m_decodingSizeOnly) {
- // We can stop here.
- // Reduce our buffer length and available data.
- m_bufferLength -= m_info.src->bytes_in_buffer;
- m_info.src->bytes_in_buffer = 0;
- return true;
- }
- }
-
- case JPEG_START_DECOMPRESS:
- {
- /* Set parameters for decompression */
- /* FIXME -- Should reset dct_method and dither mode
- * for final pass of progressive JPEG
- */
- m_info.dct_method = JDCT_ISLOW;
- m_info.dither_mode = JDITHER_FS;
- m_info.do_fancy_upsampling = true;
- m_info.enable_2pass_quant = false;
- m_info.do_block_smoothing = true;
-
- /* Start decompressor */
- if (!jpeg_start_decompress(&m_info))
- return true; /* I/O suspension */
-
- /* If this is a progressive JPEG ... */
- m_state = (m_info.buffered_image) ? JPEG_DECOMPRESS_PROGRESSIVE : JPEG_DECOMPRESS_SEQUENTIAL;
- }
-
- case JPEG_DECOMPRESS_SEQUENTIAL:
- {
- if (m_state == JPEG_DECOMPRESS_SEQUENTIAL) {
-
- if (!m_decoder->outputScanlines())
- return true; /* I/O suspension */
-
- /* If we've completed image output ... */
- assert(m_info.output_scanline == m_info.output_height);
- m_state = JPEG_DONE;
- }
- }
-
- case JPEG_DECOMPRESS_PROGRESSIVE:
- {
- if (m_state == JPEG_DECOMPRESS_PROGRESSIVE) {
- int status;
- do {
- status = jpeg_consume_input(&m_info);
- } while ((status != JPEG_SUSPENDED) &&
- (status != JPEG_REACHED_EOI));
-
- for (;;) {
- if (m_info.output_scanline == 0) {
- int scan = m_info.input_scan_number;
-
- /* if we haven't displayed anything yet (output_scan_number==0)
- and we have enough data for a complete scan, force output
- of the last full scan */
- if ((m_info.output_scan_number == 0) &&
- (scan > 1) &&
- (status != JPEG_REACHED_EOI))
- scan--;
-
- if (!jpeg_start_output(&m_info, scan))
- return true; /* I/O suspension */
- }
-
- if (m_info.output_scanline == 0xffffff)
- m_info.output_scanline = 0;
-
- if (!m_decoder->outputScanlines()) {
- if (m_info.output_scanline == 0)
- /* didn't manage to read any lines - flag so we don't call
- jpeg_start_output() multiple times for the same scan */
- m_info.output_scanline = 0xffffff;
- return true; /* I/O suspension */
- }
-
- if (m_info.output_scanline == m_info.output_height) {
- if (!jpeg_finish_output(&m_info))
- return true; /* I/O suspension */
-
- if (jpeg_input_complete(&m_info) &&
- (m_info.input_scan_number == m_info.output_scan_number))
- break;
-
- m_info.output_scanline = 0;
- }
- }
-
- m_state = JPEG_DONE;
- }
- }
-
- case JPEG_DONE:
- {
- /* Finish decompression */
- if (!jpeg_finish_decompress(&m_info))
- return true; /* I/O suspension */
-
- m_state = JPEG_SINK_NON_JPEG_TRAILER;
-
- /* we're done */
- break;
- }
-
- case JPEG_SINK_NON_JPEG_TRAILER:
- break;
-
- case JPEG_ERROR:
- break;
- }
-
- return true;
- }
-
- jpeg_decompress_struct* info() { return &m_info; }
- JSAMPARRAY samples() const { return m_samples; }
- JPEGImageDecoder* decoder() { return m_decoder; }
-
-private:
- JPEGImageDecoder* m_decoder;
- unsigned m_bufferLength;
- int m_bytesToSkip;
- bool m_decodingSizeOnly;
- bool m_initialized;
-
- jpeg_decompress_struct m_info;
- decoder_error_mgr m_err;
- jstate m_state;
-
- JSAMPARRAY m_samples;
-};
-
-/* Override the standard error method in the IJG JPEG decoder code. */
-void error_exit(j_common_ptr cinfo)
-{
- /* Return control to the setjmp point. */
- decoder_error_mgr *err = (decoder_error_mgr *) cinfo->err;
- longjmp(err->setjmp_buffer, -1);
-}
-
-void init_source(j_decompress_ptr jd)
-{
-}
-
-void skip_input_data(j_decompress_ptr jd, long num_bytes)
-{
- decoder_source_mgr *src = (decoder_source_mgr *)jd->src;
- src->decoder->skipBytes(num_bytes);
-}
-
-boolean fill_input_buffer(j_decompress_ptr jd)
-{
- // Our decode step always sets things up properly, so if this method is ever
- // called, then we have hit the end of the buffer. A return value of FALSE indicates
- // that we have no data to supply yet.
- return false;
-}
-
-void term_source (j_decompress_ptr jd)
-{
- decoder_source_mgr *src = (decoder_source_mgr *)jd->src;
- src->decoder->decoder()->jpegComplete();
-}
-
-JPEGImageDecoder::JPEGImageDecoder()
-: m_reader(0)
-{}
-
-JPEGImageDecoder::~JPEGImageDecoder()
-{
- delete m_reader;
-}
-
-// Take the data and store it.
-void JPEGImageDecoder::setData(SharedBuffer* data, bool allDataReceived)
-{
- if (m_failed)
- return;
-
- // Cache our new data.
- ImageDecoder::setData(data, allDataReceived);
-
- // Create the JPEG reader.
- if (!m_reader && !m_failed)
- m_reader = new JPEGImageReader(this);
-}
-
-// Whether or not the size information has been decoded yet.
-bool JPEGImageDecoder::isSizeAvailable() const
-{
- // If we have pending data to decode, send it to the JPEG reader now.
- if (!m_sizeAvailable && m_reader) {
- if (m_failed)
- return false;
-
- // The decoder will go ahead and aggressively consume everything up until the
- // size is encountered.
- decode(true);
- }
-
- return m_sizeAvailable;
-}
-
-RGBA32Buffer* JPEGImageDecoder::frameBufferAtIndex(size_t index)
-{
- if (index)
- return 0;
-
- if (m_frameBufferCache.isEmpty())
- m_frameBufferCache.resize(1);
-
- RGBA32Buffer& frame = m_frameBufferCache[0];
- if (frame.status() != RGBA32Buffer::FrameComplete && m_reader)
- // Decode this frame.
- decode();
- return &frame;
-}
-
-// Feed data to the JPEG reader.
-void JPEGImageDecoder::decode(bool sizeOnly) const
-{
- if (m_failed)
- return;
-
- m_failed = !m_reader->decode(m_data->buffer(), sizeOnly);
-
- if (m_failed || (!m_frameBufferCache.isEmpty() && m_frameBufferCache[0].status() == RGBA32Buffer::FrameComplete)) {
- delete m_reader;
- m_reader = 0;
- }
-}
-
-bool JPEGImageDecoder::outputScanlines()
-{
- if (m_frameBufferCache.isEmpty())
- return false;
-
- // Resize to the width and height of the image.
- RGBA32Buffer& buffer = m_frameBufferCache[0];
- if (buffer.status() == RGBA32Buffer::FrameEmpty) {
- // Let's resize our buffer now to the correct width/height.
- RGBA32Array& bytes = buffer.bytes();
- bytes.resize(m_size.width() * m_size.height());
-
- // Update our status to be partially complete.
- buffer.setStatus(RGBA32Buffer::FramePartial);
-
- // For JPEGs, the frame always fills the entire image.
- buffer.setRect(IntRect(0, 0, m_size.width(), m_size.height()));
-
- // We don't have alpha (this is the default when the buffer is constructed).
- }
-
- jpeg_decompress_struct* info = m_reader->info();
- JSAMPARRAY samples = m_reader->samples();
-
- unsigned* dst = buffer.bytes().data() + info->output_scanline * m_size.width();
-
- while (info->output_scanline < info->output_height) {
- /* Request one scanline. Returns 0 or 1 scanlines. */
- if (jpeg_read_scanlines(info, samples, 1) != 1)
- return false;
- JSAMPLE *j1 = samples[0];
- for (unsigned i = 0; i < info->output_width; ++i) {
- unsigned r = *j1++;
- unsigned g = *j1++;
- unsigned b = *j1++;
- RGBA32Buffer::setRGBA(*dst++, r, g, b, 0xFF);
- }
-
- buffer.ensureHeight(info->output_scanline);
- }
-
- return true;
-}
-
-void JPEGImageDecoder::jpegComplete()
-{
- if (m_frameBufferCache.isEmpty())
- return;
-
- // Hand back an appropriately sized buffer, even if the image ended up being empty.
- RGBA32Buffer& buffer = m_frameBufferCache[0];
- buffer.setStatus(RGBA32Buffer::FrameComplete);
-}
-
-}
-
-#endif // PLATFORM(CAIRO)
diff --git a/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.h b/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.h
deleted file mode 100644
index 57fd9da..0000000
--- a/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef JPEG_DECODER_H_
-#define JPEG_DECODER_H_
-
-#include "ImageDecoder.h"
-
-namespace WebCore {
-
-class JPEGImageReader;
-
-// This class decodes the JPEG image format.
-class JPEGImageDecoder : public ImageDecoder
-{
-public:
- JPEGImageDecoder();
- ~JPEGImageDecoder();
-
- // Take the data and store it.
- virtual void setData(SharedBuffer* data, bool allDataReceived);
-
- // Whether or not the size information has been decoded yet.
- virtual bool isSizeAvailable() const;
-
- virtual RGBA32Buffer* frameBufferAtIndex(size_t index);
-
- virtual bool supportsAlpha() const { return false; }
-
- void decode(bool sizeOnly = false) const;
-
- JPEGImageReader* reader() { return m_reader; }
-
- void setSize(int width, int height) {
- if (!m_sizeAvailable) {
- m_sizeAvailable = true;
- m_size = IntSize(width, height);
- }
- }
-
- bool outputScanlines();
- void jpegComplete();
-
-private:
- mutable JPEGImageReader* m_reader;
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp b/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp
deleted file mode 100644
index 17143b1..0000000
--- a/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp
+++ /dev/null
@@ -1,403 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc.
- *
- * Portions are Copyright (C) 2001 mozilla.org
- *
- * Other contributors:
- * Stuart Parmenter <stuart@mozilla.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Alternatively, the contents of this file may be used under the terms
- * of either the Mozilla Public License Version 1.1, found at
- * http://www.mozilla.org/MPL/ (the "MPL") or the GNU General Public
- * License Version 2.0, found at http://www.fsf.org/copyleft/gpl.html
- * (the "GPL"), in which case the provisions of the MPL or the GPL are
- * applicable instead of those above. If you wish to allow use of your
- * version of this file only under the terms of one of those two
- * licenses (the MPL or the GPL) and not to allow others to use your
- * version of this file under the LGPL, indicate your decision by
- * deletingthe provisions above and replace them with the notice and
- * other provisions required by the MPL or the GPL, as the case may be.
- * If you do not delete the provisions above, a recipient may use your
- * version of this file under any of the LGPL, the MPL or the GPL.
- */
-
-#include "config.h"
-#include "PNGImageDecoder.h"
-#include "png.h"
-#include "assert.h"
-
-#if PLATFORM(CAIRO) || PLATFORM(QT) || PLATFORM(WX)
-
-#if COMPILER(MSVC)
-// Remove warnings from warning level 4.
-#pragma warning(disable : 4611) // warning C4611: interaction between '_setjmp' and C++ object destruction is non-portable
-#endif
-
-namespace WebCore {
-
-// Gamma constants.
-const double cMaxGamma = 21474.83;
-const double cDefaultGamma = 2.2;
-const double cInverseGamma = 0.45455;
-
-// Protect against large PNGs. See Mozilla's bug #251381 for more info.
-const long cMaxPNGSize = 1000000L;
-
-// Called if the decoding of the image fails.
-static void PNGAPI decodingFailed(png_structp png_ptr, png_const_charp error_msg);
-
-// Callbacks given to the read struct. The first is for warnings (we want to treat a particular warning
-// as an error, which is why we have to register this callback.
-static void PNGAPI decodingWarning(png_structp png_ptr, png_const_charp warning_msg);
-
-// Called when we have obtained the header information (including the size).
-static void PNGAPI headerAvailable(png_structp png_ptr, png_infop info_ptr);
-
-// Called when a row is ready.
-static void PNGAPI rowAvailable(png_structp png_ptr, png_bytep new_row,
- png_uint_32 row_num, int pass);
-
-// Called when we have completely finished decoding the image.
-static void PNGAPI pngComplete(png_structp png_ptr, png_infop info_ptr);
-
-class PNGImageReader
-{
-public:
- PNGImageReader(PNGImageDecoder* decoder)
- : m_readOffset(0), m_decodingSizeOnly(false), m_interlaceBuffer(0), m_hasAlpha(0)
- {
- m_png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, decodingFailed, decodingWarning);
- m_info = png_create_info_struct(m_png);
- png_set_progressive_read_fn(m_png, decoder, headerAvailable, rowAvailable, pngComplete);
- }
-
- ~PNGImageReader()
- {
- close();
- }
-
- void close() {
- if (m_png && m_info)
- png_destroy_read_struct(&m_png, &m_info, 0);
- delete []m_interlaceBuffer;
- m_readOffset = 0;
- }
-
- void decode(const Vector<char>& data, bool sizeOnly)
- {
- m_decodingSizeOnly = sizeOnly;
-
- // We need to do the setjmp here. Otherwise bad things will happen
- if (setjmp(m_png->jmpbuf)) {
- close();
- return;
- }
-
- // Go ahead and assume we consumed all the data. If we consume less, the
- // callback will adjust our read offset accordingly. Do not attempt to adjust the
- // offset after png_process_data returns.
- unsigned offset = m_readOffset;
- unsigned remaining = data.size() - m_readOffset;
- m_readOffset = data.size();
- png_process_data(m_png, m_info, (png_bytep)(data.data()) + offset, remaining);
- }
-
- bool decodingSizeOnly() const { return m_decodingSizeOnly; }
- png_structp pngPtr() const { return m_png; }
- png_infop infoPtr() const { return m_info; }
- png_bytep interlaceBuffer() const { return m_interlaceBuffer; }
- bool hasAlpha() const { return m_hasAlpha; }
-
- void setReadOffset(unsigned offset) { m_readOffset = offset; }
- void setHasAlpha(bool b) { m_hasAlpha = b; }
-
- void createInterlaceBuffer(int size) {
- m_interlaceBuffer = new png_byte[size];
- }
-
-private:
- unsigned m_readOffset;
- bool m_decodingSizeOnly;
- png_structp m_png;
- png_infop m_info;
- png_bytep m_interlaceBuffer;
- bool m_hasAlpha;
-};
-
-PNGImageDecoder::PNGImageDecoder()
-: m_reader(0)
-{
- m_frameBufferCache.resize(1);
-}
-
-PNGImageDecoder::~PNGImageDecoder()
-{
- delete m_reader;
-}
-
-// Take the data and store it.
-void PNGImageDecoder::setData(SharedBuffer* data, bool allDataReceived)
-{
- if (m_failed)
- return;
-
- // Cache our new data.
- ImageDecoder::setData(data, allDataReceived);
-
- // Create the PNG reader.
- if (!m_reader && !m_failed)
- m_reader = new PNGImageReader(this);
-}
-
-// Whether or not the size information has been decoded yet.
-bool PNGImageDecoder::isSizeAvailable() const
-{
- // If we have pending data to decode, send it to the PNG reader now.
- if (!m_sizeAvailable && m_reader) {
- if (m_failed)
- return false;
-
- // The decoder will go ahead and aggressively consume everything up until the
- // size is encountered.
- decode(true);
- }
-
- return m_sizeAvailable;
-}
-
-RGBA32Buffer* PNGImageDecoder::frameBufferAtIndex(size_t index)
-{
- if (index)
- return 0;
-
- RGBA32Buffer& frame = m_frameBufferCache[0];
- if (frame.status() != RGBA32Buffer::FrameComplete && m_reader)
- // Decode this frame.
- decode();
- return &frame;
-}
-
-// Feed data to the PNG reader.
-void PNGImageDecoder::decode(bool sizeOnly) const
-{
- if (m_failed)
- return;
-
- m_reader->decode(m_data->buffer(), sizeOnly);
-
- if (m_failed || (m_frameBufferCache[0].status() == RGBA32Buffer::FrameComplete)) {
- delete m_reader;
- m_reader = 0;
- }
-}
-
-void decodingFailed(png_structp png, png_const_charp errorMsg)
-{
- static_cast<PNGImageDecoder*>(png_get_progressive_ptr(png))->decodingFailed();
- longjmp(png->jmpbuf, 1);
-}
-
-void decodingWarning(png_structp png, png_const_charp warningMsg)
-{
- // Mozilla did this, so we will too.
- // Convert a tRNS warning to be an error (documented in bugzilla.mozilla.org bug #251381)
- if (!strncmp(warningMsg, "Missing PLTE before tRNS", 24))
- png_error(png, warningMsg);
-}
-
-void headerAvailable(png_structp png, png_infop info)
-{
- static_cast<PNGImageDecoder*>(png_get_progressive_ptr(png))->headerAvailable();
-}
-
-void PNGImageDecoder::headerAvailable()
-{
- png_structp png = reader()->pngPtr();
- png_infop info = reader()->infoPtr();
- png_uint_32 width = png->width;
- png_uint_32 height = png->height;
-
- // Protect against large images.
- if (png->width > cMaxPNGSize || png->height > cMaxPNGSize) {
- m_failed = true;
- longjmp(png->jmpbuf, 1);
- return;
- }
-
- // We can fill in the size now that the header is available.
- if (!m_sizeAvailable) {
- m_sizeAvailable = true;
- m_size = IntSize(width, height);
- }
-
- int bitDepth, colorType, interlaceType, compressionType, filterType, channels;
- png_get_IHDR(png, info, &width, &height, &bitDepth, &colorType,
- &interlaceType, &compressionType, &filterType);
-
- // The options we set here match what Mozilla does.
-
- // Expand to ensure we use 24-bit for RGB and 32-bit for RGBA.
- if (colorType == PNG_COLOR_TYPE_PALETTE ||
- (colorType == PNG_COLOR_TYPE_GRAY && bitDepth < 8))
- png_set_expand(png);
-
- png_bytep trns = 0;
- int trnsCount = 0;
- if (png_get_valid(png, info, PNG_INFO_tRNS)) {
- png_get_tRNS(png, info, &trns, &trnsCount, 0);
- png_set_expand(png);
- }
-
- if (bitDepth == 16)
- png_set_strip_16(png);
-
- if (colorType == PNG_COLOR_TYPE_GRAY ||
- colorType == PNG_COLOR_TYPE_GRAY_ALPHA)
- png_set_gray_to_rgb(png);
-
- // Deal with gamma and keep it under our control.
- double gamma;
- if (png_get_gAMA(png, info, &gamma)) {
- if ((gamma <= 0.0) || (gamma > cMaxGamma)) {
- gamma = cInverseGamma;
- png_set_gAMA(png, info, gamma);
- }
- png_set_gamma(png, cDefaultGamma, gamma);
- }
- else
- png_set_gamma(png, cDefaultGamma, cInverseGamma);
-
- // Tell libpng to send us rows for interlaced pngs.
- if (interlaceType == PNG_INTERLACE_ADAM7)
- png_set_interlace_handling(png);
-
- // Update our info now
- png_read_update_info(png, info);
- channels = png_get_channels(png, info);
- assert(channels == 3 || channels == 4);
-
- reader()->setHasAlpha(channels == 4);
-
- if (reader()->decodingSizeOnly()) {
- // If we only needed the size, halt the reader.
- reader()->setReadOffset(m_data->size() - png->buffer_size);
- png->buffer_size = 0;
- }
-}
-
-void rowAvailable(png_structp png, png_bytep rowBuffer,
- png_uint_32 rowIndex, int interlacePass)
-{
- static_cast<PNGImageDecoder*>(png_get_progressive_ptr(png))->rowAvailable(rowBuffer, rowIndex, interlacePass);
-}
-
-void PNGImageDecoder::rowAvailable(unsigned char* rowBuffer, unsigned rowIndex, int interlacePass)
-{
- // Resize to the width and height of the image.
- RGBA32Buffer& buffer = m_frameBufferCache[0];
- if (buffer.status() == RGBA32Buffer::FrameEmpty) {
- // Let's resize our buffer now to the correct width/height.
- RGBA32Array& bytes = buffer.bytes();
- bytes.resize(m_size.width() * m_size.height());
-
- // Update our status to be partially complete.
- buffer.setStatus(RGBA32Buffer::FramePartial);
-
- // For PNGs, the frame always fills the entire image.
- buffer.setRect(IntRect(0, 0, m_size.width(), m_size.height()));
-
- if (reader()->pngPtr()->interlaced)
- reader()->createInterlaceBuffer((reader()->hasAlpha() ? 4 : 3) * m_size.width() * m_size.height());
- }
-
- if (rowBuffer == 0)
- return;
-
- /* libpng comments (pasted in here to explain what follows)
- *
- * this function is called for every row in the image. If the
- * image is interlacing, and you turned on the interlace handler,
- * this function will be called for every row in every pass.
- * Some of these rows will not be changed from the previous pass.
- * When the row is not changed, the new_row variable will be NULL.
- * The rows and passes are called in order, so you don't really
- * need the row_num and pass, but I'm supplying them because it
- * may make your life easier.
- *
- * For the non-NULL rows of interlaced images, you must call
- * png_progressive_combine_row() passing in the row and the
- * old row. You can call this function for NULL rows (it will
- * just return) and for non-interlaced images (it just does the
- * memcpy for you) if it will make the code easier. Thus, you
- * can just do this for all cases:
- *
- * png_progressive_combine_row(png_ptr, old_row, new_row);
- *
- * where old_row is what was displayed for previous rows. Note
- * that the first pass (pass == 0 really) will completely cover
- * the old row, so the rows do not have to be initialized. After
- * the first pass (and only for interlaced images), you will have
- * to pass the current row, and the function will combine the
- * old row and the new row.
- */
-
- png_structp png = reader()->pngPtr();
- bool hasAlpha = reader()->hasAlpha();
- unsigned colorChannels = hasAlpha ? 4 : 3;
- png_bytep row;
- png_bytep interlaceBuffer = reader()->interlaceBuffer();
- if (interlaceBuffer) {
- row = interlaceBuffer + (rowIndex * colorChannels * m_size.width());
- png_progressive_combine_row(png, row, rowBuffer);
- }
- else
- row = rowBuffer;
-
- // Copy the data into our buffer.
- int width = m_size.width();
- unsigned* dst = buffer.bytes().data() + rowIndex * width;
- bool sawAlpha = false;
- for (int i = 0; i < width; i++) {
- unsigned red = *row++;
- unsigned green = *row++;
- unsigned blue = *row++;
- unsigned alpha = (hasAlpha ? *row++ : 255);
- RGBA32Buffer::setRGBA(*dst++, red, green, blue, alpha);
- if (!sawAlpha && alpha < 255) {
- sawAlpha = true;
- buffer.setHasAlpha(true);
- }
- }
-
- buffer.ensureHeight(rowIndex + 1);
-}
-
-void pngComplete(png_structp png, png_infop info)
-{
- static_cast<PNGImageDecoder*>(png_get_progressive_ptr(png))->pngComplete();
-}
-
-void PNGImageDecoder::pngComplete()
-{
- // Hand back an appropriately sized buffer, even if the image ended up being empty.
- RGBA32Buffer& buffer = m_frameBufferCache[0];
- buffer.setStatus(RGBA32Buffer::FrameComplete);
-}
-
-}
-
-#endif // PLATFORM(CAIRO)
diff --git a/WebCore/platform/image-decoders/png/PNGImageDecoder.h b/WebCore/platform/image-decoders/png/PNGImageDecoder.h
deleted file mode 100644
index 926f1f2..0000000
--- a/WebCore/platform/image-decoders/png/PNGImageDecoder.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef PNG_DECODER_H_
-#define PNG_DECODER_H_
-
-#include "ImageDecoder.h"
-
-namespace WebCore {
-
-class PNGImageReader;
-
-// This class decodes the PNG image format.
-class PNGImageDecoder : public ImageDecoder
-{
-public:
- PNGImageDecoder();
- ~PNGImageDecoder();
-
- // Take the data and store it.
- virtual void setData(SharedBuffer* data, bool allDataReceived);
-
- // Whether or not the size information has been decoded yet.
- virtual bool isSizeAvailable() const;
-
- virtual RGBA32Buffer* frameBufferAtIndex(size_t index);
-
- void decode(bool sizeOnly = false) const;
-
- PNGImageReader* reader() { return m_reader; }
-
- // Callbacks from libpng
- void decodingFailed() { m_failed = true; }
- void headerAvailable();
- void rowAvailable(unsigned char* rowBuffer, unsigned rowIndex, int interlacePass);
- void pngComplete();
-
-private:
- mutable PNGImageReader* m_reader;
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/image-decoders/xbm/XBMImageDecoder.cpp b/WebCore/platform/image-decoders/xbm/XBMImageDecoder.cpp
deleted file mode 100644
index 30c5589..0000000
--- a/WebCore/platform/image-decoders/xbm/XBMImageDecoder.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "XBMImageDecoder.h"
-
-#if PLATFORM(CAIRO) || PLATFORM(QT) || PLATFORM(WX)
-
-namespace WebCore
-{
-
-bool XBMImageDecoder::isSizeAvailable() const
-{
- return false;
-}
-
-RGBA32Buffer* XBMImageDecoder::frameBufferAtIndex(size_t index)
-{
- return 0;
-}
-
-}
-
-#endif // PLATFORM(CAIRO)
diff --git a/WebCore/platform/image-decoders/xbm/XBMImageDecoder.h b/WebCore/platform/image-decoders/xbm/XBMImageDecoder.h
deleted file mode 100644
index 7c693f4..0000000
--- a/WebCore/platform/image-decoders/xbm/XBMImageDecoder.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef XBM_DECODER_H_
-#define XBM_DECODER_H_
-
-#include "ImageDecoder.h"
-
-namespace WebCore {
-
-class XBMImageReader;
-
-// This class decodes the XBM image format.
-class XBMImageDecoder : public ImageDecoder
-{
-public:
- // Whether or not the size information has been decoded yet.
- virtual bool isSizeAvailable() const;
-
- virtual RGBA32Buffer* frameBufferAtIndex(size_t index);
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/image-decoders/zlib/adler32.c b/WebCore/platform/image-decoders/zlib/adler32.c
deleted file mode 100644
index 3c2e944..0000000
--- a/WebCore/platform/image-decoders/zlib/adler32.c
+++ /dev/null
@@ -1,149 +0,0 @@
-/* adler32.c -- compute the Adler-32 checksum of a data stream
- * Copyright (C) 1995-2004 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* @(#) $Id: adler32.c,v 3.6 2005/08/04 19:14:14 tor%cs.brown.edu Exp $ */
-
-#define ZLIB_INTERNAL
-#include "zlib.h"
-
-#define BASE 65521UL /* largest prime smaller than 65536 */
-#define NMAX 5552
-/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
-
-#define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;}
-#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);
-#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2);
-#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
-#define DO16(buf) DO8(buf,0); DO8(buf,8);
-
-/* use NO_DIVIDE if your processor does not do division in hardware */
-#ifdef NO_DIVIDE
-# define MOD(a) \
- do { \
- if (a >= (BASE << 16)) a -= (BASE << 16); \
- if (a >= (BASE << 15)) a -= (BASE << 15); \
- if (a >= (BASE << 14)) a -= (BASE << 14); \
- if (a >= (BASE << 13)) a -= (BASE << 13); \
- if (a >= (BASE << 12)) a -= (BASE << 12); \
- if (a >= (BASE << 11)) a -= (BASE << 11); \
- if (a >= (BASE << 10)) a -= (BASE << 10); \
- if (a >= (BASE << 9)) a -= (BASE << 9); \
- if (a >= (BASE << 8)) a -= (BASE << 8); \
- if (a >= (BASE << 7)) a -= (BASE << 7); \
- if (a >= (BASE << 6)) a -= (BASE << 6); \
- if (a >= (BASE << 5)) a -= (BASE << 5); \
- if (a >= (BASE << 4)) a -= (BASE << 4); \
- if (a >= (BASE << 3)) a -= (BASE << 3); \
- if (a >= (BASE << 2)) a -= (BASE << 2); \
- if (a >= (BASE << 1)) a -= (BASE << 1); \
- if (a >= BASE) a -= BASE; \
- } while (0)
-# define MOD4(a) \
- do { \
- if (a >= (BASE << 4)) a -= (BASE << 4); \
- if (a >= (BASE << 3)) a -= (BASE << 3); \
- if (a >= (BASE << 2)) a -= (BASE << 2); \
- if (a >= (BASE << 1)) a -= (BASE << 1); \
- if (a >= BASE) a -= BASE; \
- } while (0)
-#else
-# define MOD(a) a %= BASE
-# define MOD4(a) a %= BASE
-#endif
-
-/* ========================================================================= */
-uLong ZEXPORT adler32(adler, buf, len)
- uLong adler;
- const Bytef *buf;
- uInt len;
-{
- unsigned long sum2;
- unsigned n;
-
- /* split Adler-32 into component sums */
- sum2 = (adler >> 16) & 0xffff;
- adler &= 0xffff;
-
- /* in case user likes doing a byte at a time, keep it fast */
- if (len == 1) {
- adler += buf[0];
- if (adler >= BASE)
- adler -= BASE;
- sum2 += adler;
- if (sum2 >= BASE)
- sum2 -= BASE;
- return adler | (sum2 << 16);
- }
-
- /* initial Adler-32 value (deferred check for len == 1 speed) */
- if (buf == Z_NULL)
- return 1L;
-
- /* in case short lengths are provided, keep it somewhat fast */
- if (len < 16) {
- while (len--) {
- adler += *buf++;
- sum2 += adler;
- }
- if (adler >= BASE)
- adler -= BASE;
- MOD4(sum2); /* only added so many BASE's */
- return adler | (sum2 << 16);
- }
-
- /* do length NMAX blocks -- requires just one modulo operation */
- while (len >= NMAX) {
- len -= NMAX;
- n = NMAX / 16; /* NMAX is divisible by 16 */
- do {
- DO16(buf); /* 16 sums unrolled */
- buf += 16;
- } while (--n);
- MOD(adler);
- MOD(sum2);
- }
-
- /* do remaining bytes (less than NMAX, still just one modulo) */
- if (len) { /* avoid modulos if none remaining */
- while (len >= 16) {
- len -= 16;
- DO16(buf);
- buf += 16;
- }
- while (len--) {
- adler += *buf++;
- sum2 += adler;
- }
- MOD(adler);
- MOD(sum2);
- }
-
- /* return recombined sums */
- return adler | (sum2 << 16);
-}
-
-/* ========================================================================= */
-uLong ZEXPORT adler32_combine(adler1, adler2, len2)
- uLong adler1;
- uLong adler2;
- z_off_t len2;
-{
- unsigned long sum1;
- unsigned long sum2;
- unsigned rem;
-
- /* the derivation of this formula is left as an exercise for the reader */
- rem = (unsigned)(len2 % BASE);
- sum1 = adler1 & 0xffff;
- sum2 = rem * sum1;
- MOD(sum2);
- sum1 += (adler2 & 0xffff) + BASE - 1;
- sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
- if (sum1 > BASE) sum1 -= BASE;
- if (sum1 > BASE) sum1 -= BASE;
- if (sum2 > (BASE << 1)) sum2 -= (BASE << 1);
- if (sum2 > BASE) sum2 -= BASE;
- return sum1 | (sum2 << 16);
-}
diff --git a/WebCore/platform/image-decoders/zlib/compress.c b/WebCore/platform/image-decoders/zlib/compress.c
deleted file mode 100644
index 825cbbc..0000000
--- a/WebCore/platform/image-decoders/zlib/compress.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/* compress.c -- compress a memory buffer
- * Copyright (C) 1995-2003 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* @(#) $Id: compress.c,v 3.6 2005/08/04 19:14:14 tor%cs.brown.edu Exp $ */
-
-#define ZLIB_INTERNAL
-#include "zlib.h"
-
-/* ===========================================================================
- Compresses the source buffer into the destination buffer. The level
- parameter has the same meaning as in deflateInit. sourceLen is the byte
- length of the source buffer. Upon entry, destLen is the total size of the
- destination buffer, which must be at least 0.1% larger than sourceLen plus
- 12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
-
- compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
- memory, Z_BUF_ERROR if there was not enough room in the output buffer,
- Z_STREAM_ERROR if the level parameter is invalid.
-*/
-int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
- Bytef *dest;
- uLongf *destLen;
- const Bytef *source;
- uLong sourceLen;
- int level;
-{
- z_stream stream;
- int err;
-
- stream.next_in = (Bytef*)source;
- stream.avail_in = (uInt)sourceLen;
-#ifdef MAXSEG_64K
- /* Check for source > 64K on 16-bit machine: */
- if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
-#endif
- stream.next_out = dest;
- stream.avail_out = (uInt)*destLen;
- if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
-
- stream.zalloc = (alloc_func)0;
- stream.zfree = (free_func)0;
- stream.opaque = (voidpf)0;
-
- err = deflateInit(&stream, level);
- if (err != Z_OK) return err;
-
- err = deflate(&stream, Z_FINISH);
- if (err != Z_STREAM_END) {
- deflateEnd(&stream);
- return err == Z_OK ? Z_BUF_ERROR : err;
- }
- *destLen = stream.total_out;
-
- err = deflateEnd(&stream);
- return err;
-}
-
-/* ===========================================================================
- */
-int ZEXPORT compress (dest, destLen, source, sourceLen)
- Bytef *dest;
- uLongf *destLen;
- const Bytef *source;
- uLong sourceLen;
-{
- return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
-}
-
-/* ===========================================================================
- If the default memLevel or windowBits for deflateInit() is changed, then
- this function needs to be updated.
- */
-uLong ZEXPORT compressBound (sourceLen)
- uLong sourceLen;
-{
- return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 11;
-}
diff --git a/WebCore/platform/image-decoders/zlib/crc32.c b/WebCore/platform/image-decoders/zlib/crc32.c
deleted file mode 100644
index 495863b..0000000
--- a/WebCore/platform/image-decoders/zlib/crc32.c
+++ /dev/null
@@ -1,423 +0,0 @@
-/* crc32.c -- compute the CRC-32 of a data stream
- * Copyright (C) 1995-2005 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- *
- * Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster
- * CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing
- * tables for updating the shift register in one step with three exclusive-ors
- * instead of four steps with four exclusive-ors. This results in about a
- * factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3.
- */
-
-/* @(#) $Id: crc32.c,v 3.6 2005/08/04 19:14:14 tor%cs.brown.edu Exp $ */
-
-/*
- Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore
- protection on the static variables used to control the first-use generation
- of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should
- first call get_crc_table() to initialize the tables before allowing more than
- one thread to use crc32().
- */
-
-#ifdef MAKECRCH
-# include <stdio.h>
-# ifndef DYNAMIC_CRC_TABLE
-# define DYNAMIC_CRC_TABLE
-# endif /* !DYNAMIC_CRC_TABLE */
-#endif /* MAKECRCH */
-
-#include "zutil.h" /* for STDC and FAR definitions */
-
-#define local static
-
-/* Find a four-byte integer type for crc32_little() and crc32_big(). */
-#ifndef NOBYFOUR
-# ifdef STDC /* need ANSI C limits.h to determine sizes */
-# include <limits.h>
-# define BYFOUR
-# if (UINT_MAX == 0xffffffffUL)
- typedef unsigned int u4;
-# else
-# if (ULONG_MAX == 0xffffffffUL)
- typedef unsigned long u4;
-# else
-# if (USHRT_MAX == 0xffffffffUL)
- typedef unsigned short u4;
-# else
-# undef BYFOUR /* can't find a four-byte integer type! */
-# endif
-# endif
-# endif
-# endif /* STDC */
-#endif /* !NOBYFOUR */
-
-/* Definitions for doing the crc four data bytes at a time. */
-#ifdef BYFOUR
-# define REV(w) (((w)>>24)+(((w)>>8)&0xff00)+ \
- (((w)&0xff00)<<8)+(((w)&0xff)<<24))
- local unsigned long crc32_little OF((unsigned long,
- const unsigned char FAR *, unsigned));
- local unsigned long crc32_big OF((unsigned long,
- const unsigned char FAR *, unsigned));
-# define TBLS 8
-#else
-# define TBLS 1
-#endif /* BYFOUR */
-
-/* Local functions for crc concatenation */
-local unsigned long gf2_matrix_times OF((unsigned long *mat,
- unsigned long vec));
-local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat));
-
-#ifdef DYNAMIC_CRC_TABLE
-
-local volatile int crc_table_empty = 1;
-local unsigned long FAR crc_table[TBLS][256];
-local void make_crc_table OF((void));
-#ifdef MAKECRCH
- local void write_table OF((FILE *, const unsigned long FAR *));
-#endif /* MAKECRCH */
-/*
- Generate tables for a byte-wise 32-bit CRC calculation on the polynomial:
- x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1.
-
- Polynomials over GF(2) are represented in binary, one bit per coefficient,
- with the lowest powers in the most significant bit. Then adding polynomials
- is just exclusive-or, and multiplying a polynomial by x is a right shift by
- one. If we call the above polynomial p, and represent a byte as the
- polynomial q, also with the lowest power in the most significant bit (so the
- byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p,
- where a mod b means the remainder after dividing a by b.
-
- This calculation is done using the shift-register method of multiplying and
- taking the remainder. The register is initialized to zero, and for each
- incoming bit, x^32 is added mod p to the register if the bit is a one (where
- x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by
- x (which is shifting right by one and adding x^32 mod p if the bit shifted
- out is a one). We start with the highest power (least significant bit) of
- q and repeat for all eight bits of q.
-
- The first table is simply the CRC of all possible eight bit values. This is
- all the information needed to generate CRCs on data a byte at a time for all
- combinations of CRC register values and incoming bytes. The remaining tables
- allow for word-at-a-time CRC calculation for both big-endian and little-
- endian machines, where a word is four bytes.
-*/
-local void make_crc_table()
-{
- unsigned long c;
- int n, k;
- unsigned long poly; /* polynomial exclusive-or pattern */
- /* terms of polynomial defining this crc (except x^32): */
- static volatile int first = 1; /* flag to limit concurrent making */
- static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
-
- /* See if another task is already doing this (not thread-safe, but better
- than nothing -- significantly reduces duration of vulnerability in
- case the advice about DYNAMIC_CRC_TABLE is ignored) */
- if (first) {
- first = 0;
-
- /* make exclusive-or pattern from polynomial (0xedb88320UL) */
- poly = 0UL;
- for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++)
- poly |= 1UL << (31 - p[n]);
-
- /* generate a crc for every 8-bit value */
- for (n = 0; n < 256; n++) {
- c = (unsigned long)n;
- for (k = 0; k < 8; k++)
- c = c & 1 ? poly ^ (c >> 1) : c >> 1;
- crc_table[0][n] = c;
- }
-
-#ifdef BYFOUR
- /* generate crc for each value followed by one, two, and three zeros,
- and then the byte reversal of those as well as the first table */
- for (n = 0; n < 256; n++) {
- c = crc_table[0][n];
- crc_table[4][n] = REV(c);
- for (k = 1; k < 4; k++) {
- c = crc_table[0][c & 0xff] ^ (c >> 8);
- crc_table[k][n] = c;
- crc_table[k + 4][n] = REV(c);
- }
- }
-#endif /* BYFOUR */
-
- crc_table_empty = 0;
- }
- else { /* not first */
- /* wait for the other guy to finish (not efficient, but rare) */
- while (crc_table_empty)
- ;
- }
-
-#ifdef MAKECRCH
- /* write out CRC tables to crc32.h */
- {
- FILE *out;
-
- out = fopen("crc32.h", "w");
- if (out == NULL) return;
- fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n");
- fprintf(out, " * Generated automatically by crc32.c\n */\n\n");
- fprintf(out, "local const unsigned long FAR ");
- fprintf(out, "crc_table[TBLS][256] =\n{\n {\n");
- write_table(out, crc_table[0]);
-# ifdef BYFOUR
- fprintf(out, "#ifdef BYFOUR\n");
- for (k = 1; k < 8; k++) {
- fprintf(out, " },\n {\n");
- write_table(out, crc_table[k]);
- }
- fprintf(out, "#endif\n");
-# endif /* BYFOUR */
- fprintf(out, " }\n};\n");
- fclose(out);
- }
-#endif /* MAKECRCH */
-}
-
-#ifdef MAKECRCH
-local void write_table(out, table)
- FILE *out;
- const unsigned long FAR *table;
-{
- int n;
-
- for (n = 0; n < 256; n++)
- fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ", table[n],
- n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", "));
-}
-#endif /* MAKECRCH */
-
-#else /* !DYNAMIC_CRC_TABLE */
-/* ========================================================================
- * Tables of CRC-32s of all single-byte values, made by make_crc_table().
- */
-#include "crc32.h"
-#endif /* DYNAMIC_CRC_TABLE */
-
-/* =========================================================================
- * This function can be used by asm versions of crc32()
- */
-const unsigned long FAR * ZEXPORT get_crc_table()
-{
-#ifdef DYNAMIC_CRC_TABLE
- if (crc_table_empty)
- make_crc_table();
-#endif /* DYNAMIC_CRC_TABLE */
- return (const unsigned long FAR *)crc_table;
-}
-
-/* ========================================================================= */
-#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8)
-#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
-
-/* ========================================================================= */
-unsigned long ZEXPORT crc32(crc, buf, len)
- unsigned long crc;
- const unsigned char FAR *buf;
- unsigned len;
-{
- if (buf == Z_NULL) return 0UL;
-
-#ifdef DYNAMIC_CRC_TABLE
- if (crc_table_empty)
- make_crc_table();
-#endif /* DYNAMIC_CRC_TABLE */
-
-#ifdef BYFOUR
- if (sizeof(void *) == sizeof(ptrdiff_t)) {
- u4 endian;
-
- endian = 1;
- if (*((unsigned char *)(&endian)))
- return crc32_little(crc, buf, len);
- else
- return crc32_big(crc, buf, len);
- }
-#endif /* BYFOUR */
- crc = crc ^ 0xffffffffUL;
- while (len >= 8) {
- DO8;
- len -= 8;
- }
- if (len) do {
- DO1;
- } while (--len);
- return crc ^ 0xffffffffUL;
-}
-
-#ifdef BYFOUR
-
-/* ========================================================================= */
-#define DOLIT4 c ^= *buf4++; \
- c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \
- crc_table[1][(c >> 16) & 0xff] ^ crc_table[0][c >> 24]
-#define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4
-
-/* ========================================================================= */
-local unsigned long crc32_little(crc, buf, len)
- unsigned long crc;
- const unsigned char FAR *buf;
- unsigned len;
-{
- register u4 c;
- register const u4 FAR *buf4;
-
- c = (u4)crc;
- c = ~c;
- while (len && ((ptrdiff_t)buf & 3)) {
- c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
- len--;
- }
-
- buf4 = (const u4 FAR *)(const void FAR *)buf;
- while (len >= 32) {
- DOLIT32;
- len -= 32;
- }
- while (len >= 4) {
- DOLIT4;
- len -= 4;
- }
- buf = (const unsigned char FAR *)buf4;
-
- if (len) do {
- c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
- } while (--len);
- c = ~c;
- return (unsigned long)c;
-}
-
-/* ========================================================================= */
-#define DOBIG4 c ^= *++buf4; \
- c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \
- crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24]
-#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4
-
-/* ========================================================================= */
-local unsigned long crc32_big(crc, buf, len)
- unsigned long crc;
- const unsigned char FAR *buf;
- unsigned len;
-{
- register u4 c;
- register const u4 FAR *buf4;
-
- c = REV((u4)crc);
- c = ~c;
- while (len && ((ptrdiff_t)buf & 3)) {
- c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
- len--;
- }
-
- buf4 = (const u4 FAR *)(const void FAR *)buf;
- buf4--;
- while (len >= 32) {
- DOBIG32;
- len -= 32;
- }
- while (len >= 4) {
- DOBIG4;
- len -= 4;
- }
- buf4++;
- buf = (const unsigned char FAR *)buf4;
-
- if (len) do {
- c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
- } while (--len);
- c = ~c;
- return (unsigned long)(REV(c));
-}
-
-#endif /* BYFOUR */
-
-#define GF2_DIM 32 /* dimension of GF(2) vectors (length of CRC) */
-
-/* ========================================================================= */
-local unsigned long gf2_matrix_times(mat, vec)
- unsigned long *mat;
- unsigned long vec;
-{
- unsigned long sum;
-
- sum = 0;
- while (vec) {
- if (vec & 1)
- sum ^= *mat;
- vec >>= 1;
- mat++;
- }
- return sum;
-}
-
-/* ========================================================================= */
-local void gf2_matrix_square(square, mat)
- unsigned long *square;
- unsigned long *mat;
-{
- int n;
-
- for (n = 0; n < GF2_DIM; n++)
- square[n] = gf2_matrix_times(mat, mat[n]);
-}
-
-/* ========================================================================= */
-uLong ZEXPORT crc32_combine(crc1, crc2, len2)
- uLong crc1;
- uLong crc2;
- z_off_t len2;
-{
- int n;
- unsigned long row;
- unsigned long even[GF2_DIM]; /* even-power-of-two zeros operator */
- unsigned long odd[GF2_DIM]; /* odd-power-of-two zeros operator */
-
- /* degenerate case */
- if (len2 == 0)
- return crc1;
-
- /* put operator for one zero bit in odd */
- odd[0] = 0xedb88320L; /* CRC-32 polynomial */
- row = 1;
- for (n = 1; n < GF2_DIM; n++) {
- odd[n] = row;
- row <<= 1;
- }
-
- /* put operator for two zero bits in even */
- gf2_matrix_square(even, odd);
-
- /* put operator for four zero bits in odd */
- gf2_matrix_square(odd, even);
-
- /* apply len2 zeros to crc1 (first square will put the operator for one
- zero byte, eight zero bits, in even) */
- do {
- /* apply zeros operator for this bit of len2 */
- gf2_matrix_square(even, odd);
- if (len2 & 1)
- crc1 = gf2_matrix_times(even, crc1);
- len2 >>= 1;
-
- /* if no more bits set, then done */
- if (len2 == 0)
- break;
-
- /* another iteration of the loop with odd and even swapped */
- gf2_matrix_square(odd, even);
- if (len2 & 1)
- crc1 = gf2_matrix_times(odd, crc1);
- len2 >>= 1;
-
- /* if no more bits set, then done */
- } while (len2 != 0);
-
- /* return combined crc */
- crc1 ^= crc2;
- return crc1;
-}
diff --git a/WebCore/platform/image-decoders/zlib/crc32.h b/WebCore/platform/image-decoders/zlib/crc32.h
deleted file mode 100644
index 8053b61..0000000
--- a/WebCore/platform/image-decoders/zlib/crc32.h
+++ /dev/null
@@ -1,441 +0,0 @@
-/* crc32.h -- tables for rapid CRC calculation
- * Generated automatically by crc32.c
- */
-
-local const unsigned long FAR crc_table[TBLS][256] =
-{
- {
- 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL,
- 0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL,
- 0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL,
- 0x90bf1d91UL, 0x1db71064UL, 0x6ab020f2UL, 0xf3b97148UL, 0x84be41deUL,
- 0x1adad47dUL, 0x6ddde4ebUL, 0xf4d4b551UL, 0x83d385c7UL, 0x136c9856UL,
- 0x646ba8c0UL, 0xfd62f97aUL, 0x8a65c9ecUL, 0x14015c4fUL, 0x63066cd9UL,
- 0xfa0f3d63UL, 0x8d080df5UL, 0x3b6e20c8UL, 0x4c69105eUL, 0xd56041e4UL,
- 0xa2677172UL, 0x3c03e4d1UL, 0x4b04d447UL, 0xd20d85fdUL, 0xa50ab56bUL,
- 0x35b5a8faUL, 0x42b2986cUL, 0xdbbbc9d6UL, 0xacbcf940UL, 0x32d86ce3UL,
- 0x45df5c75UL, 0xdcd60dcfUL, 0xabd13d59UL, 0x26d930acUL, 0x51de003aUL,
- 0xc8d75180UL, 0xbfd06116UL, 0x21b4f4b5UL, 0x56b3c423UL, 0xcfba9599UL,
- 0xb8bda50fUL, 0x2802b89eUL, 0x5f058808UL, 0xc60cd9b2UL, 0xb10be924UL,
- 0x2f6f7c87UL, 0x58684c11UL, 0xc1611dabUL, 0xb6662d3dUL, 0x76dc4190UL,
- 0x01db7106UL, 0x98d220bcUL, 0xefd5102aUL, 0x71b18589UL, 0x06b6b51fUL,
- 0x9fbfe4a5UL, 0xe8b8d433UL, 0x7807c9a2UL, 0x0f00f934UL, 0x9609a88eUL,
- 0xe10e9818UL, 0x7f6a0dbbUL, 0x086d3d2dUL, 0x91646c97UL, 0xe6635c01UL,
- 0x6b6b51f4UL, 0x1c6c6162UL, 0x856530d8UL, 0xf262004eUL, 0x6c0695edUL,
- 0x1b01a57bUL, 0x8208f4c1UL, 0xf50fc457UL, 0x65b0d9c6UL, 0x12b7e950UL,
- 0x8bbeb8eaUL, 0xfcb9887cUL, 0x62dd1ddfUL, 0x15da2d49UL, 0x8cd37cf3UL,
- 0xfbd44c65UL, 0x4db26158UL, 0x3ab551ceUL, 0xa3bc0074UL, 0xd4bb30e2UL,
- 0x4adfa541UL, 0x3dd895d7UL, 0xa4d1c46dUL, 0xd3d6f4fbUL, 0x4369e96aUL,
- 0x346ed9fcUL, 0xad678846UL, 0xda60b8d0UL, 0x44042d73UL, 0x33031de5UL,
- 0xaa0a4c5fUL, 0xdd0d7cc9UL, 0x5005713cUL, 0x270241aaUL, 0xbe0b1010UL,
- 0xc90c2086UL, 0x5768b525UL, 0x206f85b3UL, 0xb966d409UL, 0xce61e49fUL,
- 0x5edef90eUL, 0x29d9c998UL, 0xb0d09822UL, 0xc7d7a8b4UL, 0x59b33d17UL,
- 0x2eb40d81UL, 0xb7bd5c3bUL, 0xc0ba6cadUL, 0xedb88320UL, 0x9abfb3b6UL,
- 0x03b6e20cUL, 0x74b1d29aUL, 0xead54739UL, 0x9dd277afUL, 0x04db2615UL,
- 0x73dc1683UL, 0xe3630b12UL, 0x94643b84UL, 0x0d6d6a3eUL, 0x7a6a5aa8UL,
- 0xe40ecf0bUL, 0x9309ff9dUL, 0x0a00ae27UL, 0x7d079eb1UL, 0xf00f9344UL,
- 0x8708a3d2UL, 0x1e01f268UL, 0x6906c2feUL, 0xf762575dUL, 0x806567cbUL,
- 0x196c3671UL, 0x6e6b06e7UL, 0xfed41b76UL, 0x89d32be0UL, 0x10da7a5aUL,
- 0x67dd4accUL, 0xf9b9df6fUL, 0x8ebeeff9UL, 0x17b7be43UL, 0x60b08ed5UL,
- 0xd6d6a3e8UL, 0xa1d1937eUL, 0x38d8c2c4UL, 0x4fdff252UL, 0xd1bb67f1UL,
- 0xa6bc5767UL, 0x3fb506ddUL, 0x48b2364bUL, 0xd80d2bdaUL, 0xaf0a1b4cUL,
- 0x36034af6UL, 0x41047a60UL, 0xdf60efc3UL, 0xa867df55UL, 0x316e8eefUL,
- 0x4669be79UL, 0xcb61b38cUL, 0xbc66831aUL, 0x256fd2a0UL, 0x5268e236UL,
- 0xcc0c7795UL, 0xbb0b4703UL, 0x220216b9UL, 0x5505262fUL, 0xc5ba3bbeUL,
- 0xb2bd0b28UL, 0x2bb45a92UL, 0x5cb36a04UL, 0xc2d7ffa7UL, 0xb5d0cf31UL,
- 0x2cd99e8bUL, 0x5bdeae1dUL, 0x9b64c2b0UL, 0xec63f226UL, 0x756aa39cUL,
- 0x026d930aUL, 0x9c0906a9UL, 0xeb0e363fUL, 0x72076785UL, 0x05005713UL,
- 0x95bf4a82UL, 0xe2b87a14UL, 0x7bb12baeUL, 0x0cb61b38UL, 0x92d28e9bUL,
- 0xe5d5be0dUL, 0x7cdcefb7UL, 0x0bdbdf21UL, 0x86d3d2d4UL, 0xf1d4e242UL,
- 0x68ddb3f8UL, 0x1fda836eUL, 0x81be16cdUL, 0xf6b9265bUL, 0x6fb077e1UL,
- 0x18b74777UL, 0x88085ae6UL, 0xff0f6a70UL, 0x66063bcaUL, 0x11010b5cUL,
- 0x8f659effUL, 0xf862ae69UL, 0x616bffd3UL, 0x166ccf45UL, 0xa00ae278UL,
- 0xd70dd2eeUL, 0x4e048354UL, 0x3903b3c2UL, 0xa7672661UL, 0xd06016f7UL,
- 0x4969474dUL, 0x3e6e77dbUL, 0xaed16a4aUL, 0xd9d65adcUL, 0x40df0b66UL,
- 0x37d83bf0UL, 0xa9bcae53UL, 0xdebb9ec5UL, 0x47b2cf7fUL, 0x30b5ffe9UL,
- 0xbdbdf21cUL, 0xcabac28aUL, 0x53b39330UL, 0x24b4a3a6UL, 0xbad03605UL,
- 0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL,
- 0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL,
- 0x2d02ef8dUL
-#ifdef BYFOUR
- },
- {
- 0x00000000UL, 0x191b3141UL, 0x32366282UL, 0x2b2d53c3UL, 0x646cc504UL,
- 0x7d77f445UL, 0x565aa786UL, 0x4f4196c7UL, 0xc8d98a08UL, 0xd1c2bb49UL,
- 0xfaefe88aUL, 0xe3f4d9cbUL, 0xacb54f0cUL, 0xb5ae7e4dUL, 0x9e832d8eUL,
- 0x87981ccfUL, 0x4ac21251UL, 0x53d92310UL, 0x78f470d3UL, 0x61ef4192UL,
- 0x2eaed755UL, 0x37b5e614UL, 0x1c98b5d7UL, 0x05838496UL, 0x821b9859UL,
- 0x9b00a918UL, 0xb02dfadbUL, 0xa936cb9aUL, 0xe6775d5dUL, 0xff6c6c1cUL,
- 0xd4413fdfUL, 0xcd5a0e9eUL, 0x958424a2UL, 0x8c9f15e3UL, 0xa7b24620UL,
- 0xbea97761UL, 0xf1e8e1a6UL, 0xe8f3d0e7UL, 0xc3de8324UL, 0xdac5b265UL,
- 0x5d5daeaaUL, 0x44469febUL, 0x6f6bcc28UL, 0x7670fd69UL, 0x39316baeUL,
- 0x202a5aefUL, 0x0b07092cUL, 0x121c386dUL, 0xdf4636f3UL, 0xc65d07b2UL,
- 0xed705471UL, 0xf46b6530UL, 0xbb2af3f7UL, 0xa231c2b6UL, 0x891c9175UL,
- 0x9007a034UL, 0x179fbcfbUL, 0x0e848dbaUL, 0x25a9de79UL, 0x3cb2ef38UL,
- 0x73f379ffUL, 0x6ae848beUL, 0x41c51b7dUL, 0x58de2a3cUL, 0xf0794f05UL,
- 0xe9627e44UL, 0xc24f2d87UL, 0xdb541cc6UL, 0x94158a01UL, 0x8d0ebb40UL,
- 0xa623e883UL, 0xbf38d9c2UL, 0x38a0c50dUL, 0x21bbf44cUL, 0x0a96a78fUL,
- 0x138d96ceUL, 0x5ccc0009UL, 0x45d73148UL, 0x6efa628bUL, 0x77e153caUL,
- 0xbabb5d54UL, 0xa3a06c15UL, 0x888d3fd6UL, 0x91960e97UL, 0xded79850UL,
- 0xc7cca911UL, 0xece1fad2UL, 0xf5facb93UL, 0x7262d75cUL, 0x6b79e61dUL,
- 0x4054b5deUL, 0x594f849fUL, 0x160e1258UL, 0x0f152319UL, 0x243870daUL,
- 0x3d23419bUL, 0x65fd6ba7UL, 0x7ce65ae6UL, 0x57cb0925UL, 0x4ed03864UL,
- 0x0191aea3UL, 0x188a9fe2UL, 0x33a7cc21UL, 0x2abcfd60UL, 0xad24e1afUL,
- 0xb43fd0eeUL, 0x9f12832dUL, 0x8609b26cUL, 0xc94824abUL, 0xd05315eaUL,
- 0xfb7e4629UL, 0xe2657768UL, 0x2f3f79f6UL, 0x362448b7UL, 0x1d091b74UL,
- 0x04122a35UL, 0x4b53bcf2UL, 0x52488db3UL, 0x7965de70UL, 0x607eef31UL,
- 0xe7e6f3feUL, 0xfefdc2bfUL, 0xd5d0917cUL, 0xcccba03dUL, 0x838a36faUL,
- 0x9a9107bbUL, 0xb1bc5478UL, 0xa8a76539UL, 0x3b83984bUL, 0x2298a90aUL,
- 0x09b5fac9UL, 0x10aecb88UL, 0x5fef5d4fUL, 0x46f46c0eUL, 0x6dd93fcdUL,
- 0x74c20e8cUL, 0xf35a1243UL, 0xea412302UL, 0xc16c70c1UL, 0xd8774180UL,
- 0x9736d747UL, 0x8e2de606UL, 0xa500b5c5UL, 0xbc1b8484UL, 0x71418a1aUL,
- 0x685abb5bUL, 0x4377e898UL, 0x5a6cd9d9UL, 0x152d4f1eUL, 0x0c367e5fUL,
- 0x271b2d9cUL, 0x3e001cddUL, 0xb9980012UL, 0xa0833153UL, 0x8bae6290UL,
- 0x92b553d1UL, 0xddf4c516UL, 0xc4eff457UL, 0xefc2a794UL, 0xf6d996d5UL,
- 0xae07bce9UL, 0xb71c8da8UL, 0x9c31de6bUL, 0x852aef2aUL, 0xca6b79edUL,
- 0xd37048acUL, 0xf85d1b6fUL, 0xe1462a2eUL, 0x66de36e1UL, 0x7fc507a0UL,
- 0x54e85463UL, 0x4df36522UL, 0x02b2f3e5UL, 0x1ba9c2a4UL, 0x30849167UL,
- 0x299fa026UL, 0xe4c5aeb8UL, 0xfdde9ff9UL, 0xd6f3cc3aUL, 0xcfe8fd7bUL,
- 0x80a96bbcUL, 0x99b25afdUL, 0xb29f093eUL, 0xab84387fUL, 0x2c1c24b0UL,
- 0x350715f1UL, 0x1e2a4632UL, 0x07317773UL, 0x4870e1b4UL, 0x516bd0f5UL,
- 0x7a468336UL, 0x635db277UL, 0xcbfad74eUL, 0xd2e1e60fUL, 0xf9ccb5ccUL,
- 0xe0d7848dUL, 0xaf96124aUL, 0xb68d230bUL, 0x9da070c8UL, 0x84bb4189UL,
- 0x03235d46UL, 0x1a386c07UL, 0x31153fc4UL, 0x280e0e85UL, 0x674f9842UL,
- 0x7e54a903UL, 0x5579fac0UL, 0x4c62cb81UL, 0x8138c51fUL, 0x9823f45eUL,
- 0xb30ea79dUL, 0xaa1596dcUL, 0xe554001bUL, 0xfc4f315aUL, 0xd7626299UL,
- 0xce7953d8UL, 0x49e14f17UL, 0x50fa7e56UL, 0x7bd72d95UL, 0x62cc1cd4UL,
- 0x2d8d8a13UL, 0x3496bb52UL, 0x1fbbe891UL, 0x06a0d9d0UL, 0x5e7ef3ecUL,
- 0x4765c2adUL, 0x6c48916eUL, 0x7553a02fUL, 0x3a1236e8UL, 0x230907a9UL,
- 0x0824546aUL, 0x113f652bUL, 0x96a779e4UL, 0x8fbc48a5UL, 0xa4911b66UL,
- 0xbd8a2a27UL, 0xf2cbbce0UL, 0xebd08da1UL, 0xc0fdde62UL, 0xd9e6ef23UL,
- 0x14bce1bdUL, 0x0da7d0fcUL, 0x268a833fUL, 0x3f91b27eUL, 0x70d024b9UL,
- 0x69cb15f8UL, 0x42e6463bUL, 0x5bfd777aUL, 0xdc656bb5UL, 0xc57e5af4UL,
- 0xee530937UL, 0xf7483876UL, 0xb809aeb1UL, 0xa1129ff0UL, 0x8a3fcc33UL,
- 0x9324fd72UL
- },
- {
- 0x00000000UL, 0x01c26a37UL, 0x0384d46eUL, 0x0246be59UL, 0x0709a8dcUL,
- 0x06cbc2ebUL, 0x048d7cb2UL, 0x054f1685UL, 0x0e1351b8UL, 0x0fd13b8fUL,
- 0x0d9785d6UL, 0x0c55efe1UL, 0x091af964UL, 0x08d89353UL, 0x0a9e2d0aUL,
- 0x0b5c473dUL, 0x1c26a370UL, 0x1de4c947UL, 0x1fa2771eUL, 0x1e601d29UL,
- 0x1b2f0bacUL, 0x1aed619bUL, 0x18abdfc2UL, 0x1969b5f5UL, 0x1235f2c8UL,
- 0x13f798ffUL, 0x11b126a6UL, 0x10734c91UL, 0x153c5a14UL, 0x14fe3023UL,
- 0x16b88e7aUL, 0x177ae44dUL, 0x384d46e0UL, 0x398f2cd7UL, 0x3bc9928eUL,
- 0x3a0bf8b9UL, 0x3f44ee3cUL, 0x3e86840bUL, 0x3cc03a52UL, 0x3d025065UL,
- 0x365e1758UL, 0x379c7d6fUL, 0x35dac336UL, 0x3418a901UL, 0x3157bf84UL,
- 0x3095d5b3UL, 0x32d36beaUL, 0x331101ddUL, 0x246be590UL, 0x25a98fa7UL,
- 0x27ef31feUL, 0x262d5bc9UL, 0x23624d4cUL, 0x22a0277bUL, 0x20e69922UL,
- 0x2124f315UL, 0x2a78b428UL, 0x2bbade1fUL, 0x29fc6046UL, 0x283e0a71UL,
- 0x2d711cf4UL, 0x2cb376c3UL, 0x2ef5c89aUL, 0x2f37a2adUL, 0x709a8dc0UL,
- 0x7158e7f7UL, 0x731e59aeUL, 0x72dc3399UL, 0x7793251cUL, 0x76514f2bUL,
- 0x7417f172UL, 0x75d59b45UL, 0x7e89dc78UL, 0x7f4bb64fUL, 0x7d0d0816UL,
- 0x7ccf6221UL, 0x798074a4UL, 0x78421e93UL, 0x7a04a0caUL, 0x7bc6cafdUL,
- 0x6cbc2eb0UL, 0x6d7e4487UL, 0x6f38fadeUL, 0x6efa90e9UL, 0x6bb5866cUL,
- 0x6a77ec5bUL, 0x68315202UL, 0x69f33835UL, 0x62af7f08UL, 0x636d153fUL,
- 0x612bab66UL, 0x60e9c151UL, 0x65a6d7d4UL, 0x6464bde3UL, 0x662203baUL,
- 0x67e0698dUL, 0x48d7cb20UL, 0x4915a117UL, 0x4b531f4eUL, 0x4a917579UL,
- 0x4fde63fcUL, 0x4e1c09cbUL, 0x4c5ab792UL, 0x4d98dda5UL, 0x46c49a98UL,
- 0x4706f0afUL, 0x45404ef6UL, 0x448224c1UL, 0x41cd3244UL, 0x400f5873UL,
- 0x4249e62aUL, 0x438b8c1dUL, 0x54f16850UL, 0x55330267UL, 0x5775bc3eUL,
- 0x56b7d609UL, 0x53f8c08cUL, 0x523aaabbUL, 0x507c14e2UL, 0x51be7ed5UL,
- 0x5ae239e8UL, 0x5b2053dfUL, 0x5966ed86UL, 0x58a487b1UL, 0x5deb9134UL,
- 0x5c29fb03UL, 0x5e6f455aUL, 0x5fad2f6dUL, 0xe1351b80UL, 0xe0f771b7UL,
- 0xe2b1cfeeUL, 0xe373a5d9UL, 0xe63cb35cUL, 0xe7fed96bUL, 0xe5b86732UL,
- 0xe47a0d05UL, 0xef264a38UL, 0xeee4200fUL, 0xeca29e56UL, 0xed60f461UL,
- 0xe82fe2e4UL, 0xe9ed88d3UL, 0xebab368aUL, 0xea695cbdUL, 0xfd13b8f0UL,
- 0xfcd1d2c7UL, 0xfe976c9eUL, 0xff5506a9UL, 0xfa1a102cUL, 0xfbd87a1bUL,
- 0xf99ec442UL, 0xf85cae75UL, 0xf300e948UL, 0xf2c2837fUL, 0xf0843d26UL,
- 0xf1465711UL, 0xf4094194UL, 0xf5cb2ba3UL, 0xf78d95faUL, 0xf64fffcdUL,
- 0xd9785d60UL, 0xd8ba3757UL, 0xdafc890eUL, 0xdb3ee339UL, 0xde71f5bcUL,
- 0xdfb39f8bUL, 0xddf521d2UL, 0xdc374be5UL, 0xd76b0cd8UL, 0xd6a966efUL,
- 0xd4efd8b6UL, 0xd52db281UL, 0xd062a404UL, 0xd1a0ce33UL, 0xd3e6706aUL,
- 0xd2241a5dUL, 0xc55efe10UL, 0xc49c9427UL, 0xc6da2a7eUL, 0xc7184049UL,
- 0xc25756ccUL, 0xc3953cfbUL, 0xc1d382a2UL, 0xc011e895UL, 0xcb4dafa8UL,
- 0xca8fc59fUL, 0xc8c97bc6UL, 0xc90b11f1UL, 0xcc440774UL, 0xcd866d43UL,
- 0xcfc0d31aUL, 0xce02b92dUL, 0x91af9640UL, 0x906dfc77UL, 0x922b422eUL,
- 0x93e92819UL, 0x96a63e9cUL, 0x976454abUL, 0x9522eaf2UL, 0x94e080c5UL,
- 0x9fbcc7f8UL, 0x9e7eadcfUL, 0x9c381396UL, 0x9dfa79a1UL, 0x98b56f24UL,
- 0x99770513UL, 0x9b31bb4aUL, 0x9af3d17dUL, 0x8d893530UL, 0x8c4b5f07UL,
- 0x8e0de15eUL, 0x8fcf8b69UL, 0x8a809decUL, 0x8b42f7dbUL, 0x89044982UL,
- 0x88c623b5UL, 0x839a6488UL, 0x82580ebfUL, 0x801eb0e6UL, 0x81dcdad1UL,
- 0x8493cc54UL, 0x8551a663UL, 0x8717183aUL, 0x86d5720dUL, 0xa9e2d0a0UL,
- 0xa820ba97UL, 0xaa6604ceUL, 0xaba46ef9UL, 0xaeeb787cUL, 0xaf29124bUL,
- 0xad6fac12UL, 0xacadc625UL, 0xa7f18118UL, 0xa633eb2fUL, 0xa4755576UL,
- 0xa5b73f41UL, 0xa0f829c4UL, 0xa13a43f3UL, 0xa37cfdaaUL, 0xa2be979dUL,
- 0xb5c473d0UL, 0xb40619e7UL, 0xb640a7beUL, 0xb782cd89UL, 0xb2cddb0cUL,
- 0xb30fb13bUL, 0xb1490f62UL, 0xb08b6555UL, 0xbbd72268UL, 0xba15485fUL,
- 0xb853f606UL, 0xb9919c31UL, 0xbcde8ab4UL, 0xbd1ce083UL, 0xbf5a5edaUL,
- 0xbe9834edUL
- },
- {
- 0x00000000UL, 0xb8bc6765UL, 0xaa09c88bUL, 0x12b5afeeUL, 0x8f629757UL,
- 0x37def032UL, 0x256b5fdcUL, 0x9dd738b9UL, 0xc5b428efUL, 0x7d084f8aUL,
- 0x6fbde064UL, 0xd7018701UL, 0x4ad6bfb8UL, 0xf26ad8ddUL, 0xe0df7733UL,
- 0x58631056UL, 0x5019579fUL, 0xe8a530faUL, 0xfa109f14UL, 0x42acf871UL,
- 0xdf7bc0c8UL, 0x67c7a7adUL, 0x75720843UL, 0xcdce6f26UL, 0x95ad7f70UL,
- 0x2d111815UL, 0x3fa4b7fbUL, 0x8718d09eUL, 0x1acfe827UL, 0xa2738f42UL,
- 0xb0c620acUL, 0x087a47c9UL, 0xa032af3eUL, 0x188ec85bUL, 0x0a3b67b5UL,
- 0xb28700d0UL, 0x2f503869UL, 0x97ec5f0cUL, 0x8559f0e2UL, 0x3de59787UL,
- 0x658687d1UL, 0xdd3ae0b4UL, 0xcf8f4f5aUL, 0x7733283fUL, 0xeae41086UL,
- 0x525877e3UL, 0x40edd80dUL, 0xf851bf68UL, 0xf02bf8a1UL, 0x48979fc4UL,
- 0x5a22302aUL, 0xe29e574fUL, 0x7f496ff6UL, 0xc7f50893UL, 0xd540a77dUL,
- 0x6dfcc018UL, 0x359fd04eUL, 0x8d23b72bUL, 0x9f9618c5UL, 0x272a7fa0UL,
- 0xbafd4719UL, 0x0241207cUL, 0x10f48f92UL, 0xa848e8f7UL, 0x9b14583dUL,
- 0x23a83f58UL, 0x311d90b6UL, 0x89a1f7d3UL, 0x1476cf6aUL, 0xaccaa80fUL,
- 0xbe7f07e1UL, 0x06c36084UL, 0x5ea070d2UL, 0xe61c17b7UL, 0xf4a9b859UL,
- 0x4c15df3cUL, 0xd1c2e785UL, 0x697e80e0UL, 0x7bcb2f0eUL, 0xc377486bUL,
- 0xcb0d0fa2UL, 0x73b168c7UL, 0x6104c729UL, 0xd9b8a04cUL, 0x446f98f5UL,
- 0xfcd3ff90UL, 0xee66507eUL, 0x56da371bUL, 0x0eb9274dUL, 0xb6054028UL,
- 0xa4b0efc6UL, 0x1c0c88a3UL, 0x81dbb01aUL, 0x3967d77fUL, 0x2bd27891UL,
- 0x936e1ff4UL, 0x3b26f703UL, 0x839a9066UL, 0x912f3f88UL, 0x299358edUL,
- 0xb4446054UL, 0x0cf80731UL, 0x1e4da8dfUL, 0xa6f1cfbaUL, 0xfe92dfecUL,
- 0x462eb889UL, 0x549b1767UL, 0xec277002UL, 0x71f048bbUL, 0xc94c2fdeUL,
- 0xdbf98030UL, 0x6345e755UL, 0x6b3fa09cUL, 0xd383c7f9UL, 0xc1366817UL,
- 0x798a0f72UL, 0xe45d37cbUL, 0x5ce150aeUL, 0x4e54ff40UL, 0xf6e89825UL,
- 0xae8b8873UL, 0x1637ef16UL, 0x048240f8UL, 0xbc3e279dUL, 0x21e91f24UL,
- 0x99557841UL, 0x8be0d7afUL, 0x335cb0caUL, 0xed59b63bUL, 0x55e5d15eUL,
- 0x47507eb0UL, 0xffec19d5UL, 0x623b216cUL, 0xda874609UL, 0xc832e9e7UL,
- 0x708e8e82UL, 0x28ed9ed4UL, 0x9051f9b1UL, 0x82e4565fUL, 0x3a58313aUL,
- 0xa78f0983UL, 0x1f336ee6UL, 0x0d86c108UL, 0xb53aa66dUL, 0xbd40e1a4UL,
- 0x05fc86c1UL, 0x1749292fUL, 0xaff54e4aUL, 0x322276f3UL, 0x8a9e1196UL,
- 0x982bbe78UL, 0x2097d91dUL, 0x78f4c94bUL, 0xc048ae2eUL, 0xd2fd01c0UL,
- 0x6a4166a5UL, 0xf7965e1cUL, 0x4f2a3979UL, 0x5d9f9697UL, 0xe523f1f2UL,
- 0x4d6b1905UL, 0xf5d77e60UL, 0xe762d18eUL, 0x5fdeb6ebUL, 0xc2098e52UL,
- 0x7ab5e937UL, 0x680046d9UL, 0xd0bc21bcUL, 0x88df31eaUL, 0x3063568fUL,
- 0x22d6f961UL, 0x9a6a9e04UL, 0x07bda6bdUL, 0xbf01c1d8UL, 0xadb46e36UL,
- 0x15080953UL, 0x1d724e9aUL, 0xa5ce29ffUL, 0xb77b8611UL, 0x0fc7e174UL,
- 0x9210d9cdUL, 0x2aacbea8UL, 0x38191146UL, 0x80a57623UL, 0xd8c66675UL,
- 0x607a0110UL, 0x72cfaefeUL, 0xca73c99bUL, 0x57a4f122UL, 0xef189647UL,
- 0xfdad39a9UL, 0x45115eccUL, 0x764dee06UL, 0xcef18963UL, 0xdc44268dUL,
- 0x64f841e8UL, 0xf92f7951UL, 0x41931e34UL, 0x5326b1daUL, 0xeb9ad6bfUL,
- 0xb3f9c6e9UL, 0x0b45a18cUL, 0x19f00e62UL, 0xa14c6907UL, 0x3c9b51beUL,
- 0x842736dbUL, 0x96929935UL, 0x2e2efe50UL, 0x2654b999UL, 0x9ee8defcUL,
- 0x8c5d7112UL, 0x34e11677UL, 0xa9362eceUL, 0x118a49abUL, 0x033fe645UL,
- 0xbb838120UL, 0xe3e09176UL, 0x5b5cf613UL, 0x49e959fdUL, 0xf1553e98UL,
- 0x6c820621UL, 0xd43e6144UL, 0xc68bceaaUL, 0x7e37a9cfUL, 0xd67f4138UL,
- 0x6ec3265dUL, 0x7c7689b3UL, 0xc4caeed6UL, 0x591dd66fUL, 0xe1a1b10aUL,
- 0xf3141ee4UL, 0x4ba87981UL, 0x13cb69d7UL, 0xab770eb2UL, 0xb9c2a15cUL,
- 0x017ec639UL, 0x9ca9fe80UL, 0x241599e5UL, 0x36a0360bUL, 0x8e1c516eUL,
- 0x866616a7UL, 0x3eda71c2UL, 0x2c6fde2cUL, 0x94d3b949UL, 0x090481f0UL,
- 0xb1b8e695UL, 0xa30d497bUL, 0x1bb12e1eUL, 0x43d23e48UL, 0xfb6e592dUL,
- 0xe9dbf6c3UL, 0x516791a6UL, 0xccb0a91fUL, 0x740cce7aUL, 0x66b96194UL,
- 0xde0506f1UL
- },
- {
- 0x00000000UL, 0x96300777UL, 0x2c610eeeUL, 0xba510999UL, 0x19c46d07UL,
- 0x8ff46a70UL, 0x35a563e9UL, 0xa395649eUL, 0x3288db0eUL, 0xa4b8dc79UL,
- 0x1ee9d5e0UL, 0x88d9d297UL, 0x2b4cb609UL, 0xbd7cb17eUL, 0x072db8e7UL,
- 0x911dbf90UL, 0x6410b71dUL, 0xf220b06aUL, 0x4871b9f3UL, 0xde41be84UL,
- 0x7dd4da1aUL, 0xebe4dd6dUL, 0x51b5d4f4UL, 0xc785d383UL, 0x56986c13UL,
- 0xc0a86b64UL, 0x7af962fdUL, 0xecc9658aUL, 0x4f5c0114UL, 0xd96c0663UL,
- 0x633d0ffaUL, 0xf50d088dUL, 0xc8206e3bUL, 0x5e10694cUL, 0xe44160d5UL,
- 0x727167a2UL, 0xd1e4033cUL, 0x47d4044bUL, 0xfd850dd2UL, 0x6bb50aa5UL,
- 0xfaa8b535UL, 0x6c98b242UL, 0xd6c9bbdbUL, 0x40f9bcacUL, 0xe36cd832UL,
- 0x755cdf45UL, 0xcf0dd6dcUL, 0x593dd1abUL, 0xac30d926UL, 0x3a00de51UL,
- 0x8051d7c8UL, 0x1661d0bfUL, 0xb5f4b421UL, 0x23c4b356UL, 0x9995bacfUL,
- 0x0fa5bdb8UL, 0x9eb80228UL, 0x0888055fUL, 0xb2d90cc6UL, 0x24e90bb1UL,
- 0x877c6f2fUL, 0x114c6858UL, 0xab1d61c1UL, 0x3d2d66b6UL, 0x9041dc76UL,
- 0x0671db01UL, 0xbc20d298UL, 0x2a10d5efUL, 0x8985b171UL, 0x1fb5b606UL,
- 0xa5e4bf9fUL, 0x33d4b8e8UL, 0xa2c90778UL, 0x34f9000fUL, 0x8ea80996UL,
- 0x18980ee1UL, 0xbb0d6a7fUL, 0x2d3d6d08UL, 0x976c6491UL, 0x015c63e6UL,
- 0xf4516b6bUL, 0x62616c1cUL, 0xd8306585UL, 0x4e0062f2UL, 0xed95066cUL,
- 0x7ba5011bUL, 0xc1f40882UL, 0x57c40ff5UL, 0xc6d9b065UL, 0x50e9b712UL,
- 0xeab8be8bUL, 0x7c88b9fcUL, 0xdf1ddd62UL, 0x492dda15UL, 0xf37cd38cUL,
- 0x654cd4fbUL, 0x5861b24dUL, 0xce51b53aUL, 0x7400bca3UL, 0xe230bbd4UL,
- 0x41a5df4aUL, 0xd795d83dUL, 0x6dc4d1a4UL, 0xfbf4d6d3UL, 0x6ae96943UL,
- 0xfcd96e34UL, 0x468867adUL, 0xd0b860daUL, 0x732d0444UL, 0xe51d0333UL,
- 0x5f4c0aaaUL, 0xc97c0dddUL, 0x3c710550UL, 0xaa410227UL, 0x10100bbeUL,
- 0x86200cc9UL, 0x25b56857UL, 0xb3856f20UL, 0x09d466b9UL, 0x9fe461ceUL,
- 0x0ef9de5eUL, 0x98c9d929UL, 0x2298d0b0UL, 0xb4a8d7c7UL, 0x173db359UL,
- 0x810db42eUL, 0x3b5cbdb7UL, 0xad6cbac0UL, 0x2083b8edUL, 0xb6b3bf9aUL,
- 0x0ce2b603UL, 0x9ad2b174UL, 0x3947d5eaUL, 0xaf77d29dUL, 0x1526db04UL,
- 0x8316dc73UL, 0x120b63e3UL, 0x843b6494UL, 0x3e6a6d0dUL, 0xa85a6a7aUL,
- 0x0bcf0ee4UL, 0x9dff0993UL, 0x27ae000aUL, 0xb19e077dUL, 0x44930ff0UL,
- 0xd2a30887UL, 0x68f2011eUL, 0xfec20669UL, 0x5d5762f7UL, 0xcb676580UL,
- 0x71366c19UL, 0xe7066b6eUL, 0x761bd4feUL, 0xe02bd389UL, 0x5a7ada10UL,
- 0xcc4add67UL, 0x6fdfb9f9UL, 0xf9efbe8eUL, 0x43beb717UL, 0xd58eb060UL,
- 0xe8a3d6d6UL, 0x7e93d1a1UL, 0xc4c2d838UL, 0x52f2df4fUL, 0xf167bbd1UL,
- 0x6757bca6UL, 0xdd06b53fUL, 0x4b36b248UL, 0xda2b0dd8UL, 0x4c1b0aafUL,
- 0xf64a0336UL, 0x607a0441UL, 0xc3ef60dfUL, 0x55df67a8UL, 0xef8e6e31UL,
- 0x79be6946UL, 0x8cb361cbUL, 0x1a8366bcUL, 0xa0d26f25UL, 0x36e26852UL,
- 0x95770cccUL, 0x03470bbbUL, 0xb9160222UL, 0x2f260555UL, 0xbe3bbac5UL,
- 0x280bbdb2UL, 0x925ab42bUL, 0x046ab35cUL, 0xa7ffd7c2UL, 0x31cfd0b5UL,
- 0x8b9ed92cUL, 0x1daede5bUL, 0xb0c2649bUL, 0x26f263ecUL, 0x9ca36a75UL,
- 0x0a936d02UL, 0xa906099cUL, 0x3f360eebUL, 0x85670772UL, 0x13570005UL,
- 0x824abf95UL, 0x147ab8e2UL, 0xae2bb17bUL, 0x381bb60cUL, 0x9b8ed292UL,
- 0x0dbed5e5UL, 0xb7efdc7cUL, 0x21dfdb0bUL, 0xd4d2d386UL, 0x42e2d4f1UL,
- 0xf8b3dd68UL, 0x6e83da1fUL, 0xcd16be81UL, 0x5b26b9f6UL, 0xe177b06fUL,
- 0x7747b718UL, 0xe65a0888UL, 0x706a0fffUL, 0xca3b0666UL, 0x5c0b0111UL,
- 0xff9e658fUL, 0x69ae62f8UL, 0xd3ff6b61UL, 0x45cf6c16UL, 0x78e20aa0UL,
- 0xeed20dd7UL, 0x5483044eUL, 0xc2b30339UL, 0x612667a7UL, 0xf71660d0UL,
- 0x4d476949UL, 0xdb776e3eUL, 0x4a6ad1aeUL, 0xdc5ad6d9UL, 0x660bdf40UL,
- 0xf03bd837UL, 0x53aebca9UL, 0xc59ebbdeUL, 0x7fcfb247UL, 0xe9ffb530UL,
- 0x1cf2bdbdUL, 0x8ac2bacaUL, 0x3093b353UL, 0xa6a3b424UL, 0x0536d0baUL,
- 0x9306d7cdUL, 0x2957de54UL, 0xbf67d923UL, 0x2e7a66b3UL, 0xb84a61c4UL,
- 0x021b685dUL, 0x942b6f2aUL, 0x37be0bb4UL, 0xa18e0cc3UL, 0x1bdf055aUL,
- 0x8def022dUL
- },
- {
- 0x00000000UL, 0x41311b19UL, 0x82623632UL, 0xc3532d2bUL, 0x04c56c64UL,
- 0x45f4777dUL, 0x86a75a56UL, 0xc796414fUL, 0x088ad9c8UL, 0x49bbc2d1UL,
- 0x8ae8effaUL, 0xcbd9f4e3UL, 0x0c4fb5acUL, 0x4d7eaeb5UL, 0x8e2d839eUL,
- 0xcf1c9887UL, 0x5112c24aUL, 0x1023d953UL, 0xd370f478UL, 0x9241ef61UL,
- 0x55d7ae2eUL, 0x14e6b537UL, 0xd7b5981cUL, 0x96848305UL, 0x59981b82UL,
- 0x18a9009bUL, 0xdbfa2db0UL, 0x9acb36a9UL, 0x5d5d77e6UL, 0x1c6c6cffUL,
- 0xdf3f41d4UL, 0x9e0e5acdUL, 0xa2248495UL, 0xe3159f8cUL, 0x2046b2a7UL,
- 0x6177a9beUL, 0xa6e1e8f1UL, 0xe7d0f3e8UL, 0x2483dec3UL, 0x65b2c5daUL,
- 0xaaae5d5dUL, 0xeb9f4644UL, 0x28cc6b6fUL, 0x69fd7076UL, 0xae6b3139UL,
- 0xef5a2a20UL, 0x2c09070bUL, 0x6d381c12UL, 0xf33646dfUL, 0xb2075dc6UL,
- 0x715470edUL, 0x30656bf4UL, 0xf7f32abbUL, 0xb6c231a2UL, 0x75911c89UL,
- 0x34a00790UL, 0xfbbc9f17UL, 0xba8d840eUL, 0x79dea925UL, 0x38efb23cUL,
- 0xff79f373UL, 0xbe48e86aUL, 0x7d1bc541UL, 0x3c2ade58UL, 0x054f79f0UL,
- 0x447e62e9UL, 0x872d4fc2UL, 0xc61c54dbUL, 0x018a1594UL, 0x40bb0e8dUL,
- 0x83e823a6UL, 0xc2d938bfUL, 0x0dc5a038UL, 0x4cf4bb21UL, 0x8fa7960aUL,
- 0xce968d13UL, 0x0900cc5cUL, 0x4831d745UL, 0x8b62fa6eUL, 0xca53e177UL,
- 0x545dbbbaUL, 0x156ca0a3UL, 0xd63f8d88UL, 0x970e9691UL, 0x5098d7deUL,
- 0x11a9ccc7UL, 0xd2fae1ecUL, 0x93cbfaf5UL, 0x5cd76272UL, 0x1de6796bUL,
- 0xdeb55440UL, 0x9f844f59UL, 0x58120e16UL, 0x1923150fUL, 0xda703824UL,
- 0x9b41233dUL, 0xa76bfd65UL, 0xe65ae67cUL, 0x2509cb57UL, 0x6438d04eUL,
- 0xa3ae9101UL, 0xe29f8a18UL, 0x21cca733UL, 0x60fdbc2aUL, 0xafe124adUL,
- 0xeed03fb4UL, 0x2d83129fUL, 0x6cb20986UL, 0xab2448c9UL, 0xea1553d0UL,
- 0x29467efbUL, 0x687765e2UL, 0xf6793f2fUL, 0xb7482436UL, 0x741b091dUL,
- 0x352a1204UL, 0xf2bc534bUL, 0xb38d4852UL, 0x70de6579UL, 0x31ef7e60UL,
- 0xfef3e6e7UL, 0xbfc2fdfeUL, 0x7c91d0d5UL, 0x3da0cbccUL, 0xfa368a83UL,
- 0xbb07919aUL, 0x7854bcb1UL, 0x3965a7a8UL, 0x4b98833bUL, 0x0aa99822UL,
- 0xc9fab509UL, 0x88cbae10UL, 0x4f5def5fUL, 0x0e6cf446UL, 0xcd3fd96dUL,
- 0x8c0ec274UL, 0x43125af3UL, 0x022341eaUL, 0xc1706cc1UL, 0x804177d8UL,
- 0x47d73697UL, 0x06e62d8eUL, 0xc5b500a5UL, 0x84841bbcUL, 0x1a8a4171UL,
- 0x5bbb5a68UL, 0x98e87743UL, 0xd9d96c5aUL, 0x1e4f2d15UL, 0x5f7e360cUL,
- 0x9c2d1b27UL, 0xdd1c003eUL, 0x120098b9UL, 0x533183a0UL, 0x9062ae8bUL,
- 0xd153b592UL, 0x16c5f4ddUL, 0x57f4efc4UL, 0x94a7c2efUL, 0xd596d9f6UL,
- 0xe9bc07aeUL, 0xa88d1cb7UL, 0x6bde319cUL, 0x2aef2a85UL, 0xed796bcaUL,
- 0xac4870d3UL, 0x6f1b5df8UL, 0x2e2a46e1UL, 0xe136de66UL, 0xa007c57fUL,
- 0x6354e854UL, 0x2265f34dUL, 0xe5f3b202UL, 0xa4c2a91bUL, 0x67918430UL,
- 0x26a09f29UL, 0xb8aec5e4UL, 0xf99fdefdUL, 0x3accf3d6UL, 0x7bfde8cfUL,
- 0xbc6ba980UL, 0xfd5ab299UL, 0x3e099fb2UL, 0x7f3884abUL, 0xb0241c2cUL,
- 0xf1150735UL, 0x32462a1eUL, 0x73773107UL, 0xb4e17048UL, 0xf5d06b51UL,
- 0x3683467aUL, 0x77b25d63UL, 0x4ed7facbUL, 0x0fe6e1d2UL, 0xccb5ccf9UL,
- 0x8d84d7e0UL, 0x4a1296afUL, 0x0b238db6UL, 0xc870a09dUL, 0x8941bb84UL,
- 0x465d2303UL, 0x076c381aUL, 0xc43f1531UL, 0x850e0e28UL, 0x42984f67UL,
- 0x03a9547eUL, 0xc0fa7955UL, 0x81cb624cUL, 0x1fc53881UL, 0x5ef42398UL,
- 0x9da70eb3UL, 0xdc9615aaUL, 0x1b0054e5UL, 0x5a314ffcUL, 0x996262d7UL,
- 0xd85379ceUL, 0x174fe149UL, 0x567efa50UL, 0x952dd77bUL, 0xd41ccc62UL,
- 0x138a8d2dUL, 0x52bb9634UL, 0x91e8bb1fUL, 0xd0d9a006UL, 0xecf37e5eUL,
- 0xadc26547UL, 0x6e91486cUL, 0x2fa05375UL, 0xe836123aUL, 0xa9070923UL,
- 0x6a542408UL, 0x2b653f11UL, 0xe479a796UL, 0xa548bc8fUL, 0x661b91a4UL,
- 0x272a8abdUL, 0xe0bccbf2UL, 0xa18dd0ebUL, 0x62defdc0UL, 0x23efe6d9UL,
- 0xbde1bc14UL, 0xfcd0a70dUL, 0x3f838a26UL, 0x7eb2913fUL, 0xb924d070UL,
- 0xf815cb69UL, 0x3b46e642UL, 0x7a77fd5bUL, 0xb56b65dcUL, 0xf45a7ec5UL,
- 0x370953eeUL, 0x763848f7UL, 0xb1ae09b8UL, 0xf09f12a1UL, 0x33cc3f8aUL,
- 0x72fd2493UL
- },
- {
- 0x00000000UL, 0x376ac201UL, 0x6ed48403UL, 0x59be4602UL, 0xdca80907UL,
- 0xebc2cb06UL, 0xb27c8d04UL, 0x85164f05UL, 0xb851130eUL, 0x8f3bd10fUL,
- 0xd685970dUL, 0xe1ef550cUL, 0x64f91a09UL, 0x5393d808UL, 0x0a2d9e0aUL,
- 0x3d475c0bUL, 0x70a3261cUL, 0x47c9e41dUL, 0x1e77a21fUL, 0x291d601eUL,
- 0xac0b2f1bUL, 0x9b61ed1aUL, 0xc2dfab18UL, 0xf5b56919UL, 0xc8f23512UL,
- 0xff98f713UL, 0xa626b111UL, 0x914c7310UL, 0x145a3c15UL, 0x2330fe14UL,
- 0x7a8eb816UL, 0x4de47a17UL, 0xe0464d38UL, 0xd72c8f39UL, 0x8e92c93bUL,
- 0xb9f80b3aUL, 0x3cee443fUL, 0x0b84863eUL, 0x523ac03cUL, 0x6550023dUL,
- 0x58175e36UL, 0x6f7d9c37UL, 0x36c3da35UL, 0x01a91834UL, 0x84bf5731UL,
- 0xb3d59530UL, 0xea6bd332UL, 0xdd011133UL, 0x90e56b24UL, 0xa78fa925UL,
- 0xfe31ef27UL, 0xc95b2d26UL, 0x4c4d6223UL, 0x7b27a022UL, 0x2299e620UL,
- 0x15f32421UL, 0x28b4782aUL, 0x1fdeba2bUL, 0x4660fc29UL, 0x710a3e28UL,
- 0xf41c712dUL, 0xc376b32cUL, 0x9ac8f52eUL, 0xada2372fUL, 0xc08d9a70UL,
- 0xf7e75871UL, 0xae591e73UL, 0x9933dc72UL, 0x1c259377UL, 0x2b4f5176UL,
- 0x72f11774UL, 0x459bd575UL, 0x78dc897eUL, 0x4fb64b7fUL, 0x16080d7dUL,
- 0x2162cf7cUL, 0xa4748079UL, 0x931e4278UL, 0xcaa0047aUL, 0xfdcac67bUL,
- 0xb02ebc6cUL, 0x87447e6dUL, 0xdefa386fUL, 0xe990fa6eUL, 0x6c86b56bUL,
- 0x5bec776aUL, 0x02523168UL, 0x3538f369UL, 0x087faf62UL, 0x3f156d63UL,
- 0x66ab2b61UL, 0x51c1e960UL, 0xd4d7a665UL, 0xe3bd6464UL, 0xba032266UL,
- 0x8d69e067UL, 0x20cbd748UL, 0x17a11549UL, 0x4e1f534bUL, 0x7975914aUL,
- 0xfc63de4fUL, 0xcb091c4eUL, 0x92b75a4cUL, 0xa5dd984dUL, 0x989ac446UL,
- 0xaff00647UL, 0xf64e4045UL, 0xc1248244UL, 0x4432cd41UL, 0x73580f40UL,
- 0x2ae64942UL, 0x1d8c8b43UL, 0x5068f154UL, 0x67023355UL, 0x3ebc7557UL,
- 0x09d6b756UL, 0x8cc0f853UL, 0xbbaa3a52UL, 0xe2147c50UL, 0xd57ebe51UL,
- 0xe839e25aUL, 0xdf53205bUL, 0x86ed6659UL, 0xb187a458UL, 0x3491eb5dUL,
- 0x03fb295cUL, 0x5a456f5eUL, 0x6d2fad5fUL, 0x801b35e1UL, 0xb771f7e0UL,
- 0xeecfb1e2UL, 0xd9a573e3UL, 0x5cb33ce6UL, 0x6bd9fee7UL, 0x3267b8e5UL,
- 0x050d7ae4UL, 0x384a26efUL, 0x0f20e4eeUL, 0x569ea2ecUL, 0x61f460edUL,
- 0xe4e22fe8UL, 0xd388ede9UL, 0x8a36abebUL, 0xbd5c69eaUL, 0xf0b813fdUL,
- 0xc7d2d1fcUL, 0x9e6c97feUL, 0xa90655ffUL, 0x2c101afaUL, 0x1b7ad8fbUL,
- 0x42c49ef9UL, 0x75ae5cf8UL, 0x48e900f3UL, 0x7f83c2f2UL, 0x263d84f0UL,
- 0x115746f1UL, 0x944109f4UL, 0xa32bcbf5UL, 0xfa958df7UL, 0xcdff4ff6UL,
- 0x605d78d9UL, 0x5737bad8UL, 0x0e89fcdaUL, 0x39e33edbUL, 0xbcf571deUL,
- 0x8b9fb3dfUL, 0xd221f5ddUL, 0xe54b37dcUL, 0xd80c6bd7UL, 0xef66a9d6UL,
- 0xb6d8efd4UL, 0x81b22dd5UL, 0x04a462d0UL, 0x33cea0d1UL, 0x6a70e6d3UL,
- 0x5d1a24d2UL, 0x10fe5ec5UL, 0x27949cc4UL, 0x7e2adac6UL, 0x494018c7UL,
- 0xcc5657c2UL, 0xfb3c95c3UL, 0xa282d3c1UL, 0x95e811c0UL, 0xa8af4dcbUL,
- 0x9fc58fcaUL, 0xc67bc9c8UL, 0xf1110bc9UL, 0x740744ccUL, 0x436d86cdUL,
- 0x1ad3c0cfUL, 0x2db902ceUL, 0x4096af91UL, 0x77fc6d90UL, 0x2e422b92UL,
- 0x1928e993UL, 0x9c3ea696UL, 0xab546497UL, 0xf2ea2295UL, 0xc580e094UL,
- 0xf8c7bc9fUL, 0xcfad7e9eUL, 0x9613389cUL, 0xa179fa9dUL, 0x246fb598UL,
- 0x13057799UL, 0x4abb319bUL, 0x7dd1f39aUL, 0x3035898dUL, 0x075f4b8cUL,
- 0x5ee10d8eUL, 0x698bcf8fUL, 0xec9d808aUL, 0xdbf7428bUL, 0x82490489UL,
- 0xb523c688UL, 0x88649a83UL, 0xbf0e5882UL, 0xe6b01e80UL, 0xd1dadc81UL,
- 0x54cc9384UL, 0x63a65185UL, 0x3a181787UL, 0x0d72d586UL, 0xa0d0e2a9UL,
- 0x97ba20a8UL, 0xce0466aaUL, 0xf96ea4abUL, 0x7c78ebaeUL, 0x4b1229afUL,
- 0x12ac6fadUL, 0x25c6adacUL, 0x1881f1a7UL, 0x2feb33a6UL, 0x765575a4UL,
- 0x413fb7a5UL, 0xc429f8a0UL, 0xf3433aa1UL, 0xaafd7ca3UL, 0x9d97bea2UL,
- 0xd073c4b5UL, 0xe71906b4UL, 0xbea740b6UL, 0x89cd82b7UL, 0x0cdbcdb2UL,
- 0x3bb10fb3UL, 0x620f49b1UL, 0x55658bb0UL, 0x6822d7bbUL, 0x5f4815baUL,
- 0x06f653b8UL, 0x319c91b9UL, 0xb48adebcUL, 0x83e01cbdUL, 0xda5e5abfUL,
- 0xed3498beUL
- },
- {
- 0x00000000UL, 0x6567bcb8UL, 0x8bc809aaUL, 0xeeafb512UL, 0x5797628fUL,
- 0x32f0de37UL, 0xdc5f6b25UL, 0xb938d79dUL, 0xef28b4c5UL, 0x8a4f087dUL,
- 0x64e0bd6fUL, 0x018701d7UL, 0xb8bfd64aUL, 0xddd86af2UL, 0x3377dfe0UL,
- 0x56106358UL, 0x9f571950UL, 0xfa30a5e8UL, 0x149f10faUL, 0x71f8ac42UL,
- 0xc8c07bdfUL, 0xada7c767UL, 0x43087275UL, 0x266fcecdUL, 0x707fad95UL,
- 0x1518112dUL, 0xfbb7a43fUL, 0x9ed01887UL, 0x27e8cf1aUL, 0x428f73a2UL,
- 0xac20c6b0UL, 0xc9477a08UL, 0x3eaf32a0UL, 0x5bc88e18UL, 0xb5673b0aUL,
- 0xd00087b2UL, 0x6938502fUL, 0x0c5fec97UL, 0xe2f05985UL, 0x8797e53dUL,
- 0xd1878665UL, 0xb4e03addUL, 0x5a4f8fcfUL, 0x3f283377UL, 0x8610e4eaUL,
- 0xe3775852UL, 0x0dd8ed40UL, 0x68bf51f8UL, 0xa1f82bf0UL, 0xc49f9748UL,
- 0x2a30225aUL, 0x4f579ee2UL, 0xf66f497fUL, 0x9308f5c7UL, 0x7da740d5UL,
- 0x18c0fc6dUL, 0x4ed09f35UL, 0x2bb7238dUL, 0xc518969fUL, 0xa07f2a27UL,
- 0x1947fdbaUL, 0x7c204102UL, 0x928ff410UL, 0xf7e848a8UL, 0x3d58149bUL,
- 0x583fa823UL, 0xb6901d31UL, 0xd3f7a189UL, 0x6acf7614UL, 0x0fa8caacUL,
- 0xe1077fbeUL, 0x8460c306UL, 0xd270a05eUL, 0xb7171ce6UL, 0x59b8a9f4UL,
- 0x3cdf154cUL, 0x85e7c2d1UL, 0xe0807e69UL, 0x0e2fcb7bUL, 0x6b4877c3UL,
- 0xa20f0dcbUL, 0xc768b173UL, 0x29c70461UL, 0x4ca0b8d9UL, 0xf5986f44UL,
- 0x90ffd3fcUL, 0x7e5066eeUL, 0x1b37da56UL, 0x4d27b90eUL, 0x284005b6UL,
- 0xc6efb0a4UL, 0xa3880c1cUL, 0x1ab0db81UL, 0x7fd76739UL, 0x9178d22bUL,
- 0xf41f6e93UL, 0x03f7263bUL, 0x66909a83UL, 0x883f2f91UL, 0xed589329UL,
- 0x546044b4UL, 0x3107f80cUL, 0xdfa84d1eUL, 0xbacff1a6UL, 0xecdf92feUL,
- 0x89b82e46UL, 0x67179b54UL, 0x027027ecUL, 0xbb48f071UL, 0xde2f4cc9UL,
- 0x3080f9dbUL, 0x55e74563UL, 0x9ca03f6bUL, 0xf9c783d3UL, 0x176836c1UL,
- 0x720f8a79UL, 0xcb375de4UL, 0xae50e15cUL, 0x40ff544eUL, 0x2598e8f6UL,
- 0x73888baeUL, 0x16ef3716UL, 0xf8408204UL, 0x9d273ebcUL, 0x241fe921UL,
- 0x41785599UL, 0xafd7e08bUL, 0xcab05c33UL, 0x3bb659edUL, 0x5ed1e555UL,
- 0xb07e5047UL, 0xd519ecffUL, 0x6c213b62UL, 0x094687daUL, 0xe7e932c8UL,
- 0x828e8e70UL, 0xd49eed28UL, 0xb1f95190UL, 0x5f56e482UL, 0x3a31583aUL,
- 0x83098fa7UL, 0xe66e331fUL, 0x08c1860dUL, 0x6da63ab5UL, 0xa4e140bdUL,
- 0xc186fc05UL, 0x2f294917UL, 0x4a4ef5afUL, 0xf3762232UL, 0x96119e8aUL,
- 0x78be2b98UL, 0x1dd99720UL, 0x4bc9f478UL, 0x2eae48c0UL, 0xc001fdd2UL,
- 0xa566416aUL, 0x1c5e96f7UL, 0x79392a4fUL, 0x97969f5dUL, 0xf2f123e5UL,
- 0x05196b4dUL, 0x607ed7f5UL, 0x8ed162e7UL, 0xebb6de5fUL, 0x528e09c2UL,
- 0x37e9b57aUL, 0xd9460068UL, 0xbc21bcd0UL, 0xea31df88UL, 0x8f566330UL,
- 0x61f9d622UL, 0x049e6a9aUL, 0xbda6bd07UL, 0xd8c101bfUL, 0x366eb4adUL,
- 0x53090815UL, 0x9a4e721dUL, 0xff29cea5UL, 0x11867bb7UL, 0x74e1c70fUL,
- 0xcdd91092UL, 0xa8beac2aUL, 0x46111938UL, 0x2376a580UL, 0x7566c6d8UL,
- 0x10017a60UL, 0xfeaecf72UL, 0x9bc973caUL, 0x22f1a457UL, 0x479618efUL,
- 0xa939adfdUL, 0xcc5e1145UL, 0x06ee4d76UL, 0x6389f1ceUL, 0x8d2644dcUL,
- 0xe841f864UL, 0x51792ff9UL, 0x341e9341UL, 0xdab12653UL, 0xbfd69aebUL,
- 0xe9c6f9b3UL, 0x8ca1450bUL, 0x620ef019UL, 0x07694ca1UL, 0xbe519b3cUL,
- 0xdb362784UL, 0x35999296UL, 0x50fe2e2eUL, 0x99b95426UL, 0xfcdee89eUL,
- 0x12715d8cUL, 0x7716e134UL, 0xce2e36a9UL, 0xab498a11UL, 0x45e63f03UL,
- 0x208183bbUL, 0x7691e0e3UL, 0x13f65c5bUL, 0xfd59e949UL, 0x983e55f1UL,
- 0x2106826cUL, 0x44613ed4UL, 0xaace8bc6UL, 0xcfa9377eUL, 0x38417fd6UL,
- 0x5d26c36eUL, 0xb389767cUL, 0xd6eecac4UL, 0x6fd61d59UL, 0x0ab1a1e1UL,
- 0xe41e14f3UL, 0x8179a84bUL, 0xd769cb13UL, 0xb20e77abUL, 0x5ca1c2b9UL,
- 0x39c67e01UL, 0x80fea99cUL, 0xe5991524UL, 0x0b36a036UL, 0x6e511c8eUL,
- 0xa7166686UL, 0xc271da3eUL, 0x2cde6f2cUL, 0x49b9d394UL, 0xf0810409UL,
- 0x95e6b8b1UL, 0x7b490da3UL, 0x1e2eb11bUL, 0x483ed243UL, 0x2d596efbUL,
- 0xc3f6dbe9UL, 0xa6916751UL, 0x1fa9b0ccUL, 0x7ace0c74UL, 0x9461b966UL,
- 0xf10605deUL
-#endif
- }
-};
diff --git a/WebCore/platform/image-decoders/zlib/deflate.c b/WebCore/platform/image-decoders/zlib/deflate.c
deleted file mode 100644
index 46a51fe..0000000
--- a/WebCore/platform/image-decoders/zlib/deflate.c
+++ /dev/null
@@ -1,1736 +0,0 @@
-/* deflate.c -- compress data using the deflation algorithm
- * Copyright (C) 1995-2005 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/*
- * ALGORITHM
- *
- * The "deflation" process depends on being able to identify portions
- * of the input text which are identical to earlier input (within a
- * sliding window trailing behind the input currently being processed).
- *
- * The most straightforward technique turns out to be the fastest for
- * most input files: try all possible matches and select the longest.
- * The key feature of this algorithm is that insertions into the string
- * dictionary are very simple and thus fast, and deletions are avoided
- * completely. Insertions are performed at each input character, whereas
- * string matches are performed only when the previous match ends. So it
- * is preferable to spend more time in matches to allow very fast string
- * insertions and avoid deletions. The matching algorithm for small
- * strings is inspired from that of Rabin & Karp. A brute force approach
- * is used to find longer strings when a small match has been found.
- * A similar algorithm is used in comic (by Jan-Mark Wams) and freeze
- * (by Leonid Broukhis).
- * A previous version of this file used a more sophisticated algorithm
- * (by Fiala and Greene) which is guaranteed to run in linear amortized
- * time, but has a larger average cost, uses more memory and is patented.
- * However the F&G algorithm may be faster for some highly redundant
- * files if the parameter max_chain_length (described below) is too large.
- *
- * ACKNOWLEDGEMENTS
- *
- * The idea of lazy evaluation of matches is due to Jan-Mark Wams, and
- * I found it in 'freeze' written by Leonid Broukhis.
- * Thanks to many people for bug reports and testing.
- *
- * REFERENCES
- *
- * Deutsch, L.P.,"DEFLATE Compressed Data Format Specification".
- * Available in http://www.ietf.org/rfc/rfc1951.txt
- *
- * A description of the Rabin and Karp algorithm is given in the book
- * "Algorithms" by R. Sedgewick, Addison-Wesley, p252.
- *
- * Fiala,E.R., and Greene,D.H.
- * Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595
- *
- */
-
-/* @(#) $Id: deflate.c,v 3.6 2005/08/04 19:14:14 tor%cs.brown.edu Exp $ */
-
-#include "deflate.h"
-
-const char deflate_copyright[] =
- " deflate 1.2.3 Copyright 1995-2005 Jean-loup Gailly ";
-/*
- If you use the zlib library in a product, an acknowledgment is welcome
- in the documentation of your product. If for some reason you cannot
- include such an acknowledgment, I would appreciate that you keep this
- copyright string in the executable of your product.
- */
-
-/* ===========================================================================
- * Function prototypes.
- */
-typedef enum {
- need_more, /* block not completed, need more input or more output */
- block_done, /* block flush performed */
- finish_started, /* finish started, need only more output at next deflate */
- finish_done /* finish done, accept no more input or output */
-} block_state;
-
-typedef block_state (*compress_func) OF((deflate_state *s, int flush));
-/* Compression function. Returns the block state after the call. */
-
-local void fill_window OF((deflate_state *s));
-local block_state deflate_stored OF((deflate_state *s, int flush));
-local block_state deflate_fast OF((deflate_state *s, int flush));
-#ifndef FASTEST
-local block_state deflate_slow OF((deflate_state *s, int flush));
-#endif
-local void lm_init OF((deflate_state *s));
-local void putShortMSB OF((deflate_state *s, uInt b));
-local void flush_pending OF((z_streamp strm));
-local int read_buf OF((z_streamp strm, Bytef *buf, unsigned size));
-#ifndef FASTEST
-#ifdef ASMV
- void match_init OF((void)); /* asm code initialization */
- uInt longest_match OF((deflate_state *s, IPos cur_match));
-#else
-local uInt longest_match OF((deflate_state *s, IPos cur_match));
-#endif
-#endif
-local uInt longest_match_fast OF((deflate_state *s, IPos cur_match));
-
-#ifdef DEBUG
-local void check_match OF((deflate_state *s, IPos start, IPos match,
- int length));
-#endif
-
-/* ===========================================================================
- * Local data
- */
-
-#define NIL 0
-/* Tail of hash chains */
-
-#ifndef TOO_FAR
-# define TOO_FAR 4096
-#endif
-/* Matches of length 3 are discarded if their distance exceeds TOO_FAR */
-
-#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
-/* Minimum amount of lookahead, except at the end of the input file.
- * See deflate.c for comments about the MIN_MATCH+1.
- */
-
-/* Values for max_lazy_match, good_match and max_chain_length, depending on
- * the desired pack level (0..9). The values given below have been tuned to
- * exclude worst case performance for pathological files. Better values may be
- * found for specific files.
- */
-typedef struct config_s {
- ush good_length; /* reduce lazy search above this match length */
- ush max_lazy; /* do not perform lazy search above this match length */
- ush nice_length; /* quit search above this match length */
- ush max_chain;
- compress_func func;
-} config;
-
-#ifdef FASTEST
-local const config configuration_table[2] = {
-/* good lazy nice chain */
-/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */
-/* 1 */ {4, 4, 8, 4, deflate_fast}}; /* max speed, no lazy matches */
-#else
-local const config configuration_table[10] = {
-/* good lazy nice chain */
-/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */
-/* 1 */ {4, 4, 8, 4, deflate_fast}, /* max speed, no lazy matches */
-/* 2 */ {4, 5, 16, 8, deflate_fast},
-/* 3 */ {4, 6, 32, 32, deflate_fast},
-
-/* 4 */ {4, 4, 16, 16, deflate_slow}, /* lazy matches */
-/* 5 */ {8, 16, 32, 32, deflate_slow},
-/* 6 */ {8, 16, 128, 128, deflate_slow},
-/* 7 */ {8, 32, 128, 256, deflate_slow},
-/* 8 */ {32, 128, 258, 1024, deflate_slow},
-/* 9 */ {32, 258, 258, 4096, deflate_slow}}; /* max compression */
-#endif
-
-/* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4
- * For deflate_fast() (levels <= 3) good is ignored and lazy has a different
- * meaning.
- */
-
-#define EQUAL 0
-/* result of memcmp for equal strings */
-
-#ifndef NO_DUMMY_DECL
-struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
-#endif
-
-/* ===========================================================================
- * Update a hash value with the given input byte
- * IN assertion: all calls to to UPDATE_HASH are made with consecutive
- * input characters, so that a running hash key can be computed from the
- * previous key instead of complete recalculation each time.
- */
-#define UPDATE_HASH(s,h,c) (h = (((h)<<s->hash_shift) ^ (c)) & s->hash_mask)
-
-
-/* ===========================================================================
- * Insert string str in the dictionary and set match_head to the previous head
- * of the hash chain (the most recent string with same hash key). Return
- * the previous length of the hash chain.
- * If this file is compiled with -DFASTEST, the compression level is forced
- * to 1, and no hash chains are maintained.
- * IN assertion: all calls to to INSERT_STRING are made with consecutive
- * input characters and the first MIN_MATCH bytes of str are valid
- * (except for the last MIN_MATCH-1 bytes of the input file).
- */
-#ifdef FASTEST
-#define INSERT_STRING(s, str, match_head) \
- (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \
- match_head = s->head[s->ins_h], \
- s->head[s->ins_h] = (Pos)(str))
-#else
-#define INSERT_STRING(s, str, match_head) \
- (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \
- match_head = s->prev[(str) & s->w_mask] = s->head[s->ins_h], \
- s->head[s->ins_h] = (Pos)(str))
-#endif
-
-/* ===========================================================================
- * Initialize the hash table (avoiding 64K overflow for 16 bit systems).
- * prev[] will be initialized on the fly.
- */
-#define CLEAR_HASH(s) \
- s->head[s->hash_size-1] = NIL; \
- zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head));
-
-/* ========================================================================= */
-int ZEXPORT deflateInit_(strm, level, version, stream_size)
- z_streamp strm;
- int level;
- const char *version;
- int stream_size;
-{
- return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL,
- Z_DEFAULT_STRATEGY, version, stream_size);
- /* To do: ignore strm->next_in if we use it as window */
-}
-
-/* ========================================================================= */
-int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
- version, stream_size)
- z_streamp strm;
- int level;
- int method;
- int windowBits;
- int memLevel;
- int strategy;
- const char *version;
- int stream_size;
-{
- deflate_state *s;
- int wrap = 1;
- static const char my_version[] = ZLIB_VERSION;
-
- ushf *overlay;
- /* We overlay pending_buf and d_buf+l_buf. This works since the average
- * output size for (length,distance) codes is <= 24 bits.
- */
-
- if (version == Z_NULL || version[0] != my_version[0] ||
- stream_size != sizeof(z_stream)) {
- return Z_VERSION_ERROR;
- }
- if (strm == Z_NULL) return Z_STREAM_ERROR;
-
- strm->msg = Z_NULL;
- if (strm->zalloc == (alloc_func)0) {
- strm->zalloc = zcalloc;
- strm->opaque = (voidpf)0;
- }
- if (strm->zfree == (free_func)0) strm->zfree = zcfree;
-
-#ifdef FASTEST
- if (level != 0) level = 1;
-#else
- if (level == Z_DEFAULT_COMPRESSION) level = 6;
-#endif
-
- if (windowBits < 0) { /* suppress zlib wrapper */
- wrap = 0;
- windowBits = -windowBits;
- }
-#ifdef GZIP
- else if (windowBits > 15) {
- wrap = 2; /* write gzip wrapper instead */
- windowBits -= 16;
- }
-#endif
- if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED ||
- windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||
- strategy < 0 || strategy > Z_FIXED) {
- return Z_STREAM_ERROR;
- }
- if (windowBits == 8) windowBits = 9; /* until 256-byte window bug fixed */
- s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state));
- if (s == Z_NULL) return Z_MEM_ERROR;
- strm->state = (struct internal_state FAR *)s;
- s->strm = strm;
-
- s->wrap = wrap;
- s->gzhead = Z_NULL;
- s->w_bits = windowBits;
- s->w_size = 1 << s->w_bits;
- s->w_mask = s->w_size - 1;
-
- s->hash_bits = memLevel + 7;
- s->hash_size = 1 << s->hash_bits;
- s->hash_mask = s->hash_size - 1;
- s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH);
-
- s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte));
- s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos));
- s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos));
-
- s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */
-
- overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);
- s->pending_buf = (uchf *) overlay;
- s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L);
-
- if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
- s->pending_buf == Z_NULL) {
- s->status = FINISH_STATE;
- strm->msg = (char*)ERR_MSG(Z_MEM_ERROR);
- deflateEnd (strm);
- return Z_MEM_ERROR;
- }
- s->d_buf = overlay + s->lit_bufsize/sizeof(ush);
- s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize;
-
- s->level = level;
- s->strategy = strategy;
- s->method = (Byte)method;
-
- return deflateReset(strm);
-}
-
-/* ========================================================================= */
-int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
- z_streamp strm;
- const Bytef *dictionary;
- uInt dictLength;
-{
- deflate_state *s;
- uInt length = dictLength;
- uInt n;
- IPos hash_head = 0;
-
- if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL ||
- strm->state->wrap == 2 ||
- (strm->state->wrap == 1 && strm->state->status != INIT_STATE))
- return Z_STREAM_ERROR;
-
- s = strm->state;
- if (s->wrap)
- strm->adler = adler32(strm->adler, dictionary, dictLength);
-
- if (length < MIN_MATCH) return Z_OK;
- if (length > MAX_DIST(s)) {
- length = MAX_DIST(s);
- dictionary += dictLength - length; /* use the tail of the dictionary */
- }
- zmemcpy(s->window, dictionary, length);
- s->strstart = length;
- s->block_start = (long)length;
-
- /* Insert all strings in the hash table (except for the last two bytes).
- * s->lookahead stays null, so s->ins_h will be recomputed at the next
- * call of fill_window.
- */
- s->ins_h = s->window[0];
- UPDATE_HASH(s, s->ins_h, s->window[1]);
- for (n = 0; n <= length - MIN_MATCH; n++) {
- INSERT_STRING(s, n, hash_head);
- }
- if (hash_head) hash_head = 0; /* to make compiler happy */
- return Z_OK;
-}
-
-/* ========================================================================= */
-int ZEXPORT deflateReset (strm)
- z_streamp strm;
-{
- deflate_state *s;
-
- if (strm == Z_NULL || strm->state == Z_NULL ||
- strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) {
- return Z_STREAM_ERROR;
- }
-
- strm->total_in = strm->total_out = 0;
- strm->msg = Z_NULL; /* use zfree if we ever allocate msg dynamically */
- strm->data_type = Z_UNKNOWN;
-
- s = (deflate_state *)strm->state;
- s->pending = 0;
- s->pending_out = s->pending_buf;
-
- if (s->wrap < 0) {
- s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */
- }
- s->status = s->wrap ? INIT_STATE : BUSY_STATE;
- strm->adler =
-#ifdef GZIP
- s->wrap == 2 ? crc32(0L, Z_NULL, 0) :
-#endif
- adler32(0L, Z_NULL, 0);
- s->last_flush = Z_NO_FLUSH;
-
- _tr_init(s);
- lm_init(s);
-
- return Z_OK;
-}
-
-/* ========================================================================= */
-int ZEXPORT deflateSetHeader (strm, head)
- z_streamp strm;
- gz_headerp head;
-{
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- if (strm->state->wrap != 2) return Z_STREAM_ERROR;
- strm->state->gzhead = head;
- return Z_OK;
-}
-
-/* ========================================================================= */
-int ZEXPORT deflatePrime (strm, bits, value)
- z_streamp strm;
- int bits;
- int value;
-{
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- strm->state->bi_valid = bits;
- strm->state->bi_buf = (ush)(value & ((1 << bits) - 1));
- return Z_OK;
-}
-
-/* ========================================================================= */
-int ZEXPORT deflateParams(strm, level, strategy)
- z_streamp strm;
- int level;
- int strategy;
-{
- deflate_state *s;
- compress_func func;
- int err = Z_OK;
-
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- s = strm->state;
-
-#ifdef FASTEST
- if (level != 0) level = 1;
-#else
- if (level == Z_DEFAULT_COMPRESSION) level = 6;
-#endif
- if (level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) {
- return Z_STREAM_ERROR;
- }
- func = configuration_table[s->level].func;
-
- if (func != configuration_table[level].func && strm->total_in != 0) {
- /* Flush the last buffer: */
- err = deflate(strm, Z_PARTIAL_FLUSH);
- }
- if (s->level != level) {
- s->level = level;
- s->max_lazy_match = configuration_table[level].max_lazy;
- s->good_match = configuration_table[level].good_length;
- s->nice_match = configuration_table[level].nice_length;
- s->max_chain_length = configuration_table[level].max_chain;
- }
- s->strategy = strategy;
- return err;
-}
-
-/* ========================================================================= */
-int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain)
- z_streamp strm;
- int good_length;
- int max_lazy;
- int nice_length;
- int max_chain;
-{
- deflate_state *s;
-
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- s = strm->state;
- s->good_match = good_length;
- s->max_lazy_match = max_lazy;
- s->nice_match = nice_length;
- s->max_chain_length = max_chain;
- return Z_OK;
-}
-
-/* =========================================================================
- * For the default windowBits of 15 and memLevel of 8, this function returns
- * a close to exact, as well as small, upper bound on the compressed size.
- * They are coded as constants here for a reason--if the #define's are
- * changed, then this function needs to be changed as well. The return
- * value for 15 and 8 only works for those exact settings.
- *
- * For any setting other than those defaults for windowBits and memLevel,
- * the value returned is a conservative worst case for the maximum expansion
- * resulting from using fixed blocks instead of stored blocks, which deflate
- * can emit on compressed data for some combinations of the parameters.
- *
- * This function could be more sophisticated to provide closer upper bounds
- * for every combination of windowBits and memLevel, as well as wrap.
- * But even the conservative upper bound of about 14% expansion does not
- * seem onerous for output buffer allocation.
- */
-uLong ZEXPORT deflateBound(strm, sourceLen)
- z_streamp strm;
- uLong sourceLen;
-{
- deflate_state *s;
- uLong destLen;
-
- /* conservative upper bound */
- destLen = sourceLen +
- ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 11;
-
- /* if can't get parameters, return conservative bound */
- if (strm == Z_NULL || strm->state == Z_NULL)
- return destLen;
-
- /* if not default parameters, return conservative bound */
- s = strm->state;
- if (s->w_bits != 15 || s->hash_bits != 8 + 7)
- return destLen;
-
- /* default settings: return tight bound for that case */
- return compressBound(sourceLen);
-}
-
-/* =========================================================================
- * Put a short in the pending buffer. The 16-bit value is put in MSB order.
- * IN assertion: the stream state is correct and there is enough room in
- * pending_buf.
- */
-local void putShortMSB (s, b)
- deflate_state *s;
- uInt b;
-{
- put_byte(s, (Byte)(b >> 8));
- put_byte(s, (Byte)(b & 0xff));
-}
-
-/* =========================================================================
- * Flush as much pending output as possible. All deflate() output goes
- * through this function so some applications may wish to modify it
- * to avoid allocating a large strm->next_out buffer and copying into it.
- * (See also read_buf()).
- */
-local void flush_pending(strm)
- z_streamp strm;
-{
- unsigned len = strm->state->pending;
-
- if (len > strm->avail_out) len = strm->avail_out;
- if (len == 0) return;
-
- zmemcpy(strm->next_out, strm->state->pending_out, len);
- strm->next_out += len;
- strm->state->pending_out += len;
- strm->total_out += len;
- strm->avail_out -= len;
- strm->state->pending -= len;
- if (strm->state->pending == 0) {
- strm->state->pending_out = strm->state->pending_buf;
- }
-}
-
-/* ========================================================================= */
-int ZEXPORT deflate (strm, flush)
- z_streamp strm;
- int flush;
-{
- int old_flush; /* value of flush param for previous deflate call */
- deflate_state *s;
-
- if (strm == Z_NULL || strm->state == Z_NULL ||
- flush > Z_FINISH || flush < 0) {
- return Z_STREAM_ERROR;
- }
- s = strm->state;
-
- if (strm->next_out == Z_NULL ||
- (strm->next_in == Z_NULL && strm->avail_in != 0) ||
- (s->status == FINISH_STATE && flush != Z_FINISH)) {
- ERR_RETURN(strm, Z_STREAM_ERROR);
- }
- if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR);
-
- s->strm = strm; /* just in case */
- old_flush = s->last_flush;
- s->last_flush = flush;
-
- /* Write the header */
- if (s->status == INIT_STATE) {
-#ifdef GZIP
- if (s->wrap == 2) {
- strm->adler = crc32(0L, Z_NULL, 0);
- put_byte(s, 31);
- put_byte(s, 139);
- put_byte(s, 8);
- if (s->gzhead == NULL) {
- put_byte(s, 0);
- put_byte(s, 0);
- put_byte(s, 0);
- put_byte(s, 0);
- put_byte(s, 0);
- put_byte(s, s->level == 9 ? 2 :
- (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
- 4 : 0));
- put_byte(s, OS_CODE);
- s->status = BUSY_STATE;
- }
- else {
- put_byte(s, (s->gzhead->text ? 1 : 0) +
- (s->gzhead->hcrc ? 2 : 0) +
- (s->gzhead->extra == Z_NULL ? 0 : 4) +
- (s->gzhead->name == Z_NULL ? 0 : 8) +
- (s->gzhead->comment == Z_NULL ? 0 : 16)
- );
- put_byte(s, (Byte)(s->gzhead->time & 0xff));
- put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff));
- put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff));
- put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff));
- put_byte(s, s->level == 9 ? 2 :
- (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
- 4 : 0));
- put_byte(s, s->gzhead->os & 0xff);
- if (s->gzhead->extra != NULL) {
- put_byte(s, s->gzhead->extra_len & 0xff);
- put_byte(s, (s->gzhead->extra_len >> 8) & 0xff);
- }
- if (s->gzhead->hcrc)
- strm->adler = crc32(strm->adler, s->pending_buf,
- s->pending);
- s->gzindex = 0;
- s->status = EXTRA_STATE;
- }
- }
- else
-#endif
- {
- uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8;
- uInt level_flags;
-
- if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2)
- level_flags = 0;
- else if (s->level < 6)
- level_flags = 1;
- else if (s->level == 6)
- level_flags = 2;
- else
- level_flags = 3;
- header |= (level_flags << 6);
- if (s->strstart != 0) header |= PRESET_DICT;
- header += 31 - (header % 31);
-
- s->status = BUSY_STATE;
- putShortMSB(s, header);
-
- /* Save the adler32 of the preset dictionary: */
- if (s->strstart != 0) {
- putShortMSB(s, (uInt)(strm->adler >> 16));
- putShortMSB(s, (uInt)(strm->adler & 0xffff));
- }
- strm->adler = adler32(0L, Z_NULL, 0);
- }
- }
-#ifdef GZIP
- if (s->status == EXTRA_STATE) {
- if (s->gzhead->extra != NULL) {
- uInt beg = s->pending; /* start of bytes to update crc */
-
- while (s->gzindex < (s->gzhead->extra_len & 0xffff)) {
- if (s->pending == s->pending_buf_size) {
- if (s->gzhead->hcrc && s->pending > beg)
- strm->adler = crc32(strm->adler, s->pending_buf + beg,
- s->pending - beg);
- flush_pending(strm);
- beg = s->pending;
- if (s->pending == s->pending_buf_size)
- break;
- }
- put_byte(s, s->gzhead->extra[s->gzindex]);
- s->gzindex++;
- }
- if (s->gzhead->hcrc && s->pending > beg)
- strm->adler = crc32(strm->adler, s->pending_buf + beg,
- s->pending - beg);
- if (s->gzindex == s->gzhead->extra_len) {
- s->gzindex = 0;
- s->status = NAME_STATE;
- }
- }
- else
- s->status = NAME_STATE;
- }
- if (s->status == NAME_STATE) {
- if (s->gzhead->name != NULL) {
- uInt beg = s->pending; /* start of bytes to update crc */
- int val;
-
- do {
- if (s->pending == s->pending_buf_size) {
- if (s->gzhead->hcrc && s->pending > beg)
- strm->adler = crc32(strm->adler, s->pending_buf + beg,
- s->pending - beg);
- flush_pending(strm);
- beg = s->pending;
- if (s->pending == s->pending_buf_size) {
- val = 1;
- break;
- }
- }
- val = s->gzhead->name[s->gzindex++];
- put_byte(s, val);
- } while (val != 0);
- if (s->gzhead->hcrc && s->pending > beg)
- strm->adler = crc32(strm->adler, s->pending_buf + beg,
- s->pending - beg);
- if (val == 0) {
- s->gzindex = 0;
- s->status = COMMENT_STATE;
- }
- }
- else
- s->status = COMMENT_STATE;
- }
- if (s->status == COMMENT_STATE) {
- if (s->gzhead->comment != NULL) {
- uInt beg = s->pending; /* start of bytes to update crc */
- int val;
-
- do {
- if (s->pending == s->pending_buf_size) {
- if (s->gzhead->hcrc && s->pending > beg)
- strm->adler = crc32(strm->adler, s->pending_buf + beg,
- s->pending - beg);
- flush_pending(strm);
- beg = s->pending;
- if (s->pending == s->pending_buf_size) {
- val = 1;
- break;
- }
- }
- val = s->gzhead->comment[s->gzindex++];
- put_byte(s, val);
- } while (val != 0);
- if (s->gzhead->hcrc && s->pending > beg)
- strm->adler = crc32(strm->adler, s->pending_buf + beg,
- s->pending - beg);
- if (val == 0)
- s->status = HCRC_STATE;
- }
- else
- s->status = HCRC_STATE;
- }
- if (s->status == HCRC_STATE) {
- if (s->gzhead->hcrc) {
- if (s->pending + 2 > s->pending_buf_size)
- flush_pending(strm);
- if (s->pending + 2 <= s->pending_buf_size) {
- put_byte(s, (Byte)(strm->adler & 0xff));
- put_byte(s, (Byte)((strm->adler >> 8) & 0xff));
- strm->adler = crc32(0L, Z_NULL, 0);
- s->status = BUSY_STATE;
- }
- }
- else
- s->status = BUSY_STATE;
- }
-#endif
-
- /* Flush as much pending output as possible */
- if (s->pending != 0) {
- flush_pending(strm);
- if (strm->avail_out == 0) {
- /* Since avail_out is 0, deflate will be called again with
- * more output space, but possibly with both pending and
- * avail_in equal to zero. There won't be anything to do,
- * but this is not an error situation so make sure we
- * return OK instead of BUF_ERROR at next call of deflate:
- */
- s->last_flush = -1;
- return Z_OK;
- }
-
- /* Make sure there is something to do and avoid duplicate consecutive
- * flushes. For repeated and useless calls with Z_FINISH, we keep
- * returning Z_STREAM_END instead of Z_BUF_ERROR.
- */
- } else if (strm->avail_in == 0 && flush <= old_flush &&
- flush != Z_FINISH) {
- ERR_RETURN(strm, Z_BUF_ERROR);
- }
-
- /* User must not provide more input after the first FINISH: */
- if (s->status == FINISH_STATE && strm->avail_in != 0) {
- ERR_RETURN(strm, Z_BUF_ERROR);
- }
-
- /* Start a new block or continue the current one.
- */
- if (strm->avail_in != 0 || s->lookahead != 0 ||
- (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {
- block_state bstate;
-
- bstate = (*(configuration_table[s->level].func))(s, flush);
-
- if (bstate == finish_started || bstate == finish_done) {
- s->status = FINISH_STATE;
- }
- if (bstate == need_more || bstate == finish_started) {
- if (strm->avail_out == 0) {
- s->last_flush = -1; /* avoid BUF_ERROR next call, see above */
- }
- return Z_OK;
- /* If flush != Z_NO_FLUSH && avail_out == 0, the next call
- * of deflate should use the same flush parameter to make sure
- * that the flush is complete. So we don't have to output an
- * empty block here, this will be done at next call. This also
- * ensures that for a very small output buffer, we emit at most
- * one empty block.
- */
- }
- if (bstate == block_done) {
- if (flush == Z_PARTIAL_FLUSH) {
- _tr_align(s);
- } else { /* FULL_FLUSH or SYNC_FLUSH */
- _tr_stored_block(s, (char*)0, 0L, 0);
- /* For a full flush, this empty block will be recognized
- * as a special marker by inflate_sync().
- */
- if (flush == Z_FULL_FLUSH) {
- CLEAR_HASH(s); /* forget history */
- }
- }
- flush_pending(strm);
- if (strm->avail_out == 0) {
- s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */
- return Z_OK;
- }
- }
- }
- Assert(strm->avail_out > 0, "bug2");
-
- if (flush != Z_FINISH) return Z_OK;
- if (s->wrap <= 0) return Z_STREAM_END;
-
- /* Write the trailer */
-#ifdef GZIP
- if (s->wrap == 2) {
- put_byte(s, (Byte)(strm->adler & 0xff));
- put_byte(s, (Byte)((strm->adler >> 8) & 0xff));
- put_byte(s, (Byte)((strm->adler >> 16) & 0xff));
- put_byte(s, (Byte)((strm->adler >> 24) & 0xff));
- put_byte(s, (Byte)(strm->total_in & 0xff));
- put_byte(s, (Byte)((strm->total_in >> 8) & 0xff));
- put_byte(s, (Byte)((strm->total_in >> 16) & 0xff));
- put_byte(s, (Byte)((strm->total_in >> 24) & 0xff));
- }
- else
-#endif
- {
- putShortMSB(s, (uInt)(strm->adler >> 16));
- putShortMSB(s, (uInt)(strm->adler & 0xffff));
- }
- flush_pending(strm);
- /* If avail_out is zero, the application will call deflate again
- * to flush the rest.
- */
- if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */
- return s->pending != 0 ? Z_OK : Z_STREAM_END;
-}
-
-/* ========================================================================= */
-int ZEXPORT deflateEnd (strm)
- z_streamp strm;
-{
- int status;
-
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
-
- status = strm->state->status;
- if (status != INIT_STATE &&
- status != EXTRA_STATE &&
- status != NAME_STATE &&
- status != COMMENT_STATE &&
- status != HCRC_STATE &&
- status != BUSY_STATE &&
- status != FINISH_STATE) {
- return Z_STREAM_ERROR;
- }
-
- /* Deallocate in reverse order of allocations: */
- TRY_FREE(strm, strm->state->pending_buf);
- TRY_FREE(strm, strm->state->head);
- TRY_FREE(strm, strm->state->prev);
- TRY_FREE(strm, strm->state->window);
-
- ZFREE(strm, strm->state);
- strm->state = Z_NULL;
-
- return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK;
-}
-
-/* =========================================================================
- * Copy the source state to the destination state.
- * To simplify the source, this is not supported for 16-bit MSDOS (which
- * doesn't have enough memory anyway to duplicate compression states).
- */
-int ZEXPORT deflateCopy (dest, source)
- z_streamp dest;
- z_streamp source;
-{
-#ifdef MAXSEG_64K
- return Z_STREAM_ERROR;
-#else
- deflate_state *ds;
- deflate_state *ss;
- ushf *overlay;
-
-
- if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) {
- return Z_STREAM_ERROR;
- }
-
- ss = source->state;
-
- zmemcpy(dest, source, sizeof(z_stream));
-
- ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state));
- if (ds == Z_NULL) return Z_MEM_ERROR;
- dest->state = (struct internal_state FAR *) ds;
- zmemcpy(ds, ss, sizeof(deflate_state));
- ds->strm = dest;
-
- ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));
- ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos));
- ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos));
- overlay = (ushf *) ZALLOC(dest, ds->lit_bufsize, sizeof(ush)+2);
- ds->pending_buf = (uchf *) overlay;
-
- if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL ||
- ds->pending_buf == Z_NULL) {
- deflateEnd (dest);
- return Z_MEM_ERROR;
- }
- /* following zmemcpy do not work for 16-bit MSDOS */
- zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte));
- zmemcpy(ds->prev, ss->prev, ds->w_size * sizeof(Pos));
- zmemcpy(ds->head, ss->head, ds->hash_size * sizeof(Pos));
- zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size);
-
- ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf);
- ds->d_buf = overlay + ds->lit_bufsize/sizeof(ush);
- ds->l_buf = ds->pending_buf + (1+sizeof(ush))*ds->lit_bufsize;
-
- ds->l_desc.dyn_tree = ds->dyn_ltree;
- ds->d_desc.dyn_tree = ds->dyn_dtree;
- ds->bl_desc.dyn_tree = ds->bl_tree;
-
- return Z_OK;
-#endif /* MAXSEG_64K */
-}
-
-/* ===========================================================================
- * Read a new buffer from the current input stream, update the adler32
- * and total number of bytes read. All deflate() input goes through
- * this function so some applications may wish to modify it to avoid
- * allocating a large strm->next_in buffer and copying from it.
- * (See also flush_pending()).
- */
-local int read_buf(strm, buf, size)
- z_streamp strm;
- Bytef *buf;
- unsigned size;
-{
- unsigned len = strm->avail_in;
-
- if (len > size) len = size;
- if (len == 0) return 0;
-
- strm->avail_in -= len;
-
- if (strm->state->wrap == 1) {
- strm->adler = adler32(strm->adler, strm->next_in, len);
- }
-#ifdef GZIP
- else if (strm->state->wrap == 2) {
- strm->adler = crc32(strm->adler, strm->next_in, len);
- }
-#endif
- zmemcpy(buf, strm->next_in, len);
- strm->next_in += len;
- strm->total_in += len;
-
- return (int)len;
-}
-
-/* ===========================================================================
- * Initialize the "longest match" routines for a new zlib stream
- */
-local void lm_init (s)
- deflate_state *s;
-{
- s->window_size = (ulg)2L*s->w_size;
-
- CLEAR_HASH(s);
-
- /* Set the default configuration parameters:
- */
- s->max_lazy_match = configuration_table[s->level].max_lazy;
- s->good_match = configuration_table[s->level].good_length;
- s->nice_match = configuration_table[s->level].nice_length;
- s->max_chain_length = configuration_table[s->level].max_chain;
-
- s->strstart = 0;
- s->block_start = 0L;
- s->lookahead = 0;
- s->match_length = s->prev_length = MIN_MATCH-1;
- s->match_available = 0;
- s->ins_h = 0;
-#ifndef FASTEST
-#ifdef ASMV
- match_init(); /* initialize the asm code */
-#endif
-#endif
-}
-
-#ifndef FASTEST
-/* ===========================================================================
- * Set match_start to the longest match starting at the given string and
- * return its length. Matches shorter or equal to prev_length are discarded,
- * in which case the result is equal to prev_length and match_start is
- * garbage.
- * IN assertions: cur_match is the head of the hash chain for the current
- * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1
- * OUT assertion: the match length is not greater than s->lookahead.
- */
-#ifndef ASMV
-/* For 80x86 and 680x0, an optimized version will be provided in match.asm or
- * match.S. The code will be functionally equivalent.
- */
-local uInt longest_match(s, cur_match)
- deflate_state *s;
- IPos cur_match; /* current match */
-{
- unsigned chain_length = s->max_chain_length;/* max hash chain length */
- register Bytef *scan = s->window + s->strstart; /* current string */
- register Bytef *match; /* matched string */
- register int len; /* length of current match */
- int best_len = s->prev_length; /* best match length so far */
- int nice_match = s->nice_match; /* stop if match long enough */
- IPos limit = s->strstart > (IPos)MAX_DIST(s) ?
- s->strstart - (IPos)MAX_DIST(s) : NIL;
- /* Stop when cur_match becomes <= limit. To simplify the code,
- * we prevent matches with the string of window index 0.
- */
- Posf *prev = s->prev;
- uInt wmask = s->w_mask;
-
-#ifdef UNALIGNED_OK
- /* Compare two bytes at a time. Note: this is not always beneficial.
- * Try with and without -DUNALIGNED_OK to check.
- */
- register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1;
- register ush scan_start = *(ushf*)scan;
- register ush scan_end = *(ushf*)(scan+best_len-1);
-#else
- register Bytef *strend = s->window + s->strstart + MAX_MATCH;
- register Byte scan_end1 = scan[best_len-1];
- register Byte scan_end = scan[best_len];
-#endif
-
- /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
- * It is easy to get rid of this optimization if necessary.
- */
- Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
-
- /* Do not waste too much time if we already have a good match: */
- if (s->prev_length >= s->good_match) {
- chain_length >>= 2;
- }
- /* Do not look for matches beyond the end of the input. This is necessary
- * to make deflate deterministic.
- */
- if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead;
-
- Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
-
- do {
- Assert(cur_match < s->strstart, "no future");
- match = s->window + cur_match;
-
- /* Skip to next match if the match length cannot increase
- * or if the match length is less than 2. Note that the checks below
- * for insufficient lookahead only occur occasionally for performance
- * reasons. Therefore uninitialized memory will be accessed, and
- * conditional jumps will be made that depend on those values.
- * However the length of the match is limited to the lookahead, so
- * the output of deflate is not affected by the uninitialized values.
- */
-#if (defined(UNALIGNED_OK) && MAX_MATCH == 258)
- /* This code assumes sizeof(unsigned short) == 2. Do not use
- * UNALIGNED_OK if your compiler uses a different size.
- */
- if (*(ushf*)(match+best_len-1) != scan_end ||
- *(ushf*)match != scan_start) continue;
-
- /* It is not necessary to compare scan[2] and match[2] since they are
- * always equal when the other bytes match, given that the hash keys
- * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at
- * strstart+3, +5, ... up to strstart+257. We check for insufficient
- * lookahead only every 4th comparison; the 128th check will be made
- * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is
- * necessary to put more guard bytes at the end of the window, or
- * to check more often for insufficient lookahead.
- */
- Assert(scan[2] == match[2], "scan[2]?");
- scan++, match++;
- do {
- } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
- *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
- *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
- *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
- scan < strend);
- /* The funny "do {}" generates better code on most compilers */
-
- /* Here, scan <= window+strstart+257 */
- Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
- if (*scan == *match) scan++;
-
- len = (MAX_MATCH - 1) - (int)(strend-scan);
- scan = strend - (MAX_MATCH-1);
-
-#else /* UNALIGNED_OK */
-
- if (match[best_len] != scan_end ||
- match[best_len-1] != scan_end1 ||
- *match != *scan ||
- *++match != scan[1]) continue;
-
- /* The check at best_len-1 can be removed because it will be made
- * again later. (This heuristic is not always a win.)
- * It is not necessary to compare scan[2] and match[2] since they
- * are always equal when the other bytes match, given that
- * the hash keys are equal and that HASH_BITS >= 8.
- */
- scan += 2, match++;
- Assert(*scan == *match, "match[2]?");
-
- /* We check for insufficient lookahead only every 8th comparison;
- * the 256th check will be made at strstart+258.
- */
- do {
- } while (*++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- scan < strend);
-
- Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
-
- len = MAX_MATCH - (int)(strend - scan);
- scan = strend - MAX_MATCH;
-
-#endif /* UNALIGNED_OK */
-
- if (len > best_len) {
- s->match_start = cur_match;
- best_len = len;
- if (len >= nice_match) break;
-#ifdef UNALIGNED_OK
- scan_end = *(ushf*)(scan+best_len-1);
-#else
- scan_end1 = scan[best_len-1];
- scan_end = scan[best_len];
-#endif
- }
- } while ((cur_match = prev[cur_match & wmask]) > limit
- && --chain_length != 0);
-
- if ((uInt)best_len <= s->lookahead) return (uInt)best_len;
- return s->lookahead;
-}
-#endif /* ASMV */
-#endif /* FASTEST */
-
-/* ---------------------------------------------------------------------------
- * Optimized version for level == 1 or strategy == Z_RLE only
- */
-local uInt longest_match_fast(s, cur_match)
- deflate_state *s;
- IPos cur_match; /* current match */
-{
- register Bytef *scan = s->window + s->strstart; /* current string */
- register Bytef *match; /* matched string */
- register int len; /* length of current match */
- register Bytef *strend = s->window + s->strstart + MAX_MATCH;
-
- /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
- * It is easy to get rid of this optimization if necessary.
- */
- Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
-
- Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
-
- Assert(cur_match < s->strstart, "no future");
-
- match = s->window + cur_match;
-
- /* Return failure if the match length is less than 2:
- */
- if (match[0] != scan[0] || match[1] != scan[1]) return MIN_MATCH-1;
-
- /* The check at best_len-1 can be removed because it will be made
- * again later. (This heuristic is not always a win.)
- * It is not necessary to compare scan[2] and match[2] since they
- * are always equal when the other bytes match, given that
- * the hash keys are equal and that HASH_BITS >= 8.
- */
- scan += 2, match += 2;
- Assert(*scan == *match, "match[2]?");
-
- /* We check for insufficient lookahead only every 8th comparison;
- * the 256th check will be made at strstart+258.
- */
- do {
- } while (*++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- scan < strend);
-
- Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
-
- len = MAX_MATCH - (int)(strend - scan);
-
- if (len < MIN_MATCH) return MIN_MATCH - 1;
-
- s->match_start = cur_match;
- return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead;
-}
-
-#ifdef DEBUG
-/* ===========================================================================
- * Check that the match at match_start is indeed a match.
- */
-local void check_match(s, start, match, length)
- deflate_state *s;
- IPos start, match;
- int length;
-{
- /* check that the match is indeed a match */
- if (zmemcmp(s->window + match,
- s->window + start, length) != EQUAL) {
- fprintf(stderr, " start %u, match %u, length %d\n",
- start, match, length);
- do {
- fprintf(stderr, "%c%c", s->window[match++], s->window[start++]);
- } while (--length != 0);
- z_error("invalid match");
- }
- if (z_verbose > 1) {
- fprintf(stderr,"\\[%d,%d]", start-match, length);
- do { putc(s->window[start++], stderr); } while (--length != 0);
- }
-}
-#else
-# define check_match(s, start, match, length)
-#endif /* DEBUG */
-
-/* ===========================================================================
- * Fill the window when the lookahead becomes insufficient.
- * Updates strstart and lookahead.
- *
- * IN assertion: lookahead < MIN_LOOKAHEAD
- * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD
- * At least one byte has been read, or avail_in == 0; reads are
- * performed for at least two bytes (required for the zip translate_eol
- * option -- not supported here).
- */
-local void fill_window(s)
- deflate_state *s;
-{
- register unsigned n, m;
- register Posf *p;
- unsigned more; /* Amount of free space at the end of the window. */
- uInt wsize = s->w_size;
-
- do {
- more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart);
-
- /* Deal with !@#$% 64K limit: */
- if (sizeof(int) <= 2) {
- if (more == 0 && s->strstart == 0 && s->lookahead == 0) {
- more = wsize;
-
- } else if (more == (unsigned)(-1)) {
- /* Very unlikely, but possible on 16 bit machine if
- * strstart == 0 && lookahead == 1 (input done a byte at time)
- */
- more--;
- }
- }
-
- /* If the window is almost full and there is insufficient lookahead,
- * move the upper half to the lower one to make room in the upper half.
- */
- if (s->strstart >= wsize+MAX_DIST(s)) {
-
- zmemcpy(s->window, s->window+wsize, (unsigned)wsize);
- s->match_start -= wsize;
- s->strstart -= wsize; /* we now have strstart >= MAX_DIST */
- s->block_start -= (long) wsize;
-
- /* Slide the hash table (could be avoided with 32 bit values
- at the expense of memory usage). We slide even when level == 0
- to keep the hash table consistent if we switch back to level > 0
- later. (Using level 0 permanently is not an optimal usage of
- zlib, so we don't care about this pathological case.)
- */
- /* %%% avoid this when Z_RLE */
- n = s->hash_size;
- p = &s->head[n];
- do {
- m = *--p;
- *p = (Pos)(m >= wsize ? m-wsize : NIL);
- } while (--n);
-
- n = wsize;
-#ifndef FASTEST
- p = &s->prev[n];
- do {
- m = *--p;
- *p = (Pos)(m >= wsize ? m-wsize : NIL);
- /* If n is not on any hash chain, prev[n] is garbage but
- * its value will never be used.
- */
- } while (--n);
-#endif
- more += wsize;
- }
- if (s->strm->avail_in == 0) return;
-
- /* If there was no sliding:
- * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&
- * more == window_size - lookahead - strstart
- * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)
- * => more >= window_size - 2*WSIZE + 2
- * In the BIG_MEM or MMAP case (not yet supported),
- * window_size == input_size + MIN_LOOKAHEAD &&
- * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.
- * Otherwise, window_size == 2*WSIZE so more >= 2.
- * If there was sliding, more >= WSIZE. So in all cases, more >= 2.
- */
- Assert(more >= 2, "more < 2");
-
- n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more);
- s->lookahead += n;
-
- /* Initialize the hash value now that we have some input: */
- if (s->lookahead >= MIN_MATCH) {
- s->ins_h = s->window[s->strstart];
- UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]);
-#if MIN_MATCH != 3
- Call UPDATE_HASH() MIN_MATCH-3 more times
-#endif
- }
- /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,
- * but this is not important since only literal bytes will be emitted.
- */
-
- } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0);
-}
-
-/* ===========================================================================
- * Flush the current block, with given end-of-file flag.
- * IN assertion: strstart is set to the end of the current match.
- */
-#define FLUSH_BLOCK_ONLY(s, eof) { \
- _tr_flush_block(s, (s->block_start >= 0L ? \
- (charf *)&s->window[(unsigned)s->block_start] : \
- (charf *)Z_NULL), \
- (ulg)((long)s->strstart - s->block_start), \
- (eof)); \
- s->block_start = s->strstart; \
- flush_pending(s->strm); \
- Tracev((stderr,"[FLUSH]")); \
-}
-
-/* Same but force premature exit if necessary. */
-#define FLUSH_BLOCK(s, eof) { \
- FLUSH_BLOCK_ONLY(s, eof); \
- if (s->strm->avail_out == 0) return (eof) ? finish_started : need_more; \
-}
-
-/* ===========================================================================
- * Copy without compression as much as possible from the input stream, return
- * the current block state.
- * This function does not insert new strings in the dictionary since
- * uncompressible data is probably not useful. This function is used
- * only for the level=0 compression option.
- * NOTE: this function should be optimized to avoid extra copying from
- * window to pending_buf.
- */
-local block_state deflate_stored(s, flush)
- deflate_state *s;
- int flush;
-{
- /* Stored blocks are limited to 0xffff bytes, pending_buf is limited
- * to pending_buf_size, and each stored block has a 5 byte header:
- */
- ulg max_block_size = 0xffff;
- ulg max_start;
-
- if (max_block_size > s->pending_buf_size - 5) {
- max_block_size = s->pending_buf_size - 5;
- }
-
- /* Copy as much as possible from input to output: */
- for (;;) {
- /* Fill the window as much as possible: */
- if (s->lookahead <= 1) {
-
- Assert(s->strstart < s->w_size+MAX_DIST(s) ||
- s->block_start >= (long)s->w_size, "slide too late");
-
- fill_window(s);
- if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more;
-
- if (s->lookahead == 0) break; /* flush the current block */
- }
- Assert(s->block_start >= 0L, "block gone");
-
- s->strstart += s->lookahead;
- s->lookahead = 0;
-
- /* Emit a stored block if pending_buf will be full: */
- max_start = s->block_start + max_block_size;
- if (s->strstart == 0 || (ulg)s->strstart >= max_start) {
- /* strstart == 0 is possible when wraparound on 16-bit machine */
- s->lookahead = (uInt)(s->strstart - max_start);
- s->strstart = (uInt)max_start;
- FLUSH_BLOCK(s, 0);
- }
- /* Flush if we may have to slide, otherwise block_start may become
- * negative and the data will be gone:
- */
- if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) {
- FLUSH_BLOCK(s, 0);
- }
- }
- FLUSH_BLOCK(s, flush == Z_FINISH);
- return flush == Z_FINISH ? finish_done : block_done;
-}
-
-/* ===========================================================================
- * Compress as much as possible from the input stream, return the current
- * block state.
- * This function does not perform lazy evaluation of matches and inserts
- * new strings in the dictionary only for unmatched strings or for short
- * matches. It is used only for the fast compression options.
- */
-local block_state deflate_fast(s, flush)
- deflate_state *s;
- int flush;
-{
- IPos hash_head = NIL; /* head of the hash chain */
- int bflush; /* set if current block must be flushed */
-
- for (;;) {
- /* Make sure that we always have enough lookahead, except
- * at the end of the input file. We need MAX_MATCH bytes
- * for the next match, plus MIN_MATCH bytes to insert the
- * string following the next match.
- */
- if (s->lookahead < MIN_LOOKAHEAD) {
- fill_window(s);
- if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
- return need_more;
- }
- if (s->lookahead == 0) break; /* flush the current block */
- }
-
- /* Insert the string window[strstart .. strstart+2] in the
- * dictionary, and set hash_head to the head of the hash chain:
- */
- if (s->lookahead >= MIN_MATCH) {
- INSERT_STRING(s, s->strstart, hash_head);
- }
-
- /* Find the longest match, discarding those <= prev_length.
- * At this point we have always match_length < MIN_MATCH
- */
- if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) {
- /* To simplify the code, we prevent matches with the string
- * of window index 0 (in particular we have to avoid a match
- * of the string with itself at the start of the input file).
- */
-#ifdef FASTEST
- if ((s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) ||
- (s->strategy == Z_RLE && s->strstart - hash_head == 1)) {
- s->match_length = longest_match_fast (s, hash_head);
- }
-#else
- if (s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) {
- s->match_length = longest_match (s, hash_head);
- } else if (s->strategy == Z_RLE && s->strstart - hash_head == 1) {
- s->match_length = longest_match_fast (s, hash_head);
- }
-#endif
- /* longest_match() or longest_match_fast() sets match_start */
- }
- if (s->match_length >= MIN_MATCH) {
- check_match(s, s->strstart, s->match_start, s->match_length);
-
- _tr_tally_dist(s, s->strstart - s->match_start,
- s->match_length - MIN_MATCH, bflush);
-
- s->lookahead -= s->match_length;
-
- /* Insert new strings in the hash table only if the match length
- * is not too large. This saves time but degrades compression.
- */
-#ifndef FASTEST
- if (s->match_length <= s->max_insert_length &&
- s->lookahead >= MIN_MATCH) {
- s->match_length--; /* string at strstart already in table */
- do {
- s->strstart++;
- INSERT_STRING(s, s->strstart, hash_head);
- /* strstart never exceeds WSIZE-MAX_MATCH, so there are
- * always MIN_MATCH bytes ahead.
- */
- } while (--s->match_length != 0);
- s->strstart++;
- } else
-#endif
- {
- s->strstart += s->match_length;
- s->match_length = 0;
- s->ins_h = s->window[s->strstart];
- UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]);
-#if MIN_MATCH != 3
- Call UPDATE_HASH() MIN_MATCH-3 more times
-#endif
- /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not
- * matter since it will be recomputed at next deflate call.
- */
- }
- } else {
- /* No match, output a literal byte */
- Tracevv((stderr,"%c", s->window[s->strstart]));
- _tr_tally_lit (s, s->window[s->strstart], bflush);
- s->lookahead--;
- s->strstart++;
- }
- if (bflush) FLUSH_BLOCK(s, 0);
- }
- FLUSH_BLOCK(s, flush == Z_FINISH);
- return flush == Z_FINISH ? finish_done : block_done;
-}
-
-#ifndef FASTEST
-/* ===========================================================================
- * Same as above, but achieves better compression. We use a lazy
- * evaluation for matches: a match is finally adopted only if there is
- * no better match at the next window position.
- */
-local block_state deflate_slow(s, flush)
- deflate_state *s;
- int flush;
-{
- IPos hash_head = NIL; /* head of hash chain */
- int bflush; /* set if current block must be flushed */
-
- /* Process the input block. */
- for (;;) {
- /* Make sure that we always have enough lookahead, except
- * at the end of the input file. We need MAX_MATCH bytes
- * for the next match, plus MIN_MATCH bytes to insert the
- * string following the next match.
- */
- if (s->lookahead < MIN_LOOKAHEAD) {
- fill_window(s);
- if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
- return need_more;
- }
- if (s->lookahead == 0) break; /* flush the current block */
- }
-
- /* Insert the string window[strstart .. strstart+2] in the
- * dictionary, and set hash_head to the head of the hash chain:
- */
- if (s->lookahead >= MIN_MATCH) {
- INSERT_STRING(s, s->strstart, hash_head);
- }
-
- /* Find the longest match, discarding those <= prev_length.
- */
- s->prev_length = s->match_length, s->prev_match = s->match_start;
- s->match_length = MIN_MATCH-1;
-
- if (hash_head != NIL && s->prev_length < s->max_lazy_match &&
- s->strstart - hash_head <= MAX_DIST(s)) {
- /* To simplify the code, we prevent matches with the string
- * of window index 0 (in particular we have to avoid a match
- * of the string with itself at the start of the input file).
- */
- if (s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) {
- s->match_length = longest_match (s, hash_head);
- } else if (s->strategy == Z_RLE && s->strstart - hash_head == 1) {
- s->match_length = longest_match_fast (s, hash_head);
- }
- /* longest_match() or longest_match_fast() sets match_start */
-
- if (s->match_length <= 5 && (s->strategy == Z_FILTERED
-#if TOO_FAR <= 32767
- || (s->match_length == MIN_MATCH &&
- s->strstart - s->match_start > TOO_FAR)
-#endif
- )) {
-
- /* If prev_match is also MIN_MATCH, match_start is garbage
- * but we will ignore the current match anyway.
- */
- s->match_length = MIN_MATCH-1;
- }
- }
- /* If there was a match at the previous step and the current
- * match is not better, output the previous match:
- */
- if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) {
- uInt max_insert = s->strstart + s->lookahead - MIN_MATCH;
- /* Do not insert strings in hash table beyond this. */
-
- check_match(s, s->strstart-1, s->prev_match, s->prev_length);
-
- _tr_tally_dist(s, s->strstart -1 - s->prev_match,
- s->prev_length - MIN_MATCH, bflush);
-
- /* Insert in hash table all strings up to the end of the match.
- * strstart-1 and strstart are already inserted. If there is not
- * enough lookahead, the last two strings are not inserted in
- * the hash table.
- */
- s->lookahead -= s->prev_length-1;
- s->prev_length -= 2;
- do {
- if (++s->strstart <= max_insert) {
- INSERT_STRING(s, s->strstart, hash_head);
- }
- } while (--s->prev_length != 0);
- s->match_available = 0;
- s->match_length = MIN_MATCH-1;
- s->strstart++;
-
- if (bflush) FLUSH_BLOCK(s, 0);
-
- } else if (s->match_available) {
- /* If there was no match at the previous position, output a
- * single literal. If there was a match but the current match
- * is longer, truncate the previous match to a single literal.
- */
- Tracevv((stderr,"%c", s->window[s->strstart-1]));
- _tr_tally_lit(s, s->window[s->strstart-1], bflush);
- if (bflush) {
- FLUSH_BLOCK_ONLY(s, 0);
- }
- s->strstart++;
- s->lookahead--;
- if (s->strm->avail_out == 0) return need_more;
- } else {
- /* There is no previous match to compare with, wait for
- * the next step to decide.
- */
- s->match_available = 1;
- s->strstart++;
- s->lookahead--;
- }
- }
- Assert (flush != Z_NO_FLUSH, "no flush?");
- if (s->match_available) {
- Tracevv((stderr,"%c", s->window[s->strstart-1]));
- _tr_tally_lit(s, s->window[s->strstart-1], bflush);
- s->match_available = 0;
- }
- FLUSH_BLOCK(s, flush == Z_FINISH);
- return flush == Z_FINISH ? finish_done : block_done;
-}
-#endif /* FASTEST */
-
-#if 0
-/* ===========================================================================
- * For Z_RLE, simply look for runs of bytes, generate matches only of distance
- * one. Do not maintain a hash table. (It will be regenerated if this run of
- * deflate switches away from Z_RLE.)
- */
-local block_state deflate_rle(s, flush)
- deflate_state *s;
- int flush;
-{
- int bflush; /* set if current block must be flushed */
- uInt run; /* length of run */
- uInt max; /* maximum length of run */
- uInt prev; /* byte at distance one to match */
- Bytef *scan; /* scan for end of run */
-
- for (;;) {
- /* Make sure that we always have enough lookahead, except
- * at the end of the input file. We need MAX_MATCH bytes
- * for the longest encodable run.
- */
- if (s->lookahead < MAX_MATCH) {
- fill_window(s);
- if (s->lookahead < MAX_MATCH && flush == Z_NO_FLUSH) {
- return need_more;
- }
- if (s->lookahead == 0) break; /* flush the current block */
- }
-
- /* See how many times the previous byte repeats */
- run = 0;
- if (s->strstart > 0) { /* if there is a previous byte, that is */
- max = s->lookahead < MAX_MATCH ? s->lookahead : MAX_MATCH;
- scan = s->window + s->strstart - 1;
- prev = *scan++;
- do {
- if (*scan++ != prev)
- break;
- } while (++run < max);
- }
-
- /* Emit match if have run of MIN_MATCH or longer, else emit literal */
- if (run >= MIN_MATCH) {
- check_match(s, s->strstart, s->strstart - 1, run);
- _tr_tally_dist(s, 1, run - MIN_MATCH, bflush);
- s->lookahead -= run;
- s->strstart += run;
- } else {
- /* No match, output a literal byte */
- Tracevv((stderr,"%c", s->window[s->strstart]));
- _tr_tally_lit (s, s->window[s->strstart], bflush);
- s->lookahead--;
- s->strstart++;
- }
- if (bflush) FLUSH_BLOCK(s, 0);
- }
- FLUSH_BLOCK(s, flush == Z_FINISH);
- return flush == Z_FINISH ? finish_done : block_done;
-}
-#endif
diff --git a/WebCore/platform/image-decoders/zlib/deflate.h b/WebCore/platform/image-decoders/zlib/deflate.h
deleted file mode 100644
index 942fe26..0000000
--- a/WebCore/platform/image-decoders/zlib/deflate.h
+++ /dev/null
@@ -1,331 +0,0 @@
-/* deflate.h -- internal compression state
- * Copyright (C) 1995-2004 Jean-loup Gailly
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-/* @(#) $Id: deflate.h,v 3.6 2005/08/04 19:14:14 tor%cs.brown.edu Exp $ */
-
-#ifndef DEFLATE_H
-#define DEFLATE_H
-
-#include "zutil.h"
-
-/* define NO_GZIP when compiling if you want to disable gzip header and
- trailer creation by deflate(). NO_GZIP would be used to avoid linking in
- the crc code when it is not needed. For shared libraries, gzip encoding
- should be left enabled. */
-#ifndef NO_GZIP
-# define GZIP
-#endif
-
-/* ===========================================================================
- * Internal compression state.
- */
-
-#define LENGTH_CODES 29
-/* number of length codes, not counting the special END_BLOCK code */
-
-#define LITERALS 256
-/* number of literal bytes 0..255 */
-
-#define L_CODES (LITERALS+1+LENGTH_CODES)
-/* number of Literal or Length codes, including the END_BLOCK code */
-
-#define D_CODES 30
-/* number of distance codes */
-
-#define BL_CODES 19
-/* number of codes used to transfer the bit lengths */
-
-#define HEAP_SIZE (2*L_CODES+1)
-/* maximum heap size */
-
-#define MAX_BITS 15
-/* All codes must not exceed MAX_BITS bits */
-
-#define INIT_STATE 42
-#define EXTRA_STATE 69
-#define NAME_STATE 73
-#define COMMENT_STATE 91
-#define HCRC_STATE 103
-#define BUSY_STATE 113
-#define FINISH_STATE 666
-/* Stream status */
-
-
-/* Data structure describing a single value and its code string. */
-typedef struct ct_data_s {
- union {
- ush freq; /* frequency count */
- ush code; /* bit string */
- } fc;
- union {
- ush dad; /* father node in Huffman tree */
- ush len; /* length of bit string */
- } dl;
-} FAR ct_data;
-
-#define Freq fc.freq
-#define Code fc.code
-#define Dad dl.dad
-#define Len dl.len
-
-typedef struct static_tree_desc_s static_tree_desc;
-
-typedef struct tree_desc_s {
- ct_data *dyn_tree; /* the dynamic tree */
- int max_code; /* largest code with non zero frequency */
- static_tree_desc *stat_desc; /* the corresponding static tree */
-} FAR tree_desc;
-
-typedef ush Pos;
-typedef Pos FAR Posf;
-typedef unsigned IPos;
-
-/* A Pos is an index in the character window. We use short instead of int to
- * save space in the various tables. IPos is used only for parameter passing.
- */
-
-typedef struct internal_state {
- z_streamp strm; /* pointer back to this zlib stream */
- int status; /* as the name implies */
- Bytef *pending_buf; /* output still pending */
- ulg pending_buf_size; /* size of pending_buf */
- Bytef *pending_out; /* next pending byte to output to the stream */
- uInt pending; /* nb of bytes in the pending buffer */
- int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
- gz_headerp gzhead; /* gzip header information to write */
- uInt gzindex; /* where in extra, name, or comment */
- Byte method; /* STORED (for zip only) or DEFLATED */
- int last_flush; /* value of flush param for previous deflate call */
-
- /* used by deflate.c: */
-
- uInt w_size; /* LZ77 window size (32K by default) */
- uInt w_bits; /* log2(w_size) (8..16) */
- uInt w_mask; /* w_size - 1 */
-
- Bytef *window;
- /* Sliding window. Input bytes are read into the second half of the window,
- * and move to the first half later to keep a dictionary of at least wSize
- * bytes. With this organization, matches are limited to a distance of
- * wSize-MAX_MATCH bytes, but this ensures that IO is always
- * performed with a length multiple of the block size. Also, it limits
- * the window size to 64K, which is quite useful on MSDOS.
- * To do: use the user input buffer as sliding window.
- */
-
- ulg window_size;
- /* Actual size of window: 2*wSize, except when the user input buffer
- * is directly used as sliding window.
- */
-
- Posf *prev;
- /* Link to older string with same hash index. To limit the size of this
- * array to 64K, this link is maintained only for the last 32K strings.
- * An index in this array is thus a window index modulo 32K.
- */
-
- Posf *head; /* Heads of the hash chains or NIL. */
-
- uInt ins_h; /* hash index of string to be inserted */
- uInt hash_size; /* number of elements in hash table */
- uInt hash_bits; /* log2(hash_size) */
- uInt hash_mask; /* hash_size-1 */
-
- uInt hash_shift;
- /* Number of bits by which ins_h must be shifted at each input
- * step. It must be such that after MIN_MATCH steps, the oldest
- * byte no longer takes part in the hash key, that is:
- * hash_shift * MIN_MATCH >= hash_bits
- */
-
- long block_start;
- /* Window position at the beginning of the current output block. Gets
- * negative when the window is moved backwards.
- */
-
- uInt match_length; /* length of best match */
- IPos prev_match; /* previous match */
- int match_available; /* set if previous match exists */
- uInt strstart; /* start of string to insert */
- uInt match_start; /* start of matching string */
- uInt lookahead; /* number of valid bytes ahead in window */
-
- uInt prev_length;
- /* Length of the best match at previous step. Matches not greater than this
- * are discarded. This is used in the lazy match evaluation.
- */
-
- uInt max_chain_length;
- /* To speed up deflation, hash chains are never searched beyond this
- * length. A higher limit improves compression ratio but degrades the
- * speed.
- */
-
- uInt max_lazy_match;
- /* Attempt to find a better match only when the current match is strictly
- * smaller than this value. This mechanism is used only for compression
- * levels >= 4.
- */
-# define max_insert_length max_lazy_match
- /* Insert new strings in the hash table only if the match length is not
- * greater than this length. This saves time but degrades compression.
- * max_insert_length is used only for compression levels <= 3.
- */
-
- int level; /* compression level (1..9) */
- int strategy; /* favor or force Huffman coding*/
-
- uInt good_match;
- /* Use a faster search when the previous match is longer than this */
-
- int nice_match; /* Stop searching when current match exceeds this */
-
- /* used by trees.c: */
- /* Didn't use ct_data typedef below to supress compiler warning */
- struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */
- struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */
- struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */
-
- struct tree_desc_s l_desc; /* desc. for literal tree */
- struct tree_desc_s d_desc; /* desc. for distance tree */
- struct tree_desc_s bl_desc; /* desc. for bit length tree */
-
- ush bl_count[MAX_BITS+1];
- /* number of codes at each bit length for an optimal tree */
-
- int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */
- int heap_len; /* number of elements in the heap */
- int heap_max; /* element of largest frequency */
- /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.
- * The same heap array is used to build all trees.
- */
-
- uch depth[2*L_CODES+1];
- /* Depth of each subtree used as tie breaker for trees of equal frequency
- */
-
- uchf *l_buf; /* buffer for literals or lengths */
-
- uInt lit_bufsize;
- /* Size of match buffer for literals/lengths. There are 4 reasons for
- * limiting lit_bufsize to 64K:
- * - frequencies can be kept in 16 bit counters
- * - if compression is not successful for the first block, all input
- * data is still in the window so we can still emit a stored block even
- * when input comes from standard input. (This can also be done for
- * all blocks if lit_bufsize is not greater than 32K.)
- * - if compression is not successful for a file smaller than 64K, we can
- * even emit a stored file instead of a stored block (saving 5 bytes).
- * This is applicable only for zip (not gzip or zlib).
- * - creating new Huffman trees less frequently may not provide fast
- * adaptation to changes in the input data statistics. (Take for
- * example a binary file with poorly compressible code followed by
- * a highly compressible string table.) Smaller buffer sizes give
- * fast adaptation but have of course the overhead of transmitting
- * trees more frequently.
- * - I can't count above 4
- */
-
- uInt last_lit; /* running index in l_buf */
-
- ushf *d_buf;
- /* Buffer for distances. To simplify the code, d_buf and l_buf have
- * the same number of elements. To use different lengths, an extra flag
- * array would be necessary.
- */
-
- ulg opt_len; /* bit length of current block with optimal trees */
- ulg static_len; /* bit length of current block with static trees */
- uInt matches; /* number of string matches in current block */
- int last_eob_len; /* bit length of EOB code for last block */
-
-#ifdef DEBUG
- ulg compressed_len; /* total bit length of compressed file mod 2^32 */
- ulg bits_sent; /* bit length of compressed data sent mod 2^32 */
-#endif
-
- ush bi_buf;
- /* Output buffer. bits are inserted starting at the bottom (least
- * significant bits).
- */
- int bi_valid;
- /* Number of valid bits in bi_buf. All bits above the last valid bit
- * are always zero.
- */
-
-} FAR deflate_state;
-
-/* Output a byte on the stream.
- * IN assertion: there is enough room in pending_buf.
- */
-#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);}
-
-
-#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
-/* Minimum amount of lookahead, except at the end of the input file.
- * See deflate.c for comments about the MIN_MATCH+1.
- */
-
-#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD)
-/* In order to simplify the code, particularly on 16 bit machines, match
- * distances are limited to MAX_DIST instead of WSIZE.
- */
-
- /* in trees.c */
-void _tr_init OF((deflate_state *s));
-int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
-void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len,
- int eof));
-void _tr_align OF((deflate_state *s));
-void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,
- int eof));
-
-#define d_code(dist) \
- ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
-/* Mapping from a distance to a distance code. dist is the distance - 1 and
- * must not have side effects. _dist_code[256] and _dist_code[257] are never
- * used.
- */
-
-#ifndef DEBUG
-/* Inline versions of _tr_tally for speed: */
-
-#if defined(GEN_TREES_H) || !defined(STDC)
- extern uch _length_code[];
- extern uch _dist_code[];
-#else
- extern const uch _length_code[];
- extern const uch _dist_code[];
-#endif
-
-# define _tr_tally_lit(s, c, flush) \
- { uch cc = (c); \
- s->d_buf[s->last_lit] = 0; \
- s->l_buf[s->last_lit++] = cc; \
- s->dyn_ltree[cc].Freq++; \
- flush = (s->last_lit == s->lit_bufsize-1); \
- }
-# define _tr_tally_dist(s, distance, length, flush) \
- { uch len = (length); \
- ush dist = (distance); \
- s->d_buf[s->last_lit] = dist; \
- s->l_buf[s->last_lit++] = len; \
- dist--; \
- s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
- s->dyn_dtree[d_code(dist)].Freq++; \
- flush = (s->last_lit == s->lit_bufsize-1); \
- }
-#else
-# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c)
-# define _tr_tally_dist(s, distance, length, flush) \
- flush = _tr_tally(s, distance, length)
-#endif
-
-#endif /* DEFLATE_H */
diff --git a/WebCore/platform/image-decoders/zlib/gzio.c b/WebCore/platform/image-decoders/zlib/gzio.c
deleted file mode 100644
index 2c0c1d7..0000000
--- a/WebCore/platform/image-decoders/zlib/gzio.c
+++ /dev/null
@@ -1,1026 +0,0 @@
-/* gzio.c -- IO on .gz files
- * Copyright (C) 1995-2005 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- *
- * Compile this file with -DNO_GZCOMPRESS to avoid the compression code.
- */
-
-/* @(#) $Id: gzio.c,v 3.7 2005/08/04 19:14:14 tor%cs.brown.edu Exp $ */
-
-#include <stdio.h>
-
-#include "zutil.h"
-
-#ifdef NO_DEFLATE /* for compatibility with old definition */
-# define NO_GZCOMPRESS
-#endif
-
-#ifndef NO_DUMMY_DECL
-struct internal_state {int dummy;}; /* for buggy compilers */
-#endif
-
-#ifndef Z_BUFSIZE
-# ifdef MAXSEG_64K
-# define Z_BUFSIZE 4096 /* minimize memory usage for 16-bit DOS */
-# else
-# define Z_BUFSIZE 16384
-# endif
-#endif
-#ifndef Z_PRINTF_BUFSIZE
-# define Z_PRINTF_BUFSIZE 4096
-#endif
-
-#ifdef __MVS__
-# pragma map (fdopen , "\174\174FDOPEN")
- FILE *fdopen(int, const char *);
-#endif
-
-#ifndef STDC
-extern voidp malloc OF((uInt size));
-extern void free OF((voidpf ptr));
-#endif
-
-#define ALLOC(size) malloc(size)
-#define TRYFREE(p) {if (p) free(p);}
-
-static int const gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */
-
-/* gzip flag byte */
-#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */
-#define HEAD_CRC 0x02 /* bit 1 set: header CRC present */
-#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
-#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
-#define COMMENT 0x10 /* bit 4 set: file comment present */
-#define RESERVED 0xE0 /* bits 5..7: reserved */
-
-typedef struct gz_stream {
- z_stream stream;
- int z_err; /* error code for last stream operation */
- int z_eof; /* set if end of input file */
- FILE *file; /* .gz file */
- Byte *inbuf; /* input buffer */
- Byte *outbuf; /* output buffer */
- uLong crc; /* crc32 of uncompressed data */
- char *msg; /* error message */
- char *path; /* path name for debugging only */
- int transparent; /* 1 if input file is not a .gz file */
- char mode; /* 'w' or 'r' */
- z_off_t start; /* start of compressed data in file (header skipped) */
- z_off_t in; /* bytes into deflate or inflate */
- z_off_t out; /* bytes out of deflate or inflate */
- int back; /* one character push-back */
- int last; /* true if push-back is last character */
-} gz_stream;
-
-
-local gzFile gz_open OF((const char *path, const char *mode, int fd));
-local int do_flush OF((gzFile file, int flush));
-local int get_byte OF((gz_stream *s));
-local void check_header OF((gz_stream *s));
-local int destroy OF((gz_stream *s));
-local void putLong OF((FILE *file, uLong x));
-local uLong getLong OF((gz_stream *s));
-
-/* ===========================================================================
- Opens a gzip (.gz) file for reading or writing. The mode parameter
- is as in fopen ("rb" or "wb"). The file is given either by file descriptor
- or path name (if fd == -1).
- gz_open returns NULL if the file could not be opened or if there was
- insufficient memory to allocate the (de)compression state; errno
- can be checked to distinguish the two cases (if errno is zero, the
- zlib error is Z_MEM_ERROR).
-*/
-local gzFile gz_open (path, mode, fd)
- const char *path;
- const char *mode;
- int fd;
-{
- int err;
- int level = Z_DEFAULT_COMPRESSION; /* compression level */
- int strategy = Z_DEFAULT_STRATEGY; /* compression strategy */
- char *p = (char*)mode;
- gz_stream *s;
- char fmode[80]; /* copy of mode, without the compression level */
- char *m = fmode;
-
- if (!path || !mode) return Z_NULL;
-
- s = (gz_stream *)ALLOC(sizeof(gz_stream));
- if (!s) return Z_NULL;
-
- s->stream.zalloc = (alloc_func)0;
- s->stream.zfree = (free_func)0;
- s->stream.opaque = (voidpf)0;
- s->stream.next_in = s->inbuf = Z_NULL;
- s->stream.next_out = s->outbuf = Z_NULL;
- s->stream.avail_in = s->stream.avail_out = 0;
- s->file = NULL;
- s->z_err = Z_OK;
- s->z_eof = 0;
- s->in = 0;
- s->out = 0;
- s->back = EOF;
- s->crc = crc32(0L, Z_NULL, 0);
- s->msg = NULL;
- s->transparent = 0;
-
- s->path = (char*)ALLOC(strlen(path)+1);
- if (s->path == NULL) {
- return destroy(s), (gzFile)Z_NULL;
- }
- strcpy(s->path, path); /* do this early for debugging */
-
- s->mode = '\0';
- do {
- if (*p == 'r') s->mode = 'r';
- if (*p == 'w' || *p == 'a') s->mode = 'w';
- if (*p >= '0' && *p <= '9') {
- level = *p - '0';
- } else if (*p == 'f') {
- strategy = Z_FILTERED;
- } else if (*p == 'h') {
- strategy = Z_HUFFMAN_ONLY;
- } else if (*p == 'R') {
- strategy = Z_RLE;
- } else {
- *m++ = *p; /* copy the mode */
- }
- } while (*p++ && m != fmode + sizeof(fmode));
- if (s->mode == '\0') return destroy(s), (gzFile)Z_NULL;
-
- if (s->mode == 'w') {
-#ifdef NO_GZCOMPRESS
- err = Z_STREAM_ERROR;
-#else
- err = deflateInit2(&(s->stream), level,
- Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, strategy);
- /* windowBits is passed < 0 to suppress zlib header */
-
- s->stream.next_out = s->outbuf = (Byte*)ALLOC(Z_BUFSIZE);
-#endif
- if (err != Z_OK || s->outbuf == Z_NULL) {
- return destroy(s), (gzFile)Z_NULL;
- }
- } else {
- s->stream.next_in = s->inbuf = (Byte*)ALLOC(Z_BUFSIZE);
-
- err = inflateInit2(&(s->stream), -MAX_WBITS);
- /* windowBits is passed < 0 to tell that there is no zlib header.
- * Note that in this case inflate *requires* an extra "dummy" byte
- * after the compressed stream in order to complete decompression and
- * return Z_STREAM_END. Here the gzip CRC32 ensures that 4 bytes are
- * present after the compressed stream.
- */
- if (err != Z_OK || s->inbuf == Z_NULL) {
- return destroy(s), (gzFile)Z_NULL;
- }
- }
- s->stream.avail_out = Z_BUFSIZE;
-
- errno = 0;
- s->file = fd < 0 ? F_OPEN(path, fmode) : (FILE*)fdopen(fd, fmode);
-
- if (s->file == NULL) {
- return destroy(s), (gzFile)Z_NULL;
- }
- if (s->mode == 'w') {
- /* Write a very simple .gz header:
- */
- fprintf(s->file, "%c%c%c%c%c%c%c%c%c%c", gz_magic[0], gz_magic[1],
- Z_DEFLATED, 0 /*flags*/, 0,0,0,0 /*time*/, 0 /*xflags*/, OS_CODE);
- s->start = 10L;
- /* We use 10L instead of ftell(s->file) to because ftell causes an
- * fflush on some systems. This version of the library doesn't use
- * start anyway in write mode, so this initialization is not
- * necessary.
- */
- } else {
- check_header(s); /* skip the .gz header */
- s->start = ftell(s->file) - s->stream.avail_in;
- }
-
- return (gzFile)s;
-}
-
-/* ===========================================================================
- Opens a gzip (.gz) file for reading or writing.
-*/
-gzFile ZEXPORT gzopen (path, mode)
- const char *path;
- const char *mode;
-{
- return gz_open (path, mode, -1);
-}
-
-/* ===========================================================================
- Associate a gzFile with the file descriptor fd. fd is not dup'ed here
- to mimic the behavio(u)r of fdopen.
-*/
-gzFile ZEXPORT gzdopen (fd, mode)
- int fd;
- const char *mode;
-{
- char name[46]; /* allow for up to 128-bit integers */
-
- if (fd < 0) return (gzFile)Z_NULL;
- sprintf(name, "<fd:%d>", fd); /* for debugging */
-
- return gz_open (name, mode, fd);
-}
-
-/* ===========================================================================
- * Update the compression level and strategy
- */
-int ZEXPORT gzsetparams (file, level, strategy)
- gzFile file;
- int level;
- int strategy;
-{
- gz_stream *s = (gz_stream*)file;
-
- if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
-
- /* Make room to allow flushing */
- if (s->stream.avail_out == 0) {
-
- s->stream.next_out = s->outbuf;
- if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) {
- s->z_err = Z_ERRNO;
- }
- s->stream.avail_out = Z_BUFSIZE;
- }
-
- return deflateParams (&(s->stream), level, strategy);
-}
-
-/* ===========================================================================
- Read a byte from a gz_stream; update next_in and avail_in. Return EOF
- for end of file.
- IN assertion: the stream s has been sucessfully opened for reading.
-*/
-local int get_byte(s)
- gz_stream *s;
-{
- if (s->z_eof) return EOF;
- if (s->stream.avail_in == 0) {
- errno = 0;
- s->stream.avail_in = (uInt)fread(s->inbuf, 1, Z_BUFSIZE, s->file);
- if (s->stream.avail_in == 0) {
- s->z_eof = 1;
- if (ferror(s->file)) s->z_err = Z_ERRNO;
- return EOF;
- }
- s->stream.next_in = s->inbuf;
- }
- s->stream.avail_in--;
- return *(s->stream.next_in)++;
-}
-
-/* ===========================================================================
- Check the gzip header of a gz_stream opened for reading. Set the stream
- mode to transparent if the gzip magic header is not present; set s->err
- to Z_DATA_ERROR if the magic header is present but the rest of the header
- is incorrect.
- IN assertion: the stream s has already been created sucessfully;
- s->stream.avail_in is zero for the first time, but may be non-zero
- for concatenated .gz files.
-*/
-local void check_header(s)
- gz_stream *s;
-{
- int method; /* method byte */
- int flags; /* flags byte */
- uInt len;
- int c;
-
- /* Assure two bytes in the buffer so we can peek ahead -- handle case
- where first byte of header is at the end of the buffer after the last
- gzip segment */
- len = s->stream.avail_in;
- if (len < 2) {
- if (len) s->inbuf[0] = s->stream.next_in[0];
- errno = 0;
- len = (uInt)fread(s->inbuf + len, 1, Z_BUFSIZE >> len, s->file);
- if (len == 0 && ferror(s->file)) s->z_err = Z_ERRNO;
- s->stream.avail_in += len;
- s->stream.next_in = s->inbuf;
- if (s->stream.avail_in < 2) {
- s->transparent = s->stream.avail_in;
- return;
- }
- }
-
- /* Peek ahead to check the gzip magic header */
- if (s->stream.next_in[0] != gz_magic[0] ||
- s->stream.next_in[1] != gz_magic[1]) {
- s->transparent = 1;
- return;
- }
- s->stream.avail_in -= 2;
- s->stream.next_in += 2;
-
- /* Check the rest of the gzip header */
- method = get_byte(s);
- flags = get_byte(s);
- if (method != Z_DEFLATED || (flags & RESERVED) != 0) {
- s->z_err = Z_DATA_ERROR;
- return;
- }
-
- /* Discard time, xflags and OS code: */
- for (len = 0; len < 6; len++) (void)get_byte(s);
-
- if ((flags & EXTRA_FIELD) != 0) { /* skip the extra field */
- len = (uInt)get_byte(s);
- len += ((uInt)get_byte(s))<<8;
- /* len is garbage if EOF but the loop below will quit anyway */
- while (len-- != 0 && get_byte(s) != EOF) ;
- }
- if ((flags & ORIG_NAME) != 0) { /* skip the original file name */
- while ((c = get_byte(s)) != 0 && c != EOF) ;
- }
- if ((flags & COMMENT) != 0) { /* skip the .gz file comment */
- while ((c = get_byte(s)) != 0 && c != EOF) ;
- }
- if ((flags & HEAD_CRC) != 0) { /* skip the header crc */
- for (len = 0; len < 2; len++) (void)get_byte(s);
- }
- s->z_err = s->z_eof ? Z_DATA_ERROR : Z_OK;
-}
-
- /* ===========================================================================
- * Cleanup then free the given gz_stream. Return a zlib error code.
- Try freeing in the reverse order of allocations.
- */
-local int destroy (s)
- gz_stream *s;
-{
- int err = Z_OK;
-
- if (!s) return Z_STREAM_ERROR;
-
- TRYFREE(s->msg);
-
- if (s->stream.state != NULL) {
- if (s->mode == 'w') {
-#ifdef NO_GZCOMPRESS
- err = Z_STREAM_ERROR;
-#else
- err = deflateEnd(&(s->stream));
-#endif
- } else if (s->mode == 'r') {
- err = inflateEnd(&(s->stream));
- }
- }
- if (s->file != NULL && fclose(s->file)) {
-#ifdef ESPIPE
- if (errno != ESPIPE) /* fclose is broken for pipes in HP/UX */
-#endif
- err = Z_ERRNO;
- }
- if (s->z_err < 0) err = s->z_err;
-
- TRYFREE(s->inbuf);
- TRYFREE(s->outbuf);
- TRYFREE(s->path);
- TRYFREE(s);
- return err;
-}
-
-/* ===========================================================================
- Reads the given number of uncompressed bytes from the compressed file.
- gzread returns the number of bytes actually read (0 for end of file).
-*/
-int ZEXPORT gzread (file, buf, len)
- gzFile file;
- voidp buf;
- unsigned len;
-{
- gz_stream *s = (gz_stream*)file;
- Bytef *start = (Bytef*)buf; /* starting point for crc computation */
- Byte *next_out; /* == stream.next_out but not forced far (for MSDOS) */
-
- if (s == NULL || s->mode != 'r') return Z_STREAM_ERROR;
-
- if (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO) return -1;
- if (s->z_err == Z_STREAM_END) return 0; /* EOF */
-
- next_out = (Byte*)buf;
- s->stream.next_out = (Bytef*)buf;
- s->stream.avail_out = len;
-
- if (s->stream.avail_out && s->back != EOF) {
- *next_out++ = s->back;
- s->stream.next_out++;
- s->stream.avail_out--;
- s->back = EOF;
- s->out++;
- start++;
- if (s->last) {
- s->z_err = Z_STREAM_END;
- return 1;
- }
- }
-
- while (s->stream.avail_out != 0) {
-
- if (s->transparent) {
- /* Copy first the lookahead bytes: */
- uInt n = s->stream.avail_in;
- if (n > s->stream.avail_out) n = s->stream.avail_out;
- if (n > 0) {
- zmemcpy(s->stream.next_out, s->stream.next_in, n);
- next_out += n;
- s->stream.next_out = next_out;
- s->stream.next_in += n;
- s->stream.avail_out -= n;
- s->stream.avail_in -= n;
- }
- if (s->stream.avail_out > 0) {
- s->stream.avail_out -=
- (uInt)fread(next_out, 1, s->stream.avail_out, s->file);
- }
- len -= s->stream.avail_out;
- s->in += len;
- s->out += len;
- if (len == 0) s->z_eof = 1;
- return (int)len;
- }
- if (s->stream.avail_in == 0 && !s->z_eof) {
-
- errno = 0;
- s->stream.avail_in = (uInt)fread(s->inbuf, 1, Z_BUFSIZE, s->file);
- if (s->stream.avail_in == 0) {
- s->z_eof = 1;
- if (ferror(s->file)) {
- s->z_err = Z_ERRNO;
- break;
- }
- }
- s->stream.next_in = s->inbuf;
- }
- s->in += s->stream.avail_in;
- s->out += s->stream.avail_out;
- s->z_err = inflate(&(s->stream), Z_NO_FLUSH);
- s->in -= s->stream.avail_in;
- s->out -= s->stream.avail_out;
-
- if (s->z_err == Z_STREAM_END) {
- /* Check CRC and original size */
- s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start));
- start = s->stream.next_out;
-
- if (getLong(s) != s->crc) {
- s->z_err = Z_DATA_ERROR;
- } else {
- (void)getLong(s);
- /* The uncompressed length returned by above getlong() may be
- * different from s->out in case of concatenated .gz files.
- * Check for such files:
- */
- check_header(s);
- if (s->z_err == Z_OK) {
- inflateReset(&(s->stream));
- s->crc = crc32(0L, Z_NULL, 0);
- }
- }
- }
- if (s->z_err != Z_OK || s->z_eof) break;
- }
- s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start));
-
- if (len == s->stream.avail_out &&
- (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO))
- return -1;
- return (int)(len - s->stream.avail_out);
-}
-
-
-/* ===========================================================================
- Reads one byte from the compressed file. gzgetc returns this byte
- or -1 in case of end of file or error.
-*/
-int ZEXPORT gzgetc(file)
- gzFile file;
-{
- unsigned char c;
-
- return gzread(file, &c, 1) == 1 ? c : -1;
-}
-
-
-/* ===========================================================================
- Push one byte back onto the stream.
-*/
-int ZEXPORT gzungetc(c, file)
- int c;
- gzFile file;
-{
- gz_stream *s = (gz_stream*)file;
-
- if (s == NULL || s->mode != 'r' || c == EOF || s->back != EOF) return EOF;
- s->back = c;
- s->out--;
- s->last = (s->z_err == Z_STREAM_END);
- if (s->last) s->z_err = Z_OK;
- s->z_eof = 0;
- return c;
-}
-
-
-/* ===========================================================================
- Reads bytes from the compressed file until len-1 characters are
- read, or a newline character is read and transferred to buf, or an
- end-of-file condition is encountered. The string is then terminated
- with a null character.
- gzgets returns buf, or Z_NULL in case of error.
-
- The current implementation is not optimized at all.
-*/
-char * ZEXPORT gzgets(file, buf, len)
- gzFile file;
- char *buf;
- int len;
-{
- char *b = buf;
- if (buf == Z_NULL || len <= 0) return Z_NULL;
-
- while (--len > 0 && gzread(file, buf, 1) == 1 && *buf++ != '\n') ;
- *buf = '\0';
- return b == buf && len > 0 ? Z_NULL : b;
-}
-
-
-#ifndef NO_GZCOMPRESS
-/* ===========================================================================
- Writes the given number of uncompressed bytes into the compressed file.
- gzwrite returns the number of bytes actually written (0 in case of error).
-*/
-int ZEXPORT gzwrite (file, buf, len)
- gzFile file;
- voidpc buf;
- unsigned len;
-{
- gz_stream *s = (gz_stream*)file;
-
- if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
-
- s->stream.next_in = (Bytef*)buf;
- s->stream.avail_in = len;
-
- while (s->stream.avail_in != 0) {
-
- if (s->stream.avail_out == 0) {
-
- s->stream.next_out = s->outbuf;
- if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) {
- s->z_err = Z_ERRNO;
- break;
- }
- s->stream.avail_out = Z_BUFSIZE;
- }
- s->in += s->stream.avail_in;
- s->out += s->stream.avail_out;
- s->z_err = deflate(&(s->stream), Z_NO_FLUSH);
- s->in -= s->stream.avail_in;
- s->out -= s->stream.avail_out;
- if (s->z_err != Z_OK) break;
- }
- s->crc = crc32(s->crc, (const Bytef *)buf, len);
-
- return (int)(len - s->stream.avail_in);
-}
-
-
-/* ===========================================================================
- Converts, formats, and writes the args to the compressed file under
- control of the format string, as in fprintf. gzprintf returns the number of
- uncompressed bytes actually written (0 in case of error).
-*/
-#ifdef STDC
-#include <stdarg.h>
-
-int ZEXPORTVA gzprintf (gzFile file, const char *format, /* args */ ...)
-{
- char buf[Z_PRINTF_BUFSIZE];
- va_list va;
- int len;
-
- buf[sizeof(buf) - 1] = 0;
- va_start(va, format);
-#ifdef NO_vsnprintf
-# ifdef HAS_vsprintf_void
- (void)vsprintf(buf, format, va);
- va_end(va);
- for (len = 0; len < sizeof(buf); len++)
- if (buf[len] == 0) break;
-# else
- len = vsprintf(buf, format, va);
- va_end(va);
-# endif
-#else
-# ifdef HAS_vsnprintf_void
- (void)vsnprintf(buf, sizeof(buf), format, va);
- va_end(va);
- len = strlen(buf);
-# else
- len = vsnprintf(buf, sizeof(buf), format, va);
- va_end(va);
-# endif
-#endif
- if (len <= 0 || len >= (int)sizeof(buf) || buf[sizeof(buf) - 1] != 0)
- return 0;
- return gzwrite(file, buf, (unsigned)len);
-}
-#else /* not ANSI C */
-
-int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
- a11, a12, a13, a14, a15, a16, a17, a18, a19, a20)
- gzFile file;
- const char *format;
- int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
- a11, a12, a13, a14, a15, a16, a17, a18, a19, a20;
-{
- char buf[Z_PRINTF_BUFSIZE];
- int len;
-
- buf[sizeof(buf) - 1] = 0;
-#ifdef NO_snprintf
-# ifdef HAS_sprintf_void
- sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8,
- a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
- for (len = 0; len < sizeof(buf); len++)
- if (buf[len] == 0) break;
-# else
- len = sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8,
- a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
-# endif
-#else
-# ifdef HAS_snprintf_void
- snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8,
- a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
- len = strlen(buf);
-# else
- len = snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8,
- a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
-# endif
-#endif
- if (len <= 0 || len >= sizeof(buf) || buf[sizeof(buf) - 1] != 0)
- return 0;
- return gzwrite(file, buf, len);
-}
-#endif
-
-/* ===========================================================================
- Writes c, converted to an unsigned char, into the compressed file.
- gzputc returns the value that was written, or -1 in case of error.
-*/
-int ZEXPORT gzputc(file, c)
- gzFile file;
- int c;
-{
- unsigned char cc = (unsigned char) c; /* required for big endian systems */
-
- return gzwrite(file, &cc, 1) == 1 ? (int)cc : -1;
-}
-
-
-/* ===========================================================================
- Writes the given null-terminated string to the compressed file, excluding
- the terminating null character.
- gzputs returns the number of characters written, or -1 in case of error.
-*/
-int ZEXPORT gzputs(file, s)
- gzFile file;
- const char *s;
-{
- return gzwrite(file, (char*)s, (unsigned)strlen(s));
-}
-
-
-/* ===========================================================================
- Flushes all pending output into the compressed file. The parameter
- flush is as in the deflate() function.
-*/
-local int do_flush (file, flush)
- gzFile file;
- int flush;
-{
- uInt len;
- int done = 0;
- gz_stream *s = (gz_stream*)file;
-
- if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
-
- s->stream.avail_in = 0; /* should be zero already anyway */
-
- for (;;) {
- len = Z_BUFSIZE - s->stream.avail_out;
-
- if (len != 0) {
- if ((uInt)fwrite(s->outbuf, 1, len, s->file) != len) {
- s->z_err = Z_ERRNO;
- return Z_ERRNO;
- }
- s->stream.next_out = s->outbuf;
- s->stream.avail_out = Z_BUFSIZE;
- }
- if (done) break;
- s->out += s->stream.avail_out;
- s->z_err = deflate(&(s->stream), flush);
- s->out -= s->stream.avail_out;
-
- /* Ignore the second of two consecutive flushes: */
- if (len == 0 && s->z_err == Z_BUF_ERROR) s->z_err = Z_OK;
-
- /* deflate has finished flushing only when it hasn't used up
- * all the available space in the output buffer:
- */
- done = (s->stream.avail_out != 0 || s->z_err == Z_STREAM_END);
-
- if (s->z_err != Z_OK && s->z_err != Z_STREAM_END) break;
- }
- return s->z_err == Z_STREAM_END ? Z_OK : s->z_err;
-}
-
-int ZEXPORT gzflush (file, flush)
- gzFile file;
- int flush;
-{
- gz_stream *s = (gz_stream*)file;
- int err = do_flush (file, flush);
-
- if (err) return err;
- fflush(s->file);
- return s->z_err == Z_STREAM_END ? Z_OK : s->z_err;
-}
-#endif /* NO_GZCOMPRESS */
-
-/* ===========================================================================
- Sets the starting position for the next gzread or gzwrite on the given
- compressed file. The offset represents a number of bytes in the
- gzseek returns the resulting offset location as measured in bytes from
- the beginning of the uncompressed stream, or -1 in case of error.
- SEEK_END is not implemented, returns error.
- In this version of the library, gzseek can be extremely slow.
-*/
-z_off_t ZEXPORT gzseek (file, offset, whence)
- gzFile file;
- z_off_t offset;
- int whence;
-{
- gz_stream *s = (gz_stream*)file;
-
- if (s == NULL || whence == SEEK_END ||
- s->z_err == Z_ERRNO || s->z_err == Z_DATA_ERROR) {
- return -1L;
- }
-
- if (s->mode == 'w') {
-#ifdef NO_GZCOMPRESS
- return -1L;
-#else
- if (whence == SEEK_SET) {
- offset -= s->in;
- }
- if (offset < 0) return -1L;
-
- /* At this point, offset is the number of zero bytes to write. */
- if (s->inbuf == Z_NULL) {
- s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); /* for seeking */
- if (s->inbuf == Z_NULL) return -1L;
- zmemzero(s->inbuf, Z_BUFSIZE);
- }
- while (offset > 0) {
- uInt size = Z_BUFSIZE;
- if (offset < Z_BUFSIZE) size = (uInt)offset;
-
- size = gzwrite(file, s->inbuf, size);
- if (size == 0) return -1L;
-
- offset -= size;
- }
- return s->in;
-#endif
- }
- /* Rest of function is for reading only */
-
- /* compute absolute position */
- if (whence == SEEK_CUR) {
- offset += s->out;
- }
- if (offset < 0) return -1L;
-
- if (s->transparent) {
- /* map to fseek */
- s->back = EOF;
- s->stream.avail_in = 0;
- s->stream.next_in = s->inbuf;
- if (fseek(s->file, offset, SEEK_SET) < 0) return -1L;
-
- s->in = s->out = offset;
- return offset;
- }
-
- /* For a negative seek, rewind and use positive seek */
- if (offset >= s->out) {
- offset -= s->out;
- } else if (gzrewind(file) < 0) {
- return -1L;
- }
- /* offset is now the number of bytes to skip. */
-
- if (offset != 0 && s->outbuf == Z_NULL) {
- s->outbuf = (Byte*)ALLOC(Z_BUFSIZE);
- if (s->outbuf == Z_NULL) return -1L;
- }
- if (offset && s->back != EOF) {
- s->back = EOF;
- s->out++;
- offset--;
- if (s->last) s->z_err = Z_STREAM_END;
- }
- while (offset > 0) {
- int size = Z_BUFSIZE;
- if (offset < Z_BUFSIZE) size = (int)offset;
-
- size = gzread(file, s->outbuf, (uInt)size);
- if (size <= 0) return -1L;
- offset -= size;
- }
- return s->out;
-}
-
-/* ===========================================================================
- Rewinds input file.
-*/
-int ZEXPORT gzrewind (file)
- gzFile file;
-{
- gz_stream *s = (gz_stream*)file;
-
- if (s == NULL || s->mode != 'r') return -1;
-
- s->z_err = Z_OK;
- s->z_eof = 0;
- s->back = EOF;
- s->stream.avail_in = 0;
- s->stream.next_in = s->inbuf;
- s->crc = crc32(0L, Z_NULL, 0);
- if (!s->transparent) (void)inflateReset(&s->stream);
- s->in = 0;
- s->out = 0;
- return fseek(s->file, s->start, SEEK_SET);
-}
-
-/* ===========================================================================
- Returns the starting position for the next gzread or gzwrite on the
- given compressed file. This position represents a number of bytes in the
- uncompressed data stream.
-*/
-z_off_t ZEXPORT gztell (file)
- gzFile file;
-{
- return gzseek(file, 0L, SEEK_CUR);
-}
-
-/* ===========================================================================
- Returns 1 when EOF has previously been detected reading the given
- input stream, otherwise zero.
-*/
-int ZEXPORT gzeof (file)
- gzFile file;
-{
- gz_stream *s = (gz_stream*)file;
-
- /* With concatenated compressed files that can have embedded
- * crc trailers, z_eof is no longer the only/best indicator of EOF
- * on a gz_stream. Handle end-of-stream error explicitly here.
- */
- if (s == NULL || s->mode != 'r') return 0;
- if (s->z_eof) return 1;
- return s->z_err == Z_STREAM_END;
-}
-
-/* ===========================================================================
- Returns 1 if reading and doing so transparently, otherwise zero.
-*/
-int ZEXPORT gzdirect (file)
- gzFile file;
-{
- gz_stream *s = (gz_stream*)file;
-
- if (s == NULL || s->mode != 'r') return 0;
- return s->transparent;
-}
-
-/* ===========================================================================
- Outputs a long in LSB order to the given file
-*/
-local void putLong (file, x)
- FILE *file;
- uLong x;
-{
- int n;
- for (n = 0; n < 4; n++) {
- fputc((int)(x & 0xff), file);
- x >>= 8;
- }
-}
-
-/* ===========================================================================
- Reads a long in LSB order from the given gz_stream. Sets z_err in case
- of error.
-*/
-local uLong getLong (s)
- gz_stream *s;
-{
- uLong x = (uLong)get_byte(s);
- int c;
-
- x += ((uLong)get_byte(s))<<8;
- x += ((uLong)get_byte(s))<<16;
- c = get_byte(s);
- if (c == EOF) s->z_err = Z_DATA_ERROR;
- x += ((uLong)c)<<24;
- return x;
-}
-
-/* ===========================================================================
- Flushes all pending output if necessary, closes the compressed file
- and deallocates all the (de)compression state.
-*/
-int ZEXPORT gzclose (file)
- gzFile file;
-{
- gz_stream *s = (gz_stream*)file;
-
- if (s == NULL) return Z_STREAM_ERROR;
-
- if (s->mode == 'w') {
-#ifdef NO_GZCOMPRESS
- return Z_STREAM_ERROR;
-#else
- if (do_flush (file, Z_FINISH) != Z_OK)
- return destroy((gz_stream*)file);
-
- putLong (s->file, s->crc);
- putLong (s->file, (uLong)(s->in & 0xffffffff));
-#endif
- }
- return destroy((gz_stream*)file);
-}
-
-#ifdef STDC
-# define zstrerror(errnum) strerror(errnum)
-#else
-# define zstrerror(errnum) ""
-#endif
-
-/* ===========================================================================
- Returns the error message for the last error which occurred on the
- given compressed file. errnum is set to zlib error number. If an
- error occurred in the file system and not in the compression library,
- errnum is set to Z_ERRNO and the application may consult errno
- to get the exact error code.
-*/
-const char * ZEXPORT gzerror (file, errnum)
- gzFile file;
- int *errnum;
-{
- char *m;
- gz_stream *s = (gz_stream*)file;
-
- if (s == NULL) {
- *errnum = Z_STREAM_ERROR;
- return (const char*)ERR_MSG(Z_STREAM_ERROR);
- }
- *errnum = s->z_err;
- if (*errnum == Z_OK) return (const char*)"";
-
- m = (char*)(*errnum == Z_ERRNO ? zstrerror(errno) : s->stream.msg);
-
- if (m == NULL || *m == '\0') m = (char*)ERR_MSG(s->z_err);
-
- TRYFREE(s->msg);
- s->msg = (char*)ALLOC(strlen(s->path) + strlen(m) + 3);
- if (s->msg == Z_NULL) return (const char*)ERR_MSG(Z_MEM_ERROR);
- strcpy(s->msg, s->path);
- strcat(s->msg, ": ");
- strcat(s->msg, m);
- return (const char*)s->msg;
-}
-
-/* ===========================================================================
- Clear the error and end-of-file flags, and do the same for the real file.
-*/
-void ZEXPORT gzclearerr (file)
- gzFile file;
-{
- gz_stream *s = (gz_stream*)file;
-
- if (s == NULL) return;
- if (s->z_err != Z_STREAM_END) s->z_err = Z_OK;
- s->z_eof = 0;
- clearerr(s->file);
-}
diff --git a/WebCore/platform/image-decoders/zlib/infback.c b/WebCore/platform/image-decoders/zlib/infback.c
deleted file mode 100644
index 455dbc9..0000000
--- a/WebCore/platform/image-decoders/zlib/infback.c
+++ /dev/null
@@ -1,623 +0,0 @@
-/* infback.c -- inflate using a call-back interface
- * Copyright (C) 1995-2005 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/*
- This code is largely copied from inflate.c. Normally either infback.o or
- inflate.o would be linked into an application--not both. The interface
- with inffast.c is retained so that optimized assembler-coded versions of
- inflate_fast() can be used with either inflate.c or infback.c.
- */
-
-#include "zutil.h"
-#include "inftrees.h"
-#include "inflate.h"
-#include "inffast.h"
-
-/* function prototypes */
-local void fixedtables OF((struct inflate_state FAR *state));
-
-/*
- strm provides memory allocation functions in zalloc and zfree, or
- Z_NULL to use the library memory allocation functions.
-
- windowBits is in the range 8..15, and window is a user-supplied
- window and output buffer that is 2**windowBits bytes.
- */
-int ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size)
-z_streamp strm;
-int windowBits;
-unsigned char FAR *window;
-const char *version;
-int stream_size;
-{
- struct inflate_state FAR *state;
-
- if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
- stream_size != (int)(sizeof(z_stream)))
- return Z_VERSION_ERROR;
- if (strm == Z_NULL || window == Z_NULL ||
- windowBits < 8 || windowBits > 15)
- return Z_STREAM_ERROR;
- strm->msg = Z_NULL; /* in case we return an error */
- if (strm->zalloc == (alloc_func)0) {
- strm->zalloc = zcalloc;
- strm->opaque = (voidpf)0;
- }
- if (strm->zfree == (free_func)0) strm->zfree = zcfree;
- state = (struct inflate_state FAR *)ZALLOC(strm, 1,
- sizeof(struct inflate_state));
- if (state == Z_NULL) return Z_MEM_ERROR;
- Tracev((stderr, "inflate: allocated\n"));
- strm->state = (struct internal_state FAR *)state;
- state->dmax = 32768U;
- state->wbits = windowBits;
- state->wsize = 1U << windowBits;
- state->window = window;
- state->write = 0;
- state->whave = 0;
- return Z_OK;
-}
-
-/*
- Return state with length and distance decoding tables and index sizes set to
- fixed code decoding. Normally this returns fixed tables from inffixed.h.
- If BUILDFIXED is defined, then instead this routine builds the tables the
- first time it's called, and returns those tables the first time and
- thereafter. This reduces the size of the code by about 2K bytes, in
- exchange for a little execution time. However, BUILDFIXED should not be
- used for threaded applications, since the rewriting of the tables and virgin
- may not be thread-safe.
- */
-local void fixedtables(state)
-struct inflate_state FAR *state;
-{
-#ifdef BUILDFIXED
- static int virgin = 1;
- static code *lenfix, *distfix;
- static code fixed[544];
-
- /* build fixed huffman tables if first call (may not be thread safe) */
- if (virgin) {
- unsigned sym, bits;
- static code *next;
-
- /* literal/length table */
- sym = 0;
- while (sym < 144) state->lens[sym++] = 8;
- while (sym < 256) state->lens[sym++] = 9;
- while (sym < 280) state->lens[sym++] = 7;
- while (sym < 288) state->lens[sym++] = 8;
- next = fixed;
- lenfix = next;
- bits = 9;
- inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
-
- /* distance table */
- sym = 0;
- while (sym < 32) state->lens[sym++] = 5;
- distfix = next;
- bits = 5;
- inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
-
- /* do this just once */
- virgin = 0;
- }
-#else /* !BUILDFIXED */
-# include "inffixed.h"
-#endif /* BUILDFIXED */
- state->lencode = lenfix;
- state->lenbits = 9;
- state->distcode = distfix;
- state->distbits = 5;
-}
-
-/* Macros for inflateBack(): */
-
-/* Load returned state from inflate_fast() */
-#define LOAD() \
- do { \
- put = strm->next_out; \
- left = strm->avail_out; \
- next = strm->next_in; \
- have = strm->avail_in; \
- hold = state->hold; \
- bits = state->bits; \
- } while (0)
-
-/* Set state from registers for inflate_fast() */
-#define RESTORE() \
- do { \
- strm->next_out = put; \
- strm->avail_out = left; \
- strm->next_in = next; \
- strm->avail_in = have; \
- state->hold = hold; \
- state->bits = bits; \
- } while (0)
-
-/* Clear the input bit accumulator */
-#define INITBITS() \
- do { \
- hold = 0; \
- bits = 0; \
- } while (0)
-
-/* Assure that some input is available. If input is requested, but denied,
- then return a Z_BUF_ERROR from inflateBack(). */
-#define PULL() \
- do { \
- if (have == 0) { \
- have = in(in_desc, &next); \
- if (have == 0) { \
- next = Z_NULL; \
- ret = Z_BUF_ERROR; \
- goto inf_leave; \
- } \
- } \
- } while (0)
-
-/* Get a byte of input into the bit accumulator, or return from inflateBack()
- with an error if there is no input available. */
-#define PULLBYTE() \
- do { \
- PULL(); \
- have--; \
- hold += (unsigned long)(*next++) << bits; \
- bits += 8; \
- } while (0)
-
-/* Assure that there are at least n bits in the bit accumulator. If there is
- not enough available input to do that, then return from inflateBack() with
- an error. */
-#define NEEDBITS(n) \
- do { \
- while (bits < (unsigned)(n)) \
- PULLBYTE(); \
- } while (0)
-
-/* Return the low n bits of the bit accumulator (n < 16) */
-#define BITS(n) \
- ((unsigned)hold & ((1U << (n)) - 1))
-
-/* Remove n bits from the bit accumulator */
-#define DROPBITS(n) \
- do { \
- hold >>= (n); \
- bits -= (unsigned)(n); \
- } while (0)
-
-/* Remove zero to seven bits as needed to go to a byte boundary */
-#define BYTEBITS() \
- do { \
- hold >>= bits & 7; \
- bits -= bits & 7; \
- } while (0)
-
-/* Assure that some output space is available, by writing out the window
- if it's full. If the write fails, return from inflateBack() with a
- Z_BUF_ERROR. */
-#define ROOM() \
- do { \
- if (left == 0) { \
- put = state->window; \
- left = state->wsize; \
- state->whave = left; \
- if (out(out_desc, put, left)) { \
- ret = Z_BUF_ERROR; \
- goto inf_leave; \
- } \
- } \
- } while (0)
-
-/*
- strm provides the memory allocation functions and window buffer on input,
- and provides information on the unused input on return. For Z_DATA_ERROR
- returns, strm will also provide an error message.
-
- in() and out() are the call-back input and output functions. When
- inflateBack() needs more input, it calls in(). When inflateBack() has
- filled the window with output, or when it completes with data in the
- window, it calls out() to write out the data. The application must not
- change the provided input until in() is called again or inflateBack()
- returns. The application must not change the window/output buffer until
- inflateBack() returns.
-
- in() and out() are called with a descriptor parameter provided in the
- inflateBack() call. This parameter can be a structure that provides the
- information required to do the read or write, as well as accumulated
- information on the input and output such as totals and check values.
-
- in() should return zero on failure. out() should return non-zero on
- failure. If either in() or out() fails, than inflateBack() returns a
- Z_BUF_ERROR. strm->next_in can be checked for Z_NULL to see whether it
- was in() or out() that caused in the error. Otherwise, inflateBack()
- returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format
- error, or Z_MEM_ERROR if it could not allocate memory for the state.
- inflateBack() can also return Z_STREAM_ERROR if the input parameters
- are not correct, i.e. strm is Z_NULL or the state was not initialized.
- */
-int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc)
-z_streamp strm;
-in_func in;
-void FAR *in_desc;
-out_func out;
-void FAR *out_desc;
-{
- struct inflate_state FAR *state;
- unsigned char FAR *next; /* next input */
- unsigned char FAR *put; /* next output */
- unsigned have, left; /* available input and output */
- unsigned long hold; /* bit buffer */
- unsigned bits; /* bits in bit buffer */
- unsigned copy; /* number of stored or match bytes to copy */
- unsigned char FAR *from; /* where to copy match bytes from */
- code this; /* current decoding table entry */
- code last; /* parent table entry */
- unsigned len; /* length to copy for repeats, bits to drop */
- int ret; /* return code */
- static const unsigned short order[19] = /* permutation of code lengths */
- {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
-
- /* Check that the strm exists and that the state was initialized */
- if (strm == Z_NULL || strm->state == Z_NULL)
- return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
-
- /* Reset the state */
- strm->msg = Z_NULL;
- state->mode = TYPE;
- state->last = 0;
- state->whave = 0;
- next = strm->next_in;
- have = next != Z_NULL ? strm->avail_in : 0;
- hold = 0;
- bits = 0;
- put = state->window;
- left = state->wsize;
-
- /* Inflate until end of block marked as last */
- for (;;)
- switch (state->mode) {
- case TYPE:
- /* determine and dispatch block type */
- if (state->last) {
- BYTEBITS();
- state->mode = DONE;
- break;
- }
- NEEDBITS(3);
- state->last = BITS(1);
- DROPBITS(1);
- switch (BITS(2)) {
- case 0: /* stored block */
- Tracev((stderr, "inflate: stored block%s\n",
- state->last ? " (last)" : ""));
- state->mode = STORED;
- break;
- case 1: /* fixed block */
- fixedtables(state);
- Tracev((stderr, "inflate: fixed codes block%s\n",
- state->last ? " (last)" : ""));
- state->mode = LEN; /* decode codes */
- break;
- case 2: /* dynamic block */
- Tracev((stderr, "inflate: dynamic codes block%s\n",
- state->last ? " (last)" : ""));
- state->mode = TABLE;
- break;
- case 3:
- strm->msg = (char *)"invalid block type";
- state->mode = BAD;
- }
- DROPBITS(2);
- break;
-
- case STORED:
- /* get and verify stored block length */
- BYTEBITS(); /* go to byte boundary */
- NEEDBITS(32);
- if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
- strm->msg = (char *)"invalid stored block lengths";
- state->mode = BAD;
- break;
- }
- state->length = (unsigned)hold & 0xffff;
- Tracev((stderr, "inflate: stored length %u\n",
- state->length));
- INITBITS();
-
- /* copy stored block from input to output */
- while (state->length != 0) {
- copy = state->length;
- PULL();
- ROOM();
- if (copy > have) copy = have;
- if (copy > left) copy = left;
- zmemcpy(put, next, copy);
- have -= copy;
- next += copy;
- left -= copy;
- put += copy;
- state->length -= copy;
- }
- Tracev((stderr, "inflate: stored end\n"));
- state->mode = TYPE;
- break;
-
- case TABLE:
- /* get dynamic table entries descriptor */
- NEEDBITS(14);
- state->nlen = BITS(5) + 257;
- DROPBITS(5);
- state->ndist = BITS(5) + 1;
- DROPBITS(5);
- state->ncode = BITS(4) + 4;
- DROPBITS(4);
-#ifndef PKZIP_BUG_WORKAROUND
- if (state->nlen > 286 || state->ndist > 30) {
- strm->msg = (char *)"too many length or distance symbols";
- state->mode = BAD;
- break;
- }
-#endif
- Tracev((stderr, "inflate: table sizes ok\n"));
-
- /* get code length code lengths (not a typo) */
- state->have = 0;
- while (state->have < state->ncode) {
- NEEDBITS(3);
- state->lens[order[state->have++]] = (unsigned short)BITS(3);
- DROPBITS(3);
- }
- while (state->have < 19)
- state->lens[order[state->have++]] = 0;
- state->next = state->codes;
- state->lencode = (code const FAR *)(state->next);
- state->lenbits = 7;
- ret = inflate_table(CODES, state->lens, 19, &(state->next),
- &(state->lenbits), state->work);
- if (ret) {
- strm->msg = (char *)"invalid code lengths set";
- state->mode = BAD;
- break;
- }
- Tracev((stderr, "inflate: code lengths ok\n"));
-
- /* get length and distance code code lengths */
- state->have = 0;
- while (state->have < state->nlen + state->ndist) {
- for (;;) {
- this = state->lencode[BITS(state->lenbits)];
- if ((unsigned)(this.bits) <= bits) break;
- PULLBYTE();
- }
- if (this.val < 16) {
- NEEDBITS(this.bits);
- DROPBITS(this.bits);
- state->lens[state->have++] = this.val;
- }
- else {
- if (this.val == 16) {
- NEEDBITS(this.bits + 2);
- DROPBITS(this.bits);
- if (state->have == 0) {
- strm->msg = (char *)"invalid bit length repeat";
- state->mode = BAD;
- break;
- }
- len = (unsigned)(state->lens[state->have - 1]);
- copy = 3 + BITS(2);
- DROPBITS(2);
- }
- else if (this.val == 17) {
- NEEDBITS(this.bits + 3);
- DROPBITS(this.bits);
- len = 0;
- copy = 3 + BITS(3);
- DROPBITS(3);
- }
- else {
- NEEDBITS(this.bits + 7);
- DROPBITS(this.bits);
- len = 0;
- copy = 11 + BITS(7);
- DROPBITS(7);
- }
- if (state->have + copy > state->nlen + state->ndist) {
- strm->msg = (char *)"invalid bit length repeat";
- state->mode = BAD;
- break;
- }
- while (copy--)
- state->lens[state->have++] = (unsigned short)len;
- }
- }
-
- /* handle error breaks in while */
- if (state->mode == BAD) break;
-
- /* build code tables */
- state->next = state->codes;
- state->lencode = (code const FAR *)(state->next);
- state->lenbits = 9;
- ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
- &(state->lenbits), state->work);
- if (ret) {
- strm->msg = (char *)"invalid literal/lengths set";
- state->mode = BAD;
- break;
- }
- state->distcode = (code const FAR *)(state->next);
- state->distbits = 6;
- ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
- &(state->next), &(state->distbits), state->work);
- if (ret) {
- strm->msg = (char *)"invalid distances set";
- state->mode = BAD;
- break;
- }
- Tracev((stderr, "inflate: codes ok\n"));
- state->mode = LEN;
-
- case LEN:
- /* use inflate_fast() if we have enough input and output */
- if (have >= 6 && left >= 258) {
- RESTORE();
- if (state->whave < state->wsize)
- state->whave = state->wsize - left;
- inflate_fast(strm, state->wsize);
- LOAD();
- break;
- }
-
- /* get a literal, length, or end-of-block code */
- for (;;) {
- this = state->lencode[BITS(state->lenbits)];
- if ((unsigned)(this.bits) <= bits) break;
- PULLBYTE();
- }
- if (this.op && (this.op & 0xf0) == 0) {
- last = this;
- for (;;) {
- this = state->lencode[last.val +
- (BITS(last.bits + last.op) >> last.bits)];
- if ((unsigned)(last.bits + this.bits) <= bits) break;
- PULLBYTE();
- }
- DROPBITS(last.bits);
- }
- DROPBITS(this.bits);
- state->length = (unsigned)this.val;
-
- /* process literal */
- if (this.op == 0) {
- Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
- "inflate: literal '%c'\n" :
- "inflate: literal 0x%02x\n", this.val));
- ROOM();
- *put++ = (unsigned char)(state->length);
- left--;
- state->mode = LEN;
- break;
- }
-
- /* process end of block */
- if (this.op & 32) {
- Tracevv((stderr, "inflate: end of block\n"));
- state->mode = TYPE;
- break;
- }
-
- /* invalid code */
- if (this.op & 64) {
- strm->msg = (char *)"invalid literal/length code";
- state->mode = BAD;
- break;
- }
-
- /* length code -- get extra bits, if any */
- state->extra = (unsigned)(this.op) & 15;
- if (state->extra != 0) {
- NEEDBITS(state->extra);
- state->length += BITS(state->extra);
- DROPBITS(state->extra);
- }
- Tracevv((stderr, "inflate: length %u\n", state->length));
-
- /* get distance code */
- for (;;) {
- this = state->distcode[BITS(state->distbits)];
- if ((unsigned)(this.bits) <= bits) break;
- PULLBYTE();
- }
- if ((this.op & 0xf0) == 0) {
- last = this;
- for (;;) {
- this = state->distcode[last.val +
- (BITS(last.bits + last.op) >> last.bits)];
- if ((unsigned)(last.bits + this.bits) <= bits) break;
- PULLBYTE();
- }
- DROPBITS(last.bits);
- }
- DROPBITS(this.bits);
- if (this.op & 64) {
- strm->msg = (char *)"invalid distance code";
- state->mode = BAD;
- break;
- }
- state->offset = (unsigned)this.val;
-
- /* get distance extra bits, if any */
- state->extra = (unsigned)(this.op) & 15;
- if (state->extra != 0) {
- NEEDBITS(state->extra);
- state->offset += BITS(state->extra);
- DROPBITS(state->extra);
- }
- if (state->offset > state->wsize - (state->whave < state->wsize ?
- left : 0)) {
- strm->msg = (char *)"invalid distance too far back";
- state->mode = BAD;
- break;
- }
- Tracevv((stderr, "inflate: distance %u\n", state->offset));
-
- /* copy match from window to output */
- do {
- ROOM();
- copy = state->wsize - state->offset;
- if (copy < left) {
- from = put + copy;
- copy = left - copy;
- }
- else {
- from = put - state->offset;
- copy = left;
- }
- if (copy > state->length) copy = state->length;
- state->length -= copy;
- left -= copy;
- do {
- *put++ = *from++;
- } while (--copy);
- } while (state->length != 0);
- break;
-
- case DONE:
- /* inflate stream terminated properly -- write leftover output */
- ret = Z_STREAM_END;
- if (left < state->wsize) {
- if (out(out_desc, state->window, state->wsize - left))
- ret = Z_BUF_ERROR;
- }
- goto inf_leave;
-
- case BAD:
- ret = Z_DATA_ERROR;
- goto inf_leave;
-
- default: /* can't happen, but makes compilers happy */
- ret = Z_STREAM_ERROR;
- goto inf_leave;
- }
-
- /* Return unused input */
- inf_leave:
- strm->next_in = next;
- strm->avail_in = have;
- return ret;
-}
-
-int ZEXPORT inflateBackEnd(strm)
-z_streamp strm;
-{
- if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
- return Z_STREAM_ERROR;
- ZFREE(strm, strm->state);
- strm->state = Z_NULL;
- Tracev((stderr, "inflate: end\n"));
- return Z_OK;
-}
diff --git a/WebCore/platform/image-decoders/zlib/inffast.c b/WebCore/platform/image-decoders/zlib/inffast.c
deleted file mode 100644
index bbee92e..0000000
--- a/WebCore/platform/image-decoders/zlib/inffast.c
+++ /dev/null
@@ -1,318 +0,0 @@
-/* inffast.c -- fast decoding
- * Copyright (C) 1995-2004 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-#include "zutil.h"
-#include "inftrees.h"
-#include "inflate.h"
-#include "inffast.h"
-
-#ifndef ASMINF
-
-/* Allow machine dependent optimization for post-increment or pre-increment.
- Based on testing to date,
- Pre-increment preferred for:
- - PowerPC G3 (Adler)
- - MIPS R5000 (Randers-Pehrson)
- Post-increment preferred for:
- - none
- No measurable difference:
- - Pentium III (Anderson)
- - M68060 (Nikl)
- */
-#ifdef POSTINC
-# define OFF 0
-# define PUP(a) *(a)++
-#else
-# define OFF 1
-# define PUP(a) *++(a)
-#endif
-
-/*
- Decode literal, length, and distance codes and write out the resulting
- literal and match bytes until either not enough input or output is
- available, an end-of-block is encountered, or a data error is encountered.
- When large enough input and output buffers are supplied to inflate(), for
- example, a 16K input buffer and a 64K output buffer, more than 95% of the
- inflate execution time is spent in this routine.
-
- Entry assumptions:
-
- state->mode == LEN
- strm->avail_in >= 6
- strm->avail_out >= 258
- start >= strm->avail_out
- state->bits < 8
-
- On return, state->mode is one of:
-
- LEN -- ran out of enough output space or enough available input
- TYPE -- reached end of block code, inflate() to interpret next block
- BAD -- error in block data
-
- Notes:
-
- - The maximum input bits used by a length/distance pair is 15 bits for the
- length code, 5 bits for the length extra, 15 bits for the distance code,
- and 13 bits for the distance extra. This totals 48 bits, or six bytes.
- Therefore if strm->avail_in >= 6, then there is enough input to avoid
- checking for available input while decoding.
-
- - The maximum bytes that a single length/distance pair can output is 258
- bytes, which is the maximum length that can be coded. inflate_fast()
- requires strm->avail_out >= 258 for each loop to avoid checking for
- output space.
- */
-void inflate_fast(strm, start)
-z_streamp strm;
-unsigned start; /* inflate()'s starting value for strm->avail_out */
-{
- struct inflate_state FAR *state;
- unsigned char FAR *in; /* local strm->next_in */
- unsigned char FAR *last; /* while in < last, enough input available */
- unsigned char FAR *out; /* local strm->next_out */
- unsigned char FAR *beg; /* inflate()'s initial strm->next_out */
- unsigned char FAR *end; /* while out < end, enough space available */
-#ifdef INFLATE_STRICT
- unsigned dmax; /* maximum distance from zlib header */
-#endif
- unsigned wsize; /* window size or zero if not using window */
- unsigned whave; /* valid bytes in the window */
- unsigned write; /* window write index */
- unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */
- unsigned long hold; /* local strm->hold */
- unsigned bits; /* local strm->bits */
- code const FAR *lcode; /* local strm->lencode */
- code const FAR *dcode; /* local strm->distcode */
- unsigned lmask; /* mask for first level of length codes */
- unsigned dmask; /* mask for first level of distance codes */
- code this; /* retrieved table entry */
- unsigned op; /* code bits, operation, extra bits, or */
- /* window position, window bytes to copy */
- unsigned len; /* match length, unused bytes */
- unsigned dist; /* match distance */
- unsigned char FAR *from; /* where to copy match from */
-
- /* copy state to local variables */
- state = (struct inflate_state FAR *)strm->state;
- in = strm->next_in - OFF;
- last = in + (strm->avail_in - 5);
- out = strm->next_out - OFF;
- beg = out - (start - strm->avail_out);
- end = out + (strm->avail_out - 257);
-#ifdef INFLATE_STRICT
- dmax = state->dmax;
-#endif
- wsize = state->wsize;
- whave = state->whave;
- write = state->write;
- window = state->window;
- hold = state->hold;
- bits = state->bits;
- lcode = state->lencode;
- dcode = state->distcode;
- lmask = (1U << state->lenbits) - 1;
- dmask = (1U << state->distbits) - 1;
-
- /* decode literals and length/distances until end-of-block or not enough
- input data or output space */
- do {
- if (bits < 15) {
- hold += (unsigned long)(PUP(in)) << bits;
- bits += 8;
- hold += (unsigned long)(PUP(in)) << bits;
- bits += 8;
- }
- this = lcode[hold & lmask];
- dolen:
- op = (unsigned)(this.bits);
- hold >>= op;
- bits -= op;
- op = (unsigned)(this.op);
- if (op == 0) { /* literal */
- Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
- "inflate: literal '%c'\n" :
- "inflate: literal 0x%02x\n", this.val));
- PUP(out) = (unsigned char)(this.val);
- }
- else if (op & 16) { /* length base */
- len = (unsigned)(this.val);
- op &= 15; /* number of extra bits */
- if (op) {
- if (bits < op) {
- hold += (unsigned long)(PUP(in)) << bits;
- bits += 8;
- }
- len += (unsigned)hold & ((1U << op) - 1);
- hold >>= op;
- bits -= op;
- }
- Tracevv((stderr, "inflate: length %u\n", len));
- if (bits < 15) {
- hold += (unsigned long)(PUP(in)) << bits;
- bits += 8;
- hold += (unsigned long)(PUP(in)) << bits;
- bits += 8;
- }
- this = dcode[hold & dmask];
- dodist:
- op = (unsigned)(this.bits);
- hold >>= op;
- bits -= op;
- op = (unsigned)(this.op);
- if (op & 16) { /* distance base */
- dist = (unsigned)(this.val);
- op &= 15; /* number of extra bits */
- if (bits < op) {
- hold += (unsigned long)(PUP(in)) << bits;
- bits += 8;
- if (bits < op) {
- hold += (unsigned long)(PUP(in)) << bits;
- bits += 8;
- }
- }
- dist += (unsigned)hold & ((1U << op) - 1);
-#ifdef INFLATE_STRICT
- if (dist > dmax) {
- strm->msg = (char *)"invalid distance too far back";
- state->mode = BAD;
- break;
- }
-#endif
- hold >>= op;
- bits -= op;
- Tracevv((stderr, "inflate: distance %u\n", dist));
- op = (unsigned)(out - beg); /* max distance in output */
- if (dist > op) { /* see if copy from window */
- op = dist - op; /* distance back in window */
- if (op > whave) {
- strm->msg = (char *)"invalid distance too far back";
- state->mode = BAD;
- break;
- }
- from = window - OFF;
- if (write == 0) { /* very common case */
- from += wsize - op;
- if (op < len) { /* some from window */
- len -= op;
- do {
- PUP(out) = PUP(from);
- } while (--op);
- from = out - dist; /* rest from output */
- }
- }
- else if (write < op) { /* wrap around window */
- from += wsize + write - op;
- op -= write;
- if (op < len) { /* some from end of window */
- len -= op;
- do {
- PUP(out) = PUP(from);
- } while (--op);
- from = window - OFF;
- if (write < len) { /* some from start of window */
- op = write;
- len -= op;
- do {
- PUP(out) = PUP(from);
- } while (--op);
- from = out - dist; /* rest from output */
- }
- }
- }
- else { /* contiguous in window */
- from += write - op;
- if (op < len) { /* some from window */
- len -= op;
- do {
- PUP(out) = PUP(from);
- } while (--op);
- from = out - dist; /* rest from output */
- }
- }
- while (len > 2) {
- PUP(out) = PUP(from);
- PUP(out) = PUP(from);
- PUP(out) = PUP(from);
- len -= 3;
- }
- if (len) {
- PUP(out) = PUP(from);
- if (len > 1)
- PUP(out) = PUP(from);
- }
- }
- else {
- from = out - dist; /* copy direct from output */
- do { /* minimum length is three */
- PUP(out) = PUP(from);
- PUP(out) = PUP(from);
- PUP(out) = PUP(from);
- len -= 3;
- } while (len > 2);
- if (len) {
- PUP(out) = PUP(from);
- if (len > 1)
- PUP(out) = PUP(from);
- }
- }
- }
- else if ((op & 64) == 0) { /* 2nd level distance code */
- this = dcode[this.val + (hold & ((1U << op) - 1))];
- goto dodist;
- }
- else {
- strm->msg = (char *)"invalid distance code";
- state->mode = BAD;
- break;
- }
- }
- else if ((op & 64) == 0) { /* 2nd level length code */
- this = lcode[this.val + (hold & ((1U << op) - 1))];
- goto dolen;
- }
- else if (op & 32) { /* end-of-block */
- Tracevv((stderr, "inflate: end of block\n"));
- state->mode = TYPE;
- break;
- }
- else {
- strm->msg = (char *)"invalid literal/length code";
- state->mode = BAD;
- break;
- }
- } while (in < last && out < end);
-
- /* return unused bytes (on entry, bits < 8, so in won't go too far back) */
- len = bits >> 3;
- in -= len;
- bits -= len << 3;
- hold &= (1U << bits) - 1;
-
- /* update state and return */
- strm->next_in = in + OFF;
- strm->next_out = out + OFF;
- strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last));
- strm->avail_out = (unsigned)(out < end ?
- 257 + (end - out) : 257 - (out - end));
- state->hold = hold;
- state->bits = bits;
- return;
-}
-
-/*
- inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe):
- - Using bit fields for code structure
- - Different op definition to avoid & for extra bits (do & for table bits)
- - Three separate decoding do-loops for direct, window, and write == 0
- - Special case for distance > 1 copies to do overlapped load and store copy
- - Explicit branch predictions (based on measured branch probabilities)
- - Deferring match copy and interspersed it with decoding subsequent codes
- - Swapping literal/length else
- - Swapping window/direct else
- - Larger unrolled copy loops (three is about right)
- - Moving len -= 3 statement into middle of loop
- */
-
-#endif /* !ASMINF */
diff --git a/WebCore/platform/image-decoders/zlib/inffast.h b/WebCore/platform/image-decoders/zlib/inffast.h
deleted file mode 100644
index 1e88d2d..0000000
--- a/WebCore/platform/image-decoders/zlib/inffast.h
+++ /dev/null
@@ -1,11 +0,0 @@
-/* inffast.h -- header to use inffast.c
- * Copyright (C) 1995-2003 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-void inflate_fast OF((z_streamp strm, unsigned start));
diff --git a/WebCore/platform/image-decoders/zlib/inffixed.h b/WebCore/platform/image-decoders/zlib/inffixed.h
deleted file mode 100644
index 75ed4b5..0000000
--- a/WebCore/platform/image-decoders/zlib/inffixed.h
+++ /dev/null
@@ -1,94 +0,0 @@
- /* inffixed.h -- table for decoding fixed codes
- * Generated automatically by makefixed().
- */
-
- /* WARNING: this file should *not* be used by applications. It
- is part of the implementation of the compression library and
- is subject to change. Applications should only use zlib.h.
- */
-
- static const code lenfix[512] = {
- {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48},
- {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128},
- {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59},
- {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176},
- {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20},
- {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100},
- {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8},
- {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216},
- {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76},
- {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114},
- {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2},
- {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148},
- {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42},
- {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86},
- {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15},
- {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236},
- {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62},
- {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142},
- {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31},
- {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162},
- {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25},
- {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105},
- {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4},
- {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202},
- {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69},
- {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125},
- {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13},
- {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195},
- {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35},
- {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91},
- {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19},
- {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246},
- {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55},
- {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135},
- {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99},
- {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190},
- {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16},
- {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96},
- {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6},
- {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209},
- {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72},
- {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116},
- {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4},
- {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153},
- {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44},
- {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82},
- {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11},
- {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229},
- {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58},
- {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138},
- {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51},
- {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173},
- {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30},
- {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110},
- {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0},
- {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195},
- {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65},
- {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121},
- {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9},
- {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258},
- {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37},
- {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93},
- {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23},
- {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251},
- {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51},
- {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131},
- {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67},
- {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183},
- {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23},
- {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103},
- {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9},
- {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223},
- {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79},
- {0,9,255}
- };
-
- static const code distfix[32] = {
- {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025},
- {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193},
- {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385},
- {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577},
- {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073},
- {22,5,193},{64,5,0}
- };
diff --git a/WebCore/platform/image-decoders/zlib/inflate.c b/WebCore/platform/image-decoders/zlib/inflate.c
deleted file mode 100644
index 792fdee..0000000
--- a/WebCore/platform/image-decoders/zlib/inflate.c
+++ /dev/null
@@ -1,1368 +0,0 @@
-/* inflate.c -- zlib decompression
- * Copyright (C) 1995-2005 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/*
- * Change history:
- *
- * 1.2.beta0 24 Nov 2002
- * - First version -- complete rewrite of inflate to simplify code, avoid
- * creation of window when not needed, minimize use of window when it is
- * needed, make inffast.c even faster, implement gzip decoding, and to
- * improve code readability and style over the previous zlib inflate code
- *
- * 1.2.beta1 25 Nov 2002
- * - Use pointers for available input and output checking in inffast.c
- * - Remove input and output counters in inffast.c
- * - Change inffast.c entry and loop from avail_in >= 7 to >= 6
- * - Remove unnecessary second byte pull from length extra in inffast.c
- * - Unroll direct copy to three copies per loop in inffast.c
- *
- * 1.2.beta2 4 Dec 2002
- * - Change external routine names to reduce potential conflicts
- * - Correct filename to inffixed.h for fixed tables in inflate.c
- * - Make hbuf[] unsigned char to match parameter type in inflate.c
- * - Change strm->next_out[-state->offset] to *(strm->next_out - state->offset)
- * to avoid negation problem on Alphas (64 bit) in inflate.c
- *
- * 1.2.beta3 22 Dec 2002
- * - Add comments on state->bits assertion in inffast.c
- * - Add comments on op field in inftrees.h
- * - Fix bug in reuse of allocated window after inflateReset()
- * - Remove bit fields--back to byte structure for speed
- * - Remove distance extra == 0 check in inflate_fast()--only helps for lengths
- * - Change post-increments to pre-increments in inflate_fast(), PPC biased?
- * - Add compile time option, POSTINC, to use post-increments instead (Intel?)
- * - Make MATCH copy in inflate() much faster for when inflate_fast() not used
- * - Use local copies of stream next and avail values, as well as local bit
- * buffer and bit count in inflate()--for speed when inflate_fast() not used
- *
- * 1.2.beta4 1 Jan 2003
- * - Split ptr - 257 statements in inflate_table() to avoid compiler warnings
- * - Move a comment on output buffer sizes from inffast.c to inflate.c
- * - Add comments in inffast.c to introduce the inflate_fast() routine
- * - Rearrange window copies in inflate_fast() for speed and simplification
- * - Unroll last copy for window match in inflate_fast()
- * - Use local copies of window variables in inflate_fast() for speed
- * - Pull out common write == 0 case for speed in inflate_fast()
- * - Make op and len in inflate_fast() unsigned for consistency
- * - Add FAR to lcode and dcode declarations in inflate_fast()
- * - Simplified bad distance check in inflate_fast()
- * - Added inflateBackInit(), inflateBack(), and inflateBackEnd() in new
- * source file infback.c to provide a call-back interface to inflate for
- * programs like gzip and unzip -- uses window as output buffer to avoid
- * window copying
- *
- * 1.2.beta5 1 Jan 2003
- * - Improved inflateBack() interface to allow the caller to provide initial
- * input in strm.
- * - Fixed stored blocks bug in inflateBack()
- *
- * 1.2.beta6 4 Jan 2003
- * - Added comments in inffast.c on effectiveness of POSTINC
- * - Typecasting all around to reduce compiler warnings
- * - Changed loops from while (1) or do {} while (1) to for (;;), again to
- * make compilers happy
- * - Changed type of window in inflateBackInit() to unsigned char *
- *
- * 1.2.beta7 27 Jan 2003
- * - Changed many types to unsigned or unsigned short to avoid warnings
- * - Added inflateCopy() function
- *
- * 1.2.0 9 Mar 2003
- * - Changed inflateBack() interface to provide separate opaque descriptors
- * for the in() and out() functions
- * - Changed inflateBack() argument and in_func typedef to swap the length
- * and buffer address return values for the input function
- * - Check next_in and next_out for Z_NULL on entry to inflate()
- *
- * The history for versions after 1.2.0 are in ChangeLog in zlib distribution.
- */
-
-#include "zutil.h"
-#include "inftrees.h"
-#include "inflate.h"
-#include "inffast.h"
-
-#ifdef MAKEFIXED
-# ifndef BUILDFIXED
-# define BUILDFIXED
-# endif
-#endif
-
-/* function prototypes */
-local void fixedtables OF((struct inflate_state FAR *state));
-local int updatewindow OF((z_streamp strm, unsigned out));
-#ifdef BUILDFIXED
- void makefixed OF((void));
-#endif
-local unsigned syncsearch OF((unsigned FAR *have, unsigned char FAR *buf,
- unsigned len));
-
-int ZEXPORT inflateReset(strm)
-z_streamp strm;
-{
- struct inflate_state FAR *state;
-
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
- strm->total_in = strm->total_out = state->total = 0;
- strm->msg = Z_NULL;
- strm->adler = 1; /* to support ill-conceived Java test suite */
- state->mode = HEAD;
- state->last = 0;
- state->havedict = 0;
- state->dmax = 32768U;
- state->head = Z_NULL;
- state->wsize = 0;
- state->whave = 0;
- state->write = 0;
- state->hold = 0;
- state->bits = 0;
- state->lencode = state->distcode = state->next = state->codes;
- Tracev((stderr, "inflate: reset\n"));
- return Z_OK;
-}
-
-int ZEXPORT inflatePrime(strm, bits, value)
-z_streamp strm;
-int bits;
-int value;
-{
- struct inflate_state FAR *state;
-
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
- if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR;
- value &= (1L << bits) - 1;
- state->hold += value << state->bits;
- state->bits += bits;
- return Z_OK;
-}
-
-int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size)
-z_streamp strm;
-int windowBits;
-const char *version;
-int stream_size;
-{
- struct inflate_state FAR *state;
-
- if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
- stream_size != (int)(sizeof(z_stream)))
- return Z_VERSION_ERROR;
- if (strm == Z_NULL) return Z_STREAM_ERROR;
- strm->msg = Z_NULL; /* in case we return an error */
- if (strm->zalloc == (alloc_func)0) {
- strm->zalloc = zcalloc;
- strm->opaque = (voidpf)0;
- }
- if (strm->zfree == (free_func)0) strm->zfree = zcfree;
- state = (struct inflate_state FAR *)
- ZALLOC(strm, 1, sizeof(struct inflate_state));
- if (state == Z_NULL) return Z_MEM_ERROR;
- Tracev((stderr, "inflate: allocated\n"));
- strm->state = (struct internal_state FAR *)state;
- if (windowBits < 0) {
- state->wrap = 0;
- windowBits = -windowBits;
- }
- else {
- state->wrap = (windowBits >> 4) + 1;
-#ifdef GUNZIP
- if (windowBits < 48) windowBits &= 15;
-#endif
- }
- if (windowBits < 8 || windowBits > 15) {
- ZFREE(strm, state);
- strm->state = Z_NULL;
- return Z_STREAM_ERROR;
- }
- state->wbits = (unsigned)windowBits;
- state->window = Z_NULL;
- return inflateReset(strm);
-}
-
-int ZEXPORT inflateInit_(strm, version, stream_size)
-z_streamp strm;
-const char *version;
-int stream_size;
-{
- return inflateInit2_(strm, DEF_WBITS, version, stream_size);
-}
-
-/*
- Return state with length and distance decoding tables and index sizes set to
- fixed code decoding. Normally this returns fixed tables from inffixed.h.
- If BUILDFIXED is defined, then instead this routine builds the tables the
- first time it's called, and returns those tables the first time and
- thereafter. This reduces the size of the code by about 2K bytes, in
- exchange for a little execution time. However, BUILDFIXED should not be
- used for threaded applications, since the rewriting of the tables and virgin
- may not be thread-safe.
- */
-local void fixedtables(state)
-struct inflate_state FAR *state;
-{
-#ifdef BUILDFIXED
- static int virgin = 1;
- static code *lenfix, *distfix;
- static code fixed[544];
-
- /* build fixed huffman tables if first call (may not be thread safe) */
- if (virgin) {
- unsigned sym, bits;
- static code *next;
-
- /* literal/length table */
- sym = 0;
- while (sym < 144) state->lens[sym++] = 8;
- while (sym < 256) state->lens[sym++] = 9;
- while (sym < 280) state->lens[sym++] = 7;
- while (sym < 288) state->lens[sym++] = 8;
- next = fixed;
- lenfix = next;
- bits = 9;
- inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
-
- /* distance table */
- sym = 0;
- while (sym < 32) state->lens[sym++] = 5;
- distfix = next;
- bits = 5;
- inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
-
- /* do this just once */
- virgin = 0;
- }
-#else /* !BUILDFIXED */
-# include "inffixed.h"
-#endif /* BUILDFIXED */
- state->lencode = lenfix;
- state->lenbits = 9;
- state->distcode = distfix;
- state->distbits = 5;
-}
-
-#ifdef MAKEFIXED
-#include <stdio.h>
-
-/*
- Write out the inffixed.h that is #include'd above. Defining MAKEFIXED also
- defines BUILDFIXED, so the tables are built on the fly. makefixed() writes
- those tables to stdout, which would be piped to inffixed.h. A small program
- can simply call makefixed to do this:
-
- void makefixed(void);
-
- int main(void)
- {
- makefixed();
- return 0;
- }
-
- Then that can be linked with zlib built with MAKEFIXED defined and run:
-
- a.out > inffixed.h
- */
-void makefixed()
-{
- unsigned low, size;
- struct inflate_state state;
-
- fixedtables(&state);
- puts(" /* inffixed.h -- table for decoding fixed codes");
- puts(" * Generated automatically by makefixed().");
- puts(" */");
- puts("");
- puts(" /* WARNING: this file should *not* be used by applications.");
- puts(" It is part of the implementation of this library and is");
- puts(" subject to change. Applications should only use zlib.h.");
- puts(" */");
- puts("");
- size = 1U << 9;
- printf(" static const code lenfix[%u] = {", size);
- low = 0;
- for (;;) {
- if ((low % 7) == 0) printf("\n ");
- printf("{%u,%u,%d}", state.lencode[low].op, state.lencode[low].bits,
- state.lencode[low].val);
- if (++low == size) break;
- putchar(',');
- }
- puts("\n };");
- size = 1U << 5;
- printf("\n static const code distfix[%u] = {", size);
- low = 0;
- for (;;) {
- if ((low % 6) == 0) printf("\n ");
- printf("{%u,%u,%d}", state.distcode[low].op, state.distcode[low].bits,
- state.distcode[low].val);
- if (++low == size) break;
- putchar(',');
- }
- puts("\n };");
-}
-#endif /* MAKEFIXED */
-
-/*
- Update the window with the last wsize (normally 32K) bytes written before
- returning. If window does not exist yet, create it. This is only called
- when a window is already in use, or when output has been written during this
- inflate call, but the end of the deflate stream has not been reached yet.
- It is also called to create a window for dictionary data when a dictionary
- is loaded.
-
- Providing output buffers larger than 32K to inflate() should provide a speed
- advantage, since only the last 32K of output is copied to the sliding window
- upon return from inflate(), and since all distances after the first 32K of
- output will fall in the output data, making match copies simpler and faster.
- The advantage may be dependent on the size of the processor's data caches.
- */
-local int updatewindow(strm, out)
-z_streamp strm;
-unsigned out;
-{
- struct inflate_state FAR *state;
- unsigned copy, dist;
-
- state = (struct inflate_state FAR *)strm->state;
-
- /* if it hasn't been done already, allocate space for the window */
- if (state->window == Z_NULL) {
- state->window = (unsigned char FAR *)
- ZALLOC(strm, 1U << state->wbits,
- sizeof(unsigned char));
- if (state->window == Z_NULL) return 1;
- }
-
- /* if window not in use yet, initialize */
- if (state->wsize == 0) {
- state->wsize = 1U << state->wbits;
- state->write = 0;
- state->whave = 0;
- }
-
- /* copy state->wsize or less output bytes into the circular window */
- copy = out - strm->avail_out;
- if (copy >= state->wsize) {
- zmemcpy(state->window, strm->next_out - state->wsize, state->wsize);
- state->write = 0;
- state->whave = state->wsize;
- }
- else {
- dist = state->wsize - state->write;
- if (dist > copy) dist = copy;
- zmemcpy(state->window + state->write, strm->next_out - copy, dist);
- copy -= dist;
- if (copy) {
- zmemcpy(state->window, strm->next_out - copy, copy);
- state->write = copy;
- state->whave = state->wsize;
- }
- else {
- state->write += dist;
- if (state->write == state->wsize) state->write = 0;
- if (state->whave < state->wsize) state->whave += dist;
- }
- }
- return 0;
-}
-
-/* Macros for inflate(): */
-
-/* check function to use adler32() for zlib or crc32() for gzip */
-#ifdef GUNZIP
-# define UPDATE(check, buf, len) \
- (state->flags ? crc32(check, buf, len) : adler32(check, buf, len))
-#else
-# define UPDATE(check, buf, len) adler32(check, buf, len)
-#endif
-
-/* check macros for header crc */
-#ifdef GUNZIP
-# define CRC2(check, word) \
- do { \
- hbuf[0] = (unsigned char)(word); \
- hbuf[1] = (unsigned char)((word) >> 8); \
- check = crc32(check, hbuf, 2); \
- } while (0)
-
-# define CRC4(check, word) \
- do { \
- hbuf[0] = (unsigned char)(word); \
- hbuf[1] = (unsigned char)((word) >> 8); \
- hbuf[2] = (unsigned char)((word) >> 16); \
- hbuf[3] = (unsigned char)((word) >> 24); \
- check = crc32(check, hbuf, 4); \
- } while (0)
-#endif
-
-/* Load registers with state in inflate() for speed */
-#define LOAD() \
- do { \
- put = strm->next_out; \
- left = strm->avail_out; \
- next = strm->next_in; \
- have = strm->avail_in; \
- hold = state->hold; \
- bits = state->bits; \
- } while (0)
-
-/* Restore state from registers in inflate() */
-#define RESTORE() \
- do { \
- strm->next_out = put; \
- strm->avail_out = left; \
- strm->next_in = next; \
- strm->avail_in = have; \
- state->hold = hold; \
- state->bits = bits; \
- } while (0)
-
-/* Clear the input bit accumulator */
-#define INITBITS() \
- do { \
- hold = 0; \
- bits = 0; \
- } while (0)
-
-/* Get a byte of input into the bit accumulator, or return from inflate()
- if there is no input available. */
-#define PULLBYTE() \
- do { \
- if (have == 0) goto inf_leave; \
- have--; \
- hold += (unsigned long)(*next++) << bits; \
- bits += 8; \
- } while (0)
-
-/* Assure that there are at least n bits in the bit accumulator. If there is
- not enough available input to do that, then return from inflate(). */
-#define NEEDBITS(n) \
- do { \
- while (bits < (unsigned)(n)) \
- PULLBYTE(); \
- } while (0)
-
-/* Return the low n bits of the bit accumulator (n < 16) */
-#define BITS(n) \
- ((unsigned)hold & ((1U << (n)) - 1))
-
-/* Remove n bits from the bit accumulator */
-#define DROPBITS(n) \
- do { \
- hold >>= (n); \
- bits -= (unsigned)(n); \
- } while (0)
-
-/* Remove zero to seven bits as needed to go to a byte boundary */
-#define BYTEBITS() \
- do { \
- hold >>= bits & 7; \
- bits -= bits & 7; \
- } while (0)
-
-/* Reverse the bytes in a 32-bit value */
-#define REVERSE(q) \
- ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
- (((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
-
-/*
- inflate() uses a state machine to process as much input data and generate as
- much output data as possible before returning. The state machine is
- structured roughly as follows:
-
- for (;;) switch (state) {
- ...
- case STATEn:
- if (not enough input data or output space to make progress)
- return;
- ... make progress ...
- state = STATEm;
- break;
- ...
- }
-
- so when inflate() is called again, the same case is attempted again, and
- if the appropriate resources are provided, the machine proceeds to the
- next state. The NEEDBITS() macro is usually the way the state evaluates
- whether it can proceed or should return. NEEDBITS() does the return if
- the requested bits are not available. The typical use of the BITS macros
- is:
-
- NEEDBITS(n);
- ... do something with BITS(n) ...
- DROPBITS(n);
-
- where NEEDBITS(n) either returns from inflate() if there isn't enough
- input left to load n bits into the accumulator, or it continues. BITS(n)
- gives the low n bits in the accumulator. When done, DROPBITS(n) drops
- the low n bits off the accumulator. INITBITS() clears the accumulator
- and sets the number of available bits to zero. BYTEBITS() discards just
- enough bits to put the accumulator on a byte boundary. After BYTEBITS()
- and a NEEDBITS(8), then BITS(8) would return the next byte in the stream.
-
- NEEDBITS(n) uses PULLBYTE() to get an available byte of input, or to return
- if there is no input available. The decoding of variable length codes uses
- PULLBYTE() directly in order to pull just enough bytes to decode the next
- code, and no more.
-
- Some states loop until they get enough input, making sure that enough
- state information is maintained to continue the loop where it left off
- if NEEDBITS() returns in the loop. For example, want, need, and keep
- would all have to actually be part of the saved state in case NEEDBITS()
- returns:
-
- case STATEw:
- while (want < need) {
- NEEDBITS(n);
- keep[want++] = BITS(n);
- DROPBITS(n);
- }
- state = STATEx;
- case STATEx:
-
- As shown above, if the next state is also the next case, then the break
- is omitted.
-
- A state may also return if there is not enough output space available to
- complete that state. Those states are copying stored data, writing a
- literal byte, and copying a matching string.
-
- When returning, a "goto inf_leave" is used to update the total counters,
- update the check value, and determine whether any progress has been made
- during that inflate() call in order to return the proper return code.
- Progress is defined as a change in either strm->avail_in or strm->avail_out.
- When there is a window, goto inf_leave will update the window with the last
- output written. If a goto inf_leave occurs in the middle of decompression
- and there is no window currently, goto inf_leave will create one and copy
- output to the window for the next call of inflate().
-
- In this implementation, the flush parameter of inflate() only affects the
- return code (per zlib.h). inflate() always writes as much as possible to
- strm->next_out, given the space available and the provided input--the effect
- documented in zlib.h of Z_SYNC_FLUSH. Furthermore, inflate() always defers
- the allocation of and copying into a sliding window until necessary, which
- provides the effect documented in zlib.h for Z_FINISH when the entire input
- stream available. So the only thing the flush parameter actually does is:
- when flush is set to Z_FINISH, inflate() cannot return Z_OK. Instead it
- will return Z_BUF_ERROR if it has not reached the end of the stream.
- */
-
-int ZEXPORT inflate(strm, flush)
-z_streamp strm;
-int flush;
-{
- struct inflate_state FAR *state;
- unsigned char FAR *next; /* next input */
- unsigned char FAR *put; /* next output */
- unsigned have, left; /* available input and output */
- unsigned long hold; /* bit buffer */
- unsigned bits; /* bits in bit buffer */
- unsigned in, out; /* save starting available input and output */
- unsigned copy; /* number of stored or match bytes to copy */
- unsigned char FAR *from; /* where to copy match bytes from */
- code this; /* current decoding table entry */
- code last; /* parent table entry */
- unsigned len; /* length to copy for repeats, bits to drop */
- int ret; /* return code */
-#ifdef GUNZIP
- unsigned char hbuf[4]; /* buffer for gzip header crc calculation */
-#endif
- static const unsigned short order[19] = /* permutation of code lengths */
- {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
-
- if (strm == Z_NULL || strm->state == Z_NULL || strm->next_out == Z_NULL ||
- (strm->next_in == Z_NULL && strm->avail_in != 0))
- return Z_STREAM_ERROR;
-
- state = (struct inflate_state FAR *)strm->state;
- if (state->mode == TYPE) state->mode = TYPEDO; /* skip check */
- LOAD();
- in = have;
- out = left;
- ret = Z_OK;
- for (;;)
- switch (state->mode) {
- case HEAD:
- if (state->wrap == 0) {
- state->mode = TYPEDO;
- break;
- }
- NEEDBITS(16);
-#ifdef GUNZIP
- if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */
- state->check = crc32(0L, Z_NULL, 0);
- CRC2(state->check, hold);
- INITBITS();
- state->mode = FLAGS;
- break;
- }
- state->flags = 0; /* expect zlib header */
- if (state->head != Z_NULL)
- state->head->done = -1;
- if (!(state->wrap & 1) || /* check if zlib header allowed */
-#else
- if (
-#endif
- ((BITS(8) << 8) + (hold >> 8)) % 31) {
- strm->msg = (char *)"incorrect header check";
- state->mode = BAD;
- break;
- }
- if (BITS(4) != Z_DEFLATED) {
- strm->msg = (char *)"unknown compression method";
- state->mode = BAD;
- break;
- }
- DROPBITS(4);
- len = BITS(4) + 8;
- if (len > state->wbits) {
- strm->msg = (char *)"invalid window size";
- state->mode = BAD;
- break;
- }
- state->dmax = 1U << len;
- Tracev((stderr, "inflate: zlib header ok\n"));
- strm->adler = state->check = adler32(0L, Z_NULL, 0);
- state->mode = hold & 0x200 ? DICTID : TYPE;
- INITBITS();
- break;
-#ifdef GUNZIP
- case FLAGS:
- NEEDBITS(16);
- state->flags = (int)(hold);
- if ((state->flags & 0xff) != Z_DEFLATED) {
- strm->msg = (char *)"unknown compression method";
- state->mode = BAD;
- break;
- }
- if (state->flags & 0xe000) {
- strm->msg = (char *)"unknown header flags set";
- state->mode = BAD;
- break;
- }
- if (state->head != Z_NULL)
- state->head->text = (int)((hold >> 8) & 1);
- if (state->flags & 0x0200) CRC2(state->check, hold);
- INITBITS();
- state->mode = TIME;
- case TIME:
- NEEDBITS(32);
- if (state->head != Z_NULL)
- state->head->time = hold;
- if (state->flags & 0x0200) CRC4(state->check, hold);
- INITBITS();
- state->mode = OS;
- case OS:
- NEEDBITS(16);
- if (state->head != Z_NULL) {
- state->head->xflags = (int)(hold & 0xff);
- state->head->os = (int)(hold >> 8);
- }
- if (state->flags & 0x0200) CRC2(state->check, hold);
- INITBITS();
- state->mode = EXLEN;
- case EXLEN:
- if (state->flags & 0x0400) {
- NEEDBITS(16);
- state->length = (unsigned)(hold);
- if (state->head != Z_NULL)
- state->head->extra_len = (unsigned)hold;
- if (state->flags & 0x0200) CRC2(state->check, hold);
- INITBITS();
- }
- else if (state->head != Z_NULL)
- state->head->extra = Z_NULL;
- state->mode = EXTRA;
- case EXTRA:
- if (state->flags & 0x0400) {
- copy = state->length;
- if (copy > have) copy = have;
- if (copy) {
- if (state->head != Z_NULL &&
- state->head->extra != Z_NULL) {
- len = state->head->extra_len - state->length;
- zmemcpy(state->head->extra + len, next,
- len + copy > state->head->extra_max ?
- state->head->extra_max - len : copy);
- }
- if (state->flags & 0x0200)
- state->check = crc32(state->check, next, copy);
- have -= copy;
- next += copy;
- state->length -= copy;
- }
- if (state->length) goto inf_leave;
- }
- state->length = 0;
- state->mode = NAME;
- case NAME:
- if (state->flags & 0x0800) {
- if (have == 0) goto inf_leave;
- copy = 0;
- do {
- len = (unsigned)(next[copy++]);
- if (state->head != Z_NULL &&
- state->head->name != Z_NULL &&
- state->length < state->head->name_max)
- state->head->name[state->length++] = len;
- } while (len && copy < have);
- if (state->flags & 0x0200)
- state->check = crc32(state->check, next, copy);
- have -= copy;
- next += copy;
- if (len) goto inf_leave;
- }
- else if (state->head != Z_NULL)
- state->head->name = Z_NULL;
- state->length = 0;
- state->mode = COMMENT;
- case COMMENT:
- if (state->flags & 0x1000) {
- if (have == 0) goto inf_leave;
- copy = 0;
- do {
- len = (unsigned)(next[copy++]);
- if (state->head != Z_NULL &&
- state->head->comment != Z_NULL &&
- state->length < state->head->comm_max)
- state->head->comment[state->length++] = len;
- } while (len && copy < have);
- if (state->flags & 0x0200)
- state->check = crc32(state->check, next, copy);
- have -= copy;
- next += copy;
- if (len) goto inf_leave;
- }
- else if (state->head != Z_NULL)
- state->head->comment = Z_NULL;
- state->mode = HCRC;
- case HCRC:
- if (state->flags & 0x0200) {
- NEEDBITS(16);
- if (hold != (state->check & 0xffff)) {
- strm->msg = (char *)"header crc mismatch";
- state->mode = BAD;
- break;
- }
- INITBITS();
- }
- if (state->head != Z_NULL) {
- state->head->hcrc = (int)((state->flags >> 9) & 1);
- state->head->done = 1;
- }
- strm->adler = state->check = crc32(0L, Z_NULL, 0);
- state->mode = TYPE;
- break;
-#endif
- case DICTID:
- NEEDBITS(32);
- strm->adler = state->check = REVERSE(hold);
- INITBITS();
- state->mode = DICT;
- case DICT:
- if (state->havedict == 0) {
- RESTORE();
- return Z_NEED_DICT;
- }
- strm->adler = state->check = adler32(0L, Z_NULL, 0);
- state->mode = TYPE;
- case TYPE:
- if (flush == Z_BLOCK) goto inf_leave;
- case TYPEDO:
- if (state->last) {
- BYTEBITS();
- state->mode = CHECK;
- break;
- }
- NEEDBITS(3);
- state->last = BITS(1);
- DROPBITS(1);
- switch (BITS(2)) {
- case 0: /* stored block */
- Tracev((stderr, "inflate: stored block%s\n",
- state->last ? " (last)" : ""));
- state->mode = STORED;
- break;
- case 1: /* fixed block */
- fixedtables(state);
- Tracev((stderr, "inflate: fixed codes block%s\n",
- state->last ? " (last)" : ""));
- state->mode = LEN; /* decode codes */
- break;
- case 2: /* dynamic block */
- Tracev((stderr, "inflate: dynamic codes block%s\n",
- state->last ? " (last)" : ""));
- state->mode = TABLE;
- break;
- case 3:
- strm->msg = (char *)"invalid block type";
- state->mode = BAD;
- }
- DROPBITS(2);
- break;
- case STORED:
- BYTEBITS(); /* go to byte boundary */
- NEEDBITS(32);
- if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
- strm->msg = (char *)"invalid stored block lengths";
- state->mode = BAD;
- break;
- }
- state->length = (unsigned)hold & 0xffff;
- Tracev((stderr, "inflate: stored length %u\n",
- state->length));
- INITBITS();
- state->mode = COPY;
- case COPY:
- copy = state->length;
- if (copy) {
- if (copy > have) copy = have;
- if (copy > left) copy = left;
- if (copy == 0) goto inf_leave;
- zmemcpy(put, next, copy);
- have -= copy;
- next += copy;
- left -= copy;
- put += copy;
- state->length -= copy;
- break;
- }
- Tracev((stderr, "inflate: stored end\n"));
- state->mode = TYPE;
- break;
- case TABLE:
- NEEDBITS(14);
- state->nlen = BITS(5) + 257;
- DROPBITS(5);
- state->ndist = BITS(5) + 1;
- DROPBITS(5);
- state->ncode = BITS(4) + 4;
- DROPBITS(4);
-#ifndef PKZIP_BUG_WORKAROUND
- if (state->nlen > 286 || state->ndist > 30) {
- strm->msg = (char *)"too many length or distance symbols";
- state->mode = BAD;
- break;
- }
-#endif
- Tracev((stderr, "inflate: table sizes ok\n"));
- state->have = 0;
- state->mode = LENLENS;
- case LENLENS:
- while (state->have < state->ncode) {
- NEEDBITS(3);
- state->lens[order[state->have++]] = (unsigned short)BITS(3);
- DROPBITS(3);
- }
- while (state->have < 19)
- state->lens[order[state->have++]] = 0;
- state->next = state->codes;
- state->lencode = (code const FAR *)(state->next);
- state->lenbits = 7;
- ret = inflate_table(CODES, state->lens, 19, &(state->next),
- &(state->lenbits), state->work);
- if (ret) {
- strm->msg = (char *)"invalid code lengths set";
- state->mode = BAD;
- break;
- }
- Tracev((stderr, "inflate: code lengths ok\n"));
- state->have = 0;
- state->mode = CODELENS;
- case CODELENS:
- while (state->have < state->nlen + state->ndist) {
- for (;;) {
- this = state->lencode[BITS(state->lenbits)];
- if ((unsigned)(this.bits) <= bits) break;
- PULLBYTE();
- }
- if (this.val < 16) {
- NEEDBITS(this.bits);
- DROPBITS(this.bits);
- state->lens[state->have++] = this.val;
- }
- else {
- if (this.val == 16) {
- NEEDBITS(this.bits + 2);
- DROPBITS(this.bits);
- if (state->have == 0) {
- strm->msg = (char *)"invalid bit length repeat";
- state->mode = BAD;
- break;
- }
- len = state->lens[state->have - 1];
- copy = 3 + BITS(2);
- DROPBITS(2);
- }
- else if (this.val == 17) {
- NEEDBITS(this.bits + 3);
- DROPBITS(this.bits);
- len = 0;
- copy = 3 + BITS(3);
- DROPBITS(3);
- }
- else {
- NEEDBITS(this.bits + 7);
- DROPBITS(this.bits);
- len = 0;
- copy = 11 + BITS(7);
- DROPBITS(7);
- }
- if (state->have + copy > state->nlen + state->ndist) {
- strm->msg = (char *)"invalid bit length repeat";
- state->mode = BAD;
- break;
- }
- while (copy--)
- state->lens[state->have++] = (unsigned short)len;
- }
- }
-
- /* handle error breaks in while */
- if (state->mode == BAD) break;
-
- /* build code tables */
- state->next = state->codes;
- state->lencode = (code const FAR *)(state->next);
- state->lenbits = 9;
- ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
- &(state->lenbits), state->work);
- if (ret) {
- strm->msg = (char *)"invalid literal/lengths set";
- state->mode = BAD;
- break;
- }
- state->distcode = (code const FAR *)(state->next);
- state->distbits = 6;
- ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
- &(state->next), &(state->distbits), state->work);
- if (ret) {
- strm->msg = (char *)"invalid distances set";
- state->mode = BAD;
- break;
- }
- Tracev((stderr, "inflate: codes ok\n"));
- state->mode = LEN;
- case LEN:
- if (have >= 6 && left >= 258) {
- RESTORE();
- inflate_fast(strm, out);
- LOAD();
- break;
- }
- for (;;) {
- this = state->lencode[BITS(state->lenbits)];
- if ((unsigned)(this.bits) <= bits) break;
- PULLBYTE();
- }
- if (this.op && (this.op & 0xf0) == 0) {
- last = this;
- for (;;) {
- this = state->lencode[last.val +
- (BITS(last.bits + last.op) >> last.bits)];
- if ((unsigned)(last.bits + this.bits) <= bits) break;
- PULLBYTE();
- }
- DROPBITS(last.bits);
- }
- DROPBITS(this.bits);
- state->length = (unsigned)this.val;
- if ((int)(this.op) == 0) {
- Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
- "inflate: literal '%c'\n" :
- "inflate: literal 0x%02x\n", this.val));
- state->mode = LIT;
- break;
- }
- if (this.op & 32) {
- Tracevv((stderr, "inflate: end of block\n"));
- state->mode = TYPE;
- break;
- }
- if (this.op & 64) {
- strm->msg = (char *)"invalid literal/length code";
- state->mode = BAD;
- break;
- }
- state->extra = (unsigned)(this.op) & 15;
- state->mode = LENEXT;
- case LENEXT:
- if (state->extra) {
- NEEDBITS(state->extra);
- state->length += BITS(state->extra);
- DROPBITS(state->extra);
- }
- Tracevv((stderr, "inflate: length %u\n", state->length));
- state->mode = DIST;
- case DIST:
- for (;;) {
- this = state->distcode[BITS(state->distbits)];
- if ((unsigned)(this.bits) <= bits) break;
- PULLBYTE();
- }
- if ((this.op & 0xf0) == 0) {
- last = this;
- for (;;) {
- this = state->distcode[last.val +
- (BITS(last.bits + last.op) >> last.bits)];
- if ((unsigned)(last.bits + this.bits) <= bits) break;
- PULLBYTE();
- }
- DROPBITS(last.bits);
- }
- DROPBITS(this.bits);
- if (this.op & 64) {
- strm->msg = (char *)"invalid distance code";
- state->mode = BAD;
- break;
- }
- state->offset = (unsigned)this.val;
- state->extra = (unsigned)(this.op) & 15;
- state->mode = DISTEXT;
- case DISTEXT:
- if (state->extra) {
- NEEDBITS(state->extra);
- state->offset += BITS(state->extra);
- DROPBITS(state->extra);
- }
-#ifdef INFLATE_STRICT
- if (state->offset > state->dmax) {
- strm->msg = (char *)"invalid distance too far back";
- state->mode = BAD;
- break;
- }
-#endif
- if (state->offset > state->whave + out - left) {
- strm->msg = (char *)"invalid distance too far back";
- state->mode = BAD;
- break;
- }
- Tracevv((stderr, "inflate: distance %u\n", state->offset));
- state->mode = MATCH;
- case MATCH:
- if (left == 0) goto inf_leave;
- copy = out - left;
- if (state->offset > copy) { /* copy from window */
- copy = state->offset - copy;
- if (copy > state->write) {
- copy -= state->write;
- from = state->window + (state->wsize - copy);
- }
- else
- from = state->window + (state->write - copy);
- if (copy > state->length) copy = state->length;
- }
- else { /* copy from output */
- from = put - state->offset;
- copy = state->length;
- }
- if (copy > left) copy = left;
- left -= copy;
- state->length -= copy;
- do {
- *put++ = *from++;
- } while (--copy);
- if (state->length == 0) state->mode = LEN;
- break;
- case LIT:
- if (left == 0) goto inf_leave;
- *put++ = (unsigned char)(state->length);
- left--;
- state->mode = LEN;
- break;
- case CHECK:
- if (state->wrap) {
- NEEDBITS(32);
- out -= left;
- strm->total_out += out;
- state->total += out;
- if (out)
- strm->adler = state->check =
- UPDATE(state->check, put - out, out);
- out = left;
- if ((
-#ifdef GUNZIP
- state->flags ? hold :
-#endif
- REVERSE(hold)) != state->check) {
- strm->msg = (char *)"incorrect data check";
- state->mode = BAD;
- break;
- }
- INITBITS();
- Tracev((stderr, "inflate: check matches trailer\n"));
- }
-#ifdef GUNZIP
- state->mode = LENGTH;
- case LENGTH:
- if (state->wrap && state->flags) {
- NEEDBITS(32);
- if (hold != (state->total & 0xffffffffUL)) {
- strm->msg = (char *)"incorrect length check";
- state->mode = BAD;
- break;
- }
- INITBITS();
- Tracev((stderr, "inflate: length matches trailer\n"));
- }
-#endif
- state->mode = DONE;
- case DONE:
- ret = Z_STREAM_END;
- goto inf_leave;
- case BAD:
- ret = Z_DATA_ERROR;
- goto inf_leave;
- case MEM:
- return Z_MEM_ERROR;
- case SYNC:
- default:
- return Z_STREAM_ERROR;
- }
-
- /*
- Return from inflate(), updating the total counts and the check value.
- If there was no progress during the inflate() call, return a buffer
- error. Call updatewindow() to create and/or update the window state.
- Note: a memory error from inflate() is non-recoverable.
- */
- inf_leave:
- RESTORE();
- if (state->wsize || (state->mode < CHECK && out != strm->avail_out))
- if (updatewindow(strm, out)) {
- state->mode = MEM;
- return Z_MEM_ERROR;
- }
- in -= strm->avail_in;
- out -= strm->avail_out;
- strm->total_in += in;
- strm->total_out += out;
- state->total += out;
- if (state->wrap && out)
- strm->adler = state->check =
- UPDATE(state->check, strm->next_out - out, out);
- strm->data_type = state->bits + (state->last ? 64 : 0) +
- (state->mode == TYPE ? 128 : 0);
- if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
- ret = Z_BUF_ERROR;
- return ret;
-}
-
-int ZEXPORT inflateEnd(strm)
-z_streamp strm;
-{
- struct inflate_state FAR *state;
- if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
- return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
- if (state->window != Z_NULL) ZFREE(strm, state->window);
- ZFREE(strm, strm->state);
- strm->state = Z_NULL;
- Tracev((stderr, "inflate: end\n"));
- return Z_OK;
-}
-
-int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength)
-z_streamp strm;
-const Bytef *dictionary;
-uInt dictLength;
-{
- struct inflate_state FAR *state;
- unsigned long id;
-
- /* check state */
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
- if (state->wrap != 0 && state->mode != DICT)
- return Z_STREAM_ERROR;
-
- /* check for correct dictionary id */
- if (state->mode == DICT) {
- id = adler32(0L, Z_NULL, 0);
- id = adler32(id, dictionary, dictLength);
- if (id != state->check)
- return Z_DATA_ERROR;
- }
-
- /* copy dictionary to window */
- if (updatewindow(strm, strm->avail_out)) {
- state->mode = MEM;
- return Z_MEM_ERROR;
- }
- if (dictLength > state->wsize) {
- zmemcpy(state->window, dictionary + dictLength - state->wsize,
- state->wsize);
- state->whave = state->wsize;
- }
- else {
- zmemcpy(state->window + state->wsize - dictLength, dictionary,
- dictLength);
- state->whave = dictLength;
- }
- state->havedict = 1;
- Tracev((stderr, "inflate: dictionary set\n"));
- return Z_OK;
-}
-
-int ZEXPORT inflateGetHeader(strm, head)
-z_streamp strm;
-gz_headerp head;
-{
- struct inflate_state FAR *state;
-
- /* check state */
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
- if ((state->wrap & 2) == 0) return Z_STREAM_ERROR;
-
- /* save header structure */
- state->head = head;
- head->done = 0;
- return Z_OK;
-}
-
-/*
- Search buf[0..len-1] for the pattern: 0, 0, 0xff, 0xff. Return when found
- or when out of input. When called, *have is the number of pattern bytes
- found in order so far, in 0..3. On return *have is updated to the new
- state. If on return *have equals four, then the pattern was found and the
- return value is how many bytes were read including the last byte of the
- pattern. If *have is less than four, then the pattern has not been found
- yet and the return value is len. In the latter case, syncsearch() can be
- called again with more data and the *have state. *have is initialized to
- zero for the first call.
- */
-local unsigned syncsearch(have, buf, len)
-unsigned FAR *have;
-unsigned char FAR *buf;
-unsigned len;
-{
- unsigned got;
- unsigned next;
-
- got = *have;
- next = 0;
- while (next < len && got < 4) {
- if ((int)(buf[next]) == (got < 2 ? 0 : 0xff))
- got++;
- else if (buf[next])
- got = 0;
- else
- got = 4 - got;
- next++;
- }
- *have = got;
- return next;
-}
-
-int ZEXPORT inflateSync(strm)
-z_streamp strm;
-{
- unsigned len; /* number of bytes to look at or looked at */
- unsigned long in, out; /* temporary to save total_in and total_out */
- unsigned char buf[4]; /* to restore bit buffer to byte string */
- struct inflate_state FAR *state;
-
- /* check parameters */
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
- if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR;
-
- /* if first time, start search in bit buffer */
- if (state->mode != SYNC) {
- state->mode = SYNC;
- state->hold <<= state->bits & 7;
- state->bits -= state->bits & 7;
- len = 0;
- while (state->bits >= 8) {
- buf[len++] = (unsigned char)(state->hold);
- state->hold >>= 8;
- state->bits -= 8;
- }
- state->have = 0;
- syncsearch(&(state->have), buf, len);
- }
-
- /* search available input */
- len = syncsearch(&(state->have), strm->next_in, strm->avail_in);
- strm->avail_in -= len;
- strm->next_in += len;
- strm->total_in += len;
-
- /* return no joy or set up to restart inflate() on a new block */
- if (state->have != 4) return Z_DATA_ERROR;
- in = strm->total_in; out = strm->total_out;
- inflateReset(strm);
- strm->total_in = in; strm->total_out = out;
- state->mode = TYPE;
- return Z_OK;
-}
-
-/*
- Returns true if inflate is currently at the end of a block generated by
- Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP
- implementation to provide an additional safety check. PPP uses
- Z_SYNC_FLUSH but removes the length bytes of the resulting empty stored
- block. When decompressing, PPP checks that at the end of input packet,
- inflate is waiting for these length bytes.
- */
-int ZEXPORT inflateSyncPoint(strm)
-z_streamp strm;
-{
- struct inflate_state FAR *state;
-
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
- return state->mode == STORED && state->bits == 0;
-}
-
-int ZEXPORT inflateCopy(dest, source)
-z_streamp dest;
-z_streamp source;
-{
- struct inflate_state FAR *state;
- struct inflate_state FAR *copy;
- unsigned char FAR *window;
- unsigned wsize;
-
- /* check input */
- if (dest == Z_NULL || source == Z_NULL || source->state == Z_NULL ||
- source->zalloc == (alloc_func)0 || source->zfree == (free_func)0)
- return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)source->state;
-
- /* allocate space */
- copy = (struct inflate_state FAR *)
- ZALLOC(source, 1, sizeof(struct inflate_state));
- if (copy == Z_NULL) return Z_MEM_ERROR;
- window = Z_NULL;
- if (state->window != Z_NULL) {
- window = (unsigned char FAR *)
- ZALLOC(source, 1U << state->wbits, sizeof(unsigned char));
- if (window == Z_NULL) {
- ZFREE(source, copy);
- return Z_MEM_ERROR;
- }
- }
-
- /* copy state */
- zmemcpy(dest, source, sizeof(z_stream));
- zmemcpy(copy, state, sizeof(struct inflate_state));
- if (state->lencode >= state->codes &&
- state->lencode <= state->codes + ENOUGH - 1) {
- copy->lencode = copy->codes + (state->lencode - state->codes);
- copy->distcode = copy->codes + (state->distcode - state->codes);
- }
- copy->next = copy->codes + (state->next - state->codes);
- if (window != Z_NULL) {
- wsize = 1U << state->wbits;
- zmemcpy(window, state->window, wsize);
- }
- copy->window = window;
- dest->state = (struct internal_state FAR *)copy;
- return Z_OK;
-}
diff --git a/WebCore/platform/image-decoders/zlib/inflate.h b/WebCore/platform/image-decoders/zlib/inflate.h
deleted file mode 100644
index 07bd3e7..0000000
--- a/WebCore/platform/image-decoders/zlib/inflate.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/* inflate.h -- internal inflate state definition
- * Copyright (C) 1995-2004 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-/* define NO_GZIP when compiling if you want to disable gzip header and
- trailer decoding by inflate(). NO_GZIP would be used to avoid linking in
- the crc code when it is not needed. For shared libraries, gzip decoding
- should be left enabled. */
-#ifndef NO_GZIP
-# define GUNZIP
-#endif
-
-/* Possible inflate modes between inflate() calls */
-typedef enum {
- HEAD, /* i: waiting for magic header */
- FLAGS, /* i: waiting for method and flags (gzip) */
- TIME, /* i: waiting for modification time (gzip) */
- OS, /* i: waiting for extra flags and operating system (gzip) */
- EXLEN, /* i: waiting for extra length (gzip) */
- EXTRA, /* i: waiting for extra bytes (gzip) */
- NAME, /* i: waiting for end of file name (gzip) */
- COMMENT, /* i: waiting for end of comment (gzip) */
- HCRC, /* i: waiting for header crc (gzip) */
- DICTID, /* i: waiting for dictionary check value */
- DICT, /* waiting for inflateSetDictionary() call */
- TYPE, /* i: waiting for type bits, including last-flag bit */
- TYPEDO, /* i: same, but skip check to exit inflate on new block */
- STORED, /* i: waiting for stored size (length and complement) */
- COPY, /* i/o: waiting for input or output to copy stored block */
- TABLE, /* i: waiting for dynamic block table lengths */
- LENLENS, /* i: waiting for code length code lengths */
- CODELENS, /* i: waiting for length/lit and distance code lengths */
- LEN, /* i: waiting for length/lit code */
- LENEXT, /* i: waiting for length extra bits */
- DIST, /* i: waiting for distance code */
- DISTEXT, /* i: waiting for distance extra bits */
- MATCH, /* o: waiting for output space to copy string */
- LIT, /* o: waiting for output space to write literal */
- CHECK, /* i: waiting for 32-bit check value */
- LENGTH, /* i: waiting for 32-bit length (gzip) */
- DONE, /* finished check, done -- remain here until reset */
- BAD, /* got a data error -- remain here until reset */
- MEM, /* got an inflate() memory error -- remain here until reset */
- SYNC /* looking for synchronization bytes to restart inflate() */
-} inflate_mode;
-
-/*
- State transitions between above modes -
-
- (most modes can go to the BAD or MEM mode -- not shown for clarity)
-
- Process header:
- HEAD -> (gzip) or (zlib)
- (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME
- NAME -> COMMENT -> HCRC -> TYPE
- (zlib) -> DICTID or TYPE
- DICTID -> DICT -> TYPE
- Read deflate blocks:
- TYPE -> STORED or TABLE or LEN or CHECK
- STORED -> COPY -> TYPE
- TABLE -> LENLENS -> CODELENS -> LEN
- Read deflate codes:
- LEN -> LENEXT or LIT or TYPE
- LENEXT -> DIST -> DISTEXT -> MATCH -> LEN
- LIT -> LEN
- Process trailer:
- CHECK -> LENGTH -> DONE
- */
-
-/* state maintained between inflate() calls. Approximately 7K bytes. */
-struct inflate_state {
- inflate_mode mode; /* current inflate mode */
- int last; /* true if processing last block */
- int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
- int havedict; /* true if dictionary provided */
- int flags; /* gzip header method and flags (0 if zlib) */
- unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */
- unsigned long check; /* protected copy of check value */
- unsigned long total; /* protected copy of output count */
- gz_headerp head; /* where to save gzip header information */
- /* sliding window */
- unsigned wbits; /* log base 2 of requested window size */
- unsigned wsize; /* window size or zero if not using window */
- unsigned whave; /* valid bytes in the window */
- unsigned write; /* window write index */
- unsigned char FAR *window; /* allocated sliding window, if needed */
- /* bit accumulator */
- unsigned long hold; /* input bit accumulator */
- unsigned bits; /* number of bits in "in" */
- /* for string and stored block copying */
- unsigned length; /* literal or length of data to copy */
- unsigned offset; /* distance back to copy string from */
- /* for table and code decoding */
- unsigned extra; /* extra bits needed */
- /* fixed and dynamic code tables */
- code const FAR *lencode; /* starting table for length/literal codes */
- code const FAR *distcode; /* starting table for distance codes */
- unsigned lenbits; /* index bits for lencode */
- unsigned distbits; /* index bits for distcode */
- /* dynamic table building */
- unsigned ncode; /* number of code length code lengths */
- unsigned nlen; /* number of length code lengths */
- unsigned ndist; /* number of distance code lengths */
- unsigned have; /* number of code lengths in lens[] */
- code FAR *next; /* next available space in codes[] */
- unsigned short lens[320]; /* temporary storage for code lengths */
- unsigned short work[288]; /* work area for code table building */
- code codes[ENOUGH]; /* space for code tables */
-};
diff --git a/WebCore/platform/image-decoders/zlib/inftrees.c b/WebCore/platform/image-decoders/zlib/inftrees.c
deleted file mode 100644
index 8a9c13f..0000000
--- a/WebCore/platform/image-decoders/zlib/inftrees.c
+++ /dev/null
@@ -1,329 +0,0 @@
-/* inftrees.c -- generate Huffman trees for efficient decoding
- * Copyright (C) 1995-2005 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-#include "zutil.h"
-#include "inftrees.h"
-
-#define MAXBITS 15
-
-const char inflate_copyright[] =
- " inflate 1.2.3 Copyright 1995-2005 Mark Adler ";
-/*
- If you use the zlib library in a product, an acknowledgment is welcome
- in the documentation of your product. If for some reason you cannot
- include such an acknowledgment, I would appreciate that you keep this
- copyright string in the executable of your product.
- */
-
-/*
- Build a set of tables to decode the provided canonical Huffman code.
- The code lengths are lens[0..codes-1]. The result starts at *table,
- whose indices are 0..2^bits-1. work is a writable array of at least
- lens shorts, which is used as a work area. type is the type of code
- to be generated, CODES, LENS, or DISTS. On return, zero is success,
- -1 is an invalid code, and +1 means that ENOUGH isn't enough. table
- on return points to the next available entry's address. bits is the
- requested root table index bits, and on return it is the actual root
- table index bits. It will differ if the request is greater than the
- longest code or if it is less than the shortest code.
- */
-int inflate_table(type, lens, codes, table, bits, work)
-codetype type;
-unsigned short FAR *lens;
-unsigned codes;
-code FAR * FAR *table;
-unsigned FAR *bits;
-unsigned short FAR *work;
-{
- unsigned len; /* a code's length in bits */
- unsigned sym; /* index of code symbols */
- unsigned min, max; /* minimum and maximum code lengths */
- unsigned root; /* number of index bits for root table */
- unsigned curr; /* number of index bits for current table */
- unsigned drop; /* code bits to drop for sub-table */
- int left; /* number of prefix codes available */
- unsigned used; /* code entries in table used */
- unsigned huff; /* Huffman code */
- unsigned incr; /* for incrementing code, index */
- unsigned fill; /* index for replicating entries */
- unsigned low; /* low bits for current root entry */
- unsigned mask; /* mask for low root bits */
- code this; /* table entry for duplication */
- code FAR *next; /* next available space in table */
- const unsigned short FAR *base; /* base value table to use */
- const unsigned short FAR *extra; /* extra bits table to use */
- int end; /* use base and extra for symbol > end */
- unsigned short count[MAXBITS+1]; /* number of codes of each length */
- unsigned short offs[MAXBITS+1]; /* offsets in table for each length */
- static const unsigned short lbase[31] = { /* Length codes 257..285 base */
- 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
- 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
- static const unsigned short lext[31] = { /* Length codes 257..285 extra */
- 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
- 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 201, 196};
- static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
- 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
- 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
- 8193, 12289, 16385, 24577, 0, 0};
- static const unsigned short dext[32] = { /* Distance codes 0..29 extra */
- 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,
- 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,
- 28, 28, 29, 29, 64, 64};
-
- /*
- Process a set of code lengths to create a canonical Huffman code. The
- code lengths are lens[0..codes-1]. Each length corresponds to the
- symbols 0..codes-1. The Huffman code is generated by first sorting the
- symbols by length from short to long, and retaining the symbol order
- for codes with equal lengths. Then the code starts with all zero bits
- for the first code of the shortest length, and the codes are integer
- increments for the same length, and zeros are appended as the length
- increases. For the deflate format, these bits are stored backwards
- from their more natural integer increment ordering, and so when the
- decoding tables are built in the large loop below, the integer codes
- are incremented backwards.
-
- This routine assumes, but does not check, that all of the entries in
- lens[] are in the range 0..MAXBITS. The caller must assure this.
- 1..MAXBITS is interpreted as that code length. zero means that that
- symbol does not occur in this code.
-
- The codes are sorted by computing a count of codes for each length,
- creating from that a table of starting indices for each length in the
- sorted table, and then entering the symbols in order in the sorted
- table. The sorted table is work[], with that space being provided by
- the caller.
-
- The length counts are used for other purposes as well, i.e. finding
- the minimum and maximum length codes, determining if there are any
- codes at all, checking for a valid set of lengths, and looking ahead
- at length counts to determine sub-table sizes when building the
- decoding tables.
- */
-
- /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */
- for (len = 0; len <= MAXBITS; len++)
- count[len] = 0;
- for (sym = 0; sym < codes; sym++)
- count[lens[sym]]++;
-
- /* bound code lengths, force root to be within code lengths */
- root = *bits;
- for (max = MAXBITS; max >= 1; max--)
- if (count[max] != 0) break;
- if (root > max) root = max;
- if (max == 0) { /* no symbols to code at all */
- this.op = (unsigned char)64; /* invalid code marker */
- this.bits = (unsigned char)1;
- this.val = (unsigned short)0;
- *(*table)++ = this; /* make a table to force an error */
- *(*table)++ = this;
- *bits = 1;
- return 0; /* no symbols, but wait for decoding to report error */
- }
- for (min = 1; min <= MAXBITS; min++)
- if (count[min] != 0) break;
- if (root < min) root = min;
-
- /* check for an over-subscribed or incomplete set of lengths */
- left = 1;
- for (len = 1; len <= MAXBITS; len++) {
- left <<= 1;
- left -= count[len];
- if (left < 0) return -1; /* over-subscribed */
- }
- if (left > 0 && (type == CODES || max != 1))
- return -1; /* incomplete set */
-
- /* generate offsets into symbol table for each length for sorting */
- offs[1] = 0;
- for (len = 1; len < MAXBITS; len++)
- offs[len + 1] = offs[len] + count[len];
-
- /* sort symbols by length, by symbol order within each length */
- for (sym = 0; sym < codes; sym++)
- if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym;
-
- /*
- Create and fill in decoding tables. In this loop, the table being
- filled is at next and has curr index bits. The code being used is huff
- with length len. That code is converted to an index by dropping drop
- bits off of the bottom. For codes where len is less than drop + curr,
- those top drop + curr - len bits are incremented through all values to
- fill the table with replicated entries.
-
- root is the number of index bits for the root table. When len exceeds
- root, sub-tables are created pointed to by the root entry with an index
- of the low root bits of huff. This is saved in low to check for when a
- new sub-table should be started. drop is zero when the root table is
- being filled, and drop is root when sub-tables are being filled.
-
- When a new sub-table is needed, it is necessary to look ahead in the
- code lengths to determine what size sub-table is needed. The length
- counts are used for this, and so count[] is decremented as codes are
- entered in the tables.
-
- used keeps track of how many table entries have been allocated from the
- provided *table space. It is checked when a LENS table is being made
- against the space in *table, ENOUGH, minus the maximum space needed by
- the worst case distance code, MAXD. This should never happen, but the
- sufficiency of ENOUGH has not been proven exhaustively, hence the check.
- This assumes that when type == LENS, bits == 9.
-
- sym increments through all symbols, and the loop terminates when
- all codes of length max, i.e. all codes, have been processed. This
- routine permits incomplete codes, so another loop after this one fills
- in the rest of the decoding tables with invalid code markers.
- */
-
- /* set up for code type */
- switch (type) {
- case CODES:
- base = extra = work; /* dummy value--not used */
- end = 19;
- break;
- case LENS:
- base = lbase;
- base -= 257;
- extra = lext;
- extra -= 257;
- end = 256;
- break;
- default: /* DISTS */
- base = dbase;
- extra = dext;
- end = -1;
- }
-
- /* initialize state for loop */
- huff = 0; /* starting code */
- sym = 0; /* starting code symbol */
- len = min; /* starting code length */
- next = *table; /* current table to fill in */
- curr = root; /* current table index bits */
- drop = 0; /* current bits to drop from code for index */
- low = (unsigned)(-1); /* trigger new sub-table when len > root */
- used = 1U << root; /* use root table entries */
- mask = used - 1; /* mask for comparing low */
-
- /* check available table space */
- if (type == LENS && used >= ENOUGH - MAXD)
- return 1;
-
- /* process all codes and make table entries */
- for (;;) {
- /* create table entry */
- this.bits = (unsigned char)(len - drop);
- if ((int)(work[sym]) < end) {
- this.op = (unsigned char)0;
- this.val = work[sym];
- }
- else if ((int)(work[sym]) > end) {
- this.op = (unsigned char)(extra[work[sym]]);
- this.val = base[work[sym]];
- }
- else {
- this.op = (unsigned char)(32 + 64); /* end of block */
- this.val = 0;
- }
-
- /* replicate for those indices with low len bits equal to huff */
- incr = 1U << (len - drop);
- fill = 1U << curr;
- min = fill; /* save offset to next table */
- do {
- fill -= incr;
- next[(huff >> drop) + fill] = this;
- } while (fill != 0);
-
- /* backwards increment the len-bit code huff */
- incr = 1U << (len - 1);
- while (huff & incr)
- incr >>= 1;
- if (incr != 0) {
- huff &= incr - 1;
- huff += incr;
- }
- else
- huff = 0;
-
- /* go to next symbol, update count, len */
- sym++;
- if (--(count[len]) == 0) {
- if (len == max) break;
- len = lens[work[sym]];
- }
-
- /* create new sub-table if needed */
- if (len > root && (huff & mask) != low) {
- /* if first time, transition to sub-tables */
- if (drop == 0)
- drop = root;
-
- /* increment past last table */
- next += min; /* here min is 1 << curr */
-
- /* determine length of next table */
- curr = len - drop;
- left = (int)(1 << curr);
- while (curr + drop < max) {
- left -= count[curr + drop];
- if (left <= 0) break;
- curr++;
- left <<= 1;
- }
-
- /* check for enough space */
- used += 1U << curr;
- if (type == LENS && used >= ENOUGH - MAXD)
- return 1;
-
- /* point entry in root table to sub-table */
- low = huff & mask;
- (*table)[low].op = (unsigned char)curr;
- (*table)[low].bits = (unsigned char)root;
- (*table)[low].val = (unsigned short)(next - *table);
- }
- }
-
- /*
- Fill in rest of table for incomplete codes. This loop is similar to the
- loop above in incrementing huff for table indices. It is assumed that
- len is equal to curr + drop, so there is no loop needed to increment
- through high index bits. When the current sub-table is filled, the loop
- drops back to the root table to fill in any remaining entries there.
- */
- this.op = (unsigned char)64; /* invalid code marker */
- this.bits = (unsigned char)(len - drop);
- this.val = (unsigned short)0;
- while (huff != 0) {
- /* when done with sub-table, drop back to root table */
- if (drop != 0 && (huff & mask) != low) {
- drop = 0;
- len = root;
- next = *table;
- this.bits = (unsigned char)len;
- }
-
- /* put invalid code marker in table */
- next[huff >> drop] = this;
-
- /* backwards increment the len-bit code huff */
- incr = 1U << (len - 1);
- while (huff & incr)
- incr >>= 1;
- if (incr != 0) {
- huff &= incr - 1;
- huff += incr;
- }
- else
- huff = 0;
- }
-
- /* set return parameters */
- *table += used;
- *bits = root;
- return 0;
-}
diff --git a/WebCore/platform/image-decoders/zlib/inftrees.h b/WebCore/platform/image-decoders/zlib/inftrees.h
deleted file mode 100644
index b1104c8..0000000
--- a/WebCore/platform/image-decoders/zlib/inftrees.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* inftrees.h -- header to use inftrees.c
- * Copyright (C) 1995-2005 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-/* Structure for decoding tables. Each entry provides either the
- information needed to do the operation requested by the code that
- indexed that table entry, or it provides a pointer to another
- table that indexes more bits of the code. op indicates whether
- the entry is a pointer to another table, a literal, a length or
- distance, an end-of-block, or an invalid code. For a table
- pointer, the low four bits of op is the number of index bits of
- that table. For a length or distance, the low four bits of op
- is the number of extra bits to get after the code. bits is
- the number of bits in this code or part of the code to drop off
- of the bit buffer. val is the actual byte to output in the case
- of a literal, the base length or distance, or the offset from
- the current table to the next table. Each entry is four bytes. */
-typedef struct {
- unsigned char op; /* operation, extra bits, table bits */
- unsigned char bits; /* bits in this part of the code */
- unsigned short val; /* offset in table or code value */
-} code;
-
-/* op values as set by inflate_table():
- 00000000 - literal
- 0000tttt - table link, tttt != 0 is the number of table index bits
- 0001eeee - length or distance, eeee is the number of extra bits
- 01100000 - end of block
- 01000000 - invalid code
- */
-
-/* Maximum size of dynamic tree. The maximum found in a long but non-
- exhaustive search was 1444 code structures (852 for length/literals
- and 592 for distances, the latter actually the result of an
- exhaustive search). The true maximum is not known, but the value
- below is more than safe. */
-#define ENOUGH 2048
-#define MAXD 592
-
-/* Type of code to build for inftable() */
-typedef enum {
- CODES,
- LENS,
- DISTS
-} codetype;
-
-extern int inflate_table OF((codetype type, unsigned short FAR *lens,
- unsigned codes, code FAR * FAR *table,
- unsigned FAR *bits, unsigned short FAR *work));
diff --git a/WebCore/platform/image-decoders/zlib/mozzconf.h b/WebCore/platform/image-decoders/zlib/mozzconf.h
deleted file mode 100644
index 118185c..0000000
--- a/WebCore/platform/image-decoders/zlib/mozzconf.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is the mozilla zlib configuration.
- *
- * The Initial Developer of the Original Code is IBM Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2004
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef MOZZCONF_H
-#define MOZZCONF_H
-
-#if defined(XP_WIN) && defined(ZLIB_DLL) && !defined(MOZ_ENABLE_LIBXUL)
-#undef ZLIB_DLL
-#endif
-
-#ifdef HAVE_VISIBILITY_ATTRIBUTE
-#define ZEXTERN __attribute__((visibility ("default"))) extern
-#endif
-
-/* Exported Symbols */
-#define zlibVersion MOZ_Z_zlibVersion
-#define deflate MOZ_Z_deflate
-#define deflateEnd MOZ_Z_deflateEnd
-#define inflate MOZ_Z_inflate
-#define inflateEnd MOZ_Z_inflateEnd
-#define deflateSetDictionary MOZ_Z_deflateSetDictionary
-#define deflateCopy MOZ_Z_deflateCopy
-#define deflateReset MOZ_Z_deflateReset
-#define deflateParams MOZ_Z_deflateParams
-#define deflateBound MOZ_Z_deflateBound
-#define deflatePrime MOZ_Z_deflatePrime
-#define inflateSetDictionary MOZ_Z_inflateSetDictionary
-#define inflateSync MOZ_Z_inflateSync
-#define inflateCopy MOZ_Z_inflateCopy
-#define inflateReset MOZ_Z_inflateReset
-#define inflateBack MOZ_Z_inflateBack
-#define inflateBackEnd MOZ_Z_inflateBackEnd
-#define zlibCompileFlags MOZ_Z_zlibCompileFlags
-#define compress MOZ_Z_compress
-#define compress2 MOZ_Z_compress2
-#define compressBound MOZ_Z_compressBound
-#define uncompress MOZ_Z_uncompress
-#define gzopen MOZ_Z_gzopen
-#define gzdopen MOZ_Z_gzdopen
-#define gzsetparams MOZ_Z_gzsetparams
-#define gzread MOZ_Z_gzread
-#define gzwrite MOZ_Z_gzwrite
-#define gzprintf MOZ_Z_gzprintf
-#define gzputs MOZ_Z_gzputs
-#define gzgets MOZ_Z_gzgets
-#define gzputc MOZ_Z_gzputc
-#define gzgetc MOZ_Z_gzgetc
-#define gzungetc MOZ_Z_gzungetc
-#define gzflush MOZ_Z_gzflush
-#define gzseek MOZ_Z_gzseek
-#define gzrewind MOZ_Z_gzrewind
-#define gztell MOZ_Z_gztell
-#define gzeof MOZ_Z_gzeof
-#define gzclose MOZ_Z_gzclose
-#define gzerror MOZ_Z_gzerror
-#define gzclearerr MOZ_Z_gzclearerr
-#define adler32 MOZ_Z_adler32
-#define crc32 MOZ_Z_crc32
-#define deflateInit_ MOZ_Z_deflateInit_
-#define deflateInit2_ MOZ_Z_deflateInit2_
-#define inflateInit_ MOZ_Z_inflateInit_
-#define inflateInit2_ MOZ_Z_inflateInit2_
-#define inflateBackInit_ MOZ_Z_inflateBackInit_
-#define inflateSyncPoint MOZ_Z_inflateSyncPoint
-#define get_crc_table MOZ_Z_get_crc_table
-#define zError MOZ_Z_zError
-
-/* Extra global symbols */
-#define _dist_code MOZ_Z__dist_code
-#define _length_code MOZ_Z__length_code
-#define _tr_align MOZ_Z__tr_align
-#define _tr_flush_block MOZ_Z__tr_flush_block
-#define _tr_init MOZ_Z__tr_init
-#define _tr_stored_block MOZ_Z__tr_stored_block
-#define _tr_tally MOZ_Z__tr_tally
-#define deflate_copyright MOZ_Z_deflate_copyright
-#define inflate_copyright MOZ_Z_inflate_copyright
-#define inflate_fast MOZ_Z_inflate_fast
-#define inflate_table MOZ_Z_inflate_table
-#define z_errmsg MOZ_Z_z_errmsg
-#define zcalloc MOZ_Z_zcalloc
-#define zcfree MOZ_Z_zcfree
-#define alloc_func MOZ_Z_alloc_func
-#define free_func MOZ_Z_free_func
-#define in_func MOZ_Z_in_func
-#define out_func MOZ_Z_out_func
-
-/* New as of libpng-1.2.3 */
-#define adler32_combine MOZ_Z_adler32_combine
-#define crc32_combine MOZ_Z_crc32_combine
-#define deflateSetHeader MOZ_Z_deflateSetHeader
-#define deflateTune MOZ_Z_deflateTune
-#define gzdirect MOZ_Z_gzdirect
-#define inflatePrime MOZ_Z_inflatePrime
-#define inflateGetHeader MOZ_Z_inflateGetHeader
-
-#endif
diff --git a/WebCore/platform/image-decoders/zlib/trees.c b/WebCore/platform/image-decoders/zlib/trees.c
deleted file mode 100644
index 0cbfae2..0000000
--- a/WebCore/platform/image-decoders/zlib/trees.c
+++ /dev/null
@@ -1,1219 +0,0 @@
-/* trees.c -- output deflated data using Huffman coding
- * Copyright (C) 1995-2005 Jean-loup Gailly
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/*
- * ALGORITHM
- *
- * The "deflation" process uses several Huffman trees. The more
- * common source values are represented by shorter bit sequences.
- *
- * Each code tree is stored in a compressed form which is itself
- * a Huffman encoding of the lengths of all the code strings (in
- * ascending order by source values). The actual code strings are
- * reconstructed from the lengths in the inflate process, as described
- * in the deflate specification.
- *
- * REFERENCES
- *
- * Deutsch, L.P.,"'Deflate' Compressed Data Format Specification".
- * Available in ftp.uu.net:/pub/archiving/zip/doc/deflate-1.1.doc
- *
- * Storer, James A.
- * Data Compression: Methods and Theory, pp. 49-50.
- * Computer Science Press, 1988. ISBN 0-7167-8156-5.
- *
- * Sedgewick, R.
- * Algorithms, p290.
- * Addison-Wesley, 1983. ISBN 0-201-06672-6.
- */
-
-/* @(#) $Id: trees.c,v 3.6 2005/08/04 19:14:14 tor%cs.brown.edu Exp $ */
-
-/* #define GEN_TREES_H */
-
-#include "deflate.h"
-
-#ifdef DEBUG
-# include <ctype.h>
-#endif
-
-/* ===========================================================================
- * Constants
- */
-
-#define MAX_BL_BITS 7
-/* Bit length codes must not exceed MAX_BL_BITS bits */
-
-#define END_BLOCK 256
-/* end of block literal code */
-
-#define REP_3_6 16
-/* repeat previous bit length 3-6 times (2 bits of repeat count) */
-
-#define REPZ_3_10 17
-/* repeat a zero length 3-10 times (3 bits of repeat count) */
-
-#define REPZ_11_138 18
-/* repeat a zero length 11-138 times (7 bits of repeat count) */
-
-local const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */
- = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0};
-
-local const int extra_dbits[D_CODES] /* extra bits for each distance code */
- = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13};
-
-local const int extra_blbits[BL_CODES]/* extra bits for each bit length code */
- = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7};
-
-local const uch bl_order[BL_CODES]
- = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15};
-/* The lengths of the bit length codes are sent in order of decreasing
- * probability, to avoid transmitting the lengths for unused bit length codes.
- */
-
-#define Buf_size (8 * 2*sizeof(char))
-/* Number of bits used within bi_buf. (bi_buf might be implemented on
- * more than 16 bits on some systems.)
- */
-
-/* ===========================================================================
- * Local data. These are initialized only once.
- */
-
-#define DIST_CODE_LEN 512 /* see definition of array dist_code below */
-
-#if defined(GEN_TREES_H) || !defined(STDC)
-/* non ANSI compilers may not accept trees.h */
-
-local ct_data static_ltree[L_CODES+2];
-/* The static literal tree. Since the bit lengths are imposed, there is no
- * need for the L_CODES extra codes used during heap construction. However
- * The codes 286 and 287 are needed to build a canonical tree (see _tr_init
- * below).
- */
-
-local ct_data static_dtree[D_CODES];
-/* The static distance tree. (Actually a trivial tree since all codes use
- * 5 bits.)
- */
-
-uch _dist_code[DIST_CODE_LEN];
-/* Distance codes. The first 256 values correspond to the distances
- * 3 .. 258, the last 256 values correspond to the top 8 bits of
- * the 15 bit distances.
- */
-
-uch _length_code[MAX_MATCH-MIN_MATCH+1];
-/* length code for each normalized match length (0 == MIN_MATCH) */
-
-local int base_length[LENGTH_CODES];
-/* First normalized length for each code (0 = MIN_MATCH) */
-
-local int base_dist[D_CODES];
-/* First normalized distance for each code (0 = distance of 1) */
-
-#else
-# include "trees.h"
-#endif /* GEN_TREES_H */
-
-struct static_tree_desc_s {
- const ct_data *static_tree; /* static tree or NULL */
- const intf *extra_bits; /* extra bits for each code or NULL */
- int extra_base; /* base index for extra_bits */
- int elems; /* max number of elements in the tree */
- int max_length; /* max bit length for the codes */
-};
-
-local static_tree_desc static_l_desc =
-{static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS};
-
-local static_tree_desc static_d_desc =
-{static_dtree, extra_dbits, 0, D_CODES, MAX_BITS};
-
-local static_tree_desc static_bl_desc =
-{(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS};
-
-/* ===========================================================================
- * Local (static) routines in this file.
- */
-
-local void tr_static_init OF((void));
-local void init_block OF((deflate_state *s));
-local void pqdownheap OF((deflate_state *s, ct_data *tree, int k));
-local void gen_bitlen OF((deflate_state *s, tree_desc *desc));
-local void gen_codes OF((ct_data *tree, int max_code, ushf *bl_count));
-local void build_tree OF((deflate_state *s, tree_desc *desc));
-local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code));
-local void send_tree OF((deflate_state *s, ct_data *tree, int max_code));
-local int build_bl_tree OF((deflate_state *s));
-local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes,
- int blcodes));
-local void compress_block OF((deflate_state *s, ct_data *ltree,
- ct_data *dtree));
-local void set_data_type OF((deflate_state *s));
-local unsigned bi_reverse OF((unsigned value, int length));
-local void bi_windup OF((deflate_state *s));
-local void bi_flush OF((deflate_state *s));
-local void copy_block OF((deflate_state *s, charf *buf, unsigned len,
- int header));
-
-#ifdef GEN_TREES_H
-local void gen_trees_header OF((void));
-#endif
-
-#ifndef DEBUG
-# define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len)
- /* Send a code of the given tree. c and tree must not have side effects */
-
-#else /* DEBUG */
-# define send_code(s, c, tree) \
- { if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \
- send_bits(s, tree[c].Code, tree[c].Len); }
-#endif
-
-/* ===========================================================================
- * Output a short LSB first on the stream.
- * IN assertion: there is enough room in pendingBuf.
- */
-#define put_short(s, w) { \
- put_byte(s, (uch)((w) & 0xff)); \
- put_byte(s, (uch)((ush)(w) >> 8)); \
-}
-
-/* ===========================================================================
- * Send a value on a given number of bits.
- * IN assertion: length <= 16 and value fits in length bits.
- */
-#ifdef DEBUG
-local void send_bits OF((deflate_state *s, int value, int length));
-
-local void send_bits(s, value, length)
- deflate_state *s;
- int value; /* value to send */
- int length; /* number of bits */
-{
- Tracevv((stderr," l %2d v %4x ", length, value));
- Assert(length > 0 && length <= 15, "invalid length");
- s->bits_sent += (ulg)length;
-
- /* If not enough room in bi_buf, use (valid) bits from bi_buf and
- * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid))
- * unused bits in value.
- */
- if (s->bi_valid > (int)Buf_size - length) {
- s->bi_buf |= (value << s->bi_valid);
- put_short(s, s->bi_buf);
- s->bi_buf = (ush)value >> (Buf_size - s->bi_valid);
- s->bi_valid += length - Buf_size;
- } else {
- s->bi_buf |= value << s->bi_valid;
- s->bi_valid += length;
- }
-}
-#else /* !DEBUG */
-
-#define send_bits(s, value, length) \
-{ int len = length;\
- if (s->bi_valid > (int)Buf_size - len) {\
- int val = value;\
- s->bi_buf |= (val << s->bi_valid);\
- put_short(s, s->bi_buf);\
- s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\
- s->bi_valid += len - Buf_size;\
- } else {\
- s->bi_buf |= (value) << s->bi_valid;\
- s->bi_valid += len;\
- }\
-}
-#endif /* DEBUG */
-
-
-/* the arguments must not have side effects */
-
-/* ===========================================================================
- * Initialize the various 'constant' tables.
- */
-local void tr_static_init()
-{
-#if defined(GEN_TREES_H) || !defined(STDC)
- static int static_init_done = 0;
- int n; /* iterates over tree elements */
- int bits; /* bit counter */
- int length; /* length value */
- int code; /* code value */
- int dist; /* distance index */
- ush bl_count[MAX_BITS+1];
- /* number of codes at each bit length for an optimal tree */
-
- if (static_init_done) return;
-
- /* For some embedded targets, global variables are not initialized: */
- static_l_desc.static_tree = static_ltree;
- static_l_desc.extra_bits = extra_lbits;
- static_d_desc.static_tree = static_dtree;
- static_d_desc.extra_bits = extra_dbits;
- static_bl_desc.extra_bits = extra_blbits;
-
- /* Initialize the mapping length (0..255) -> length code (0..28) */
- length = 0;
- for (code = 0; code < LENGTH_CODES-1; code++) {
- base_length[code] = length;
- for (n = 0; n < (1<<extra_lbits[code]); n++) {
- _length_code[length++] = (uch)code;
- }
- }
- Assert (length == 256, "tr_static_init: length != 256");
- /* Note that the length 255 (match length 258) can be represented
- * in two different ways: code 284 + 5 bits or code 285, so we
- * overwrite length_code[255] to use the best encoding:
- */
- _length_code[length-1] = (uch)code;
-
- /* Initialize the mapping dist (0..32K) -> dist code (0..29) */
- dist = 0;
- for (code = 0 ; code < 16; code++) {
- base_dist[code] = dist;
- for (n = 0; n < (1<<extra_dbits[code]); n++) {
- _dist_code[dist++] = (uch)code;
- }
- }
- Assert (dist == 256, "tr_static_init: dist != 256");
- dist >>= 7; /* from now on, all distances are divided by 128 */
- for ( ; code < D_CODES; code++) {
- base_dist[code] = dist << 7;
- for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) {
- _dist_code[256 + dist++] = (uch)code;
- }
- }
- Assert (dist == 256, "tr_static_init: 256+dist != 512");
-
- /* Construct the codes of the static literal tree */
- for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0;
- n = 0;
- while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++;
- while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++;
- while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++;
- while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++;
- /* Codes 286 and 287 do not exist, but we must include them in the
- * tree construction to get a canonical Huffman tree (longest code
- * all ones)
- */
- gen_codes((ct_data *)static_ltree, L_CODES+1, bl_count);
-
- /* The static distance tree is trivial: */
- for (n = 0; n < D_CODES; n++) {
- static_dtree[n].Len = 5;
- static_dtree[n].Code = bi_reverse((unsigned)n, 5);
- }
- static_init_done = 1;
-
-# ifdef GEN_TREES_H
- gen_trees_header();
-# endif
-#endif /* defined(GEN_TREES_H) || !defined(STDC) */
-}
-
-/* ===========================================================================
- * Genererate the file trees.h describing the static trees.
- */
-#ifdef GEN_TREES_H
-# ifndef DEBUG
-# include <stdio.h>
-# endif
-
-# define SEPARATOR(i, last, width) \
- ((i) == (last)? "\n};\n\n" : \
- ((i) % (width) == (width)-1 ? ",\n" : ", "))
-
-void gen_trees_header()
-{
- FILE *header = fopen("trees.h", "w");
- int i;
-
- Assert (header != NULL, "Can't open trees.h");
- fprintf(header,
- "/* header created automatically with -DGEN_TREES_H */\n\n");
-
- fprintf(header, "local const ct_data static_ltree[L_CODES+2] = {\n");
- for (i = 0; i < L_CODES+2; i++) {
- fprintf(header, "{{%3u},{%3u}}%s", static_ltree[i].Code,
- static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5));
- }
-
- fprintf(header, "local const ct_data static_dtree[D_CODES] = {\n");
- for (i = 0; i < D_CODES; i++) {
- fprintf(header, "{{%2u},{%2u}}%s", static_dtree[i].Code,
- static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5));
- }
-
- fprintf(header, "const uch _dist_code[DIST_CODE_LEN] = {\n");
- for (i = 0; i < DIST_CODE_LEN; i++) {
- fprintf(header, "%2u%s", _dist_code[i],
- SEPARATOR(i, DIST_CODE_LEN-1, 20));
- }
-
- fprintf(header, "const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {\n");
- for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) {
- fprintf(header, "%2u%s", _length_code[i],
- SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20));
- }
-
- fprintf(header, "local const int base_length[LENGTH_CODES] = {\n");
- for (i = 0; i < LENGTH_CODES; i++) {
- fprintf(header, "%1u%s", base_length[i],
- SEPARATOR(i, LENGTH_CODES-1, 20));
- }
-
- fprintf(header, "local const int base_dist[D_CODES] = {\n");
- for (i = 0; i < D_CODES; i++) {
- fprintf(header, "%5u%s", base_dist[i],
- SEPARATOR(i, D_CODES-1, 10));
- }
-
- fclose(header);
-}
-#endif /* GEN_TREES_H */
-
-/* ===========================================================================
- * Initialize the tree data structures for a new zlib stream.
- */
-void _tr_init(s)
- deflate_state *s;
-{
- tr_static_init();
-
- s->l_desc.dyn_tree = s->dyn_ltree;
- s->l_desc.stat_desc = &static_l_desc;
-
- s->d_desc.dyn_tree = s->dyn_dtree;
- s->d_desc.stat_desc = &static_d_desc;
-
- s->bl_desc.dyn_tree = s->bl_tree;
- s->bl_desc.stat_desc = &static_bl_desc;
-
- s->bi_buf = 0;
- s->bi_valid = 0;
- s->last_eob_len = 8; /* enough lookahead for inflate */
-#ifdef DEBUG
- s->compressed_len = 0L;
- s->bits_sent = 0L;
-#endif
-
- /* Initialize the first block of the first file: */
- init_block(s);
-}
-
-/* ===========================================================================
- * Initialize a new block.
- */
-local void init_block(s)
- deflate_state *s;
-{
- int n; /* iterates over tree elements */
-
- /* Initialize the trees. */
- for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0;
- for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0;
- for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0;
-
- s->dyn_ltree[END_BLOCK].Freq = 1;
- s->opt_len = s->static_len = 0L;
- s->last_lit = s->matches = 0;
-}
-
-#define SMALLEST 1
-/* Index within the heap array of least frequent node in the Huffman tree */
-
-
-/* ===========================================================================
- * Remove the smallest element from the heap and recreate the heap with
- * one less element. Updates heap and heap_len.
- */
-#define pqremove(s, tree, top) \
-{\
- top = s->heap[SMALLEST]; \
- s->heap[SMALLEST] = s->heap[s->heap_len--]; \
- pqdownheap(s, tree, SMALLEST); \
-}
-
-/* ===========================================================================
- * Compares to subtrees, using the tree depth as tie breaker when
- * the subtrees have equal frequency. This minimizes the worst case length.
- */
-#define smaller(tree, n, m, depth) \
- (tree[n].Freq < tree[m].Freq || \
- (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m]))
-
-/* ===========================================================================
- * Restore the heap property by moving down the tree starting at node k,
- * exchanging a node with the smallest of its two sons if necessary, stopping
- * when the heap property is re-established (each father smaller than its
- * two sons).
- */
-local void pqdownheap(s, tree, k)
- deflate_state *s;
- ct_data *tree; /* the tree to restore */
- int k; /* node to move down */
-{
- int v = s->heap[k];
- int j = k << 1; /* left son of k */
- while (j <= s->heap_len) {
- /* Set j to the smallest of the two sons: */
- if (j < s->heap_len &&
- smaller(tree, s->heap[j+1], s->heap[j], s->depth)) {
- j++;
- }
- /* Exit if v is smaller than both sons */
- if (smaller(tree, v, s->heap[j], s->depth)) break;
-
- /* Exchange v with the smallest son */
- s->heap[k] = s->heap[j]; k = j;
-
- /* And continue down the tree, setting j to the left son of k */
- j <<= 1;
- }
- s->heap[k] = v;
-}
-
-/* ===========================================================================
- * Compute the optimal bit lengths for a tree and update the total bit length
- * for the current block.
- * IN assertion: the fields freq and dad are set, heap[heap_max] and
- * above are the tree nodes sorted by increasing frequency.
- * OUT assertions: the field len is set to the optimal bit length, the
- * array bl_count contains the frequencies for each bit length.
- * The length opt_len is updated; static_len is also updated if stree is
- * not null.
- */
-local void gen_bitlen(s, desc)
- deflate_state *s;
- tree_desc *desc; /* the tree descriptor */
-{
- ct_data *tree = desc->dyn_tree;
- int max_code = desc->max_code;
- const ct_data *stree = desc->stat_desc->static_tree;
- const intf *extra = desc->stat_desc->extra_bits;
- int base = desc->stat_desc->extra_base;
- int max_length = desc->stat_desc->max_length;
- int h; /* heap index */
- int n, m; /* iterate over the tree elements */
- int bits; /* bit length */
- int xbits; /* extra bits */
- ush f; /* frequency */
- int overflow = 0; /* number of elements with bit length too large */
-
- for (bits = 0; bits <= MAX_BITS; bits++) s->bl_count[bits] = 0;
-
- /* In a first pass, compute the optimal bit lengths (which may
- * overflow in the case of the bit length tree).
- */
- tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */
-
- for (h = s->heap_max+1; h < HEAP_SIZE; h++) {
- n = s->heap[h];
- bits = tree[tree[n].Dad].Len + 1;
- if (bits > max_length) bits = max_length, overflow++;
- tree[n].Len = (ush)bits;
- /* We overwrite tree[n].Dad which is no longer needed */
-
- if (n > max_code) continue; /* not a leaf node */
-
- s->bl_count[bits]++;
- xbits = 0;
- if (n >= base) xbits = extra[n-base];
- f = tree[n].Freq;
- s->opt_len += (ulg)f * (bits + xbits);
- if (stree) s->static_len += (ulg)f * (stree[n].Len + xbits);
- }
- if (overflow == 0) return;
-
- Trace((stderr,"\nbit length overflow\n"));
- /* This happens for example on obj2 and pic of the Calgary corpus */
-
- /* Find the first bit length which could increase: */
- do {
- bits = max_length-1;
- while (s->bl_count[bits] == 0) bits--;
- s->bl_count[bits]--; /* move one leaf down the tree */
- s->bl_count[bits+1] += 2; /* move one overflow item as its brother */
- s->bl_count[max_length]--;
- /* The brother of the overflow item also moves one step up,
- * but this does not affect bl_count[max_length]
- */
- overflow -= 2;
- } while (overflow > 0);
-
- /* Now recompute all bit lengths, scanning in increasing frequency.
- * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all
- * lengths instead of fixing only the wrong ones. This idea is taken
- * from 'ar' written by Haruhiko Okumura.)
- */
- for (bits = max_length; bits != 0; bits--) {
- n = s->bl_count[bits];
- while (n != 0) {
- m = s->heap[--h];
- if (m > max_code) continue;
- if ((unsigned) tree[m].Len != (unsigned) bits) {
- Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits));
- s->opt_len += ((long)bits - (long)tree[m].Len)
- *(long)tree[m].Freq;
- tree[m].Len = (ush)bits;
- }
- n--;
- }
- }
-}
-
-/* ===========================================================================
- * Generate the codes for a given tree and bit counts (which need not be
- * optimal).
- * IN assertion: the array bl_count contains the bit length statistics for
- * the given tree and the field len is set for all tree elements.
- * OUT assertion: the field code is set for all tree elements of non
- * zero code length.
- */
-local void gen_codes (tree, max_code, bl_count)
- ct_data *tree; /* the tree to decorate */
- int max_code; /* largest code with non zero frequency */
- ushf *bl_count; /* number of codes at each bit length */
-{
- ush next_code[MAX_BITS+1]; /* next code value for each bit length */
- ush code = 0; /* running code value */
- int bits; /* bit index */
- int n; /* code index */
-
- /* The distribution counts are first used to generate the code values
- * without bit reversal.
- */
- for (bits = 1; bits <= MAX_BITS; bits++) {
- next_code[bits] = code = (code + bl_count[bits-1]) << 1;
- }
- /* Check that the bit counts in bl_count are consistent. The last code
- * must be all ones.
- */
- Assert (code + bl_count[MAX_BITS]-1 == (1<<MAX_BITS)-1,
- "inconsistent bit counts");
- Tracev((stderr,"\ngen_codes: max_code %d ", max_code));
-
- for (n = 0; n <= max_code; n++) {
- int len = tree[n].Len;
- if (len == 0) continue;
- /* Now reverse the bits */
- tree[n].Code = bi_reverse(next_code[len]++, len);
-
- Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ",
- n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1));
- }
-}
-
-/* ===========================================================================
- * Construct one Huffman tree and assigns the code bit strings and lengths.
- * Update the total bit length for the current block.
- * IN assertion: the field freq is set for all tree elements.
- * OUT assertions: the fields len and code are set to the optimal bit length
- * and corresponding code. The length opt_len is updated; static_len is
- * also updated if stree is not null. The field max_code is set.
- */
-local void build_tree(s, desc)
- deflate_state *s;
- tree_desc *desc; /* the tree descriptor */
-{
- ct_data *tree = desc->dyn_tree;
- const ct_data *stree = desc->stat_desc->static_tree;
- int elems = desc->stat_desc->elems;
- int n, m; /* iterate over heap elements */
- int max_code = -1; /* largest code with non zero frequency */
- int node; /* new node being created */
-
- /* Construct the initial heap, with least frequent element in
- * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].
- * heap[0] is not used.
- */
- s->heap_len = 0, s->heap_max = HEAP_SIZE;
-
- for (n = 0; n < elems; n++) {
- if (tree[n].Freq != 0) {
- s->heap[++(s->heap_len)] = max_code = n;
- s->depth[n] = 0;
- } else {
- tree[n].Len = 0;
- }
- }
-
- /* The pkzip format requires that at least one distance code exists,
- * and that at least one bit should be sent even if there is only one
- * possible code. So to avoid special checks later on we force at least
- * two codes of non zero frequency.
- */
- while (s->heap_len < 2) {
- node = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0);
- tree[node].Freq = 1;
- s->depth[node] = 0;
- s->opt_len--; if (stree) s->static_len -= stree[node].Len;
- /* node is 0 or 1 so it does not have extra bits */
- }
- desc->max_code = max_code;
-
- /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,
- * establish sub-heaps of increasing lengths:
- */
- for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n);
-
- /* Construct the Huffman tree by repeatedly combining the least two
- * frequent nodes.
- */
- node = elems; /* next internal node of the tree */
- do {
- pqremove(s, tree, n); /* n = node of least frequency */
- m = s->heap[SMALLEST]; /* m = node of next least frequency */
-
- s->heap[--(s->heap_max)] = n; /* keep the nodes sorted by frequency */
- s->heap[--(s->heap_max)] = m;
-
- /* Create a new node father of n and m */
- tree[node].Freq = tree[n].Freq + tree[m].Freq;
- s->depth[node] = (uch)((s->depth[n] >= s->depth[m] ?
- s->depth[n] : s->depth[m]) + 1);
- tree[n].Dad = tree[m].Dad = (ush)node;
-#ifdef DUMP_BL_TREE
- if (tree == s->bl_tree) {
- fprintf(stderr,"\nnode %d(%d), sons %d(%d) %d(%d)",
- node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq);
- }
-#endif
- /* and insert the new node in the heap */
- s->heap[SMALLEST] = node++;
- pqdownheap(s, tree, SMALLEST);
-
- } while (s->heap_len >= 2);
-
- s->heap[--(s->heap_max)] = s->heap[SMALLEST];
-
- /* At this point, the fields freq and dad are set. We can now
- * generate the bit lengths.
- */
- gen_bitlen(s, (tree_desc *)desc);
-
- /* The field len is now set, we can generate the bit codes */
- gen_codes ((ct_data *)tree, max_code, s->bl_count);
-}
-
-/* ===========================================================================
- * Scan a literal or distance tree to determine the frequencies of the codes
- * in the bit length tree.
- */
-local void scan_tree (s, tree, max_code)
- deflate_state *s;
- ct_data *tree; /* the tree to be scanned */
- int max_code; /* and its largest code of non zero frequency */
-{
- int n; /* iterates over all tree elements */
- int prevlen = -1; /* last emitted length */
- int curlen; /* length of current code */
- int nextlen = tree[0].Len; /* length of next code */
- int count = 0; /* repeat count of the current code */
- int max_count = 7; /* max repeat count */
- int min_count = 4; /* min repeat count */
-
- if (nextlen == 0) max_count = 138, min_count = 3;
- tree[max_code+1].Len = (ush)0xffff; /* guard */
-
- for (n = 0; n <= max_code; n++) {
- curlen = nextlen; nextlen = tree[n+1].Len;
- if (++count < max_count && curlen == nextlen) {
- continue;
- } else if (count < min_count) {
- s->bl_tree[curlen].Freq += count;
- } else if (curlen != 0) {
- if (curlen != prevlen) s->bl_tree[curlen].Freq++;
- s->bl_tree[REP_3_6].Freq++;
- } else if (count <= 10) {
- s->bl_tree[REPZ_3_10].Freq++;
- } else {
- s->bl_tree[REPZ_11_138].Freq++;
- }
- count = 0; prevlen = curlen;
- if (nextlen == 0) {
- max_count = 138, min_count = 3;
- } else if (curlen == nextlen) {
- max_count = 6, min_count = 3;
- } else {
- max_count = 7, min_count = 4;
- }
- }
-}
-
-/* ===========================================================================
- * Send a literal or distance tree in compressed form, using the codes in
- * bl_tree.
- */
-local void send_tree (s, tree, max_code)
- deflate_state *s;
- ct_data *tree; /* the tree to be scanned */
- int max_code; /* and its largest code of non zero frequency */
-{
- int n; /* iterates over all tree elements */
- int prevlen = -1; /* last emitted length */
- int curlen; /* length of current code */
- int nextlen = tree[0].Len; /* length of next code */
- int count = 0; /* repeat count of the current code */
- int max_count = 7; /* max repeat count */
- int min_count = 4; /* min repeat count */
-
- /* tree[max_code+1].Len = -1; */ /* guard already set */
- if (nextlen == 0) max_count = 138, min_count = 3;
-
- for (n = 0; n <= max_code; n++) {
- curlen = nextlen; nextlen = tree[n+1].Len;
- if (++count < max_count && curlen == nextlen) {
- continue;
- } else if (count < min_count) {
- do { send_code(s, curlen, s->bl_tree); } while (--count != 0);
-
- } else if (curlen != 0) {
- if (curlen != prevlen) {
- send_code(s, curlen, s->bl_tree); count--;
- }
- Assert(count >= 3 && count <= 6, " 3_6?");
- send_code(s, REP_3_6, s->bl_tree); send_bits(s, count-3, 2);
-
- } else if (count <= 10) {
- send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count-3, 3);
-
- } else {
- send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count-11, 7);
- }
- count = 0; prevlen = curlen;
- if (nextlen == 0) {
- max_count = 138, min_count = 3;
- } else if (curlen == nextlen) {
- max_count = 6, min_count = 3;
- } else {
- max_count = 7, min_count = 4;
- }
- }
-}
-
-/* ===========================================================================
- * Construct the Huffman tree for the bit lengths and return the index in
- * bl_order of the last bit length code to send.
- */
-local int build_bl_tree(s)
- deflate_state *s;
-{
- int max_blindex; /* index of last bit length code of non zero freq */
-
- /* Determine the bit length frequencies for literal and distance trees */
- scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code);
- scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code);
-
- /* Build the bit length tree: */
- build_tree(s, (tree_desc *)(&(s->bl_desc)));
- /* opt_len now includes the length of the tree representations, except
- * the lengths of the bit lengths codes and the 5+5+4 bits for the counts.
- */
-
- /* Determine the number of bit length codes to send. The pkzip format
- * requires that at least 4 bit length codes be sent. (appnote.txt says
- * 3 but the actual value used is 4.)
- */
- for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) {
- if (s->bl_tree[bl_order[max_blindex]].Len != 0) break;
- }
- /* Update opt_len to include the bit length tree and counts */
- s->opt_len += 3*(max_blindex+1) + 5+5+4;
- Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld",
- s->opt_len, s->static_len));
-
- return max_blindex;
-}
-
-/* ===========================================================================
- * Send the header for a block using dynamic Huffman trees: the counts, the
- * lengths of the bit length codes, the literal tree and the distance tree.
- * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.
- */
-local void send_all_trees(s, lcodes, dcodes, blcodes)
- deflate_state *s;
- int lcodes, dcodes, blcodes; /* number of codes for each tree */
-{
- int rank; /* index in bl_order */
-
- Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes");
- Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES,
- "too many codes");
- Tracev((stderr, "\nbl counts: "));
- send_bits(s, lcodes-257, 5); /* not +255 as stated in appnote.txt */
- send_bits(s, dcodes-1, 5);
- send_bits(s, blcodes-4, 4); /* not -3 as stated in appnote.txt */
- for (rank = 0; rank < blcodes; rank++) {
- Tracev((stderr, "\nbl code %2d ", bl_order[rank]));
- send_bits(s, s->bl_tree[bl_order[rank]].Len, 3);
- }
- Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent));
-
- send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */
- Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent));
-
- send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1); /* distance tree */
- Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent));
-}
-
-/* ===========================================================================
- * Send a stored block
- */
-void _tr_stored_block(s, buf, stored_len, eof)
- deflate_state *s;
- charf *buf; /* input block */
- ulg stored_len; /* length of input block */
- int eof; /* true if this is the last block for a file */
-{
- send_bits(s, (STORED_BLOCK<<1)+eof, 3); /* send block type */
-#ifdef DEBUG
- s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L;
- s->compressed_len += (stored_len + 4) << 3;
-#endif
- copy_block(s, buf, (unsigned)stored_len, 1); /* with header */
-}
-
-/* ===========================================================================
- * Send one empty static block to give enough lookahead for inflate.
- * This takes 10 bits, of which 7 may remain in the bit buffer.
- * The current inflate code requires 9 bits of lookahead. If the
- * last two codes for the previous block (real code plus EOB) were coded
- * on 5 bits or less, inflate may have only 5+3 bits of lookahead to decode
- * the last real code. In this case we send two empty static blocks instead
- * of one. (There are no problems if the previous block is stored or fixed.)
- * To simplify the code, we assume the worst case of last real code encoded
- * on one bit only.
- */
-void _tr_align(s)
- deflate_state *s;
-{
- send_bits(s, STATIC_TREES<<1, 3);
- send_code(s, END_BLOCK, static_ltree);
-#ifdef DEBUG
- s->compressed_len += 10L; /* 3 for block type, 7 for EOB */
-#endif
- bi_flush(s);
- /* Of the 10 bits for the empty block, we have already sent
- * (10 - bi_valid) bits. The lookahead for the last real code (before
- * the EOB of the previous block) was thus at least one plus the length
- * of the EOB plus what we have just sent of the empty static block.
- */
- if (1 + s->last_eob_len + 10 - s->bi_valid < 9) {
- send_bits(s, STATIC_TREES<<1, 3);
- send_code(s, END_BLOCK, static_ltree);
-#ifdef DEBUG
- s->compressed_len += 10L;
-#endif
- bi_flush(s);
- }
- s->last_eob_len = 7;
-}
-
-/* ===========================================================================
- * Determine the best encoding for the current block: dynamic trees, static
- * trees or store, and output the encoded block to the zip file.
- */
-void _tr_flush_block(s, buf, stored_len, eof)
- deflate_state *s;
- charf *buf; /* input block, or NULL if too old */
- ulg stored_len; /* length of input block */
- int eof; /* true if this is the last block for a file */
-{
- ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */
- int max_blindex = 0; /* index of last bit length code of non zero freq */
-
- /* Build the Huffman trees unless a stored block is forced */
- if (s->level > 0) {
-
- /* Check if the file is binary or text */
- if (stored_len > 0 && s->strm->data_type == Z_UNKNOWN)
- set_data_type(s);
-
- /* Construct the literal and distance trees */
- build_tree(s, (tree_desc *)(&(s->l_desc)));
- Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len,
- s->static_len));
-
- build_tree(s, (tree_desc *)(&(s->d_desc)));
- Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len,
- s->static_len));
- /* At this point, opt_len and static_len are the total bit lengths of
- * the compressed block data, excluding the tree representations.
- */
-
- /* Build the bit length tree for the above two trees, and get the index
- * in bl_order of the last bit length code to send.
- */
- max_blindex = build_bl_tree(s);
-
- /* Determine the best encoding. Compute the block lengths in bytes. */
- opt_lenb = (s->opt_len+3+7)>>3;
- static_lenb = (s->static_len+3+7)>>3;
-
- Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ",
- opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,
- s->last_lit));
-
- if (static_lenb <= opt_lenb) opt_lenb = static_lenb;
-
- } else {
- Assert(buf != (char*)0, "lost buf");
- opt_lenb = static_lenb = stored_len + 5; /* force a stored block */
- }
-
-#ifdef FORCE_STORED
- if (buf != (char*)0) { /* force stored block */
-#else
- if (stored_len+4 <= opt_lenb && buf != (char*)0) {
- /* 4: two words for the lengths */
-#endif
- /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.
- * Otherwise we can't have processed more than WSIZE input bytes since
- * the last block flush, because compression would have been
- * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to
- * transform a block into a stored block.
- */
- _tr_stored_block(s, buf, stored_len, eof);
-
-#ifdef FORCE_STATIC
- } else if (static_lenb >= 0) { /* force static trees */
-#else
- } else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) {
-#endif
- send_bits(s, (STATIC_TREES<<1)+eof, 3);
- compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree);
-#ifdef DEBUG
- s->compressed_len += 3 + s->static_len;
-#endif
- } else {
- send_bits(s, (DYN_TREES<<1)+eof, 3);
- send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1,
- max_blindex+1);
- compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree);
-#ifdef DEBUG
- s->compressed_len += 3 + s->opt_len;
-#endif
- }
- Assert (s->compressed_len == s->bits_sent, "bad compressed size");
- /* The above check is made mod 2^32, for files larger than 512 MB
- * and uLong implemented on 32 bits.
- */
- init_block(s);
-
- if (eof) {
- bi_windup(s);
-#ifdef DEBUG
- s->compressed_len += 7; /* align on byte boundary */
-#endif
- }
- Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3,
- s->compressed_len-7*eof));
-}
-
-/* ===========================================================================
- * Save the match info and tally the frequency counts. Return true if
- * the current block must be flushed.
- */
-int _tr_tally (s, dist, lc)
- deflate_state *s;
- unsigned dist; /* distance of matched string */
- unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */
-{
- s->d_buf[s->last_lit] = (ush)dist;
- s->l_buf[s->last_lit++] = (uch)lc;
- if (dist == 0) {
- /* lc is the unmatched char */
- s->dyn_ltree[lc].Freq++;
- } else {
- s->matches++;
- /* Here, lc is the match length - MIN_MATCH */
- dist--; /* dist = match distance - 1 */
- Assert((ush)dist < (ush)MAX_DIST(s) &&
- (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) &&
- (ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match");
-
- s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++;
- s->dyn_dtree[d_code(dist)].Freq++;
- }
-
-#ifdef TRUNCATE_BLOCK
- /* Try to guess if it is profitable to stop the current block here */
- if ((s->last_lit & 0x1fff) == 0 && s->level > 2) {
- /* Compute an upper bound for the compressed length */
- ulg out_length = (ulg)s->last_lit*8L;
- ulg in_length = (ulg)((long)s->strstart - s->block_start);
- int dcode;
- for (dcode = 0; dcode < D_CODES; dcode++) {
- out_length += (ulg)s->dyn_dtree[dcode].Freq *
- (5L+extra_dbits[dcode]);
- }
- out_length >>= 3;
- Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ",
- s->last_lit, in_length, out_length,
- 100L - out_length*100L/in_length));
- if (s->matches < s->last_lit/2 && out_length < in_length/2) return 1;
- }
-#endif
- return (s->last_lit == s->lit_bufsize-1);
- /* We avoid equality with lit_bufsize because of wraparound at 64K
- * on 16 bit machines and because stored blocks are restricted to
- * 64K-1 bytes.
- */
-}
-
-/* ===========================================================================
- * Send the block data compressed using the given Huffman trees
- */
-local void compress_block(s, ltree, dtree)
- deflate_state *s;
- ct_data *ltree; /* literal tree */
- ct_data *dtree; /* distance tree */
-{
- unsigned dist; /* distance of matched string */
- int lc; /* match length or unmatched char (if dist == 0) */
- unsigned lx = 0; /* running index in l_buf */
- unsigned code; /* the code to send */
- int extra; /* number of extra bits to send */
-
- if (s->last_lit != 0) do {
- dist = s->d_buf[lx];
- lc = s->l_buf[lx++];
- if (dist == 0) {
- send_code(s, lc, ltree); /* send a literal byte */
- Tracecv(isgraph(lc), (stderr," '%c' ", lc));
- } else {
- /* Here, lc is the match length - MIN_MATCH */
- code = _length_code[lc];
- send_code(s, code+LITERALS+1, ltree); /* send the length code */
- extra = extra_lbits[code];
- if (extra != 0) {
- lc -= base_length[code];
- send_bits(s, lc, extra); /* send the extra length bits */
- }
- dist--; /* dist is now the match distance - 1 */
- code = d_code(dist);
- Assert (code < D_CODES, "bad d_code");
-
- send_code(s, code, dtree); /* send the distance code */
- extra = extra_dbits[code];
- if (extra != 0) {
- dist -= base_dist[code];
- send_bits(s, dist, extra); /* send the extra distance bits */
- }
- } /* literal or match pair ? */
-
- /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */
- Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx,
- "pendingBuf overflow");
-
- } while (lx < s->last_lit);
-
- send_code(s, END_BLOCK, ltree);
- s->last_eob_len = ltree[END_BLOCK].Len;
-}
-
-/* ===========================================================================
- * Set the data type to BINARY or TEXT, using a crude approximation:
- * set it to Z_TEXT if all symbols are either printable characters (33 to 255)
- * or white spaces (9 to 13, or 32); or set it to Z_BINARY otherwise.
- * IN assertion: the fields Freq of dyn_ltree are set.
- */
-local void set_data_type(s)
- deflate_state *s;
-{
- int n;
-
- for (n = 0; n < 9; n++)
- if (s->dyn_ltree[n].Freq != 0)
- break;
- if (n == 9)
- for (n = 14; n < 32; n++)
- if (s->dyn_ltree[n].Freq != 0)
- break;
- s->strm->data_type = (n == 32) ? Z_TEXT : Z_BINARY;
-}
-
-/* ===========================================================================
- * Reverse the first len bits of a code, using straightforward code (a faster
- * method would use a table)
- * IN assertion: 1 <= len <= 15
- */
-local unsigned bi_reverse(code, len)
- unsigned code; /* the value to invert */
- int len; /* its bit length */
-{
- register unsigned res = 0;
- do {
- res |= code & 1;
- code >>= 1, res <<= 1;
- } while (--len > 0);
- return res >> 1;
-}
-
-/* ===========================================================================
- * Flush the bit buffer, keeping at most 7 bits in it.
- */
-local void bi_flush(s)
- deflate_state *s;
-{
- if (s->bi_valid == 16) {
- put_short(s, s->bi_buf);
- s->bi_buf = 0;
- s->bi_valid = 0;
- } else if (s->bi_valid >= 8) {
- put_byte(s, (Byte)s->bi_buf);
- s->bi_buf >>= 8;
- s->bi_valid -= 8;
- }
-}
-
-/* ===========================================================================
- * Flush the bit buffer and align the output on a byte boundary
- */
-local void bi_windup(s)
- deflate_state *s;
-{
- if (s->bi_valid > 8) {
- put_short(s, s->bi_buf);
- } else if (s->bi_valid > 0) {
- put_byte(s, (Byte)s->bi_buf);
- }
- s->bi_buf = 0;
- s->bi_valid = 0;
-#ifdef DEBUG
- s->bits_sent = (s->bits_sent+7) & ~7;
-#endif
-}
-
-/* ===========================================================================
- * Copy a stored block, storing first the length and its
- * one's complement if requested.
- */
-local void copy_block(s, buf, len, header)
- deflate_state *s;
- charf *buf; /* the input data */
- unsigned len; /* its length */
- int header; /* true if block header must be written */
-{
- bi_windup(s); /* align on byte boundary */
- s->last_eob_len = 8; /* enough lookahead for inflate */
-
- if (header) {
- put_short(s, (ush)len);
- put_short(s, (ush)~len);
-#ifdef DEBUG
- s->bits_sent += 2*16;
-#endif
- }
-#ifdef DEBUG
- s->bits_sent += (ulg)len<<3;
-#endif
- while (len--) {
- put_byte(s, *buf++);
- }
-}
diff --git a/WebCore/platform/image-decoders/zlib/trees.h b/WebCore/platform/image-decoders/zlib/trees.h
deleted file mode 100644
index 72facf9..0000000
--- a/WebCore/platform/image-decoders/zlib/trees.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/* header created automatically with -DGEN_TREES_H */
-
-local const ct_data static_ltree[L_CODES+2] = {
-{{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}},
-{{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}},
-{{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}},
-{{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}},
-{{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}},
-{{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}},
-{{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}},
-{{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}},
-{{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}},
-{{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}},
-{{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}},
-{{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}},
-{{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}},
-{{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}},
-{{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}},
-{{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}},
-{{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}},
-{{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}},
-{{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}},
-{{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}},
-{{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}},
-{{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}},
-{{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}},
-{{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}},
-{{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}},
-{{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}},
-{{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}},
-{{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}},
-{{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}},
-{{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}},
-{{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}},
-{{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}},
-{{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}},
-{{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}},
-{{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}},
-{{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}},
-{{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}},
-{{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}},
-{{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}},
-{{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}},
-{{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}},
-{{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}},
-{{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}},
-{{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}},
-{{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}},
-{{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}},
-{{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}},
-{{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}},
-{{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}},
-{{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}},
-{{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}},
-{{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}},
-{{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}},
-{{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}},
-{{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}},
-{{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}},
-{{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}},
-{{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}}
-};
-
-local const ct_data static_dtree[D_CODES] = {
-{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}},
-{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}},
-{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}},
-{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}},
-{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}},
-{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}}
-};
-
-const uch _dist_code[DIST_CODE_LEN] = {
- 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8,
- 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10,
-10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
-11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
-12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13,
-13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
-13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
-14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
-14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
-14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15,
-15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
-15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
-15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17,
-18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22,
-23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
-24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
-26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
-26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27,
-27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
-27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29
-};
-
-const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12,
-13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16,
-17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19,
-19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
-21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22,
-22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23,
-23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
-24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
-25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
-25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26,
-26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
-26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
-27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28
-};
-
-local const int base_length[LENGTH_CODES] = {
-0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56,
-64, 80, 96, 112, 128, 160, 192, 224, 0
-};
-
-local const int base_dist[D_CODES] = {
- 0, 1, 2, 3, 4, 6, 8, 12, 16, 24,
- 32, 48, 64, 96, 128, 192, 256, 384, 512, 768,
- 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576
-};
-
diff --git a/WebCore/platform/image-decoders/zlib/uncompr.c b/WebCore/platform/image-decoders/zlib/uncompr.c
deleted file mode 100644
index c3d7716..0000000
--- a/WebCore/platform/image-decoders/zlib/uncompr.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/* uncompr.c -- decompress a memory buffer
- * Copyright (C) 1995-2003 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* @(#) $Id: uncompr.c,v 3.6 2005/08/04 19:14:14 tor%cs.brown.edu Exp $ */
-
-#define ZLIB_INTERNAL
-#include "zlib.h"
-
-/* ===========================================================================
- Decompresses the source buffer into the destination buffer. sourceLen is
- the byte length of the source buffer. Upon entry, destLen is the total
- size of the destination buffer, which must be large enough to hold the
- entire uncompressed data. (The size of the uncompressed data must have
- been saved previously by the compressor and transmitted to the decompressor
- by some mechanism outside the scope of this compression library.)
- Upon exit, destLen is the actual size of the compressed buffer.
- This function can be used to decompress a whole file at once if the
- input file is mmap'ed.
-
- uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_BUF_ERROR if there was not enough room in the output
- buffer, or Z_DATA_ERROR if the input data was corrupted.
-*/
-int ZEXPORT uncompress (dest, destLen, source, sourceLen)
- Bytef *dest;
- uLongf *destLen;
- const Bytef *source;
- uLong sourceLen;
-{
- z_stream stream;
- int err;
-
- stream.next_in = (Bytef*)source;
- stream.avail_in = (uInt)sourceLen;
- /* Check for source > 64K on 16-bit machine: */
- if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
-
- stream.next_out = dest;
- stream.avail_out = (uInt)*destLen;
- if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
-
- stream.zalloc = (alloc_func)0;
- stream.zfree = (free_func)0;
-
- err = inflateInit(&stream);
- if (err != Z_OK) return err;
-
- err = inflate(&stream, Z_FINISH);
- if (err != Z_STREAM_END) {
- inflateEnd(&stream);
- if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0))
- return Z_DATA_ERROR;
- return err;
- }
- *destLen = stream.total_out;
-
- err = inflateEnd(&stream);
- return err;
-}
diff --git a/WebCore/platform/image-decoders/zlib/zconf.h b/WebCore/platform/image-decoders/zlib/zconf.h
deleted file mode 100644
index b0e17bb..0000000
--- a/WebCore/platform/image-decoders/zlib/zconf.h
+++ /dev/null
@@ -1,335 +0,0 @@
-/* zconf.h -- configuration of the zlib compression library
- * Copyright (C) 1995-2005 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* @(#) $Id: zconf.h,v 3.9 2005/08/04 19:14:14 tor%cs.brown.edu Exp $ */
-
-#ifndef ZCONF_H
-#define ZCONF_H
-
-/* This include does prefixing as below, but with an updated set of names */
-#include "mozzconf.h"
-
-/*
- * If you *really* need a unique prefix for all types and library functions,
- * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
- */
-#ifdef Z_PREFIX
-# define deflateInit_ z_deflateInit_
-# define deflate z_deflate
-# define deflateEnd z_deflateEnd
-# define inflateInit_ z_inflateInit_
-# define inflate z_inflate
-# define inflateEnd z_inflateEnd
-# define deflateInit2_ z_deflateInit2_
-# define deflateSetDictionary z_deflateSetDictionary
-# define deflateCopy z_deflateCopy
-# define deflateReset z_deflateReset
-# define deflateParams z_deflateParams
-# define deflateBound z_deflateBound
-# define deflatePrime z_deflatePrime
-# define inflateInit2_ z_inflateInit2_
-# define inflateSetDictionary z_inflateSetDictionary
-# define inflateSync z_inflateSync
-# define inflateSyncPoint z_inflateSyncPoint
-# define inflateCopy z_inflateCopy
-# define inflateReset z_inflateReset
-# define inflateBack z_inflateBack
-# define inflateBackEnd z_inflateBackEnd
-# define compress z_compress
-# define compress2 z_compress2
-# define compressBound z_compressBound
-# define uncompress z_uncompress
-# define adler32 z_adler32
-# define crc32 z_crc32
-# define get_crc_table z_get_crc_table
-# define zError z_zError
-
-# define alloc_func z_alloc_func
-# define free_func z_free_func
-# define in_func z_in_func
-# define out_func z_out_func
-# define Byte z_Byte
-# define uInt z_uInt
-# define uLong z_uLong
-# define Bytef z_Bytef
-# define charf z_charf
-# define intf z_intf
-# define uIntf z_uIntf
-# define uLongf z_uLongf
-# define voidpf z_voidpf
-# define voidp z_voidp
-#endif
-
-#if defined(__MSDOS__) && !defined(MSDOS)
-# define MSDOS
-#endif
-#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
-# define OS2
-#endif
-#if defined(_WINDOWS) && !defined(WINDOWS)
-# define WINDOWS
-#endif
-#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
-# ifndef WIN32
-# define WIN32
-# endif
-#endif
-#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
-# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
-# ifndef SYS16BIT
-# define SYS16BIT
-# endif
-# endif
-#endif
-
-/*
- * Compile with -DMAXSEG_64K if the alloc function cannot allocate more
- * than 64k bytes at a time (needed on systems with 16-bit int).
- */
-#ifdef SYS16BIT
-# define MAXSEG_64K
-#endif
-#ifdef MSDOS
-# define UNALIGNED_OK
-#endif
-
-#ifdef __STDC_VERSION__
-# ifndef STDC
-# define STDC
-# endif
-# if __STDC_VERSION__ >= 199901L
-# ifndef STDC99
-# define STDC99
-# endif
-# endif
-#endif
-#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
-# define STDC
-#endif
-#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
-# define STDC
-#endif
-#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
-# define STDC
-#endif
-#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
-# define STDC
-#endif
-
-#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */
-# define STDC
-#endif
-
-#ifndef STDC
-# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
-# define const /* note: need a more gentle solution here */
-# endif
-#endif
-
-/* Some Mac compilers merge all .h files incorrectly: */
-#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
-# define NO_DUMMY_DECL
-#endif
-
-/* Maximum value for memLevel in deflateInit2 */
-#ifndef MAX_MEM_LEVEL
-# ifdef MAXSEG_64K
-# define MAX_MEM_LEVEL 8
-# else
-# define MAX_MEM_LEVEL 9
-# endif
-#endif
-
-/* Maximum value for windowBits in deflateInit2 and inflateInit2.
- * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
- * created by gzip. (Files created by minigzip can still be extracted by
- * gzip.)
- */
-#ifndef MAX_WBITS
-# define MAX_WBITS 15 /* 32K LZ77 window */
-#endif
-
-/* The memory requirements for deflate are (in bytes):
- (1 << (windowBits+2)) + (1 << (memLevel+9))
- that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
- plus a few kilobytes for small objects. For example, if you want to reduce
- the default memory requirements from 256K to 128K, compile with
- make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
- Of course this will generally degrade compression (there's no free lunch).
-
- The memory requirements for inflate are (in bytes) 1 << windowBits
- that is, 32K for windowBits=15 (default value) plus a few kilobytes
- for small objects.
-*/
-
- /* Type declarations */
-
-#ifndef OF /* function prototypes */
-# ifdef STDC
-# define OF(args) args
-# else
-# define OF(args) ()
-# endif
-#endif
-
-/* The following definitions for FAR are needed only for MSDOS mixed
- * model programming (small or medium model with some far allocations).
- * This was tested only with MSC; for other MSDOS compilers you may have
- * to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
- * just define FAR to be empty.
- */
-#ifdef SYS16BIT
-# if defined(M_I86SM) || defined(M_I86MM)
- /* MSC small or medium model */
-# define SMALL_MEDIUM
-# ifdef _MSC_VER
-# define FAR _far
-# else
-# define FAR far
-# endif
-# endif
-# if (defined(__SMALL__) || defined(__MEDIUM__))
- /* Turbo C small or medium model */
-# define SMALL_MEDIUM
-# ifdef __BORLANDC__
-# define FAR _far
-# else
-# define FAR far
-# endif
-# endif
-#endif
-
-#if defined(WINDOWS) || defined(WIN32)
- /* If building or using zlib as a DLL, define ZLIB_DLL.
- * This is not mandatory, but it offers a little performance increase.
- */
-# ifdef ZLIB_DLL
-# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
-# ifdef ZLIB_INTERNAL
-# define ZEXTERN extern __declspec(dllexport)
-# else
-# define ZEXTERN extern __declspec(dllimport)
-# endif
-# endif
-# endif /* ZLIB_DLL */
- /* If building or using zlib with the WINAPI/WINAPIV calling convention,
- * define ZLIB_WINAPI.
- * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
- */
-# ifdef ZLIB_WINAPI
-# ifdef FAR
-# undef FAR
-# endif
-# include <windows.h>
- /* No need for _export, use ZLIB.DEF instead. */
- /* For complete Windows compatibility, use WINAPI, not __stdcall. */
-# define ZEXPORT WINAPI
-# ifdef WIN32
-# define ZEXPORTVA WINAPIV
-# else
-# define ZEXPORTVA FAR CDECL
-# endif
-# endif
-#endif
-
-#if defined (__BEOS__)
-# ifdef ZLIB_DLL
-# ifdef ZLIB_INTERNAL
-# define ZEXPORT __declspec(dllexport)
-# define ZEXPORTVA __declspec(dllexport)
-# else
-# define ZEXPORT __declspec(dllimport)
-# define ZEXPORTVA __declspec(dllimport)
-# endif
-# endif
-#endif
-
-#ifndef ZEXTERN
-# define ZEXTERN extern
-#endif
-#ifndef ZEXPORT
-# define ZEXPORT
-#endif
-#ifndef ZEXPORTVA
-# define ZEXPORTVA
-#endif
-
-#ifndef FAR
-# define FAR
-#endif
-
-#if !defined(__MACTYPES__)
-typedef unsigned char Byte; /* 8 bits */
-#endif
-typedef unsigned int uInt; /* 16 bits or more */
-typedef unsigned long uLong; /* 32 bits or more */
-
-#ifdef SMALL_MEDIUM
- /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
-# define Bytef Byte FAR
-#else
- typedef Byte FAR Bytef;
-#endif
-typedef char FAR charf;
-typedef int FAR intf;
-typedef uInt FAR uIntf;
-typedef uLong FAR uLongf;
-
-#ifdef STDC
- typedef void const *voidpc;
- typedef void FAR *voidpf;
- typedef void *voidp;
-#else
- typedef Byte const *voidpc;
- typedef Byte FAR *voidpf;
- typedef Byte *voidp;
-#endif
-
-#if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */
-# include <sys/types.h> /* for off_t */
-# include <unistd.h> /* for SEEK_* and off_t */
-# ifdef VMS
-# include <unixio.h> /* for off_t */
-# endif
-# define z_off_t off_t
-#endif
-#ifndef SEEK_SET
-# define SEEK_SET 0 /* Seek from beginning of file. */
-# define SEEK_CUR 1 /* Seek from current position. */
-# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
-#endif
-#ifndef z_off_t
-# define z_off_t long
-#endif
-
-#if defined(__OS400__)
-# define NO_vsnprintf
-#endif
-
-#if defined(__MVS__)
-# define NO_vsnprintf
-# ifdef FAR
-# undef FAR
-# endif
-#endif
-
-/* MVS linker does not support external names larger than 8 bytes */
-#if defined(__MVS__)
-# pragma map(deflateInit_,"DEIN")
-# pragma map(deflateInit2_,"DEIN2")
-# pragma map(deflateEnd,"DEEND")
-# pragma map(deflateBound,"DEBND")
-# pragma map(inflateInit_,"ININ")
-# pragma map(inflateInit2_,"ININ2")
-# pragma map(inflateEnd,"INEND")
-# pragma map(inflateSync,"INSY")
-# pragma map(inflateSetDictionary,"INSEDI")
-# pragma map(compressBound,"CMBND")
-# pragma map(inflate_table,"INTABL")
-# pragma map(inflate_fast,"INFA")
-# pragma map(inflate_copyright,"INCOPY")
-#endif
-
-#endif /* ZCONF_H */
diff --git a/WebCore/platform/image-decoders/zlib/zlib.h b/WebCore/platform/image-decoders/zlib/zlib.h
deleted file mode 100644
index 0228179..0000000
--- a/WebCore/platform/image-decoders/zlib/zlib.h
+++ /dev/null
@@ -1,1357 +0,0 @@
-/* zlib.h -- interface of the 'zlib' general purpose compression library
- version 1.2.3, July 18th, 2005
-
- Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-
- Jean-loup Gailly Mark Adler
- jloup@gzip.org madler@alumni.caltech.edu
-
-
- The data format used by the zlib library is described by RFCs (Request for
- Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt
- (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
-*/
-
-#ifndef ZLIB_H
-#define ZLIB_H
-
-#include "zconf.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define ZLIB_VERSION "1.2.3"
-#define ZLIB_VERNUM 0x1230
-
-/*
- The 'zlib' compression library provides in-memory compression and
- decompression functions, including integrity checks of the uncompressed
- data. This version of the library supports only one compression method
- (deflation) but other algorithms will be added later and will have the same
- stream interface.
-
- Compression can be done in a single step if the buffers are large
- enough (for example if an input file is mmap'ed), or can be done by
- repeated calls of the compression function. In the latter case, the
- application must provide more input and/or consume the output
- (providing more output space) before each call.
-
- The compressed data format used by default by the in-memory functions is
- the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped
- around a deflate stream, which is itself documented in RFC 1951.
-
- The library also supports reading and writing files in gzip (.gz) format
- with an interface similar to that of stdio using the functions that start
- with "gz". The gzip format is different from the zlib format. gzip is a
- gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.
-
- This library can optionally read and write gzip streams in memory as well.
-
- The zlib format was designed to be compact and fast for use in memory
- and on communications channels. The gzip format was designed for single-
- file compression on file systems, has a larger header than zlib to maintain
- directory information, and uses a different, slower check method than zlib.
-
- The library does not install any signal handler. The decoder checks
- the consistency of the compressed data, so the library should never
- crash even in case of corrupted input.
-*/
-
-typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
-typedef void (*free_func) OF((voidpf opaque, voidpf address));
-
-struct internal_state;
-
-typedef struct z_stream_s {
- Bytef *next_in; /* next input byte */
- uInt avail_in; /* number of bytes available at next_in */
- uLong total_in; /* total nb of input bytes read so far */
-
- Bytef *next_out; /* next output byte should be put there */
- uInt avail_out; /* remaining free space at next_out */
- uLong total_out; /* total nb of bytes output so far */
-
- char *msg; /* last error message, NULL if no error */
- struct internal_state FAR *state; /* not visible by applications */
-
- alloc_func zalloc; /* used to allocate the internal state */
- free_func zfree; /* used to free the internal state */
- voidpf opaque; /* private data object passed to zalloc and zfree */
-
- int data_type; /* best guess about the data type: binary or text */
- uLong adler; /* adler32 value of the uncompressed data */
- uLong reserved; /* reserved for future use */
-} z_stream;
-
-typedef z_stream FAR *z_streamp;
-
-/*
- gzip header information passed to and from zlib routines. See RFC 1952
- for more details on the meanings of these fields.
-*/
-typedef struct gz_header_s {
- int text; /* true if compressed data believed to be text */
- uLong time; /* modification time */
- int xflags; /* extra flags (not used when writing a gzip file) */
- int os; /* operating system */
- Bytef *extra; /* pointer to extra field or Z_NULL if none */
- uInt extra_len; /* extra field length (valid if extra != Z_NULL) */
- uInt extra_max; /* space at extra (only when reading header) */
- Bytef *name; /* pointer to zero-terminated file name or Z_NULL */
- uInt name_max; /* space at name (only when reading header) */
- Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */
- uInt comm_max; /* space at comment (only when reading header) */
- int hcrc; /* true if there was or will be a header crc */
- int done; /* true when done reading gzip header (not used
- when writing a gzip file) */
-} gz_header;
-
-typedef gz_header FAR *gz_headerp;
-
-/*
- The application must update next_in and avail_in when avail_in has
- dropped to zero. It must update next_out and avail_out when avail_out
- has dropped to zero. The application must initialize zalloc, zfree and
- opaque before calling the init function. All other fields are set by the
- compression library and must not be updated by the application.
-
- The opaque value provided by the application will be passed as the first
- parameter for calls of zalloc and zfree. This can be useful for custom
- memory management. The compression library attaches no meaning to the
- opaque value.
-
- zalloc must return Z_NULL if there is not enough memory for the object.
- If zlib is used in a multi-threaded application, zalloc and zfree must be
- thread safe.
-
- On 16-bit systems, the functions zalloc and zfree must be able to allocate
- exactly 65536 bytes, but will not be required to allocate more than this
- if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS,
- pointers returned by zalloc for objects of exactly 65536 bytes *must*
- have their offset normalized to zero. The default allocation function
- provided by this library ensures this (see zutil.c). To reduce memory
- requirements and avoid any allocation of 64K objects, at the expense of
- compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h).
-
- The fields total_in and total_out can be used for statistics or
- progress reports. After compression, total_in holds the total size of
- the uncompressed data and may be saved for use in the decompressor
- (particularly if the decompressor wants to decompress everything in
- a single step).
-*/
-
- /* constants */
-
-#define Z_NO_FLUSH 0
-#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */
-#define Z_SYNC_FLUSH 2
-#define Z_FULL_FLUSH 3
-#define Z_FINISH 4
-#define Z_BLOCK 5
-/* Allowed flush values; see deflate() and inflate() below for details */
-
-#define Z_OK 0
-#define Z_STREAM_END 1
-#define Z_NEED_DICT 2
-#define Z_ERRNO (-1)
-#define Z_STREAM_ERROR (-2)
-#define Z_DATA_ERROR (-3)
-#define Z_MEM_ERROR (-4)
-#define Z_BUF_ERROR (-5)
-#define Z_VERSION_ERROR (-6)
-/* Return codes for the compression/decompression functions. Negative
- * values are errors, positive values are used for special but normal events.
- */
-
-#define Z_NO_COMPRESSION 0
-#define Z_BEST_SPEED 1
-#define Z_BEST_COMPRESSION 9
-#define Z_DEFAULT_COMPRESSION (-1)
-/* compression levels */
-
-#define Z_FILTERED 1
-#define Z_HUFFMAN_ONLY 2
-#define Z_RLE 3
-#define Z_FIXED 4
-#define Z_DEFAULT_STRATEGY 0
-/* compression strategy; see deflateInit2() below for details */
-
-#define Z_BINARY 0
-#define Z_TEXT 1
-#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */
-#define Z_UNKNOWN 2
-/* Possible values of the data_type field (though see inflate()) */
-
-#define Z_DEFLATED 8
-/* The deflate compression method (the only one supported in this version) */
-
-#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */
-
-#define zlib_version zlibVersion()
-/* for compatibility with versions < 1.0.2 */
-
- /* basic functions */
-
-ZEXTERN const char * ZEXPORT zlibVersion OF((void));
-/* The application can compare zlibVersion and ZLIB_VERSION for consistency.
- If the first character differs, the library code actually used is
- not compatible with the zlib.h header file used by the application.
- This check is automatically made by deflateInit and inflateInit.
- */
-
-/*
-ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));
-
- Initializes the internal stream state for compression. The fields
- zalloc, zfree and opaque must be initialized before by the caller.
- If zalloc and zfree are set to Z_NULL, deflateInit updates them to
- use default allocation functions.
-
- The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
- 1 gives best speed, 9 gives best compression, 0 gives no compression at
- all (the input data is simply copied a block at a time).
- Z_DEFAULT_COMPRESSION requests a default compromise between speed and
- compression (currently equivalent to level 6).
-
- deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_STREAM_ERROR if level is not a valid compression level,
- Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible
- with the version assumed by the caller (ZLIB_VERSION).
- msg is set to null if there is no error message. deflateInit does not
- perform any compression: this will be done by deflate().
-*/
-
-
-ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
-/*
- deflate compresses as much data as possible, and stops when the input
- buffer becomes empty or the output buffer becomes full. It may introduce some
- output latency (reading input without producing any output) except when
- forced to flush.
-
- The detailed semantics are as follows. deflate performs one or both of the
- following actions:
-
- - Compress more input starting at next_in and update next_in and avail_in
- accordingly. If not all input can be processed (because there is not
- enough room in the output buffer), next_in and avail_in are updated and
- processing will resume at this point for the next call of deflate().
-
- - Provide more output starting at next_out and update next_out and avail_out
- accordingly. This action is forced if the parameter flush is non zero.
- Forcing flush frequently degrades the compression ratio, so this parameter
- should be set only when necessary (in interactive applications).
- Some output may be provided even if flush is not set.
-
- Before the call of deflate(), the application should ensure that at least
- one of the actions is possible, by providing more input and/or consuming
- more output, and updating avail_in or avail_out accordingly; avail_out
- should never be zero before the call. The application can consume the
- compressed output when it wants, for example when the output buffer is full
- (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK
- and with zero avail_out, it must be called again after making room in the
- output buffer because there might be more output pending.
-
- Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to
- decide how much data to accumualte before producing output, in order to
- maximize compression.
-
- If the parameter flush is set to Z_SYNC_FLUSH, all pending output is
- flushed to the output buffer and the output is aligned on a byte boundary, so
- that the decompressor can get all input data available so far. (In particular
- avail_in is zero after the call if enough output space has been provided
- before the call.) Flushing may degrade compression for some compression
- algorithms and so it should be used only when necessary.
-
- If flush is set to Z_FULL_FLUSH, all output is flushed as with
- Z_SYNC_FLUSH, and the compression state is reset so that decompression can
- restart from this point if previous compressed data has been damaged or if
- random access is desired. Using Z_FULL_FLUSH too often can seriously degrade
- compression.
-
- If deflate returns with avail_out == 0, this function must be called again
- with the same value of the flush parameter and more output space (updated
- avail_out), until the flush is complete (deflate returns with non-zero
- avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that
- avail_out is greater than six to avoid repeated flush markers due to
- avail_out == 0 on return.
-
- If the parameter flush is set to Z_FINISH, pending input is processed,
- pending output is flushed and deflate returns with Z_STREAM_END if there
- was enough output space; if deflate returns with Z_OK, this function must be
- called again with Z_FINISH and more output space (updated avail_out) but no
- more input data, until it returns with Z_STREAM_END or an error. After
- deflate has returned Z_STREAM_END, the only possible operations on the
- stream are deflateReset or deflateEnd.
-
- Z_FINISH can be used immediately after deflateInit if all the compression
- is to be done in a single step. In this case, avail_out must be at least
- the value returned by deflateBound (see below). If deflate does not return
- Z_STREAM_END, then it must be called again as described above.
-
- deflate() sets strm->adler to the adler32 checksum of all input read
- so far (that is, total_in bytes).
-
- deflate() may update strm->data_type if it can make a good guess about
- the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered
- binary. This field is only for information purposes and does not affect
- the compression algorithm in any manner.
-
- deflate() returns Z_OK if some progress has been made (more input
- processed or more output produced), Z_STREAM_END if all input has been
- consumed and all output has been produced (only when flush is set to
- Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
- if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible
- (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not
- fatal, and deflate() can be called again with more input and more output
- space to continue compressing.
-*/
-
-
-ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
-/*
- All dynamically allocated data structures for this stream are freed.
- This function discards any unprocessed input and does not flush any
- pending output.
-
- deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
- stream state was inconsistent, Z_DATA_ERROR if the stream was freed
- prematurely (some input or output was discarded). In the error case,
- msg may be set but then points to a static string (which must not be
- deallocated).
-*/
-
-
-/*
-ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
-
- Initializes the internal stream state for decompression. The fields
- next_in, avail_in, zalloc, zfree and opaque must be initialized before by
- the caller. If next_in is not Z_NULL and avail_in is large enough (the exact
- value depends on the compression method), inflateInit determines the
- compression method from the zlib header and allocates all data structures
- accordingly; otherwise the allocation will be deferred to the first call of
- inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to
- use default allocation functions.
-
- inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
- memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
- version assumed by the caller. msg is set to null if there is no error
- message. inflateInit does not perform any decompression apart from reading
- the zlib header if present: this will be done by inflate(). (So next_in and
- avail_in may be modified, but next_out and avail_out are unchanged.)
-*/
-
-
-ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
-/*
- inflate decompresses as much data as possible, and stops when the input
- buffer becomes empty or the output buffer becomes full. It may introduce
- some output latency (reading input without producing any output) except when
- forced to flush.
-
- The detailed semantics are as follows. inflate performs one or both of the
- following actions:
-
- - Decompress more input starting at next_in and update next_in and avail_in
- accordingly. If not all input can be processed (because there is not
- enough room in the output buffer), next_in is updated and processing
- will resume at this point for the next call of inflate().
-
- - Provide more output starting at next_out and update next_out and avail_out
- accordingly. inflate() provides as much output as possible, until there
- is no more input data or no more space in the output buffer (see below
- about the flush parameter).
-
- Before the call of inflate(), the application should ensure that at least
- one of the actions is possible, by providing more input and/or consuming
- more output, and updating the next_* and avail_* values accordingly.
- The application can consume the uncompressed output when it wants, for
- example when the output buffer is full (avail_out == 0), or after each
- call of inflate(). If inflate returns Z_OK and with zero avail_out, it
- must be called again after making room in the output buffer because there
- might be more output pending.
-
- The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH,
- Z_FINISH, or Z_BLOCK. Z_SYNC_FLUSH requests that inflate() flush as much
- output as possible to the output buffer. Z_BLOCK requests that inflate() stop
- if and when it gets to the next deflate block boundary. When decoding the
- zlib or gzip format, this will cause inflate() to return immediately after
- the header and before the first block. When doing a raw inflate, inflate()
- will go ahead and process the first block, and will return when it gets to
- the end of that block, or when it runs out of data.
-
- The Z_BLOCK option assists in appending to or combining deflate streams.
- Also to assist in this, on return inflate() will set strm->data_type to the
- number of unused bits in the last byte taken from strm->next_in, plus 64
- if inflate() is currently decoding the last block in the deflate stream,
- plus 128 if inflate() returned immediately after decoding an end-of-block
- code or decoding the complete header up to just before the first byte of the
- deflate stream. The end-of-block will not be indicated until all of the
- uncompressed data from that block has been written to strm->next_out. The
- number of unused bits may in general be greater than seven, except when
- bit 7 of data_type is set, in which case the number of unused bits will be
- less than eight.
-
- inflate() should normally be called until it returns Z_STREAM_END or an
- error. However if all decompression is to be performed in a single step
- (a single call of inflate), the parameter flush should be set to
- Z_FINISH. In this case all pending input is processed and all pending
- output is flushed; avail_out must be large enough to hold all the
- uncompressed data. (The size of the uncompressed data may have been saved
- by the compressor for this purpose.) The next operation on this stream must
- be inflateEnd to deallocate the decompression state. The use of Z_FINISH
- is never required, but can be used to inform inflate that a faster approach
- may be used for the single inflate() call.
-
- In this implementation, inflate() always flushes as much output as
- possible to the output buffer, and always uses the faster approach on the
- first call. So the only effect of the flush parameter in this implementation
- is on the return value of inflate(), as noted below, or when it returns early
- because Z_BLOCK is used.
-
- If a preset dictionary is needed after this call (see inflateSetDictionary
- below), inflate sets strm->adler to the adler32 checksum of the dictionary
- chosen by the compressor and returns Z_NEED_DICT; otherwise it sets
- strm->adler to the adler32 checksum of all output produced so far (that is,
- total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described
- below. At the end of the stream, inflate() checks that its computed adler32
- checksum is equal to that saved by the compressor and returns Z_STREAM_END
- only if the checksum is correct.
-
- inflate() will decompress and check either zlib-wrapped or gzip-wrapped
- deflate data. The header type is detected automatically. Any information
- contained in the gzip header is not retained, so applications that need that
- information should instead use raw inflate, see inflateInit2() below, or
- inflateBack() and perform their own processing of the gzip header and
- trailer.
-
- inflate() returns Z_OK if some progress has been made (more input processed
- or more output produced), Z_STREAM_END if the end of the compressed data has
- been reached and all uncompressed output has been produced, Z_NEED_DICT if a
- preset dictionary is needed at this point, Z_DATA_ERROR if the input data was
- corrupted (input stream not conforming to the zlib format or incorrect check
- value), Z_STREAM_ERROR if the stream structure was inconsistent (for example
- if next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory,
- Z_BUF_ERROR if no progress is possible or if there was not enough room in the
- output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and
- inflate() can be called again with more input and more output space to
- continue decompressing. If Z_DATA_ERROR is returned, the application may then
- call inflateSync() to look for a good compression block if a partial recovery
- of the data is desired.
-*/
-
-
-ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
-/*
- All dynamically allocated data structures for this stream are freed.
- This function discards any unprocessed input and does not flush any
- pending output.
-
- inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state
- was inconsistent. In the error case, msg may be set but then points to a
- static string (which must not be deallocated).
-*/
-
- /* Advanced functions */
-
-/*
- The following functions are needed only in some special applications.
-*/
-
-/*
-ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
- int level,
- int method,
- int windowBits,
- int memLevel,
- int strategy));
-
- This is another version of deflateInit with more compression options. The
- fields next_in, zalloc, zfree and opaque must be initialized before by
- the caller.
-
- The method parameter is the compression method. It must be Z_DEFLATED in
- this version of the library.
-
- The windowBits parameter is the base two logarithm of the window size
- (the size of the history buffer). It should be in the range 8..15 for this
- version of the library. Larger values of this parameter result in better
- compression at the expense of memory usage. The default value is 15 if
- deflateInit is used instead.
-
- windowBits can also be -8..-15 for raw deflate. In this case, -windowBits
- determines the window size. deflate() will then generate raw deflate data
- with no zlib header or trailer, and will not compute an adler32 check value.
-
- windowBits can also be greater than 15 for optional gzip encoding. Add
- 16 to windowBits to write a simple gzip header and trailer around the
- compressed data instead of a zlib wrapper. The gzip header will have no
- file name, no extra data, no comment, no modification time (set to zero),
- no header crc, and the operating system will be set to 255 (unknown). If a
- gzip stream is being written, strm->adler is a crc32 instead of an adler32.
-
- The memLevel parameter specifies how much memory should be allocated
- for the internal compression state. memLevel=1 uses minimum memory but
- is slow and reduces compression ratio; memLevel=9 uses maximum memory
- for optimal speed. The default value is 8. See zconf.h for total memory
- usage as a function of windowBits and memLevel.
-
- The strategy parameter is used to tune the compression algorithm. Use the
- value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
- filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no
- string match), or Z_RLE to limit match distances to one (run-length
- encoding). Filtered data consists mostly of small values with a somewhat
- random distribution. In this case, the compression algorithm is tuned to
- compress them better. The effect of Z_FILTERED is to force more Huffman
- coding and less string matching; it is somewhat intermediate between
- Z_DEFAULT and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as fast as
- Z_HUFFMAN_ONLY, but give better compression for PNG image data. The strategy
- parameter only affects the compression ratio but not the correctness of the
- compressed output even if it is not set appropriately. Z_FIXED prevents the
- use of dynamic Huffman codes, allowing for a simpler decoder for special
- applications.
-
- deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
- memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid
- method). msg is set to null if there is no error message. deflateInit2 does
- not perform any compression: this will be done by deflate().
-*/
-
-ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
- const Bytef *dictionary,
- uInt dictLength));
-/*
- Initializes the compression dictionary from the given byte sequence
- without producing any compressed output. This function must be called
- immediately after deflateInit, deflateInit2 or deflateReset, before any
- call of deflate. The compressor and decompressor must use exactly the same
- dictionary (see inflateSetDictionary).
-
- The dictionary should consist of strings (byte sequences) that are likely
- to be encountered later in the data to be compressed, with the most commonly
- used strings preferably put towards the end of the dictionary. Using a
- dictionary is most useful when the data to be compressed is short and can be
- predicted with good accuracy; the data can then be compressed better than
- with the default empty dictionary.
-
- Depending on the size of the compression data structures selected by
- deflateInit or deflateInit2, a part of the dictionary may in effect be
- discarded, for example if the dictionary is larger than the window size in
- deflate or deflate2. Thus the strings most likely to be useful should be
- put at the end of the dictionary, not at the front. In addition, the
- current implementation of deflate will use at most the window size minus
- 262 bytes of the provided dictionary.
-
- Upon return of this function, strm->adler is set to the adler32 value
- of the dictionary; the decompressor may later use this value to determine
- which dictionary has been used by the compressor. (The adler32 value
- applies to the whole dictionary even if only a subset of the dictionary is
- actually used by the compressor.) If a raw deflate was requested, then the
- adler32 value is not computed and strm->adler is not set.
-
- deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
- parameter is invalid (such as NULL dictionary) or the stream state is
- inconsistent (for example if deflate has already been called for this stream
- or if the compression method is bsort). deflateSetDictionary does not
- perform any compression: this will be done by deflate().
-*/
-
-ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
- z_streamp source));
-/*
- Sets the destination stream as a complete copy of the source stream.
-
- This function can be useful when several compression strategies will be
- tried, for example when there are several ways of pre-processing the input
- data with a filter. The streams that will be discarded should then be freed
- by calling deflateEnd. Note that deflateCopy duplicates the internal
- compression state which can be quite large, so this strategy is slow and
- can consume lots of memory.
-
- deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
- (such as zalloc being NULL). msg is left unchanged in both source and
- destination.
-*/
-
-ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
-/*
- This function is equivalent to deflateEnd followed by deflateInit,
- but does not free and reallocate all the internal compression state.
- The stream will keep the same compression level and any other attributes
- that may have been set by deflateInit2.
-
- deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
- stream state was inconsistent (such as zalloc or state being NULL).
-*/
-
-ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
- int level,
- int strategy));
-/*
- Dynamically update the compression level and compression strategy. The
- interpretation of level and strategy is as in deflateInit2. This can be
- used to switch between compression and straight copy of the input data, or
- to switch to a different kind of input data requiring a different
- strategy. If the compression level is changed, the input available so far
- is compressed with the old level (and may be flushed); the new level will
- take effect only at the next call of deflate().
-
- Before the call of deflateParams, the stream state must be set as for
- a call of deflate(), since the currently available input may have to
- be compressed and flushed. In particular, strm->avail_out must be non-zero.
-
- deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source
- stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR
- if strm->avail_out was zero.
-*/
-
-ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm,
- int good_length,
- int max_lazy,
- int nice_length,
- int max_chain));
-/*
- Fine tune deflate's internal compression parameters. This should only be
- used by someone who understands the algorithm used by zlib's deflate for
- searching for the best matching string, and even then only by the most
- fanatic optimizer trying to squeeze out the last compressed bit for their
- specific input data. Read the deflate.c source code for the meaning of the
- max_lazy, good_length, nice_length, and max_chain parameters.
-
- deflateTune() can be called after deflateInit() or deflateInit2(), and
- returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream.
- */
-
-ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,
- uLong sourceLen));
-/*
- deflateBound() returns an upper bound on the compressed size after
- deflation of sourceLen bytes. It must be called after deflateInit()
- or deflateInit2(). This would be used to allocate an output buffer
- for deflation in a single pass, and so would be called before deflate().
-*/
-
-ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,
- int bits,
- int value));
-/*
- deflatePrime() inserts bits in the deflate output stream. The intent
- is that this function is used to start off the deflate output with the
- bits leftover from a previous deflate stream when appending to it. As such,
- this function can only be used for raw deflate, and must be used before the
- first deflate() call after a deflateInit2() or deflateReset(). bits must be
- less than or equal to 16, and that many of the least significant bits of
- value will be inserted in the output.
-
- deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source
- stream state was inconsistent.
-*/
-
-ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm,
- gz_headerp head));
-/*
- deflateSetHeader() provides gzip header information for when a gzip
- stream is requested by deflateInit2(). deflateSetHeader() may be called
- after deflateInit2() or deflateReset() and before the first call of
- deflate(). The text, time, os, extra field, name, and comment information
- in the provided gz_header structure are written to the gzip header (xflag is
- ignored -- the extra flags are set according to the compression level). The
- caller must assure that, if not Z_NULL, name and comment are terminated with
- a zero byte, and that if extra is not Z_NULL, that extra_len bytes are
- available there. If hcrc is true, a gzip header crc is included. Note that
- the current versions of the command-line version of gzip (up through version
- 1.3.x) do not support header crc's, and will report that it is a "multi-part
- gzip file" and give up.
-
- If deflateSetHeader is not used, the default gzip header has text false,
- the time set to zero, and os set to 255, with no extra, name, or comment
- fields. The gzip header is returned to the default state by deflateReset().
-
- deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
- stream state was inconsistent.
-*/
-
-/*
-ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
- int windowBits));
-
- This is another version of inflateInit with an extra parameter. The
- fields next_in, avail_in, zalloc, zfree and opaque must be initialized
- before by the caller.
-
- The windowBits parameter is the base two logarithm of the maximum window
- size (the size of the history buffer). It should be in the range 8..15 for
- this version of the library. The default value is 15 if inflateInit is used
- instead. windowBits must be greater than or equal to the windowBits value
- provided to deflateInit2() while compressing, or it must be equal to 15 if
- deflateInit2() was not used. If a compressed stream with a larger window
- size is given as input, inflate() will return with the error code
- Z_DATA_ERROR instead of trying to allocate a larger window.
-
- windowBits can also be -8..-15 for raw inflate. In this case, -windowBits
- determines the window size. inflate() will then process raw deflate data,
- not looking for a zlib or gzip header, not generating a check value, and not
- looking for any check values for comparison at the end of the stream. This
- is for use with other formats that use the deflate compressed data format
- such as zip. Those formats provide their own check values. If a custom
- format is developed using the raw deflate format for compressed data, it is
- recommended that a check value such as an adler32 or a crc32 be applied to
- the uncompressed data as is done in the zlib, gzip, and zip formats. For
- most applications, the zlib format should be used as is. Note that comments
- above on the use in deflateInit2() applies to the magnitude of windowBits.
-
- windowBits can also be greater than 15 for optional gzip decoding. Add
- 32 to windowBits to enable zlib and gzip decoding with automatic header
- detection, or add 16 to decode only the gzip format (the zlib format will
- return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is
- a crc32 instead of an adler32.
-
- inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
- memory, Z_STREAM_ERROR if a parameter is invalid (such as a null strm). msg
- is set to null if there is no error message. inflateInit2 does not perform
- any decompression apart from reading the zlib header if present: this will
- be done by inflate(). (So next_in and avail_in may be modified, but next_out
- and avail_out are unchanged.)
-*/
-
-ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
- const Bytef *dictionary,
- uInt dictLength));
-/*
- Initializes the decompression dictionary from the given uncompressed byte
- sequence. This function must be called immediately after a call of inflate,
- if that call returned Z_NEED_DICT. The dictionary chosen by the compressor
- can be determined from the adler32 value returned by that call of inflate.
- The compressor and decompressor must use exactly the same dictionary (see
- deflateSetDictionary). For raw inflate, this function can be called
- immediately after inflateInit2() or inflateReset() and before any call of
- inflate() to set the dictionary. The application must insure that the
- dictionary that was used for compression is provided.
-
- inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
- parameter is invalid (such as NULL dictionary) or the stream state is
- inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
- expected one (incorrect adler32 value). inflateSetDictionary does not
- perform any decompression: this will be done by subsequent calls of
- inflate().
-*/
-
-ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
-/*
- Skips invalid compressed data until a full flush point (see above the
- description of deflate with Z_FULL_FLUSH) can be found, or until all
- available input is skipped. No output is provided.
-
- inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR
- if no more input was provided, Z_DATA_ERROR if no flush point has been found,
- or Z_STREAM_ERROR if the stream structure was inconsistent. In the success
- case, the application may save the current current value of total_in which
- indicates where valid compressed data was found. In the error case, the
- application may repeatedly call inflateSync, providing more input each time,
- until success or end of the input data.
-*/
-
-ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,
- z_streamp source));
-/*
- Sets the destination stream as a complete copy of the source stream.
-
- This function can be useful when randomly accessing a large stream. The
- first pass through the stream can periodically record the inflate state,
- allowing restarting inflate at those points when randomly accessing the
- stream.
-
- inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
- (such as zalloc being NULL). msg is left unchanged in both source and
- destination.
-*/
-
-ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
-/*
- This function is equivalent to inflateEnd followed by inflateInit,
- but does not free and reallocate all the internal decompression state.
- The stream will keep attributes that may have been set by inflateInit2.
-
- inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
- stream state was inconsistent (such as zalloc or state being NULL).
-*/
-
-ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm,
- int bits,
- int value));
-/*
- This function inserts bits in the inflate input stream. The intent is
- that this function is used to start inflating at a bit position in the
- middle of a byte. The provided bits will be used before any bytes are used
- from next_in. This function should only be used with raw inflate, and
- should be used before the first inflate() call after inflateInit2() or
- inflateReset(). bits must be less than or equal to 16, and that many of the
- least significant bits of value will be inserted in the input.
-
- inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source
- stream state was inconsistent.
-*/
-
-ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm,
- gz_headerp head));
-/*
- inflateGetHeader() requests that gzip header information be stored in the
- provided gz_header structure. inflateGetHeader() may be called after
- inflateInit2() or inflateReset(), and before the first call of inflate().
- As inflate() processes the gzip stream, head->done is zero until the header
- is completed, at which time head->done is set to one. If a zlib stream is
- being decoded, then head->done is set to -1 to indicate that there will be
- no gzip header information forthcoming. Note that Z_BLOCK can be used to
- force inflate() to return immediately after header processing is complete
- and before any actual data is decompressed.
-
- The text, time, xflags, and os fields are filled in with the gzip header
- contents. hcrc is set to true if there is a header CRC. (The header CRC
- was valid if done is set to one.) If extra is not Z_NULL, then extra_max
- contains the maximum number of bytes to write to extra. Once done is true,
- extra_len contains the actual extra field length, and extra contains the
- extra field, or that field truncated if extra_max is less than extra_len.
- If name is not Z_NULL, then up to name_max characters are written there,
- terminated with a zero unless the length is greater than name_max. If
- comment is not Z_NULL, then up to comm_max characters are written there,
- terminated with a zero unless the length is greater than comm_max. When
- any of extra, name, or comment are not Z_NULL and the respective field is
- not present in the header, then that field is set to Z_NULL to signal its
- absence. This allows the use of deflateSetHeader() with the returned
- structure to duplicate the header. However if those fields are set to
- allocated memory, then the application will need to save those pointers
- elsewhere so that they can be eventually freed.
-
- If inflateGetHeader is not used, then the header information is simply
- discarded. The header is always checked for validity, including the header
- CRC if present. inflateReset() will reset the process to discard the header
- information. The application would need to call inflateGetHeader() again to
- retrieve the header from the next gzip stream.
-
- inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
- stream state was inconsistent.
-*/
-
-/*
-ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,
- unsigned char FAR *window));
-
- Initialize the internal stream state for decompression using inflateBack()
- calls. The fields zalloc, zfree and opaque in strm must be initialized
- before the call. If zalloc and zfree are Z_NULL, then the default library-
- derived memory allocation routines are used. windowBits is the base two
- logarithm of the window size, in the range 8..15. window is a caller
- supplied buffer of that size. Except for special applications where it is
- assured that deflate was used with small window sizes, windowBits must be 15
- and a 32K byte window must be supplied to be able to decompress general
- deflate streams.
-
- See inflateBack() for the usage of these routines.
-
- inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of
- the paramaters are invalid, Z_MEM_ERROR if the internal state could not
- be allocated, or Z_VERSION_ERROR if the version of the library does not
- match the version of the header file.
-*/
-
-typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *));
-typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned));
-
-ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
- in_func in, void FAR *in_desc,
- out_func out, void FAR *out_desc));
-/*
- inflateBack() does a raw inflate with a single call using a call-back
- interface for input and output. This is more efficient than inflate() for
- file i/o applications in that it avoids copying between the output and the
- sliding window by simply making the window itself the output buffer. This
- function trusts the application to not change the output buffer passed by
- the output function, at least until inflateBack() returns.
-
- inflateBackInit() must be called first to allocate the internal state
- and to initialize the state with the user-provided window buffer.
- inflateBack() may then be used multiple times to inflate a complete, raw
- deflate stream with each call. inflateBackEnd() is then called to free
- the allocated state.
-
- A raw deflate stream is one with no zlib or gzip header or trailer.
- This routine would normally be used in a utility that reads zip or gzip
- files and writes out uncompressed files. The utility would decode the
- header and process the trailer on its own, hence this routine expects
- only the raw deflate stream to decompress. This is different from the
- normal behavior of inflate(), which expects either a zlib or gzip header and
- trailer around the deflate stream.
-
- inflateBack() uses two subroutines supplied by the caller that are then
- called by inflateBack() for input and output. inflateBack() calls those
- routines until it reads a complete deflate stream and writes out all of the
- uncompressed data, or until it encounters an error. The function's
- parameters and return types are defined above in the in_func and out_func
- typedefs. inflateBack() will call in(in_desc, &buf) which should return the
- number of bytes of provided input, and a pointer to that input in buf. If
- there is no input available, in() must return zero--buf is ignored in that
- case--and inflateBack() will return a buffer error. inflateBack() will call
- out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out()
- should return zero on success, or non-zero on failure. If out() returns
- non-zero, inflateBack() will return with an error. Neither in() nor out()
- are permitted to change the contents of the window provided to
- inflateBackInit(), which is also the buffer that out() uses to write from.
- The length written by out() will be at most the window size. Any non-zero
- amount of input may be provided by in().
-
- For convenience, inflateBack() can be provided input on the first call by
- setting strm->next_in and strm->avail_in. If that input is exhausted, then
- in() will be called. Therefore strm->next_in must be initialized before
- calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called
- immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in
- must also be initialized, and then if strm->avail_in is not zero, input will
- initially be taken from strm->next_in[0 .. strm->avail_in - 1].
-
- The in_desc and out_desc parameters of inflateBack() is passed as the
- first parameter of in() and out() respectively when they are called. These
- descriptors can be optionally used to pass any information that the caller-
- supplied in() and out() functions need to do their job.
-
- On return, inflateBack() will set strm->next_in and strm->avail_in to
- pass back any unused input that was provided by the last in() call. The
- return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR
- if in() or out() returned an error, Z_DATA_ERROR if there was a format
- error in the deflate stream (in which case strm->msg is set to indicate the
- nature of the error), or Z_STREAM_ERROR if the stream was not properly
- initialized. In the case of Z_BUF_ERROR, an input or output error can be
- distinguished using strm->next_in which will be Z_NULL only if in() returned
- an error. If strm->next is not Z_NULL, then the Z_BUF_ERROR was due to
- out() returning non-zero. (in() will always be called before out(), so
- strm->next_in is assured to be defined if out() returns non-zero.) Note
- that inflateBack() cannot return Z_OK.
-*/
-
-ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm));
-/*
- All memory allocated by inflateBackInit() is freed.
-
- inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream
- state was inconsistent.
-*/
-
-ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));
-/* Return flags indicating compile-time options.
-
- Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other:
- 1.0: size of uInt
- 3.2: size of uLong
- 5.4: size of voidpf (pointer)
- 7.6: size of z_off_t
-
- Compiler, assembler, and debug options:
- 8: DEBUG
- 9: ASMV or ASMINF -- use ASM code
- 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention
- 11: 0 (reserved)
-
- One-time table building (smaller code, but not thread-safe if true):
- 12: BUILDFIXED -- build static block decoding tables when needed
- 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed
- 14,15: 0 (reserved)
-
- Library content (indicates missing functionality):
- 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking
- deflate code when not needed)
- 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect
- and decode gzip streams (to avoid linking crc code)
- 18-19: 0 (reserved)
-
- Operation variations (changes in library functionality):
- 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate
- 21: FASTEST -- deflate algorithm with only one, lowest compression level
- 22,23: 0 (reserved)
-
- The sprintf variant used by gzprintf (zero is best):
- 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format
- 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure!
- 26: 0 = returns value, 1 = void -- 1 means inferred string length returned
-
- Remainder:
- 27-31: 0 (reserved)
- */
-
-
- /* utility functions */
-
-/*
- The following utility functions are implemented on top of the
- basic stream-oriented functions. To simplify the interface, some
- default options are assumed (compression level and memory usage,
- standard memory allocation functions). The source code of these
- utility functions can easily be modified if you need special options.
-*/
-
-ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen,
- const Bytef *source, uLong sourceLen));
-/*
- Compresses the source buffer into the destination buffer. sourceLen is
- the byte length of the source buffer. Upon entry, destLen is the total
- size of the destination buffer, which must be at least the value returned
- by compressBound(sourceLen). Upon exit, destLen is the actual size of the
- compressed buffer.
- This function can be used to compress a whole file at once if the
- input file is mmap'ed.
- compress returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_BUF_ERROR if there was not enough room in the output
- buffer.
-*/
-
-ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen,
- const Bytef *source, uLong sourceLen,
- int level));
-/*
- Compresses the source buffer into the destination buffer. The level
- parameter has the same meaning as in deflateInit. sourceLen is the byte
- length of the source buffer. Upon entry, destLen is the total size of the
- destination buffer, which must be at least the value returned by
- compressBound(sourceLen). Upon exit, destLen is the actual size of the
- compressed buffer.
-
- compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
- memory, Z_BUF_ERROR if there was not enough room in the output buffer,
- Z_STREAM_ERROR if the level parameter is invalid.
-*/
-
-ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen));
-/*
- compressBound() returns an upper bound on the compressed size after
- compress() or compress2() on sourceLen bytes. It would be used before
- a compress() or compress2() call to allocate the destination buffer.
-*/
-
-ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
- const Bytef *source, uLong sourceLen));
-/*
- Decompresses the source buffer into the destination buffer. sourceLen is
- the byte length of the source buffer. Upon entry, destLen is the total
- size of the destination buffer, which must be large enough to hold the
- entire uncompressed data. (The size of the uncompressed data must have
- been saved previously by the compressor and transmitted to the decompressor
- by some mechanism outside the scope of this compression library.)
- Upon exit, destLen is the actual size of the compressed buffer.
- This function can be used to decompress a whole file at once if the
- input file is mmap'ed.
-
- uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_BUF_ERROR if there was not enough room in the output
- buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete.
-*/
-
-
-typedef voidp gzFile;
-
-ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
-/*
- Opens a gzip (.gz) file for reading or writing. The mode parameter
- is as in fopen ("rb" or "wb") but can also include a compression level
- ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for
- Huffman only compression as in "wb1h", or 'R' for run-length encoding
- as in "wb1R". (See the description of deflateInit2 for more information
- about the strategy parameter.)
-
- gzopen can be used to read a file which is not in gzip format; in this
- case gzread will directly read from the file without decompression.
-
- gzopen returns NULL if the file could not be opened or if there was
- insufficient memory to allocate the (de)compression state; errno
- can be checked to distinguish the two cases (if errno is zero, the
- zlib error is Z_MEM_ERROR). */
-
-ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
-/*
- gzdopen() associates a gzFile with the file descriptor fd. File
- descriptors are obtained from calls like open, dup, creat, pipe or
- fileno (in the file has been previously opened with fopen).
- The mode parameter is as in gzopen.
- The next call of gzclose on the returned gzFile will also close the
- file descriptor fd, just like fclose(fdopen(fd), mode) closes the file
- descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode).
- gzdopen returns NULL if there was insufficient memory to allocate
- the (de)compression state.
-*/
-
-ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
-/*
- Dynamically update the compression level or strategy. See the description
- of deflateInit2 for the meaning of these parameters.
- gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not
- opened for writing.
-*/
-
-ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
-/*
- Reads the given number of uncompressed bytes from the compressed file.
- If the input file was not in gzip format, gzread copies the given number
- of bytes into the buffer.
- gzread returns the number of uncompressed bytes actually read (0 for
- end of file, -1 for error). */
-
-ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
- voidpc buf, unsigned len));
-/*
- Writes the given number of uncompressed bytes into the compressed file.
- gzwrite returns the number of uncompressed bytes actually written
- (0 in case of error).
-*/
-
-ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...));
-/*
- Converts, formats, and writes the args to the compressed file under
- control of the format string, as in fprintf. gzprintf returns the number of
- uncompressed bytes actually written (0 in case of error). The number of
- uncompressed bytes written is limited to 4095. The caller should assure that
- this limit is not exceeded. If it is exceeded, then gzprintf() will return
- return an error (0) with nothing written. In this case, there may also be a
- buffer overflow with unpredictable consequences, which is possible only if
- zlib was compiled with the insecure functions sprintf() or vsprintf()
- because the secure snprintf() or vsnprintf() functions were not available.
-*/
-
-ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
-/*
- Writes the given null-terminated string to the compressed file, excluding
- the terminating null character.
- gzputs returns the number of characters written, or -1 in case of error.
-*/
-
-ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
-/*
- Reads bytes from the compressed file until len-1 characters are read, or
- a newline character is read and transferred to buf, or an end-of-file
- condition is encountered. The string is then terminated with a null
- character.
- gzgets returns buf, or Z_NULL in case of error.
-*/
-
-ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));
-/*
- Writes c, converted to an unsigned char, into the compressed file.
- gzputc returns the value that was written, or -1 in case of error.
-*/
-
-ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
-/*
- Reads one byte from the compressed file. gzgetc returns this byte
- or -1 in case of end of file or error.
-*/
-
-ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));
-/*
- Push one character back onto the stream to be read again later.
- Only one character of push-back is allowed. gzungetc() returns the
- character pushed, or -1 on failure. gzungetc() will fail if a
- character has been pushed but not read yet, or if c is -1. The pushed
- character will be discarded if the stream is repositioned with gzseek()
- or gzrewind().
-*/
-
-ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
-/*
- Flushes all pending output into the compressed file. The parameter
- flush is as in the deflate() function. The return value is the zlib
- error number (see function gzerror below). gzflush returns Z_OK if
- the flush parameter is Z_FINISH and all output could be flushed.
- gzflush should be called only when strictly necessary because it can
- degrade compression.
-*/
-
-ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
- z_off_t offset, int whence));
-/*
- Sets the starting position for the next gzread or gzwrite on the
- given compressed file. The offset represents a number of bytes in the
- uncompressed data stream. The whence parameter is defined as in lseek(2);
- the value SEEK_END is not supported.
- If the file is opened for reading, this function is emulated but can be
- extremely slow. If the file is opened for writing, only forward seeks are
- supported; gzseek then compresses a sequence of zeroes up to the new
- starting position.
-
- gzseek returns the resulting offset location as measured in bytes from
- the beginning of the uncompressed stream, or -1 in case of error, in
- particular if the file is opened for writing and the new starting position
- would be before the current position.
-*/
-
-ZEXTERN int ZEXPORT gzrewind OF((gzFile file));
-/*
- Rewinds the given file. This function is supported only for reading.
-
- gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
-*/
-
-ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file));
-/*
- Returns the starting position for the next gzread or gzwrite on the
- given compressed file. This position represents a number of bytes in the
- uncompressed data stream.
-
- gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
-*/
-
-ZEXTERN int ZEXPORT gzeof OF((gzFile file));
-/*
- Returns 1 when EOF has previously been detected reading the given
- input stream, otherwise zero.
-*/
-
-ZEXTERN int ZEXPORT gzdirect OF((gzFile file));
-/*
- Returns 1 if file is being read directly without decompression, otherwise
- zero.
-*/
-
-ZEXTERN int ZEXPORT gzclose OF((gzFile file));
-/*
- Flushes all pending output if necessary, closes the compressed file
- and deallocates all the (de)compression state. The return value is the zlib
- error number (see function gzerror below).
-*/
-
-ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
-/*
- Returns the error message for the last error which occurred on the
- given compressed file. errnum is set to zlib error number. If an
- error occurred in the file system and not in the compression library,
- errnum is set to Z_ERRNO and the application may consult errno
- to get the exact error code.
-*/
-
-ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
-/*
- Clears the error and end-of-file flags for file. This is analogous to the
- clearerr() function in stdio. This is useful for continuing to read a gzip
- file that is being written concurrently.
-*/
-
- /* checksum functions */
-
-/*
- These functions are not related to compression but are exported
- anyway because they might be useful in applications using the
- compression library.
-*/
-
-ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
-/*
- Update a running Adler-32 checksum with the bytes buf[0..len-1] and
- return the updated checksum. If buf is NULL, this function returns
- the required initial value for the checksum.
- An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
- much faster. Usage example:
-
- uLong adler = adler32(0L, Z_NULL, 0);
-
- while (read_buffer(buffer, length) != EOF) {
- adler = adler32(adler, buffer, length);
- }
- if (adler != original_adler) error();
-*/
-
-ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,
- z_off_t len2));
-/*
- Combine two Adler-32 checksums into one. For two sequences of bytes, seq1
- and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for
- each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of
- seq1 and seq2 concatenated, requiring only adler1, adler2, and len2.
-*/
-
-ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
-/*
- Update a running CRC-32 with the bytes buf[0..len-1] and return the
- updated CRC-32. If buf is NULL, this function returns the required initial
- value for the for the crc. Pre- and post-conditioning (one's complement) is
- performed within this function so it shouldn't be done by the application.
- Usage example:
-
- uLong crc = crc32(0L, Z_NULL, 0);
-
- while (read_buffer(buffer, length) != EOF) {
- crc = crc32(crc, buffer, length);
- }
- if (crc != original_crc) error();
-*/
-
-ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));
-
-/*
- Combine two CRC-32 check values into one. For two sequences of bytes,
- seq1 and seq2 with lengths len1 and len2, CRC-32 check values were
- calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32
- check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and
- len2.
-*/
-
-
- /* various hacks, don't look :) */
-
-/* deflateInit and inflateInit are macros to allow checking the zlib version
- * and the compiler's view of z_stream:
- */
-ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,
- const char *version, int stream_size));
-ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,
- const char *version, int stream_size));
-ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method,
- int windowBits, int memLevel,
- int strategy, const char *version,
- int stream_size));
-ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits,
- const char *version, int stream_size));
-ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
- unsigned char FAR *window,
- const char *version,
- int stream_size));
-#define deflateInit(strm, level) \
- deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream))
-#define inflateInit(strm) \
- inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream))
-#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
- deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
- (strategy), ZLIB_VERSION, sizeof(z_stream))
-#define inflateInit2(strm, windowBits) \
- inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
-#define inflateBackInit(strm, windowBits, window) \
- inflateBackInit_((strm), (windowBits), (window), \
- ZLIB_VERSION, sizeof(z_stream))
-
-
-#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL)
- struct internal_state {int dummy;}; /* hack for buggy compilers */
-#endif
-
-ZEXTERN const char * ZEXPORT zError OF((int));
-ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z));
-ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void));
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* ZLIB_H */
diff --git a/WebCore/platform/image-decoders/zlib/zutil.c b/WebCore/platform/image-decoders/zlib/zutil.c
deleted file mode 100644
index 4a51340..0000000
--- a/WebCore/platform/image-decoders/zlib/zutil.c
+++ /dev/null
@@ -1,318 +0,0 @@
-/* zutil.c -- target dependent utility functions for the compression library
- * Copyright (C) 1995-2005 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* @(#) $Id: zutil.c,v 3.11 2005/08/04 19:14:14 tor%cs.brown.edu Exp $ */
-
-#include "zutil.h"
-
-#ifndef NO_DUMMY_DECL
-struct internal_state {int dummy;}; /* for buggy compilers */
-#endif
-
-const char * const z_errmsg[10] = {
-"need dictionary", /* Z_NEED_DICT 2 */
-"stream end", /* Z_STREAM_END 1 */
-"", /* Z_OK 0 */
-"file error", /* Z_ERRNO (-1) */
-"stream error", /* Z_STREAM_ERROR (-2) */
-"data error", /* Z_DATA_ERROR (-3) */
-"insufficient memory", /* Z_MEM_ERROR (-4) */
-"buffer error", /* Z_BUF_ERROR (-5) */
-"incompatible version",/* Z_VERSION_ERROR (-6) */
-""};
-
-
-const char * ZEXPORT zlibVersion()
-{
- return ZLIB_VERSION;
-}
-
-uLong ZEXPORT zlibCompileFlags()
-{
- uLong flags;
-
- flags = 0;
- switch (sizeof(uInt)) {
- case 2: break;
- case 4: flags += 1; break;
- case 8: flags += 2; break;
- default: flags += 3;
- }
- switch (sizeof(uLong)) {
- case 2: break;
- case 4: flags += 1 << 2; break;
- case 8: flags += 2 << 2; break;
- default: flags += 3 << 2;
- }
- switch (sizeof(voidpf)) {
- case 2: break;
- case 4: flags += 1 << 4; break;
- case 8: flags += 2 << 4; break;
- default: flags += 3 << 4;
- }
- switch (sizeof(z_off_t)) {
- case 2: break;
- case 4: flags += 1 << 6; break;
- case 8: flags += 2 << 6; break;
- default: flags += 3 << 6;
- }
-#ifdef DEBUG
- flags += 1 << 8;
-#endif
-#if defined(ASMV) || defined(ASMINF)
- flags += 1 << 9;
-#endif
-#ifdef ZLIB_WINAPI
- flags += 1 << 10;
-#endif
-#ifdef BUILDFIXED
- flags += 1 << 12;
-#endif
-#ifdef DYNAMIC_CRC_TABLE
- flags += 1 << 13;
-#endif
-#ifdef NO_GZCOMPRESS
- flags += 1L << 16;
-#endif
-#ifdef NO_GZIP
- flags += 1L << 17;
-#endif
-#ifdef PKZIP_BUG_WORKAROUND
- flags += 1L << 20;
-#endif
-#ifdef FASTEST
- flags += 1L << 21;
-#endif
-#ifdef STDC
-# ifdef NO_vsnprintf
- flags += 1L << 25;
-# ifdef HAS_vsprintf_void
- flags += 1L << 26;
-# endif
-# else
-# ifdef HAS_vsnprintf_void
- flags += 1L << 26;
-# endif
-# endif
-#else
- flags += 1L << 24;
-# ifdef NO_snprintf
- flags += 1L << 25;
-# ifdef HAS_sprintf_void
- flags += 1L << 26;
-# endif
-# else
-# ifdef HAS_snprintf_void
- flags += 1L << 26;
-# endif
-# endif
-#endif
- return flags;
-}
-
-#ifdef DEBUG
-
-# ifndef verbose
-# define verbose 0
-# endif
-int z_verbose = verbose;
-
-void z_error (m)
- char *m;
-{
- fprintf(stderr, "%s\n", m);
- exit(1);
-}
-#endif
-
-/* exported to allow conversion of error code to string for compress() and
- * uncompress()
- */
-const char * ZEXPORT zError(err)
- int err;
-{
- return ERR_MSG(err);
-}
-
-#if defined(_WIN32_WCE)
- /* The Microsoft C Run-Time Library for Windows CE doesn't have
- * errno. We define it as a global variable to simplify porting.
- * Its value is always 0 and should not be used.
- */
- int errno = 0;
-#endif
-
-#ifndef HAVE_MEMCPY
-
-void zmemcpy(dest, source, len)
- Bytef* dest;
- const Bytef* source;
- uInt len;
-{
- if (len == 0) return;
- do {
- *dest++ = *source++; /* ??? to be unrolled */
- } while (--len != 0);
-}
-
-int zmemcmp(s1, s2, len)
- const Bytef* s1;
- const Bytef* s2;
- uInt len;
-{
- uInt j;
-
- for (j = 0; j < len; j++) {
- if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1;
- }
- return 0;
-}
-
-void zmemzero(dest, len)
- Bytef* dest;
- uInt len;
-{
- if (len == 0) return;
- do {
- *dest++ = 0; /* ??? to be unrolled */
- } while (--len != 0);
-}
-#endif
-
-
-#ifdef SYS16BIT
-
-#ifdef __TURBOC__
-/* Turbo C in 16-bit mode */
-
-# define MY_ZCALLOC
-
-/* Turbo C malloc() does not allow dynamic allocation of 64K bytes
- * and farmalloc(64K) returns a pointer with an offset of 8, so we
- * must fix the pointer. Warning: the pointer must be put back to its
- * original form in order to free it, use zcfree().
- */
-
-#define MAX_PTR 10
-/* 10*64K = 640K */
-
-local int next_ptr = 0;
-
-typedef struct ptr_table_s {
- voidpf org_ptr;
- voidpf new_ptr;
-} ptr_table;
-
-local ptr_table table[MAX_PTR];
-/* This table is used to remember the original form of pointers
- * to large buffers (64K). Such pointers are normalized with a zero offset.
- * Since MSDOS is not a preemptive multitasking OS, this table is not
- * protected from concurrent access. This hack doesn't work anyway on
- * a protected system like OS/2. Use Microsoft C instead.
- */
-
-voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
-{
- voidpf buf = opaque; /* just to make some compilers happy */
- ulg bsize = (ulg)items*size;
-
- /* If we allocate less than 65520 bytes, we assume that farmalloc
- * will return a usable pointer which doesn't have to be normalized.
- */
- if (bsize < 65520L) {
- buf = farmalloc(bsize);
- if (*(ush*)&buf != 0) return buf;
- } else {
- buf = farmalloc(bsize + 16L);
- }
- if (buf == NULL || next_ptr >= MAX_PTR) return NULL;
- table[next_ptr].org_ptr = buf;
-
- /* Normalize the pointer to seg:0 */
- *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4;
- *(ush*)&buf = 0;
- table[next_ptr++].new_ptr = buf;
- return buf;
-}
-
-void zcfree (voidpf opaque, voidpf ptr)
-{
- int n;
- if (*(ush*)&ptr != 0) { /* object < 64K */
- farfree(ptr);
- return;
- }
- /* Find the original pointer */
- for (n = 0; n < next_ptr; n++) {
- if (ptr != table[n].new_ptr) continue;
-
- farfree(table[n].org_ptr);
- while (++n < next_ptr) {
- table[n-1] = table[n];
- }
- next_ptr--;
- return;
- }
- ptr = opaque; /* just to make some compilers happy */
- Assert(0, "zcfree: ptr not found");
-}
-
-#endif /* __TURBOC__ */
-
-
-#ifdef M_I86
-/* Microsoft C in 16-bit mode */
-
-# define MY_ZCALLOC
-
-#if (!defined(_MSC_VER) || (_MSC_VER <= 600))
-# define _halloc halloc
-# define _hfree hfree
-#endif
-
-voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
-{
- if (opaque) opaque = 0; /* to make compiler happy */
- return _halloc((long)items, size);
-}
-
-void zcfree (voidpf opaque, voidpf ptr)
-{
- if (opaque) opaque = 0; /* to make compiler happy */
- _hfree(ptr);
-}
-
-#endif /* M_I86 */
-
-#endif /* SYS16BIT */
-
-
-#ifndef MY_ZCALLOC /* Any system without a special alloc function */
-
-#ifndef STDC
-extern voidp malloc OF((uInt size));
-extern voidp calloc OF((uInt items, uInt size));
-extern void free OF((voidpf ptr));
-#endif
-
-voidpf zcalloc (opaque, items, size)
- voidpf opaque;
- unsigned items;
- unsigned size;
-{
- if (opaque) items += size - size; /* make compiler happy */
- return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
- (voidpf)calloc(items, size);
-}
-
-void zcfree (opaque, ptr)
- voidpf opaque;
- voidpf ptr;
-{
- free(ptr);
- if (opaque) return; /* make compiler happy */
-}
-
-#endif /* MY_ZCALLOC */
diff --git a/WebCore/platform/image-decoders/zlib/zutil.h b/WebCore/platform/image-decoders/zlib/zutil.h
deleted file mode 100644
index 8b26cef..0000000
--- a/WebCore/platform/image-decoders/zlib/zutil.h
+++ /dev/null
@@ -1,269 +0,0 @@
-/* zutil.h -- internal interface and configuration of the compression library
- * Copyright (C) 1995-2005 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-/* @(#) $Id: zutil.h,v 3.10 2005/08/04 19:14:14 tor%cs.brown.edu Exp $ */
-
-#ifndef ZUTIL_H
-#define ZUTIL_H
-
-#define ZLIB_INTERNAL
-#include "zlib.h"
-
-#ifdef STDC
-# ifndef _WIN32_WCE
-# include <stddef.h>
-# endif
-# include <string.h>
-# include <stdlib.h>
-#endif
-#ifdef NO_ERRNO_H
-# ifdef _WIN32_WCE
- /* The Microsoft C Run-Time Library for Windows CE doesn't have
- * errno. We define it as a global variable to simplify porting.
- * Its value is always 0 and should not be used. We rename it to
- * avoid conflict with other libraries that use the same workaround.
- */
-# define errno z_errno
-# endif
- extern int errno;
-#else
-# ifndef _WIN32_WCE
-# include <errno.h>
-# endif
-#endif
-
-#ifndef local
-# define local static
-#endif
-/* compile with -Dlocal if your debugger can't find static symbols */
-
-typedef unsigned char uch;
-typedef uch FAR uchf;
-typedef unsigned short ush;
-typedef ush FAR ushf;
-typedef unsigned long ulg;
-
-extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
-/* (size given to avoid silly warnings with Visual C++) */
-
-#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
-
-#define ERR_RETURN(strm,err) \
- return (strm->msg = (char*)ERR_MSG(err), (err))
-/* To be used only when the state is known to be valid */
-
- /* common constants */
-
-#ifndef DEF_WBITS
-# define DEF_WBITS MAX_WBITS
-#endif
-/* default windowBits for decompression. MAX_WBITS is for compression only */
-
-#if MAX_MEM_LEVEL >= 8
-# define DEF_MEM_LEVEL 8
-#else
-# define DEF_MEM_LEVEL MAX_MEM_LEVEL
-#endif
-/* default memLevel */
-
-#define STORED_BLOCK 0
-#define STATIC_TREES 1
-#define DYN_TREES 2
-/* The three kinds of block type */
-
-#define MIN_MATCH 3
-#define MAX_MATCH 258
-/* The minimum and maximum match lengths */
-
-#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
-
- /* target dependencies */
-
-#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
-# define OS_CODE 0x00
-# if defined(__TURBOC__) || defined(__BORLANDC__)
-# if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
- /* Allow compilation with ANSI keywords only enabled */
- void _Cdecl farfree( void *block );
- void *_Cdecl farmalloc( unsigned long nbytes );
-# else
-# include <alloc.h>
-# endif
-# else /* MSC or DJGPP */
-# include <malloc.h>
-# endif
-#endif
-
-#ifdef AMIGA
-# define OS_CODE 0x01
-#endif
-
-#if defined(VAXC) || defined(VMS)
-# define OS_CODE 0x02
-# define F_OPEN(name, mode) \
- fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
-#endif
-
-#if defined(ATARI) || defined(atarist)
-# define OS_CODE 0x05
-#endif
-
-#ifdef OS2
-# define OS_CODE 0x06
-# ifdef M_I86
- #include <malloc.h>
-# endif
-#endif
-
-#if defined(MACOS) || defined(TARGET_OS_MAC)
-# define OS_CODE 0x07
-# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
-# include <unix.h> /* for fdopen */
-# else
-# ifndef fdopen
-# define fdopen(fd,mode) NULL /* No fdopen() */
-# endif
-# endif
-#endif
-
-#ifdef TOPS20
-# define OS_CODE 0x0a
-#endif
-
-#ifdef WIN32
-# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */
-# define OS_CODE 0x0b
-# endif
-#endif
-
-#ifdef __50SERIES /* Prime/PRIMOS */
-# define OS_CODE 0x0f
-#endif
-
-#if defined(_BEOS_) || defined(RISCOS)
-# define fdopen(fd,mode) NULL /* No fdopen() */
-#endif
-
-#if (defined(_MSC_VER) && (_MSC_VER > 600))
-# if defined(_WIN32_WCE)
-# define fdopen(fd,mode) NULL /* No fdopen() */
-# ifndef _PTRDIFF_T_DEFINED
- typedef int ptrdiff_t;
-# define _PTRDIFF_T_DEFINED
-# endif
-# else
-# define fdopen(fd,type) _fdopen(fd,type)
-# endif
-#endif
-
- /* common defaults */
-
-#ifndef OS_CODE
-# define OS_CODE 0x03 /* assume Unix */
-#endif
-
-#ifndef F_OPEN
-# define F_OPEN(name, mode) fopen((name), (mode))
-#endif
-
- /* functions */
-
-#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
-# ifndef HAVE_VSNPRINTF
-# define HAVE_VSNPRINTF
-# endif
-#endif
-#if defined(__CYGWIN__)
-# ifndef HAVE_VSNPRINTF
-# define HAVE_VSNPRINTF
-# endif
-#endif
-#ifndef HAVE_VSNPRINTF
-# ifdef MSDOS
- /* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
- but for now we just assume it doesn't. */
-# define NO_vsnprintf
-# endif
-# ifdef __TURBOC__
-# define NO_vsnprintf
-# endif
-# ifdef WIN32
- /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
-# if !defined(vsnprintf) && !defined(NO_vsnprintf)
-# define vsnprintf _vsnprintf
-# endif
-# endif
-# ifdef __SASC
-# define NO_vsnprintf
-# endif
-#endif
-#ifdef VMS
-# define NO_vsnprintf
-#endif
-
-#if defined(pyr)
-# define NO_MEMCPY
-#endif
-#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
- /* Use our own functions for small and medium model with MSC <= 5.0.
- * You may have to use the same strategy for Borland C (untested).
- * The __SC__ check is for Symantec.
- */
-# define NO_MEMCPY
-#endif
-#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
-# define HAVE_MEMCPY
-#endif
-#ifdef HAVE_MEMCPY
-# ifdef SMALL_MEDIUM /* MSDOS small or medium model */
-# define zmemcpy _fmemcpy
-# define zmemcmp _fmemcmp
-# define zmemzero(dest, len) _fmemset(dest, 0, len)
-# else
-# define zmemcpy memcpy
-# define zmemcmp memcmp
-# define zmemzero(dest, len) memset(dest, 0, len)
-# endif
-#else
- extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
- extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
- extern void zmemzero OF((Bytef* dest, uInt len));
-#endif
-
-/* Diagnostic functions */
-#ifdef DEBUG
-# include <stdio.h>
- extern int z_verbose;
- extern void z_error OF((char *m));
-# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
-# define Trace(x) {if (z_verbose>=0) fprintf x ;}
-# define Tracev(x) {if (z_verbose>0) fprintf x ;}
-# define Tracevv(x) {if (z_verbose>1) fprintf x ;}
-# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
-# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
-#else
-# define Assert(cond,msg)
-# define Trace(x)
-# define Tracev(x)
-# define Tracevv(x)
-# define Tracec(c,x)
-# define Tracecv(c,x)
-#endif
-
-
-voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
-void zcfree OF((voidpf opaque, voidpf ptr));
-
-#define ZALLOC(strm, items, size) \
- (*((strm)->zalloc))((strm)->opaque, (items), (size))
-#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
-#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
-
-#endif /* ZUTIL_H */
diff --git a/WebCore/platform/mac/AutodrainedPool.mm b/WebCore/platform/mac/AutodrainedPool.mm
deleted file mode 100644
index 6febaef..0000000
--- a/WebCore/platform/mac/AutodrainedPool.mm
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "AutodrainedPool.h"
-
-namespace WebCore {
-
-AutodrainedPool::AutodrainedPool(int iterationLimit)
- : m_iterationLimit(iterationLimit)
- , m_iterationCount(0)
- , m_pool([[NSAutoreleasePool alloc] init])
-{
-}
-
-AutodrainedPool::~AutodrainedPool()
-{
- [m_pool drain];
-}
-
-void AutodrainedPool::cycle()
-{
- if (++m_iterationCount == m_iterationLimit) {
- [m_pool drain];
- m_pool = [[NSAutoreleasePool alloc] init];
- m_iterationCount = 0;
- }
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/mac/BlockExceptions.h b/WebCore/platform/mac/BlockExceptions.h
deleted file mode 100644
index a3016d2..0000000
--- a/WebCore/platform/mac/BlockExceptions.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2003 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <Foundation/NSException.h>
-
-void ReportBlockedObjCException(NSException *);
-
-#define BEGIN_BLOCK_OBJC_EXCEPTIONS @try {
-#define END_BLOCK_OBJC_EXCEPTIONS } @catch(NSException *localException) { ReportBlockedObjCException(localException); }
-
diff --git a/WebCore/platform/mac/BlockExceptions.mm b/WebCore/platform/mac/BlockExceptions.mm
deleted file mode 100644
index f2dc1ec..0000000
--- a/WebCore/platform/mac/BlockExceptions.mm
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2003, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "BlockExceptions.h"
-
-#import <wtf/Assertions.h>
-
-void ReportBlockedObjCException(NSException *exception)
-{
-#if ASSERT_DISABLED
- NSLog(@"*** WebKit discarding exception: <%@> %@", [exception name], [exception reason]);
-#else
- ASSERT_WITH_MESSAGE(0, "Uncaught exception - %@", exception);
-#endif
-}
diff --git a/WebCore/platform/mac/ClipboardMac.h b/WebCore/platform/mac/ClipboardMac.h
deleted file mode 100644
index db6ecb6..0000000
--- a/WebCore/platform/mac/ClipboardMac.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ClipboardMac_h
-#define ClipboardMac_h
-
-#include "CachedResourceClient.h"
-#include "Clipboard.h"
-#include <wtf/RetainPtr.h>
-
-#ifdef __OBJC__
-@class NSImage;
-@class NSPasteboard;
-#else
-class NSImage;
-class NSPasteboard;
-#endif
-
-namespace WebCore {
-
-class Frame;
-
-class ClipboardMac : public Clipboard, public CachedResourceClient {
-public:
- static PassRefPtr<ClipboardMac> create(bool forDragging, NSPasteboard *pasteboard, ClipboardAccessPolicy policy, Frame* frame)
- {
- return adoptRef(new ClipboardMac(forDragging, pasteboard, policy, frame));
- }
-
- virtual ~ClipboardMac();
-
- void clearData(const String& type);
- void clearAllData();
- String getData(const String& type, bool& success) const;
- bool setData(const String& type, const String& data);
-
- virtual bool hasData();
-
- // extensions beyond IE's API
- virtual HashSet<String> types() const;
-
- void setDragImage(CachedImage*, const IntPoint&);
- void setDragImageElement(Node *, const IntPoint&);
-
- virtual DragImageRef createDragImage(IntPoint& dragLoc) const;
- virtual void declareAndWriteDragImage(Element*, const KURL&, const String& title, Frame*);
- virtual void writeRange(Range*, Frame* frame);
- virtual void writeURL(const KURL&, const String&, Frame* frame);
-
- // Methods for getting info in Cocoa's type system
- NSImage *dragNSImage(NSPoint&) const; // loc converted from dragLoc, based on whole image size
- NSPasteboard *pasteboard() { return m_pasteboard.get(); }
-
-private:
- ClipboardMac(bool forDragging, NSPasteboard *, ClipboardAccessPolicy, Frame*);
-
- void setDragImage(CachedImage*, Node*, const IntPoint&);
-
- RetainPtr<NSPasteboard> m_pasteboard;
- int m_changeCount;
- Frame* m_frame; // used on the source side to generate dragging images
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/mac/ClipboardMac.mm b/WebCore/platform/mac/ClipboardMac.mm
deleted file mode 100644
index 8117b2b..0000000
--- a/WebCore/platform/mac/ClipboardMac.mm
+++ /dev/null
@@ -1,360 +0,0 @@
-/*
- * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "ClipboardMac.h"
-
-#import "DOMElementInternal.h"
-#import "DragClient.h"
-#import "DragController.h"
-#import "Editor.h"
-#import "FoundationExtras.h"
-#import "Frame.h"
-#import "Image.h"
-#import "Page.h"
-#import "Pasteboard.h"
-#import "RenderImage.h"
-#import "WebCoreSystemInterface.h"
-
-namespace WebCore {
-
-ClipboardMac::ClipboardMac(bool forDragging, NSPasteboard *pasteboard, ClipboardAccessPolicy policy, Frame *frame)
- : Clipboard(policy, forDragging)
- , m_pasteboard(pasteboard)
- , m_frame(frame)
-{
- m_changeCount = [m_pasteboard.get() changeCount];
-}
-
-ClipboardMac::~ClipboardMac()
-{
-}
-
-bool ClipboardMac::hasData()
-{
- return m_pasteboard && [m_pasteboard.get() types] && [[m_pasteboard.get() types] count] > 0;
-}
-
-static NSString *cocoaTypeFromMIMEType(const String& type)
-{
- String qType = type.stripWhiteSpace();
-
- // two special cases for IE compatibility
- if (qType == "Text")
- return NSStringPboardType;
- if (qType == "URL")
- return NSURLPboardType;
-
- // Ignore any trailing charset - JS strings are Unicode, which encapsulates the charset issue
- if (qType == "text/plain" || qType.startsWith("text/plain;"))
- return NSStringPboardType;
- if (qType == "text/uri-list")
- // special case because UTI doesn't work with Cocoa's URL type
- return NSURLPboardType; // note special case in getData to read NSFilenamesType
-
- // Try UTI now
- NSString *mimeType = qType;
- CFStringRef UTIType = UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, (CFStringRef)mimeType, NULL);
- if (UTIType) {
- CFStringRef pbType = UTTypeCopyPreferredTagWithClass(UTIType, kUTTagClassNSPboardType);
- CFRelease(UTIType);
- if (pbType)
- return HardAutorelease(pbType);
- }
-
- // No mapping, just pass the whole string though
- return qType;
-}
-
-static String MIMETypeFromCocoaType(NSString *type)
-{
- // UTI may not do these right, so make sure we get the right, predictable result
- if ([type isEqualToString:NSStringPboardType])
- return "text/plain";
- if ([type isEqualToString:NSURLPboardType] || [type isEqualToString:NSFilenamesPboardType])
- return "text/uri-list";
-
- // Now try the general UTI mechanism
- CFStringRef UTIType = UTTypeCreatePreferredIdentifierForTag(kUTTagClassNSPboardType, (CFStringRef)type, NULL);
- if (UTIType) {
- CFStringRef mimeType = UTTypeCopyPreferredTagWithClass(UTIType, kUTTagClassMIMEType);
- CFRelease(UTIType);
- if (mimeType) {
- String result = mimeType;
- CFRelease(mimeType);
- return result;
- }
- }
-
- // No mapping, just pass the whole string though
- return type;
-}
-
-void ClipboardMac::clearData(const String& type)
-{
- if (policy() != ClipboardWritable)
- return;
-
- // note NSPasteboard enforces changeCount itself on writing - can't write if not the owner
-
- NSString *cocoaType = cocoaTypeFromMIMEType(type);
- if (cocoaType) {
- [m_pasteboard.get() setString:@"" forType:cocoaType];
- }
-}
-
-void ClipboardMac::clearAllData()
-{
- if (policy() != ClipboardWritable)
- return;
-
- // note NSPasteboard enforces changeCount itself on writing - can't write if not the owner
-
- [m_pasteboard.get() declareTypes:[NSArray array] owner:nil];
-}
-
-String ClipboardMac::getData(const String& type, bool& success) const
-{
- success = false;
- if (policy() != ClipboardReadable)
- return String();
-
- NSString *cocoaType = cocoaTypeFromMIMEType(type);
- NSString *cocoaValue = nil;
- NSArray *availableTypes = [m_pasteboard.get() types];
-
- // Fetch the data in different ways for the different Cocoa types
-
- if ([cocoaType isEqualToString:NSURLPboardType]) {
- // When both URL and filenames are present, filenames is superior since it can contain a list.
- // must check this or we get a printf from CF when there's no data of this type
- if ([availableTypes containsObject:NSFilenamesPboardType]) {
- NSArray *fileList = [m_pasteboard.get() propertyListForType:NSFilenamesPboardType];
- if (fileList && [fileList isKindOfClass:[NSArray class]]) {
- unsigned count = [fileList count];
- if (count > 0) {
- if (type != "text/uri-list")
- count = 1;
- NSMutableString *urls = [NSMutableString string];
- unsigned i;
- for (i = 0; i < count; i++) {
- if (i > 0) {
- [urls appendString:@"\n"];
- }
- NSString *string = [fileList objectAtIndex:i];
- if (![string isKindOfClass:[NSString class]])
- break;
- NSURL *url = [NSURL fileURLWithPath:string];
- [urls appendString:[url absoluteString]];
- }
- if (i == count)
- cocoaValue = urls;
- }
- }
- }
- if (!cocoaValue) {
- // must check this or we get a printf from CF when there's no data of this type
- if ([availableTypes containsObject:NSURLPboardType]) {
- NSURL *url = [NSURL URLFromPasteboard:m_pasteboard.get()];
- if (url) {
- cocoaValue = [url absoluteString];
- }
- }
- }
- } else if (cocoaType) {
- cocoaValue = [m_pasteboard.get() stringForType:cocoaType];
- }
-
- // Enforce changeCount ourselves for security. We check after reading instead of before to be
- // sure it doesn't change between our testing the change count and accessing the data.
- if (cocoaValue && m_changeCount == [m_pasteboard.get() changeCount]) {
- success = true;
- return cocoaValue;
- }
-
- return String();
-}
-
-bool ClipboardMac::setData(const String &type, const String &data)
-{
- if (policy() != ClipboardWritable)
- return false;
- // note NSPasteboard enforces changeCount itself on writing - can't write if not the owner
-
- NSString *cocoaType = cocoaTypeFromMIMEType(type);
- NSString *cocoaData = data;
-
- if ([cocoaType isEqualToString:NSURLPboardType]) {
- [m_pasteboard.get() addTypes:[NSArray arrayWithObject:NSURLPboardType] owner:nil];
- NSURL *url = [[NSURL alloc] initWithString:cocoaData];
- [url writeToPasteboard:m_pasteboard.get()];
-
- if ([url isFileURL]) {
- [m_pasteboard.get() addTypes:[NSArray arrayWithObject:NSFilenamesPboardType] owner:nil];
- NSArray *fileList = [NSArray arrayWithObject:[url path]];
- [m_pasteboard.get() setPropertyList:fileList forType:NSFilenamesPboardType];
- }
-
- [url release];
- return true;
- }
-
- if (cocoaType) {
- // everything else we know of goes on the pboard as a string
- [m_pasteboard.get() addTypes:[NSArray arrayWithObject:cocoaType] owner:nil];
- return [m_pasteboard.get() setString:cocoaData forType:cocoaType];
- }
-
- return false;
-}
-
-HashSet<String> ClipboardMac::types() const
-{
- if (policy() != ClipboardReadable && policy() != ClipboardTypesReadable)
- return HashSet<String>();
-
- NSArray *types = [m_pasteboard.get() types];
-
- // Enforce changeCount ourselves for security. We check after reading instead of before to be
- // sure it doesn't change between our testing the change count and accessing the data.
- if (m_changeCount != [m_pasteboard.get() changeCount])
- return HashSet<String>();
-
- HashSet<String> result;
- if (types) {
- unsigned count = [types count];
- unsigned i;
- for (i = 0; i < count; i++) {
- NSString *pbType = [types objectAtIndex:i];
- if ([pbType isEqualToString:@"NeXT plain ascii pasteboard type"])
- continue; // skip this ancient type that gets auto-supplied by some system conversion
-
- String str = MIMETypeFromCocoaType(pbType);
- if (!result.contains(str))
- result.add(str);
- }
- }
- return result;
-}
-
-// The rest of these getters don't really have any impact on security, so for now make no checks
-
-void ClipboardMac::setDragImage(CachedImage* img, const IntPoint &loc)
-{
- setDragImage(img, 0, loc);
-}
-
-void ClipboardMac::setDragImageElement(Node *node, const IntPoint &loc)
-{
- setDragImage(0, node, loc);
-}
-
-void ClipboardMac::setDragImage(CachedImage* image, Node *node, const IntPoint &loc)
-{
- if (policy() == ClipboardImageWritable || policy() == ClipboardWritable) {
- if (m_dragImage)
- m_dragImage->removeClient(this);
- m_dragImage = image;
- if (m_dragImage)
- m_dragImage->addClient(this);
-
- m_dragLoc = loc;
- m_dragImageElement = node;
-
- if (dragStarted() && m_changeCount == [m_pasteboard.get() changeCount]) {
- NSPoint cocoaLoc;
- NSImage* cocoaImage = dragNSImage(cocoaLoc);
- if (cocoaImage) {
- // Dashboard wants to be able to set the drag image during dragging, but Cocoa does not allow this.
- // Instead we must drop down to the CoreGraphics API.
- wkSetDragImage(cocoaImage, cocoaLoc);
-
- // Hack: We must post an event to wake up the NSDragManager, which is sitting in a nextEvent call
- // up the stack from us because the CoreFoundation drag manager does not use the run loop by itself.
- // This is the most innocuous event to use, per Kristen Forster.
- NSEvent* ev = [NSEvent mouseEventWithType:NSMouseMoved location:NSZeroPoint
- modifierFlags:0 timestamp:0 windowNumber:0 context:nil eventNumber:0 clickCount:0 pressure:0];
- [NSApp postEvent:ev atStart:YES];
- }
- }
- // Else either 1) we haven't started dragging yet, so we rely on the part to install this drag image
- // as part of getting the drag kicked off, or 2) Someone kept a ref to the clipboard and is trying to
- // set the image way too late.
- }
-}
-
-void ClipboardMac::writeRange(Range* range, Frame* frame)
-{
- ASSERT(range);
- ASSERT(frame);
- Pasteboard::writeSelection(m_pasteboard.get(), range, frame->editor()->smartInsertDeleteEnabled() && frame->selectionGranularity() == WordGranularity, frame);
-}
-
-void ClipboardMac::writeURL(const KURL& url, const String& title, Frame* frame)
-{
- ASSERT(frame);
- ASSERT(m_pasteboard);
- Pasteboard::writeURL(m_pasteboard.get(), nil, url, title, frame);
-}
-
-void ClipboardMac::declareAndWriteDragImage(Element* element, const KURL& url, const String& title, Frame* frame)
-{
- ASSERT(frame);
- if (Page* page = frame->page())
- page->dragController()->client()->declareAndWriteDragImage(m_pasteboard.get(), [DOMElement _wrapElement:element], url, title, frame);
-}
-
-DragImageRef ClipboardMac::createDragImage(IntPoint& loc) const
-{
- NSPoint nsloc = {loc.x(), loc.y()};
- DragImageRef result = dragNSImage(nsloc);
- loc = (IntPoint)nsloc;
- return result;
-}
-
-NSImage *ClipboardMac::dragNSImage(NSPoint& loc) const
-{
- NSImage *result = nil;
- if (m_dragImageElement) {
- if (m_frame) {
- NSRect imageRect;
- NSRect elementRect;
- result = m_frame->snapshotDragImage(m_dragImageElement.get(), &imageRect, &elementRect);
- // Client specifies point relative to element, not the whole image, which may include child
- // layers spread out all over the place.
- loc.x = elementRect.origin.x - imageRect.origin.x + m_dragLoc.x();
- loc.y = elementRect.origin.y - imageRect.origin.y + m_dragLoc.y();
- loc.y = imageRect.size.height - loc.y;
- }
- } else if (m_dragImage) {
- result = m_dragImage->image()->getNSImage();
-
- loc = m_dragLoc;
- loc.y = [result size].height - loc.y;
- }
- return result;
-}
-
-}
diff --git a/WebCore/platform/mac/ContextMenuItemMac.mm b/WebCore/platform/mac/ContextMenuItemMac.mm
deleted file mode 100644
index c5e2942..0000000
--- a/WebCore/platform/mac/ContextMenuItemMac.mm
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ContextMenuItem.h"
-
-#include "ContextMenu.h"
-
-namespace WebCore {
-
-static NSMutableArray* menuToArray(NSMenu* menu)
-{
- NSMutableArray* itemsArray = [NSMutableArray array];
- int total = [menu numberOfItems];
- for (int i = 0; i < total; i++)
- [itemsArray addObject:[menu itemAtIndex:i]];
-
- return itemsArray;
-}
-
-ContextMenuItem::ContextMenuItem(NSMenuItem* item)
-{
- m_platformDescription = item;
-}
-
-ContextMenuItem::ContextMenuItem(ContextMenu* subMenu)
-{
- NSMenuItem* item = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
- m_platformDescription = item;
- [item release];
-
- [m_platformDescription.get() setTag:ContextMenuItemTagNoAction];
- if (subMenu)
- setSubMenu(subMenu);
-}
-
-ContextMenuItem::ContextMenuItem(ContextMenuItemType type, ContextMenuAction action, const String& title, ContextMenu* subMenu)
-{
- if (type == SeparatorType) {
- m_platformDescription = [NSMenuItem separatorItem];
- return;
- }
-
- NSMenuItem* item = [[NSMenuItem alloc] initWithTitle:title action:nil keyEquivalent:@""];
- m_platformDescription = item;
- [item release];
-
- [m_platformDescription.get() setTag:action];
- if (subMenu)
- setSubMenu(subMenu);
-}
-
-ContextMenuItem::~ContextMenuItem()
-{
-}
-
-NSMenuItem* ContextMenuItem::releasePlatformDescription()
-{
- NSMenuItem* item = [m_platformDescription.get() retain];
- m_platformDescription = 0;
- return item;
-}
-
-ContextMenuItemType ContextMenuItem::type() const
-{
- if ([m_platformDescription.get() isSeparatorItem])
- return SeparatorType;
- if ([m_platformDescription.get() hasSubmenu])
- return SubmenuType;
- return ActionType;
-}
-
-ContextMenuAction ContextMenuItem::action() const
-{
- return static_cast<ContextMenuAction>([m_platformDescription.get() tag]);
-}
-
-String ContextMenuItem::title() const
-{
- return [m_platformDescription.get() title];
-}
-
-NSMutableArray* ContextMenuItem::platformSubMenu() const
-{
- return menuToArray([m_platformDescription.get() submenu]);
-}
-
-void ContextMenuItem::setType(ContextMenuItemType type)
-{
- if (type == SeparatorType)
- m_platformDescription = [NSMenuItem separatorItem];
-}
-
-void ContextMenuItem::setAction(ContextMenuAction action)
-{
- [m_platformDescription.get() setTag:action];
-}
-
-void ContextMenuItem::setTitle(const String& title)
-{
- [m_platformDescription.get() setTitle:title];
-}
-
-void ContextMenuItem::setSubMenu(ContextMenu* menu)
-{
- NSArray* subMenuArray = menu->platformDescription();
- NSMenu* subMenu = [[NSMenu alloc] init];
- [subMenu setAutoenablesItems:NO];
- for (unsigned i = 0; i < [subMenuArray count]; i++)
- [subMenu insertItem:[subMenuArray objectAtIndex:i] atIndex:i];
- [m_platformDescription.get() setSubmenu:subMenu];
- [subMenu release];
-}
-
-void ContextMenuItem::setChecked(bool checked)
-{
- if (checked)
- [m_platformDescription.get() setState:NSOnState];
- else
- [m_platformDescription.get() setState:NSOffState];
-}
-
-void ContextMenuItem::setEnabled(bool enable)
-{
- [m_platformDescription.get() setEnabled:enable];
-}
-
-bool ContextMenuItem::enabled() const
-{
- return [m_platformDescription.get() isEnabled];
-}
-
-}
diff --git a/WebCore/platform/mac/ContextMenuMac.mm b/WebCore/platform/mac/ContextMenuMac.mm
deleted file mode 100644
index b56d0b9..0000000
--- a/WebCore/platform/mac/ContextMenuMac.mm
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ContextMenu.h"
-
-#include "ContextMenuController.h"
-
-@interface WebCoreMenuTarget : NSObject {
- WebCore::ContextMenuController* _menuController;
-}
-+ (WebCoreMenuTarget*)sharedMenuTarget;
-- (WebCore::ContextMenuController*)menuController;
-- (void)setMenuController:(WebCore::ContextMenuController*)menuController;
-- (void)forwardContextMenuAction:(id)sender;
-- (BOOL)validateMenuItem:(NSMenuItem *)item;
-@end
-
-static WebCoreMenuTarget* target;
-
-@implementation WebCoreMenuTarget
-
-+ (WebCoreMenuTarget*)sharedMenuTarget
-{
- if (!target)
- target = [[WebCoreMenuTarget alloc] init];
- return target;
-}
-
-- (WebCore::ContextMenuController*)menuController
-{
- return _menuController;
-}
-
-- (void)setMenuController:(WebCore::ContextMenuController*)menuController
-{
- _menuController = menuController;
-}
-
-- (void)forwardContextMenuAction:(id)sender
-{
- WebCore::ContextMenuItem item(WebCore::ActionType, static_cast<WebCore::ContextMenuAction>([sender tag]), [sender title]);
- _menuController->contextMenuItemSelected(&item);
-}
-
-- (BOOL)validateMenuItem:(NSMenuItem *)item
-{
- WebCore::ContextMenuItem coreItem(item);
- ASSERT(_menuController->contextMenu());
- _menuController->contextMenu()->checkOrEnableIfNeeded(coreItem);
- return coreItem.enabled();
-}
-
-@end
-
-namespace WebCore {
-
-ContextMenu::ContextMenu(const HitTestResult& result)
- : m_hitTestResult(result)
-{
- NSMutableArray* array = [[NSMutableArray alloc] init];
- m_platformDescription = array;
- [array release];
-
- [[WebCoreMenuTarget sharedMenuTarget] setMenuController:controller()];
-}
-
-ContextMenu::ContextMenu(const HitTestResult& result, const PlatformMenuDescription menu)
- : m_hitTestResult(result)
- , m_platformDescription(menu)
-{
- [[WebCoreMenuTarget sharedMenuTarget] setMenuController:controller()];
-}
-
-ContextMenu::~ContextMenu()
-{
-}
-
-static void setMenuItemTarget(NSMenuItem* menuItem)
-{
- [menuItem setTarget:[WebCoreMenuTarget sharedMenuTarget]];
- [menuItem setAction:@selector(forwardContextMenuAction:)];
-}
-
-void ContextMenu::appendItem(ContextMenuItem& item)
-{
- checkOrEnableIfNeeded(item);
-
- ContextMenuItemType type = item.type();
- NSMenuItem* platformItem = item.releasePlatformDescription();
- if (type == ActionType)
- setMenuItemTarget(platformItem);
-
- [m_platformDescription.get() addObject:platformItem];
- [platformItem release];
-}
-
-void ContextMenu::insertItem(unsigned position, ContextMenuItem& item)
-{
- checkOrEnableIfNeeded(item);
-
- ContextMenuItemType type = item.type();
- NSMenuItem* platformItem = item.releasePlatformDescription();
- if (type == ActionType)
- setMenuItemTarget(platformItem);
-
- [m_platformDescription.get() insertObject:platformItem atIndex:position];
- [platformItem release];
-}
-
-unsigned ContextMenu::itemCount() const
-{
- return [m_platformDescription.get() count];
-}
-
-void ContextMenu::setPlatformDescription(NSMutableArray* menu)
-{
- if (m_platformDescription.get() != menu)
- m_platformDescription = menu;
-}
-
-NSMutableArray* ContextMenu::platformDescription() const
-{
- return m_platformDescription.get();
-}
-
-NSMutableArray* ContextMenu::releasePlatformDescription()
-{
- return m_platformDescription.releaseRef();
-}
-
-}
diff --git a/WebCore/platform/mac/CookieJar.mm b/WebCore/platform/mac/CookieJar.mm
deleted file mode 100644
index 5fe7a63..0000000
--- a/WebCore/platform/mac/CookieJar.mm
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2003, 2006, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "CookieJar.h"
-
-#import "BlockExceptions.h"
-#import "KURL.h"
-#import <wtf/RetainPtr.h>
-
-#ifdef BUILDING_ON_TIGER
-typedef unsigned NSUInteger;
-#endif
-
-namespace WebCore {
-
-String cookies(const Document* /*document*/, const KURL& url)
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
-
- NSURL *cookieURL = url;
- NSArray *cookiesForURL = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:cookieURL];
-
- // <rdar://problem/5632883> On 10.5, NSHTTPCookieStorage would happily store an empty cookie, which would be sent as "Cookie: =".
- // We have a workaround in setCookies() to prevent that, but we also need to avoid sending cookies that were previously stored.
- NSUInteger count = [cookiesForURL count];
- RetainPtr<NSMutableArray> cookiesForURLFilteredCopy(AdoptNS, [[NSMutableArray alloc] initWithCapacity:count]);
- for (NSUInteger i = 0; i < count; ++i) {
- NSHTTPCookie *cookie = (NSHTTPCookie *)[cookiesForURL objectAtIndex:i];
- if ([[cookie name] length] != 0)
- [cookiesForURLFilteredCopy.get() addObject:cookie];
- }
-
- NSDictionary *header = [NSHTTPCookie requestHeaderFieldsWithCookies:cookiesForURLFilteredCopy.get()];
- return [header objectForKey:@"Cookie"];
-
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-void setCookies(Document* /*document*/, const KURL& url, const KURL& policyBaseURL, const String& cookieStr)
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
-
- // <rdar://problem/5632883> On 10.5, NSHTTPCookieStorage would happily store an empty cookie, which would be sent as "Cookie: =".
- if (cookieStr.isEmpty())
- return;
-
- NSURL *cookieURL = url;
-
- // <http://bugs.webkit.org/show_bug.cgi?id=6531>, <rdar://4409034>
- // cookiesWithResponseHeaderFields doesn't parse cookies without a value
- String cookieString = cookieStr.contains('=') ? cookieStr : cookieStr + "=";
-
- NSArray *cookies = [NSHTTPCookie cookiesWithResponseHeaderFields:[NSDictionary dictionaryWithObject:cookieString forKey:@"Set-Cookie"] forURL:cookieURL];
- [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookies:cookies forURL:cookieURL mainDocumentURL:policyBaseURL];
-
- END_BLOCK_OBJC_EXCEPTIONS;
-}
-
-bool cookiesEnabled(const Document* /*document*/)
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
-
- NSHTTPCookieAcceptPolicy cookieAcceptPolicy = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookieAcceptPolicy];
- return cookieAcceptPolicy == NSHTTPCookieAcceptPolicyAlways || cookieAcceptPolicy == NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain;
-
- END_BLOCK_OBJC_EXCEPTIONS;
- return false;
-}
-
-}
diff --git a/WebCore/platform/mac/CursorMac.mm b/WebCore/platform/mac/CursorMac.mm
deleted file mode 100644
index b07964b..0000000
--- a/WebCore/platform/mac/CursorMac.mm
+++ /dev/null
@@ -1,355 +0,0 @@
-/*
- * Copyright (C) 2004, 2006 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "Cursor.h"
-
-#import "BlockExceptions.h"
-#import "FoundationExtras.h"
-#import "Image.h"
-#import "IntPoint.h"
-
-@interface WebCoreCursorBundle : NSObject { }
-@end
-
-@implementation WebCoreCursorBundle
-@end
-
-namespace WebCore {
-
-// Simple NSCursor calls shouldn't need protection,
-// but creating a cursor with a bad image might throw.
-
-static NSCursor* createCustomCursor(Image* image, const IntPoint& hotspot)
-{
- // FIXME: The cursor won't animate. Not sure if that's a big deal.
- NSImage* img = image->getNSImage();
- if (!img)
- return 0;
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[NSCursor alloc] initWithImage:img hotSpot:hotspot];
- END_BLOCK_OBJC_EXCEPTIONS;
- return 0;
-}
-
-// Leak these cursors intentionally, that way we won't waste time trying to clean them
-// up at process exit time.
-static NSCursor* leakNamedCursor(const char* name, int x, int y)
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- NSString* resourceName = [[NSString alloc] initWithUTF8String:name];
- NSImage* cursorImage = [[NSImage alloc] initWithContentsOfFile:
- [[NSBundle bundleForClass:[WebCoreCursorBundle class]]
- pathForResource:resourceName ofType:@"png"]];
- [resourceName release];
- NSCursor* cursor = 0;
- if (cursorImage) {
- NSPoint hotSpotPoint = {x, y}; // workaround for 4213314
- cursor = [[NSCursor alloc] initWithImage:cursorImage hotSpot:hotSpotPoint];
- [cursorImage release];
- }
- return cursor;
- END_BLOCK_OBJC_EXCEPTIONS;
- return 0;
-}
-
-Cursor::Cursor(Image* image, const IntPoint& hotspot)
- : m_impl(HardRetainWithNSRelease(createCustomCursor(image, hotspot)))
-{
-}
-
-Cursor::Cursor(const Cursor& other)
- : m_impl(HardRetain(other.m_impl))
-{
-}
-
-Cursor::~Cursor()
-{
- HardRelease(m_impl);
-}
-
-Cursor& Cursor::operator=(const Cursor& other)
-{
- HardRetain(other.m_impl);
- HardRelease(m_impl);
- m_impl = other.m_impl;
- return *this;
-}
-
-Cursor::Cursor(NSCursor* c)
- : m_impl(HardRetain(c))
-{
-}
-
-const Cursor& pointerCursor()
-{
- static Cursor c = [NSCursor arrowCursor];
- return c;
-}
-
-const Cursor& crossCursor()
-{
- static Cursor c = leakNamedCursor("crossHairCursor", 11, 11);
- return c;
-}
-
-const Cursor& handCursor()
-{
- static Cursor c = leakNamedCursor("linkCursor", 6, 1);
- return c;
-}
-
-const Cursor& moveCursor()
-{
- static Cursor c = leakNamedCursor("moveCursor", 7, 7);
- return c;
-}
-
-const Cursor& verticalTextCursor()
-{
- static Cursor c = leakNamedCursor("verticalTextCursor", 7, 7);
- return c;
-}
-
-const Cursor& cellCursor()
-{
- static Cursor c = leakNamedCursor("cellCursor", 7, 7);
- return c;
-}
-
-const Cursor& contextMenuCursor()
-{
- static Cursor c = leakNamedCursor("contextMenuCursor", 3, 2);
- return c;
-}
-
-const Cursor& aliasCursor()
-{
- static Cursor c = leakNamedCursor("aliasCursor", 11, 3);
- return c;
-}
-
-const Cursor& zoomInCursor()
-{
- static Cursor c = leakNamedCursor("zoomInCursor", 7, 7);
- return c;
-}
-
-const Cursor& zoomOutCursor()
-{
- static Cursor c = leakNamedCursor("zoomOutCursor", 7, 7);
- return c;
-}
-
-const Cursor& copyCursor()
-{
- static Cursor c = leakNamedCursor("copyCursor", 3, 2);
- return c;
-}
-
-const Cursor& noneCursor()
-{
- static Cursor c = leakNamedCursor("noneCursor", 7, 7);
- return c;
-}
-
-const Cursor& progressCursor()
-{
- static Cursor c = leakNamedCursor("progressCursor", 3, 2);
- return c;
-}
-
-const Cursor& noDropCursor()
-{
- static Cursor c = leakNamedCursor("noDropCursor", 3, 1);
- return c;
-}
-
-const Cursor& notAllowedCursor()
-{
- static Cursor c = leakNamedCursor("notAllowedCursor", 11, 11);
- return c;
-}
-
-const Cursor& iBeamCursor()
-{
- static Cursor c = [NSCursor IBeamCursor];
- return c;
-}
-
-const Cursor& waitCursor()
-{
- static Cursor c = leakNamedCursor("waitCursor", 7, 7);
- return c;
-}
-
-const Cursor& helpCursor()
-{
- static Cursor c = leakNamedCursor("helpCursor", 8, 8);
- return c;
-}
-
-const Cursor& eastResizeCursor()
-{
- static Cursor c = leakNamedCursor("eastResizeCursor", 14, 7);
- return c;
-}
-
-const Cursor& northResizeCursor()
-{
- static Cursor c = leakNamedCursor("northResizeCursor", 7, 1);
- return c;
-}
-
-const Cursor& northEastResizeCursor()
-{
- static Cursor c = leakNamedCursor("northEastResizeCursor", 14, 1);
- return c;
-}
-
-const Cursor& northWestResizeCursor()
-{
- static Cursor c = leakNamedCursor("northWestResizeCursor", 0, 0);
- return c;
-}
-
-const Cursor& southResizeCursor()
-{
- static Cursor c = leakNamedCursor("southResizeCursor", 7, 14);
- return c;
-}
-
-const Cursor& southEastResizeCursor()
-{
- static Cursor c = leakNamedCursor("southEastResizeCursor", 14, 14);
- return c;
-}
-
-const Cursor& southWestResizeCursor()
-{
- static Cursor c = leakNamedCursor("southWestResizeCursor", 1, 14);
- return c;
-}
-
-const Cursor& westResizeCursor()
-{
- static Cursor c = leakNamedCursor("westResizeCursor", 1, 7);
- return c;
-}
-
-const Cursor& northSouthResizeCursor()
-{
- static Cursor c = leakNamedCursor("northSouthResizeCursor", 7, 7);
- return c;
-}
-
-const Cursor& eastWestResizeCursor()
-{
- static Cursor c = leakNamedCursor("eastWestResizeCursor", 7, 7);
- return c;
-}
-
-const Cursor& northEastSouthWestResizeCursor()
-{
- static Cursor c = leakNamedCursor("northEastSouthWestResizeCursor", 7, 7);
- return c;
-}
-
-const Cursor& northWestSouthEastResizeCursor()
-{
- static Cursor c = leakNamedCursor("northWestSouthEastResizeCursor", 7, 7);
- return c;
-}
-
-const Cursor& columnResizeCursor()
-{
- static Cursor c = [NSCursor resizeLeftRightCursor];
- return c;
-}
-
-const Cursor& rowResizeCursor()
-{
- static Cursor c = [NSCursor resizeUpDownCursor];
- return c;
-}
-
-const Cursor& middlePanningCursor()
-{
- return moveCursor();
-}
-
-const Cursor& eastPanningCursor()
-{
- return eastResizeCursor();
-}
-
-const Cursor& northPanningCursor()
-{
- return northResizeCursor();
-}
-
-const Cursor& northEastPanningCursor()
-{
- return northEastResizeCursor();
-}
-
-const Cursor& northWestPanningCursor()
-{
- return northWestResizeCursor();
-}
-
-const Cursor& southPanningCursor()
-{
- return southResizeCursor();
-}
-
-const Cursor& southEastPanningCursor()
-{
- return southEastResizeCursor();
-}
-
-const Cursor& southWestPanningCursor()
-{
- return southWestResizeCursor();
-}
-
-const Cursor& westPanningCursor()
-{
- return westResizeCursor();
-}
-
-const Cursor& grabCursor()
-{
- static Cursor c = [NSCursor openHandCursor];
- return c;
-}
-
-const Cursor& grabbingCursor()
-{
- static Cursor c = [NSCursor closedHandCursor];
- return c;
-}
-
-}
diff --git a/WebCore/platform/mac/DragDataMac.mm b/WebCore/platform/mac/DragDataMac.mm
deleted file mode 100644
index bd66787..0000000
--- a/WebCore/platform/mac/DragDataMac.mm
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "DragData.h"
-
-#import "ClipboardMac.h"
-#import "ClipboardAccessPolicy.h"
-#import "Document.h"
-#import "DocumentFragment.h"
-#import "DOMDocumentFragment.h"
-#import "DOMDocumentFragmentInternal.h"
-#import "MIMETypeRegistry.h"
-#import "Pasteboard.h"
-#import "PasteboardHelper.h"
-
-namespace WebCore {
-
-DragData::DragData(DragDataRef data, const IntPoint& clientPosition, const IntPoint& globalPosition,
- DragOperation sourceOperationMask, PasteboardHelper* pasteboardHelper)
- : m_clientPosition(clientPosition)
- , m_globalPosition(globalPosition)
- , m_platformDragData(data)
- , m_draggingSourceOperationMask(sourceOperationMask)
- , m_pasteboardHelper(pasteboardHelper)
-{
- ASSERT(pasteboardHelper);
-}
-
-bool DragData::canSmartReplace() const
-{
- //Need to call this so that the various Pasteboard type strings are intialised
- Pasteboard::generalPasteboard();
- return [[[m_platformDragData draggingPasteboard] types] containsObject:WebSmartPastePboardType];
-}
-
-bool DragData::containsColor() const
-{
- return [[[m_platformDragData draggingPasteboard] types] containsObject:NSColorPboardType];
-}
-
-bool DragData::containsFiles() const
-{
- return [[[m_platformDragData draggingPasteboard] types] containsObject:NSFilenamesPboardType];
-}
-
-void DragData::asFilenames(Vector<String>& result) const
-{
- NSArray *filenames = [[m_platformDragData draggingPasteboard] propertyListForType:NSFilenamesPboardType];
- NSEnumerator *fileEnumerator = [filenames objectEnumerator];
-
- while (NSString *filename = [fileEnumerator nextObject])
- result.append(filename);
-}
-
-bool DragData::containsPlainText() const
-{
- NSPasteboard *pasteboard = [m_platformDragData draggingPasteboard];
- NSArray *types = [pasteboard types];
-
- return [types containsObject:NSStringPboardType]
- || [types containsObject:NSRTFDPboardType]
- || [types containsObject:NSRTFPboardType]
- || [types containsObject:NSFilenamesPboardType]
- || [NSURL URLFromPasteboard:pasteboard];
-}
-
-String DragData::asPlainText() const
-{
- return m_pasteboardHelper->plainTextFromPasteboard([m_platformDragData draggingPasteboard]);
-}
-
-Color DragData::asColor() const
-{
- NSColor *color = [NSColor colorFromPasteboard:[m_platformDragData draggingPasteboard]];
- return makeRGBA((int)([color redComponent] * 255.0 + 0.5), (int)([color greenComponent] * 255.0 + 0.5),
- (int)([color blueComponent] * 255.0 + 0.5), (int)([color alphaComponent] * 255.0 + 0.5));
-}
-
-PassRefPtr<Clipboard> DragData::createClipboard(ClipboardAccessPolicy policy) const
-{
- return ClipboardMac::create(true, [m_platformDragData draggingPasteboard], policy, 0);
-}
-
-bool DragData::containsCompatibleContent() const
-{
- NSPasteboard *pasteboard = [m_platformDragData draggingPasteboard];
- NSMutableSet *types = [NSMutableSet setWithArray:[pasteboard types]];
- [types intersectSet:[NSSet setWithArray:m_pasteboardHelper->insertablePasteboardTypes()]];
- return [types count] != 0;
-}
-
-bool DragData::containsURL() const
-{
- return !asURL().isEmpty();
-}
-
-String DragData::asURL(String* title) const
-{
- return m_pasteboardHelper->urlFromPasteboard([m_platformDragData draggingPasteboard], title);
-}
-
-PassRefPtr<DocumentFragment> DragData::asFragment(Document* doc) const
-{
- return [m_pasteboardHelper->fragmentFromPasteboard([m_platformDragData draggingPasteboard]) _documentFragment];
-}
-
-}
-
diff --git a/WebCore/platform/mac/DragImageMac.mm b/WebCore/platform/mac/DragImageMac.mm
deleted file mode 100644
index 098a548..0000000
--- a/WebCore/platform/mac/DragImageMac.mm
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#import "config.h"
-#import "DragImage.h"
-
-#import "CachedImage.h"
-#import "Image.h"
-#import "KURL.h"
-#import "PlatformString.h"
-#import "ResourceResponse.h"
-#import <FoundationExtras.h>
-
-namespace WebCore {
-
-
-
-IntSize dragImageSize(DragImageRef image)
-{
- return (IntSize)[image.get() size];
-}
-
-void deleteDragImage(DragImageRef image)
-{
- //DragImageRef is a RetainPtr, so we don't need to explicitly delete it
-}
-
-DragImageRef scaleDragImage(DragImageRef image, FloatSize scale)
-{
- NSSize originalSize = [image.get() size];
- NSSize newSize = NSMakeSize((originalSize.width * scale.width()), (originalSize.height * scale.height()));
- newSize.width = roundf(newSize.width);
- newSize.height = roundf(newSize.height);
- [image.get() setScalesWhenResized:YES];
- [image.get() setSize:newSize];
- return image;
-}
-
-DragImageRef dissolveDragImageToFraction(DragImageRef image, float delta)
-{
- RetainPtr<NSImage> dissolvedImage(AdoptNS, [[NSImage alloc] initWithSize:[image.get() size]]);
-
- NSPoint point = [image.get() isFlipped] ? NSMakePoint(0, [image.get() size].height) : NSZeroPoint;
-
- // In this case the dragging image is always correct.
- [dissolvedImage.get() setFlipped:[image.get() isFlipped]];
-
- [dissolvedImage.get() lockFocus];
- [image.get() dissolveToPoint:point fraction: delta];
- [dissolvedImage.get() unlockFocus];
-
- [image.get() lockFocus];
- [dissolvedImage.get() compositeToPoint:point operation:NSCompositeCopy];
- [image.get() unlockFocus];
-
- return image;
-}
-
-DragImageRef createDragImageFromImage(Image* image)
-{
- DragImageRef dragImage(AdoptNS, [image->getNSImage() copy]);
- [dragImage.get() setSize:(NSSize)(image->size())];
- return dragImage;
-}
-
-DragImageRef createDragImageIconForCachedImage(CachedImage* image)
-{
- const String& filename = image->response().suggestedFilename();
- NSString *extension = nil;
- int dotIndex = filename.reverseFind('.');
-
- if (dotIndex > 0 && dotIndex < (int)(filename.length() - 1)) // require that a . exists after the first character and before the last
- extension = filename.substring(dotIndex + 1);
- else
- //It might be worth doing a further look up to pull the extension from the mimetype
- extension = @"";
-
- return DragImageRef([[NSWorkspace sharedWorkspace] iconForFileType:extension]);
-
-}
-
-}
diff --git a/WebCore/platform/mac/EventLoopMac.mm b/WebCore/platform/mac/EventLoopMac.mm
deleted file mode 100644
index 05ef33a..0000000
--- a/WebCore/platform/mac/EventLoopMac.mm
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "EventLoop.h"
-
-namespace WebCore {
-
-void EventLoop::cycle()
-{
- // FIXME: Should this use NSRunLoopCommonModes? Switching to NSRunLoopCommonModes causes Safari to hang in a tight loop.
- [NSApp setWindowsNeedUpdate:YES];
- NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantFuture] inMode:NSDefaultRunLoopMode dequeue:YES];
- [NSApp sendEvent:event];
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/mac/FileChooserMac.mm b/WebCore/platform/mac/FileChooserMac.mm
deleted file mode 100644
index 03532ff..0000000
--- a/WebCore/platform/mac/FileChooserMac.mm
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#import "config.h"
-#import "FileChooser.h"
-
-#import "LocalizedStrings.h"
-#import "SimpleFontData.h"
-#import "StringTruncator.h"
-
-namespace WebCore {
-
-String FileChooser::basenameForWidth(const Font& font, int width) const
-{
- if (width <= 0)
- return String();
-
- String strToTruncate;
- if (m_filenames.isEmpty())
- strToTruncate = fileButtonNoFileSelectedLabel();
- else if (m_filenames.size() == 1)
- strToTruncate = [[NSFileManager defaultManager] displayNameAtPath:(m_filenames[0])];
- else
- return StringTruncator::rightTruncate(multipleFileUploadText(m_filenames.size()), width, font, false);
-
- return StringTruncator::centerTruncate(strToTruncate, width, font, false);
-}
-
-}
diff --git a/WebCore/platform/mac/FileSystemMac.mm b/WebCore/platform/mac/FileSystemMac.mm
deleted file mode 100644
index 98f85bb..0000000
--- a/WebCore/platform/mac/FileSystemMac.mm
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#import "config.h"
-#import "FileSystem.h"
-
-#import "PlatformString.h"
-
-namespace WebCore {
-
-String homeDirectoryPath()
-{
- return NSHomeDirectory();
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/mac/FoundationExtras.h b/WebCore/platform/mac/FoundationExtras.h
deleted file mode 100644
index 51a7df0..0000000
--- a/WebCore/platform/mac/FoundationExtras.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2004 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-// nil-checked CFRetain/CFRelease covers for Objective-C ids
-
-// Use CFRetain, CFRelease, HardRetain, or HardRelease instead of
-// -[NSObject retain] and -[NSObject release] if you want to store
-// a pointer to an Objective-C object into memory that won't
-// be scanned for GC, like a C++ object.
-
-static inline id HardRetain(id obj)
-{
- if (obj) CFRetain(obj);
- return obj;
-}
-
-static inline void HardRelease(id obj)
-{
- if (obj) CFRelease(obj);
-}
-
-// As if CF and Foundation had logically separate reference counts,
-// this function first increments the CF retain count, and then
-// decrements the NS retain count. This is needed to handle cases where
-// -retain/-release aren't equivalent to CFRetain/HardRelease, such as
-// when GC is used.
-
-// Use HardRetainWithNSRelease after allocating and initializing a NSObject
-// if you want to store a pointer to that object into memory that won't
-// be scanned for GC, like a C++ object.
-
-static inline id HardRetainWithNSRelease(id obj)
-{
- HardRetain(obj);
- [obj release];
- return obj;
-}
-
-// Use HardAutorelease to return an object made by a CoreFoundation
-// "create" or "copy" function as an autoreleased and garbage collected
-// object. CF objects need to be "made collectable" for autorelease to work
-// properly under GC.
-
-static inline id HardAutorelease(CFTypeRef obj)
-{
- if (obj)
- CFMakeCollectable(obj);
- [(id)obj autorelease];
- return (id)obj;
-}
diff --git a/WebCore/platform/mac/KURLMac.mm b/WebCore/platform/mac/KURLMac.mm
deleted file mode 100644
index c913ab4..0000000
--- a/WebCore/platform/mac/KURLMac.mm
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2004, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "KURL.h"
-
-#import "FoundationExtras.h"
-
-namespace WebCore {
-
-KURL::KURL(NSURL *url)
-{
- if (!url) {
- parse(0, 0);
- return;
- }
-
- CFIndex bytesLength = CFURLGetBytes(reinterpret_cast<CFURLRef>(url), 0, 0);
- Vector<char, 512> buffer(bytesLength + 6); // 5 for "file:", 1 for null character to end C string
- char* bytes = &buffer[5];
- CFURLGetBytes(reinterpret_cast<CFURLRef>(url), reinterpret_cast<UInt8*>(bytes), bytesLength);
- bytes[bytesLength] = '\0';
- if (bytes[0] != '/') {
- parse(bytes, 0);
- return;
- }
-
- buffer[0] = 'f';
- buffer[1] = 'i';
- buffer[2] = 'l';
- buffer[3] = 'e';
- buffer[4] = ':';
-
- parse(buffer.data(), 0);
-}
-
-KURL::operator NSURL *() const
-{
- if (isNull())
- return nil;
-
- // CFURL can't hold an empty URL, unlike NSURL.
- if (isEmpty())
- return [NSURL URLWithString:@""];
-
- return HardAutorelease(createCFURL());
-}
-
-}
diff --git a/WebCore/platform/mac/KeyEventMac.mm b/WebCore/platform/mac/KeyEventMac.mm
deleted file mode 100644
index b6c3b21..0000000
--- a/WebCore/platform/mac/KeyEventMac.mm
+++ /dev/null
@@ -1,876 +0,0 @@
-/*
- * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "PlatformKeyboardEvent.h"
-
-#import "Logging.h"
-#import <Carbon/Carbon.h>
-#import <wtf/ASCIICType.h>
-
-using namespace WTF;
-
-namespace WebCore {
-
-static String keyIdentifierForKeyEvent(NSEvent* event)
-{
- if ([event type] == NSFlagsChanged)
- switch ([event keyCode]) {
- case 54: // Right Command
- case 55: // Left Command
- return "Meta";
-
- case 57: // Capslock
- return "CapsLock";
-
- case 56: // Left Shift
- case 60: // Right Shift
- return "Shift";
-
- case 58: // Left Alt
- case 61: // Right Alt
- return "Alt";
-
- case 59: // Left Ctrl
- case 62: // Right Ctrl
- return "Control";
-
- default:
- ASSERT_NOT_REACHED();
- return "";
- }
-
- NSString *s = [event charactersIgnoringModifiers];
- if ([s length] != 1) {
- LOG(Events, "received an unexpected number of characters in key event: %u", [s length]);
- return "Unidentified";
- }
- unichar c = [s characterAtIndex:0];
- switch (c) {
- // Each identifier listed in the DOM spec is listed here.
- // Many are simply commented out since they do not appear on standard Macintosh keyboards
- // or are on a key that doesn't have a corresponding character.
-
- // "Accept"
- // "AllCandidates"
-
- // "Alt"
- case NSMenuFunctionKey:
- return "Alt";
-
- // "Apps"
- // "BrowserBack"
- // "BrowserForward"
- // "BrowserHome"
- // "BrowserRefresh"
- // "BrowserSearch"
- // "BrowserStop"
- // "CapsLock"
-
- // "Clear"
- case NSClearLineFunctionKey:
- return "Clear";
-
- // "CodeInput"
- // "Compose"
- // "Control"
- // "Crsel"
- // "Convert"
- // "Copy"
- // "Cut"
-
- // "Down"
- case NSDownArrowFunctionKey:
- return "Down";
- // "End"
- case NSEndFunctionKey:
- return "End";
- // "Enter"
- case 0x3: case 0xA: case 0xD: // Macintosh calls the one on the main keyboard Return, but Windows calls it Enter, so we'll do the same for the DOM
- return "Enter";
-
- // "EraseEof"
-
- // "Execute"
- case NSExecuteFunctionKey:
- return "Execute";
-
- // "Exsel"
-
- // "F1"
- case NSF1FunctionKey:
- return "F1";
- // "F2"
- case NSF2FunctionKey:
- return "F2";
- // "F3"
- case NSF3FunctionKey:
- return "F3";
- // "F4"
- case NSF4FunctionKey:
- return "F4";
- // "F5"
- case NSF5FunctionKey:
- return "F5";
- // "F6"
- case NSF6FunctionKey:
- return "F6";
- // "F7"
- case NSF7FunctionKey:
- return "F7";
- // "F8"
- case NSF8FunctionKey:
- return "F8";
- // "F9"
- case NSF9FunctionKey:
- return "F9";
- // "F10"
- case NSF10FunctionKey:
- return "F10";
- // "F11"
- case NSF11FunctionKey:
- return "F11";
- // "F12"
- case NSF12FunctionKey:
- return "F12";
- // "F13"
- case NSF13FunctionKey:
- return "F13";
- // "F14"
- case NSF14FunctionKey:
- return "F14";
- // "F15"
- case NSF15FunctionKey:
- return "F15";
- // "F16"
- case NSF16FunctionKey:
- return "F16";
- // "F17"
- case NSF17FunctionKey:
- return "F17";
- // "F18"
- case NSF18FunctionKey:
- return "F18";
- // "F19"
- case NSF19FunctionKey:
- return "F19";
- // "F20"
- case NSF20FunctionKey:
- return "F20";
- // "F21"
- case NSF21FunctionKey:
- return "F21";
- // "F22"
- case NSF22FunctionKey:
- return "F22";
- // "F23"
- case NSF23FunctionKey:
- return "F23";
- // "F24"
- case NSF24FunctionKey:
- return "F24";
-
- // "FinalMode"
-
- // "Find"
- case NSFindFunctionKey:
- return "Find";
-
- // "FullWidth"
- // "HalfWidth"
- // "HangulMode"
- // "HanjaMode"
-
- // "Help"
- case NSHelpFunctionKey:
- return "Help";
-
- // "Hiragana"
-
- // "Home"
- case NSHomeFunctionKey:
- return "Home";
- // "Insert"
- case NSInsertFunctionKey:
- return "Insert";
-
- // "JapaneseHiragana"
- // "JapaneseKatakana"
- // "JapaneseRomaji"
- // "JunjaMode"
- // "KanaMode"
- // "KanjiMode"
- // "Katakana"
- // "LaunchApplication1"
- // "LaunchApplication2"
- // "LaunchMail"
-
- // "Left"
- case NSLeftArrowFunctionKey:
- return "Left";
-
- // "Meta"
- // "MediaNextTrack"
- // "MediaPlayPause"
- // "MediaPreviousTrack"
- // "MediaStop"
-
- // "ModeChange"
- case NSModeSwitchFunctionKey:
- return "ModeChange";
-
- // "Nonconvert"
- // "NumLock"
-
- // "PageDown"
- case NSPageDownFunctionKey:
- return "PageDown";
- // "PageUp"
- case NSPageUpFunctionKey:
- return "PageUp";
-
- // "Paste"
-
- // "Pause"
- case NSPauseFunctionKey:
- return "Pause";
-
- // "Play"
- // "PreviousCandidate"
-
- // "PrintScreen"
- case NSPrintScreenFunctionKey:
- return "PrintScreen";
-
- // "Process"
- // "Props"
-
- // "Right"
- case NSRightArrowFunctionKey:
- return "Right";
-
- // "RomanCharacters"
-
- // "Scroll"
- case NSScrollLockFunctionKey:
- return "Scroll";
- // "Select"
- case NSSelectFunctionKey:
- return "Select";
-
- // "SelectMedia"
- // "Shift"
-
- // "Stop"
- case NSStopFunctionKey:
- return "Stop";
- // "Up"
- case NSUpArrowFunctionKey:
- return "Up";
- // "Undo"
- case NSUndoFunctionKey:
- return "Undo";
-
- // "VolumeDown"
- // "VolumeMute"
- // "VolumeUp"
- // "Win"
- // "Zoom"
-
- // More function keys, not in the key identifier specification.
- case NSF25FunctionKey:
- return "F25";
- case NSF26FunctionKey:
- return "F26";
- case NSF27FunctionKey:
- return "F27";
- case NSF28FunctionKey:
- return "F28";
- case NSF29FunctionKey:
- return "F29";
- case NSF30FunctionKey:
- return "F30";
- case NSF31FunctionKey:
- return "F31";
- case NSF32FunctionKey:
- return "F32";
- case NSF33FunctionKey:
- return "F33";
- case NSF34FunctionKey:
- return "F34";
- case NSF35FunctionKey:
- return "F35";
-
- // Turn 0x7F into 0x08, because backspace needs to always be 0x08.
- case 0x7F:
- return "U+0008";
- // Standard says that DEL becomes U+007F.
- case NSDeleteFunctionKey:
- return "U+007F";
-
- // Always use 0x09 for tab instead of AppKit's backtab character.
- case NSBackTabCharacter:
- return "U+0009";
-
- case NSBeginFunctionKey:
- case NSBreakFunctionKey:
- case NSClearDisplayFunctionKey:
- case NSDeleteCharFunctionKey:
- case NSDeleteLineFunctionKey:
- case NSInsertCharFunctionKey:
- case NSInsertLineFunctionKey:
- case NSNextFunctionKey:
- case NSPrevFunctionKey:
- case NSPrintFunctionKey:
- case NSRedoFunctionKey:
- case NSResetFunctionKey:
- case NSSysReqFunctionKey:
- case NSSystemFunctionKey:
- case NSUserFunctionKey:
- // FIXME: We should use something other than the vendor-area Unicode values for the above keys.
- // For now, just fall through to the default.
- default:
- return String::format("U+%04X", toASCIIUpper(c));
- }
-}
-
-static bool isKeypadEvent(NSEvent* event)
-{
- // Check that this is the type of event that has a keyCode.
- switch ([event type]) {
- case NSKeyDown:
- case NSKeyUp:
- case NSFlagsChanged:
- break;
- default:
- return false;
- }
-
- switch ([event keyCode]) {
- case 71: // Clear
- case 81: // =
- case 75: // /
- case 67: // *
- case 78: // -
- case 69: // +
- case 76: // Enter
- case 65: // .
- case 82: // 0
- case 83: // 1
- case 84: // 2
- case 85: // 3
- case 86: // 4
- case 87: // 5
- case 88: // 6
- case 89: // 7
- case 91: // 8
- case 92: // 9
- return true;
- }
-
- return false;
-}
-
-static int windowsKeyCodeForKeyEvent(NSEvent* event)
-{
- switch ([event keyCode]) {
- // VK_TAB (09) TAB key
- case 48: return 0x09;
-
- // VK_APPS (5D) Right windows/meta key
- case 54: // Right Command
- return 0x5D;
-
- // VK_LWIN (5B) Left windows/meta key
- case 55: // Left Command
- return 0x5B;
-
- // VK_CAPITAL (14) caps locks key
- case 57: // Capslock
- return 0x14;
-
- // VK_SHIFT (10) either shift key
- case 56: // Left Shift
- case 60: // Right Shift
- return 0x10;
-
- // VK_MENU (12) either alt key
- case 58: // Left Alt
- case 61: // Right Alt
- return 0x12;
-
- // VK_CONTROL (11) either ctrl key
- case 59: // Left Ctrl
- case 62: // Right Ctrl
- return 0x11;
-
- // VK_CLEAR (0C) CLEAR key
- case 71: return 0x0C;
-
- // VK_NUMPAD0 (60) Numeric keypad 0 key
- case 82: return 0x60;
- // VK_NUMPAD1 (61) Numeric keypad 1 key
- case 83: return 0x61;
- // VK_NUMPAD2 (62) Numeric keypad 2 key
- case 84: return 0x62;
- // VK_NUMPAD3 (63) Numeric keypad 3 key
- case 85: return 0x63;
- // VK_NUMPAD4 (64) Numeric keypad 4 key
- case 86: return 0x64;
- // VK_NUMPAD5 (65) Numeric keypad 5 key
- case 87: return 0x65;
- // VK_NUMPAD6 (66) Numeric keypad 6 key
- case 88: return 0x66;
- // VK_NUMPAD7 (67) Numeric keypad 7 key
- case 89: return 0x67;
- // VK_NUMPAD8 (68) Numeric keypad 8 key
- case 91: return 0x68;
- // VK_NUMPAD9 (69) Numeric keypad 9 key
- case 92: return 0x69;
- // VK_MULTIPLY (6A) Multiply key
- case 67: return 0x6A;
- // VK_ADD (6B) Add key
- case 69: return 0x6B;
-
- // VK_SUBTRACT (6D) Subtract key
- case 78: return 0x6D;
- // VK_DECIMAL (6E) Decimal key
- case 65: return 0x6E;
- // VK_DIVIDE (6F) Divide key
- case 75: return 0x6F;
- }
-
- NSString* s = [event charactersIgnoringModifiers];
- if ([s length] != 1)
- return 0;
-
- switch ([s characterAtIndex:0]) {
- // VK_LBUTTON (01) Left mouse button
- // VK_RBUTTON (02) Right mouse button
- // VK_CANCEL (03) Control-break processing
- // VK_MBUTTON (04) Middle mouse button (three-button mouse)
- // VK_XBUTTON1 (05)
- // VK_XBUTTON2 (06)
-
- // VK_BACK (08) BACKSPACE key
- case 8: case 0x7F: return 0x08;
- // VK_TAB (09) TAB key
- case 9: return 0x09;
-
- // VK_CLEAR (0C) CLEAR key
- // handled by key code above
-
- // VK_RETURN (0D)
- case 0xD: case 3: return 0x0D;
-
- // VK_SHIFT (10) SHIFT key
- // VK_CONTROL (11) CTRL key
- // VK_MENU (12) ALT key
-
- // VK_PAUSE (13) PAUSE key
- case NSPauseFunctionKey: return 0x13;
-
- // VK_CAPITAL (14) CAPS LOCK key
- // VK_KANA (15) Input Method Editor (IME) Kana mode
- // VK_HANGUEL (15) IME Hanguel mode (maintained for compatibility; use VK_HANGUL)
- // VK_HANGUL (15) IME Hangul mode
- // VK_JUNJA (17) IME Junja mode
- // VK_FINAL (18) IME final mode
- // VK_HANJA (19) IME Hanja mode
- // VK_KANJI (19) IME Kanji mode
-
- // VK_ESCAPE (1B) ESC key
- case 0x1B: return 0x1B;
-
- // VK_CONVERT (1C) IME convert
- // VK_NONCONVERT (1D) IME nonconvert
- // VK_ACCEPT (1E) IME accept
- // VK_MODECHANGE (1F) IME mode change request
-
- // VK_SPACE (20) SPACEBAR
- case ' ': return 0x20;
- // VK_PRIOR (21) PAGE UP key
- case NSPageUpFunctionKey: return 0x21;
- // VK_NEXT (22) PAGE DOWN key
- case NSPageDownFunctionKey: return 0x22;
- // VK_END (23) END key
- case NSEndFunctionKey: return 0x23;
- // VK_HOME (24) HOME key
- case NSHomeFunctionKey: return 0x24;
- // VK_LEFT (25) LEFT ARROW key
- case NSLeftArrowFunctionKey: return 0x25;
- // VK_UP (26) UP ARROW key
- case NSUpArrowFunctionKey: return 0x26;
- // VK_RIGHT (27) RIGHT ARROW key
- case NSRightArrowFunctionKey: return 0x27;
- // VK_DOWN (28) DOWN ARROW key
- case NSDownArrowFunctionKey: return 0x28;
- // VK_SELECT (29) SELECT key
- case NSSelectFunctionKey: return 0x29;
- // VK_PRINT (2A) PRINT key
- case NSPrintFunctionKey: return 0x2A;
- // VK_EXECUTE (2B) EXECUTE key
- case NSExecuteFunctionKey: return 0x2B;
- // VK_SNAPSHOT (2C) PRINT SCREEN key
- case NSPrintScreenFunctionKey: return 0x2C;
- // VK_INSERT (2D) INS key
- case NSInsertFunctionKey: case NSHelpFunctionKey: return 0x2D;
- // VK_DELETE (2E) DEL key
- case NSDeleteFunctionKey: return 0x2E;
-
- // VK_HELP (2F) HELP key
-
- // (30) 0 key
- case '0': case ')': return 0x30;
- // (31) 1 key
- case '1': case '!': return 0x31;
- // (32) 2 key
- case '2': case '@': return 0x32;
- // (33) 3 key
- case '3': case '#': return 0x33;
- // (34) 4 key
- case '4': case '$': return 0x34;
- // (35) 5 key
- case '5': case '%': return 0x35;
- // (36) 6 key
- case '6': case '^': return 0x36;
- // (37) 7 key
- case '7': case '&': return 0x37;
- // (38) 8 key
- case '8': case '*': return 0x38;
- // (39) 9 key
- case '9': case '(': return 0x39;
- // (41) A key
- case 'a': case 'A': return 0x41;
- // (42) B key
- case 'b': case 'B': return 0x42;
- // (43) C key
- case 'c': case 'C': return 0x43;
- // (44) D key
- case 'd': case 'D': return 0x44;
- // (45) E key
- case 'e': case 'E': return 0x45;
- // (46) F key
- case 'f': case 'F': return 0x46;
- // (47) G key
- case 'g': case 'G': return 0x47;
- // (48) H key
- case 'h': case 'H': return 0x48;
- // (49) I key
- case 'i': case 'I': return 0x49;
- // (4A) J key
- case 'j': case 'J': return 0x4A;
- // (4B) K key
- case 'k': case 'K': return 0x4B;
- // (4C) L key
- case 'l': case 'L': return 0x4C;
- // (4D) M key
- case 'm': case 'M': return 0x4D;
- // (4E) N key
- case 'n': case 'N': return 0x4E;
- // (4F) O key
- case 'o': case 'O': return 0x4F;
- // (50) P key
- case 'p': case 'P': return 0x50;
- // (51) Q key
- case 'q': case 'Q': return 0x51;
- // (52) R key
- case 'r': case 'R': return 0x52;
- // (53) S key
- case 's': case 'S': return 0x53;
- // (54) T key
- case 't': case 'T': return 0x54;
- // (55) U key
- case 'u': case 'U': return 0x55;
- // (56) V key
- case 'v': case 'V': return 0x56;
- // (57) W key
- case 'w': case 'W': return 0x57;
- // (58) X key
- case 'x': case 'X': return 0x58;
- // (59) Y key
- case 'y': case 'Y': return 0x59;
- // (5A) Z key
- case 'z': case 'Z': return 0x5A;
-
- // VK_LWIN (5B) Left Windows key (Microsoft Natural keyboard)
- // VK_RWIN (5C) Right Windows key (Natural keyboard)
- // VK_APPS (5D) Applications key (Natural keyboard)
- // VK_SLEEP (5F) Computer Sleep key
-
- // VK_NUMPAD0 (60) Numeric keypad 0 key
- // VK_NUMPAD1 (61) Numeric keypad 1 key
- // VK_NUMPAD2 (62) Numeric keypad 2 key
- // VK_NUMPAD3 (63) Numeric keypad 3 key
- // VK_NUMPAD4 (64) Numeric keypad 4 key
- // VK_NUMPAD5 (65) Numeric keypad 5 key
- // VK_NUMPAD6 (66) Numeric keypad 6 key
- // VK_NUMPAD7 (67) Numeric keypad 7 key
- // VK_NUMPAD8 (68) Numeric keypad 8 key
- // VK_NUMPAD9 (69) Numeric keypad 9 key
- // VK_MULTIPLY (6A) Multiply key
- // VK_ADD (6B) Add key
- // handled by key code above
-
- // VK_SEPARATOR (6C) Separator key
-
- // VK_SUBTRACT (6D) Subtract key
- // VK_DECIMAL (6E) Decimal key
- // VK_DIVIDE (6F) Divide key
- // handled by key code above
-
- // VK_F1 (70) F1 key
- case NSF1FunctionKey: return 0x70;
- // VK_F2 (71) F2 key
- case NSF2FunctionKey: return 0x71;
- // VK_F3 (72) F3 key
- case NSF3FunctionKey: return 0x72;
- // VK_F4 (73) F4 key
- case NSF4FunctionKey: return 0x73;
- // VK_F5 (74) F5 key
- case NSF5FunctionKey: return 0x74;
- // VK_F6 (75) F6 key
- case NSF6FunctionKey: return 0x75;
- // VK_F7 (76) F7 key
- case NSF7FunctionKey: return 0x76;
- // VK_F8 (77) F8 key
- case NSF8FunctionKey: return 0x77;
- // VK_F9 (78) F9 key
- case NSF9FunctionKey: return 0x78;
- // VK_F10 (79) F10 key
- case NSF10FunctionKey: return 0x79;
- // VK_F11 (7A) F11 key
- case NSF11FunctionKey: return 0x7A;
- // VK_F12 (7B) F12 key
- case NSF12FunctionKey: return 0x7B;
- // VK_F13 (7C) F13 key
- case NSF13FunctionKey: return 0x7C;
- // VK_F14 (7D) F14 key
- case NSF14FunctionKey: return 0x7D;
- // VK_F15 (7E) F15 key
- case NSF15FunctionKey: return 0x7E;
- // VK_F16 (7F) F16 key
- case NSF16FunctionKey: return 0x7F;
- // VK_F17 (80H) F17 key
- case NSF17FunctionKey: return 0x80;
- // VK_F18 (81H) F18 key
- case NSF18FunctionKey: return 0x81;
- // VK_F19 (82H) F19 key
- case NSF19FunctionKey: return 0x82;
- // VK_F20 (83H) F20 key
- case NSF20FunctionKey: return 0x83;
- // VK_F21 (84H) F21 key
- case NSF21FunctionKey: return 0x84;
- // VK_F22 (85H) F22 key
- case NSF22FunctionKey: return 0x85;
- // VK_F23 (86H) F23 key
- case NSF23FunctionKey: return 0x86;
- // VK_F24 (87H) F24 key
- case NSF24FunctionKey: return 0x87;
-
- // VK_NUMLOCK (90) NUM LOCK key
-
- // VK_SCROLL (91) SCROLL LOCK key
- case NSScrollLockFunctionKey: return 0x91;
-
- // VK_LSHIFT (A0) Left SHIFT key
- // VK_RSHIFT (A1) Right SHIFT key
- // VK_LCONTROL (A2) Left CONTROL key
- // VK_RCONTROL (A3) Right CONTROL key
- // VK_LMENU (A4) Left MENU key
- // VK_RMENU (A5) Right MENU key
- // VK_BROWSER_BACK (A6) Windows 2000/XP: Browser Back key
- // VK_BROWSER_FORWARD (A7) Windows 2000/XP: Browser Forward key
- // VK_BROWSER_REFRESH (A8) Windows 2000/XP: Browser Refresh key
- // VK_BROWSER_STOP (A9) Windows 2000/XP: Browser Stop key
- // VK_BROWSER_SEARCH (AA) Windows 2000/XP: Browser Search key
- // VK_BROWSER_FAVORITES (AB) Windows 2000/XP: Browser Favorites key
- // VK_BROWSER_HOME (AC) Windows 2000/XP: Browser Start and Home key
- // VK_VOLUME_MUTE (AD) Windows 2000/XP: Volume Mute key
- // VK_VOLUME_DOWN (AE) Windows 2000/XP: Volume Down key
- // VK_VOLUME_UP (AF) Windows 2000/XP: Volume Up key
- // VK_MEDIA_NEXT_TRACK (B0) Windows 2000/XP: Next Track key
- // VK_MEDIA_PREV_TRACK (B1) Windows 2000/XP: Previous Track key
- // VK_MEDIA_STOP (B2) Windows 2000/XP: Stop Media key
- // VK_MEDIA_PLAY_PAUSE (B3) Windows 2000/XP: Play/Pause Media key
- // VK_LAUNCH_MAIL (B4) Windows 2000/XP: Start Mail key
- // VK_LAUNCH_MEDIA_SELECT (B5) Windows 2000/XP: Select Media key
- // VK_LAUNCH_APP1 (B6) Windows 2000/XP: Start Application 1 key
- // VK_LAUNCH_APP2 (B7) Windows 2000/XP: Start Application 2 key
-
- // VK_OEM_1 (BA) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ';:' key
- case ';': case ':': return 0xBA;
- // VK_OEM_PLUS (BB) Windows 2000/XP: For any country/region, the '+' key
- case '=': case '+': return 0xBB;
- // VK_OEM_COMMA (BC) Windows 2000/XP: For any country/region, the ',' key
- case ',': case '<': return 0xBC;
- // VK_OEM_MINUS (BD) Windows 2000/XP: For any country/region, the '-' key
- case '-': case '_': return 0xBD;
- // VK_OEM_PERIOD (BE) Windows 2000/XP: For any country/region, the '.' key
- case '.': case '>': return 0xBE;
- // VK_OEM_2 (BF) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '/?' key
- case '/': case '?': return 0xBF;
- // VK_OEM_3 (C0) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '`~' key
- case '`': case '~': return 0xC0;
- // VK_OEM_4 (DB) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '[{' key
- case '[': case '{': return 0xDB;
- // VK_OEM_5 (DC) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '\|' key
- case '\\': case '|': return 0xDC;
- // VK_OEM_6 (DD) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ']}' key
- case ']': case '}': return 0xDD;
- // VK_OEM_7 (DE) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the 'single-quote/double-quote' key
- case '\'': case '"': return 0xDE;
-
- // VK_OEM_8 (DF) Used for miscellaneous characters; it can vary by keyboard.
- // VK_OEM_102 (E2) Windows 2000/XP: Either the angle bracket key or the backslash key on the RT 102-key keyboard
- // VK_PROCESSKEY (E5) Windows 95/98/Me, Windows NT 4.0, Windows 2000/XP: IME PROCESS key
- // VK_PACKET (E7) Windows 2000/XP: Used to pass Unicode characters as if they were keystrokes. The VK_PACKET key is the low word of a 32-bit Virtual Key value used for non-keyboard input methods. For more information, see Remark in KEYBDINPUT,SendInput, WM_KEYDOWN, and WM_KEYUP
- // VK_ATTN (F6) Attn key
- // VK_CRSEL (F7) CrSel key
- // VK_EXSEL (F8) ExSel key
- // VK_EREOF (F9) Erase EOF key
- // VK_PLAY (FA) Play key
- // VK_ZOOM (FB) Zoom key
- // VK_NONAME (FC) Reserved for future use
- // VK_PA1 (FD) PA1 key
- // VK_OEM_CLEAR (FE) Clear key
- }
-
- return 0;
-}
-
-static inline bool isKeyUpEvent(NSEvent *event)
-{
- if ([event type] != NSFlagsChanged)
- return [event type] == NSKeyUp;
- // FIXME: This logic fails if the user presses both Shift keys at once, for example:
- // we treat releasing one of them as keyDown.
- switch ([event keyCode]) {
- case 54: // Right Command
- case 55: // Left Command
- return ([event modifierFlags] & NSCommandKeyMask) == 0;
-
- case 57: // Capslock
- return ([event modifierFlags] & NSAlphaShiftKeyMask) == 0;
-
- case 56: // Left Shift
- case 60: // Right Shift
- return ([event modifierFlags] & NSShiftKeyMask) == 0;
-
- case 58: // Left Alt
- case 61: // Right Alt
- return ([event modifierFlags] & NSAlternateKeyMask) == 0;
-
- case 59: // Left Ctrl
- case 62: // Right Ctrl
- return ([event modifierFlags] & NSControlKeyMask) == 0;
-
- case 63: // Function
- return ([event modifierFlags] & NSFunctionKeyMask) == 0;
- }
- return false;
-}
-
-static inline String textFromEvent(NSEvent* event)
-{
- if ([event type] == NSFlagsChanged)
- return "";
- return [event characters];
-}
-
-
-static inline String unmodifiedTextFromEvent(NSEvent* event)
-{
- if ([event type] == NSFlagsChanged)
- return "";
- return [event charactersIgnoringModifiers];
-}
-
-PlatformKeyboardEvent::PlatformKeyboardEvent(NSEvent *event)
- : m_type(isKeyUpEvent(event) ? PlatformKeyboardEvent::KeyUp : PlatformKeyboardEvent::KeyDown)
- , m_text(textFromEvent(event))
- , m_unmodifiedText(unmodifiedTextFromEvent(event))
- , m_keyIdentifier(keyIdentifierForKeyEvent(event))
- , m_autoRepeat(([event type] != NSFlagsChanged) && [event isARepeat])
- , m_windowsVirtualKeyCode(windowsKeyCodeForKeyEvent(event))
- , m_nativeVirtualKeyCode([event keyCode])
- , m_isKeypad(isKeypadEvent(event))
- , m_shiftKey([event modifierFlags] & NSShiftKeyMask)
- , m_ctrlKey([event modifierFlags] & NSControlKeyMask)
- , m_altKey([event modifierFlags] & NSAlternateKeyMask)
- , m_metaKey([event modifierFlags] & NSCommandKeyMask)
- , m_macEvent(event)
-{
- // Always use 13 for Enter/Return -- we don't want to use AppKit's different character for Enter.
- if (m_windowsVirtualKeyCode == '\r') {
- m_text = "\r";
- m_unmodifiedText = "\r";
- }
-
- // The adjustments below are only needed in backward compatibility mode, but we cannot tell what mode we are in from here.
-
- // Turn 0x7F into 8, because backspace needs to always be 8.
- if (m_text == "\x7F")
- m_text = "\x8";
- if (m_unmodifiedText == "\x7F")
- m_unmodifiedText = "\x8";
- // Always use 9 for tab -- we don't want to use AppKit's different character for shift-tab.
- if (m_windowsVirtualKeyCode == 9) {
- m_text = "\x9";
- m_unmodifiedText = "\x9";
- }
-}
-
-void PlatformKeyboardEvent::disambiguateKeyDownEvent(Type type, bool backwardCompatibilityMode)
-{
- // Can only change type from KeyDown to RawKeyDown or Char, as we lack information for other conversions.
- ASSERT(m_type == KeyDown);
- ASSERT(type == RawKeyDown || type == Char);
- m_type = type;
- if (backwardCompatibilityMode)
- return;
-
- if (type == RawKeyDown) {
- m_text = String();
- m_unmodifiedText = String();
- } else {
- m_keyIdentifier = String();
- m_windowsVirtualKeyCode = 0;
- if (m_text.length() == 1 && (m_text[0U] >= 0xF700 && m_text[0U] <= 0xF7FF)) {
- // According to NSEvents.h, OpenStep reserves the range 0xF700-0xF8FF for function keys. However, some actual private use characters
- // happen to be in this range, e.g. the Apple logo (Option+Shift+K).
- // 0xF7FF is an arbitrary cut-off.
- m_text = String();
- m_unmodifiedText = String();
- }
- }
-}
-
-bool PlatformKeyboardEvent::currentCapsLockState()
-{
- return GetCurrentKeyModifiers() & alphaLock;
-}
-
-}
diff --git a/WebCore/platform/mac/Language.mm b/WebCore/platform/mac/Language.mm
deleted file mode 100644
index 96caaa6..0000000
--- a/WebCore/platform/mac/Language.mm
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "Language.h"
-
-#import "BlockExceptions.h"
-#import "PlatformString.h"
-#import "WebCoreViewFactory.h"
-
-namespace WebCore {
-
-String defaultLanguage()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] defaultLanguageCode];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-}
diff --git a/WebCore/platform/mac/LocalCurrentGraphicsContext.h b/WebCore/platform/mac/LocalCurrentGraphicsContext.h
deleted file mode 100644
index 856cf52..0000000
--- a/WebCore/platform/mac/LocalCurrentGraphicsContext.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include <wtf/Noncopyable.h>
-
-class NSGraphicsContext;
-
-namespace WebCore {
-
-class GraphicsContext;
-
-// This class automatically saves and restores the current NSGraphicsContext for
-// functions which call out into AppKit and rely on the currentContext being set
-class LocalCurrentGraphicsContext : Noncopyable {
-public:
- LocalCurrentGraphicsContext(GraphicsContext* graphicsContext);
- ~LocalCurrentGraphicsContext();
-
-private:
- GraphicsContext* m_savedGraphicsContext;
- NSGraphicsContext* m_savedNSGraphicsContext;
-};
-
-}
diff --git a/WebCore/platform/mac/LocalCurrentGraphicsContext.mm b/WebCore/platform/mac/LocalCurrentGraphicsContext.mm
deleted file mode 100644
index 756d353..0000000
--- a/WebCore/platform/mac/LocalCurrentGraphicsContext.mm
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-#include "LocalCurrentGraphicsContext.h"
-
-#include "GraphicsContext.h"
-#include <AppKit/NSGraphicsContext.h>
-
-namespace WebCore {
-
-LocalCurrentGraphicsContext::LocalCurrentGraphicsContext(GraphicsContext* graphicsContext)
-{
- m_savedGraphicsContext = graphicsContext;
- graphicsContext->save();
-
- if (graphicsContext->platformContext() == [[NSGraphicsContext currentContext] graphicsPort]) {
- m_savedNSGraphicsContext = 0;
- return;
- }
-
- m_savedNSGraphicsContext = [[NSGraphicsContext currentContext] retain];
- NSGraphicsContext* newContext = [NSGraphicsContext graphicsContextWithGraphicsPort:graphicsContext->platformContext() flipped:YES];
- [NSGraphicsContext setCurrentContext:newContext];
-}
-
-LocalCurrentGraphicsContext::~LocalCurrentGraphicsContext()
-{
- m_savedGraphicsContext->restore();
-
- if (m_savedNSGraphicsContext) {
- [NSGraphicsContext setCurrentContext:m_savedNSGraphicsContext];
- [m_savedNSGraphicsContext release];
- }
-}
-
-}
diff --git a/WebCore/platform/mac/LocalizedStringsMac.mm b/WebCore/platform/mac/LocalizedStringsMac.mm
deleted file mode 100644
index d458778..0000000
--- a/WebCore/platform/mac/LocalizedStringsMac.mm
+++ /dev/null
@@ -1,588 +0,0 @@
-/*
- * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "LocalizedStrings.h"
-
-#import "BlockExceptions.h"
-#import "IntSize.h"
-#import "PlatformString.h"
-#import "WebCoreViewFactory.h"
-
-namespace WebCore {
-
-String inputElementAltText()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] inputElementAltText];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String resetButtonDefaultLabel()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] resetButtonDefaultLabel];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String searchableIndexIntroduction()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] searchableIndexIntroduction];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String submitButtonDefaultLabel()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] submitButtonDefaultLabel];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String fileButtonChooseFileLabel()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] fileButtonChooseFileLabel];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String fileButtonNoFileSelectedLabel()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] fileButtonNoFileSelectedLabel];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String copyImageUnknownFileLabel()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] copyImageUnknownFileLabel];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagOpenLinkInNewWindow()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagOpenLinkInNewWindow];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagDownloadLinkToDisk()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagDownloadLinkToDisk];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagCopyLinkToClipboard()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagCopyLinkToClipboard];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagOpenImageInNewWindow()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagOpenImageInNewWindow];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagDownloadImageToDisk()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagDownloadImageToDisk];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagCopyImageToClipboard()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagCopyImageToClipboard];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagOpenFrameInNewWindow()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagOpenFrameInNewWindow];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagCopy()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagCopy];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagGoBack()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagGoBack];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagGoForward()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagGoForward];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagStop()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagStop];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagReload()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagReload];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagCut()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagCut];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagPaste()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagPaste];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagNoGuessesFound()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagNoGuessesFound];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagIgnoreSpelling()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagIgnoreSpelling];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagLearnSpelling()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagLearnSpelling];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagSearchInSpotlight()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagSearchInSpotlight];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagSearchWeb()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagSearchWeb];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagLookUpInDictionary()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagLookUpInDictionary];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagOpenLink()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagOpenLink];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagIgnoreGrammar()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagIgnoreGrammar];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagSpellingMenu()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagSpellingMenu];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagShowSpellingPanel(bool show)
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagShowSpellingPanel:show];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagCheckSpelling()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagCheckSpelling];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagCheckSpellingWhileTyping()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagCheckSpellingWhileTyping];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagCheckGrammarWithSpelling()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagCheckGrammarWithSpelling];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagFontMenu()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagFontMenu];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagShowFonts()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagShowFonts];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagBold()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagBold];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagItalic()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagItalic];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagUnderline()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagUnderline];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagOutline()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagOutline];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagStyles()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagStyles];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagShowColors()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagShowColors];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagSpeechMenu()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagSpeechMenu];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagStartSpeaking()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagStartSpeaking];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagStopSpeaking()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagStopSpeaking];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagWritingDirectionMenu()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagWritingDirectionMenu];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagDefaultDirection()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagDefaultDirection];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagLeftToRight()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagLeftToRight];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagRightToLeft()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagRightToLeft];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String contextMenuItemTagInspectElement()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] contextMenuItemTagInspectElement];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String searchMenuNoRecentSearchesText()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] searchMenuNoRecentSearchesText];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String searchMenuRecentSearchesText ()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] searchMenuRecentSearchesText];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String searchMenuClearRecentSearchesText()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] searchMenuClearRecentSearchesText];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String AXWebAreaText()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] AXWebAreaText];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String AXLinkText()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] AXLinkText];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String AXListMarkerText()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] AXListMarkerText];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String AXImageMapText()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] AXImageMapText];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String AXHeadingText()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] AXHeadingText];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String AXDefinitionListTermText()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] AXDefinitionListTermText];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String AXDefinitionListDefinitionText()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] AXDefinitionListDefinitionText];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String AXButtonActionVerb()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] AXButtonActionVerb];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String AXRadioButtonActionVerb()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] AXRadioButtonActionVerb];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String AXTextFieldActionVerb()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] AXTextFieldActionVerb];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String AXCheckedCheckBoxActionVerb()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] AXCheckedCheckBoxActionVerb];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String AXUncheckedCheckBoxActionVerb()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] AXUncheckedCheckBoxActionVerb];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String AXLinkActionVerb()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] AXLinkActionVerb];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String multipleFileUploadText(unsigned numberOfFiles)
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] multipleFileUploadTextForNumberOfFiles:numberOfFiles];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String unknownFileSizeText()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] unknownFileSizeText];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-String imageTitle(const String& filename, const IntSize& size)
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [[WebCoreViewFactory sharedFactory] imageTitleForFilename:filename width:size.width() height:size.height()];
- END_BLOCK_OBJC_EXCEPTIONS;
- return String();
-}
-
-}
diff --git a/WebCore/platform/mac/LoggingMac.mm b/WebCore/platform/mac/LoggingMac.mm
deleted file mode 100644
index 2ee983c..0000000
--- a/WebCore/platform/mac/LoggingMac.mm
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "Logging.h"
-
-namespace WebCore {
-
-static inline void initializeWithUserDefault(WTFLogChannel& channel)
-{
- NSString *logLevelString = [[NSUserDefaults standardUserDefaults] objectForKey:[NSString stringWithUTF8String:channel.defaultName]];
- if (logLevelString) {
- unsigned logLevel;
- if (![[NSScanner scannerWithString:logLevelString] scanHexInt:&logLevel])
- NSLog(@"unable to parse hex value for %s (%@), logging is off", channel.defaultName, logLevelString);
- if ((logLevel & channel.mask) == channel.mask)
- channel.state = WTFLogChannelOn;
- else
- channel.state = WTFLogChannelOff;
- }
-}
-
-void InitializeLoggingChannelsIfNecessary()
-{
- static bool haveInitializedLoggingChannels = false;
- if (haveInitializedLoggingChannels)
- return;
- haveInitializedLoggingChannels = true;
-
- initializeWithUserDefault(LogNotYetImplemented);
- initializeWithUserDefault(LogFrames);
- initializeWithUserDefault(LogLoading);
- initializeWithUserDefault(LogPopupBlocking);
- initializeWithUserDefault(LogEvents);
- initializeWithUserDefault(LogEditing);
- initializeWithUserDefault(LogTextConversion);
- initializeWithUserDefault(LogIconDatabase);
- initializeWithUserDefault(LogSQLDatabase);
- initializeWithUserDefault(LogSpellingAndGrammar);
- initializeWithUserDefault(LogBackForward);
- initializeWithUserDefault(LogHistory);
- initializeWithUserDefault(LogPageCache);
- initializeWithUserDefault(LogPlatformLeaks);
- initializeWithUserDefault(LogNetwork);
- initializeWithUserDefault(LogFTP);
- initializeWithUserDefault(LogThreading);
- initializeWithUserDefault(LogStorageAPI);
- initializeWithUserDefault(LogMedia);
- initializeWithUserDefault(LogPlugin);
- initializeWithUserDefault(LogArchives);
-}
-
-}
diff --git a/WebCore/platform/mac/MIMETypeRegistryMac.mm b/WebCore/platform/mac/MIMETypeRegistryMac.mm
deleted file mode 100644
index c67b891..0000000
--- a/WebCore/platform/mac/MIMETypeRegistryMac.mm
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "MIMETypeRegistry.h"
-
-#include "WebCoreSystemInterface.h"
-
-namespace WebCore
-{
-String getMIMETypeForUTI(const String & uti)
-{
- CFStringRef utiref = uti.createCFString();
- CFStringRef mime = UTTypeCopyPreferredTagWithClass(utiref, kUTTagClassMIMEType);
- String mimeType = mime;
- if (mime)
- CFRelease(mime);
- CFRelease(utiref);
- return mimeType;
-}
-
-String MIMETypeRegistry::getMIMETypeForExtension(const String &ext)
-{
- return wkGetMIMETypeForExtension(ext);
-}
-
-Vector<String> MIMETypeRegistry::getExtensionsForMIMEType(const String& type)
-{
- NSArray *stringsArray = wkGetExtensionsForMIMEType(type);
- Vector<String> stringsVector = Vector<String>();
- unsigned count = [stringsArray count];
- if (count > 0) {
- NSEnumerator* enumerator = [stringsArray objectEnumerator];
- NSString* string;
- while ((string = [enumerator nextObject]) != nil)
- stringsVector.append(string);
- }
- return stringsVector;
-}
-
-String MIMETypeRegistry::getPreferredExtensionForMIMEType(const String& type)
-{
- return wkGetPreferredExtensionForMIMEType(type);
-}
-
-}
diff --git a/WebCore/platform/mac/PasteboardHelper.h b/WebCore/platform/mac/PasteboardHelper.h
deleted file mode 100644
index 4ae964d..0000000
--- a/WebCore/platform/mac/PasteboardHelper.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef PasteboardHelper_h
-#define PasteboardHelper_h
-
-/* FIXME: This is a helper class used to provide access to functionality inside
- * WebKit. The required functionality should eventually be migrated to WebCore
- * so that this class can be removed.
- */
-#if PLATFORM(MAC)
-
-#import <wtf/Forward.h>
-
-#ifdef __OBJC__
-@class DOMDocumentFragment;
-#else
-class DOMDocumentFragment;
-#endif
-
-namespace WebCore {
-
- class String;
- class Document;
-
- class PasteboardHelper {
- public:
- virtual ~PasteboardHelper() {}
- virtual String urlFromPasteboard(const NSPasteboard*, String* title) const = 0;
- virtual String plainTextFromPasteboard(const NSPasteboard*) const = 0;
- virtual DOMDocumentFragment* fragmentFromPasteboard(const NSPasteboard*) const = 0;
- virtual NSArray* insertablePasteboardTypes() const = 0;
- };
-
-}
-#endif // PLATFORM(MAC)
-
-#endif // !PasteboardHelper_h
diff --git a/WebCore/platform/mac/PasteboardMac.mm b/WebCore/platform/mac/PasteboardMac.mm
deleted file mode 100644
index 4e15ad0..0000000
--- a/WebCore/platform/mac/PasteboardMac.mm
+++ /dev/null
@@ -1,378 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "Pasteboard.h"
-
-#import "CachedResource.h"
-#import "CharacterNames.h"
-#import "DOMRangeInternal.h"
-#import "Document.h"
-#import "DocumentFragment.h"
-#import "Editor.h"
-#import "EditorClient.h"
-#import "Frame.h"
-#import "HitTestResult.h"
-#import "Image.h"
-#import "KURL.h"
-#import "LegacyWebArchive.h"
-#import "LoaderNSURLExtras.h"
-#import "MIMETypeRegistry.h"
-#import "RenderImage.h"
-#import "WebCoreNSStringExtras.h"
-#import "markup.h"
-
-#import <wtf/RetainPtr.h>
-
-@interface NSAttributedString (AppKitSecretsIKnowAbout)
-- (id)_initWithDOMRange:(DOMRange *)domRange;
-@end
-
-namespace WebCore {
-
-// FIXME: It's not great to have these both here and in WebKit.
-NSString *WebArchivePboardType = @"Apple Web Archive pasteboard type";
-NSString *WebSmartPastePboardType = @"NeXT smart paste pasteboard type";
-NSString *WebURLNamePboardType = @"public.url-name";
-NSString *WebURLPboardType = @"public.url";
-NSString *WebURLsWithTitlesPboardType = @"WebURLsWithTitlesPboardType";
-
-#ifndef BUILDING_ON_TIGER
-static NSArray* selectionPasteboardTypes(bool canSmartCopyOrDelete, bool selectionContainsAttachments)
-{
- if (selectionContainsAttachments) {
- if (canSmartCopyOrDelete)
- return [NSArray arrayWithObjects:WebSmartPastePboardType, WebArchivePboardType, NSRTFDPboardType, NSRTFPboardType, NSStringPboardType, nil];
- else
- return [NSArray arrayWithObjects:WebArchivePboardType, NSRTFDPboardType, NSRTFPboardType, NSStringPboardType, nil];
- } else { // Don't write RTFD to the pasteboard when the copied attributed string has no attachments.
- if (canSmartCopyOrDelete)
- return [NSArray arrayWithObjects:WebSmartPastePboardType, WebArchivePboardType, NSRTFPboardType, NSStringPboardType, nil];
- else
- return [NSArray arrayWithObjects:WebArchivePboardType, NSRTFPboardType, NSStringPboardType, nil];
- }
-}
-#endif
-
-static NSArray* writableTypesForURL()
-{
- static RetainPtr<NSArray> types = nil;
- if (!types) {
- types = [[NSArray alloc] initWithObjects:
- WebURLsWithTitlesPboardType,
- NSURLPboardType,
- WebURLPboardType,
- WebURLNamePboardType,
- NSStringPboardType,
- nil];
- }
- return types.get();
-}
-
-static NSArray* writableTypesForImage()
-{
- static RetainPtr<NSMutableArray> types = nil;
- if (!types) {
- types = [[NSMutableArray alloc] initWithObjects:NSTIFFPboardType, nil];
- [types.get() addObjectsFromArray:writableTypesForURL()];
- [types.get() addObject:NSRTFDPboardType];
- }
- return types.get();
-}
-
-Pasteboard* Pasteboard::generalPasteboard()
-{
- static Pasteboard* pasteboard = new Pasteboard([NSPasteboard generalPasteboard]);
- return pasteboard;
-}
-
-Pasteboard::Pasteboard(NSPasteboard* pboard)
- : m_pasteboard(pboard)
-{
-}
-
-void Pasteboard::clear()
-{
- [m_pasteboard.get() declareTypes:[NSArray array] owner:nil];
-}
-
-static NSAttributedString *stripAttachmentCharacters(NSAttributedString *string)
-{
- const unichar attachmentCharacter = NSAttachmentCharacter;
- static RetainPtr<NSString> attachmentCharacterString = [NSString stringWithCharacters:&attachmentCharacter length:1];
- NSMutableAttributedString *result = [[string mutableCopy] autorelease];
- NSRange attachmentRange = [[result string] rangeOfString:attachmentCharacterString.get()];
- while (attachmentRange.location != NSNotFound) {
- [result replaceCharactersInRange:attachmentRange withString:@""];
- attachmentRange = [[result string] rangeOfString:attachmentCharacterString.get()];
- }
- return result;
-}
-
-void Pasteboard::writeSelection(NSPasteboard* pasteboard, Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame)
-{
- if (WebArchivePboardType == nil)
- Pasteboard::generalPasteboard(); //Initialises pasteboard types
- ASSERT(selectedRange);
-
- NSAttributedString *attributedString = [[[NSAttributedString alloc] _initWithDOMRange:[DOMRange _wrapRange:selectedRange]] autorelease];
-#ifdef BUILDING_ON_TIGER
- // 4930197: Mail overrides [WebHTMLView pasteboardTypesForSelection] in order to add another type to the pasteboard
- // after WebKit does. On Tiger we must call this function so that Mail code will be executed, meaning that
- // we can't call WebCore::Pasteboard's method for setting types.
-
- NSArray *types = frame->editor()->client()->pasteboardTypesForSelection(frame);
- // Don't write RTFD to the pasteboard when the copied attributed string has no attachments.
- NSMutableArray *mutableTypes = nil;
- if (![attributedString containsAttachments]) {
- mutableTypes = [[types mutableCopy] autorelease];
- [mutableTypes removeObject:NSRTFDPboardType];
- types = mutableTypes;
- }
- [pasteboard declareTypes:types owner:nil];
-#else
- NSArray *types = selectionPasteboardTypes(canSmartCopyOrDelete, [attributedString containsAttachments]);
- [pasteboard declareTypes:types owner:nil];
- frame->editor()->client()->didSetSelectionTypesForPasteboard();
-#endif
-
- // Put HTML on the pasteboard.
- if ([types containsObject:WebArchivePboardType]) {
- RefPtr<LegacyWebArchive> archive = LegacyWebArchive::createFromSelection(frame);
- RetainPtr<CFDataRef> data = archive ? archive->rawDataRepresentation() : 0;
- [pasteboard setData:(NSData *)data.get() forType:WebArchivePboardType];
- }
-
- // Put the attributed string on the pasteboard (RTF/RTFD format).
- if ([types containsObject:NSRTFDPboardType]) {
- NSData *RTFDData = [attributedString RTFDFromRange:NSMakeRange(0, [attributedString length]) documentAttributes:nil];
- [pasteboard setData:RTFDData forType:NSRTFDPboardType];
- }
- if ([types containsObject:NSRTFPboardType]) {
- if ([attributedString containsAttachments])
- attributedString = stripAttachmentCharacters(attributedString);
- NSData *RTFData = [attributedString RTFFromRange:NSMakeRange(0, [attributedString length]) documentAttributes:nil];
- [pasteboard setData:RTFData forType:NSRTFPboardType];
- }
-
- // Put plain string on the pasteboard.
- if ([types containsObject:NSStringPboardType]) {
- // Map &nbsp; to a plain old space because this is better for source code, other browsers do it,
- // and because HTML forces you to do this any time you want two spaces in a row.
- String text = selectedRange->text();
- text.replace('\\', frame->backslashAsCurrencySymbol());
- NSMutableString *s = [[[(NSString*)text copy] autorelease] mutableCopy];
-
- NSString *NonBreakingSpaceString = [NSString stringWithCharacters:&noBreakSpace length:1];
- [s replaceOccurrencesOfString:NonBreakingSpaceString withString:@" " options:0 range:NSMakeRange(0, [s length])];
- [pasteboard setString:s forType:NSStringPboardType];
- [s release];
- }
-
- if ([types containsObject:WebSmartPastePboardType]) {
- [pasteboard setData:nil forType:WebSmartPastePboardType];
- }
-}
-
-void Pasteboard::writeSelection(Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame)
-{
- Pasteboard::writeSelection(m_pasteboard.get(), selectedRange, canSmartCopyOrDelete, frame);
-}
-
-void Pasteboard::writeURL(NSPasteboard* pasteboard, NSArray* types, const KURL& url, const String& titleStr, Frame* frame)
-{
- if (WebArchivePboardType == nil)
- Pasteboard::generalPasteboard(); //Initialises pasteboard types
-
- if (types == nil) {
- types = writableTypesForURL();
- [pasteboard declareTypes:types owner:nil];
- }
-
- ASSERT(!url.isEmpty());
-
- NSURL *cocoaURL = url;
- NSString *userVisibleString = frame->editor()->client()->userVisibleString(cocoaURL);
-
- NSString *title = (NSString*)titleStr;
- if ([title length] == 0) {
- title = [[cocoaURL path] lastPathComponent];
- if ([title length] == 0)
- title = userVisibleString;
- }
-
- if ([types containsObject:WebURLsWithTitlesPboardType])
- [pasteboard setPropertyList:[NSArray arrayWithObjects:[NSArray arrayWithObject:userVisibleString],
- [NSArray arrayWithObject:(NSString*)titleStr.stripWhiteSpace()],
- nil]
- forType:WebURLsWithTitlesPboardType];
- if ([types containsObject:NSURLPboardType])
- [cocoaURL writeToPasteboard:pasteboard];
- if ([types containsObject:WebURLPboardType])
- [pasteboard setString:userVisibleString forType:WebURLPboardType];
- if ([types containsObject:WebURLNamePboardType])
- [pasteboard setString:title forType:WebURLNamePboardType];
- if ([types containsObject:NSStringPboardType])
- [pasteboard setString:userVisibleString forType:NSStringPboardType];
-}
-
-void Pasteboard::writeURL(const KURL& url, const String& titleStr, Frame* frame)
-{
- Pasteboard::writeURL(m_pasteboard.get(), nil, url, titleStr, frame);
-}
-
-static NSFileWrapper* fileWrapperForImage(CachedResource* resource, NSURL *url)
-{
- SharedBuffer* coreData = resource->data();
- NSData *data = [[[NSData alloc] initWithBytes:coreData->platformData()
- length:coreData->platformDataSize()] autorelease];
- NSFileWrapper *wrapper = [[[NSFileWrapper alloc] initRegularFileWithContents:data] autorelease];
- String coreMIMEType = resource->response().mimeType();
- NSString *MIMEType = nil;
- if (!coreMIMEType.isNull())
- MIMEType = coreMIMEType;
- [wrapper setPreferredFilename:suggestedFilenameWithMIMEType(url, MIMEType)];
- return wrapper;
-}
-
-void Pasteboard::writeFileWrapperAsRTFDAttachment(NSFileWrapper* wrapper)
-{
- NSTextAttachment *attachment = [[NSTextAttachment alloc] initWithFileWrapper:wrapper];
-
- NSAttributedString *string = [NSAttributedString attributedStringWithAttachment:attachment];
- [attachment release];
-
- NSData *RTFDData = [string RTFDFromRange:NSMakeRange(0, [string length]) documentAttributes:nil];
- [m_pasteboard.get() setData:RTFDData forType:NSRTFDPboardType];
-}
-
-void Pasteboard::writeImage(Node* node, const KURL& url, const String& title)
-{
- ASSERT(node);
- Frame* frame = node->document()->frame();
-
- NSURL *cocoaURL = url;
- ASSERT(cocoaURL);
-
- ASSERT(node->renderer() && node->renderer()->isImage());
- RenderImage* renderer = static_cast<RenderImage*>(node->renderer());
- CachedImage* cachedImage = static_cast<CachedImage*>(renderer->cachedImage());
- ASSERT(cachedImage);
-
- if (cachedImage->errorOccurred())
- return;
-
- NSArray* types = writableTypesForImage();
- [m_pasteboard.get() declareTypes:types owner:nil];
- writeURL(m_pasteboard.get(), types, cocoaURL, nsStringNilIfEmpty(title), frame);
-
- Image* image = cachedImage->image();
- ASSERT(image);
-
- [m_pasteboard.get() setData:[image->getNSImage() TIFFRepresentation] forType:NSTIFFPboardType];
-
- String MIMEType = cachedImage->response().mimeType();
- ASSERT(MIMETypeRegistry::isSupportedImageResourceMIMEType(MIMEType));
-
- writeFileWrapperAsRTFDAttachment(fileWrapperForImage(cachedImage, cocoaURL));
-}
-
-bool Pasteboard::canSmartReplace()
-{
- return [[m_pasteboard.get() types] containsObject:WebSmartPastePboardType];
-}
-
-String Pasteboard::plainText(Frame* frame)
-{
- NSArray *types = [m_pasteboard.get() types];
-
- if ([types containsObject:NSStringPboardType])
- return [m_pasteboard.get() stringForType:NSStringPboardType];
-
- NSAttributedString *attributedString = nil;
- NSString *string;
-
- if ([types containsObject:NSRTFDPboardType])
- attributedString = [[NSAttributedString alloc] initWithRTFD:[m_pasteboard.get() dataForType:NSRTFDPboardType] documentAttributes:NULL];
- if (attributedString == nil && [types containsObject:NSRTFPboardType])
- attributedString = [[NSAttributedString alloc] initWithRTF:[m_pasteboard.get() dataForType:NSRTFPboardType] documentAttributes:NULL];
- if (attributedString != nil) {
- string = [[attributedString string] copy];
- [attributedString release];
- return [string autorelease];
- }
-
- if ([types containsObject:NSFilenamesPboardType]) {
- string = [[m_pasteboard.get() propertyListForType:NSFilenamesPboardType] componentsJoinedByString:@"\n"];
- if (string != nil)
- return string;
- }
-
-
- if (NSURL *url = [NSURL URLFromPasteboard:m_pasteboard.get()]) {
- // FIXME: using the editorClient to call into webkit, for now, since
- // calling _web_userVisibleString from WebCore involves migrating a sizable web of
- // helper code that should either be done in a separate patch or figured out in another way.
- string = frame->editor()->client()->userVisibleString(url);
- if ([string length] > 0)
- return string;
- }
-
-
- return String();
-}
-
-PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefPtr<Range> context, bool allowPlainText, bool& chosePlainText)
-{
- NSArray *types = [m_pasteboard.get() types];
- chosePlainText = false;
-
- if ([types containsObject:NSHTMLPboardType]) {
- NSString *HTMLString = [m_pasteboard.get() stringForType:NSHTMLPboardType];
- // This is a hack to make Microsoft's HTML pasteboard data work. See 3778785.
- if ([HTMLString hasPrefix:@"Version:"]) {
- NSRange range = [HTMLString rangeOfString:@"<html" options:NSCaseInsensitiveSearch];
- if (range.location != NSNotFound) {
- HTMLString = [HTMLString substringFromIndex:range.location];
- }
- }
- if ([HTMLString length] != 0) {
- RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(frame->document(), HTMLString, "");
- if (fragment)
- return fragment.release();
- }
- }
-
- if (allowPlainText && [types containsObject:NSStringPboardType]) {
- chosePlainText = true;
- RefPtr<DocumentFragment> fragment = createFragmentFromText(context.get(), [m_pasteboard.get() stringForType:NSStringPboardType]);
- if (fragment)
- return fragment.release();
- }
-
- return 0;
-}
-
-}
diff --git a/WebCore/platform/mac/PlatformMouseEventMac.mm b/WebCore/platform/mac/PlatformMouseEventMac.mm
deleted file mode 100644
index af7415d..0000000
--- a/WebCore/platform/mac/PlatformMouseEventMac.mm
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "PlatformMouseEvent.h"
-
-#import "PlatformScreen.h"
-
-namespace WebCore {
-
-static MouseButton mouseButtonForEvent(NSEvent *event)
-{
- switch ([event type]) {
- case NSLeftMouseDown:
- case NSLeftMouseUp:
- case NSLeftMouseDragged:
- return LeftButton;
- case NSRightMouseDown:
- case NSRightMouseUp:
- case NSRightMouseDragged:
- return RightButton;
- case NSOtherMouseDown:
- case NSOtherMouseUp:
- case NSOtherMouseDragged:
- return MiddleButton;
- default:
- return NoButton;
- }
-}
-
-static int clickCountForEvent(NSEvent *event)
-{
- switch ([event type]) {
- case NSLeftMouseDown:
- case NSLeftMouseUp:
- case NSLeftMouseDragged:
- case NSRightMouseDown:
- case NSRightMouseUp:
- case NSRightMouseDragged:
- case NSOtherMouseDown:
- case NSOtherMouseUp:
- case NSOtherMouseDragged:
- return [event clickCount];
- default:
- return 0;
- }
-}
-
-IntPoint globalPoint(const NSPoint& windowPoint, NSWindow* window)
-{
- return IntPoint(flipScreenPoint([window convertBaseToScreen:windowPoint], screenForWindow(window)));
-}
-
-IntPoint pointForEvent(NSEvent *event)
-{
- switch ([event type]) {
- case NSLeftMouseDown:
- case NSLeftMouseUp:
- case NSLeftMouseDragged:
- case NSRightMouseDown:
- case NSRightMouseUp:
- case NSRightMouseDragged:
- case NSOtherMouseDown:
- case NSOtherMouseUp:
- case NSOtherMouseDragged:
- case NSMouseMoved:
- case NSScrollWheel:
- // Note: This has its origin at the bottom left of the window.
- // The Y coordinate gets flipped by ScrollView::viewportToContents.
- // We should probably change both this and that to not use "bottom left origin" coordinates at all.
- return IntPoint([event locationInWindow]);
- default:
- return IntPoint();
- }
-}
-
-IntPoint globalPointForEvent(NSEvent *event)
-{
- switch ([event type]) {
- case NSLeftMouseDown:
- case NSLeftMouseUp:
- case NSLeftMouseDragged:
- case NSRightMouseDown:
- case NSRightMouseUp:
- case NSRightMouseDragged:
- case NSOtherMouseDown:
- case NSOtherMouseUp:
- case NSOtherMouseDragged:
- case NSMouseMoved:
- case NSScrollWheel:
- return globalPoint([event locationInWindow], [event window]);
- default:
- return IntPoint();
- }
-}
-
-int eventNumberForEvent(NSEvent *event)
-{
- switch ([event type]) {
- case NSLeftMouseDown:
- case NSLeftMouseUp:
- case NSLeftMouseDragged:
- case NSRightMouseDown:
- case NSRightMouseUp:
- case NSRightMouseDragged:
- case NSOtherMouseDown:
- case NSOtherMouseUp:
- case NSOtherMouseDragged:
- case NSMouseMoved:
- return [event eventNumber];
- default:
- return 0;
- }
-}
-
-static MouseEventType mouseEventForNSEvent(NSEvent* event)
-{
- switch ([event type]) {
- case NSScrollWheel:
- return MouseEventScroll;
- case NSLeftMouseDragged:
- case NSRightMouseDragged:
- case NSOtherMouseDragged:
- case NSMouseMoved:
- return MouseEventMoved;
- case NSLeftMouseDown:
- case NSRightMouseDown:
- case NSOtherMouseDown:
- return MouseEventPressed;
- case NSLeftMouseUp:
- case NSRightMouseUp:
- case NSOtherMouseUp:
- return MouseEventReleased;
- default:
- return MouseEventMoved;
- }
-}
-
-PlatformMouseEvent::PlatformMouseEvent(NSEvent* event)
- : m_position(pointForEvent(event))
- , m_globalPosition(globalPointForEvent(event))
- , m_button(mouseButtonForEvent(event))
- , m_eventType(mouseEventForNSEvent(event))
- , m_clickCount(clickCountForEvent(event))
- , m_shiftKey([event modifierFlags] & NSShiftKeyMask)
- , m_ctrlKey([event modifierFlags] & NSControlKeyMask)
- , m_altKey([event modifierFlags] & NSAlternateKeyMask)
- , m_metaKey([event modifierFlags] & NSCommandKeyMask)
- , m_timestamp([event timestamp])
- , m_modifierFlags([event modifierFlags])
- , m_eventNumber([event eventNumber])
-{
-}
-
-}
diff --git a/WebCore/platform/mac/PlatformScreenMac.mm b/WebCore/platform/mac/PlatformScreenMac.mm
deleted file mode 100644
index 8f12df0..0000000
--- a/WebCore/platform/mac/PlatformScreenMac.mm
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "PlatformScreen.h"
-
-#import "FloatRect.h"
-#import "Frame.h"
-#import "FrameView.h"
-#import "Page.h"
-
-namespace WebCore {
-
-int screenDepth(Widget*)
-{
- return NSBitsPerPixelFromDepth([[NSScreen deepestScreen] depth]);
-}
-
-int screenDepthPerComponent(Widget*)
-{
- return NSBitsPerSampleFromDepth([[NSScreen deepestScreen] depth]);
-}
-
-bool screenIsMonochrome(Widget*)
-{
- NSString *colorSpace = NSColorSpaceFromDepth([[NSScreen deepestScreen] depth]);
- return colorSpace == NSCalibratedWhiteColorSpace
- || colorSpace == NSCalibratedBlackColorSpace
- || colorSpace == NSDeviceWhiteColorSpace
- || colorSpace == NSDeviceBlackColorSpace;
-}
-
-// These functions scale between screen and page coordinates because JavaScript/DOM operations
-// assume that the screen and the page share the same coordinate system.
-
-FloatRect screenRect(Widget* widget)
-{
- NSWindow *window = widget ? [widget->platformWidget() window] : nil;
- return toUserSpace([screenForWindow(window) frame], window);
-}
-
-FloatRect screenAvailableRect(Widget* widget)
-{
- NSWindow *window = widget ? [widget->platformWidget() window] : nil;
- return toUserSpace([screenForWindow(window) visibleFrame], window);
-}
-
-NSScreen *screenForWindow(NSWindow *window)
-{
- NSScreen *screen = [window screen]; // nil if the window is off-screen
- if (screen)
- return screen;
-
- NSArray *screens = [NSScreen screens];
- if ([screens count] > 0)
- return [screens objectAtIndex:0]; // screen containing the menubar
-
- return nil;
-}
-
-FloatRect toUserSpace(const NSRect& rect, NSWindow *destination)
-{
- FloatRect userRect = rect;
- userRect.setY(NSMaxY([screenForWindow(destination) frame]) - (userRect.y() + userRect.height())); // flip
- if (destination)
- userRect.scale(1 / [destination userSpaceScaleFactor]); // scale down
- return userRect;
-}
-
-NSRect toDeviceSpace(const FloatRect& rect, NSWindow *source)
-{
- FloatRect deviceRect = rect;
- if (source)
- deviceRect.scale([source userSpaceScaleFactor]); // scale up
- deviceRect.setY(NSMaxY([screenForWindow(source) frame]) - (deviceRect.y() + deviceRect.height())); // flip
- return deviceRect;
-}
-
-NSPoint flipScreenPoint(const NSPoint& screenPoint, NSScreen *screen)
-{
- NSPoint flippedPoint = screenPoint;
- flippedPoint.y = NSMaxY([screen frame]) - flippedPoint.y;
- return flippedPoint;
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/mac/PopupMenuMac.mm b/WebCore/platform/mac/PopupMenuMac.mm
deleted file mode 100644
index 23324d3..0000000
--- a/WebCore/platform/mac/PopupMenuMac.mm
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#import "config.h"
-#import "PopupMenu.h"
-
-#import "ChromeClient.h"
-#import "EventHandler.h"
-#import "Frame.h"
-#import "FrameView.h"
-#import "HTMLNames.h"
-#import "HTMLOptGroupElement.h"
-#import "HTMLOptionElement.h"
-#import "HTMLSelectElement.h"
-#import "Page.h"
-#import "SimpleFontData.h"
-#import "WebCoreSystemInterface.h"
-
-namespace WebCore {
-
-using namespace HTMLNames;
-
-PopupMenu::PopupMenu(PopupMenuClient* client)
- : m_popupClient(client)
-{
-}
-
-PopupMenu::~PopupMenu()
-{
- if (m_popup)
- [m_popup.get() setControlView:nil];
-}
-
-void PopupMenu::clear()
-{
- if (m_popup)
- [m_popup.get() removeAllItems];
-}
-
-void PopupMenu::populate()
-{
- if (m_popup)
- clear();
- else {
- m_popup = [[NSPopUpButtonCell alloc] initTextCell:@"" pullsDown:!client()->shouldPopOver()];
- [m_popup.get() release]; // release here since the RetainPtr has retained the object already
- [m_popup.get() setUsesItemFromMenu:NO];
- [m_popup.get() setAutoenablesItems:NO];
- }
-
- BOOL messagesEnabled = [[m_popup.get() menu] menuChangedMessagesEnabled];
- [[m_popup.get() menu] setMenuChangedMessagesEnabled:NO];
-
- // For pullDown menus the first item is hidden.
- if (!client()->shouldPopOver())
- [m_popup.get() addItemWithTitle:@""];
-
- ASSERT(client());
- int size = client()->listSize();
-
- for (int i = 0; i < size; i++) {
- if (client()->itemIsSeparator(i))
- [[m_popup.get() menu] addItem:[NSMenuItem separatorItem]];
- else {
- PopupMenuStyle style = client()->itemStyle(i);
- NSMutableDictionary* attributes = [[NSMutableDictionary alloc] init];
- if (style.font() != Font())
- [attributes setObject:style.font().primaryFont()->getNSFont() forKey:NSFontAttributeName];
- // FIXME: Add support for styling the foreground and background colors.
- // FIXME: Find a way to customize text color when an item is highlighted.
- NSAttributedString* string = [[NSAttributedString alloc] initWithString:client()->itemText(i) attributes:attributes];
- [attributes release];
-
- [m_popup.get() addItemWithTitle:@""];
- NSMenuItem* menuItem = [m_popup.get() lastItem];
- [menuItem setAttributedTitle:string];
- [menuItem setEnabled:client()->itemIsEnabled(i)];
- [string release];
- }
- }
-
- [[m_popup.get() menu] setMenuChangedMessagesEnabled:messagesEnabled];
-}
-
-void PopupMenu::show(const IntRect& r, FrameView* v, int index)
-{
- populate();
- int numItems = [m_popup.get() numberOfItems];
- if (numItems <= 0) {
- if (client())
- client()->hidePopup();
- return;
- }
- ASSERT(numItems > index);
-
- // Workaround for crazy bug where a selected index of -1 for a menu with only 1 item will cause a blank menu.
- if (index == -1 && numItems == 2 && !client()->shouldPopOver() && ![[m_popup.get() itemAtIndex:1] isEnabled])
- index = 0;
-
- NSView* view = v->documentView();
-
- [m_popup.get() attachPopUpWithFrame:r inView:view];
- [m_popup.get() selectItemAtIndex:index];
-
- NSMenu* menu = [m_popup.get() menu];
-
- NSPoint location;
- NSFont* font = client()->menuStyle().font().primaryFont()->getNSFont();
-
- // These values were borrowed from AppKit to match their placement of the menu.
- const int popOverHorizontalAdjust = -10;
- const int popUnderHorizontalAdjust = 6;
- const int popUnderVerticalAdjust = 6;
- if (client()->shouldPopOver()) {
- NSRect titleFrame = [m_popup.get() titleRectForBounds:r];
- if (titleFrame.size.width <= 0 || titleFrame.size.height <= 0)
- titleFrame = r;
- float vertOffset = roundf((NSMaxY(r) - NSMaxY(titleFrame)) + NSHeight(titleFrame));
- // Adjust for fonts other than the system font.
- NSFont* defaultFont = [NSFont systemFontOfSize:[font pointSize]];
- vertOffset += [font descender] - [defaultFont descender];
- vertOffset = fminf(NSHeight(r), vertOffset);
-
- location = NSMakePoint(NSMinX(r) + popOverHorizontalAdjust, NSMaxY(r) - vertOffset);
- } else
- location = NSMakePoint(NSMinX(r) + popUnderHorizontalAdjust, NSMaxY(r) + popUnderVerticalAdjust);
-
- // Save the current event that triggered the popup, so we can clean up our event
- // state after the NSMenu goes away.
- RefPtr<Frame> frame = v->frame();
- NSEvent* event = [frame->eventHandler()->currentNSEvent() retain];
-
- RefPtr<PopupMenu> protector(this);
-
- RetainPtr<NSView> dummyView(AdoptNS, [[NSView alloc] initWithFrame:r]);
- [view addSubview:dummyView.get()];
- location = [dummyView.get() convertPoint:location fromView:view];
-
- if (Page* page = frame->page())
- page->chrome()->client()->willPopUpMenu(menu);
- wkPopupMenu(menu, location, roundf(NSWidth(r)), dummyView.get(), index, font);
-
- [m_popup.get() dismissPopUp];
- [dummyView.get() removeFromSuperview];
-
- if (client()) {
- int newIndex = [m_popup.get() indexOfSelectedItem];
- client()->hidePopup();
-
- // Adjust newIndex for hidden first item.
- if (!client()->shouldPopOver())
- newIndex--;
-
- if (index != newIndex && newIndex >= 0)
- client()->valueChanged(newIndex);
-
- // Give the frame a chance to fix up its event state, since the popup eats all the
- // events during tracking.
- frame->eventHandler()->sendFakeEventsAfterWidgetTracking(event);
- }
-
- [event release];
-}
-
-void PopupMenu::hide()
-{
- [m_popup.get() dismissPopUp];
-}
-
-void PopupMenu::updateFromElement()
-{
-}
-
-bool PopupMenu::itemWritingDirectionIsNatural()
-{
- return true;
-}
-
-}
diff --git a/WebCore/platform/mac/SSLKeyGeneratorMac.mm b/WebCore/platform/mac/SSLKeyGeneratorMac.mm
deleted file mode 100644
index dd76b59..0000000
--- a/WebCore/platform/mac/SSLKeyGeneratorMac.mm
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2003, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "SSLKeyGenerator.h"
-
-#import "KURL.h"
-#import "WebCoreKeyGenerator.h"
-
-namespace WebCore {
-
-void getSupportedKeySizes(Vector<String>& supportedKeySizes)
-{
- NSEnumerator *enumerator = [[[WebCoreKeyGenerator sharedGenerator] strengthMenuItemTitles] objectEnumerator];
- NSString *string;
- while ((string = [enumerator nextObject]) != nil)
- supportedKeySizes.append(string);
-}
-
-String signedPublicKeyAndChallengeString(unsigned keySizeIndex, const String& challengeString, const KURL& url)
-{
- return [[WebCoreKeyGenerator sharedGenerator] signedPublicKeyAndChallengeStringWithStrengthIndex:keySizeIndex
- challenge:challengeString
- pageURL:url];
-}
-
-}
diff --git a/WebCore/platform/mac/SchedulePairMac.mm b/WebCore/platform/mac/SchedulePairMac.mm
deleted file mode 100644
index e1709b3..0000000
--- a/WebCore/platform/mac/SchedulePairMac.mm
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "SchedulePair.h"
-
-namespace WebCore {
-
-SchedulePair::SchedulePair(NSRunLoop* runLoop, CFStringRef mode)
- : m_nsRunLoop(runLoop)
- , m_runLoop([runLoop getCFRunLoop])
-{
- if (mode)
- m_mode.adoptCF(CFStringCreateCopy(0, mode));
-}
-
-} // namespace
diff --git a/WebCore/platform/mac/ScrollViewMac.mm b/WebCore/platform/mac/ScrollViewMac.mm
deleted file mode 100644
index 6d477e2..0000000
--- a/WebCore/platform/mac/ScrollViewMac.mm
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Copyright (C) 2004, 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "ScrollView.h"
-
-#import "BlockExceptions.h"
-#import "FloatRect.h"
-#import "IntRect.h"
-#import "Logging.h"
-#import "NotImplemented.h"
-#import "WebCoreFrameView.h"
-
-using namespace std;
-
-@interface NSWindow (WebWindowDetails)
-- (BOOL)_needsToResetDragMargins;
-- (void)_setNeedsToResetDragMargins:(BOOL)needs;
-@end
-
-namespace WebCore {
-
-inline NSScrollView<WebCoreFrameScrollView> *ScrollView::scrollView() const
-{
- ASSERT(!platformWidget() || [platformWidget() isKindOfClass:[NSScrollView class]]);
- ASSERT(!platformWidget() || [platformWidget() conformsToProtocol:@protocol(WebCoreFrameScrollView)]);
- return static_cast<NSScrollView<WebCoreFrameScrollView> *>(platformWidget());
-}
-
-NSView *ScrollView::documentView() const
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return [scrollView() documentView];
- END_BLOCK_OBJC_EXCEPTIONS;
- return nil;
-}
-
-void ScrollView::platformAddChild(Widget* child)
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- NSView *parentView = documentView();
- NSView *childView = child->getOuterView();
- ASSERT(![parentView isDescendantOf:childView]);
-
- // Suppress the resetting of drag margins since we know we can't affect them.
- NSWindow *window = [parentView window];
- BOOL resetDragMargins = [window _needsToResetDragMargins];
- [window _setNeedsToResetDragMargins:NO];
- if ([childView superview] != parentView)
- [parentView addSubview:childView];
- [window _setNeedsToResetDragMargins:resetDragMargins];
- END_BLOCK_OBJC_EXCEPTIONS;
-}
-
-void ScrollView::platformRemoveChild(Widget* child)
-{
- child->removeFromSuperview();
-}
-
-void ScrollView::platformSetScrollbarModes()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- [scrollView() setScrollingModes:m_horizontalScrollbarMode vertical:m_verticalScrollbarMode andLock:NO];
- END_BLOCK_OBJC_EXCEPTIONS;
-}
-
-void ScrollView::platformScrollbarModes(ScrollbarMode& horizontal, ScrollbarMode& vertical) const
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- [scrollView() scrollingModes:&horizontal vertical:&vertical];
- END_BLOCK_OBJC_EXCEPTIONS;
-}
-
-void ScrollView::platformSetCanBlitOnScroll()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- [[scrollView() contentView] setCopiesOnScroll:canBlitOnScroll()];
- END_BLOCK_OBJC_EXCEPTIONS;
-}
-
-IntRect ScrollView::platformVisibleContentRect(bool includeScrollbars) const
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- if (includeScrollbars) {
- if (NSView* documentView = this->documentView())
- return enclosingIntRect([documentView visibleRect]);
- }
- return enclosingIntRect([scrollView() documentVisibleRect]);
- END_BLOCK_OBJC_EXCEPTIONS;
- return IntRect();
-}
-
-IntSize ScrollView::platformContentsSize() const
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- if (NSView* documentView = this->documentView())
- return enclosingIntRect([documentView bounds]).size();
- END_BLOCK_OBJC_EXCEPTIONS;
- return IntSize();
-}
-
-void ScrollView::platformSetContentsSize()
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- int w = m_contentsSize.width();
- int h = m_contentsSize.height();
- LOG(Frames, "%p %@ at w %d h %d\n", documentView(), [(id)[documentView() class] className], w, h);
- NSSize tempSize = { max(0, w), max(0, h) }; // workaround for 4213314
- [documentView() setFrameSize:tempSize];
- END_BLOCK_OBJC_EXCEPTIONS;
-}
-
-void ScrollView::platformSetScrollbarsSuppressed(bool repaintOnUnsuppress)
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- [scrollView() setScrollBarsSuppressed:m_scrollbarsSuppressed
- repaintOnUnsuppress:repaintOnUnsuppress];
- END_BLOCK_OBJC_EXCEPTIONS;
-}
-
-void ScrollView::platformSetScrollPosition(const IntPoint& scrollPoint)
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- NSPoint tempPoint = { max(0, scrollPoint.x()), max(0, scrollPoint.y()) }; // Don't use NSMakePoint to work around 4213314.
- [documentView() scrollPoint:tempPoint];
- END_BLOCK_OBJC_EXCEPTIONS;
-}
-
-bool ScrollView::platformScroll(ScrollDirection, ScrollGranularity)
-{
- // FIXME: It would be nice to implement this so that all of the code in WebFrameView could go away.
- notImplemented();
- return true;
-}
-
-void ScrollView::platformRepaintContentRectangle(const IntRect& rect, bool now)
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
-
- NSView *view = documentView();
- NSRect visibleRect = visibleContentRect();
-
- // FIXME: I don't think this intersection is necessary any more now that
- // selection doesn't call this method directly (but has to go through FrameView's
- // repaintContentRectangle, which does the intersection test also). Leaving it in
- // for now until I'm sure.
- // Checking for rect visibility is an important optimization for the case of
- // Select All of a large document. AppKit does not do this check, and so ends
- // up building a large complicated NSRegion if we don't perform the check.
- NSRect dirtyRect = NSIntersectionRect(rect, visibleRect);
- if (!NSIsEmptyRect(dirtyRect)) {
- [view setNeedsDisplayInRect:dirtyRect];
- if (now) {
- [[view window] displayIfNeeded];
- [[view window] flushWindowIfNeeded];
- }
- }
-
- END_BLOCK_OBJC_EXCEPTIONS;
-}
-
-// "Containing Window" means the NSWindow's coord system, which is origin lower left
-
-IntRect ScrollView::platformContentsToScreen(const IntRect& rect) const
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- if (NSView* documentView = this->documentView()) {
- NSRect tempRect = rect;
- tempRect = [documentView convertRect:tempRect toView:nil];
- tempRect.origin = [[documentView window] convertBaseToScreen:tempRect.origin];
- return enclosingIntRect(tempRect);
- }
- END_BLOCK_OBJC_EXCEPTIONS;
- return IntRect();
-}
-
-IntPoint ScrollView::platformScreenToContents(const IntPoint& point) const
-{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- if (NSView* documentView = this->documentView()) {
- NSPoint windowCoord = [[documentView window] convertScreenToBase: point];
- return IntPoint([documentView convertPoint:windowCoord fromView:nil]);
- }
- END_BLOCK_OBJC_EXCEPTIONS;
- return IntPoint();
-}
-
-bool ScrollView::platformIsOffscreen() const
-{
- return ![platformWidget() window] || ![[platformWidget() window] isVisible];
-}
-
-}
diff --git a/WebCore/platform/mac/ScrollbarThemeMac.h b/WebCore/platform/mac/ScrollbarThemeMac.h
deleted file mode 100644
index 5af5fd5..0000000
--- a/WebCore/platform/mac/ScrollbarThemeMac.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ScrollbarThemeMac_h
-#define ScrollbarThemeMac_h
-
-#include "ScrollbarThemeComposite.h"
-
-namespace WebCore {
-
-class ScrollbarThemeMac : public ScrollbarThemeComposite {
-public:
- ScrollbarThemeMac();
- virtual ~ScrollbarThemeMac();
-
- virtual bool paint(Scrollbar*, GraphicsContext* context, const IntRect& damageRect);
-
- virtual int scrollbarThickness(ScrollbarControlSize = RegularScrollbar);
-
- virtual bool supportsControlTints() const { return true; }
-
- virtual double initialAutoscrollTimerDelay();
- virtual double autoscrollTimerDelay();
-
- virtual ScrollbarButtonsPlacement buttonsPlacement() const;
-
- virtual void registerScrollbar(Scrollbar*);
- virtual void unregisterScrollbar(Scrollbar*);
-
-protected:
- virtual bool hasButtons(Scrollbar*);
- virtual bool hasThumb(Scrollbar*);
-
- virtual IntRect backButtonRect(Scrollbar*, ScrollbarPart, bool painting = false);
- virtual IntRect forwardButtonRect(Scrollbar*, ScrollbarPart, bool painting = false);
- virtual IntRect trackRect(Scrollbar*, bool painting = false);
-
- virtual int minimumThumbLength(Scrollbar*);
-
- virtual bool shouldCenterOnThumb(Scrollbar*, const PlatformMouseEvent&);
-
-public:
- void preferencesChanged();
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/mac/ScrollbarThemeMac.mm b/WebCore/platform/mac/ScrollbarThemeMac.mm
deleted file mode 100644
index dd2c233..0000000
--- a/WebCore/platform/mac/ScrollbarThemeMac.mm
+++ /dev/null
@@ -1,403 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ScrollbarThemeMac.h"
-
-#include "GraphicsContext.h"
-#include "ImageBuffer.h"
-#include "IntRect.h"
-#include "Page.h"
-#include "PlatformMouseEvent.h"
-#include "Scrollbar.h"
-#include "ScrollbarClient.h"
-#include "Settings.h"
-
-#include <Carbon/Carbon.h>
-
-// FIXME: There are repainting problems due to Aqua scroll bar buttons' visual overflow.
-
-using namespace std;
-using namespace WebCore;
-
-static HashSet<Scrollbar*>* gScrollbars;
-
-@interface ScrollbarPrefsObserver : NSObject
-{
-
-}
-
-+ (void)registerAsObserver;
-+ (void)appearancePrefsChanged:(NSNotification*)theNotification;
-+ (void)behaviorPrefsChanged:(NSNotification*)theNotification;
-
-@end
-
-@implementation ScrollbarPrefsObserver
-
-+ (void)appearancePrefsChanged:(NSNotification*)theNotification
-{
- static_cast<ScrollbarThemeMac*>(ScrollbarTheme::nativeTheme())->preferencesChanged();
- if (!gScrollbars)
- return;
- HashSet<Scrollbar*>::iterator end = gScrollbars->end();
- for (HashSet<Scrollbar*>::iterator it = gScrollbars->begin(); it != end; ++it) {
- (*it)->styleChanged();
- (*it)->invalidate();
- }
-}
-
-+ (void)behaviorPrefsChanged:(NSNotification*)theNotification
-{
- static_cast<ScrollbarThemeMac*>(ScrollbarTheme::nativeTheme())->preferencesChanged();
-}
-
-+ (void)registerAsObserver
-{
- [[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(appearancePrefsChanged:) name:@"AppleAquaScrollBarVariantChanged" object:nil suspensionBehavior:NSNotificationSuspensionBehaviorDeliverImmediately];
- [[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(behaviorPrefsChanged:) name:@"AppleNoRedisplayAppearancePreferenceChanged" object:nil suspensionBehavior:NSNotificationSuspensionBehaviorCoalesce];
-}
-
-@end
-
-namespace WebCore {
-
-ScrollbarTheme* ScrollbarTheme::nativeTheme()
-{
- static ScrollbarThemeMac theme;
- return &theme;
-}
-
-// FIXME: Get these numbers from CoreUI.
-static int cScrollbarThickness[] = { 15, 11 };
-static int cRealButtonLength[] = { 28, 21 };
-static int cButtonInset[] = { 14, 11 };
-static int cButtonHitInset[] = { 3, 2 };
-// cRealButtonLength - cButtonInset
-static int cButtonLength[] = { 14, 10 };
-static int cThumbMinLength[] = { 26, 20 };
-
-static int cOuterButtonLength[] = { 16, 14 }; // The outer button in a double button pair is a bit bigger.
-static int cOuterButtonOverlap = 2;
-
-static float gInitialButtonDelay = 0.5f;
-static float gAutoscrollButtonDelay = 0.05f;
-static bool gJumpOnTrackClick = false;
-static ScrollbarButtonsPlacement gButtonPlacement = ScrollbarButtonsDoubleEnd;
-
-static void updateArrowPlacement()
-{
- NSString *buttonPlacement = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleScrollBarVariant"];
- if ([buttonPlacement isEqualToString:@"Single"])
- gButtonPlacement = ScrollbarButtonsSingle;
- else if ([buttonPlacement isEqualToString:@"DoubleMin"])
- gButtonPlacement = ScrollbarButtonsDoubleStart;
- else if ([buttonPlacement isEqualToString:@"DoubleBoth"])
- gButtonPlacement = ScrollbarButtonsDoubleBoth;
- else
- gButtonPlacement = ScrollbarButtonsDoubleEnd; // The default is ScrollbarButtonsDoubleEnd.
-}
-
-void ScrollbarThemeMac::registerScrollbar(Scrollbar* scrollbar)
-{
- if (!gScrollbars)
- gScrollbars = new HashSet<Scrollbar*>;
- gScrollbars->add(scrollbar);
-}
-
-void ScrollbarThemeMac::unregisterScrollbar(Scrollbar* scrollbar)
-{
- gScrollbars->remove(scrollbar);
- if (gScrollbars->isEmpty()) {
- delete gScrollbars;
- gScrollbars = 0;
- }
-}
-
-ScrollbarThemeMac::ScrollbarThemeMac()
-{
- static bool initialized;
- if (!initialized) {
- initialized = true;
- [ScrollbarPrefsObserver registerAsObserver];
- preferencesChanged();
- }
-}
-
-ScrollbarThemeMac::~ScrollbarThemeMac()
-{
-}
-
-void ScrollbarThemeMac::preferencesChanged()
-{
- NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
- [defaults synchronize];
- updateArrowPlacement();
- gInitialButtonDelay = [defaults floatForKey:@"NSScrollerButtonDelay"];
- gAutoscrollButtonDelay = [defaults floatForKey:@"NSScrollerButtonPeriod"];
- gJumpOnTrackClick = [defaults boolForKey:@"AppleScrollerPagingBehavior"];
-}
-
-int ScrollbarThemeMac::scrollbarThickness(ScrollbarControlSize controlSize)
-{
- return cScrollbarThickness[controlSize];
-}
-
-double ScrollbarThemeMac::initialAutoscrollTimerDelay()
-{
- return gInitialButtonDelay;
-}
-
-double ScrollbarThemeMac::autoscrollTimerDelay()
-{
- return gAutoscrollButtonDelay;
-}
-
-ScrollbarButtonsPlacement ScrollbarThemeMac::buttonsPlacement() const
-{
- return gButtonPlacement;
-}
-
-bool ScrollbarThemeMac::hasButtons(Scrollbar* scrollbar)
-{
- return scrollbar->enabled() && (scrollbar->orientation() == HorizontalScrollbar ?
- scrollbar->width() :
- scrollbar->height()) >= 2 * (cRealButtonLength[scrollbar->controlSize()] - cButtonHitInset[scrollbar->controlSize()]);
-}
-
-bool ScrollbarThemeMac::hasThumb(Scrollbar* scrollbar)
-{
- return scrollbar->enabled() && (scrollbar->orientation() == HorizontalScrollbar ?
- scrollbar->width() :
- scrollbar->height()) >= 2 * cButtonInset[scrollbar->controlSize()] + cThumbMinLength[scrollbar->controlSize()] + 1;
-}
-
-static IntRect buttonRepaintRect(const IntRect& buttonRect, ScrollbarOrientation orientation, ScrollbarControlSize controlSize, bool start)
-{
- IntRect paintRect(buttonRect);
- if (orientation == HorizontalScrollbar) {
- paintRect.setWidth(cRealButtonLength[controlSize]);
- if (!start)
- paintRect.setX(buttonRect.x() - (cRealButtonLength[controlSize] - buttonRect.width()));
- } else {
- paintRect.setHeight(cRealButtonLength[controlSize]);
- if (!start)
- paintRect.setY(buttonRect.y() - (cRealButtonLength[controlSize] - buttonRect.height()));
- }
-
- return paintRect;
-}
-
-IntRect ScrollbarThemeMac::backButtonRect(Scrollbar* scrollbar, ScrollbarPart part, bool painting)
-{
- IntRect result;
-
- if (part == BackButtonStartPart && (buttonsPlacement() == ScrollbarButtonsNone || buttonsPlacement() == ScrollbarButtonsDoubleEnd))
- return result;
-
- if (part == BackButtonEndPart && (buttonsPlacement() == ScrollbarButtonsNone || buttonsPlacement() == ScrollbarButtonsDoubleStart || buttonsPlacement() == ScrollbarButtonsSingle))
- return result;
-
- int thickness = scrollbarThickness(scrollbar->controlSize());
- bool outerButton = part == BackButtonStartPart && (buttonsPlacement() == ScrollbarButtonsDoubleStart || buttonsPlacement() == ScrollbarButtonsDoubleBoth);
- if (outerButton) {
- if (scrollbar->orientation() == HorizontalScrollbar)
- result = IntRect(scrollbar->x(), scrollbar->y(), cOuterButtonLength[scrollbar->controlSize()] + painting ? cOuterButtonOverlap : 0, thickness);
- else
- result = IntRect(scrollbar->x(), scrollbar->y(), thickness, cOuterButtonLength[scrollbar->controlSize()] + painting ? cOuterButtonOverlap : 0);
- return result;
- }
-
- // Our repaint rect is slightly larger, since we are a button that is adjacent to the track.
- if (scrollbar->orientation() == HorizontalScrollbar) {
- int start = part == BackButtonStartPart ? scrollbar->x() : scrollbar->x() + scrollbar->width() - cOuterButtonLength[scrollbar->controlSize()] - cButtonLength[scrollbar->controlSize()];
- result = IntRect(start, scrollbar->y(), cButtonLength[scrollbar->controlSize()], thickness);
- } else {
- int start = part == BackButtonStartPart ? scrollbar->y() : scrollbar->y() + scrollbar->height() - cOuterButtonLength[scrollbar->controlSize()] - cButtonLength[scrollbar->controlSize()];
- result = IntRect(scrollbar->x(), start, thickness, cButtonLength[scrollbar->controlSize()]);
- }
-
- if (painting)
- return buttonRepaintRect(result, scrollbar->orientation(), scrollbar->controlSize(), part == BackButtonStartPart);
- return result;
-}
-
-IntRect ScrollbarThemeMac::forwardButtonRect(Scrollbar* scrollbar, ScrollbarPart part, bool painting)
-{
- IntRect result;
-
- if (part == ForwardButtonEndPart && (buttonsPlacement() == ScrollbarButtonsNone || buttonsPlacement() == ScrollbarButtonsDoubleStart))
- return result;
-
- if (part == ForwardButtonStartPart && (buttonsPlacement() == ScrollbarButtonsNone || buttonsPlacement() == ScrollbarButtonsDoubleEnd || buttonsPlacement() == ScrollbarButtonsSingle))
- return result;
-
- int thickness = scrollbarThickness(scrollbar->controlSize());
- int outerButtonLength = cOuterButtonLength[scrollbar->controlSize()];
- int buttonLength = cButtonLength[scrollbar->controlSize()];
-
- bool outerButton = part == ForwardButtonEndPart && (buttonsPlacement() == ScrollbarButtonsDoubleEnd || buttonsPlacement() == ScrollbarButtonsDoubleBoth);
- if (outerButton) {
- if (scrollbar->orientation() == HorizontalScrollbar) {
- result = IntRect(scrollbar->x() + scrollbar->width() - outerButtonLength, scrollbar->y(), outerButtonLength, thickness);
- if (painting)
- result.inflateX(cOuterButtonOverlap);
- } else {
- result = IntRect(scrollbar->x(), scrollbar->y() + scrollbar->height() - outerButtonLength, thickness, outerButtonLength);
- if (painting)
- result.inflateY(cOuterButtonOverlap);
- }
- return result;
- }
-
- if (scrollbar->orientation() == HorizontalScrollbar) {
- int start = part == ForwardButtonEndPart ? scrollbar->x() + scrollbar->width() - buttonLength : scrollbar->x() + outerButtonLength;
- result = IntRect(start, scrollbar->y(), buttonLength, thickness);
- } else {
- int start = part == ForwardButtonEndPart ? scrollbar->y() + scrollbar->height() - buttonLength : scrollbar->y() + outerButtonLength;
- result = IntRect(scrollbar->x(), start, thickness, buttonLength);
- }
- if (painting)
- return buttonRepaintRect(result, scrollbar->orientation(), scrollbar->controlSize(), part == ForwardButtonStartPart);
- return result;
-}
-
-IntRect ScrollbarThemeMac::trackRect(Scrollbar* scrollbar, bool painting)
-{
- if (painting || !hasButtons(scrollbar))
- return scrollbar->frameRect();
-
- IntRect result;
- int thickness = scrollbarThickness(scrollbar->controlSize());
- int startWidth = 0;
- int endWidth = 0;
- int outerButtonLength = cOuterButtonLength[scrollbar->controlSize()];
- int buttonLength = cButtonLength[scrollbar->controlSize()];
- int doubleButtonLength = outerButtonLength + buttonLength;
- switch (buttonsPlacement()) {
- case ScrollbarButtonsSingle:
- startWidth = buttonLength;
- endWidth = buttonLength;
- break;
- case ScrollbarButtonsDoubleStart:
- startWidth = doubleButtonLength;
- break;
- case ScrollbarButtonsDoubleEnd:
- endWidth = doubleButtonLength;
- break;
- case ScrollbarButtonsDoubleBoth:
- startWidth = doubleButtonLength;
- endWidth = doubleButtonLength;
- break;
- default:
- break;
- }
-
- int totalWidth = startWidth + endWidth;
- if (scrollbar->orientation() == HorizontalScrollbar)
- return IntRect(scrollbar->x() + startWidth, scrollbar->y(), scrollbar->width() - totalWidth, thickness);
- return IntRect(scrollbar->x(), scrollbar->y() + startWidth, thickness, scrollbar->height() - totalWidth);
-}
-
-int ScrollbarThemeMac::minimumThumbLength(Scrollbar* scrollbar)
-{
- return cThumbMinLength[scrollbar->controlSize()];
-}
-
-bool ScrollbarThemeMac::shouldCenterOnThumb(Scrollbar*, const PlatformMouseEvent& evt)
-{
- if (evt.button() != LeftButton)
- return false;
- if (gJumpOnTrackClick)
- return !evt.altKey();
- return evt.altKey();
-}
-
-static int scrollbarPartToHIPressedState(ScrollbarPart part)
-{
- switch (part) {
- case BackButtonStartPart:
- return kThemeTopOutsideArrowPressed;
- case BackButtonEndPart:
- return kThemeTopOutsideArrowPressed; // This does not make much sense. For some reason the outside constant is required.
- case ForwardButtonStartPart:
- return kThemeTopInsideArrowPressed;
- case ForwardButtonEndPart:
- return kThemeBottomOutsideArrowPressed;
- case ThumbPart:
- return kThemeThumbPressed;
- default:
- return 0;
- }
-}
-
-bool ScrollbarThemeMac::paint(Scrollbar* scrollbar, GraphicsContext* context, const IntRect& damageRect)
-{
- HIThemeTrackDrawInfo trackInfo;
- trackInfo.version = 0;
- trackInfo.kind = scrollbar->controlSize() == RegularScrollbar ? kThemeMediumScrollBar : kThemeSmallScrollBar;
- trackInfo.bounds = scrollbar->frameRect();
- trackInfo.min = 0;
- trackInfo.max = scrollbar->maximum();
- trackInfo.value = scrollbar->currentPos();
- trackInfo.trackInfo.scrollbar.viewsize = scrollbar->pageStep();
- trackInfo.attributes = 0;
- if (scrollbar->orientation() == HorizontalScrollbar)
- trackInfo.attributes |= kThemeTrackHorizontal;
- trackInfo.enableState = scrollbar->client()->isActive() ? kThemeTrackActive : kThemeTrackInactive;
- if (!scrollbar->enabled())
- trackInfo.enableState = kThemeTrackDisabled;
- if (hasThumb(scrollbar))
- trackInfo.attributes |= kThemeTrackShowThumb;
- else if (!hasButtons(scrollbar))
- trackInfo.enableState = kThemeTrackNothingToScroll;
- trackInfo.trackInfo.scrollbar.pressState = scrollbarPartToHIPressedState(scrollbar->pressedPart());
-
- CGAffineTransform currentCTM = CGContextGetCTM(context->platformContext());
-
- // The Aqua scrollbar is buggy when rotated and scaled. We will just draw into a bitmap if we detect a scale or rotation.
- bool canDrawDirectly = currentCTM.a == 1.0f && currentCTM.b == 0.0f && currentCTM.c == 0.0f && (currentCTM.d == 1.0f || currentCTM.d == -1.0f);
- if (canDrawDirectly)
- HIThemeDrawTrack(&trackInfo, 0, context->platformContext(), kHIThemeOrientationNormal);
- else {
- trackInfo.bounds = IntRect(IntPoint(), scrollbar->frameRect().size());
-
- IntRect bufferRect(scrollbar->frameRect());
- bufferRect.intersect(damageRect);
- bufferRect.move(-scrollbar->frameRect().x(), -scrollbar->frameRect().y());
-
- auto_ptr<ImageBuffer> imageBuffer = ImageBuffer::create(bufferRect.size(), false);
- if (!imageBuffer.get())
- return true;
-
- HIThemeDrawTrack(&trackInfo, 0, imageBuffer->context()->platformContext(), kHIThemeOrientationNormal);
- context->drawImage(imageBuffer->image(), scrollbar->frameRect().location());
- }
-
- return true;
-}
-
-}
-
diff --git a/WebCore/platform/mac/SearchPopupMenuMac.mm b/WebCore/platform/mac/SearchPopupMenuMac.mm
deleted file mode 100644
index 262734d..0000000
--- a/WebCore/platform/mac/SearchPopupMenuMac.mm
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#import "config.h"
-#import "SearchPopupMenu.h"
-
-#import "AtomicString.h"
-
-namespace WebCore {
-
-SearchPopupMenu::SearchPopupMenu(PopupMenuClient* client)
- : PopupMenu(client)
-{
-}
-
-static NSString* autosaveKey(const String& name)
-{
- return [@"com.apple.WebKit.searchField:" stringByAppendingString:name];
-}
-
-bool SearchPopupMenu::enabled()
-{
- return true;
-}
-
-void SearchPopupMenu::saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems)
-{
- if (name.isEmpty())
- return;
-
- size_t size = searchItems.size();
- if (size == 0)
- [[NSUserDefaults standardUserDefaults] removeObjectForKey:autosaveKey(name)];
- else {
- NSMutableArray* items = [[NSMutableArray alloc] initWithCapacity:size];
- for (size_t i = 0; i < size; ++i)
- [items addObject:searchItems[i]];
- [[NSUserDefaults standardUserDefaults] setObject:items forKey:autosaveKey(name)];
- [items release];
- }
-}
-
-void SearchPopupMenu::loadRecentSearches(const AtomicString& name, Vector<String>& searchItems)
-{
- if (name.isEmpty())
- return;
-
- searchItems.clear();
- NSArray* items = [[NSUserDefaults standardUserDefaults] arrayForKey:autosaveKey(name)];
- size_t size = [items count];
- for (size_t i = 0; i < size; ++i) {
- NSString* item = [items objectAtIndex:i];
- if ([item isKindOfClass:[NSString class]])
- searchItems.append(item);
- }
-}
-
-}
diff --git a/WebCore/platform/mac/SharedBufferMac.mm b/WebCore/platform/mac/SharedBufferMac.mm
deleted file mode 100644
index ecf01c7..0000000
--- a/WebCore/platform/mac/SharedBufferMac.mm
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FoundationExtras.h"
-#include "SharedBuffer.h"
-#include "WebCoreObjCExtras.h"
-#include <string.h>
-#include <wtf/PassRefPtr.h>
-
-#ifdef BUILDING_ON_TIGER
-typedef unsigned NSUInteger;
-#endif
-
-using namespace WebCore;
-
-@interface WebCoreSharedBufferData : NSData
-{
- SharedBuffer* sharedBuffer;
-}
-
-- (id)initWithSharedBuffer:(SharedBuffer*)buffer;
-@end
-
-@implementation WebCoreSharedBufferData
-
-#ifndef BUILDING_ON_TIGER
-+ (void)initialize
-{
- WebCoreObjCFinalizeOnMainThread(self);
-}
-#endif
-
-- (void)dealloc
-{
- if (WebCoreObjCScheduleDeallocateOnMainThread([WebCoreSharedBufferData class], self))
- return;
-
- sharedBuffer->deref();
-
- [super dealloc];
-}
-
-- (void)finalize
-{
- sharedBuffer->deref();
-
- [super finalize];
-}
-
-- (id)initWithSharedBuffer:(SharedBuffer*)buffer
-{
- self = [super init];
-
- if (self) {
- sharedBuffer = buffer;
- sharedBuffer->ref();
- }
-
- return self;
-}
-
-- (NSUInteger)length
-{
- return sharedBuffer->size();
-}
-
-- (const void *)bytes
-{
- return reinterpret_cast<const void*>(sharedBuffer->data());
-}
-
-@end
-
-namespace WebCore {
-
-PassRefPtr<SharedBuffer> SharedBuffer::wrapNSData(NSData *nsData)
-{
- return adoptRef(new SharedBuffer((CFDataRef)nsData));
-}
-
-NSData *SharedBuffer::createNSData()
-{
- return [[WebCoreSharedBufferData alloc] initWithSharedBuffer:this];
-}
-
-CFDataRef SharedBuffer::createCFData()
-{
- if (m_cfData) {
- CFRetain(m_cfData.get());
- return m_cfData.get();
- }
-
- return (CFDataRef)HardRetainWithNSRelease([[WebCoreSharedBufferData alloc] initWithSharedBuffer:this]);
-}
-
-PassRefPtr<SharedBuffer> SharedBuffer::createWithContentsOfFile(const String& filePath)
-{
- NSData *resourceData = [NSData dataWithContentsOfFile:filePath];
- if (resourceData)
- return SharedBuffer::wrapNSData(resourceData);
- return 0;
-}
-
-}
-
diff --git a/WebCore/platform/mac/SharedTimerMac.mm b/WebCore/platform/mac/SharedTimerMac.mm
deleted file mode 100644
index 991f527..0000000
--- a/WebCore/platform/mac/SharedTimerMac.mm
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "SharedTimer.h"
-
-#include <Foundation/Foundation.h>
-#include <wtf/Assertions.h>
-
-@class WebCorePowerNotifier;
-
-namespace WebCore {
-
-static WebCorePowerNotifier *powerNotifier;
-static CFRunLoopTimerRef sharedTimer;
-static void (*sharedTimerFiredFunction)();
-static void timerFired(CFRunLoopTimerRef, void*);
-
-}
-
-@interface WebCorePowerNotifier : NSObject
-@end
-
-@implementation WebCorePowerNotifier
-
-- (id)init
-{
- self = [super init];
-
- if (self)
- [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self
- selector:@selector(didWake:)
- name:NSWorkspaceDidWakeNotification
- object:nil];
-
- return self;
-}
-
-- (void)didWake:(NSNotification *)notification
-{
- if (WebCore::sharedTimer) {
- WebCore::stopSharedTimer();
- WebCore::timerFired(0, 0);
- }
-}
-
-@end
-
-namespace WebCore {
-
-void setSharedTimerFiredFunction(void (*f)())
-{
- ASSERT(!sharedTimerFiredFunction || sharedTimerFiredFunction == f);
-
- sharedTimerFiredFunction = f;
-}
-
-static void timerFired(CFRunLoopTimerRef, void*)
-{
- // FIXME: We can remove this global catch-all if we fix <rdar://problem/5299018>.
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- sharedTimerFiredFunction();
- [pool drain];
-}
-
-void setSharedTimerFireTime(double fireTime)
-{
- ASSERT(sharedTimerFiredFunction);
-
- if (sharedTimer) {
- CFRunLoopTimerInvalidate(sharedTimer);
- CFRelease(sharedTimer);
- }
-
- CFAbsoluteTime fireDate = fireTime - kCFAbsoluteTimeIntervalSince1970;
- sharedTimer = CFRunLoopTimerCreate(0, fireDate, 0, 0, 0, timerFired, 0);
- CFRunLoopAddTimer(CFRunLoopGetCurrent(), sharedTimer, kCFRunLoopCommonModes);
-
- if (!powerNotifier) {
- powerNotifier = [[WebCorePowerNotifier alloc] init];
- CFRetain(powerNotifier);
- [powerNotifier release];
- }
-}
-
-void stopSharedTimer()
-{
- if (sharedTimer) {
- CFRunLoopTimerInvalidate(sharedTimer);
- CFRelease(sharedTimer);
- sharedTimer = 0;
- }
-}
-
-}
diff --git a/WebCore/platform/mac/SoftLinking.h b/WebCore/platform/mac/SoftLinking.h
deleted file mode 100644
index ce72f34..0000000
--- a/WebCore/platform/mac/SoftLinking.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <wtf/Assertions.h>
-#import <dlfcn.h>
-
-#define SOFT_LINK_LIBRARY(lib) \
- static void* lib##Library() \
- { \
- static void* dylib = dlopen("/usr/lib/" #lib ".dylib", RTLD_NOW); \
- ASSERT(dylib); \
- return dylib; \
- }
-
-#define SOFT_LINK_FRAMEWORK(framework) \
- static void* framework##Library() \
- { \
- static void* frameworkLibrary = dlopen("/System/Library/Frameworks/" #framework ".framework/" #framework, RTLD_NOW); \
- ASSERT(frameworkLibrary); \
- return frameworkLibrary; \
- }
-
-#define SOFT_LINK(framework, functionName, resultType, parameterDeclarations, parameterNames) \
- static resultType init##functionName parameterDeclarations; \
- static resultType (*softLink##functionName) parameterDeclarations = init##functionName; \
- \
- static resultType init##functionName parameterDeclarations \
- { \
- softLink##functionName = (resultType (*) parameterDeclarations) dlsym(framework##Library(), #functionName); \
- ASSERT(softLink##functionName); \
- return softLink##functionName parameterNames; \
- }\
- \
- inline resultType functionName parameterDeclarations \
- {\
- return softLink##functionName parameterNames; \
- }
-
-#define SOFT_LINK_CLASS(framework, className) \
- static Class init##className(); \
- static Class (*get##className##Class)() = init##className; \
- static Class class##className; \
- \
- static Class className##Function() \
- { \
- return class##className; \
- }\
- \
- static Class init##className() \
- { \
- framework##Library(); \
- class##className = objc_getClass(#className); \
- ASSERT(class##className); \
- get##className##Class = className##Function; \
- return class##className; \
- }
-
-#define SOFT_LINK_POINTER(framework, name, type) \
- static type init##name(); \
- static type (*get##name)() = init##name; \
- static type pointer##name; \
- \
- static type name##Function() \
- { \
- return pointer##name; \
- }\
- \
- static type init##name() \
- { \
- void** pointer = static_cast<void**>(dlsym(framework##Library(), #name)); \
- ASSERT(pointer); \
- pointer##name = static_cast<type>(*pointer); \
- get##name = name##Function; \
- return pointer##name; \
- }
-
-#define SOFT_LINK_CONSTANT(framework, name, type) \
- static type init##name(); \
- static type (*get##name)() = init##name; \
- static type constant##name; \
- \
- static type name##Function() \
- { \
- return constant##name; \
- }\
- \
- static type init##name() \
- { \
- void* constant = dlsym(framework##Library(), #name); \
- ASSERT(constant); \
- constant##name = *static_cast<type*>(constant); \
- get##name = name##Function; \
- return constant##name; \
- }
diff --git a/WebCore/platform/mac/SoundMac.mm b/WebCore/platform/mac/SoundMac.mm
deleted file mode 100644
index ced14b8..0000000
--- a/WebCore/platform/mac/SoundMac.mm
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "Sound.h"
-
-namespace WebCore {
-
-void systemBeep() { NSBeep(); }
-
-} // namespace WebCore
diff --git a/WebCore/platform/mac/SystemTimeMac.cpp b/WebCore/platform/mac/SystemTimeMac.cpp
deleted file mode 100644
index dd5e500..0000000
--- a/WebCore/platform/mac/SystemTimeMac.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "SystemTime.h"
-
-#include <CoreGraphics/CGEventSource.h>
-#include <CoreFoundation/CFDate.h>
-
-namespace WebCore {
-
-double currentTime()
-{
- return CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970;
-}
-
-float userIdleTime()
-{
- return static_cast<float>(CGEventSourceSecondsSinceLastEventType(kCGEventSourceStateCombinedSessionState, kCGAnyInputEventType));
-}
-
-}
diff --git a/WebCore/platform/mac/ThemeMac.h b/WebCore/platform/mac/ThemeMac.h
deleted file mode 100644
index ce534b1..0000000
--- a/WebCore/platform/mac/ThemeMac.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ThemeMac_h
-#define ThemeMac_h
-
-#include "Theme.h"
-
-namespace WebCore {
-
-class ThemeMac : public Theme {
-public:
- ThemeMac() { }
- virtual ~ThemeMac() { }
-
- virtual int baselinePositionAdjustment(ControlPart) const;
-
- virtual FontDescription controlFont(ControlPart, const Font&, float zoomFactor) const;
-
- virtual LengthSize controlSize(ControlPart, const Font&, const LengthSize&, float zoomFactor) const;
- virtual LengthSize minimumControlSize(ControlPart, const Font&, float zoomFactor) const;
-
- virtual LengthBox controlPadding(ControlPart, const Font&, const LengthBox& zoomedBox, float zoomFactor) const;
- virtual LengthBox controlBorder(ControlPart, const Font&, const LengthBox& zoomedBox, float zoomFactor) const;
-
- virtual bool controlRequiresPreWhiteSpace(ControlPart part) const { return part == PushButtonPart; }
-
- virtual void paint(ControlPart, ControlStates, GraphicsContext*, const IntRect&, float zoomFactor, ScrollView*) const;
- virtual void inflateControlPaintRect(ControlPart, ControlStates, IntRect&, float zoomFactor) const;
-};
-
-} // namespace WebCore
-
-#endif // ThemeMac_h
diff --git a/WebCore/platform/mac/ThemeMac.mm b/WebCore/platform/mac/ThemeMac.mm
deleted file mode 100644
index 3b1da55..0000000
--- a/WebCore/platform/mac/ThemeMac.mm
+++ /dev/null
@@ -1,544 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "ThemeMac.h"
-
-#import "GraphicsContext.h"
-#import "LocalCurrentGraphicsContext.h"
-#import "ScrollView.h"
-#import "WebCoreSystemInterface.h"
-
-using namespace std;
-
-// FIXME: Default buttons really should be more like push buttons and not like buttons.
-
-namespace WebCore {
-
-enum {
- topMargin,
- rightMargin,
- bottomMargin,
- leftMargin
-};
-
-Theme* platformTheme()
-{
- static ThemeMac themeMac;
- return &themeMac;
-}
-
-// Helper functions used by a bunch of different control parts.
-
-static NSControlSize controlSizeForFont(const Font& font)
-{
- int fontSize = font.pixelSize();
- if (fontSize >= 16)
- return NSRegularControlSize;
- if (fontSize >= 11)
- return NSSmallControlSize;
- return NSMiniControlSize;
-}
-
-static LengthSize sizeFromFont(const Font& font, const LengthSize& zoomedSize, float zoomFactor, const IntSize* sizes)
-{
- IntSize controlSize = sizes[controlSizeForFont(font)];
- if (zoomFactor != 1.0f)
- controlSize = IntSize(controlSize.width() * zoomFactor, controlSize.height() * zoomFactor);
- LengthSize result = zoomedSize;
- if (zoomedSize.width().isIntrinsicOrAuto() && controlSize.width() > 0)
- result.setWidth(Length(controlSize.width(), Fixed));
- if (zoomedSize.height().isIntrinsicOrAuto() && controlSize.height() > 0)
- result.setHeight(Length(controlSize.height(), Fixed));
- return result;
-}
-
-static void setControlSize(NSCell* cell, const IntSize* sizes, const IntSize& minZoomedSize, float zoomFactor)
-{
- NSControlSize size;
- if (minZoomedSize.width() >= static_cast<int>(sizes[NSRegularControlSize].width() * zoomFactor) &&
- minZoomedSize.height() >= static_cast<int>(sizes[NSRegularControlSize].height() * zoomFactor))
- size = NSRegularControlSize;
- else if (minZoomedSize.width() >= static_cast<int>(sizes[NSSmallControlSize].width() * zoomFactor) &&
- minZoomedSize.height() >= static_cast<int>(sizes[NSSmallControlSize].height() * zoomFactor))
- size = NSSmallControlSize;
- else
- size = NSMiniControlSize;
- if (size != [cell controlSize]) // Only update if we have to, since AppKit does work even if the size is the same.
- [cell setControlSize:size];
-}
-
-static void updateStates(NSCell* cell, ControlStates states)
-{
- // Hover state is not supported by Aqua.
-
- // Pressed state
- bool oldPressed = [cell isHighlighted];
- bool pressed = states & PressedState;
- if (pressed != oldPressed)
- [cell setHighlighted:pressed];
-
- // Enabled state
- bool oldEnabled = [cell isEnabled];
- bool enabled = states & EnabledState;
- if (enabled != oldEnabled)
- [cell setEnabled:enabled];
-
- // Focused state
- bool oldFocused = [cell showsFirstResponder];
- bool focused = states & FocusState;
- if (focused != oldFocused)
- [cell setShowsFirstResponder:focused];
-
- // Checked and Indeterminate
- bool oldIndeterminate = [cell state] == NSMixedState;
- bool indeterminate = (states & IndeterminateState);
- bool checked = states & CheckedState;
- bool oldChecked = [cell state] == NSOnState;
- if (oldIndeterminate != indeterminate || checked != oldChecked)
- [cell setState:indeterminate ? NSMixedState : (checked ? NSOnState : NSOffState)];
-
- // Window inactive state does not need to be checked explicitly, since we paint parented to
- // a view in a window whose key state can be detected.
-}
-
-static IntRect inflateRect(const IntRect& zoomedRect, const IntSize& zoomedSize, const int* margins, float zoomFactor)
-{
- // Only do the inflation if the available width/height are too small. Otherwise try to
- // fit the glow/check space into the available box's width/height.
- int widthDelta = zoomedRect.width() - (zoomedSize.width() + margins[leftMargin] * zoomFactor + margins[rightMargin] * zoomFactor);
- int heightDelta = zoomedRect.height() - (zoomedSize.height() + margins[topMargin] * zoomFactor + margins[bottomMargin] * zoomFactor);
- IntRect result(zoomedRect);
- if (widthDelta < 0) {
- result.setX(result.x() - margins[leftMargin] * zoomFactor);
- result.setWidth(result.width() - widthDelta);
- }
- if (heightDelta < 0) {
- result.setY(result.y() - margins[topMargin] * zoomFactor);
- result.setHeight(result.height() - heightDelta);
- }
- return result;
-}
-
-// Checkboxes
-
-static const IntSize* checkboxSizes()
-{
- static const IntSize sizes[3] = { IntSize(14, 14), IntSize(12, 12), IntSize(10, 10) };
- return sizes;
-}
-
-static const int* checkboxMargins(NSControlSize controlSize)
-{
- static const int margins[3][4] =
- {
- { 3, 4, 4, 2 },
- { 4, 3, 3, 3 },
- { 4, 3, 3, 3 },
- };
- return margins[controlSize];
-}
-
-static LengthSize checkboxSize(const Font& font, const LengthSize& zoomedSize, float zoomFactor)
-{
- // If the width and height are both specified, then we have nothing to do.
- if (!zoomedSize.width().isIntrinsicOrAuto() && !zoomedSize.height().isIntrinsicOrAuto())
- return zoomedSize;
-
- // Use the font size to determine the intrinsic width of the control.
- return sizeFromFont(font, zoomedSize, zoomFactor, checkboxSizes());
-}
-
-static NSButtonCell* checkbox(ControlStates states, const IntRect& zoomedRect, float zoomFactor)
-{
- static NSButtonCell* checkboxCell;
- if (!checkboxCell) {
- checkboxCell = [[NSButtonCell alloc] init];
- [checkboxCell setButtonType:NSSwitchButton];
- [checkboxCell setTitle:nil];
- [checkboxCell setAllowsMixedState:YES];
- [checkboxCell setFocusRingType:NSFocusRingTypeExterior];
- }
-
- // Set the control size based off the rectangle we're painting into.
- setControlSize(checkboxCell, checkboxSizes(), zoomedRect.size(), zoomFactor);
-
- // Update the various states we respond to.
- updateStates(checkboxCell, states);
-
- return checkboxCell;
-}
-
-// FIXME: Share more code with radio buttons.
-static void paintCheckbox(ControlStates states, GraphicsContext* context, const IntRect& zoomedRect, float zoomFactor, ScrollView* scrollView)
-{
- // Determine the width and height needed for the control and prepare the cell for painting.
- NSButtonCell* checkboxCell = checkbox(states, zoomedRect, zoomFactor);
-
- context->save();
-
- NSControlSize controlSize = [checkboxCell controlSize];
- IntSize zoomedSize = checkboxSizes()[controlSize];
- zoomedSize.setWidth(zoomedSize.width() * zoomFactor);
- zoomedSize.setHeight(zoomedSize.height() * zoomFactor);
- IntRect inflatedRect = inflateRect(zoomedRect, zoomedSize, checkboxMargins(controlSize), zoomFactor);
-
- if (zoomFactor != 1.0f) {
- inflatedRect.setWidth(inflatedRect.width() / zoomFactor);
- inflatedRect.setHeight(inflatedRect.height() / zoomFactor);
- context->translate(inflatedRect.x(), inflatedRect.y());
- context->scale(FloatSize(zoomFactor, zoomFactor));
- context->translate(-inflatedRect.x(), -inflatedRect.y());
- }
-
- [checkboxCell drawWithFrame:NSRect(inflatedRect) inView:scrollView->documentView()];
- [checkboxCell setControlView:nil];
-
- context->restore();
-}
-
-// Radio Buttons
-
-static const IntSize* radioSizes()
-{
- static const IntSize sizes[3] = { IntSize(14, 15), IntSize(12, 13), IntSize(10, 10) };
- return sizes;
-}
-
-static const int* radioMargins(NSControlSize controlSize)
-{
- static const int margins[3][4] =
- {
- { 2, 2, 4, 2 },
- { 3, 2, 3, 2 },
- { 1, 0, 2, 0 },
- };
- return margins[controlSize];
-}
-
-static LengthSize radioSize(const Font& font, const LengthSize& zoomedSize, float zoomFactor)
-{
- // If the width and height are both specified, then we have nothing to do.
- if (!zoomedSize.width().isIntrinsicOrAuto() && !zoomedSize.height().isIntrinsicOrAuto())
- return zoomedSize;
-
- // Use the font size to determine the intrinsic width of the control.
- return sizeFromFont(font, zoomedSize, zoomFactor, radioSizes());
-}
-
-static NSButtonCell* radio(ControlStates states, const IntRect& zoomedRect, float zoomFactor)
-{
- static NSButtonCell* radioCell;
- if (!radioCell) {
- radioCell = [[NSButtonCell alloc] init];
- [radioCell setButtonType:NSRadioButton];
- [radioCell setTitle:nil];
- [radioCell setFocusRingType:NSFocusRingTypeExterior];
- }
-
- // Set the control size based off the rectangle we're painting into.
- setControlSize(radioCell, radioSizes(), zoomedRect.size(), zoomFactor);
-
- // Update the various states we respond to.
- updateStates(radioCell, states);
-
- return radioCell;
-}
-
-static void paintRadio(ControlStates states, GraphicsContext* context, const IntRect& zoomedRect, float zoomFactor, ScrollView* scrollView)
-{
- // Determine the width and height needed for the control and prepare the cell for painting.
- NSButtonCell* radioCell = radio(states, zoomedRect, zoomFactor);
-
- context->save();
-
- NSControlSize controlSize = [radioCell controlSize];
- IntSize zoomedSize = radioSizes()[controlSize];
- zoomedSize.setWidth(zoomedSize.width() * zoomFactor);
- zoomedSize.setHeight(zoomedSize.height() * zoomFactor);
- IntRect inflatedRect = inflateRect(zoomedRect, zoomedSize, radioMargins(controlSize), zoomFactor);
-
- if (zoomFactor != 1.0f) {
- inflatedRect.setWidth(inflatedRect.width() / zoomFactor);
- inflatedRect.setHeight(inflatedRect.height() / zoomFactor);
- context->translate(inflatedRect.x(), inflatedRect.y());
- context->scale(FloatSize(zoomFactor, zoomFactor));
- context->translate(-inflatedRect.x(), -inflatedRect.y());
- }
-
- [radioCell drawWithFrame:NSRect(inflatedRect) inView:scrollView->documentView()];
- [radioCell setControlView:nil];
-
- context->restore();
-}
-
-// Buttons
-
-// Buttons really only constrain height. They respect width.
-static const IntSize* buttonSizes()
-{
- static const IntSize sizes[3] = { IntSize(0, 21), IntSize(0, 18), IntSize(0, 15) };
- return sizes;
-}
-
-static const int* buttonMargins(NSControlSize controlSize)
-{
- static const int margins[3][4] =
- {
- { 4, 6, 7, 6 },
- { 4, 5, 6, 5 },
- { 0, 1, 1, 1 },
- };
- return margins[controlSize];
-}
-
-static NSButtonCell* button(ControlPart part, ControlStates states, const IntRect& zoomedRect, float zoomFactor)
-{
- static NSButtonCell *buttonCell;
- static bool defaultButton;
- if (!buttonCell) {
- buttonCell = [[NSButtonCell alloc] init];
- [buttonCell setTitle:nil];
- [buttonCell setButtonType:NSMomentaryPushInButton];
- }
-
- // Set the control size based off the rectangle we're painting into.
- if (part == SquareButtonPart || zoomedRect.height() > buttonSizes()[NSRegularControlSize].height() * zoomFactor) {
- // Use the square button
- if ([buttonCell bezelStyle] != NSShadowlessSquareBezelStyle)
- [buttonCell setBezelStyle:NSShadowlessSquareBezelStyle];
- } else if ([buttonCell bezelStyle] != NSRoundedBezelStyle)
- [buttonCell setBezelStyle:NSRoundedBezelStyle];
-
- setControlSize(buttonCell, buttonSizes(), zoomedRect.size(), zoomFactor);
-
- if (defaultButton != (states & DefaultState)) {
- defaultButton = !defaultButton;
- [buttonCell setKeyEquivalent:(defaultButton ? @"\r" : @"")];
- }
-
- // Update the various states we respond to.
- updateStates(buttonCell, states);
-
- return buttonCell;
-}
-
-static void paintButton(ControlPart part, ControlStates states, GraphicsContext* context, const IntRect& zoomedRect, float zoomFactor, ScrollView* scrollView)
-{
- // Determine the width and height needed for the control and prepare the cell for painting.
- NSButtonCell *buttonCell = button(part, states, zoomedRect, zoomFactor);
- LocalCurrentGraphicsContext localContext(context);
-
- NSControlSize controlSize = [buttonCell controlSize];
- IntSize zoomedSize = buttonSizes()[controlSize];
- zoomedSize.setWidth(zoomedRect.width()); // Buttons don't ever constrain width, so the zoomed width can just be honored.
- zoomedSize.setHeight(zoomedSize.height() * zoomFactor);
- IntRect inflatedRect = zoomedRect;
- if ([buttonCell bezelStyle] == NSRoundedBezelStyle) {
- // Center the button within the available space.
- if (inflatedRect.height() > zoomedSize.height()) {
- inflatedRect.setY(inflatedRect.y() + (inflatedRect.height() - zoomedSize.height()) / 2);
- inflatedRect.setHeight(zoomedSize.height());
- }
-
- // Now inflate it to account for the shadow.
- inflatedRect = inflateRect(inflatedRect, zoomedSize, buttonMargins(controlSize), zoomFactor);
-
- if (zoomFactor != 1.0f) {
- inflatedRect.setWidth(inflatedRect.width() / zoomFactor);
- inflatedRect.setHeight(inflatedRect.height() / zoomFactor);
- context->translate(inflatedRect.x(), inflatedRect.y());
- context->scale(FloatSize(zoomFactor, zoomFactor));
- context->translate(-inflatedRect.x(), -inflatedRect.y());
- }
- }
-
- NSView *view = scrollView->documentView();
- NSWindow *window = [view window];
- NSButtonCell *previousDefaultButtonCell = [window defaultButtonCell];
-
- if ((states & DefaultState) && [window isKeyWindow]) {
- [window setDefaultButtonCell:buttonCell];
- wkAdvanceDefaultButtonPulseAnimation(buttonCell);
- } else if ([previousDefaultButtonCell isEqual:buttonCell])
- [window setDefaultButtonCell:nil];
-
- [buttonCell drawWithFrame:NSRect(inflatedRect) inView:view];
- [buttonCell setControlView:nil];
-
- if (![previousDefaultButtonCell isEqual:buttonCell])
- [window setDefaultButtonCell:previousDefaultButtonCell];
-}
-
-// Theme overrides
-
-int ThemeMac::baselinePositionAdjustment(ControlPart part) const
-{
- if (part == CheckboxPart || part == RadioPart)
- return -2;
- return Theme::baselinePositionAdjustment(part);
-}
-
-FontDescription ThemeMac::controlFont(ControlPart part, const Font& font, float zoomFactor) const
-{
- switch (part) {
- case PushButtonPart: {
- FontDescription fontDescription;
- fontDescription.setIsAbsoluteSize(true);
- fontDescription.setGenericFamily(FontDescription::SerifFamily);
-
- NSFont* nsFont = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:controlSizeForFont(font)]];
- fontDescription.firstFamily().setFamily([nsFont familyName]);
- fontDescription.setComputedSize([nsFont pointSize] * zoomFactor);
- fontDescription.setSpecifiedSize([nsFont pointSize] * zoomFactor);
- return fontDescription;
- }
- default:
- return Theme::controlFont(part, font, zoomFactor);
- }
-}
-
-LengthSize ThemeMac::controlSize(ControlPart part, const Font& font, const LengthSize& zoomedSize, float zoomFactor) const
-{
- switch (part) {
- case CheckboxPart:
- return checkboxSize(font, zoomedSize, zoomFactor);
- case RadioPart:
- return radioSize(font, zoomedSize, zoomFactor);
- case PushButtonPart:
- // Height is reset to auto so that specified heights can be ignored.
- return sizeFromFont(font, LengthSize(zoomedSize.width(), Length()), zoomFactor, buttonSizes());
- default:
- return zoomedSize;
- }
-}
-
-LengthSize ThemeMac::minimumControlSize(ControlPart part, const Font& font, float zoomFactor) const
-{
- switch (part) {
- case SquareButtonPart:
- case DefaultButtonPart:
- case ButtonPart:
- return LengthSize(Length(0, Fixed), Length(static_cast<int>(15 * zoomFactor), Fixed));
- default:
- return Theme::minimumControlSize(part, font, zoomFactor);
- }
-}
-
-LengthBox ThemeMac::controlBorder(ControlPart part, const Font& font, const LengthBox& zoomedBox, float zoomFactor) const
-{
- switch (part) {
- case SquareButtonPart:
- case DefaultButtonPart:
- case ButtonPart:
- return LengthBox(0, zoomedBox.right().value(), 0, zoomedBox.left().value());
- default:
- return Theme::controlBorder(part, font, zoomedBox, zoomFactor);
- }
-}
-
-LengthBox ThemeMac::controlPadding(ControlPart part, const Font& font, const LengthBox& zoomedBox, float zoomFactor) const
-{
- switch (part) {
- case PushButtonPart: {
- // Just use 8px. AppKit wants to use 11px for mini buttons, but that padding is just too large
- // for real-world Web sites (creating a huge necessary minimum width for buttons whose space is
- // by definition constrained, since we select mini only for small cramped environments.
- // This also guarantees the HTML <button> will match our rendering by default, since we're using a consistent
- // padding.
- const int padding = 8 * zoomFactor;
- return LengthBox(0, padding, 0, padding);
- }
- default:
- return Theme::controlPadding(part, font, zoomedBox, zoomFactor);
- }
-}
-
-void ThemeMac::inflateControlPaintRect(ControlPart part, ControlStates states, IntRect& zoomedRect, float zoomFactor) const
-{
- switch (part) {
- case CheckboxPart: {
- // We inflate the rect as needed to account for padding included in the cell to accommodate the checkbox
- // shadow" and the check. We don't consider this part of the bounds of the control in WebKit.
- NSCell *cell = checkbox(states, zoomedRect, zoomFactor);
- NSControlSize controlSize = [cell controlSize];
- IntSize zoomedSize = checkboxSizes()[controlSize];
- zoomedSize.setHeight(zoomedSize.height() * zoomFactor);
- zoomedSize.setWidth(zoomedSize.width() * zoomFactor);
- zoomedRect = inflateRect(zoomedRect, zoomedSize, checkboxMargins(controlSize), zoomFactor);
- break;
- }
- case RadioPart: {
- // We inflate the rect as needed to account for padding included in the cell to accommodate the radio button
- // shadow". We don't consider this part of the bounds of the control in WebKit.
- NSCell *cell = radio(states, zoomedRect, zoomFactor);
- NSControlSize controlSize = [cell controlSize];
- IntSize zoomedSize = radioSizes()[controlSize];
- zoomedSize.setHeight(zoomedSize.height() * zoomFactor);
- zoomedSize.setWidth(zoomedSize.width() * zoomFactor);
- zoomedRect = inflateRect(zoomedRect, zoomedSize, radioMargins(controlSize), zoomFactor);
- break;
- }
- case PushButtonPart:
- case DefaultButtonPart:
- case ButtonPart: {
- NSButtonCell *cell = button(part, states, zoomedRect, zoomFactor);
- NSControlSize controlSize = [cell controlSize];
-
- // We inflate the rect as needed to account for the Aqua button's shadow.
- if ([cell bezelStyle] == NSRoundedBezelStyle) {
- IntSize zoomedSize = buttonSizes()[controlSize];
- zoomedSize.setHeight(zoomedSize.height() * zoomFactor);
- zoomedSize.setWidth(zoomedRect.width()); // Buttons don't ever constrain width, so the zoomed width can just be honored.
- zoomedRect = inflateRect(zoomedRect, zoomedSize, buttonMargins(controlSize), zoomFactor);
- }
- break;
- }
- default:
- break;
- }
-}
-
-void ThemeMac::paint(ControlPart part, ControlStates states, GraphicsContext* context, const IntRect& zoomedRect, float zoomFactor, ScrollView* scrollView) const
-{
- switch (part) {
- case CheckboxPart:
- paintCheckbox(states, context, zoomedRect, zoomFactor, scrollView);
- break;
- case RadioPart:
- paintRadio(states, context, zoomedRect, zoomFactor, scrollView);
- break;
- case PushButtonPart:
- case DefaultButtonPart:
- case ButtonPart:
- case SquareButtonPart:
- paintButton(part, states, context, zoomedRect, zoomFactor, scrollView);
- break;
- default:
- break;
- }
-}
-
-}
diff --git a/WebCore/platform/mac/ThreadCheck.mm b/WebCore/platform/mac/ThreadCheck.mm
deleted file mode 100644
index 6320c70..0000000
--- a/WebCore/platform/mac/ThreadCheck.mm
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "ThreadCheck.h"
-
-#import "StringHash.h"
-#import <wtf/HashSet.h>
-
-namespace WebCore {
-
-static ThreadViolationBehavior defaultThreadViolationBehavior = RaiseExceptionOnThreadViolation;
-
-static bool didReadThreadViolationBehaviorFromUserDefaults = false;
-static bool threadViolationBehaviorIsDefault;
-static ThreadViolationBehavior threadViolationBehavior;
-
-static void readThreadViolationBehaviorFromUserDefaults()
-{
- NSString *threadCheckLevel = [[NSUserDefaults standardUserDefaults] stringForKey:@"WebCoreThreadCheck"];
- if ([threadCheckLevel isEqualToString:@"None"])
- threadViolationBehavior = NoThreadCheck;
- else if ([threadCheckLevel isEqualToString:@"Exception"])
- threadViolationBehavior = RaiseExceptionOnThreadViolation;
- else if ([threadCheckLevel isEqualToString:@"Log"])
- threadViolationBehavior = LogOnThreadViolation;
- else if ([threadCheckLevel isEqualToString:@"LogOnce"])
- threadViolationBehavior = LogOnFirstThreadViolation;
- else {
- threadViolationBehavior = defaultThreadViolationBehavior;
- threadViolationBehaviorIsDefault = true;
- }
- didReadThreadViolationBehaviorFromUserDefaults = true;
-}
-
-void setDefaultThreadViolationBehavior(ThreadViolationBehavior behavior)
-{
- defaultThreadViolationBehavior = behavior;
- if (threadViolationBehaviorIsDefault)
- threadViolationBehavior = behavior;
-}
-
-void reportThreadViolation(const char* function)
-{
- if (!didReadThreadViolationBehaviorFromUserDefaults)
- readThreadViolationBehaviorFromUserDefaults();
- if (threadViolationBehavior == NoThreadCheck)
- return;
- if (pthread_main_np())
- return;
- WebCoreReportThreadViolation(function);
-}
-
-} // namespace WebCore
-
-// Split out the actual reporting of the thread violation to make it easier to set a breakpoint
-void WebCoreReportThreadViolation(const char* function)
-{
- using namespace WebCore;
- static HashSet<String> loggedFunctions;
- switch (threadViolationBehavior) {
- case NoThreadCheck:
- break;
- case LogOnFirstThreadViolation:
- if (loggedFunctions.add(function).second) {
- NSLog(@"WebKit Threading Violation - %s called from secondary thread", function);
- NSLog(@"Additional threading violations for this function will not be logged.");
- }
- break;
- case LogOnThreadViolation:
- NSLog(@"WebKit Threading Violation - %s called from secondary thread", function);
- break;
- case RaiseExceptionOnThreadViolation:
- [NSException raise:@"WebKitThreadingException" format:@"%s was called from a secondary thread", function];
- break;
- }
-}
diff --git a/WebCore/platform/mac/WebCoreKeyGenerator.h b/WebCore/platform/mac/WebCoreKeyGenerator.h
deleted file mode 100644
index c9260e1..0000000
--- a/WebCore/platform/mac/WebCoreKeyGenerator.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2003 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-@interface WebCoreKeyGenerator : NSObject
-
-+ (WebCoreKeyGenerator *)sharedGenerator;
-- (NSArray *)strengthMenuItemTitles;
-- (NSString *)signedPublicKeyAndChallengeStringWithStrengthIndex:(unsigned)index challenge:(NSString *)challenge pageURL:(NSURL *)pageURL;
-
-@end
diff --git a/WebCore/platform/mac/WebCoreKeyGenerator.m b/WebCore/platform/mac/WebCoreKeyGenerator.m
deleted file mode 100644
index c1004a7..0000000
--- a/WebCore/platform/mac/WebCoreKeyGenerator.m
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2003 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "WebCoreKeyGenerator.h"
-
-#import <wtf/Assertions.h>
-
-static WebCoreKeyGenerator *sharedGenerator;
-
-@implementation WebCoreKeyGenerator
-
-+ (WebCoreKeyGenerator *)sharedGenerator
-{
- return sharedGenerator;
-}
-
-- init
-{
- ASSERT(!sharedGenerator);
- [super init];
- sharedGenerator = [self retain];
- return self;
-}
-
-- (NSArray *)strengthMenuItemTitles
-{
- return nil;
-}
-
-- (NSString *)signedPublicKeyAndChallengeStringWithStrengthIndex:(unsigned)index challenge:(NSString *)challenge pageURL:(NSURL *)pageURL
-{
- return nil;
-}
-
-@end
diff --git a/WebCore/platform/mac/WebCoreNSStringExtras.h b/WebCore/platform/mac/WebCoreNSStringExtras.h
deleted file mode 100644
index 95d2031..0000000
--- a/WebCore/platform/mac/WebCoreNSStringExtras.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2005, 2007 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <Cocoa/Cocoa.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-BOOL hasCaseInsensitiveSuffix(NSString *string, NSString *suffix);
-BOOL hasCaseInsensitiveSubstring(NSString *string, NSString *substring);
-NSString *filenameByFixingIllegalCharacters(NSString *string);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/WebCore/platform/mac/WebCoreNSStringExtras.mm b/WebCore/platform/mac/WebCoreNSStringExtras.mm
deleted file mode 100644
index a2b0a28..0000000
--- a/WebCore/platform/mac/WebCoreNSStringExtras.mm
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2005, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "WebCoreNSStringExtras.h"
-
-BOOL hasCaseInsensitiveSuffix(NSString *string, NSString *suffix)
-{
- return [string rangeOfString:suffix options:(NSCaseInsensitiveSearch | NSBackwardsSearch | NSAnchoredSearch)].location != NSNotFound;
-}
-
-BOOL hasCaseInsensitiveSubstring(NSString *string, NSString *substring)
-{
- return [string rangeOfString:substring options:NSCaseInsensitiveSearch].location != NSNotFound;
-}
-
-NSString *filenameByFixingIllegalCharacters(NSString *string)
-{
- NSMutableString *filename = [[string mutableCopy] autorelease];
-
- // Strip null characters.
- unichar nullChar = 0;
- [filename replaceOccurrencesOfString:[NSString stringWithCharacters:&nullChar length:0] withString:@"" options:0 range:NSMakeRange(0, [filename length])];
-
- // Replace "/" with "-".
- [filename replaceOccurrencesOfString:@"/" withString:@"-" options:0 range:NSMakeRange(0, [filename length])];
-
- // Replace ":" with "-".
- [filename replaceOccurrencesOfString:@":" withString:@"-" options:0 range:NSMakeRange(0, [filename length])];
-
- // Strip leading dots.
- while ([filename hasPrefix:@"."]) {
- [filename deleteCharactersInRange:NSMakeRange(0,1)];
- }
-
- return filename;
-}
diff --git a/WebCore/platform/mac/WebCoreObjCExtras.h b/WebCore/platform/mac/WebCoreObjCExtras.h
deleted file mode 100644
index 7e699a5..0000000
--- a/WebCore/platform/mac/WebCoreObjCExtras.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <objc/objc.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void WebCoreObjCFinalizeOnMainThread(Class cls);
-
-// The 'Class' that should be passed in here is the class of the
-// object that implements the dealloc method that this function is called from.
-bool WebCoreObjCScheduleDeallocateOnMainThread(Class cls, id object);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/WebCore/platform/mac/WebCoreObjCExtras.mm b/WebCore/platform/mac/WebCoreObjCExtras.mm
deleted file mode 100644
index 105c462..0000000
--- a/WebCore/platform/mac/WebCoreObjCExtras.mm
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "WebCoreObjCExtras.h"
-
-#include <objc/objc-auto.h>
-#include <objc/objc-runtime.h>
-#include <wtf/Assertions.h>
-#include <wtf/MainThread.h>
-#include <wtf/Threading.h>
-
-void WebCoreObjCFinalizeOnMainThread(Class cls)
-{
-#if !defined(BUILDING_ON_TIGER) && !defined(DONT_FINALIZE_ON_MAIN_THREAD)
- objc_finalizeOnMainThread(cls);
-#endif
-
- // The reason we call initializeThreading here is that we'd like to have
- // threading initialized early, otherwise WebCoreObjCScheduleDeallocateOnMainThread
- // will crash
- WTF::initializeThreading();
-}
-
-#ifdef BUILDING_ON_TIGER
-static inline IMP method_getImplementation(Method method)
-{
- return method->method_imp;
-}
-#endif
-
-typedef std::pair<Class, id> ClassAndIdPair;
-
-static void deallocCallback(void* context)
-{
- ClassAndIdPair* pair = static_cast<ClassAndIdPair*>(context);
-
- Method method = class_getInstanceMethod(pair->first, @selector(dealloc));
-
- IMP imp = method_getImplementation(method);
- imp(pair->second, @selector(dealloc));
-
- delete pair;
-}
-
-bool WebCoreObjCScheduleDeallocateOnMainThread(Class cls, id object)
-{
- ASSERT([object isKindOfClass:cls]);
-
- if (pthread_main_np() != 0)
- return false;
-
- ClassAndIdPair* pair = new ClassAndIdPair(cls, object);
- callOnMainThread(deallocCallback, pair);
- return true;
-}
-
diff --git a/WebCore/platform/mac/WebCoreSystemInterface.h b/WebCore/platform/mac/WebCoreSystemInterface.h
deleted file mode 100644
index 6085483..0000000
--- a/WebCore/platform/mac/WebCoreSystemInterface.h
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef WebCoreSystemInterface_h
-#define WebCoreSystemInterface_h
-
-#include <ApplicationServices/ApplicationServices.h>
-#include <objc/objc.h>
-
-typedef struct _NSRange NSRange;
-
-#ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
-typedef struct CGPoint NSPoint;
-typedef struct CGRect NSRect;
-#else
-typedef struct _NSPoint NSPoint;
-typedef struct _NSRect NSRect;
-#endif
-
-#ifdef __OBJC__
-@class NSButtonCell;
-@class NSData;
-@class NSEvent;
-@class NSFont;
-@class NSMutableURLRequest;
-@class NSURLRequest;
-@class QTMovie;
-@class QTMovieView;
-#else
-typedef struct NSArray NSArray;
-typedef struct NSButtonCell NSButtonCell;
-typedef struct NSData NSData;
-typedef struct NSDate NSDate;
-typedef struct NSEvent NSEvent;
-typedef struct NSFont NSFont;
-typedef struct NSImage NSImage;
-typedef struct NSMenu NSMenu;
-typedef struct NSMutableURLRequest NSMutableURLRequest;
-typedef struct NSURLRequest NSURLRequest;
-typedef struct NSString NSString;
-typedef struct NSTextFieldCell NSTextFieldCell;
-typedef struct NSURLConnection NSURLConnection;
-typedef struct NSURLResponse NSURLResponse;
-typedef struct NSView NSView;
-typedef struct objc_object *id;
-typedef struct QTMovie QTMovie;
-typedef struct QTMovieView QTMovieView;
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// In alphabetical order.
-
-extern void (*wkAdvanceDefaultButtonPulseAnimation)(NSButtonCell *);
-extern BOOL (*wkCGContextGetShouldSmoothFonts)(CGContextRef);
-extern CFReadStreamRef (*wkCreateCustomCFReadStream)(void *(*formCreate)(CFReadStreamRef, void *),
- void (*formFinalize)(CFReadStreamRef, void *),
- Boolean (*formOpen)(CFReadStreamRef, CFStreamError *, Boolean *, void *),
- CFIndex (*formRead)(CFReadStreamRef, UInt8 *, CFIndex, CFStreamError *, Boolean *, void *),
- Boolean (*formCanRead)(CFReadStreamRef, void *),
- void (*formClose)(CFReadStreamRef, void *),
- void (*formSchedule)(CFReadStreamRef, CFRunLoopRef, CFStringRef, void *),
- void (*formUnschedule)(CFReadStreamRef, CFRunLoopRef, CFStringRef, void *),
- void *context);
-extern id (*wkCreateNSURLConnectionDelegateProxy)(void);
-extern void (*wkDrawBezeledTextFieldCell)(NSRect, BOOL enabled);
-extern void (*wkDrawTextFieldCellFocusRing)(NSTextFieldCell*, NSRect);
-extern void (*wkDrawCapsLockIndicator)(CGContextRef, CGRect);
-extern void (*wkDrawBezeledTextArea)(NSRect, BOOL enabled);
-extern void (*wkDrawFocusRing)(CGContextRef, CGColorRef, int radius);
-extern NSFont* (*wkGetFontInLanguageForRange)(NSFont*, NSString*, NSRange);
-extern NSFont* (*wkGetFontInLanguageForCharacter)(NSFont*, UniChar);
-extern BOOL (*wkGetGlyphTransformedAdvances)(CGFontRef, NSFont*, CGAffineTransform*, ATSGlyphRef*, CGSize* advance);
-extern void (*wkDrawMediaFullscreenButton)(CGContextRef context, CGRect rect, BOOL active);
-extern void (*wkDrawMediaMuteButton)(CGContextRef context, CGRect rect, BOOL active);
-extern void (*wkDrawMediaPauseButton)(CGContextRef context, CGRect rect, BOOL active);
-extern void (*wkDrawMediaPlayButton)(CGContextRef context, CGRect rect, BOOL active);
-extern void (*wkDrawMediaSeekBackButton)(CGContextRef context, CGRect rect, BOOL active);
-extern void (*wkDrawMediaSeekForwardButton)(CGContextRef context, CGRect rect, BOOL active);
-extern void (*wkDrawMediaSliderTrack)(CGContextRef context, CGRect rect, float percentLoaded);
-extern void (*wkDrawMediaSliderThumb)(CGContextRef context, CGRect rect, BOOL active);
-extern void (*wkDrawMediaUnMuteButton)(CGContextRef context, CGRect rect, BOOL active);
-extern NSString* (*wkGetPreferredExtensionForMIMEType)(NSString*);
-extern NSArray* (*wkGetExtensionsForMIMEType)(NSString*);
-extern NSString* (*wkGetMIMETypeForExtension)(NSString*);
-extern ATSUFontID (*wkGetNSFontATSUFontId)(NSFont*);
-extern double (*wkGetNSURLResponseCalculatedExpiration)(NSURLResponse *response);
-extern NSDate *(*wkGetNSURLResponseLastModifiedDate)(NSURLResponse *response);
-extern BOOL (*wkGetNSURLResponseMustRevalidate)(NSURLResponse *response);
-extern void (*wkGetWheelEventDeltas)(NSEvent*, float* deltaX, float* deltaY, BOOL* continuous);
-extern void (*wkPopupMenu)(NSMenu*, NSPoint location, float width, NSView*, int selectedItem, NSFont*);
-extern int (*wkQTMovieDataRate)(QTMovie*);
-extern float (*wkQTMovieMaxTimeLoaded)(QTMovie*);
-extern void (*wkQTMovieViewSetDrawSynchronously)(QTMovieView*, BOOL);
-extern void (*wkSetCGFontRenderingMode)(CGContextRef, NSFont*);
-extern void (*wkSetDragImage)(NSImage*, NSPoint offset);
-extern void (*wkSetNSURLConnectionDefersCallbacks)(NSURLConnection *, BOOL);
-extern void (*wkSetNSURLRequestShouldContentSniff)(NSMutableURLRequest *, BOOL);
-extern void (*wkSetPatternBaseCTM)(CGContextRef, CGAffineTransform);
-extern void (*wkSetPatternPhaseInUserSpace)(CGContextRef, CGPoint);
-extern void (*wkSetUpFontCache)();
-extern void (*wkSignalCFReadStreamEnd)(CFReadStreamRef stream);
-extern void (*wkSignalCFReadStreamError)(CFReadStreamRef stream, CFStreamError *error);
-extern void (*wkSignalCFReadStreamHasBytes)(CFReadStreamRef stream);
-
-#ifndef BUILDING_ON_TIGER
-extern void (*wkGetGlyphsForCharacters)(CGFontRef, const UniChar[], CGGlyph[], size_t);
-#else
-#define GLYPH_VECTOR_SIZE (50 * 32)
-
-extern void (*wkClearGlyphVector)(void* glyphs);
-extern OSStatus (*wkConvertCharToGlyphs)(void* styleGroup, const UniChar*, unsigned numCharacters, void* glyphs);
-extern CFStringRef (*wkCopyFullFontName)(CGFontRef font);
-extern OSStatus (*wkGetATSStyleGroup)(ATSUStyle, void** styleGroup);
-extern CGFontRef (*wkGetCGFontFromNSFont)(NSFont*);
-extern void (*wkGetFontMetrics)(CGFontRef, int* ascent, int* descent, int* lineGap, unsigned* unitsPerEm);
-extern ATSLayoutRecord* (*wkGetGlyphVectorFirstRecord)(void* glyphVector);
-extern void* wkGetGlyphsForCharacters;
-extern int (*wkGetGlyphVectorNumGlyphs)(void* glyphVector);
-extern size_t (*wkGetGlyphVectorRecordSize)(void* glyphVector);
-extern OSStatus (*wkInitializeGlyphVector)(int count, void* glyphs);
-extern void (*wkReleaseStyleGroup)(void* group);
-extern BOOL (*wkSupportsMultipartXMixedReplace)(NSMutableURLRequest *);
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/WebCore/platform/mac/WebCoreSystemInterface.mm b/WebCore/platform/mac/WebCoreSystemInterface.mm
deleted file mode 100644
index c0305ae..0000000
--- a/WebCore/platform/mac/WebCoreSystemInterface.mm
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright 2006, 2007, 2008 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "WebCoreSystemInterface.h"
-
-void (*wkAdvanceDefaultButtonPulseAnimation)(NSButtonCell *);
-BOOL (*wkCGContextGetShouldSmoothFonts)(CGContextRef);
-NSString* (*wkCreateURLPasteboardFlavorTypeName)(void);
-NSString* (*wkCreateURLNPasteboardFlavorTypeName)(void);
-void (*wkDrawBezeledTextFieldCell)(NSRect, BOOL enabled);
-void (*wkDrawTextFieldCellFocusRing)(NSTextFieldCell*, NSRect);
-void (*wkDrawCapsLockIndicator)(CGContextRef, CGRect);
-void (*wkDrawBezeledTextArea)(NSRect, BOOL enabled);
-void (*wkDrawFocusRing)(CGContextRef, CGColorRef, int radius);
-NSFont* (*wkGetFontInLanguageForRange)(NSFont*, NSString*, NSRange);
-NSFont* (*wkGetFontInLanguageForCharacter)(NSFont*, UniChar);
-BOOL (*wkGetGlyphTransformedAdvances)(CGFontRef, NSFont*, CGAffineTransform*, ATSGlyphRef*, CGSize* advance);
-void (*wkDrawMediaFullscreenButton)(CGContextRef context, CGRect rect, BOOL active);
-void (*wkDrawMediaMuteButton)(CGContextRef context, CGRect rect, BOOL active);
-void (*wkDrawMediaPauseButton)(CGContextRef context, CGRect rect, BOOL active);
-void (*wkDrawMediaPlayButton)(CGContextRef context, CGRect rect, BOOL active);
-void (*wkDrawMediaSeekBackButton)(CGContextRef context, CGRect rect, BOOL active);
-void (*wkDrawMediaSeekForwardButton)(CGContextRef context, CGRect rect, BOOL active);
-void (*wkDrawMediaSliderTrack)(CGContextRef context, CGRect rect, float percentLoaded);
-void (*wkDrawMediaSliderThumb)(CGContextRef context, CGRect rect, BOOL active);
-void (*wkDrawMediaUnMuteButton)(CGContextRef context, CGRect rect, BOOL active);
-NSString* (*wkGetPreferredExtensionForMIMEType)(NSString*);
-NSArray* (*wkGetExtensionsForMIMEType)(NSString*);
-NSString* (*wkGetMIMETypeForExtension)(NSString*);
-NSTimeInterval (*wkGetNSURLResponseCalculatedExpiration)(NSURLResponse *response);
-NSDate *(*wkGetNSURLResponseLastModifiedDate)(NSURLResponse *response);
-BOOL (*wkGetNSURLResponseMustRevalidate)(NSURLResponse *response);
-void (*wkGetWheelEventDeltas)(NSEvent*, float* deltaX, float* deltaY, BOOL* continuous);
-void (*wkPopupMenu)(NSMenu*, NSPoint location, float width, NSView*, int selectedItem, NSFont*);
-int (*wkQTMovieDataRate)(QTMovie*);
-float (*wkQTMovieMaxTimeLoaded)(QTMovie*);
-void (*wkQTMovieViewSetDrawSynchronously)(QTMovieView*, BOOL);
-void (*wkSetCGFontRenderingMode)(CGContextRef, NSFont*);
-void (*wkSetDragImage)(NSImage*, NSPoint offset);
-void (*wkSetPatternBaseCTM)(CGContextRef, CGAffineTransform);
-void (*wkSetPatternPhaseInUserSpace)(CGContextRef, CGPoint point);
-void (*wkSetUpFontCache)();
-void (*wkSignalCFReadStreamEnd)(CFReadStreamRef stream);
-void (*wkSignalCFReadStreamHasBytes)(CFReadStreamRef stream);
-void (*wkSignalCFReadStreamError)(CFReadStreamRef stream, CFStreamError *error);
-CFReadStreamRef (*wkCreateCustomCFReadStream)(void *(*formCreate)(CFReadStreamRef, void *),
- void (*formFinalize)(CFReadStreamRef, void *),
- Boolean (*formOpen)(CFReadStreamRef, CFStreamError *, Boolean *, void *),
- CFIndex (*formRead)(CFReadStreamRef, UInt8 *, CFIndex, CFStreamError *, Boolean *, void *),
- Boolean (*formCanRead)(CFReadStreamRef, void *),
- void (*formClose)(CFReadStreamRef, void *),
- void (*formSchedule)(CFReadStreamRef, CFRunLoopRef, CFStringRef, void *),
- void (*formUnschedule)(CFReadStreamRef, CFRunLoopRef, CFStringRef, void *),
- void *context);
-void (*wkSetNSURLConnectionDefersCallbacks)(NSURLConnection *, BOOL);
-void (*wkSetNSURLRequestShouldContentSniff)(NSMutableURLRequest *, BOOL);
-id (*wkCreateNSURLConnectionDelegateProxy)(void);
-
-#ifndef BUILDING_ON_TIGER
-void (*wkGetGlyphsForCharacters)(CGFontRef, const UniChar[], CGGlyph[], size_t);
-#else
-void (*wkClearGlyphVector)(void* glyphs);
-OSStatus (*wkConvertCharToGlyphs)(void* styleGroup, const UniChar*, unsigned numCharacters, void* glyphs);
-CFStringRef (*wkCopyFullFontName)(CGFontRef font);
-OSStatus (*wkGetATSStyleGroup)(ATSUStyle, void** styleGroup);
-CGFontRef (*wkGetCGFontFromNSFont)(NSFont*);
-void (*wkGetFontMetrics)(CGFontRef, int* ascent, int* descent, int* lineGap, unsigned* unitsPerEm);
-ATSLayoutRecord* (*wkGetGlyphVectorFirstRecord)(void* glyphVector);
-void* wkGetGlyphsForCharacters;
-int (*wkGetGlyphVectorNumGlyphs)(void* glyphVector);
-size_t (*wkGetGlyphVectorRecordSize)(void* glyphVector);
-OSStatus (*wkInitializeGlyphVector)(int count, void* glyphs);
-void (*wkReleaseStyleGroup)(void* group);
-ATSUFontID (*wkGetNSFontATSUFontId)(NSFont*);
-BOOL (*wkSupportsMultipartXMixedReplace)(NSMutableURLRequest *);
-#endif
diff --git a/WebCore/platform/mac/WebCoreTextRenderer.h b/WebCore/platform/mac/WebCoreTextRenderer.h
deleted file mode 100644
index 3e77434..0000000
--- a/WebCore/platform/mac/WebCoreTextRenderer.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern void WebCoreDrawTextAtPoint(const UniChar*, unsigned length, NSPoint, NSFont*, NSColor*);
-extern float WebCoreTextFloatWidth(const UniChar*, unsigned length, NSFont*);
-extern void WebCoreSetShouldUseFontSmoothing(bool);
-extern bool WebCoreShouldUseFontSmoothing();
-extern void WebCoreSetAlwaysUsesComplexTextCodePath(bool);
-extern bool WebCoreAlwaysUsesComplexTextCodePath();
-extern NSFont* WebCoreFindFont(NSString* familyName, NSFontTraitMask, int weight, int size);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/WebCore/platform/mac/WebCoreTextRenderer.mm b/WebCore/platform/mac/WebCoreTextRenderer.mm
deleted file mode 100644
index 0cd5967..0000000
--- a/WebCore/platform/mac/WebCoreTextRenderer.mm
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "WebCoreTextRenderer.h"
-
-#import "Font.h"
-#import "SimpleFontData.h"
-#import "GraphicsContext.h"
-#import "IntPoint.h"
-#import "WebFontCache.h"
-
-using namespace WebCore;
-
-void WebCoreDrawTextAtPoint(const UniChar* buffer, unsigned length, NSPoint point, NSFont* font, NSColor* textColor)
-{
- NSGraphicsContext *nsContext = [NSGraphicsContext currentContext];
- CGContextRef cgContext = (CGContextRef)[nsContext graphicsPort];
- GraphicsContext graphicsContext(cgContext);
- // Safari doesn't flip the NSGraphicsContext before calling WebKit, yet WebCore requires a flipped graphics context.
- BOOL flipped = [nsContext isFlipped];
- if (!flipped)
- CGContextScaleCTM(cgContext, 1.0f, -1.0f);
-
- FontPlatformData f(font);
- Font renderer(f, ![[NSGraphicsContext currentContext] isDrawingToScreen]);
- TextRun run(buffer, length);
- run.disableRoundingHacks();
- CGFloat red, green, blue, alpha;
- [[textColor colorUsingColorSpaceName:NSDeviceRGBColorSpace] getRed:&red green:&green blue:&blue alpha:&alpha];
- graphicsContext.setFillColor(makeRGBA((int)(red * 255), (int)(green * 255), (int)(blue * 255), (int)(alpha * 255)));
- renderer.drawText(&graphicsContext, run, FloatPoint(point.x, (flipped ? point.y : (-1.0f * point.y))));
- if (!flipped)
- CGContextScaleCTM(cgContext, 1.0f, -1.0f);
-}
-
-float WebCoreTextFloatWidth(const UniChar* buffer, unsigned length , NSFont* font)
-{
- FontPlatformData f(font);
- Font renderer(f, ![[NSGraphicsContext currentContext] isDrawingToScreen]);
- TextRun run(buffer, length);
- run.disableRoundingHacks();
- return renderer.floatWidth(run);
-}
-
-static bool gShouldUseFontSmoothing = true;
-
-void WebCoreSetShouldUseFontSmoothing(bool smooth)
-{
- gShouldUseFontSmoothing = smooth;
-}
-
-bool WebCoreShouldUseFontSmoothing()
-{
- return gShouldUseFontSmoothing;
-}
-
-void WebCoreSetAlwaysUsesComplexTextCodePath(bool complex)
-{
- Font::setCodePath(complex ? Font::Complex : Font::Auto);
-}
-
-bool WebCoreAlwaysUsesComplexTextCodePath()
-{
- return Font::codePath() == Font::Complex;
-}
-
-NSFont* WebCoreFindFont(NSString* familyName, NSFontTraitMask traits, int weight, int size)
-{
- return [WebFontCache fontWithFamily:familyName traits:traits weight:weight size:size];
-}
diff --git a/WebCore/platform/mac/WebCoreView.h b/WebCore/platform/mac/WebCoreView.h
deleted file mode 100644
index 15d5b13..0000000
--- a/WebCore/platform/mac/WebCoreView.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2003 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-@interface NSView (WebCoreView)
-- (NSView *)_webcore_effectiveFirstResponder;
-@end
diff --git a/WebCore/platform/mac/WebCoreView.m b/WebCore/platform/mac/WebCoreView.m
deleted file mode 100644
index e2f11fa..0000000
--- a/WebCore/platform/mac/WebCoreView.m
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2003 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "WebCoreView.h"
-
-@interface NSClipView (WebCoreView)
-- (NSView *)_webcore_effectiveFirstResponder;
-@end
-
-@interface NSScrollView (WebCoreView)
-- (NSView *)_webcore_effectiveFirstResponder;
-@end
-
-@implementation NSView (WebCoreView)
-
-- (NSView *)_webcore_effectiveFirstResponder
-{
- return self;
-}
-
-@end
-
-@implementation NSClipView (WebCoreView)
-
-- (NSView *)_webcore_effectiveFirstResponder
-{
- NSView *view = [self documentView];
- return view ? [view _webcore_effectiveFirstResponder] : [super _webcore_effectiveFirstResponder];
-}
-
-@end
-
-@implementation NSScrollView (WebCoreView)
-
-- (NSView *)_webcore_effectiveFirstResponder
-{
- NSView *view = [self contentView];
- return view ? [view _webcore_effectiveFirstResponder] : [super _webcore_effectiveFirstResponder];
-}
-
-@end
-
diff --git a/WebCore/platform/mac/WebFontCache.h b/WebCore/platform/mac/WebFontCache.h
deleted file mode 100644
index b31a684..0000000
--- a/WebCore/platform/mac/WebFontCache.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <wtf/Vector.h>
-
-// This interface exists so that third party products (like Silk) can patch in to an Obj-C method to manipulate WebKit's font caching/substitution.
-@interface WebFontCache : NSObject
-+ (NSFont *)fontWithFamily:(NSString *)desiredFamily traits:(NSFontTraitMask)desiredTraits weight:(int)desiredWeight size:(float)size;
-+ (void)getTraits:(Vector<unsigned>&)traitsMasks inFamily:(NSString *)desiredFamily;
-
-@end
diff --git a/WebCore/platform/mac/WebFontCache.mm b/WebCore/platform/mac/WebFontCache.mm
deleted file mode 100644
index 84f60b5..0000000
--- a/WebCore/platform/mac/WebFontCache.mm
+++ /dev/null
@@ -1,301 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "FontTraitsMask.h"
-#import "WebFontCache.h"
-
-#import <math.h>
-
-using namespace WebCore;
-
-#ifdef BUILDING_ON_TIGER
-typedef int NSInteger;
-#endif
-
-#define SYNTHESIZED_FONT_TRAITS (NSBoldFontMask | NSItalicFontMask)
-
-#define IMPORTANT_FONT_TRAITS (0 \
- | NSCompressedFontMask \
- | NSCondensedFontMask \
- | NSExpandedFontMask \
- | NSItalicFontMask \
- | NSNarrowFontMask \
- | NSPosterFontMask \
- | NSSmallCapsFontMask \
-)
-
-static BOOL acceptableChoice(NSFontTraitMask desiredTraits, int desiredWeight, NSFontTraitMask candidateTraits, int candidateWeight)
-{
- desiredTraits &= ~SYNTHESIZED_FONT_TRAITS;
- return (candidateTraits & desiredTraits) == desiredTraits;
-}
-
-static BOOL betterChoice(NSFontTraitMask desiredTraits, int desiredWeight,
- NSFontTraitMask chosenTraits, int chosenWeight,
- NSFontTraitMask candidateTraits, int candidateWeight)
-{
- if (!acceptableChoice(desiredTraits, desiredWeight, candidateTraits, candidateWeight))
- return NO;
-
- // A list of the traits we care about.
- // The top item in the list is the worst trait to mismatch; if a font has this
- // and we didn't ask for it, we'd prefer any other font in the family.
- const NSFontTraitMask masks[] = {
- NSPosterFontMask,
- NSSmallCapsFontMask,
- NSItalicFontMask,
- NSCompressedFontMask,
- NSCondensedFontMask,
- NSExpandedFontMask,
- NSNarrowFontMask,
- 0
- };
-
- int i = 0;
- NSFontTraitMask mask;
- while ((mask = masks[i++])) {
- BOOL desired = (desiredTraits & mask) != 0;
- BOOL chosenHasUnwantedTrait = desired != ((chosenTraits & mask) != 0);
- BOOL candidateHasUnwantedTrait = desired != ((candidateTraits & mask) != 0);
- if (!candidateHasUnwantedTrait && chosenHasUnwantedTrait)
- return YES;
- if (!chosenHasUnwantedTrait && candidateHasUnwantedTrait)
- return NO;
- }
-
- int chosenWeightDeltaMagnitude = abs(chosenWeight - desiredWeight);
- int candidateWeightDeltaMagnitude = abs(candidateWeight - desiredWeight);
-
- // If both are the same distance from the desired weight, prefer the candidate if it is further from medium.
- if (chosenWeightDeltaMagnitude == candidateWeightDeltaMagnitude)
- return abs(candidateWeight - 6) > abs(chosenWeight - 6);
-
- // Otherwise, prefer the one closer to the desired weight.
- return candidateWeightDeltaMagnitude < chosenWeightDeltaMagnitude;
-}
-
-// Workaround for <rdar://problem/5781372>.
-static inline void fixUpWeight(NSInteger& weight, NSString *fontName)
-{
- if (weight == 3 && [fontName rangeOfString:@"ultralight" options:NSCaseInsensitiveSearch | NSBackwardsSearch | NSLiteralSearch].location != NSNotFound)
- weight = 2;
-}
-
-static inline FontTraitsMask toTraitsMask(NSFontTraitMask appKitTraits, NSInteger appKitWeight)
-{
- return static_cast<FontTraitsMask>(((appKitTraits & NSFontItalicTrait) ? FontStyleItalicMask : FontStyleNormalMask)
- | FontVariantNormalMask
- | (appKitWeight == 1 ? FontWeight100Mask :
- appKitWeight == 2 ? FontWeight200Mask :
- appKitWeight <= 4 ? FontWeight300Mask :
- appKitWeight == 5 ? FontWeight400Mask :
- appKitWeight == 6 ? FontWeight500Mask :
- appKitWeight <= 8 ? FontWeight600Mask :
- appKitWeight == 9 ? FontWeight700Mask :
- appKitWeight <= 11 ? FontWeight800Mask :
- FontWeight900Mask));
-}
-
-@implementation WebFontCache
-
-+ (void)getTraits:(Vector<unsigned>&)traitsMasks inFamily:(NSString *)desiredFamily
-{
- NSFontManager *fontManager = [NSFontManager sharedFontManager];
-
- NSEnumerator *e = [[fontManager availableFontFamilies] objectEnumerator];
- NSString *availableFamily;
- while ((availableFamily = [e nextObject])) {
- if ([desiredFamily caseInsensitiveCompare:availableFamily] == NSOrderedSame)
- break;
- }
-
- if (!availableFamily) {
- // Match by PostScript name.
- NSEnumerator *availableFonts = [[fontManager availableFonts] objectEnumerator];
- NSString *availableFont;
- while ((availableFont = [availableFonts nextObject])) {
- if ([desiredFamily caseInsensitiveCompare:availableFont] == NSOrderedSame) {
- NSFont *font = [NSFont fontWithName:availableFont size:10];
- NSInteger weight = [fontManager weightOfFont:font];
- fixUpWeight(weight, desiredFamily);
- traitsMasks.append(toTraitsMask([fontManager traitsOfFont:font], weight));
- break;
- }
- }
- return;
- }
-
- NSArray *fonts = [fontManager availableMembersOfFontFamily:availableFamily];
- unsigned n = [fonts count];
- unsigned i;
- for (i = 0; i < n; i++) {
- NSArray *fontInfo = [fonts objectAtIndex:i];
- // Array indices must be hard coded because of lame AppKit API.
- NSString *fontFullName = [fontInfo objectAtIndex:0];
- NSInteger fontWeight = [[fontInfo objectAtIndex:2] intValue];
- fixUpWeight(fontWeight, fontFullName);
-
- NSFontTraitMask fontTraits = [[fontInfo objectAtIndex:3] unsignedIntValue];
- traitsMasks.append(toTraitsMask(fontTraits, fontWeight));
- }
-}
-
-// Family name is somewhat of a misnomer here. We first attempt to find an exact match
-// comparing the desiredFamily to the PostScript name of the installed fonts. If that fails
-// we then do a search based on the family names of the installed fonts.
-+ (NSFont *)internalFontWithFamily:(NSString *)desiredFamily traits:(NSFontTraitMask)desiredTraits weight:(int)desiredWeight size:(float)size
-{
- NSFontManager *fontManager = [NSFontManager sharedFontManager];
-
- // Do a simple case insensitive search for a matching font family.
- // NSFontManager requires exact name matches.
- // This addresses the problem of matching arial to Arial, etc., but perhaps not all the issues.
- NSEnumerator *e = [[fontManager availableFontFamilies] objectEnumerator];
- NSString *availableFamily;
- while ((availableFamily = [e nextObject])) {
- if ([desiredFamily caseInsensitiveCompare:availableFamily] == NSOrderedSame)
- break;
- }
-
- if (!availableFamily) {
- // Match by PostScript name.
- NSEnumerator *availableFonts = [[fontManager availableFonts] objectEnumerator];
- NSString *availableFont;
- NSFont *nameMatchedFont = nil;
- NSFontTraitMask desiredTraitsForNameMatch = desiredTraits | (desiredWeight >= 7 ? NSBoldFontMask : 0);
- while ((availableFont = [availableFonts nextObject])) {
- if ([desiredFamily caseInsensitiveCompare:availableFont] == NSOrderedSame) {
- nameMatchedFont = [NSFont fontWithName:availableFont size:size];
-
- // Special case Osaka-Mono. According to <rdar://problem/3999467>, we need to
- // treat Osaka-Mono as fixed pitch.
- if ([desiredFamily caseInsensitiveCompare:@"Osaka-Mono"] == NSOrderedSame && desiredTraitsForNameMatch == 0)
- return nameMatchedFont;
-
- NSFontTraitMask traits = [fontManager traitsOfFont:nameMatchedFont];
- if ((traits & desiredTraitsForNameMatch) == desiredTraitsForNameMatch)
- return [fontManager convertFont:nameMatchedFont toHaveTrait:desiredTraitsForNameMatch];
-
- availableFamily = [nameMatchedFont familyName];
- break;
- }
- }
- }
-
- // Found a family, now figure out what weight and traits to use.
- BOOL choseFont = false;
- int chosenWeight = 0;
- NSFontTraitMask chosenTraits = 0;
- NSString *chosenFullName = 0;
-
- NSArray *fonts = [fontManager availableMembersOfFontFamily:availableFamily];
- unsigned n = [fonts count];
- unsigned i;
- for (i = 0; i < n; i++) {
- NSArray *fontInfo = [fonts objectAtIndex:i];
-
- // Array indices must be hard coded because of lame AppKit API.
- NSString *fontFullName = [fontInfo objectAtIndex:0];
- NSInteger fontWeight = [[fontInfo objectAtIndex:2] intValue];
- fixUpWeight(fontWeight, fontFullName);
-
- NSFontTraitMask fontTraits = [[fontInfo objectAtIndex:3] unsignedIntValue];
-
- BOOL newWinner;
- if (!choseFont)
- newWinner = acceptableChoice(desiredTraits, desiredWeight, fontTraits, fontWeight);
- else
- newWinner = betterChoice(desiredTraits, desiredWeight, chosenTraits, chosenWeight, fontTraits, fontWeight);
-
- if (newWinner) {
- choseFont = YES;
- chosenWeight = fontWeight;
- chosenTraits = fontTraits;
- chosenFullName = fontFullName;
-
- if (chosenWeight == desiredWeight && (chosenTraits & IMPORTANT_FONT_TRAITS) == (desiredTraits & IMPORTANT_FONT_TRAITS))
- break;
- }
- }
-
- if (!choseFont)
- return nil;
-
- NSFont *font = [NSFont fontWithName:chosenFullName size:size];
-
- if (!font)
- return nil;
-
- NSFontTraitMask actualTraits = 0;
- if (desiredTraits & NSFontItalicTrait)
- actualTraits = [fontManager traitsOfFont:font];
- int actualWeight = [fontManager weightOfFont:font];
-
- bool syntheticBold = desiredWeight >= 7 && actualWeight < 7;
- bool syntheticOblique = (desiredTraits & NSFontItalicTrait) && !(actualTraits & NSFontItalicTrait);
-
- // There are some malformed fonts that will be correctly returned by -fontWithFamily:traits:weight:size: as a match for a particular trait,
- // though -[NSFontManager traitsOfFont:] incorrectly claims the font does not have the specified trait. This could result in applying
- // synthetic bold on top of an already-bold font, as reported in <http://bugs.webkit.org/show_bug.cgi?id=6146>. To work around this
- // problem, if we got an apparent exact match, but the requested traits aren't present in the matched font, we'll try to get a font from
- // the same family without those traits (to apply the synthetic traits to later).
- NSFontTraitMask nonSyntheticTraits = desiredTraits;
-
- if (syntheticBold)
- nonSyntheticTraits &= ~NSBoldFontMask;
-
- if (syntheticOblique)
- nonSyntheticTraits &= ~NSItalicFontMask;
-
- if (nonSyntheticTraits != desiredTraits) {
- NSFont *fontWithoutSyntheticTraits = [fontManager fontWithFamily:availableFamily traits:nonSyntheticTraits weight:chosenWeight size:size];
- if (fontWithoutSyntheticTraits)
- font = fontWithoutSyntheticTraits;
- }
-
- return font;
-}
-
-+ (NSFont *)fontWithFamily:(NSString *)desiredFamily traits:(NSFontTraitMask)desiredTraits weight:(int)desiredWeight size:(float)size
-{
-#ifndef BUILDING_ON_TIGER
- NSFont *font = [self internalFontWithFamily:desiredFamily traits:desiredTraits weight:desiredWeight size:size];
- if (font)
- return font;
-
- // Auto activate the font before looking for it a second time.
- // Ignore the result because we want to use our own algorithm to actually find the font.
- [NSFont fontWithName:desiredFamily size:size];
-#endif
-
- return [self internalFontWithFamily:desiredFamily traits:desiredTraits weight:desiredWeight size:size];
-}
-
-@end
diff --git a/WebCore/platform/mac/WheelEventMac.mm b/WebCore/platform/mac/WheelEventMac.mm
deleted file mode 100644
index 7b60494..0000000
--- a/WebCore/platform/mac/WheelEventMac.mm
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "PlatformWheelEvent.h"
-
-#import "PlatformMouseEvent.h"
-#import "WebCoreSystemInterface.h"
-
-namespace WebCore {
-
-PlatformWheelEvent::PlatformWheelEvent(NSEvent* event)
- : m_position(pointForEvent(event))
- , m_globalPosition(globalPointForEvent(event))
- , m_isAccepted(false)
- , m_shiftKey([event modifierFlags] & NSShiftKeyMask)
- , m_ctrlKey([event modifierFlags] & NSControlKeyMask)
- , m_altKey([event modifierFlags] & NSAlternateKeyMask)
- , m_metaKey([event modifierFlags] & NSCommandKeyMask)
-{
- BOOL continuous;
- wkGetWheelEventDeltas(event, &m_deltaX, &m_deltaY, &continuous);
- m_granularity = continuous ? ScrollByPixelWheelEvent : ScrollByLineWheelEvent;
- if (m_granularity == ScrollByLineWheelEvent) {
- m_deltaX *= horizontalLineMultiplier();
- m_deltaY *= verticalLineMultiplier();
- }
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/mac/WidgetMac.mm b/WebCore/platform/mac/WidgetMac.mm
deleted file mode 100644
index 3fe8e0d..0000000
--- a/WebCore/platform/mac/WidgetMac.mm
+++ /dev/null
@@ -1,353 +0,0 @@
-/*
- * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "Widget.h"
-
-#import "BlockExceptions.h"
-#import "Cursor.h"
-#import "Document.h"
-#import "Font.h"
-#import "FoundationExtras.h"
-#import "Frame.h"
-#import "GraphicsContext.h"
-#import "Page.h"
-#import "PlatformMouseEvent.h"
-#import "ScrollView.h"
-#import "WebCoreFrameView.h"
-#import "WebCoreView.h"
-
-#import <wtf/RetainPtr.h>
-
-@interface NSWindow (WebWindowDetails)
-- (BOOL)_needsToResetDragMargins;
-- (void)_setNeedsToResetDragMargins:(BOOL)needs;
-@end
-
-@interface NSView (WebSetSelectedMethods)
-- (void)setIsSelected:(BOOL)isSelected;
-- (void)webPlugInSetIsSelected:(BOOL)isSelected;
-@end
-
-namespace WebCore {
-
-class WidgetPrivate {
-public:
- bool mustStayInWindow;
- bool removeFromSuperviewSoon;
-};
-
-static void safeRemoveFromSuperview(NSView *view)
-{
- // If the the view is the first responder, then set the window's first responder to nil so
- // we don't leave the window pointing to a view that's no longer in it.
- NSWindow *window = [view window];
- NSResponder *firstResponder = [window firstResponder];
- if ([firstResponder isKindOfClass:[NSView class]] && [(NSView *)firstResponder isDescendantOf:view])
- [window makeFirstResponder:nil];
-
- // Suppress the resetting of drag margins since we know we can't affect them.
- BOOL resetDragMargins = [window _needsToResetDragMargins];
- [window _setNeedsToResetDragMargins:NO];
- [view removeFromSuperview];
- [window _setNeedsToResetDragMargins:resetDragMargins];
-}
-
-Widget::Widget(NSView* view)
- : m_data(new WidgetPrivate)
-{
- init(view);
- m_data->mustStayInWindow = false;
- m_data->removeFromSuperviewSoon = false;
-}
-
-Widget::~Widget()
-{
- releasePlatformWidget();
- delete m_data;
-}
-
-// FIXME: Should move this to Chrome; bad layering that this knows about Frame.
-void Widget::setFocus()
-{
- Frame* frame = Frame::frameForWidget(this);
- if (!frame)
- return;
-
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
-
- NSView *view = [platformWidget() _webcore_effectiveFirstResponder];
- if (Page* page = frame->page())
- page->chrome()->focusNSView(view);
-
- END_BLOCK_OBJC_EXCEPTIONS;
-}
-
- void Widget::setCursor(const Cursor& cursor)
- {
- if ([NSCursor currentCursor] == cursor.impl())
- return;
- [cursor.impl() set];
-}
-
-void Widget::show()
-{
- if (isSelfVisible())
- return;
-
- setSelfVisible(true);
-
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- [getOuterView() setHidden:NO];
- END_BLOCK_OBJC_EXCEPTIONS;
-}
-
-void Widget::hide()
-{
- if (!isSelfVisible())
- return;
-
- setSelfVisible(false);
-
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- [getOuterView() setHidden:YES];
- END_BLOCK_OBJC_EXCEPTIONS;
-}
-
-IntRect Widget::frameRect() const
-{
- if (!platformWidget())
- return m_frame;
-
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return enclosingIntRect([getOuterView() frame]);
- END_BLOCK_OBJC_EXCEPTIONS;
-
- return m_frame;
-}
-
-void Widget::setFrameRect(const IntRect& rect)
-{
- m_frame = rect;
-
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- NSView *v = getOuterView();
- NSRect f = rect;
- if (!NSEqualRects(f, [v frame])) {
- [v setFrame:f];
- [v setNeedsDisplay: NO];
- }
- END_BLOCK_OBJC_EXCEPTIONS;
-}
-
-NSView* Widget::getOuterView() const
-{
- NSView* view = platformWidget();
-
- // If this widget's view is a WebCoreFrameScrollView then we
- // resize its containing view, a WebFrameView.
- if ([view conformsToProtocol:@protocol(WebCoreFrameScrollView)]) {
- view = [view superview];
- ASSERT(view);
- }
-
- return view;
-}
-
-void Widget::paint(GraphicsContext* p, const IntRect& r)
-{
- if (p->paintingDisabled())
- return;
- NSView *view = getOuterView();
- NSGraphicsContext *currentContext = [NSGraphicsContext currentContext];
- if (currentContext == [[view window] graphicsContext] || ![currentContext isDrawingToScreen]) {
- // This is the common case of drawing into a window or printing.
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- [view displayRectIgnoringOpacity:[view convertRect:r fromView:[view superview]]];
- END_BLOCK_OBJC_EXCEPTIONS;
- } else {
- // This is the case of drawing into a bitmap context other than a window backing store. It gets hit beneath
- // -cacheDisplayInRect:toBitmapImageRep:.
-
- // Transparent subframes are in fact implemented with scroll views that return YES from -drawsBackground (whenever the WebView
- // itself is in drawsBackground mode). In the normal drawing code path, the scroll views are never asked to draw the background,
- // so this is not an issue, but in this code path they are, so the following code temporarily turns background drwaing off.
- NSView *innerView = platformWidget();
- NSScrollView *scrollView = 0;
- if ([innerView conformsToProtocol:@protocol(WebCoreFrameScrollView)]) {
- ASSERT([innerView isKindOfClass:[NSScrollView class]]);
- NSScrollView *scrollView = static_cast<NSScrollView *>(innerView);
- // -copiesOnScroll will return NO whenever the content view is not fully opaque.
- if ([scrollView drawsBackground] && ![[scrollView contentView] copiesOnScroll])
- [scrollView setDrawsBackground:NO];
- else
- scrollView = 0;
- }
-
- CGContextRef cgContext = p->platformContext();
- ASSERT(cgContext == [currentContext graphicsPort]);
- CGContextSaveGState(cgContext);
-
- NSRect viewFrame = [view frame];
- NSRect viewBounds = [view bounds];
- // Set up the translation and (flipped) orientation of the graphics context. In normal drawing, AppKit does it as it descends down
- // the view hierarchy.
- CGContextTranslateCTM(cgContext, viewFrame.origin.x - viewBounds.origin.x, viewFrame.origin.y + viewFrame.size.height + viewBounds.origin.y);
- CGContextScaleCTM(cgContext, 1, -1);
-
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- NSGraphicsContext *nsContext = [NSGraphicsContext graphicsContextWithGraphicsPort:cgContext flipped:YES];
- [view displayRectIgnoringOpacity:[view convertRect:r fromView:[view superview]] inContext:nsContext];
- END_BLOCK_OBJC_EXCEPTIONS;
-
- CGContextRestoreGState(cgContext);
-
- if (scrollView)
- [scrollView setDrawsBackground:YES];
- }
-}
-
-void Widget::setIsSelected(bool isSelected)
-{
- NSView *view = platformWidget();
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- if ([view respondsToSelector:@selector(webPlugInSetIsSelected:)])
- [view webPlugInSetIsSelected:isSelected];
- else if ([view respondsToSelector:@selector(setIsSelected:)])
- [view setIsSelected:isSelected];
- END_BLOCK_OBJC_EXCEPTIONS;
-}
-
-void Widget::removeFromSuperview()
-{
- if (m_data->mustStayInWindow)
- m_data->removeFromSuperviewSoon = true;
- else {
- m_data->removeFromSuperviewSoon = false;
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- safeRemoveFromSuperview(getOuterView());
- END_BLOCK_OBJC_EXCEPTIONS;
- }
-}
-
-void Widget::beforeMouseDown(NSView *view, Widget* widget)
-{
- if (widget) {
- ASSERT(view == widget->getOuterView());
- ASSERT(!widget->m_data->mustStayInWindow);
- widget->m_data->mustStayInWindow = true;
- }
-}
-
-void Widget::afterMouseDown(NSView *view, Widget* widget)
-{
- if (!widget) {
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- safeRemoveFromSuperview(view);
- END_BLOCK_OBJC_EXCEPTIONS;
- } else {
- ASSERT(widget->m_data->mustStayInWindow);
- widget->m_data->mustStayInWindow = false;
- if (widget->m_data->removeFromSuperviewSoon)
- widget->removeFromSuperview();
- }
-}
-
-IntPoint Widget::convertFromContainingWindow(const IntPoint& point) const
-{
- if (!platformWidget() && parent()) {
- IntPoint result = parent()->convertFromContainingWindow(point);
- result.move(parent()->scrollX() - x(), parent()->scrollY() - y());
- return result;
- }
-
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return IntPoint([platformWidget() convertPoint:point fromView:nil]);
- END_BLOCK_OBJC_EXCEPTIONS;
-
- return point;
-}
-
-IntRect Widget::convertFromContainingWindow(const IntRect& rect) const
-{
- if (!platformWidget() && parent()) {
- IntRect result = parent()->convertFromContainingWindow(rect);
- result.move(parent()->scrollX() - x(), parent()->scrollY() - y());
- return result;
- }
-
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return enclosingIntRect([platformWidget() convertRect:rect fromView:nil]);
- END_BLOCK_OBJC_EXCEPTIONS;
-
- return rect;
-}
-
-IntRect Widget::convertToContainingWindow(const IntRect& r) const
-{
- if (!platformWidget()) {
- if (!parent())
- return r;
- IntRect result = r;
- result.move(parent()->scrollX() - x(), parent()->scrollY() - y());
- return parent()->convertToContainingWindow(result);
- }
-
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return IntRect([platformWidget() convertRect:r toView:nil]);
- END_BLOCK_OBJC_EXCEPTIONS;
-
- return r;
-}
-
-IntPoint Widget::convertToContainingWindow(const IntPoint& p) const
-{
- if (!platformWidget()) {
- if (!parent())
- return p;
- IntPoint result = p;
- result.move(parent()->scrollX() - x(), parent()->scrollY() - y());
- return parent()->convertToContainingWindow(result);
- }
-
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- return IntPoint([platformWidget() convertPoint:p toView:nil]);
- END_BLOCK_OBJC_EXCEPTIONS;
-
- return p;
-}
-
-void Widget::releasePlatformWidget()
-{
- HardRelease(m_widget);
-}
-
-void Widget::retainPlatformWidget()
-{
- HardRetain(m_widget);
-}
-
-}
-
diff --git a/WebCore/platform/network/AuthenticationChallengeBase.cpp b/WebCore/platform/network/AuthenticationChallengeBase.cpp
deleted file mode 100644
index df80441..0000000
--- a/WebCore/platform/network/AuthenticationChallengeBase.cpp
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "config.h"
-#include "AuthenticationChallenge.h"
-
-#include "ResourceHandle.h"
-
-namespace WebCore {
-
-AuthenticationChallengeBase::AuthenticationChallengeBase()
- : m_isNull(true)
- , m_previousFailureCount(0)
-{
-}
-
-AuthenticationChallengeBase::AuthenticationChallengeBase(const ProtectionSpace& protectionSpace,
- const Credential& proposedCredential,
- unsigned previousFailureCount,
- const ResourceResponse& response,
- const ResourceError& error)
- : m_isNull(false)
- , m_protectionSpace(protectionSpace)
- , m_proposedCredential(proposedCredential)
- , m_previousFailureCount(previousFailureCount)
- , m_failureResponse(response)
- , m_error(error)
-{
-}
-
-unsigned AuthenticationChallengeBase::previousFailureCount() const
-{
- return m_previousFailureCount;
-}
-
-const Credential& AuthenticationChallengeBase::proposedCredential() const
-{
- return m_proposedCredential;
-}
-
-const ProtectionSpace& AuthenticationChallengeBase::protectionSpace() const
-{
- return m_protectionSpace;
-}
-
-const ResourceResponse& AuthenticationChallengeBase::failureResponse() const
-{
- return m_failureResponse;
-}
-
-const ResourceError& AuthenticationChallengeBase::error() const
-{
- return m_error;
-}
-
-bool AuthenticationChallengeBase::isNull() const
-{
- return m_isNull;
-}
-
-void AuthenticationChallengeBase::nullify()
-{
- m_isNull = true;
-}
-
-bool AuthenticationChallengeBase::compare(const AuthenticationChallenge& a, const AuthenticationChallenge& b)
-{
- if (a.isNull() && b.isNull())
- return true;
-
- if (a.isNull() || b.isNull())
- return false;
-
- if (a.protectionSpace() != b.protectionSpace())
- return false;
-
- if (a.proposedCredential() != b.proposedCredential())
- return false;
-
- if (a.previousFailureCount() != b.previousFailureCount())
- return false;
-
- if (a.failureResponse() != b.failureResponse())
- return false;
-
- if (a.error() != b.error())
- return false;
-
- return AuthenticationChallenge::platformCompare(a, b);
-}
-
-}
diff --git a/WebCore/platform/network/AuthenticationChallengeBase.h b/WebCore/platform/network/AuthenticationChallengeBase.h
deleted file mode 100644
index 5810a6d..0000000
--- a/WebCore/platform/network/AuthenticationChallengeBase.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef AuthenticationChallengeBase_h
-#define AuthenticationChallengeBase_h
-
-#include "Credential.h"
-#include "ProtectionSpace.h"
-#include "ResourceResponse.h"
-#include "ResourceError.h"
-
-namespace WebCore {
-
-class AuthenticationChallenge;
-
-class AuthenticationChallengeBase {
-public:
- AuthenticationChallengeBase();
- AuthenticationChallengeBase(const ProtectionSpace& protectionSpace, const Credential& proposedCredential, unsigned previousFailureCount, const ResourceResponse& response, const ResourceError& error);
-
- unsigned previousFailureCount() const;
- const Credential& proposedCredential() const;
- const ProtectionSpace& protectionSpace() const;
- const ResourceResponse& failureResponse() const;
- const ResourceError& error() const;
-
- bool isNull() const;
- void nullify();
-
- static bool compare(const AuthenticationChallenge& a, const AuthenticationChallenge& b);
-
-protected:
- // The AuthenticationChallenge subclass may "shadow" this method to compare platform specific fields
- static bool platformCompare(const AuthenticationChallengeBase& a, const AuthenticationChallengeBase& b) { return true; }
-
- bool m_isNull;
- ProtectionSpace m_protectionSpace;
- Credential m_proposedCredential;
- unsigned m_previousFailureCount;
- ResourceResponse m_failureResponse;
- ResourceError m_error;
-};
-
-inline bool operator==(const AuthenticationChallenge& a, const AuthenticationChallenge& b) { return AuthenticationChallengeBase::compare(a, b); }
-inline bool operator!=(const AuthenticationChallenge& a, const AuthenticationChallenge& b) { return !(a == b); }
-
-}
-
-#endif
diff --git a/WebCore/platform/network/Credential.cpp b/WebCore/platform/network/Credential.cpp
deleted file mode 100644
index 4743959..0000000
--- a/WebCore/platform/network/Credential.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "config.h"
-#include "Credential.h"
-
-namespace WebCore {
-
-// Need to enforce empty, non-null strings due to the pickiness of the String == String operator
-// combined with the semantics of the String(NSString*) constructor
-Credential::Credential()
- : m_user("")
- , m_password("")
-{
-}
-
-// Need to enforce empty, non-null strings due to the pickiness of the String == String operator
-// combined with the semantics of the String(NSString*) constructor
-Credential::Credential(const String& user, const String& password, CredentialPersistence persistence)
- : m_user(user.length() ? user : "")
- , m_password(password.length() ? password : "")
- , m_persistence(persistence)
-{
-}
-
-const String& Credential::user() const
-{
- return m_user;
-}
-
-const String& Credential::password() const
-{
- return m_password;
-}
-
-bool Credential::hasPassword() const
-{
- return !m_password.isEmpty();
-}
-
-CredentialPersistence Credential::persistence() const
-{
- return m_persistence;
-}
-
-bool operator==(const Credential& a, const Credential& b)
-{
- if (a.user() != b.user())
- return false;
- if (a.password() != b.password())
- return false;
- if (a.persistence() != b.persistence())
- return false;
-
- return true;
-}
-
-}
-
diff --git a/WebCore/platform/network/Credential.h b/WebCore/platform/network/Credential.h
deleted file mode 100644
index 4d80490..0000000
--- a/WebCore/platform/network/Credential.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef Credential_h
-#define Credential_h
-
-#include "PlatformString.h"
-
-namespace WebCore {
-
-enum CredentialPersistence {
- CredentialPersistenceNone,
- CredentialPersistenceForSession,
- CredentialPersistencePermanent
-};
-
-class Credential {
-
-public:
- Credential();
- Credential(const String& user, const String& password, CredentialPersistence);
-
- const String& user() const;
- const String& password() const;
- bool hasPassword() const;
- CredentialPersistence persistence() const;
-
-private:
- String m_user;
- String m_password;
- CredentialPersistence m_persistence;
-};
-
-bool operator==(const Credential& a, const Credential& b);
-inline bool operator!=(const Credential& a, const Credential& b) { return !(a == b); }
-
-};
-#endif
diff --git a/WebCore/platform/network/DNS.h b/WebCore/platform/network/DNS.h
deleted file mode 100644
index c232272..0000000
--- a/WebCore/platform/network/DNS.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2008 Collin Jackson <collinj@webkit.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef DNS_h
-#define DNS_h
-
-namespace WebCore {
-
- class String;
-
- void prefetchDNS(const String& hostname);
-}
-
-#endif
diff --git a/WebCore/platform/network/FormData.cpp b/WebCore/platform/network/FormData.cpp
deleted file mode 100644
index 0d31856..0000000
--- a/WebCore/platform/network/FormData.cpp
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-#include "FormData.h"
-
-#include "CString.h"
-#include "ChromeClient.h"
-#include "FileSystem.h"
-#include "TextEncoding.h"
-
-namespace WebCore {
-
-inline FormData::FormData()
- : m_hasGeneratedFiles(false)
- , m_alwaysStream(false)
-{
-}
-
-inline FormData::FormData(const FormData& data)
- : RefCounted<FormData>()
- , m_elements(data.m_elements)
- , m_hasGeneratedFiles(false)
- , m_alwaysStream(false)
-{
- // We shouldn't be copying FormData that hasn't already removed its generated files
- // but just in case, make sure the new FormData is ready to generate its own files.
- if (data.m_hasGeneratedFiles) {
- size_t n = m_elements.size();
- for (size_t i = 0; i < n; ++i) {
- FormDataElement& e = m_elements[i];
- if (e.m_type == FormDataElement::encodedFile)
- e.m_generatedFilename = String();
- }
- }
-}
-
-FormData::~FormData()
-{
- // This cleanup should've happened when the form submission finished.
- // Just in case, let's assert, and do the cleanup anyway in release builds.
- ASSERT(!m_hasGeneratedFiles);
- removeGeneratedFilesIfNeeded();
-}
-
-PassRefPtr<FormData> FormData::create()
-{
- return adoptRef(new FormData);
-}
-
-PassRefPtr<FormData> FormData::create(const void* data, size_t size)
-{
- RefPtr<FormData> result = create();
- result->appendData(data, size);
- return result.release();
-}
-
-PassRefPtr<FormData> FormData::create(const CString& string)
-{
- RefPtr<FormData> result = create();
- result->appendData(string.data(), string.length());
- return result.release();
-}
-
-PassRefPtr<FormData> FormData::create(const Vector<char>& vector)
-{
- RefPtr<FormData> result = create();
- result->appendData(vector.data(), vector.size());
- return result.release();
-}
-
-PassRefPtr<FormData> FormData::copy() const
-{
- return adoptRef(new FormData(*this));
-}
-
-void FormData::appendData(const void* data, size_t size)
-{
- if (m_elements.isEmpty() || m_elements.last().m_type != FormDataElement::data)
- m_elements.append(FormDataElement());
- FormDataElement& e = m_elements.last();
- size_t oldSize = e.m_data.size();
- e.m_data.grow(oldSize + size);
- memcpy(e.m_data.data() + oldSize, data, size);
-}
-
-void FormData::appendFile(const String& filename, bool shouldGenerateFile)
-{
- m_elements.append(FormDataElement(filename, shouldGenerateFile));
-}
-
-void FormData::flatten(Vector<char>& data) const
-{
- // Concatenate all the byte arrays, but omit any files.
- data.clear();
- size_t n = m_elements.size();
- for (size_t i = 0; i < n; ++i) {
- const FormDataElement& e = m_elements[i];
- if (e.m_type == FormDataElement::data) {
- size_t oldSize = data.size();
- size_t delta = e.m_data.size();
- data.grow(oldSize + delta);
- memcpy(data.data() + oldSize, e.m_data.data(), delta);
- }
- }
-}
-
-String FormData::flattenToString() const
-{
- Vector<char> bytes;
- flatten(bytes);
- return Latin1Encoding().decode(bytes.data(), bytes.size());
-}
-
-void FormData::generateFiles(ChromeClient* client)
-{
- ASSERT(!m_hasGeneratedFiles);
-
- if (m_hasGeneratedFiles)
- return;
-
- size_t n = m_elements.size();
- for (size_t i = 0; i < n; ++i) {
- FormDataElement& e = m_elements[i];
- if (e.m_type == FormDataElement::encodedFile && e.m_shouldGenerateFile) {
- e.m_generatedFilename = client->generateReplacementFile(e.m_filename);
- m_hasGeneratedFiles = true;
- }
- }
-}
-
-void FormData::removeGeneratedFilesIfNeeded()
-{
- if (!m_hasGeneratedFiles)
- return;
-
- size_t n = m_elements.size();
- for (size_t i = 0; i < n; ++i) {
- FormDataElement& e = m_elements[i];
- if (e.m_type == FormDataElement::encodedFile && !e.m_generatedFilename.isEmpty()) {
- ASSERT(e.m_shouldGenerateFile);
- String directory = directoryName(e.m_generatedFilename);
- deleteFile(e.m_generatedFilename);
- deleteEmptyDirectory(directory);
- e.m_generatedFilename = String();
- }
- }
- m_hasGeneratedFiles = false;
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/network/FormData.h b/WebCore/platform/network/FormData.h
deleted file mode 100644
index cb91fab..0000000
--- a/WebCore/platform/network/FormData.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef FormData_h
-#define FormData_h
-
-#include "PlatformString.h"
-#include <wtf/RefCounted.h>
-#include <wtf/Vector.h>
-
-namespace WebCore {
-
-class ChromeClient;
-
-class FormDataElement {
-public:
- FormDataElement() : m_type(data) { }
- FormDataElement(const Vector<char>& array) : m_type(data), m_data(array) { }
- FormDataElement(const String& filename, bool shouldGenerateFile) : m_type(encodedFile), m_filename(filename), m_shouldGenerateFile(shouldGenerateFile) { }
-
- enum { data, encodedFile } m_type;
- Vector<char> m_data;
- String m_filename;
- String m_generatedFilename;
- bool m_shouldGenerateFile;
-};
-
-inline bool operator==(const FormDataElement& a, const FormDataElement& b)
-{
- if (&a == &b)
- return true;
-
- if (a.m_type != b.m_type)
- return false;
- if (a.m_data != b.m_data)
- return false;
- if (a.m_filename != b.m_filename)
- return false;
-
- return true;
-}
-
-inline bool operator!=(const FormDataElement& a, const FormDataElement& b)
-{
- return !(a == b);
-}
-
-class FormData : public RefCounted<FormData> {
-public:
- static PassRefPtr<FormData> create();
- static PassRefPtr<FormData> create(const void*, size_t);
- static PassRefPtr<FormData> create(const CString&);
- static PassRefPtr<FormData> create(const Vector<char>&);
- PassRefPtr<FormData> copy() const;
- ~FormData();
-
- void appendData(const void* data, size_t);
- void appendFile(const String& filename, bool shouldGenerateFile = false);
-
- void flatten(Vector<char>&) const; // omits files
- String flattenToString() const; // omits files
-
- bool isEmpty() const { return m_elements.isEmpty(); }
- const Vector<FormDataElement>& elements() const { return m_elements; }
-
- void generateFiles(ChromeClient*);
- void removeGeneratedFilesIfNeeded();
-
- bool alwaysStream() const { return m_alwaysStream; }
- void setAlwaysStream(bool alwaysStream) { m_alwaysStream = alwaysStream; }
-
-private:
- FormData();
- FormData(const FormData&);
-
- Vector<FormDataElement> m_elements;
- bool m_hasGeneratedFiles;
- bool m_alwaysStream;
-};
-
-inline bool operator==(const FormData& a, const FormData& b)
-{
- return a.elements() == b.elements();
-}
-
-inline bool operator!=(const FormData& a, const FormData& b)
-{
- return a.elements() != b.elements();
-}
-
-} // namespace WebCore
-
-#endif
diff --git a/WebCore/platform/network/HTTPHeaderMap.h b/WebCore/platform/network/HTTPHeaderMap.h
deleted file mode 100644
index dc204cb..0000000
--- a/WebCore/platform/network/HTTPHeaderMap.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef HTTPHeaderMap_h
-#define HTTPHeaderMap_h
-
-#include "StringHash.h"
-#include <wtf/HashMap.h>
-
-namespace WebCore {
-
- typedef HashMap<String, String, CaseFoldingHash> HTTPHeaderMap;
-
-} // namespace WebCore
-
-#endif // HTTPHeaderMap_h
diff --git a/WebCore/platform/network/HTTPParsers.cpp b/WebCore/platform/network/HTTPParsers.cpp
deleted file mode 100644
index 0858fc9..0000000
--- a/WebCore/platform/network/HTTPParsers.cpp
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "HTTPParsers.h"
-
-#include "PlatformString.h"
-
-namespace WebCore {
-
-// true if there is more to parse
-static inline bool skipWhiteSpace(const String& str, int& pos, bool fromHttpEquivMeta)
-{
- int len = str.length();
-
- if (fromHttpEquivMeta)
- while (pos != len && str[pos] <= ' ')
- ++pos;
- else
- while (pos != len && (str[pos] == '\t' || str[pos] == ' '))
- ++pos;
-
- return pos != len;
-}
-
-bool parseHTTPRefresh(const String& refresh, bool fromHttpEquivMeta, double& delay, String& url)
-{
- int len = refresh.length();
- int pos = 0;
-
- if (!skipWhiteSpace(refresh, pos, fromHttpEquivMeta))
- return false;
-
- while (pos != len && refresh[pos] != ',' && refresh[pos] != ';')
- ++pos;
-
- if (pos == len) { // no URL
- url = String();
- bool ok;
- delay = refresh.stripWhiteSpace().toDouble(&ok);
- return ok;
- } else {
- bool ok;
- delay = refresh.left(pos).stripWhiteSpace().toDouble(&ok);
- if (!ok)
- return false;
-
- ++pos;
- skipWhiteSpace(refresh, pos, fromHttpEquivMeta);
- int urlStartPos = pos;
- if (refresh.find("url", urlStartPos, false) == urlStartPos) {
- urlStartPos += 3;
- skipWhiteSpace(refresh, urlStartPos, fromHttpEquivMeta);
- if (refresh[urlStartPos] == '=') {
- ++urlStartPos;
- skipWhiteSpace(refresh, urlStartPos, fromHttpEquivMeta);
- } else
- urlStartPos = pos; // e.g. "Refresh: 0; url.html"
- }
-
- int urlEndPos = len;
-
- if (refresh[urlStartPos] == '"' || refresh[urlStartPos] == '\'') {
- UChar quotationMark = refresh[urlStartPos];
- urlStartPos++;
- while (urlEndPos > urlStartPos) {
- urlEndPos--;
- if (refresh[urlEndPos] == quotationMark)
- break;
- }
- }
-
- url = refresh.substring(urlStartPos, urlEndPos - urlStartPos).stripWhiteSpace();
- return true;
- }
-}
-
-String filenameFromHTTPContentDisposition(const String& value)
-{
- Vector<String> keyValuePairs;
- value.split(';', keyValuePairs);
-
- unsigned length = keyValuePairs.size();
- for (unsigned i = 0; i < length; i++) {
- int valueStartPos = keyValuePairs[i].find('=');
- if (valueStartPos < 0)
- continue;
-
- String key = keyValuePairs[i].left(valueStartPos).stripWhiteSpace();
-
- if (key.isEmpty() || key != "filename")
- continue;
-
- String value = keyValuePairs[i].substring(valueStartPos + 1).stripWhiteSpace();
-
- // Remove quotes if there are any
- if (value[0] == '\"')
- value = value.substring(1, value.length() - 2);
-
- return value;
- }
-
- return String();
-}
-
-String extractMIMETypeFromMediaType(const String& mediaType)
-{
- String mimeType;
- unsigned length = mediaType.length();
- for (unsigned offset = 0; offset < length; offset++) {
- UChar c = mediaType[offset];
- if (c == ';')
- break;
- else if (isSpaceOrNewline(c)) // FIXME: This seems wrong, " " is an invalid MIME type character according to RFC 2045. bug 8644
- continue;
- // FIXME: This is a very slow way to build a string, given WebCore::String's implementation.
- mimeType += String(&c, 1);
- }
- return mimeType;
-}
-
-String extractCharsetFromMediaType(const String& mediaType)
-{
- int pos = 0;
- int length = (int)mediaType.length();
-
- while (pos < length) {
- pos = mediaType.find("charset", pos, false);
- if (pos <= 0)
- return String();
-
- // is what we found a beginning of a word?
- if (mediaType[pos-1] > ' ' && mediaType[pos-1] != ';') {
- pos += 7;
- continue;
- }
-
- pos += 7;
-
- // skip whitespace
- while (pos != length && mediaType[pos] <= ' ')
- ++pos;
-
- if (mediaType[pos++] != '=') // this "charset" substring wasn't a parameter name, but there may be others
- continue;
-
- while (pos != length && (mediaType[pos] <= ' ' || mediaType[pos] == '"' || mediaType[pos] == '\''))
- ++pos;
-
- // we don't handle spaces within quoted parameter values, because charset names cannot have any
- int endpos = pos;
- while (pos != length && mediaType[endpos] > ' ' && mediaType[endpos] != '"' && mediaType[endpos] != '\'' && mediaType[endpos] != ';')
- ++endpos;
-
- return mediaType.substring(pos, endpos-pos);
- }
-
- return String();
-}
-}
diff --git a/WebCore/platform/network/HTTPParsers.h b/WebCore/platform/network/HTTPParsers.h
deleted file mode 100644
index 28a9ce9..0000000
--- a/WebCore/platform/network/HTTPParsers.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef HTTPParsers_h
-#define HTTPParsers_h
-
-namespace WebCore {
-
- class String;
-
- bool parseHTTPRefresh(const String& refresh, bool fromHttpEquivMeta, double& delay, String& url);
- String filenameFromHTTPContentDisposition(const String&);
- String extractMIMETypeFromMediaType(const String&);
- String extractCharsetFromMediaType(const String&);
-}
-
-#endif
diff --git a/WebCore/platform/network/NetworkStateNotifier.cpp b/WebCore/platform/network/NetworkStateNotifier.cpp
deleted file mode 100644
index d39fc30..0000000
--- a/WebCore/platform/network/NetworkStateNotifier.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "NetworkStateNotifier.h"
-
-#include <wtf/Assertions.h>
-
-namespace WebCore {
-
-NetworkStateNotifier& networkStateNotifier()
-{
- static NetworkStateNotifier networkStateNotifier;
-
- return networkStateNotifier;
-}
-
-void NetworkStateNotifier::setNetworkStateChangedFunction(void(*function)())
-{
- ASSERT(!m_networkStateChangedFunction);
-
- m_networkStateChangedFunction = function;
-}
-
-}
diff --git a/WebCore/platform/network/NetworkStateNotifier.h b/WebCore/platform/network/NetworkStateNotifier.h
deleted file mode 100644
index 53ab4c8..0000000
--- a/WebCore/platform/network/NetworkStateNotifier.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef NetworkStateNotifier_h
-#define NetworkStateNotifier_h
-
-#if PLATFORM(MAC)
-
-#include <wtf/RetainPtr.h>
-#include "Timer.h"
-
-typedef const struct __CFArray * CFArrayRef;
-typedef const struct __SCDynamicStore * SCDynamicStoreRef;
-
-#elif PLATFORM(CHROMIUM)
-
-#include "NetworkStateNotifierPrivate.h"
-
-#elif PLATFORM(WIN)
-
-#include <windows.h>
-
-#endif
-
-namespace WebCore {
-
-class NetworkStateNotifier {
-public:
- NetworkStateNotifier();
- void setNetworkStateChangedFunction(void (*)());
-
- bool onLine() const { return m_isOnLine; }
-
-private:
- bool m_isOnLine;
- void (*m_networkStateChangedFunction)();
-
- void updateState();
-
-#if PLATFORM(MAC)
- void networkStateChangeTimerFired(Timer<NetworkStateNotifier>*);
-
- static void dynamicStoreCallback(SCDynamicStoreRef, CFArrayRef changedKeys, void *info);
-
- RetainPtr<SCDynamicStoreRef> m_store;
- Timer<NetworkStateNotifier> m_networkStateChangeTimer;
-
-#elif PLATFORM(WIN)
- static void CALLBACK addrChangeCallback(void*, BOOLEAN timedOut);
- static void callAddressChanged(void*);
- void addressChanged();
-
- void registerForAddressChange();
- HANDLE m_waitHandle;
- OVERLAPPED m_overlapped;
-
-#elif PLATFORM(ANDROID)
-public:
- void networkStateChange(bool online);
-
-#elif PLATFORM(CHROMIUM)
- NetworkStateNotifierPrivate p;
-#endif
-};
-
-#if !PLATFORM(MAC) && !PLATFORM(WIN) && !PLATFORM(CHROMIUM)
-
-inline NetworkStateNotifier::NetworkStateNotifier()
- : m_isOnLine(true)
-{
-}
-
-inline void NetworkStateNotifier::updateState() { }
-
-#endif
-
-NetworkStateNotifier& networkStateNotifier();
-
-};
-
-#endif // NetworkStateNotifier_h
diff --git a/WebCore/platform/network/ProtectionSpace.cpp b/WebCore/platform/network/ProtectionSpace.cpp
deleted file mode 100644
index bd73558..0000000
--- a/WebCore/platform/network/ProtectionSpace.cpp
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "config.h"
-#include "ProtectionSpace.h"
-
-#if USE(CFNETWORK) && !PLATFORM(MAC)
-#include "AuthenticationCF.h"
-#include <CFNetwork/CFURLProtectionSpacePriv.h>
-#include <wtf/RetainPtr.h>
-#endif
-
-namespace WebCore {
-
-// Need to enforce empty, non-null strings due to the pickiness of the String == String operator
-// combined with the semantics of the String(NSString*) constructor
-ProtectionSpace::ProtectionSpace()
- : m_host("")
- , m_realm("")
-{
-}
-
-// Need to enforce empty, non-null strings due to the pickiness of the String == String operator
-// combined with the semantics of the String(NSString*) constructor
-ProtectionSpace::ProtectionSpace(const String& host, int port, ProtectionSpaceServerType serverType, const String& realm, ProtectionSpaceAuthenticationScheme authenticationScheme)
- : m_host(host.length() ? host : "")
- , m_port(port)
- , m_serverType(serverType)
- , m_realm(realm.length() ? realm : "")
- , m_authenticationScheme(authenticationScheme)
-{
-}
-
-const String& ProtectionSpace::host() const
-{
- return m_host;
-}
-
-int ProtectionSpace::port() const
-{
- return m_port;
-}
-
-ProtectionSpaceServerType ProtectionSpace::serverType() const
-{
- return m_serverType;
-}
-
-bool ProtectionSpace::isProxy() const
-{
- return (m_serverType == ProtectionSpaceProxyHTTP ||
- m_serverType == ProtectionSpaceProxyHTTPS ||
- m_serverType == ProtectionSpaceProxyFTP ||
- m_serverType == ProtectionSpaceProxySOCKS);
-}
-
-const String& ProtectionSpace::realm() const
-{
- return m_realm;
-}
-
-ProtectionSpaceAuthenticationScheme ProtectionSpace::authenticationScheme() const
-{
- return m_authenticationScheme;
-}
-
-bool ProtectionSpace::receivesCredentialSecurely() const
-{
-#if USE(CFNETWORK) && !PLATFORM(MAC)
- RetainPtr<CFURLProtectionSpaceRef> cfSpace(AdoptCF, createCF(*this));
- return cfSpace && CFURLProtectionSpaceReceivesCredentialSecurely(cfSpace.get());
-#else
- return (m_serverType == ProtectionSpaceServerHTTPS ||
- m_serverType == ProtectionSpaceServerFTPS ||
- m_serverType == ProtectionSpaceProxyHTTPS ||
- m_authenticationScheme == ProtectionSpaceAuthenticationSchemeHTTPDigest);
-#endif
-}
-
-bool operator==(const ProtectionSpace& a, const ProtectionSpace& b)
-{
- if (a.host() != b.host())
- return false;
- if (a.port() != b.port())
- return false;
- if (a.serverType() != b.serverType())
- return false;
- if (a.realm() != b.realm())
- return false;
- if (a.authenticationScheme() != b.authenticationScheme())
- return false;
-
- return true;
-}
-
-}
-
-
diff --git a/WebCore/platform/network/ProtectionSpace.h b/WebCore/platform/network/ProtectionSpace.h
deleted file mode 100644
index 9a73cff..0000000
--- a/WebCore/platform/network/ProtectionSpace.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef ProtectionSpace_h
-#define ProtectionSpace_h
-
-#include "PlatformString.h"
-
-namespace WebCore {
-
-enum ProtectionSpaceServerType {
- ProtectionSpaceServerHTTP = 1,
- ProtectionSpaceServerHTTPS = 2,
- ProtectionSpaceServerFTP = 3,
- ProtectionSpaceServerFTPS = 4,
- ProtectionSpaceProxyHTTP = 5,
- ProtectionSpaceProxyHTTPS = 6,
- ProtectionSpaceProxyFTP = 7,
- ProtectionSpaceProxySOCKS = 8
-};
-
-enum ProtectionSpaceAuthenticationScheme {
- ProtectionSpaceAuthenticationSchemeDefault = 1,
- ProtectionSpaceAuthenticationSchemeHTTPBasic = 2,
- ProtectionSpaceAuthenticationSchemeHTTPDigest = 3,
- ProtectionSpaceAuthenticationSchemeHTMLForm = 4,
- ProtectionSpaceAuthenticationSchemeNTLM = 5,
- ProtectionSpaceAuthenticationSchemeNegotiate = 6,
-};
-
-class ProtectionSpace {
-
-public:
- ProtectionSpace();
- ProtectionSpace(const String& host, int port, ProtectionSpaceServerType, const String& realm, ProtectionSpaceAuthenticationScheme);
-
- const String& host() const;
- int port() const;
- ProtectionSpaceServerType serverType() const;
- bool isProxy() const;
- const String& realm() const;
- ProtectionSpaceAuthenticationScheme authenticationScheme() const;
-
- bool receivesCredentialSecurely() const;
-
-private:
- String m_host;
- int m_port;
- ProtectionSpaceServerType m_serverType;
- String m_realm;
- ProtectionSpaceAuthenticationScheme m_authenticationScheme;
-};
-
-bool operator==(const ProtectionSpace& a, const ProtectionSpace& b);
-inline bool operator!=(const ProtectionSpace& a, const ProtectionSpace& b) { return !(a == b); }
-
-}
-#endif
diff --git a/WebCore/platform/network/ResourceErrorBase.cpp b/WebCore/platform/network/ResourceErrorBase.cpp
deleted file mode 100644
index 1ea35b0..0000000
--- a/WebCore/platform/network/ResourceErrorBase.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ResourceError.h"
-
-namespace WebCore {
-
-void ResourceErrorBase::lazyInit() const
-{
- const_cast<ResourceError*>(static_cast<const ResourceError*>(this))->platformLazyInit();
-}
-
-bool ResourceErrorBase::compare(const ResourceError& a, const ResourceError& b)
-{
- if (a.isNull() && b.isNull())
- return true;
-
- if (a.isNull() || b.isNull())
- return false;
-
- if (a.domain() != b.domain())
- return false;
-
- if (a.errorCode() != b.errorCode())
- return false;
-
- if (a.failingURL() != b.failingURL())
- return false;
-
- if (a.localizedDescription() != b.localizedDescription())
- return false;
-
- if (a.isCancellation() != b.isCancellation())
- return false;
-
- return platformCompare(a, b);
-}
-
-}
diff --git a/WebCore/platform/network/ResourceErrorBase.h b/WebCore/platform/network/ResourceErrorBase.h
deleted file mode 100644
index b2aac67..0000000
--- a/WebCore/platform/network/ResourceErrorBase.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ResourceErrorBase_h
-#define ResourceErrorBase_h
-
-#include "PlatformString.h"
-
-namespace WebCore {
-
-class ResourceError;
-
-class ResourceErrorBase {
-public:
- bool isNull() const { return m_isNull; }
-
- const String& domain() const { lazyInit(); return m_domain; }
- int errorCode() const { lazyInit(); return m_errorCode; }
- const String& failingURL() const { lazyInit(); return m_failingURL; }
- const String& localizedDescription() const { lazyInit(); return m_localizedDescription; }
-
- void setIsCancellation(bool isCancellation) { m_isCancellation = isCancellation; }
- bool isCancellation() const { return m_isCancellation; }
-
- static bool compare(const ResourceError& a, const ResourceError& b);
-
-protected:
- ResourceErrorBase()
- : m_errorCode(0)
- , m_isNull(true)
- , m_isCancellation(false)
- {
- }
-
- ResourceErrorBase(const String& domain, int errorCode, const String& failingURL, const String& localizedDescription)
- : m_domain(domain)
- , m_errorCode(errorCode)
- , m_failingURL(failingURL)
- , m_localizedDescription(localizedDescription)
- , m_isNull(false)
- , m_isCancellation(false)
- {
- }
-
- void lazyInit() const;
-
- // The ResourceError subclass may "shadow" this method to lazily initialize platform specific fields
- void platformLazyInit() {}
-
- // The ResourceError subclass may "shadow" this method to compare platform specific fields
- static bool platformCompare(const ResourceError& a, const ResourceError& b) { return true; }
-
- String m_domain;
- int m_errorCode;
- String m_failingURL;
- String m_localizedDescription;
- bool m_isNull;
- bool m_isCancellation;
-};
-
-inline bool operator==(const ResourceError& a, const ResourceError& b) { return ResourceErrorBase::compare(a, b); }
-inline bool operator!=(const ResourceError& a, const ResourceError& b) { return !(a == b); }
-
-} // namespace WebCore
-
-#endif // ResourceErrorBase_h_
diff --git a/WebCore/platform/network/ResourceHandle.cpp b/WebCore/platform/network/ResourceHandle.cpp
deleted file mode 100644
index 149411e..0000000
--- a/WebCore/platform/network/ResourceHandle.cpp
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * Copyright (C) 2004, 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ResourceHandle.h"
-#include "ResourceHandleInternal.h"
-
-#include "Logging.h"
-#include "ResourceHandleClient.h"
-#include "Timer.h"
-#include <algorithm>
-
-namespace WebCore {
-
-static bool portAllowed(const ResourceRequest&);
-
-ResourceHandle::ResourceHandle(const ResourceRequest& request, ResourceHandleClient* client, bool defersLoading,
- bool shouldContentSniff, bool mightDownloadFromHandle)
- : d(new ResourceHandleInternal(this, request, client, defersLoading, shouldContentSniff, mightDownloadFromHandle))
-{
-}
-
-PassRefPtr<ResourceHandle> ResourceHandle::create(const ResourceRequest& request, ResourceHandleClient* client,
- Frame* frame, bool defersLoading, bool shouldContentSniff, bool mightDownloadFromHandle)
-{
- RefPtr<ResourceHandle> newHandle(adoptRef(new ResourceHandle(request, client, defersLoading, shouldContentSniff, mightDownloadFromHandle)));
-
- if (!request.url().isValid()) {
- newHandle->scheduleFailure(InvalidURLFailure);
- return newHandle.release();
- }
-
- if (!portAllowed(request)) {
- newHandle->scheduleFailure(BlockedFailure);
- return newHandle.release();
- }
-
- if (newHandle->start(frame))
- return newHandle.release();
-
- return 0;
-}
-
-void ResourceHandle::scheduleFailure(FailureType type)
-{
- d->m_failureType = type;
- d->m_failureTimer.startOneShot(0);
-}
-
-void ResourceHandle::fireFailure(Timer<ResourceHandle>*)
-{
- if (!client())
- return;
-
- switch (d->m_failureType) {
- case BlockedFailure:
- client()->wasBlocked(this);
- return;
- case InvalidURLFailure:
- client()->cannotShowURL(this);
- return;
- }
-
- ASSERT_NOT_REACHED();
-}
-
-ResourceHandleClient* ResourceHandle::client() const
-{
- return d->m_client;
-}
-
-void ResourceHandle::setClient(ResourceHandleClient* client)
-{
- d->m_client = client;
-}
-
-const ResourceRequest& ResourceHandle::request() const
-{
- return d->m_request;
-}
-
-void ResourceHandle::clearAuthentication()
-{
-#if PLATFORM(MAC)
- d->m_currentMacChallenge = nil;
-#elif USE(CFNETWORK)
- d->m_currentCFChallenge = 0;
-#endif
- d->m_currentWebChallenge.nullify();
-}
-
-static bool portAllowed(const ResourceRequest& request)
-{
- unsigned short port = request.url().port();
-
- // Since most URLs don't have a port, return early for the "no port" case.
- if (!port)
- return true;
-
- // This blocked port list matches the port blocking that Mozilla implements.
- // See http://www.mozilla.org/projects/netlib/PortBanning.html for more information.
- static const unsigned short blockedPortList[] = {
- 1, // tcpmux
- 7, // echo
- 9, // discard
- 11, // systat
- 13, // daytime
- 15, // netstat
- 17, // qotd
- 19, // chargen
- 20, // FTP-data
- 21, // FTP-control
- 22, // SSH
- 23, // telnet
- 25, // SMTP
- 37, // time
- 42, // name
- 43, // nicname
- 53, // domain
- 77, // priv-rjs
- 79, // finger
- 87, // ttylink
- 95, // supdup
- 101, // hostriame
- 102, // iso-tsap
- 103, // gppitnp
- 104, // acr-nema
- 109, // POP2
- 110, // POP3
- 111, // sunrpc
- 113, // auth
- 115, // SFTP
- 117, // uucp-path
- 119, // nntp
- 123, // NTP
- 135, // loc-srv / epmap
- 139, // netbios
- 143, // IMAP2
- 179, // BGP
- 389, // LDAP
- 465, // SMTP+SSL
- 512, // print / exec
- 513, // login
- 514, // shell
- 515, // printer
- 526, // tempo
- 530, // courier
- 531, // Chat
- 532, // netnews
- 540, // UUCP
- 556, // remotefs
- 563, // NNTP+SSL
- 587, // ESMTP
- 601, // syslog-conn
- 636, // LDAP+SSL
- 993, // IMAP+SSL
- 995, // POP3+SSL
- 2049, // NFS
- 4045, // lockd
- 6000, // X11
- };
- const unsigned short* const blockedPortListEnd = blockedPortList
- + sizeof(blockedPortList) / sizeof(blockedPortList[0]);
-
- // If the port is not in the blocked port list, allow it.
- if (!std::binary_search(blockedPortList, blockedPortListEnd, port))
- return true;
-
- // Allow ports 21 and 22 for FTP URLs, as Mozilla does.
- if ((port == 21 || port == 22) && request.url().protocolIs("ftp"))
- return true;
-
- // Allow any port number in a file URL, since the port number is ignored.
- if (request.url().protocolIs("file"))
- return true;
-
- return false;
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/network/ResourceHandle.h b/WebCore/platform/network/ResourceHandle.h
deleted file mode 100644
index 304bdbe..0000000
--- a/WebCore/platform/network/ResourceHandle.h
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ResourceHandle_h
-#define ResourceHandle_h
-
-#include "AuthenticationChallenge.h"
-#include "HTTPHeaderMap.h"
-#include <wtf/OwnPtr.h>
-
-#if PLATFORM(CF)
-typedef const struct __CFData * CFDataRef;
-#endif
-
-#if PLATFORM(WIN)
-typedef unsigned long DWORD;
-typedef unsigned long DWORD_PTR;
-typedef void* LPVOID;
-typedef LPVOID HINTERNET;
-typedef unsigned WPARAM;
-typedef long LPARAM;
-typedef struct HWND__* HWND;
-typedef _W64 long LONG_PTR;
-typedef LONG_PTR LRESULT;
-#endif
-
-
-#if PLATFORM(MAC)
-#include <wtf/RetainPtr.h>
-#ifdef __OBJC__
-@class NSData;
-@class NSError;
-@class NSURLConnection;
-@class WebCoreResourceHandleAsDelegate;
-#else
-class NSData;
-class NSError;
-class NSURLConnection;
-class WebCoreResourceHandleAsDelegate;
-typedef struct objc_object *id;
-#endif
-#endif
-
-#if USE(CFNETWORK)
-typedef struct _CFURLConnection* CFURLConnectionRef;
-typedef int CFHTTPCookieStorageAcceptPolicy;
-typedef struct OpaqueCFHTTPCookieStorage* CFHTTPCookieStorageRef;
-#endif
-
-namespace WebCore {
-
-class AuthenticationChallenge;
-class Credential;
-class FormData;
-class Frame;
-class KURL;
-class ResourceError;
-class ResourceHandleClient;
-class ResourceHandleInternal;
-class ResourceRequest;
-class ResourceResponse;
-class SchedulePair;
-class SharedBuffer;
-class SubresourceLoader;
-class SubresourceLoaderClient;
-
-template <typename T> class Timer;
-
-class ResourceHandle : public RefCounted<ResourceHandle> {
-private:
- ResourceHandle(const ResourceRequest&, ResourceHandleClient*, bool defersLoading, bool shouldContentSniff, bool mightDownloadFromHandle);
-
- enum FailureType {
- BlockedFailure,
- InvalidURLFailure
- };
-
-public:
- // FIXME: should not need the Frame
- static PassRefPtr<ResourceHandle> create(const ResourceRequest&, ResourceHandleClient*, Frame*, bool defersLoading, bool shouldContentSniff, bool mightDownloadFromHandle = false);
-
- static void loadResourceSynchronously(const ResourceRequest&, ResourceError&, ResourceResponse&, Vector<char>& data, Frame* frame);
- static bool willLoadFromCache(ResourceRequest&);
-#if PLATFORM(MAC)
- static bool didSendBodyDataDelegateExists();
-#endif
-
- ~ResourceHandle();
-
-#if PLATFORM(MAC) || USE(CFNETWORK) || USE(CURL)
- void didReceiveAuthenticationChallenge(const AuthenticationChallenge&);
- void receivedCredential(const AuthenticationChallenge&, const Credential&);
- void receivedRequestToContinueWithoutCredential(const AuthenticationChallenge&);
- void receivedCancellation(const AuthenticationChallenge&);
-#endif
-
-#if PLATFORM(MAC)
- void didCancelAuthenticationChallenge(const AuthenticationChallenge&);
- NSURLConnection *connection() const;
- WebCoreResourceHandleAsDelegate *delegate();
- void releaseDelegate();
- id releaseProxy();
-
- void schedule(SchedulePair*);
- void unschedule(SchedulePair*);
-#elif USE(CFNETWORK)
- static CFRunLoopRef loaderRunLoop();
- CFURLConnectionRef connection() const;
- CFURLConnectionRef releaseConnectionForDownload();
- static void setHostAllowsAnyHTTPSCertificate(const String&);
- static void setClientCertificate(const String& host, CFDataRef);
-#endif
-
-#if PLATFORM(WIN) && USE(CURL)
- static void setHostAllowsAnyHTTPSCertificate(const String&);
-#endif
-#if PLATFORM(WIN) && USE(CURL) && PLATFORM(CF)
- static void setClientCertificate(const String& host, CFDataRef);
-#endif
-
- PassRefPtr<SharedBuffer> bufferedData();
- static bool supportsBufferedData();
-
-#if USE(WININET)
- void setHasReceivedResponse(bool = true);
- bool hasReceivedResponse() const;
- void fileLoadTimer(Timer<ResourceHandle>*);
- void onHandleCreated(LPARAM);
- void onRequestRedirected(LPARAM);
- void onRequestComplete(LPARAM);
- friend void __stdcall transferJobStatusCallback(HINTERNET, DWORD_PTR, DWORD, LPVOID, DWORD);
- friend LRESULT __stdcall ResourceHandleWndProc(HWND, unsigned message, WPARAM, LPARAM);
-#endif
-
-#if PLATFORM(QT) || USE(CURL) || USE(SOUP) || defined(ANDROID)
- ResourceHandleInternal* getInternal() { return d.get(); }
-#endif
-
- // Used to work around the fact that you don't get any more NSURLConnection callbacks until you return from the one you're in.
- static bool loadsBlocked();
-
- void clearAuthentication();
- void cancel();
-
- // The client may be 0, in which case no callbacks will be made.
- ResourceHandleClient* client() const;
- void setClient(ResourceHandleClient*);
-
- void setDefersLoading(bool);
-
- const ResourceRequest& request() const;
-
- void fireFailure(Timer<ResourceHandle>*);
-
-private:
-#if USE(SOUP)
- bool startData(String urlString);
- bool startHttp(String urlString);
- bool startGio(String urlString);
-#endif
-
- void scheduleFailure(FailureType);
-
- bool start(Frame*);
-
- friend class ResourceHandleInternal;
- OwnPtr<ResourceHandleInternal> d;
-};
-
-}
-
-#endif // ResourceHandle_h
diff --git a/WebCore/platform/network/ResourceHandleClient.h b/WebCore/platform/network/ResourceHandleClient.h
deleted file mode 100644
index 08e06a2..0000000
--- a/WebCore/platform/network/ResourceHandleClient.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ResourceHandleClient_h
-#define ResourceHandleClient_h
-
-#include <wtf/RefCounted.h>
-#include <wtf/Platform.h>
-#include <wtf/RefPtr.h>
-
-#if USE(CFNETWORK)
-#include <ConditionalMacros.h>
-#include <CFNetwork/CFURLResponsePriv.h>
-#endif
-
-#if PLATFORM(MAC)
-#ifdef __OBJC__
-@class NSCachedURLResponse;
-#else
-class NSCachedURLResponse;
-#endif
-#endif
-
-namespace WebCore {
- class AuthenticationChallenge;
- class Credential;
- class KURL;
- class ResourceHandle;
- class ResourceError;
- class ResourceRequest;
- class ResourceResponse;
-
- enum CacheStoragePolicy {
- StorageAllowed,
- StorageAllowedInMemoryOnly,
- StorageNotAllowed,
- };
-
- class ResourceHandleClient {
- public:
- virtual ~ResourceHandleClient() { }
-
- // request may be modified
- virtual void willSendRequest(ResourceHandle*, ResourceRequest&, const ResourceResponse& redirectResponse) { }
- virtual void didSendData(ResourceHandle*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent) { }
-
- virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&) { }
- virtual void didReceiveData(ResourceHandle*, const char*, int, int lengthReceived) { }
- virtual void didFinishLoading(ResourceHandle*) { }
- virtual void didFail(ResourceHandle*, const ResourceError&) { }
- virtual void wasBlocked(ResourceHandle*) { }
- virtual void cannotShowURL(ResourceHandle*) { }
-
- virtual void willCacheResponse(ResourceHandle*, CacheStoragePolicy&) { }
-
- virtual void didReceiveAuthenticationChallenge(ResourceHandle*, const AuthenticationChallenge&) { }
- virtual void didCancelAuthenticationChallenge(ResourceHandle*, const AuthenticationChallenge&) { }
- virtual void receivedCredential(ResourceHandle*, const AuthenticationChallenge&, const Credential&) { }
- virtual void receivedRequestToContinueWithoutCredential(ResourceHandle*, const AuthenticationChallenge&) { }
- virtual void receivedCancellation(ResourceHandle*, const AuthenticationChallenge&) { }
-
-#if PLATFORM(MAC)
- virtual NSCachedURLResponse* willCacheResponse(ResourceHandle*, NSCachedURLResponse* response) { return response; }
- virtual void willStopBufferingData(ResourceHandle*, const char*, int) { }
-#endif
- };
-
-}
-
-#endif
diff --git a/WebCore/platform/network/ResourceHandleInternal.h b/WebCore/platform/network/ResourceHandleInternal.h
deleted file mode 100644
index 0bfa9da..0000000
--- a/WebCore/platform/network/ResourceHandleInternal.h
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ResourceHandleInternal_h
-#define ResourceHandleInternal_h
-
-#include "ResourceHandle.h"
-#include "ResourceRequest.h"
-#include "AuthenticationChallenge.h"
-#include "Timer.h"
-
-#if USE(CFNETWORK)
-#include <CFNetwork/CFURLConnectionPriv.h>
-#endif
-
-#if USE(WININET)
-#include <winsock2.h>
-#include <windows.h>
-#endif
-
-#if USE(CURL)
-#include <curl/curl.h>
-#include "FormDataStreamCurl.h"
-#endif
-
-#if USE(SOUP)
-#include <libsoup/soup.h>
-#endif
-
-#if PLATFORM(QT)
-class QWebFrame;
-class QWebNetworkJob;
-namespace WebCore {
-class QNetworkReplyHandler;
-}
-#endif
-
-#if PLATFORM(MAC)
-#ifdef __OBJC__
-@class NSURLAuthenticationChallenge;
-@class NSURLConnection;
-#else
-class NSURLAuthenticationChallenge;
-class NSURLConnection;
-#endif
-#endif
-
-#if PLATFORM(ANDROID)
-namespace android {
- class WebCoreResourceLoader;
-}
-#endif
-
-// The allocations and releases in ResourceHandleInternal are
-// Cocoa-exception-free (either simple Foundation classes or
-// WebCoreResourceLoaderImp which avoids doing work in dealloc).
-
-namespace WebCore {
- class ResourceHandleClient;
-
- class ResourceHandleInternal : Noncopyable {
- public:
- ResourceHandleInternal(ResourceHandle* loader, const ResourceRequest& request, ResourceHandleClient* c, bool defersLoading, bool shouldContentSniff, bool mightDownloadFromHandle)
- : m_client(c)
- , m_request(request)
- , status(0)
- , m_defersLoading(defersLoading)
- , m_shouldContentSniff(shouldContentSniff)
- , m_mightDownloadFromHandle(mightDownloadFromHandle)
-#if USE(CFNETWORK)
- , m_connection(0)
-#endif
-#if USE(WININET)
- , m_fileHandle(INVALID_HANDLE_VALUE)
- , m_fileLoadTimer(loader, &ResourceHandle::fileLoadTimer)
- , m_resourceHandle(0)
- , m_secondaryHandle(0)
- , m_jobId(0)
- , m_threadId(0)
- , m_writing(false)
- , m_formDataString(0)
- , m_formDataLength(0)
- , m_bytesRemainingToWrite(0)
- , m_hasReceivedResponse(false)
- , m_resend(false)
-#endif
-#if USE(CURL)
- , m_handle(0)
- , m_url(0)
- , m_customHeaders(0)
- , m_cancelled(false)
- , m_formDataStream(loader)
-#endif
-#if USE(SOUP)
- , m_msg(0)
- , m_cancelled(false)
- , m_gfile(0)
- , m_input_stream(0)
- , m_cancellable(0)
- , m_buffer(0)
- , m_bufsize(0)
- , m_total(0)
-#endif
-#if PLATFORM(QT)
- , m_job(0)
- , m_frame(0)
-#endif
-#if PLATFORM(MAC)
- , m_startWhenScheduled(false)
- , m_currentMacChallenge(nil)
-#elif USE(CFNETWORK)
- , m_currentCFChallenge(0)
-#endif
-#if PLATFORM(ANDROID)
- , m_loader(0)
-#endif
- , m_failureTimer(loader, &ResourceHandle::fireFailure)
- {
- }
-
- ~ResourceHandleInternal();
-
- ResourceHandleClient* client() { return m_client; }
- ResourceHandleClient* m_client;
-
- ResourceRequest m_request;
-
- int status;
-
- bool m_defersLoading;
- bool m_shouldContentSniff;
- bool m_mightDownloadFromHandle;
-#if USE(CFNETWORK)
- RetainPtr<CFURLConnectionRef> m_connection;
-#elif PLATFORM(MAC)
- RetainPtr<NSURLConnection> m_connection;
- RetainPtr<WebCoreResourceHandleAsDelegate> m_delegate;
- RetainPtr<id> m_proxy;
- bool m_startWhenScheduled;
-#endif
-#if USE(WININET)
- HANDLE m_fileHandle;
- Timer<ResourceHandle> m_fileLoadTimer;
- HINTERNET m_resourceHandle;
- HINTERNET m_secondaryHandle;
- unsigned m_jobId;
- DWORD m_threadId;
- bool m_writing;
- char* m_formDataString;
- int m_formDataLength;
- int m_bytesRemainingToWrite;
- String m_postReferrer;
- bool m_hasReceivedResponse;
- bool m_resend;
-#endif
-#if USE(CURL)
- CURL* m_handle;
- char* m_url;
- struct curl_slist* m_customHeaders;
- ResourceResponse m_response;
- bool m_cancelled;
-
- FormDataStream m_formDataStream;
- Vector<char> m_postBytes;
-#endif
-#if USE(SOUP)
- SoupMessage* m_msg;
- ResourceResponse m_response;
- bool m_cancelled;
- GFile* m_gfile;
- GInputStream* m_input_stream;
- GCancellable* m_cancellable;
- char* m_buffer;
- gsize m_bufsize, m_total;
-#endif
-#if PLATFORM(QT)
-#if QT_VERSION < 0x040400
- QWebNetworkJob* m_job;
-#else
- QNetworkReplyHandler* m_job;
-#endif
- QWebFrame* m_frame;
-#endif
-#if PLATFORM(MAC)
- NSURLAuthenticationChallenge *m_currentMacChallenge;
-#endif
-#if USE(CFNETWORK)
- CFURLAuthChallengeRef m_currentCFChallenge;
-#endif
-#if PLATFORM(ANDROID)
- android::WebCoreResourceLoader* m_loader;
-#endif
- AuthenticationChallenge m_currentWebChallenge;
-
- ResourceHandle::FailureType m_failureType;
- Timer<ResourceHandle> m_failureTimer;
- };
-
-} // namespace WebCore
-
-#endif // ResourceHandleInternal_h
diff --git a/WebCore/platform/network/ResourceRequestBase.cpp b/WebCore/platform/network/ResourceRequestBase.cpp
deleted file mode 100644
index 4784bbe..0000000
--- a/WebCore/platform/network/ResourceRequestBase.cpp
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
- * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "config.h"
-#include "ResourceRequestBase.h"
-#include "ResourceRequest.h"
-
-namespace WebCore {
-
-inline const ResourceRequest& ResourceRequestBase::asResourceRequest() const
-{
- return *static_cast<const ResourceRequest*>(this);
-}
-
-bool ResourceRequestBase::isEmpty() const
-{
- updateResourceRequest();
-
- return m_url.isEmpty();
-}
-
-bool ResourceRequestBase::isNull() const
-{
- updateResourceRequest();
-
- return m_url.isNull();
-}
-
-const KURL& ResourceRequestBase::url() const
-{
- updateResourceRequest();
-
- return m_url;
-}
-
-void ResourceRequestBase::setURL(const KURL& url)
-{
- updateResourceRequest();
-
- m_url = url;
-
- m_platformRequestUpdated = false;
-}
-
-ResourceRequestCachePolicy ResourceRequestBase::cachePolicy() const
-{
- updateResourceRequest();
-
- return m_cachePolicy;
-}
-
-void ResourceRequestBase::setCachePolicy(ResourceRequestCachePolicy cachePolicy)
-{
- updateResourceRequest();
-
- m_cachePolicy = cachePolicy;
-
- m_platformRequestUpdated = false;
-}
-
-double ResourceRequestBase::timeoutInterval() const
-{
- updateResourceRequest();
-
- return m_timeoutInterval;
-}
-
-void ResourceRequestBase::setTimeoutInterval(double timeoutInterval)
-{
- updateResourceRequest();
-
- m_timeoutInterval = timeoutInterval;
-
- m_platformRequestUpdated = false;
-}
-
-const KURL& ResourceRequestBase::mainDocumentURL() const
-{
- updateResourceRequest();
-
- return m_mainDocumentURL;
-}
-
-void ResourceRequestBase::setMainDocumentURL(const KURL& mainDocumentURL)
-{
- updateResourceRequest();
-
- m_mainDocumentURL = mainDocumentURL;
-
- m_platformRequestUpdated = false;
-}
-
-const String& ResourceRequestBase::httpMethod() const
-{
- updateResourceRequest();
-
- return m_httpMethod;
-}
-
-void ResourceRequestBase::setHTTPMethod(const String& httpMethod)
-{
- updateResourceRequest();
-
- m_httpMethod = httpMethod;
-
- m_platformRequestUpdated = false;
-}
-
-const HTTPHeaderMap& ResourceRequestBase::httpHeaderFields() const
-{
- updateResourceRequest();
-
- return m_httpHeaderFields;
-}
-
-String ResourceRequestBase::httpHeaderField(const String& name) const
-{
- updateResourceRequest();
-
- return m_httpHeaderFields.get(name);
-}
-
-void ResourceRequestBase::setHTTPHeaderField(const String& name, const String& value)
-{
- updateResourceRequest();
-
- m_httpHeaderFields.set(name, value);
-
- m_platformRequestUpdated = false;
-}
-
-FormData* ResourceRequestBase::httpBody() const
-{
- updateResourceRequest();
-
- return m_httpBody.get();
-}
-
-void ResourceRequestBase::setHTTPBody(PassRefPtr<FormData> httpBody)
-{
- updateResourceRequest();
-
- m_httpBody = httpBody;
-
- m_platformRequestUpdated = false;
-}
-
-bool ResourceRequestBase::allowHTTPCookies() const
-{
- updateResourceRequest();
-
- return m_allowHTTPCookies;
-}
-
-void ResourceRequestBase::setAllowHTTPCookies(bool allowHTTPCookies)
-{
- updateResourceRequest();
-
- m_allowHTTPCookies = allowHTTPCookies;
-
- m_platformRequestUpdated = false;
-}
-
-void ResourceRequestBase::addHTTPHeaderField(const String& name, const String& value)
-{
- updateResourceRequest();
- pair<HTTPHeaderMap::iterator, bool> result = m_httpHeaderFields.add(name, value);
- if (!result.second)
- result.first->second += "," + value;
-}
-
-void ResourceRequestBase::addHTTPHeaderFields(const HTTPHeaderMap& headerFields)
-{
- HTTPHeaderMap::const_iterator end = headerFields.end();
- for (HTTPHeaderMap::const_iterator it = headerFields.begin(); it != end; ++it)
- addHTTPHeaderField(it->first, it->second);
-}
-
-bool equalIgnoringHeaderFields(const ResourceRequestBase& a, const ResourceRequestBase& b)
-{
- if (a.url() != b.url())
- return false;
-
- if (a.cachePolicy() != b.cachePolicy())
- return false;
-
- if (a.timeoutInterval() != b.timeoutInterval())
- return false;
-
- if (a.mainDocumentURL() != b.mainDocumentURL())
- return false;
-
- if (a.httpMethod() != b.httpMethod())
- return false;
-
- if (a.allowHTTPCookies() != b.allowHTTPCookies())
- return false;
-
- FormData* formDataA = a.httpBody();
- FormData* formDataB = b.httpBody();
-
- if (!formDataA)
- return !formDataB;
- if (!formDataB)
- return !formDataA;
-
- if (*formDataA != *formDataB)
- return false;
-
- return true;
-}
-
-bool operator==(const ResourceRequestBase& a, const ResourceRequestBase& b)
-{
- if (!equalIgnoringHeaderFields(a, b))
- return false;
-
- if (a.httpHeaderFields() != b.httpHeaderFields())
- return false;
-
- return true;
-}
-
-bool ResourceRequestBase::isConditional() const
-{
- return (m_httpHeaderFields.contains("If-Match") ||
- m_httpHeaderFields.contains("If-Modified-Since") ||
- m_httpHeaderFields.contains("If-None-Match") ||
- m_httpHeaderFields.contains("If-Range") ||
- m_httpHeaderFields.contains("If-Unmodified-Since"));
-}
-
-void ResourceRequestBase::updatePlatformRequest() const
-{
- if (m_platformRequestUpdated)
- return;
-
- const_cast<ResourceRequest&>(asResourceRequest()).doUpdatePlatformRequest();
- m_platformRequestUpdated = true;
-}
-
-void ResourceRequestBase::updateResourceRequest() const
-{
- if (m_resourceRequestUpdated)
- return;
-
- const_cast<ResourceRequest&>(asResourceRequest()).doUpdateResourceRequest();
- m_resourceRequestUpdated = true;
-}
-
-}
diff --git a/WebCore/platform/network/ResourceRequestBase.h b/WebCore/platform/network/ResourceRequestBase.h
deleted file mode 100644
index 32a3384..0000000
--- a/WebCore/platform/network/ResourceRequestBase.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ResourceRequestBase_h
-#define ResourceRequestBase_h
-
-#include "FormData.h"
-#include "KURL.h"
-#include "HTTPHeaderMap.h"
-
-namespace WebCore {
-
- enum ResourceRequestCachePolicy {
- UseProtocolCachePolicy, // normal load
- ReloadIgnoringCacheData, // reload
- ReturnCacheDataElseLoad, // back/forward or encoding change - allow stale data
- ReturnCacheDataDontLoad, // results of a post - allow stale data and only use cache
- };
-
- const int unspecifiedTimeoutInterval = INT_MAX;
-
- class ResourceRequest;
-
- // Do not use this type directly. Use ResourceRequest instead.
- class ResourceRequestBase {
- public:
- bool isNull() const;
- bool isEmpty() const;
-
- const KURL& url() const;
- void setURL(const KURL& url);
-
- ResourceRequestCachePolicy cachePolicy() const;
- void setCachePolicy(ResourceRequestCachePolicy cachePolicy);
-
- double timeoutInterval() const;
- void setTimeoutInterval(double timeoutInterval);
-
- const KURL& mainDocumentURL() const;
- void setMainDocumentURL(const KURL& mainDocumentURL);
-
- const String& httpMethod() const;
- void setHTTPMethod(const String& httpMethod);
-
- const HTTPHeaderMap& httpHeaderFields() const;
- String httpHeaderField(const String& name) const;
- void setHTTPHeaderField(const String& name, const String& value);
- void addHTTPHeaderField(const String& name, const String& value);
- void addHTTPHeaderFields(const HTTPHeaderMap& headerFields);
-
- String httpContentType() const { return httpHeaderField("Content-Type"); }
- void setHTTPContentType(const String& httpContentType) { setHTTPHeaderField("Content-Type", httpContentType); }
-
- String httpReferrer() const { return httpHeaderField("Referer"); }
- void setHTTPReferrer(const String& httpReferrer) { setHTTPHeaderField("Referer", httpReferrer); }
- void clearHTTPReferrer() { m_httpHeaderFields.remove("Referer"); }
-
- String httpOrigin() const { return httpHeaderField("Origin"); }
- void setHTTPOrigin(const String& httpOrigin) { setHTTPHeaderField("Origin", httpOrigin); }
- void clearHTTPOrigin() { m_httpHeaderFields.remove("Origin"); }
-
- String httpUserAgent() const { return httpHeaderField("User-Agent"); }
- void setHTTPUserAgent(const String& httpUserAgent) { setHTTPHeaderField("User-Agent", httpUserAgent); }
-
- String httpAccept() const { return httpHeaderField("Accept"); }
- void setHTTPAccept(const String& httpAccept) { setHTTPHeaderField("Accept", httpAccept); }
-
- FormData* httpBody() const;
- void setHTTPBody(PassRefPtr<FormData> httpBody);
-
- bool allowHTTPCookies() const;
- void setAllowHTTPCookies(bool allowHTTPCookies);
-
- bool isConditional() const;
-
- protected:
- // Used when ResourceRequest is initialized from a platform representation of the request
- ResourceRequestBase()
- : m_resourceRequestUpdated(false)
- , m_platformRequestUpdated(true)
- {
- }
-
- ResourceRequestBase(const KURL& url, ResourceRequestCachePolicy policy)
- : m_url(url)
- , m_cachePolicy(policy)
- , m_timeoutInterval(unspecifiedTimeoutInterval)
- , m_httpMethod("GET")
- , m_allowHTTPCookies(true)
- , m_resourceRequestUpdated(true)
- , m_platformRequestUpdated(false)
- {
- }
-
- void updatePlatformRequest() const;
- void updateResourceRequest() const;
-
- KURL m_url;
-
- ResourceRequestCachePolicy m_cachePolicy;
- double m_timeoutInterval;
- KURL m_mainDocumentURL;
- String m_httpMethod;
- HTTPHeaderMap m_httpHeaderFields;
- RefPtr<FormData> m_httpBody;
- bool m_allowHTTPCookies;
- mutable bool m_resourceRequestUpdated;
- mutable bool m_platformRequestUpdated;
-
- private:
- const ResourceRequest& asResourceRequest() const;
- };
-
- bool equalIgnoringHeaderFields(const ResourceRequestBase&, const ResourceRequestBase&);
-
- bool operator==(const ResourceRequestBase&, const ResourceRequestBase&);
- inline bool operator!=(ResourceRequestBase& a, const ResourceRequestBase& b) { return !(a == b); }
-
-} // namespace WebCore
-
-#endif // ResourceRequestBase_h
diff --git a/WebCore/platform/network/ResourceResponseBase.cpp b/WebCore/platform/network/ResourceResponseBase.cpp
deleted file mode 100644
index a9ddc30..0000000
--- a/WebCore/platform/network/ResourceResponseBase.cpp
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ResourceResponseBase.h"
-#include "ResourceResponse.h"
-
-namespace WebCore {
-
-bool ResourceResponseBase::isHTTP() const
-{
- lazyInit();
-
- String protocol = m_url.protocol();
-
- return equalIgnoringCase(protocol, "http") || equalIgnoringCase(protocol, "https");
-}
-
-const KURL& ResourceResponseBase::url() const
-{
- lazyInit();
-
- return m_url;
-}
-
-void ResourceResponseBase::setUrl(const KURL& url)
-{
- lazyInit();
- m_isNull = false;
-
- m_url = url;
-}
-
-const String& ResourceResponseBase::mimeType() const
-{
- lazyInit();
-
- return m_mimeType;
-}
-
-void ResourceResponseBase::setMimeType(const String& mimeType)
-{
- lazyInit();
- m_isNull = false;
-
- m_mimeType = mimeType;
-}
-
-long long ResourceResponseBase::expectedContentLength() const
-{
- lazyInit();
-
- return m_expectedContentLength;
-}
-
-void ResourceResponseBase::setExpectedContentLength(long long expectedContentLength)
-{
- lazyInit();
- m_isNull = false;
-
- m_expectedContentLength = expectedContentLength;
-}
-
-const String& ResourceResponseBase::textEncodingName() const
-{
- lazyInit();
-
- return m_textEncodingName;
-}
-
-void ResourceResponseBase::setTextEncodingName(const String& encodingName)
-{
- lazyInit();
- m_isNull = false;
-
- m_textEncodingName = encodingName;
-}
-
-// FIXME should compute this on the fly
-const String& ResourceResponseBase::suggestedFilename() const
-{
- lazyInit();
-
- return m_suggestedFilename;
-}
-
-void ResourceResponseBase::setSuggestedFilename(const String& suggestedName)
-{
- lazyInit();
- m_isNull = false;
-
- m_suggestedFilename = suggestedName;
-}
-
-int ResourceResponseBase::httpStatusCode() const
-{
- lazyInit();
-
- return m_httpStatusCode;
-}
-
-void ResourceResponseBase::setHTTPStatusCode(int statusCode)
-{
- lazyInit();
-
- m_httpStatusCode = statusCode;
-}
-
-const String& ResourceResponseBase::httpStatusText() const
-{
- lazyInit();
-
- return m_httpStatusText;
-}
-
-void ResourceResponseBase::setHTTPStatusText(const String& statusText)
-{
- lazyInit();
-
- m_httpStatusText = statusText;
-}
-
-String ResourceResponseBase::httpHeaderField(const String& name) const
-{
- lazyInit();
-
- return m_httpHeaderFields.get(name);
-}
-
-void ResourceResponseBase::setHTTPHeaderField(const String& name, const String& value)
-{
- lazyInit();
-
- m_httpHeaderFields.set(name, value);
-}
-
-const HTTPHeaderMap& ResourceResponseBase::httpHeaderFields() const
-{
- lazyInit();
-
- return m_httpHeaderFields;
-}
-
-bool ResourceResponseBase::isAttachment() const
-{
- lazyInit();
-
- String value = m_httpHeaderFields.get("Content-Disposition");
- int loc = value.find(';');
- if (loc != -1)
- value = value.left(loc);
- value = value.stripWhiteSpace();
- return equalIgnoringCase(value, "attachment");
-}
-
-void ResourceResponseBase::setExpirationDate(time_t expirationDate)
-{
- lazyInit();
-
- m_expirationDate = expirationDate;
-}
-
-time_t ResourceResponseBase::expirationDate() const
-{
- lazyInit();
-
- return m_expirationDate;
-}
-
-void ResourceResponseBase::setLastModifiedDate(time_t lastModifiedDate)
-{
- lazyInit();
-
- m_lastModifiedDate = lastModifiedDate;
-}
-
-time_t ResourceResponseBase::lastModifiedDate() const
-{
- lazyInit();
-
- return m_lastModifiedDate;
-}
-
-void ResourceResponseBase::lazyInit() const
-{
- const_cast<ResourceResponse*>(static_cast<const ResourceResponse*>(this))->platformLazyInit();
-}
-
-bool ResourceResponseBase::compare(const ResourceResponse& a, const ResourceResponse& b)
-{
- if (a.isNull() != b.isNull())
- return false;
- if (a.url() != b.url())
- return false;
- if (a.mimeType() != b.mimeType())
- return false;
- if (a.expectedContentLength() != b.expectedContentLength())
- return false;
- if (a.textEncodingName() != b.textEncodingName())
- return false;
- if (a.suggestedFilename() != b.suggestedFilename())
- return false;
- if (a.httpStatusCode() != b.httpStatusCode())
- return false;
- if (a.httpStatusText() != b.httpStatusText())
- return false;
- if (a.httpHeaderFields() != b.httpHeaderFields())
- return false;
- if (a.expirationDate() != b.expirationDate())
- return false;
- return ResourceResponse::platformCompare(a, b);
-}
-
-}
diff --git a/WebCore/platform/network/ResourceResponseBase.h b/WebCore/platform/network/ResourceResponseBase.h
deleted file mode 100644
index 06b0499..0000000
--- a/WebCore/platform/network/ResourceResponseBase.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ResourceResponseBase_h
-#define ResourceResponseBase_h
-
-#include "HTTPHeaderMap.h"
-#include "KURL.h"
-
-namespace WebCore {
-
-class ResourceResponse;
-
-// Do not use this class directly, use the class ResponseResponse instead
-class ResourceResponseBase {
- public:
-
- bool isNull() const { return m_isNull; }
- bool isHTTP() const;
-
- const KURL& url() const;
- void setUrl(const KURL& url);
-
- const String& mimeType() const;
- void setMimeType(const String& mimeType);
-
- long long expectedContentLength() const;
- void setExpectedContentLength(long long expectedContentLength);
-
- const String& textEncodingName() const;
- void setTextEncodingName(const String& name);
-
- // FIXME should compute this on the fly
- const String& suggestedFilename() const;
- void setSuggestedFilename(const String&);
-
- int httpStatusCode() const;
- void setHTTPStatusCode(int);
-
- const String& httpStatusText() const;
- void setHTTPStatusText(const String&);
-
- String httpHeaderField(const String& name) const;
- void setHTTPHeaderField(const String& name, const String& value);
- const HTTPHeaderMap& httpHeaderFields() const;
-
- bool isMultipart() const { return mimeType() == "multipart/x-mixed-replace"; }
-
- bool isAttachment() const;
-
- void setExpirationDate(time_t);
- time_t expirationDate() const;
-
- void setLastModifiedDate(time_t);
- time_t lastModifiedDate() const;
-
- static bool compare(const ResourceResponse& a, const ResourceResponse& b);
-
- protected:
- ResourceResponseBase()
- : m_expectedContentLength(0)
- , m_httpStatusCode(0)
- , m_expirationDate(0)
- , m_lastModifiedDate(0)
- , m_isNull(true)
- {
- }
-
- ResourceResponseBase(const KURL& url, const String& mimeType, long long expectedLength, const String& textEncodingName, const String& filename)
- : m_url(url)
- , m_mimeType(mimeType)
- , m_expectedContentLength(expectedLength)
- , m_textEncodingName(textEncodingName)
- , m_suggestedFilename(filename)
- , m_httpStatusCode(0)
- , m_expirationDate(0)
- , m_lastModifiedDate(0)
- , m_isNull(false)
- {
- }
-
- void lazyInit() const;
-
- // The ResourceResponse subclass may "shadow" this method to lazily initialize platform specific fields
- void platformLazyInit() {}
-
- // The ResourceResponse subclass may "shadow" this method to compare platform specific fields
- static bool platformCompare(const ResourceResponse& a, const ResourceResponse& b) { return true; }
-
- KURL m_url;
- String m_mimeType;
- long long m_expectedContentLength;
- String m_textEncodingName;
- String m_suggestedFilename;
- int m_httpStatusCode;
- String m_httpStatusText;
- HTTPHeaderMap m_httpHeaderFields;
- time_t m_expirationDate;
- time_t m_lastModifiedDate;
- bool m_isNull;
-
-};
-
-inline bool operator==(const ResourceResponse& a, const ResourceResponse& b) { return ResourceResponseBase::compare(a, b); }
-inline bool operator!=(const ResourceResponse& a, const ResourceResponse& b) { return !(a == b); }
-
-} // namespace WebCore
-
-#endif // ResourceResponseBase_h
diff --git a/WebCore/platform/network/android/AuthenticationChallenge.h b/WebCore/platform/network/android/AuthenticationChallenge.h
deleted file mode 100644
index 971bf97..0000000
--- a/WebCore/platform/network/android/AuthenticationChallenge.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 2009, The Android Open Source Project
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef AuthenticationChallenge_h
-#define AuthenticationChallenge_h
-
-#include "AuthenticationChallengeBase.h"
-#include "ResourceHandle.h"
-#include <wtf/RefPtr.h>
-
-namespace WebCore {
-
-class ResourceHandle;
-
-class AuthenticationChallenge : public AuthenticationChallengeBase {
-public:
- AuthenticationChallenge()
- {
- }
-
- AuthenticationChallenge(const ProtectionSpace& protectionSpace, const Credential& proposedCredential, unsigned previousFailureCount, const ResourceResponse& response, const ResourceError& error)
- : AuthenticationChallengeBase(protectionSpace, proposedCredential, previousFailureCount, response, error)
- {
- }
-
- ResourceHandle* sourceHandle() const { return m_sourceHandle.get(); }
-
- RefPtr<ResourceHandle> m_sourceHandle;
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/network/android/Cookie.cpp b/WebCore/platform/network/android/Cookie.cpp
deleted file mode 100644
index 0b7aa45..0000000
--- a/WebCore/platform/network/android/Cookie.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright 2007, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#define LOG_TAG "Cookies"
-
-#include "config.h"
-#include "JavaSharedClient.h"
-#include "CookieClient.h"
-
-using namespace android;
-
-namespace WebCore {
-
- class Document;
-
- void setCookies(Document* , const KURL& url, const KURL& policyBaseURL, const String& value)
- {
- if (JavaSharedClient::GetCookieClient())
- JavaSharedClient::GetCookieClient()->setCookies(url, policyBaseURL, value);
- }
-
- String cookies(const Document* , const KURL& url)
- {
- if (JavaSharedClient::GetCookieClient())
- return JavaSharedClient::GetCookieClient()->cookies(url);
- return String();
- }
-
- bool cookiesEnabled(const Document* )
- {
- if (JavaSharedClient::GetCookieClient())
- return JavaSharedClient::GetCookieClient()->cookiesEnabled();
- return false;
- }
-
-}
-
diff --git a/WebCore/platform/network/android/CookieClient.h b/WebCore/platform/network/android/CookieClient.h
deleted file mode 100644
index 4b6ffef..0000000
--- a/WebCore/platform/network/android/CookieClient.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2007, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef COOKIE_CLIENT_H
-#define COOKIE_CLIENT_H
-
-#include "KURL.h"
-#include "PlatformString.h"
-
-using namespace WebCore;
-
-namespace android {
-
- class CookieClient
- {
- public:
- virtual ~CookieClient() {}
- virtual void setCookies(const KURL& url, const KURL& docURL, const String& value) = 0;
- virtual String cookies(const KURL& url) = 0;
- virtual bool cookiesEnabled() = 0;
- };
-
-}
-#endif
-
diff --git a/WebCore/platform/network/android/NetworkStateNotifierAndroid.cpp b/WebCore/platform/network/android/NetworkStateNotifierAndroid.cpp
deleted file mode 100644
index 3e49fff..0000000
--- a/WebCore/platform/network/android/NetworkStateNotifierAndroid.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2008, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "NetworkStateNotifier.h"
-
-namespace WebCore {
-
-void NetworkStateNotifier::networkStateChange(bool online)
-{
- if (m_isOnLine == online)
- return;
-
- m_isOnLine = online;
-
- if (m_networkStateChangedFunction)
- m_networkStateChangedFunction();
-}
-
-}
diff --git a/WebCore/platform/network/android/ResourceError.h b/WebCore/platform/network/android/ResourceError.h
deleted file mode 100644
index 12a6323..0000000
--- a/WebCore/platform/network/android/ResourceError.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2009, The Android Open Source Project
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ResourceError_h
-#define ResourceError_h
-
-#include "ResourceErrorBase.h"
-
-namespace WebCore {
-
-class ResourceError : public ResourceErrorBase
-{
-public:
- ResourceError()
- {
- }
-
- ResourceError(const String& domain, int errorCode, const String& failingURL, const String& localizedDescription)
- : ResourceErrorBase(domain, errorCode, failingURL, localizedDescription)
- {
- }
-};
-
-}
-
-#endif // ResourceError_h_
diff --git a/WebCore/platform/network/android/ResourceHandleAndroid.cpp b/WebCore/platform/network/android/ResourceHandleAndroid.cpp
deleted file mode 100644
index 4d9199a..0000000
--- a/WebCore/platform/network/android/ResourceHandleAndroid.cpp
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright 2007, The Android Open Source Project
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#define LOG_TAG "WebCore"
-
-#include "config.h"
-#include "ResourceHandle.h"
-
-#include "DocLoader.h"
-#include "Frame.h"
-#include "FrameLoader.h"
-#include "FrameLoaderClientAndroid.h"
-#include "NotImplemented.h"
-#include "ResourceHandleClient.h"
-#include "ResourceHandleInternal.h"
-#include "WebCoreFrameBridge.h"
-#include "WebCoreResourceLoader.h"
-#include "CString.h"
-
-using namespace android;
-
-namespace WebCore {
-
-ResourceHandleInternal::~ResourceHandleInternal()
-{
- Release(m_loader);
-}
-
-ResourceHandle::~ResourceHandle()
-{
-}
-
-bool ResourceHandle::start(Frame* frame)
-{
- WebCoreResourceLoader* loader;
- bool highPriority = true;
- CachedResource* r = d->m_request.getCachedResource();
- if (r) {
- CachedResource::Type t = r->type();
- highPriority = !(t == CachedResource::ImageResource ||
- t == CachedResource::FontResource);
- }
- FrameLoaderClientAndroid* client = static_cast<FrameLoaderClientAndroid*> (frame->loader()->client());
- loader = client->webFrame()->startLoadingResource(this, d->m_request, highPriority, false);
-
- if (loader) {
- Release(d->m_loader);
- d->m_loader = loader;
- }
-
- return loader != NULL;
-}
-
-void ResourceHandle::cancel()
-{
- if (d->m_loader)
- d->m_loader->cancel();
-}
-
-PassRefPtr<SharedBuffer> ResourceHandle::bufferedData()
-{
- return 0;
-}
-
-bool ResourceHandle::supportsBufferedData()
-{
- // We don't support buffering data on the native side.
- return false;
-}
-
-void ResourceHandle::setDefersLoading(bool defers)
-{
- notImplemented();
-}
-
-/*
-* This static method is called to check to see if a POST response is in
-* the cache. The JNI call through to the HTTP cache stored on the Java
-* side may be slow, but is only used during a navigation to
-* a POST response.
-*/
-bool ResourceHandle::willLoadFromCache(ResourceRequest& request)
-{
- // set the cache policy correctly, copied from
- // network/mac/ResourceHandleMac.mm
- request.setCachePolicy(ReturnCacheDataDontLoad);
- return WebCoreResourceLoader::willLoadFromCache(request.url());
-}
-
-bool ResourceHandle::loadsBlocked()
-{
- // FIXME, need to check whether connection pipe is blocked.
- // return false for now
- return false;
-}
-
-// Class to handle synchronized loading of resources.
-class SyncLoader : public ResourceHandleClient {
-public:
- SyncLoader(ResourceError& error, ResourceResponse& response, Vector<char>& data) {
- m_error = &error;
- m_response = &response;
- m_data = &data;
- }
- ~SyncLoader() {}
-
- virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse& response) {
- *m_response = response;
- }
-
- virtual void didReceiveData(ResourceHandle*, const char* data, int len, int lengthReceived) {
- m_data->append(data, len);
- }
-
- virtual void didFail(ResourceHandle*, const ResourceError& error) {
- *m_error = error;
- }
-
-private:
- ResourceError* m_error;
- ResourceResponse* m_response;
- Vector<char>* m_data;
-};
-
-void ResourceHandle::loadResourceSynchronously(const ResourceRequest& request,
- ResourceError& error, ResourceResponse& response, Vector<char>& data,
- Frame* frame)
-{
- SyncLoader s(error, response, data);
- ResourceHandle h(request, &s, false, false, false);
- // This blocks until the load is finished.
- FrameLoaderClientAndroid* client = static_cast<FrameLoaderClientAndroid*> (frame->loader()->client());
- client->webFrame()->startLoadingResource(&h, request, true, true);
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/network/android/ResourceRequest.h b/WebCore/platform/network/android/ResourceRequest.h
deleted file mode 100644
index bc12600..0000000
--- a/WebCore/platform/network/android/ResourceRequest.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright 2009, The Android Open Source Project
- * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ResourceRequest_h
-#define ResourceRequest_h
-
-#include "CachedResource.h"
-#include "ResourceRequestBase.h"
-
-namespace WebCore {
-
- struct ResourceRequest : ResourceRequestBase {
-
- ResourceRequest(const String& url)
- : ResourceRequestBase(KURL(url), UseProtocolCachePolicy)
- , m_cachedResource(0)
-#ifdef ANDROID_USER_GESTURE
- , m_wasUserGesture(true)
-#endif
- {
- }
-
- ResourceRequest(const KURL& url)
- : ResourceRequestBase(url, UseProtocolCachePolicy)
- , m_cachedResource(0)
-#ifdef ANDROID_USER_GESTURE
- , m_wasUserGesture(true)
-#endif
- {
- }
-
- ResourceRequest(const KURL& url, const String& referrer, ResourceRequestCachePolicy policy = UseProtocolCachePolicy)
- : ResourceRequestBase(url, policy)
- , m_cachedResource(0)
-#ifdef ANDROID_USER_GESTURE
- , m_wasUserGesture(true)
-#endif
- {
- setHTTPReferrer(referrer);
- }
-
- ResourceRequest()
- : ResourceRequestBase(KURL(), UseProtocolCachePolicy)
- , m_cachedResource(0)
-#ifdef ANDROID_USER_GESTURE
- , m_wasUserGesture(true)
-#endif
- {
- }
-
- void doUpdatePlatformRequest() {}
- void doUpdateResourceRequest() {}
- void setCachedResource(CachedResource* r) { m_cachedResource = r; }
- CachedResource* getCachedResource() const { return m_cachedResource; }
-#ifdef ANDROID_USER_GESTURE
- void setUserGesture(bool userGesture) { m_wasUserGesture = userGesture; }
- bool userGesture() const { return m_wasUserGesture; }
-#endif
- private:
- friend class ResourceRequestBase;
- CachedResource* m_cachedResource;
-#ifdef ANDROID_USER_GESTURE
- bool m_wasUserGesture;
-#endif
- };
-
-} // namespace WebCore
-
-#endif // ResourceRequest_h
diff --git a/WebCore/platform/network/android/ResourceResponse.h b/WebCore/platform/network/android/ResourceResponse.h
deleted file mode 100644
index 5249636..0000000
--- a/WebCore/platform/network/android/ResourceResponse.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2009, The Android Open Source Project
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ResourceResponse_h
-#define ResourceResponse_h
-
-#include "ResourceResponseBase.h"
-
-#include "NotImplemented.h"
-
-namespace WebCore {
-
-class ResourceResponse : public ResourceResponseBase {
-public:
- ResourceResponse()
- : ResourceResponseBase()
- {
- }
-
- ResourceResponse(const KURL& url, const String& mimeType, long long expectedLength, const String& textEncodingName, const String& filename)
- : ResourceResponseBase(url, mimeType, expectedLength, textEncodingName, filename)
- {
- }
-
-private:
- friend class ResourceResponseBase;
-
- void doUpdateResourceResponse()
- {
- notImplemented();
- }
-
-};
-
-} // namespace WebCore
-
-#endif // ResourceResponse_h
diff --git a/WebCore/platform/network/cf/AuthenticationCF.cpp b/WebCore/platform/network/cf/AuthenticationCF.cpp
deleted file mode 100644
index bb05a39..0000000
--- a/WebCore/platform/network/cf/AuthenticationCF.cpp
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "AuthenticationCF.h"
-
-#include "AuthenticationChallenge.h"
-#include "Credential.h"
-#include "ProtectionSpace.h"
-#include "ResourceHandle.h"
-
-#include <CFNetwork/CFURLAuthChallengePriv.h>
-#include <CFNetwork/CFURLCredentialPriv.h>
-#include <CFNetwork/CFURLProtectionSpacePriv.h>
-
-namespace WebCore {
-
-AuthenticationChallenge::AuthenticationChallenge(const ProtectionSpace& protectionSpace,
- const Credential& proposedCredential,
- unsigned previousFailureCount,
- const ResourceResponse& response,
- const ResourceError& error)
- : AuthenticationChallengeBase(protectionSpace,
- proposedCredential,
- previousFailureCount,
- response,
- error)
-{
-}
-
-AuthenticationChallenge::AuthenticationChallenge(CFURLAuthChallengeRef cfChallenge,
- ResourceHandle* sourceHandle)
- : AuthenticationChallengeBase(core(CFURLAuthChallengeGetProtectionSpace(cfChallenge)),
- core(CFURLAuthChallengeGetProposedCredential(cfChallenge)),
- CFURLAuthChallengeGetPreviousFailureCount(cfChallenge),
- (CFURLResponseRef)CFURLAuthChallengeGetFailureResponse(cfChallenge),
- CFURLAuthChallengeGetError(cfChallenge))
- , m_sourceHandle(sourceHandle)
- , m_cfChallenge(cfChallenge)
-{
-}
-
-bool AuthenticationChallenge::platformCompare(const AuthenticationChallenge& a, const AuthenticationChallenge& b)
-{
- if (a.sourceHandle() != b.sourceHandle())
- return false;
-
- if (a.cfURLAuthChallengeRef() != b.cfURLAuthChallengeRef())
- return false;
-
- return true;
-}
-
-CFURLAuthChallengeRef createCF(const AuthenticationChallenge& coreChallenge)
-{
- CFURLProtectionSpaceRef protectionSpace = createCF(coreChallenge.protectionSpace());
- CFURLCredentialRef credential = createCF(coreChallenge.proposedCredential());
-
- CFURLAuthChallengeRef result = CFURLAuthChallengeCreate(0, protectionSpace, credential,
- coreChallenge.previousFailureCount(),
- coreChallenge.failureResponse().cfURLResponse(),
- coreChallenge.error());
- CFRelease(protectionSpace);
- CFRelease(credential);
- return result;
-}
-
-CFURLCredentialRef createCF(const Credential& coreCredential)
-{
- CFURLCredentialPersistence persistence = kCFURLCredentialPersistenceNone;
- switch (coreCredential.persistence()) {
- case CredentialPersistenceNone:
- break;
- case CredentialPersistenceForSession:
- persistence = kCFURLCredentialPersistenceForSession;
- break;
- case CredentialPersistencePermanent:
- persistence = kCFURLCredentialPersistencePermanent;
- break;
- default:
- ASSERT_NOT_REACHED();
- }
-
- CFStringRef user = coreCredential.user().createCFString();
- CFStringRef password = coreCredential.password().createCFString();
- CFURLCredentialRef result = CFURLCredentialCreate(0, user, password, 0, persistence);
- CFRelease(user);
- CFRelease(password);
-
- return result;
-}
-
-CFURLProtectionSpaceRef createCF(const ProtectionSpace& coreSpace)
-{
- CFURLProtectionSpaceServerType serverType = kCFURLProtectionSpaceServerHTTP;
- switch (coreSpace.serverType()) {
- case ProtectionSpaceServerHTTP:
- serverType = kCFURLProtectionSpaceServerHTTP;
- break;
- case ProtectionSpaceServerHTTPS:
- serverType = kCFURLProtectionSpaceServerHTTPS;
- break;
- case ProtectionSpaceServerFTP:
- serverType = kCFURLProtectionSpaceServerFTP;
- break;
- case ProtectionSpaceServerFTPS:
- serverType = kCFURLProtectionSpaceServerFTPS;
- break;
- case ProtectionSpaceProxyHTTP:
- serverType = kCFURLProtectionSpaceProxyHTTP;
- break;
- case ProtectionSpaceProxyHTTPS:
- serverType = kCFURLProtectionSpaceProxyHTTPS;
- break;
- case ProtectionSpaceProxyFTP:
- serverType = kCFURLProtectionSpaceProxyFTP;
- break;
- case ProtectionSpaceProxySOCKS:
- serverType = kCFURLProtectionSpaceProxySOCKS;
- break;
- default:
- ASSERT_NOT_REACHED();
- }
-
- CFURLProtectionSpaceAuthenticationScheme scheme = kCFURLProtectionSpaceAuthenticationSchemeDefault;
- switch (coreSpace.authenticationScheme()) {
- case ProtectionSpaceAuthenticationSchemeDefault:
- scheme = kCFURLProtectionSpaceAuthenticationSchemeDefault;
- break;
- case ProtectionSpaceAuthenticationSchemeHTTPBasic:
- scheme = kCFURLProtectionSpaceAuthenticationSchemeHTTPBasic;
- break;
- case ProtectionSpaceAuthenticationSchemeHTTPDigest:
- scheme = kCFURLProtectionSpaceAuthenticationSchemeHTTPDigest;
- break;
- case ProtectionSpaceAuthenticationSchemeHTMLForm:
- scheme = kCFURLProtectionSpaceAuthenticationSchemeHTMLForm;
- break;
- case ProtectionSpaceAuthenticationSchemeNTLM:
- scheme = kCFURLProtectionSpaceAuthenticationSchemeNTLM;
- break;
- case ProtectionSpaceAuthenticationSchemeNegotiate:
- scheme = kCFURLProtectionSpaceAuthenticationSchemeNegotiate;
- break;
- default:
- ASSERT_NOT_REACHED();
- }
-
- CFStringRef host = coreSpace.host().createCFString();
- CFStringRef realm = coreSpace.realm().createCFString();
- CFURLProtectionSpaceRef result = CFURLProtectionSpaceCreate(0, host, coreSpace.port(), serverType, realm, scheme);
- CFRelease(host);
- CFRelease(realm);
-
- return result;
-}
-
-Credential core(CFURLCredentialRef cfCredential)
-{
- if (!cfCredential)
- return Credential();
-
- CredentialPersistence persistence = CredentialPersistenceNone;
- switch (CFURLCredentialGetPersistence(cfCredential)) {
- case kCFURLCredentialPersistenceNone:
- break;
- case kCFURLCredentialPersistenceForSession:
- persistence = CredentialPersistenceForSession;
- break;
- case kCFURLCredentialPersistencePermanent:
- persistence = CredentialPersistencePermanent;
- break;
- default:
- ASSERT_NOT_REACHED();
- }
-
- return Credential(CFURLCredentialGetUsername(cfCredential), CFURLCredentialCopyPassword(cfCredential), persistence);
-}
-
-ProtectionSpace core(CFURLProtectionSpaceRef cfSpace)
-{
- ProtectionSpaceServerType serverType = ProtectionSpaceServerHTTP;
-
- switch (CFURLProtectionSpaceGetServerType(cfSpace)) {
- case kCFURLProtectionSpaceServerHTTP:
- break;
- case kCFURLProtectionSpaceServerHTTPS:
- serverType = ProtectionSpaceServerHTTPS;
- break;
- case kCFURLProtectionSpaceServerFTP:
- serverType = ProtectionSpaceServerFTP;
- break;
- case kCFURLProtectionSpaceServerFTPS:
- serverType = ProtectionSpaceServerFTPS;
- break;
- case kCFURLProtectionSpaceProxyHTTP:
- serverType = ProtectionSpaceProxyHTTP;
- break;
- case kCFURLProtectionSpaceProxyHTTPS:
- serverType = ProtectionSpaceProxyHTTPS;
- break;
- case kCFURLProtectionSpaceProxyFTP:
- serverType = ProtectionSpaceProxyFTP;
- break;
- case kCFURLProtectionSpaceProxySOCKS:
- serverType = ProtectionSpaceProxySOCKS;
- break;
- default:
- ASSERT_NOT_REACHED();
- }
-
- ProtectionSpaceAuthenticationScheme scheme = ProtectionSpaceAuthenticationSchemeDefault;
-
- switch (CFURLProtectionSpaceGetAuthenticationScheme(cfSpace)) {
- case kCFURLProtectionSpaceAuthenticationSchemeDefault:
- scheme = ProtectionSpaceAuthenticationSchemeDefault;
- break;
- case kCFURLProtectionSpaceAuthenticationSchemeHTTPBasic:
- scheme = ProtectionSpaceAuthenticationSchemeHTTPBasic;
- break;
- case kCFURLProtectionSpaceAuthenticationSchemeHTTPDigest:
- scheme = ProtectionSpaceAuthenticationSchemeHTTPDigest;
- break;
- case kCFURLProtectionSpaceAuthenticationSchemeHTMLForm:
- scheme = ProtectionSpaceAuthenticationSchemeHTMLForm;
- break;
- case kCFURLProtectionSpaceAuthenticationSchemeNTLM:
- scheme = ProtectionSpaceAuthenticationSchemeNTLM;
- break;
- case kCFURLProtectionSpaceAuthenticationSchemeNegotiate:
- scheme = ProtectionSpaceAuthenticationSchemeNegotiate;
- break;
- default:
- ASSERT_NOT_REACHED();
- }
-
- return ProtectionSpace(CFURLProtectionSpaceGetHost(cfSpace),
- CFURLProtectionSpaceGetPort(cfSpace),
- serverType,
- CFURLProtectionSpaceGetRealm(cfSpace),
- scheme);
-}
-
-};
diff --git a/WebCore/platform/network/cf/AuthenticationCF.h b/WebCore/platform/network/cf/AuthenticationCF.h
deleted file mode 100644
index 681e71f..0000000
--- a/WebCore/platform/network/cf/AuthenticationCF.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef AuthenticationCF_h
-#define AuthenticationCF_h
-
-typedef struct _CFURLAuthChallenge* CFURLAuthChallengeRef;
-typedef struct _CFURLCredential* CFURLCredentialRef;
-typedef struct _CFURLProtectionSpace* CFURLProtectionSpaceRef;
-
-namespace WebCore {
-
-class AuthenticationChallenge;
-class Credential;
-class ProtectionSpace;
-
-CFURLAuthChallengeRef createCF(const AuthenticationChallenge&);
-CFURLCredentialRef createCF(const Credential&);
-CFURLProtectionSpaceRef createCF(const ProtectionSpace&);
-
-Credential core(CFURLCredentialRef);
-ProtectionSpace core(CFURLProtectionSpaceRef);
-
-
-}
-
-#endif
diff --git a/WebCore/platform/network/cf/AuthenticationChallenge.h b/WebCore/platform/network/cf/AuthenticationChallenge.h
deleted file mode 100644
index 9697d7e..0000000
--- a/WebCore/platform/network/cf/AuthenticationChallenge.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef AuthenticationChallenge_h
-#define AuthenticationChallenge_h
-
-#include "AuthenticationChallengeBase.h"
-#include "ResourceHandle.h"
-#include <wtf/RefPtr.h>
-
-typedef struct _CFURLAuthChallenge* CFURLAuthChallengeRef;
-
-namespace WebCore {
-
-class ResourceHandle;
-
-class AuthenticationChallenge : public AuthenticationChallengeBase {
-public:
- AuthenticationChallenge() {}
- AuthenticationChallenge(const ProtectionSpace& protectionSpace, const Credential& proposedCredential, unsigned previousFailureCount, const ResourceResponse& response, const ResourceError& error);
- AuthenticationChallenge(CFURLAuthChallengeRef, ResourceHandle* sourceHandle);
-
- ResourceHandle* sourceHandle() const { return m_sourceHandle.get(); }
- CFURLAuthChallengeRef cfURLAuthChallengeRef() const { return m_cfChallenge.get(); }
-
-private:
- friend class AuthenticationChallengeBase;
- static bool platformCompare(const AuthenticationChallenge& a, const AuthenticationChallenge& b);
-
- RefPtr<ResourceHandle> m_sourceHandle;
- RetainPtr<CFURLAuthChallengeRef> m_cfChallenge;
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/network/cf/DNSCFNet.cpp b/WebCore/platform/network/cf/DNSCFNet.cpp
deleted file mode 100644
index e571494..0000000
--- a/WebCore/platform/network/cf/DNSCFNet.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2008 Collin Jackson <collinj@webkit.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "DNS.h"
-
-#include "NotImplemented.h"
-
-namespace WebCore {
-
-void prefetchDNS(const String& hostname)
-{
- notImplemented();
-}
-
-}
diff --git a/WebCore/platform/network/cf/FormDataStreamCFNet.cpp b/WebCore/platform/network/cf/FormDataStreamCFNet.cpp
deleted file mode 100644
index 71fbfe7..0000000
--- a/WebCore/platform/network/cf/FormDataStreamCFNet.cpp
+++ /dev/null
@@ -1,422 +0,0 @@
-/*
- * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/* originally written by Becky Willrich, additional code by Darin Adler */
-
-#include "config.h"
-#include "FormDataStreamCFNet.h"
-
-#include "CString.h"
-#include "FileSystem.h"
-#include "FormData.h"
-#include <CFNetwork/CFURLRequestPriv.h>
-#include <CoreFoundation/CFStreamAbstract.h>
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
-#include <sys/types.h>
-#include <wtf/Assertions.h>
-#include <wtf/HashMap.h>
-#include <wtf/RetainPtr.h>
-
-#define USE_V1_CFSTREAM_CALLBACKS
-#ifdef USE_V1_CFSTREAM_CALLBACKS
-typedef CFReadStreamCallBacksV1 WCReadStreamCallBacks;
-#else
-typedef CFReadStreamCallBacks WCReadStreamCallBacks;
-#endif
-
-namespace WebCore {
-
-static HashMap<CFReadStreamRef, RefPtr<FormData> >& getStreamFormDatas()
-{
- static HashMap<CFReadStreamRef, RefPtr<FormData> > streamFormDatas;
- return streamFormDatas;
-}
-
-static void formEventCallback(CFReadStreamRef stream, CFStreamEventType type, void* context);
-
-struct FormStreamFields {
- CFMutableSetRef scheduledRunLoopPairs;
- Vector<FormDataElement> remainingElements; // in reverse order
- CFReadStreamRef currentStream;
- char* currentData;
- CFReadStreamRef formStream;
-};
-
-struct SchedulePair {
- CFRunLoopRef runLoop;
- CFStringRef mode;
-};
-
-static const void* pairRetain(CFAllocatorRef alloc, const void* value)
-{
- const SchedulePair* pair = static_cast<const SchedulePair*>(value);
-
- SchedulePair* result = new SchedulePair;
- CFRetain(pair->runLoop);
- result->runLoop = pair->runLoop;
- result->mode = CFStringCreateCopy(alloc, pair->mode);
- return result;
-}
-
-static void pairRelease(CFAllocatorRef alloc, const void* value)
-{
- const SchedulePair* pair = static_cast<const SchedulePair*>(value);
-
- CFRelease(pair->runLoop);
- CFRelease(pair->mode);
- delete pair;
-}
-
-static Boolean pairEqual(const void* a, const void* b)
-{
- const SchedulePair* pairA = static_cast<const SchedulePair*>(a);
- const SchedulePair* pairB = static_cast<const SchedulePair*>(b);
-
- return pairA->runLoop == pairB->runLoop && CFEqual(pairA->mode, pairB->mode);
-}
-
-static CFHashCode pairHash(const void* value)
-{
- const SchedulePair* pair = static_cast<const SchedulePair*>(value);
-
- return (CFHashCode)pair->runLoop ^ CFHash(pair->mode);
-}
-
-static void closeCurrentStream(FormStreamFields *form)
-{
- if (form->currentStream) {
- CFReadStreamClose(form->currentStream);
- CFReadStreamSetClient(form->currentStream, kCFStreamEventNone, NULL, NULL);
- CFRelease(form->currentStream);
- form->currentStream = NULL;
- }
- if (form->currentData) {
- fastFree(form->currentData);
- form->currentData = 0;
- }
-}
-
-static void scheduleWithPair(const void* value, void* context)
-{
- const SchedulePair* pair = static_cast<const SchedulePair*>(value);
- CFReadStreamRef stream = (CFReadStreamRef)context;
-
- CFReadStreamScheduleWithRunLoop(stream, pair->runLoop, pair->mode);
-}
-
-static void advanceCurrentStream(FormStreamFields *form)
-{
- closeCurrentStream(form);
-
- if (form->remainingElements.isEmpty())
- return;
-
- // Create the new stream.
- FormDataElement& nextInput = form->remainingElements.last();
- if (nextInput.m_type == FormDataElement::data) {
- size_t size = nextInput.m_data.size();
- char* data = nextInput.m_data.releaseBuffer();
- form->currentStream = CFReadStreamCreateWithBytesNoCopy(0, reinterpret_cast<const UInt8*>(data), size, kCFAllocatorNull);
- form->currentData = data;
- } else {
- CFStringRef filename = nextInput.m_filename.createCFString();
-#if PLATFORM(WIN)
- CFURLRef fileURL = CFURLCreateWithFileSystemPath(0, filename, kCFURLWindowsPathStyle, FALSE);
-#else
- CFURLRef fileURL = CFURLCreateWithFileSystemPath(0, filename, kCFURLPOSIXPathStyle, FALSE);
-#endif
- CFRelease(filename);
- form->currentStream = CFReadStreamCreateWithFile(0, fileURL);
- CFRelease(fileURL);
- }
- form->remainingElements.removeLast();
-
- // Set up the callback.
- CFStreamClientContext context = { 0, form, NULL, NULL, NULL };
- CFReadStreamSetClient(form->currentStream, kCFStreamEventHasBytesAvailable | kCFStreamEventErrorOccurred | kCFStreamEventEndEncountered,
- formEventCallback, &context);
-
- // Schedule with the current set of run loops.
- CFSetApplyFunction(form->scheduledRunLoopPairs, scheduleWithPair, form->currentStream);
-}
-
-static void openNextStream(FormStreamFields* form)
-{
- // Skip over any streams we can't open.
- // For some purposes we might want to return an error, but the current CFURLConnection
- // can't really do anything useful with an error at this point, so this is better.
- advanceCurrentStream(form);
- while (form->currentStream && !CFReadStreamOpen(form->currentStream))
- advanceCurrentStream(form);
-}
-
-static void* formCreate(CFReadStreamRef stream, void* context)
-{
- FormData* formData = static_cast<FormData*>(context);
-
- CFSetCallBacks runLoopAndModeCallBacks = { 0, pairRetain, pairRelease, NULL, pairEqual, pairHash };
-
- FormStreamFields* newInfo = new FormStreamFields;
- newInfo->scheduledRunLoopPairs = CFSetCreateMutable(0, 0, &runLoopAndModeCallBacks);
- newInfo->currentStream = NULL;
- newInfo->currentData = 0;
- newInfo->formStream = stream; // Don't retain. That would create a reference cycle.
-
- // Append in reverse order since we remove elements from the end.
- size_t size = formData->elements().size();
- newInfo->remainingElements.reserveCapacity(size);
- for (size_t i = 0; i < size; ++i)
- newInfo->remainingElements.append(formData->elements()[size - i - 1]);
-
- getStreamFormDatas().set(stream, adoptRef(formData));
-
- return newInfo;
-}
-
-static void formFinalize(CFReadStreamRef stream, void* context)
-{
- FormStreamFields* form = static_cast<FormStreamFields*>(context);
-
- getStreamFormDatas().remove(stream);
-
- closeCurrentStream(form);
- CFRelease(form->scheduledRunLoopPairs);
- delete form;
-}
-
-static Boolean formOpen(CFReadStreamRef stream, CFStreamError* error, Boolean* openComplete, void* context)
-{
- FormStreamFields* form = static_cast<FormStreamFields*>(context);
-
- openNextStream(form);
-
- *openComplete = TRUE;
- error->error = 0;
- return TRUE;
-}
-
-static CFIndex formRead(CFReadStreamRef stream, UInt8* buffer, CFIndex bufferLength, CFStreamError* error, Boolean* atEOF, void* context)
-{
- FormStreamFields* form = static_cast<FormStreamFields*>(context);
-
- while (form->currentStream) {
- CFIndex bytesRead = CFReadStreamRead(form->currentStream, buffer, bufferLength);
- if (bytesRead < 0) {
- *error = CFReadStreamGetError(form->currentStream);
- return -1;
- }
- if (bytesRead > 0) {
- error->error = 0;
- *atEOF = FALSE;
- return bytesRead;
- }
- openNextStream(form);
- }
-
- error->error = 0;
- *atEOF = TRUE;
- return 0;
-}
-
-static Boolean formCanRead(CFReadStreamRef stream, void* context)
-{
- FormStreamFields* form = static_cast<FormStreamFields*>(context);
-
- while (form->currentStream && CFReadStreamGetStatus(form->currentStream) == kCFStreamStatusAtEnd) {
- openNextStream(form);
- }
- if (!form->currentStream) {
- CFReadStreamSignalEvent(stream, kCFStreamEventEndEncountered, 0);
- return FALSE;
- }
- return CFReadStreamHasBytesAvailable(form->currentStream);
-}
-
-static void formClose(CFReadStreamRef stream, void* context)
-{
- FormStreamFields* form = static_cast<FormStreamFields*>(context);
-
- closeCurrentStream(form);
-}
-
-static void formSchedule(CFReadStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void* context)
-{
- FormStreamFields* form = static_cast<FormStreamFields*>(context);
-
- if (form->currentStream)
- CFReadStreamScheduleWithRunLoop(form->currentStream, runLoop, runLoopMode);
- SchedulePair pair = { runLoop, runLoopMode };
- CFSetAddValue(form->scheduledRunLoopPairs, &pair);
-}
-
-static void formUnschedule(CFReadStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void* context)
-{
- FormStreamFields* form = static_cast<FormStreamFields*>(context);
-
- if (form->currentStream)
- CFReadStreamUnscheduleFromRunLoop(form->currentStream, runLoop, runLoopMode);
- SchedulePair pair = { runLoop, runLoopMode };
- CFSetRemoveValue(form->scheduledRunLoopPairs, &pair);
-}
-
-static void formEventCallback(CFReadStreamRef stream, CFStreamEventType type, void* context)
-{
- FormStreamFields* form = static_cast<FormStreamFields*>(context);
-
- switch (type) {
- case kCFStreamEventHasBytesAvailable:
- CFReadStreamSignalEvent(form->formStream, kCFStreamEventHasBytesAvailable, 0);
- break;
- case kCFStreamEventErrorOccurred: {
- CFStreamError readStreamError = CFReadStreamGetError(stream);
- CFReadStreamSignalEvent(form->formStream, kCFStreamEventErrorOccurred, &readStreamError);
- break;
- }
- case kCFStreamEventEndEncountered:
- openNextStream(form);
- if (!form->currentStream)
- CFReadStreamSignalEvent(form->formStream, kCFStreamEventEndEncountered, 0);
- break;
- case kCFStreamEventNone:
- LOG_ERROR("unexpected kCFStreamEventNone");
- break;
- case kCFStreamEventOpenCompleted:
- LOG_ERROR("unexpected kCFStreamEventOpenCompleted");
- break;
- case kCFStreamEventCanAcceptBytes:
- LOG_ERROR("unexpected kCFStreamEventCanAcceptBytes");
- break;
- }
-}
-
-void setHTTPBody(CFMutableURLRequestRef request, PassRefPtr<FormData> formData)
-{
- if (!formData) {
- if (wkCanAccessCFURLRequestHTTPBodyParts())
- wkCFURLRequestSetHTTPRequestBodyParts(request, 0);
- return;
- }
-
- size_t count = formData->elements().size();
-
- if (count == 0)
- return;
-
- // Handle the common special case of one piece of form data, with no files.
- if (count == 1) {
- const FormDataElement& element = formData->elements()[0];
- if (element.m_type == FormDataElement::data) {
- CFDataRef data = CFDataCreate(0, reinterpret_cast<const UInt8 *>(element.m_data.data()), element.m_data.size());
- CFURLRequestSetHTTPRequestBody(request, data);
- CFRelease(data);
- return;
- }
- }
-
- if (wkCanAccessCFURLRequestHTTPBodyParts()) {
- RetainPtr<CFMutableArrayRef> array(AdoptCF, CFArrayCreateMutable(0, 0, &kCFTypeArrayCallBacks));
-
- for (size_t i = 0; i < count; ++i) {
- const FormDataElement& element = formData->elements()[i];
- if (element.m_type == FormDataElement::data) {
- RetainPtr<CFDataRef> data(AdoptCF, CFDataCreate(0, reinterpret_cast<const UInt8*>(element.m_data.data()), element.m_data.size()));
- CFArrayAppendValue(array.get(), data.get());
- } else {
- RetainPtr<CFStringRef> filename(AdoptCF, element.m_filename.createCFString());
- CFArrayAppendValue(array.get(), filename.get());
- }
- }
-
- wkCFURLRequestSetHTTPRequestBodyParts(request, array.get());
- return;
- }
-
- // Precompute the content length so CFURLConnection doesn't use chunked mode.
- bool haveLength = true;
- long long length = 0;
- for (size_t i = 0; i < count; ++i) {
- const FormDataElement& element = formData->elements()[i];
- if (element.m_type == FormDataElement::data)
- length += element.m_data.size();
- else {
- long long size;
- if (getFileSize(element.m_filename, size))
- length += size;
- else
- haveLength = false;
- }
- }
-
- if (haveLength) {
- CFStringRef lengthStr = CFStringCreateWithFormat(0, 0, CFSTR("%lld"), length);
- CFURLRequestSetHTTPHeaderFieldValue(request, CFSTR("Content-Length"), lengthStr);
- CFRelease(lengthStr);
- }
-
- static WCReadStreamCallBacks formDataStreamCallbacks =
- { 1, formCreate, formFinalize, 0, formOpen, 0, formRead, 0, formCanRead, formClose, 0, 0, 0, formSchedule, formUnschedule };
-
- CFReadStreamRef stream = CFReadStreamCreate(0, (CFReadStreamCallBacks *)&formDataStreamCallbacks, formData.releaseRef());
- CFURLRequestSetHTTPRequestBodyStream(request, stream);
- CFRelease(stream);
-}
-
-PassRefPtr<FormData> httpBodyFromRequest(CFURLRequestRef request)
-{
- if (RetainPtr<CFDataRef> bodyData = CFURLRequestCopyHTTPRequestBody(request))
- return FormData::create(CFDataGetBytePtr(bodyData.get()), CFDataGetLength(bodyData.get()));
-
- if (wkCanAccessCFURLRequestHTTPBodyParts()) {
- if (RetainPtr<CFArrayRef> bodyParts = wkCFURLRequestCopyHTTPRequestBodyParts(request)) {
- RefPtr<FormData> formData = FormData::create();
-
- CFIndex count = CFArrayGetCount(bodyParts.get());
- for (CFIndex i = 0; i < count; i++) {
- CFTypeRef bodyPart = CFArrayGetValueAtIndex(bodyParts.get(), i);
- CFTypeID typeID = CFGetTypeID(bodyPart);
- if (typeID == CFStringGetTypeID()) {
- String filename = (CFStringRef)bodyPart;
- formData->appendFile(filename);
- } else if (typeID == CFDataGetTypeID()) {
- CFDataRef data = (CFDataRef)bodyPart;
- formData->appendData(CFDataGetBytePtr(data), CFDataGetLength(data));
- } else
- ASSERT_NOT_REACHED();
- }
- return formData.release();
- }
- } else {
- if (RetainPtr<CFReadStreamRef> bodyStream = CFURLRequestCopyHTTPRequestBodyStream(request))
- return getStreamFormDatas().get(bodyStream.get());
- }
-
- // FIXME: what to do about arbitrary body streams?
- return 0;
-}
-
-}
diff --git a/WebCore/platform/network/cf/FormDataStreamCFNet.h b/WebCore/platform/network/cf/FormDataStreamCFNet.h
deleted file mode 100644
index 254a2cd..0000000
--- a/WebCore/platform/network/cf/FormDataStreamCFNet.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef FormDataStreamCFNet_h_
-#define FormDataStreamCFNet_h_
-
-#include <CoreFoundation/CoreFoundation.h>
-#include <wtf/Forward.h>
-
-typedef struct _CFURLRequest* CFMutableURLRequestRef;
-typedef const struct _CFURLRequest* CFURLRequestRef;
-
-namespace WebCore {
- class FormData;
- void setHTTPBody(CFMutableURLRequestRef, PassRefPtr<FormData>);
- PassRefPtr<FormData> httpBodyFromRequest(CFURLRequestRef);
-}
-
-#endif FormDataStreamCFNet_h_
diff --git a/WebCore/platform/network/cf/ResourceError.h b/WebCore/platform/network/cf/ResourceError.h
deleted file mode 100644
index 10f1208..0000000
--- a/WebCore/platform/network/cf/ResourceError.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ResourceError_h
-#define ResourceError_h
-
-#include "ResourceErrorBase.h"
-
-#include <wtf/RetainPtr.h>
-#include <CoreFoundation/CFStream.h>
-
-namespace WebCore {
-
-class ResourceError : public ResourceErrorBase {
-public:
- ResourceError()
- : m_dataIsUpToDate(true)
- {
- }
-
- ResourceError(const String& domain, int errorCode, const String& failingURL, const String& localizedDescription)
- : ResourceErrorBase(domain, errorCode, failingURL, localizedDescription)
- , m_dataIsUpToDate(true)
- {
- }
-
- ResourceError(CFStreamError error);
-
- ResourceError(CFErrorRef error)
- : m_dataIsUpToDate(false)
- , m_platformError(error)
- {
- m_isNull = !error;
- }
-
- operator CFErrorRef() const;
- operator CFStreamError() const;
-
-private:
- friend class ResourceErrorBase;
-
- void platformLazyInit();
- static bool platformCompare(const ResourceError& a, const ResourceError& b);
-
- bool m_dataIsUpToDate;
- mutable RetainPtr<CFErrorRef> m_platformError;
-};
-
-} // namespace WebCore
-
-#endif // ResourceError_h_
diff --git a/WebCore/platform/network/cf/ResourceErrorCF.cpp b/WebCore/platform/network/cf/ResourceErrorCF.cpp
deleted file mode 100644
index 8e82cd5..0000000
--- a/WebCore/platform/network/cf/ResourceErrorCF.cpp
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "KURL.h"
-#include "ResourceError.h"
-
-#if USE(CFNETWORK)
-
-// FIXME: Once <rdar://problem/5050881> is fixed in open source we
-// can remove this extern "C"
-extern "C" {
-#include <CFNetwork/CFNetworkErrors.h>
-}
-
-#include <CoreFoundation/CFError.h>
-#include <WTF/RetainPtr.h>
-
-namespace WebCore {
-
-const CFStringRef failingURLStringKey = CFSTR("NSErrorFailingURLStringKey");
-const CFStringRef failingURLKey = CFSTR("NSErrorFailingURLKey");
-
-// FIXME: Once <rdar://problem/5050841> is fixed we can remove this constructor.
-ResourceError::ResourceError(CFStreamError error)
- : m_dataIsUpToDate(true)
-{
- m_isNull = false;
- m_errorCode = error.error;
-
- switch(error.domain) {
- case kCFStreamErrorDomainCustom:
- m_domain ="NSCustomErrorDomain";
- break;
- case kCFStreamErrorDomainPOSIX:
- m_domain = "NSPOSIXErrorDomain";
- break;
- case kCFStreamErrorDomainMacOSStatus:
- m_domain = "NSOSStatusErrorDomain";
- break;
- }
-}
-
-void ResourceError::platformLazyInit()
-{
- if (m_dataIsUpToDate)
- return;
-
- if (!m_platformError)
- return;
-
- CFStringRef domain = CFErrorGetDomain(m_platformError.get());
- if (domain == kCFErrorDomainMach || domain == kCFErrorDomainCocoa)
- m_domain ="NSCustomErrorDomain";
- else if (domain == kCFErrorDomainCFNetwork)
- m_domain = "CFURLErrorDomain";
- else if (domain == kCFErrorDomainPOSIX)
- m_domain = "NSPOSIXErrorDomain";
- else if (domain == kCFErrorDomainOSStatus)
- m_domain = "NSOSStatusErrorDomain";
- else if (domain == kCFErrorDomainWinSock)
- m_domain = "kCFErrorDomainWinSock";
-
- m_errorCode = CFErrorGetCode(m_platformError.get());
-
- RetainPtr<CFDictionaryRef> userInfo(AdoptCF, CFErrorCopyUserInfo(m_platformError.get()));
- if (userInfo.get()) {
- CFStringRef failingURLString = (CFStringRef) CFDictionaryGetValue(userInfo.get(), failingURLStringKey);
- if (failingURLString)
- m_failingURL = String(failingURLString);
- else {
- CFURLRef failingURL = (CFURLRef) CFDictionaryGetValue(userInfo.get(), failingURLKey);
- if (failingURL) {
- RetainPtr<CFURLRef> absoluteURLRef(AdoptCF, CFURLCopyAbsoluteURL(failingURL));
- if (absoluteURLRef.get()) {
- failingURLString = CFURLGetString(absoluteURLRef.get());
- m_failingURL = String(failingURLString);
- }
- }
- }
- m_localizedDescription = (CFStringRef) CFDictionaryGetValue(userInfo.get(), kCFErrorLocalizedDescriptionKey);
- }
-
- m_dataIsUpToDate = true;
-}
-
-bool ResourceError::platformCompare(const ResourceError& a, const ResourceError& b)
-{
- return (CFErrorRef)a == (CFErrorRef)b;
-}
-
-ResourceError::operator CFErrorRef() const
-{
- if (m_isNull) {
- ASSERT(!m_platformError);
- return nil;
- }
-
- if (!m_platformError) {
- RetainPtr<CFMutableDictionaryRef> userInfo(AdoptCF, CFDictionaryCreateMutable(0, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
-
- if (!m_localizedDescription.isEmpty()) {
- RetainPtr<CFStringRef> localizedDescriptionString(AdoptCF, m_localizedDescription.createCFString());
- CFDictionarySetValue(userInfo.get(), kCFErrorLocalizedDescriptionKey, localizedDescriptionString.get());
- }
-
- if (!m_failingURL.isEmpty()) {
- RetainPtr<CFStringRef> failingURLString(AdoptCF, m_failingURL.createCFString());
- CFDictionarySetValue(userInfo.get(), failingURLStringKey, failingURLString.get());
- RetainPtr<CFURLRef> url(AdoptCF, KURL(m_failingURL).createCFURL());
- CFDictionarySetValue(userInfo.get(), failingURLKey, url.get());
- }
-
- RetainPtr<CFStringRef> domainString(AdoptCF, m_domain.createCFString());
- m_platformError.adoptCF(CFErrorCreate(0, domainString.get(), m_errorCode, userInfo.get()));
- }
-
- return m_platformError.get();
-}
-
-ResourceError::operator CFStreamError() const
-{
- lazyInit();
-
- CFStreamError result;
- result.error = m_errorCode;
-
- if (m_domain == "NSCustomErrorDomain")
- result.domain = kCFStreamErrorDomainCustom;
- else if (m_domain == "NSPOSIXErrorDomain")
- result.domain = kCFStreamErrorDomainPOSIX;
- else if (m_domain == "NSOSStatusErrorDomain")
- result.domain = kCFStreamErrorDomainMacOSStatus;
- else
- ASSERT_NOT_REACHED();
-
- return result;
-}
-
-} // namespace WebCore
-
-#endif // USE(CFNETWORK)
diff --git a/WebCore/platform/network/cf/ResourceHandleCFNet.cpp b/WebCore/platform/network/cf/ResourceHandleCFNet.cpp
deleted file mode 100644
index fa7947f..0000000
--- a/WebCore/platform/network/cf/ResourceHandleCFNet.cpp
+++ /dev/null
@@ -1,443 +0,0 @@
-/*
- * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "ResourceHandle.h"
-#include "ResourceHandleClient.h"
-#include "ResourceHandleInternal.h"
-
-#include "AuthenticationCF.h"
-#include "AuthenticationChallenge.h"
-#include "CookieStorageWin.h"
-#include "CString.h"
-#include "DocLoader.h"
-#include "Frame.h"
-#include "FrameLoader.h"
-#include "Logging.h"
-#include "NotImplemented.h"
-#include "ResourceError.h"
-#include "ResourceResponse.h"
-
-#include <wtf/HashMap.h>
-#include <wtf/Threading.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <process.h> // for _beginthread()
-
-#include <CFNetwork/CFNetwork.h>
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
-
-namespace WebCore {
-
-static HashSet<String>& allowsAnyHTTPSCertificateHosts()
-{
- static HashSet<String> hosts;
-
- return hosts;
-}
-
-static HashMap<String, RetainPtr<CFDataRef> >& clientCerts()
-{
- static HashMap<String, RetainPtr<CFDataRef> > certs;
- return certs;
-}
-
-CFURLRequestRef willSendRequest(CFURLConnectionRef conn, CFURLRequestRef cfRequest, CFURLResponseRef cfRedirectResponse, const void* clientInfo)
-{
- ResourceHandle* handle = (ResourceHandle*)clientInfo;
-
- if (!cfRedirectResponse) {
- CFRetain(cfRequest);
- return cfRequest;
- }
-
- LOG(Network, "CFNet - willSendRequest(conn=%p, handle=%p) (%s)", conn, handle, handle->request().url().string().utf8().data());
-
- ResourceRequest request(cfRequest);
- if (handle->client())
- handle->client()->willSendRequest(handle, request, cfRedirectResponse);
-
- cfRequest = request.cfURLRequest();
-
- CFRetain(cfRequest);
- return cfRequest;
-}
-
-void didReceiveResponse(CFURLConnectionRef conn, CFURLResponseRef cfResponse, const void* clientInfo)
-{
- ResourceHandle* handle = (ResourceHandle*)clientInfo;
-
- LOG(Network, "CFNet - didReceiveResponse(conn=%p, handle=%p) (%s)", conn, handle, handle->request().url().string().utf8().data());
-
- if (handle->client())
- handle->client()->didReceiveResponse(handle, cfResponse);
-}
-
-void didReceiveData(CFURLConnectionRef conn, CFDataRef data, CFIndex originalLength, const void* clientInfo)
-{
- ResourceHandle* handle = (ResourceHandle*)clientInfo;
- const UInt8* bytes = CFDataGetBytePtr(data);
- CFIndex length = CFDataGetLength(data);
-
- LOG(Network, "CFNet - didReceiveData(conn=%p, handle=%p, bytes=%d) (%s)", conn, handle, length, handle->request().url().string().utf8().data());
-
- if (handle->client())
- handle->client()->didReceiveData(handle, (const char*)bytes, length, originalLength);
-}
-
-void didFinishLoading(CFURLConnectionRef conn, const void* clientInfo)
-{
- ResourceHandle* handle = (ResourceHandle*)clientInfo;
-
- LOG(Network, "CFNet - didFinishLoading(conn=%p, handle=%p) (%s)", conn, handle, handle->request().url().string().utf8().data());
-
- if (handle->client())
- handle->client()->didFinishLoading(handle);
-}
-
-void didFail(CFURLConnectionRef conn, CFErrorRef error, const void* clientInfo)
-{
- ResourceHandle* handle = (ResourceHandle*)clientInfo;
-
- LOG(Network, "CFNet - didFail(conn=%p, handle=%p, error = %p) (%s)", conn, handle, error, handle->request().url().string().utf8().data());
-
- if (handle->client())
- handle->client()->didFail(handle, ResourceError(error));
-}
-
-CFCachedURLResponseRef willCacheResponse(CFURLConnectionRef conn, CFCachedURLResponseRef cachedResponse, const void* clientInfo)
-{
- ResourceHandle* handle = (ResourceHandle*)clientInfo;
-
- CacheStoragePolicy policy = static_cast<CacheStoragePolicy>(CFCachedURLResponseGetStoragePolicy(cachedResponse));
-
- if (handle->client())
- handle->client()->willCacheResponse(handle, policy);
-
- if (static_cast<CFURLCacheStoragePolicy>(policy) != CFCachedURLResponseGetStoragePolicy(cachedResponse))
- cachedResponse = CFCachedURLResponseCreateWithUserInfo(kCFAllocatorDefault,
- CFCachedURLResponseGetWrappedResponse(cachedResponse),
- CFCachedURLResponseGetReceiverData(cachedResponse),
- CFCachedURLResponseGetUserInfo(cachedResponse),
- static_cast<CFURLCacheStoragePolicy>(policy));
- CFRetain(cachedResponse);
-
- return cachedResponse;
-}
-
-void didReceiveChallenge(CFURLConnectionRef conn, CFURLAuthChallengeRef challenge, const void* clientInfo)
-{
- ResourceHandle* handle = (ResourceHandle*)clientInfo;
- ASSERT(handle);
- LOG(Network, "CFNet - didReceiveChallenge(conn=%p, handle=%p (%s)", conn, handle, handle->request().url().string().utf8().data());
-
- handle->didReceiveAuthenticationChallenge(AuthenticationChallenge(challenge, handle));
-}
-
-void addHeadersFromHashMap(CFMutableURLRequestRef request, const HTTPHeaderMap& requestHeaders)
-{
- if (!requestHeaders.size())
- return;
-
- HTTPHeaderMap::const_iterator end = requestHeaders.end();
- for (HTTPHeaderMap::const_iterator it = requestHeaders.begin(); it != end; ++it) {
- CFStringRef key = it->first.createCFString();
- CFStringRef value = it->second.createCFString();
- CFURLRequestSetHTTPHeaderFieldValue(request, key, value);
- CFRelease(key);
- CFRelease(value);
- }
-}
-
-ResourceHandleInternal::~ResourceHandleInternal()
-{
- if (m_connection) {
- LOG(Network, "CFNet - Cancelling connection %p (%s)", m_connection, m_request.url().string().utf8().data());
- CFURLConnectionCancel(m_connection.get());
- }
-}
-
-ResourceHandle::~ResourceHandle()
-{
- LOG(Network, "CFNet - Destroying job %p (%s)", this, d->m_request.url().string().utf8().data());
-}
-
-CFArrayRef arrayFromFormData(const FormData& d)
-{
- size_t size = d.elements().size();
- CFMutableArrayRef a = CFArrayCreateMutable(0, d.elements().size(), &kCFTypeArrayCallBacks);
- for (size_t i = 0; i < size; ++i) {
- const FormDataElement& e = d.elements()[i];
- if (e.m_type == FormDataElement::data) {
- CFDataRef data = CFDataCreate(0, (const UInt8*)e.m_data.data(), e.m_data.size());
- CFArrayAppendValue(a, data);
- CFRelease(data);
- } else {
- ASSERT(e.m_type == FormDataElement::encodedFile);
- CFStringRef filename = e.m_filename.createCFString();
- CFArrayAppendValue(a, filename);
- CFRelease(filename);
- }
- }
- return a;
-}
-
-void emptyPerform(void* unused)
-{
-}
-
-static CFRunLoopRef loaderRL = 0;
-void* runLoaderThread(void *unused)
-{
- loaderRL = CFRunLoopGetCurrent();
-
- // Must add a source to the run loop to prevent CFRunLoopRun() from exiting
- CFRunLoopSourceContext ctxt = {0, (void *)1 /*must be non-NULL*/, 0, 0, 0, 0, 0, 0, 0, emptyPerform};
- CFRunLoopSourceRef bogusSource = CFRunLoopSourceCreate(0, 0, &ctxt);
- CFRunLoopAddSource(loaderRL, bogusSource,kCFRunLoopDefaultMode);
-
- CFRunLoopRun();
-
- return 0;
-}
-
-CFRunLoopRef ResourceHandle::loaderRunLoop()
-{
- if (!loaderRL) {
- createThread(runLoaderThread, 0, "CFNetwork::Loader");
- while (loaderRL == 0) {
- // FIXME: sleep 10? that can't be right...
- Sleep(10);
- }
- }
- return loaderRL;
-}
-
-static CFURLRequestRef makeFinalRequest(const ResourceRequest& request, bool shouldContentSniff)
-{
- CFMutableURLRequestRef newRequest = CFURLRequestCreateMutableCopy(kCFAllocatorDefault, request.cfURLRequest());
-
- if (!shouldContentSniff)
- wkSetCFURLRequestShouldContentSniff(newRequest, false);
-
- RetainPtr<CFMutableDictionaryRef> sslProps;
-
- if (allowsAnyHTTPSCertificateHosts().contains(request.url().host().lower())) {
- sslProps.adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
- CFDictionaryAddValue(sslProps.get(), kCFStreamSSLAllowsAnyRoot, kCFBooleanTrue);
- CFDictionaryAddValue(sslProps.get(), kCFStreamSSLAllowsExpiredRoots, kCFBooleanTrue);
- }
-
- HashMap<String, RetainPtr<CFDataRef> >::iterator clientCert = clientCerts().find(request.url().host().lower());
- if (clientCert != clientCerts().end()) {
- if (!sslProps)
- sslProps.adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
- wkSetClientCertificateInSSLProperties(sslProps.get(), (clientCert->second).get());
- }
-
- if (sslProps)
- CFURLRequestSetSSLProperties(newRequest, sslProps.get());
-
- if (CFHTTPCookieStorageRef cookieStorage = currentCookieStorage()) {
- CFURLRequestSetHTTPCookieStorage(newRequest, cookieStorage);
- CFURLRequestSetHTTPCookieStorageAcceptPolicy(newRequest, CFHTTPCookieStorageGetCookieAcceptPolicy(cookieStorage));
- }
-
- return newRequest;
-}
-
-bool ResourceHandle::start(Frame* frame)
-{
- // If we are no longer attached to a Page, this must be an attempted load from an
- // onUnload handler, so let's just block it.
- if (!frame->page())
- return false;
-
- RetainPtr<CFURLRequestRef> request(AdoptCF, makeFinalRequest(d->m_request, d->m_shouldContentSniff));
-
- // CFURLConnection Callback API currently at version 1
- const int CFURLConnectionClientVersion = 1;
- CFURLConnectionClient client = {CFURLConnectionClientVersion, this, 0, 0, 0, willSendRequest, didReceiveResponse, didReceiveData, NULL, didFinishLoading, didFail, willCacheResponse, didReceiveChallenge};
-
- d->m_connection.adoptCF(CFURLConnectionCreate(0, request.get(), &client));
-
- CFURLConnectionScheduleWithCurrentMessageQueue(d->m_connection.get());
- CFURLConnectionScheduleDownloadWithRunLoop(d->m_connection.get(), loaderRunLoop(), kCFRunLoopDefaultMode);
- CFURLConnectionStart(d->m_connection.get());
-
- LOG(Network, "CFNet - Starting URL %s (handle=%p, conn=%p)", d->m_request.url().string().utf8().data(), this, d->m_connection);
-
- return true;
-}
-
-void ResourceHandle::cancel()
-{
- if (d->m_connection) {
- CFURLConnectionCancel(d->m_connection.get());
- d->m_connection = 0;
- }
-}
-
-PassRefPtr<SharedBuffer> ResourceHandle::bufferedData()
-{
- ASSERT_NOT_REACHED();
- return 0;
-}
-
-bool ResourceHandle::supportsBufferedData()
-{
- return false;
-}
-
-void ResourceHandle::didReceiveAuthenticationChallenge(const AuthenticationChallenge& challenge)
-{
- LOG(Network, "CFNet - didReceiveAuthenticationChallenge()");
- ASSERT(!d->m_currentCFChallenge);
- ASSERT(d->m_currentWebChallenge.isNull());
- // Since CFURLConnection networking relies on keeping a reference to the original CFURLAuthChallengeRef,
- // we make sure that is actually present
- ASSERT(challenge.cfURLAuthChallengeRef());
-
- d->m_currentCFChallenge = challenge.cfURLAuthChallengeRef();
- d->m_currentWebChallenge = AuthenticationChallenge(d->m_currentCFChallenge, this);
-
- if (client())
- client()->didReceiveAuthenticationChallenge(this, d->m_currentWebChallenge);
-}
-
-void ResourceHandle::receivedCredential(const AuthenticationChallenge& challenge, const Credential& credential)
-{
- LOG(Network, "CFNet - receivedCredential()");
- ASSERT(!challenge.isNull());
- ASSERT(challenge.cfURLAuthChallengeRef());
- if (challenge != d->m_currentWebChallenge)
- return;
-
- CFURLCredentialRef cfCredential = createCF(credential);
- CFURLConnectionUseCredential(d->m_connection.get(), cfCredential, challenge.cfURLAuthChallengeRef());
- CFRelease(cfCredential);
-
- clearAuthentication();
-}
-
-void ResourceHandle::receivedRequestToContinueWithoutCredential(const AuthenticationChallenge& challenge)
-{
- LOG(Network, "CFNet - receivedRequestToContinueWithoutCredential()");
- ASSERT(!challenge.isNull());
- ASSERT(challenge.cfURLAuthChallengeRef());
- if (challenge != d->m_currentWebChallenge)
- return;
-
- CFURLConnectionUseCredential(d->m_connection.get(), 0, challenge.cfURLAuthChallengeRef());
-
- clearAuthentication();
-}
-
-void ResourceHandle::receivedCancellation(const AuthenticationChallenge& challenge)
-{
- LOG(Network, "CFNet - receivedCancellation()");
- if (challenge != d->m_currentWebChallenge)
- return;
-
- if (client())
- client()->receivedCancellation(this, challenge);
-}
-
-CFURLConnectionRef ResourceHandle::connection() const
-{
- return d->m_connection.get();
-}
-
-CFURLConnectionRef ResourceHandle::releaseConnectionForDownload()
-{
- LOG(Network, "CFNet - Job %p releasing connection %p for download", this, d->m_connection.get());
- return d->m_connection.releaseRef();
-}
-
-void ResourceHandle::loadResourceSynchronously(const ResourceRequest& request, ResourceError& error, ResourceResponse& response, Vector<char>& vector, Frame*)
-{
- ASSERT(!request.isEmpty());
- CFURLResponseRef cfResponse = 0;
- CFErrorRef cfError = 0;
- RetainPtr<CFURLRequestRef> cfRequest(AdoptCF, makeFinalRequest(request, true));
-
- CFDataRef data = CFURLConnectionSendSynchronousRequest(cfRequest.get(), &cfResponse, &cfError, request.timeoutInterval());
-
- if (cfError) {
- error = cfError;
- CFRelease(cfError);
-
- response = ResourceResponse(request.url(), String(), 0, String(), String());
- response.setHTTPStatusCode(404);
- } else {
- response = cfResponse;
- if (cfResponse)
- CFRelease(cfResponse);
- }
-
- if (data) {
- ASSERT(vector.isEmpty());
- vector.append(CFDataGetBytePtr(data), CFDataGetLength(data));
- CFRelease(data);
- }
-}
-
-void ResourceHandle::setHostAllowsAnyHTTPSCertificate(const String& host)
-{
- allowsAnyHTTPSCertificateHosts().add(host.lower());
-}
-
-void ResourceHandle::setClientCertificate(const String& host, CFDataRef cert)
-{
- clientCerts().set(host.lower(), cert);
-}
-
-void ResourceHandle::setDefersLoading(bool defers)
-{
- if (!d->m_connection)
- return;
-
- if (defers)
- CFURLConnectionHalt(d->m_connection.get());
- else
- CFURLConnectionResume(d->m_connection.get());
-}
-
-bool ResourceHandle::loadsBlocked()
-{
- return false;
-}
-
-bool ResourceHandle::willLoadFromCache(ResourceRequest&)
-{
- // Not having this function means that we'll ask the user about re-posting a form
- // even when we go back to a page that's still in the cache.
- notImplemented();
- return false;
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/network/cf/ResourceRequest.h b/WebCore/platform/network/cf/ResourceRequest.h
deleted file mode 100644
index a4e9749..0000000
--- a/WebCore/platform/network/cf/ResourceRequest.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ResourceRequest_h
-#define ResourceRequest_h
-
-#include "ResourceRequestBase.h"
-
-#include <wtf/RetainPtr.h>
-typedef const struct _CFURLRequest* CFURLRequestRef;
-
-namespace WebCore {
-
- struct ResourceRequest : ResourceRequestBase {
-
- ResourceRequest(const String& url)
- : ResourceRequestBase(KURL(url), UseProtocolCachePolicy)
- {
- }
-
- ResourceRequest(const KURL& url)
- : ResourceRequestBase(url, UseProtocolCachePolicy)
- {
- }
-
- ResourceRequest(const KURL& url, const String& referrer, ResourceRequestCachePolicy policy = UseProtocolCachePolicy)
- : ResourceRequestBase(url, policy)
- {
- setHTTPReferrer(referrer);
- }
-
- ResourceRequest()
- : ResourceRequestBase(KURL(), UseProtocolCachePolicy)
- {
- }
-
- ResourceRequest(CFURLRequestRef cfRequest)
- : ResourceRequestBase()
- , m_cfRequest(cfRequest) { }
-
- CFURLRequestRef cfURLRequest() const;
-
- private:
- friend struct ResourceRequestBase;
-
- void doUpdatePlatformRequest();
- void doUpdateResourceRequest();
-
- RetainPtr<CFURLRequestRef> m_cfRequest;
- };
-
-} // namespace WebCore
-
-#endif // ResourceRequest_h
diff --git a/WebCore/platform/network/cf/ResourceRequestCFNet.cpp b/WebCore/platform/network/cf/ResourceRequestCFNet.cpp
deleted file mode 100644
index b73df13..0000000
--- a/WebCore/platform/network/cf/ResourceRequestCFNet.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ResourceRequestCFNet.h"
-
-#include "FormDataStreamCFNet.h"
-#include "ResourceRequest.h"
-
-#include <CFNetwork/CFURLRequestPriv.h>
-
-namespace WebCore {
-
-CFURLRequestRef ResourceRequest::cfURLRequest() const
-{
- updatePlatformRequest();
-
- return m_cfRequest.get();
-}
-
-static inline void addHeadersFromHashMap(CFMutableURLRequestRef request, const HTTPHeaderMap& requestHeaders)
-{
- if (!requestHeaders.size())
- return;
-
- HTTPHeaderMap::const_iterator end = requestHeaders.end();
- for (HTTPHeaderMap::const_iterator it = requestHeaders.begin(); it != end; ++it) {
- CFStringRef key = it->first.createCFString();
- CFStringRef value = it->second.createCFString();
- CFURLRequestSetHTTPHeaderFieldValue(request, key, value);
- CFRelease(key);
- CFRelease(value);
- }
-}
-
-void ResourceRequest::doUpdatePlatformRequest()
-{
- CFMutableURLRequestRef cfRequest;
-
- RetainPtr<CFURLRef> url(AdoptCF, ResourceRequest::url().createCFURL());
- RetainPtr<CFURLRef> mainDocumentURL(AdoptCF, ResourceRequest::mainDocumentURL().createCFURL());
- if (m_cfRequest) {
- cfRequest = CFURLRequestCreateMutableCopy(0, m_cfRequest.get());
- CFURLRequestSetURL(cfRequest, url.get());
- CFURLRequestSetMainDocumentURL(cfRequest, mainDocumentURL.get());
- } else {
- cfRequest = CFURLRequestCreateMutable(0, url.get(), (CFURLRequestCachePolicy)cachePolicy(), timeoutInterval(), mainDocumentURL.get());
- }
-
- RetainPtr<CFStringRef> requestMethod(AdoptCF, httpMethod().createCFString());
- CFURLRequestSetHTTPRequestMethod(cfRequest, requestMethod.get());
-
- addHeadersFromHashMap(cfRequest, httpHeaderFields());
- WebCore::setHTTPBody(cfRequest, httpBody());
- CFURLRequestSetShouldHandleHTTPCookies(cfRequest, allowHTTPCookies());
-
- if (m_cfRequest) {
- RetainPtr<CFHTTPCookieStorageRef> cookieStorage(AdoptCF, CFURLRequestCopyHTTPCookieStorage(m_cfRequest.get()));
- if (cookieStorage)
- CFURLRequestSetHTTPCookieStorage(cfRequest, cookieStorage.get());
- CFURLRequestSetHTTPCookieStorageAcceptPolicy(cfRequest, CFURLRequestGetHTTPCookieStorageAcceptPolicy(m_cfRequest.get()));
- CFURLRequestSetSSLProperties(cfRequest, CFURLRequestGetSSLProperties(m_cfRequest.get()));
- }
-
- m_cfRequest.adoptCF(cfRequest);
-}
-
-void ResourceRequest::doUpdateResourceRequest()
-{
- m_url = CFURLRequestGetURL(m_cfRequest.get());
-
- m_cachePolicy = (ResourceRequestCachePolicy)CFURLRequestGetCachePolicy(m_cfRequest.get());
- m_timeoutInterval = CFURLRequestGetTimeoutInterval(m_cfRequest.get());
- m_mainDocumentURL = CFURLRequestGetMainDocumentURL(m_cfRequest.get());
- if (CFStringRef method = CFURLRequestCopyHTTPRequestMethod(m_cfRequest.get())) {
- m_httpMethod = method;
- CFRelease(method);
- }
- m_allowHTTPCookies = CFURLRequestShouldHandleHTTPCookies(m_cfRequest.get());
-
- if (CFDictionaryRef headers = CFURLRequestCopyAllHTTPHeaderFields(m_cfRequest.get())) {
- CFIndex headerCount = CFDictionaryGetCount(headers);
- Vector<const void*, 128> keys(headerCount);
- Vector<const void*, 128> values(headerCount);
- CFDictionaryGetKeysAndValues(headers, keys.data(), values.data());
- for (int i = 0; i < headerCount; ++i)
- m_httpHeaderFields.set((CFStringRef)keys[i], (CFStringRef)values[i]);
- CFRelease(headers);
- }
-
- m_httpBody = httpBodyFromRequest(m_cfRequest.get());
-}
-
-}
diff --git a/WebCore/platform/network/cf/ResourceRequestCFNet.h b/WebCore/platform/network/cf/ResourceRequestCFNet.h
deleted file mode 100644
index e9ebe76..0000000
--- a/WebCore/platform/network/cf/ResourceRequestCFNet.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ResourceRequestCFNet_h
-#define ResourceRequestCFNet_h
-
-typedef const struct _CFURLRequest* CFURLRequestRef;
-
-namespace WebCore {
-
- class ResourceRequest;
-
- void getResourceRequest(ResourceRequest&, CFURLRequestRef);
- CFURLRequestRef cfURLRequest(const ResourceRequest&);
-}
-
-#endif // ResourceRequestCFNet_h
diff --git a/WebCore/platform/network/cf/ResourceResponse.h b/WebCore/platform/network/cf/ResourceResponse.h
deleted file mode 100644
index e14c79e..0000000
--- a/WebCore/platform/network/cf/ResourceResponse.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef ResourceResponse_h
-#define ResourceResponse_h
-
-#include "ResourceResponseBase.h"
-#include <wtf/RetainPtr.h>
-
-typedef struct _CFURLResponse* CFURLResponseRef;
-
-namespace WebCore {
-
-class ResourceResponse : public ResourceResponseBase {
-public:
- ResourceResponse()
- : m_isUpToDate(true)
- {
- }
-
- ResourceResponse(CFURLResponseRef cfResponse)
- : m_cfResponse(cfResponse)
- , m_isUpToDate(false)
- {
- m_isNull = !cfResponse;
- }
-
- ResourceResponse(const KURL& url, const String& mimeType, long long expectedLength, const String& textEncodingName, const String& filename)
- : ResourceResponseBase(url, mimeType, expectedLength, textEncodingName, filename)
- , m_isUpToDate(true)
- {
- }
-
- CFURLResponseRef cfURLResponse() const;
-
-private:
- friend class ResourceResponseBase;
-
- void platformLazyInit();
- static bool platformCompare(const ResourceResponse& a, const ResourceResponse& b);
-
- RetainPtr<CFURLResponseRef> m_cfResponse;
- bool m_isUpToDate;
-};
-
-} // namespace WebCore
-
-#endif // ResourceResponse_h
diff --git a/WebCore/platform/network/cf/ResourceResponseCFNet.cpp b/WebCore/platform/network/cf/ResourceResponseCFNet.cpp
deleted file mode 100644
index 79efe89..0000000
--- a/WebCore/platform/network/cf/ResourceResponseCFNet.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ResourceResponseCFNet.h"
-
-#include "HTTPParsers.h"
-#include "MIMETypeRegistry.h"
-#include "ResourceResponse.h"
-#include <CFNetwork/CFURLResponsePriv.h>
-#include <wtf/RetainPtr.h>
-
-using namespace std;
-
-// We would like a better value for a maximum time_t,
-// but there is no way to do that in C with any certainty.
-// INT_MAX should work well enough for our purposes.
-#define MAX_TIME_T ((time_t)INT_MAX)
-
-namespace WebCore {
-
-CFURLResponseRef ResourceResponse::cfURLResponse() const
-{
- return m_cfResponse.get();
-}
-
-static inline bool filenameHasSaneExtension(const String& filename)
-{
- int dot = filename.find('.');
-
- // The dot can't be the first or last character in the filename.
- int length = filename.length();
- return dot > 0 && dot < length - 1;
-}
-
-static time_t toTimeT(CFAbsoluteTime time)
-{
- static const double maxTimeAsDouble = std::numeric_limits<time_t>::max();
- static const double minTimeAsDouble = std::numeric_limits<time_t>::min();
- return min(max(minTimeAsDouble, time + kCFAbsoluteTimeIntervalSince1970), maxTimeAsDouble);
-}
-
-void ResourceResponse::platformLazyInit()
-{
- if (m_isUpToDate)
- return;
- m_isUpToDate = true;
-
- if (m_isNull) {
- ASSERT(!m_cfResponse.get());
- return;
- }
-
- // FIXME: We may need to do MIME type sniffing here (unless that is done in CFURLResponseGetMIMEType).
-
- m_url = CFURLResponseGetURL(m_cfResponse.get());
- m_mimeType = CFURLResponseGetMIMEType(m_cfResponse.get());
- m_expectedContentLength = CFURLResponseGetExpectedContentLength(m_cfResponse.get());
- m_textEncodingName = CFURLResponseGetTextEncodingName(m_cfResponse.get());
-
- m_expirationDate = toTimeT(CFURLResponseGetExpirationTime(m_cfResponse.get()));
- m_lastModifiedDate = toTimeT(CFURLResponseGetLastModifiedDate(m_cfResponse.get()));
-
- RetainPtr<CFStringRef> suggestedFilename(AdoptCF, CFURLResponseCopySuggestedFilename(m_cfResponse.get()));
- m_suggestedFilename = suggestedFilename.get();
-
- CFHTTPMessageRef httpResponse = CFURLResponseGetHTTPResponse(m_cfResponse.get());
- if (httpResponse) {
- m_httpStatusCode = CFHTTPMessageGetResponseStatusCode(httpResponse);
-
- RetainPtr<CFStringRef> statusLine(AdoptCF, CFHTTPMessageCopyResponseStatusLine(httpResponse));
- String statusText(statusLine.get());
- int spacePos = statusText.find(" ");
- if (spacePos != -1)
- statusText = statusText.substring(spacePos + 1);
- m_httpStatusText = statusText;
-
- RetainPtr<CFDictionaryRef> headers(AdoptCF, CFHTTPMessageCopyAllHeaderFields(httpResponse));
- CFIndex headerCount = CFDictionaryGetCount(headers.get());
- Vector<const void*, 128> keys(headerCount);
- Vector<const void*, 128> values(headerCount);
- CFDictionaryGetKeysAndValues(headers.get(), keys.data(), values.data());
- for (int i = 0; i < headerCount; ++i)
- m_httpHeaderFields.set((CFStringRef)keys[i], (CFStringRef)values[i]);
- } else
- m_httpStatusCode = 0;
-}
-
-bool ResourceResponse::platformCompare(const ResourceResponse& a, const ResourceResponse& b)
-{
- return CFEqual(a.cfURLResponse(), b.cfURLResponse());
-}
-
-
-}
diff --git a/WebCore/platform/network/cf/ResourceResponseCFNet.h b/WebCore/platform/network/cf/ResourceResponseCFNet.h
deleted file mode 100644
index 27144c6..0000000
--- a/WebCore/platform/network/cf/ResourceResponseCFNet.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ResourceResponseCFNet_h
-#define ResourceResponseCFNet_h
-
-typedef struct _CFURLResponse* CFURLResponseRef;
-
-namespace WebCore {
-
- class ResourceResponse;
-
- void getResourceResponse(ResourceResponse& response, CFURLResponseRef cfResponse);
-
-}
-
-#endif // ResourceResponseCFNet_h
diff --git a/WebCore/platform/network/curl/AuthenticationChallenge.h b/WebCore/platform/network/curl/AuthenticationChallenge.h
deleted file mode 100644
index a64d575..0000000
--- a/WebCore/platform/network/curl/AuthenticationChallenge.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef AuthenticationChallenge_h
-#define AuthenticationChallenge_h
-
-#include "AuthenticationChallengeBase.h"
-#include "ResourceHandle.h"
-#include <wtf/RefPtr.h>
-
-namespace WebCore {
-
-class ResourceHandle;
-
-class AuthenticationChallenge : public AuthenticationChallengeBase {
-public:
- AuthenticationChallenge()
- {
- }
-
- AuthenticationChallenge(const ProtectionSpace& protectionSpace, const Credential& proposedCredential, unsigned previousFailureCount, const ResourceResponse& response, const ResourceError& error)
- : AuthenticationChallengeBase(protectionSpace, proposedCredential, previousFailureCount, response, error)
- {
- }
-
- ResourceHandle* sourceHandle() const { return m_sourceHandle.get(); }
-
- RefPtr<ResourceHandle> m_sourceHandle;
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/network/curl/CookieJarCurl.cpp b/WebCore/platform/network/curl/CookieJarCurl.cpp
deleted file mode 100644
index 2f76ebc..0000000
--- a/WebCore/platform/network/curl/CookieJarCurl.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "config.h"
-#include "CookieJar.h"
-
-#include "KURL.h"
-#include "PlatformString.h"
-#include "StringHash.h"
-
-#include <wtf/HashMap.h>
-
-namespace WebCore {
-
-static HashMap<String, String> cookieJar;
-
-void setCookies(Document* /*document*/, const KURL& url, const KURL& /*policyURL*/, const String& value)
-{
- cookieJar.set(url.string(), value);
-}
-
-String cookies(const Document* /*document*/, const KURL& url)
-{
- return cookieJar.get(url.string());
-}
-
-bool cookiesEnabled(const Document* /*document*/)
-{
- return true;
-}
-
-}
diff --git a/WebCore/platform/network/curl/DNSCurl.cpp b/WebCore/platform/network/curl/DNSCurl.cpp
deleted file mode 100644
index 1ffe1a0..0000000
--- a/WebCore/platform/network/curl/DNSCurl.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "DNS.h"
-
-#include "NotImplemented.h"
-
-namespace WebCore {
-
-void prefetchDNS(const String& hostname)
-{
- notImplemented();
-}
-
-}
diff --git a/WebCore/platform/network/curl/FormDataStreamCurl.cpp b/WebCore/platform/network/curl/FormDataStreamCurl.cpp
deleted file mode 100644
index 639a741..0000000
--- a/WebCore/platform/network/curl/FormDataStreamCurl.cpp
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
- * Copyright (C) 2007 Alp Toker <alp.toker@collabora.co.uk>
- * Copyright (C) 2007 Holger Hans Peter Freyther
- * Copyright (C) 2008 Collabora Ltd.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FormDataStreamCurl.h"
-
-#include "CString.h"
-#include "FormData.h"
-#include "ResourceRequest.h"
-
-namespace WebCore {
-
-FormDataStream::~FormDataStream()
-{
- if (m_file)
- fclose(m_file);
-}
-
-size_t FormDataStream::read(void* ptr, size_t blockSize, size_t numberOfBlocks)
-{
- // Check for overflow.
- if (!numberOfBlocks || blockSize > std::numeric_limits<size_t>::max() / numberOfBlocks)
- return 0;
-
- Vector<FormDataElement> elements;
- if (m_resourceHandle->request().httpBody())
- elements = m_resourceHandle->request().httpBody()->elements();
-
- if (m_formDataElementIndex >= elements.size())
- return 0;
-
- FormDataElement element = elements[m_formDataElementIndex];
-
- size_t toSend = blockSize * numberOfBlocks;
- size_t sent;
-
- if (element.m_type == FormDataElement::encodedFile) {
- if (!m_file)
- m_file = fopen(element.m_filename.utf8().data(), "rb");
-
- if (!m_file) {
- // FIXME: show a user error?
-#ifndef NDEBUG
- printf("Failed while trying to open %s for upload\n", element.m_filename.utf8().data());
-#endif
- return 0;
- }
-
- sent = fread(ptr, blockSize, numberOfBlocks, m_file);
- if (!blockSize && ferror(m_file)) {
- // FIXME: show a user error?
-#ifndef NDEBUG
- printf("Failed while trying to read %s for upload\n", element.m_filename.utf8().data());
-#endif
- return 0;
- }
- if (feof(m_file)) {
- fclose(m_file);
- m_file = 0;
- m_formDataElementIndex++;
- }
- } else {
- size_t elementSize = element.m_data.size() - m_formDataElementDataOffset;
- sent = elementSize > toSend ? toSend : elementSize;
- memcpy(ptr, element.m_data.data() + m_formDataElementDataOffset, sent);
- if (elementSize > sent)
- m_formDataElementDataOffset += sent;
- else {
- m_formDataElementDataOffset = 0;
- m_formDataElementIndex++;
- }
- }
-
- return sent;
-}
-
-bool FormDataStream::hasMoreElements() const
-{
- Vector<FormDataElement> elements;
- if (m_resourceHandle->request().httpBody())
- elements = m_resourceHandle->request().httpBody()->elements();
-
- return m_formDataElementIndex < elements.size();
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/network/curl/FormDataStreamCurl.h b/WebCore/platform/network/curl/FormDataStreamCurl.h
deleted file mode 100644
index 85ca8b0..0000000
--- a/WebCore/platform/network/curl/FormDataStreamCurl.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef FormatDataStreamCurl_h
-#define FormatDataStreamCurl_h
-
-#include "config.h"
-
-#include "FileSystem.h"
-#include "ResourceHandle.h"
-#include <stdio.h>
-
-namespace WebCore {
-
-class FormDataStream {
-public:
- FormDataStream(ResourceHandle* handle)
- : m_resourceHandle(handle)
- , m_file(0)
- , m_formDataElementIndex(0)
- , m_formDataElementDataOffset(0)
- {
- }
-
- ~FormDataStream();
-
- size_t read(void* ptr, size_t blockSize, size_t numberOfBlocks);
- bool hasMoreElements() const;
-
-private:
- // We can hold a weak reference to our ResourceHandle as it holds a strong reference
- // to us through its ResourceHandleInternal.
- ResourceHandle* m_resourceHandle;
-
- FILE* m_file;
- size_t m_formDataElementIndex;
- size_t m_formDataElementDataOffset;
-};
-
-} // namespace WebCore
-
-#endif // FormDataStreamCurl_h
diff --git a/WebCore/platform/network/curl/ResourceError.h b/WebCore/platform/network/curl/ResourceError.h
deleted file mode 100644
index ca8d36b..0000000
--- a/WebCore/platform/network/curl/ResourceError.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ResourceError_h
-#define ResourceError_h
-
-#include "ResourceErrorBase.h"
-
-namespace WebCore {
-
-class ResourceError : public ResourceErrorBase
-{
-public:
- ResourceError()
- {
- }
-
- ResourceError(const String& domain, int errorCode, const String& failingURL, const String& localizedDescription)
- : ResourceErrorBase(domain, errorCode, failingURL, localizedDescription)
- {
- }
-};
-
-}
-
-#endif // ResourceError_h_
diff --git a/WebCore/platform/network/curl/ResourceHandleCurl.cpp b/WebCore/platform/network/curl/ResourceHandleCurl.cpp
deleted file mode 100644
index bbc31d4..0000000
--- a/WebCore/platform/network/curl/ResourceHandleCurl.cpp
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2005, 2006 Michael Emmel mike.emmel@gmail.com
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ResourceHandle.h"
-
-#include "DocLoader.h"
-#include "NotImplemented.h"
-#include "ResourceHandleInternal.h"
-#include "ResourceHandleManager.h"
-
-#if PLATFORM(WIN) && PLATFORM(CF)
-#include <wtf/RetainPtr.h>
-#endif
-
-namespace WebCore {
-
-class WebCoreSynchronousLoader : public ResourceHandleClient {
-public:
- WebCoreSynchronousLoader();
-
- virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&);
- virtual void didReceiveData(ResourceHandle*, const char*, int, int lengthReceived);
- virtual void didFinishLoading(ResourceHandle*);
- virtual void didFail(ResourceHandle*, const ResourceError&);
-
- ResourceResponse resourceResponse() const { return m_response; }
- ResourceError resourceError() const { return m_error; }
- Vector<char> data() const { return m_data; }
-
-private:
- ResourceResponse m_response;
- ResourceError m_error;
- Vector<char> m_data;
-};
-
-WebCoreSynchronousLoader::WebCoreSynchronousLoader()
-{
-}
-
-void WebCoreSynchronousLoader::didReceiveResponse(ResourceHandle*, const ResourceResponse& response)
-{
- m_response = response;
-}
-
-void WebCoreSynchronousLoader::didReceiveData(ResourceHandle*, const char* data, int length, int)
-{
- m_data.append(data, length);
-}
-
-void WebCoreSynchronousLoader::didFinishLoading(ResourceHandle*)
-{
-}
-
-void WebCoreSynchronousLoader::didFail(ResourceHandle*, const ResourceError& error)
-{
- m_error = error;
-}
-
-
-static HashSet<String>& allowsAnyHTTPSCertificateHosts()
-{
- static HashSet<String> hosts;
-
- return hosts;
-}
-
-ResourceHandleInternal::~ResourceHandleInternal()
-{
- free(m_url);
- if (m_customHeaders)
- curl_slist_free_all(m_customHeaders);
-}
-
-ResourceHandle::~ResourceHandle()
-{
- cancel();
-}
-
-bool ResourceHandle::start(Frame* frame)
-{
- ASSERT(frame);
- ref();
- ResourceHandleManager::sharedInstance()->add(this);
- return true;
-}
-
-void ResourceHandle::cancel()
-{
- ResourceHandleManager::sharedInstance()->cancel(this);
-}
-
-PassRefPtr<SharedBuffer> ResourceHandle::bufferedData()
-{
- return 0;
-}
-
-bool ResourceHandle::supportsBufferedData()
-{
- return false;
-}
-
-#if PLATFORM(WIN) && PLATFORM(CF)
-void ResourceHandle::setHostAllowsAnyHTTPSCertificate(const String& host)
-{
- allowsAnyHTTPSCertificateHosts().add(host.lower());
-}
-#endif
-
-#if PLATFORM(WIN) && PLATFORM(CF)
-// FIXME: The CFDataRef will need to be something else when
-// building without
-static HashMap<String, RetainPtr<CFDataRef> >& clientCerts()
-{
- static HashMap<String, RetainPtr<CFDataRef> > certs;
- return certs;
-}
-
-void ResourceHandle::setClientCertificate(const String& host, CFDataRef cert)
-{
- clientCerts().set(host.lower(), cert);
-}
-#endif
-
-void ResourceHandle::setDefersLoading(bool defers)
-{
- if (d->m_defersLoading == defers)
- return;
-
-#if LIBCURL_VERSION_NUM > 0x071200
- if (!d->m_handle)
- d->m_defersLoading = defers;
- else if (defers) {
- CURLcode error = curl_easy_pause(d->m_handle, CURLPAUSE_ALL);
- // If we could not defer the handle, so don't do it.
- if (error != CURLE_OK)
- return;
-
- d->m_defersLoading = defers;
- } else {
- // We need to set defersLoading before restarting a connection
- // or libcURL will call the callbacks in curl_easy_pause and
- // we would ASSERT.
- d->m_defersLoading = defers;
-
- CURLcode error = curl_easy_pause(d->m_handle, CURLPAUSE_CONT);
- if (error != CURLE_OK)
- // Restarting the handle has failed so just cancel it.
- cancel();
- }
-#else
- d->m_defersLoading = defers;
-#ifndef NDEBUG
- printf("Deferred loading is implemented if libcURL version is above 7.18.0");
-#endif
-#endif
-}
-
-bool ResourceHandle::willLoadFromCache(ResourceRequest&)
-{
- notImplemented();
- return false;
-}
-
-bool ResourceHandle::loadsBlocked()
-{
- notImplemented();
- return false;
-}
-
-void ResourceHandle::loadResourceSynchronously(const ResourceRequest& request, ResourceError& error, ResourceResponse& response, Vector<char>& data, Frame*)
-{
- WebCoreSynchronousLoader syncLoader;
- ResourceHandle handle(request, &syncLoader, true, false, true);
-
- ResourceHandleManager* manager = ResourceHandleManager::sharedInstance();
-
- manager->dispatchSynchronousJob(&handle);
-
- error = syncLoader.resourceError();
- data = syncLoader.data();
- response = syncLoader.resourceResponse();
-}
-
-//stubs needed for windows version
-void ResourceHandle::didReceiveAuthenticationChallenge(const AuthenticationChallenge&)
-{
- notImplemented();
-}
-
-void ResourceHandle::receivedCredential(const AuthenticationChallenge&, const Credential&)
-{
- notImplemented();
-}
-
-void ResourceHandle::receivedRequestToContinueWithoutCredential(const AuthenticationChallenge&)
-{
- notImplemented();
-}
-
-void ResourceHandle::receivedCancellation(const AuthenticationChallenge&)
-{
- notImplemented();
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/network/curl/ResourceHandleManager.cpp b/WebCore/platform/network/curl/ResourceHandleManager.cpp
deleted file mode 100644
index b022913..0000000
--- a/WebCore/platform/network/curl/ResourceHandleManager.cpp
+++ /dev/null
@@ -1,700 +0,0 @@
-/*
- * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
- * Copyright (C) 2007 Alp Toker <alp@atoker.com>
- * Copyright (C) 2007 Holger Hans Peter Freyther
- * Copyright (C) 2008 Collabora Ltd.
- * Copyright (C) 2008 Nuanti Ltd.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ResourceHandleManager.h"
-
-#include "Base64.h"
-#include "CString.h"
-#include "HTTPParsers.h"
-#include "MIMETypeRegistry.h"
-#include "NotImplemented.h"
-#include "ResourceError.h"
-#include "ResourceHandle.h"
-#include "ResourceHandleInternal.h"
-#include "TextEncoding.h"
-
-#include <errno.h>
-#include <wtf/Vector.h>
-
-#if PLATFORM(GTK)
- #if GLIB_CHECK_VERSION(2,12,0)
- #define USE_GLIB_BASE64
- #endif
-#endif
-
-namespace WebCore {
-
-const int selectTimeoutMS = 5;
-const double pollTimeSeconds = 0.05;
-const int maxRunningJobs = 5;
-
-static const bool ignoreSSLErrors = getenv("WEBKIT_IGNORE_SSL_ERRORS");
-
-ResourceHandleManager::ResourceHandleManager()
- : m_downloadTimer(this, &ResourceHandleManager::downloadTimerCallback)
- , m_cookieJarFileName(0)
- , m_runningJobs(0)
-{
- curl_global_init(CURL_GLOBAL_ALL);
- m_curlMultiHandle = curl_multi_init();
- m_curlShareHandle = curl_share_init();
- curl_share_setopt(m_curlShareHandle, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
- curl_share_setopt(m_curlShareHandle, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS);
-}
-
-ResourceHandleManager::~ResourceHandleManager()
-{
- curl_multi_cleanup(m_curlMultiHandle);
- curl_share_cleanup(m_curlShareHandle);
- if (m_cookieJarFileName)
- free(m_cookieJarFileName);
- curl_global_cleanup();
-}
-
-void ResourceHandleManager::setCookieJarFileName(const char* cookieJarFileName)
-{
- m_cookieJarFileName = strdup(cookieJarFileName);
-}
-
-ResourceHandleManager* ResourceHandleManager::sharedInstance()
-{
- static ResourceHandleManager* sharedInstance = 0;
- if (!sharedInstance)
- sharedInstance = new ResourceHandleManager();
- return sharedInstance;
-}
-
-// called with data after all headers have been processed via headerCallback
-static size_t writeCallback(void* ptr, size_t size, size_t nmemb, void* data)
-{
- ResourceHandle* job = static_cast<ResourceHandle*>(data);
- ResourceHandleInternal* d = job->getInternal();
- if (d->m_cancelled)
- return 0;
-
-#if LIBCURL_VERSION_NUM > 0x071200
- // We should never be called when deferred loading is activated.
- ASSERT(!d->m_defersLoading);
-#endif
-
- size_t totalSize = size * nmemb;
-
- // this shouldn't be necessary but apparently is. CURL writes the data
- // of html page even if it is a redirect that was handled internally
- // can be observed e.g. on gmail.com
- CURL* h = d->m_handle;
- long httpCode = 0;
- CURLcode err = curl_easy_getinfo(h, CURLINFO_RESPONSE_CODE, &httpCode);
- if (CURLE_OK == err && httpCode >= 300 && httpCode < 400)
- return totalSize;
-
- // since the code in headerCallback will not have run for local files
- // the code to set the URL and fire didReceiveResponse is never run,
- // which means the ResourceLoader's response does not contain the URL.
- // Run the code here for local files to resolve the issue.
- // TODO: See if there is a better approach for handling this.
- if (!d->m_response.responseFired()) {
- const char* hdr;
- err = curl_easy_getinfo(h, CURLINFO_EFFECTIVE_URL, &hdr);
- d->m_response.setUrl(KURL(hdr));
- if (d->client())
- d->client()->didReceiveResponse(job, d->m_response);
- d->m_response.setResponseFired(true);
- }
-
- if (d->client())
- d->client()->didReceiveData(job, static_cast<char*>(ptr), totalSize, 0);
- return totalSize;
-}
-
-/*
- * This is being called for each HTTP header in the response. This includes '\r\n'
- * for the last line of the header.
- *
- * We will add each HTTP Header to the ResourceResponse and on the termination
- * of the header (\r\n) we will parse Content-Type and Content-Disposition and
- * update the ResourceResponse and then send it away.
- *
- */
-static size_t headerCallback(char* ptr, size_t size, size_t nmemb, void* data)
-{
- ResourceHandle* job = static_cast<ResourceHandle*>(data);
- ResourceHandleInternal* d = job->getInternal();
- if (d->m_cancelled)
- return 0;
-
-#if LIBCURL_VERSION_NUM > 0x071200
- // We should never be called when deferred loading is activated.
- ASSERT(!d->m_defersLoading);
-#endif
-
- size_t totalSize = size * nmemb;
- ResourceHandleClient* client = d->client();
-
- String header(static_cast<const char*>(ptr), totalSize);
-
- /*
- * a) We can finish and send the ResourceResponse
- * b) We will add the current header to the HTTPHeaderMap of the ResourceResponse
- *
- * The HTTP standard requires to use \r\n but for compatibility it recommends to
- * accept also \n.
- */
- if (header == String("\r\n") || header == String("\n")) {
- CURL* h = d->m_handle;
- CURLcode err;
-
- double contentLength = 0;
- err = curl_easy_getinfo(h, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &contentLength);
- d->m_response.setExpectedContentLength(static_cast<long long int>(contentLength));
-
- const char* hdr;
- err = curl_easy_getinfo(h, CURLINFO_EFFECTIVE_URL, &hdr);
- d->m_response.setUrl(KURL(hdr));
-
- long httpCode = 0;
- err = curl_easy_getinfo(h, CURLINFO_RESPONSE_CODE, &httpCode);
- d->m_response.setHTTPStatusCode(httpCode);
-
- d->m_response.setMimeType(extractMIMETypeFromMediaType(d->m_response.httpHeaderField("Content-Type")));
- d->m_response.setTextEncodingName(extractCharsetFromMediaType(d->m_response.httpHeaderField("Content-Type")));
- d->m_response.setSuggestedFilename(filenameFromHTTPContentDisposition(d->m_response.httpHeaderField("Content-Disposition")));
-
- // HTTP redirection
- if (httpCode >= 300 && httpCode < 400) {
- String location = d->m_response.httpHeaderField("location");
- if (!location.isEmpty()) {
- KURL newURL = KURL(job->request().url(), location);
-
- ResourceRequest redirectedRequest = job->request();
- redirectedRequest.setURL(newURL);
- if (client)
- client->willSendRequest(job, redirectedRequest, d->m_response);
-
- d->m_request.setURL(newURL);
-
- return totalSize;
- }
- }
-
- if (client)
- client->didReceiveResponse(job, d->m_response);
- d->m_response.setResponseFired(true);
-
- } else {
- int splitPos = header.find(":");
- if (splitPos != -1)
- d->m_response.setHTTPHeaderField(header.left(splitPos), header.substring(splitPos+1).stripWhiteSpace());
- }
-
- return totalSize;
-}
-
-/* This is called to obtain HTTP POST or PUT data.
- Iterate through FormData elements and upload files.
- Carefully respect the given buffer size and fill the rest of the data at the next calls.
-*/
-size_t readCallback(void* ptr, size_t size, size_t nmemb, void* data)
-{
- ResourceHandle* job = static_cast<ResourceHandle*>(data);
- ResourceHandleInternal* d = job->getInternal();
- if (d->m_cancelled)
- return 0;
-
-#if LIBCURL_VERSION_NUM > 0x071200
- // We should never be called when deferred loading is activated.
- ASSERT(!d->m_defersLoading);
-#endif
-
- if (!size || !nmemb)
- return 0;
-
- if (!d->m_formDataStream.hasMoreElements())
- return 0;
-
- size_t sent = d->m_formDataStream.read(ptr, size, nmemb);
-
- // Something went wrong so cancel the job.
- if (!sent)
- job->cancel();
-
- return sent;
-}
-
-void ResourceHandleManager::downloadTimerCallback(Timer<ResourceHandleManager>* timer)
-{
- startScheduledJobs();
-
- fd_set fdread;
- fd_set fdwrite;
- fd_set fdexcep;
- int maxfd = 0;
-
- struct timeval timeout;
- timeout.tv_sec = 0;
- timeout.tv_usec = selectTimeoutMS * 1000; // select waits microseconds
-
- // Temporarily disable timers since signals may interrupt select(), raising EINTR errors on some platforms
- setDeferringTimers(true);
- int rc = 0;
- do {
- FD_ZERO(&fdread);
- FD_ZERO(&fdwrite);
- FD_ZERO(&fdexcep);
- curl_multi_fdset(m_curlMultiHandle, &fdread, &fdwrite, &fdexcep, &maxfd);
- // When the 3 file descriptors are empty, winsock will return -1
- // and bail out, stopping the file download. So make sure we
- // have valid file descriptors before calling select.
- if (maxfd >= 0)
- rc = ::select(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout);
- } while (rc == -1 && errno == EINTR);
- setDeferringTimers(false);
-
- if (-1 == rc) {
-#ifndef NDEBUG
- perror("bad: select() returned -1: ");
-#endif
- return;
- }
-
- int runningHandles = 0;
- while (curl_multi_perform(m_curlMultiHandle, &runningHandles) == CURLM_CALL_MULTI_PERFORM) { }
-
- // check the curl messages indicating completed transfers
- // and free their resources
- while (true) {
- int messagesInQueue;
- CURLMsg* msg = curl_multi_info_read(m_curlMultiHandle, &messagesInQueue);
- if (!msg)
- break;
-
- // find the node which has same d->m_handle as completed transfer
- CURL* handle = msg->easy_handle;
- ASSERT(handle);
- ResourceHandle* job = 0;
- CURLcode err = curl_easy_getinfo(handle, CURLINFO_PRIVATE, &job);
- ASSERT(CURLE_OK == err);
- ASSERT(job);
- if (!job)
- continue;
- ResourceHandleInternal* d = job->getInternal();
- ASSERT(d->m_handle == handle);
-
- if (d->m_cancelled) {
- removeFromCurl(job);
- continue;
- }
-
- if (CURLMSG_DONE != msg->msg)
- continue;
-
- if (CURLE_OK == msg->data.result) {
- if (d->client())
- d->client()->didFinishLoading(job);
- } else {
-#ifndef NDEBUG
- char* url = 0;
- curl_easy_getinfo(d->m_handle, CURLINFO_EFFECTIVE_URL, &url);
- printf("Curl ERROR for url='%s', error: '%s'\n", url, curl_easy_strerror(msg->data.result));
-#endif
- if (d->client())
- d->client()->didFail(job, ResourceError());
- }
-
- removeFromCurl(job);
- }
-
- bool started = startScheduledJobs(); // new jobs might have been added in the meantime
-
- if (!m_downloadTimer.isActive() && (started || (runningHandles > 0)))
- m_downloadTimer.startOneShot(pollTimeSeconds);
-}
-
-void ResourceHandleManager::removeFromCurl(ResourceHandle* job)
-{
- ResourceHandleInternal* d = job->getInternal();
- ASSERT(d->m_handle);
- if (!d->m_handle)
- return;
- m_runningJobs--;
- curl_multi_remove_handle(m_curlMultiHandle, d->m_handle);
- curl_easy_cleanup(d->m_handle);
- d->m_handle = 0;
-}
-
-void ResourceHandleManager::setupPUT(ResourceHandle*, struct curl_slist**)
-{
- notImplemented();
-}
-
-/* Calculate the length of the POST.
- Force chunked data transfer if size of files can't be obtained.
- */
-void ResourceHandleManager::setupPOST(ResourceHandle* job, struct curl_slist** headers)
-{
- ResourceHandleInternal* d = job->getInternal();
- Vector<FormDataElement> elements;
- // Fix crash when httpBody is null (see bug #16906).
- if (job->request().httpBody())
- elements = job->request().httpBody()->elements();
- size_t numElements = elements.size();
-
- if (!numElements)
- return;
-
- // Do not stream for simple POST data
- if (numElements == 1) {
- job->request().httpBody()->flatten(d->m_postBytes);
- if (d->m_postBytes.size() != 0) {
- curl_easy_setopt(d->m_handle, CURLOPT_POST, TRUE);
- curl_easy_setopt(d->m_handle, CURLOPT_POSTFIELDSIZE, d->m_postBytes.size());
- curl_easy_setopt(d->m_handle, CURLOPT_POSTFIELDS, d->m_postBytes.data());
- }
- return;
- }
-
- // Obtain the total size of the POST
- // The size of a curl_off_t could be different in WebKit and in cURL depending on
- // compilation flags of both. For CURLOPT_POSTFIELDSIZE_LARGE we have to pass the
- // right size or random data will be used as the size.
- static int expectedSizeOfCurlOffT = 0;
- if (!expectedSizeOfCurlOffT) {
- curl_version_info_data *infoData = curl_version_info(CURLVERSION_NOW);
- if (infoData->features & CURL_VERSION_LARGEFILE)
- expectedSizeOfCurlOffT = sizeof(long long);
- else
- expectedSizeOfCurlOffT = sizeof(int);
- }
-
-#if COMPILER(MSVC)
- // work around compiler error in Visual Studio 2005. It can't properly
- // handle math with 64-bit constant declarations.
-#pragma warning(disable: 4307)
-#endif
- static const long long maxCurlOffT = (1LL << (expectedSizeOfCurlOffT * 8 - 1)) - 1;
- curl_off_t size = 0;
- bool chunkedTransfer = false;
- for (size_t i = 0; i < numElements; i++) {
- FormDataElement element = elements[i];
- if (element.m_type == FormDataElement::encodedFile) {
- long long fileSizeResult;
- if (getFileSize(element.m_filename, fileSizeResult)) {
- if (fileSizeResult > maxCurlOffT) {
- // File size is too big for specifying it to cURL
- chunkedTransfer = true;
- break;
- }
- size += fileSizeResult;
- } else {
- chunkedTransfer = true;
- break;
- }
- } else
- size += elements[i].m_data.size();
- }
-
- curl_easy_setopt(d->m_handle, CURLOPT_POST, TRUE);
-
- // cURL guesses that we want chunked encoding as long as we specify the header
- if (chunkedTransfer)
- *headers = curl_slist_append(*headers, "Transfer-Encoding: chunked");
- else {
- if (sizeof(long long) == expectedSizeOfCurlOffT)
- curl_easy_setopt(d->m_handle, CURLOPT_POSTFIELDSIZE_LARGE, (long long)size);
- else
- curl_easy_setopt(d->m_handle, CURLOPT_POSTFIELDSIZE_LARGE, (int)size);
- }
-
- curl_easy_setopt(d->m_handle, CURLOPT_READFUNCTION, readCallback);
- curl_easy_setopt(d->m_handle, CURLOPT_READDATA, job);
-}
-
-void ResourceHandleManager::add(ResourceHandle* job)
-{
- // we can be called from within curl, so to avoid re-entrancy issues
- // schedule this job to be added the next time we enter curl download loop
- m_resourceHandleList.append(job);
- if (!m_downloadTimer.isActive())
- m_downloadTimer.startOneShot(pollTimeSeconds);
-}
-
-bool ResourceHandleManager::removeScheduledJob(ResourceHandle* job)
-{
- int size = m_resourceHandleList.size();
- for (int i = 0; i < size; i++) {
- if (job == m_resourceHandleList[i]) {
- m_resourceHandleList.remove(i);
- return true;
- }
- }
- return false;
-}
-
-bool ResourceHandleManager::startScheduledJobs()
-{
- // TODO: Create a separate stack of jobs for each domain.
-
- bool started = false;
- while (!m_resourceHandleList.isEmpty() && m_runningJobs < maxRunningJobs) {
- ResourceHandle* job = m_resourceHandleList[0];
- m_resourceHandleList.remove(0);
- startJob(job);
- started = true;
- }
- return started;
-}
-
-static void parseDataUrl(ResourceHandle* handle)
-{
- ResourceHandleClient* client = handle->client();
-
- ASSERT(client);
- if (!client)
- return;
-
- String url = handle->request().url().string();
- ASSERT(url.startsWith("data:", false));
-
- int index = url.find(',');
- if (index == -1) {
- client->cannotShowURL(handle);
- return;
- }
-
- String mediaType = url.substring(5, index - 5);
- String data = url.substring(index + 1);
-
- bool base64 = mediaType.endsWith(";base64", false);
- if (base64)
- mediaType = mediaType.left(mediaType.length() - 7);
-
- if (mediaType.isEmpty())
- mediaType = "text/plain;charset=US-ASCII";
-
- String mimeType = extractMIMETypeFromMediaType(mediaType);
- String charset = extractCharsetFromMediaType(mediaType);
-
- ResourceResponse response;
- response.setMimeType(mimeType);
-
- if (base64) {
- data = decodeURLEscapeSequences(data);
- response.setTextEncodingName(charset);
- client->didReceiveResponse(handle, response);
-
- // Use the GLib Base64 if available, since WebCore's decoder isn't
- // general-purpose and fails on Acid3 test 97 (whitespace).
-#ifdef USE_GLIB_BASE64
- size_t outLength = 0;
- char* outData = 0;
- outData = reinterpret_cast<char*>(g_base64_decode(data.utf8().data(), &outLength));
- if (outData && outLength > 0)
- client->didReceiveData(handle, outData, outLength, 0);
- g_free(outData);
-#else
- Vector<char> out;
- if (base64Decode(data.latin1().data(), data.latin1().length(), out) && out.size() > 0)
- client->didReceiveData(handle, out.data(), out.size(), 0);
-#endif
- } else {
- // We have to convert to UTF-16 early due to limitations in KURL
- data = decodeURLEscapeSequences(data, TextEncoding(charset));
- response.setTextEncodingName("UTF-16");
- client->didReceiveResponse(handle, response);
- if (data.length() > 0)
- client->didReceiveData(handle, reinterpret_cast<const char*>(data.characters()), data.length() * sizeof(UChar), 0);
- }
-
- client->didFinishLoading(handle);
-}
-
-void ResourceHandleManager::dispatchSynchronousJob(ResourceHandle* job)
-{
- KURL kurl = job->request().url();
-
- if (kurl.protocolIs("data")) {
- parseDataUrl(job);
- return;
- }
-
- ResourceHandleInternal* handle = job->getInternal();
-
-#if LIBCURL_VERSION_NUM > 0x071200
- // If defersLoading is true and we call curl_easy_perform
- // on a paused handle, libcURL would do the transfert anyway
- // and we would assert so force defersLoading to be false.
- handle->m_defersLoading = false;
-#endif
-
- initializeHandle(job);
-
- // curl_easy_perform blocks until the transfert is finished.
- CURLcode ret = curl_easy_perform(handle->m_handle);
-
- if (ret != 0) {
- ResourceError error(String(handle->m_url), ret, String(handle->m_url), String(curl_easy_strerror(ret)));
- handle->client()->didFail(job, error);
- }
-
- curl_easy_cleanup(handle->m_handle);
-}
-
-void ResourceHandleManager::startJob(ResourceHandle* job)
-{
- KURL kurl = job->request().url();
-
- if (kurl.protocolIs("data")) {
- parseDataUrl(job);
- return;
- }
-
- initializeHandle(job);
-
- m_runningJobs++;
- CURLMcode ret = curl_multi_add_handle(m_curlMultiHandle, job->getInternal()->m_handle);
- // don't call perform, because events must be async
- // timeout will occur and do curl_multi_perform
- if (ret && ret != CURLM_CALL_MULTI_PERFORM) {
-#ifndef NDEBUG
- printf("Error %d starting job %s\n", ret, encodeWithURLEscapeSequences(job->request().url().string()).latin1().data());
-#endif
- job->cancel();
- return;
- }
-}
-
-void ResourceHandleManager::initializeHandle(ResourceHandle* job)
-{
- KURL kurl = job->request().url();
-
- // Remove any fragment part, otherwise curl will send it as part of the request.
- kurl.removeRef();
-
- ResourceHandleInternal* d = job->getInternal();
- String url = kurl.string();
-
- if (kurl.isLocalFile()) {
- String query = kurl.query();
- // Remove any query part sent to a local file.
- if (!query.isEmpty())
- url = url.left(url.find(query));
- // Determine the MIME type based on the path.
- d->m_response.setMimeType(MIMETypeRegistry::getMIMETypeForPath(url));
- }
-
- d->m_handle = curl_easy_init();
-
-#if LIBCURL_VERSION_NUM > 0x071200
- if (d->m_defersLoading) {
- CURLcode error = curl_easy_pause(d->m_handle, CURLPAUSE_ALL);
- // If we did not pause the handle, we would ASSERT in the
- // header callback. So just assert here.
- ASSERT(error == CURLE_OK);
- }
-#endif
-#ifndef NDEBUG
- if (getenv("DEBUG_CURL"))
- curl_easy_setopt(d->m_handle, CURLOPT_VERBOSE, 1);
-#endif
- curl_easy_setopt(d->m_handle, CURLOPT_PRIVATE, job);
- curl_easy_setopt(d->m_handle, CURLOPT_ERRORBUFFER, m_curlErrorBuffer);
- curl_easy_setopt(d->m_handle, CURLOPT_WRITEFUNCTION, writeCallback);
- curl_easy_setopt(d->m_handle, CURLOPT_WRITEDATA, job);
- curl_easy_setopt(d->m_handle, CURLOPT_HEADERFUNCTION, headerCallback);
- curl_easy_setopt(d->m_handle, CURLOPT_WRITEHEADER, job);
- curl_easy_setopt(d->m_handle, CURLOPT_AUTOREFERER, 1);
- curl_easy_setopt(d->m_handle, CURLOPT_FOLLOWLOCATION, 1);
- curl_easy_setopt(d->m_handle, CURLOPT_MAXREDIRS, 10);
- curl_easy_setopt(d->m_handle, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
- curl_easy_setopt(d->m_handle, CURLOPT_SHARE, m_curlShareHandle);
- curl_easy_setopt(d->m_handle, CURLOPT_DNS_CACHE_TIMEOUT, 60 * 5); // 5 minutes
- // FIXME: Enable SSL verification when we have a way of shipping certs
- // and/or reporting SSL errors to the user.
- if (ignoreSSLErrors)
- curl_easy_setopt(d->m_handle, CURLOPT_SSL_VERIFYPEER, false);
- // enable gzip and deflate through Accept-Encoding:
- curl_easy_setopt(d->m_handle, CURLOPT_ENCODING, "");
-
- // url must remain valid through the request
- ASSERT(!d->m_url);
-
- // url is in ASCII so latin1() will only convert it to char* without character translation.
- d->m_url = strdup(url.latin1().data());
- curl_easy_setopt(d->m_handle, CURLOPT_URL, d->m_url);
-
- if (m_cookieJarFileName) {
- curl_easy_setopt(d->m_handle, CURLOPT_COOKIEFILE, m_cookieJarFileName);
- curl_easy_setopt(d->m_handle, CURLOPT_COOKIEJAR, m_cookieJarFileName);
- }
-
- struct curl_slist* headers = 0;
- if (job->request().httpHeaderFields().size() > 0) {
- HTTPHeaderMap customHeaders = job->request().httpHeaderFields();
- HTTPHeaderMap::const_iterator end = customHeaders.end();
- for (HTTPHeaderMap::const_iterator it = customHeaders.begin(); it != end; ++it) {
- String key = it->first;
- String value = it->second;
- String headerString(key);
- headerString.append(": ");
- headerString.append(value);
- CString headerLatin1 = headerString.latin1();
- headers = curl_slist_append(headers, headerLatin1.data());
- }
- }
-
- if ("GET" == job->request().httpMethod())
- curl_easy_setopt(d->m_handle, CURLOPT_HTTPGET, TRUE);
- else if ("POST" == job->request().httpMethod())
- setupPOST(job, &headers);
- else if ("PUT" == job->request().httpMethod())
- setupPUT(job, &headers);
- else if ("HEAD" == job->request().httpMethod())
- curl_easy_setopt(d->m_handle, CURLOPT_NOBODY, TRUE);
-
- if (headers) {
- curl_easy_setopt(d->m_handle, CURLOPT_HTTPHEADER, headers);
- d->m_customHeaders = headers;
- }
-}
-
-void ResourceHandleManager::cancel(ResourceHandle* job)
-{
- if (removeScheduledJob(job))
- return;
-
- ResourceHandleInternal* d = job->getInternal();
- d->m_cancelled = true;
- if (!m_downloadTimer.isActive())
- m_downloadTimer.startOneShot(pollTimeSeconds);
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/network/curl/ResourceHandleManager.h b/WebCore/platform/network/curl/ResourceHandleManager.h
deleted file mode 100644
index f3ad234..0000000
--- a/WebCore/platform/network/curl/ResourceHandleManager.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ResourceHandleManager_h
-#define ResourceHandleManager_h
-
-#include "Frame.h"
-#include "Timer.h"
-#include "ResourceHandleClient.h"
-
-#include <curl/curl.h>
-#include <wtf/Vector.h>
-
-namespace WebCore {
-
-class ResourceHandleManager {
-public:
- static ResourceHandleManager* sharedInstance();
- void add(ResourceHandle*);
- void cancel(ResourceHandle*);
- void setCookieJarFileName(const char* cookieJarFileName);
-
- void dispatchSynchronousJob(ResourceHandle*);
-
- void setupPOST(ResourceHandle*, struct curl_slist**);
- void setupPUT(ResourceHandle*, struct curl_slist**);
-
-private:
- ResourceHandleManager();
- ~ResourceHandleManager();
- void downloadTimerCallback(Timer<ResourceHandleManager>*);
- void removeFromCurl(ResourceHandle*);
- bool removeScheduledJob(ResourceHandle*);
- void startJob(ResourceHandle*);
- bool startScheduledJobs();
-
- void initializeHandle(ResourceHandle*);
-
- Timer<ResourceHandleManager> m_downloadTimer;
- CURLM* m_curlMultiHandle;
- CURLSH* m_curlShareHandle;
- char* m_cookieJarFileName;
- char m_curlErrorBuffer[CURL_ERROR_SIZE];
- Vector<ResourceHandle*> m_resourceHandleList;
- int m_runningJobs;
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/network/curl/ResourceRequest.h b/WebCore/platform/network/curl/ResourceRequest.h
deleted file mode 100644
index b3032aa..0000000
--- a/WebCore/platform/network/curl/ResourceRequest.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ResourceRequest_h
-#define ResourceRequest_h
-
-#include "ResourceRequestBase.h"
-
-typedef const struct _CFURLRequest* CFURLRequestRef;
-
-namespace WebCore {
-
- struct ResourceRequest : ResourceRequestBase {
-
- ResourceRequest(const String& url)
- : ResourceRequestBase(KURL(url), UseProtocolCachePolicy)
- {
- }
-
- ResourceRequest(const KURL& url)
- : ResourceRequestBase(url, UseProtocolCachePolicy)
- {
- }
-
- ResourceRequest(const KURL& url, const String& referrer, ResourceRequestCachePolicy policy = UseProtocolCachePolicy)
- : ResourceRequestBase(url, policy)
- {
- setHTTPReferrer(referrer);
- }
-
- ResourceRequest()
- : ResourceRequestBase(KURL(), UseProtocolCachePolicy)
- {
- }
-
- // Needed for compatibility.
- CFURLRequestRef cfURLRequest() const { return 0; }
-
- private:
- friend class ResourceRequestBase;
-
- void doUpdatePlatformRequest() {}
- void doUpdateResourceRequest() {}
- };
-
-} // namespace WebCore
-
-#endif // ResourceRequest_h
diff --git a/WebCore/platform/network/curl/ResourceResponse.h b/WebCore/platform/network/curl/ResourceResponse.h
deleted file mode 100644
index 6195f61..0000000
--- a/WebCore/platform/network/curl/ResourceResponse.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ResourceResponse_h
-#define ResourceResponse_h
-
-#include "ResourceResponseBase.h"
-
-namespace WebCore {
-
-class ResourceResponse : public ResourceResponseBase {
-public:
- ResourceResponse()
- : m_responseFired(false)
- {
- }
-
- ResourceResponse(const KURL& url, const String& mimeType, long long expectedLength, const String& textEncodingName, const String& filename)
- : ResourceResponseBase(url, mimeType, expectedLength, textEncodingName, filename),
- m_responseFired(false)
- {
- }
-
- void setResponseFired(bool fired) { m_responseFired = fired; }
- bool responseFired() { return m_responseFired; }
-
-private:
- bool m_responseFired;
-};
-
-} // namespace WebCore
-
-#endif // ResourceResponse_h
diff --git a/WebCore/platform/network/mac/AuthenticationChallenge.h b/WebCore/platform/network/mac/AuthenticationChallenge.h
deleted file mode 100644
index e8f3a2d..0000000
--- a/WebCore/platform/network/mac/AuthenticationChallenge.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef AuthenticationChallenge_h
-#define AuthenticationChallenge_h
-
-#include "AuthenticationChallengeBase.h"
-
-#include <wtf/RetainPtr.h>
-#ifndef __OBJC__
-typedef struct objc_object *id;
-class NSURLAuthenticationChallenge;
-#else
-@class NSURLAuthenticationChallenge;
-#endif
-
-namespace WebCore {
-
-class AuthenticationChallenge : public AuthenticationChallengeBase {
-public:
- AuthenticationChallenge() {}
- AuthenticationChallenge(const ProtectionSpace& protectionSpace, const Credential& proposedCredential, unsigned previousFailureCount, const ResourceResponse& response, const ResourceError& error);
- AuthenticationChallenge(NSURLAuthenticationChallenge *);
-
- id sender() const { return m_sender.get(); }
- NSURLAuthenticationChallenge *nsURLAuthenticationChallenge() const { return m_macChallenge.get(); }
-
-private:
- friend class AuthenticationChallengeBase;
- static bool platformCompare(const AuthenticationChallenge& a, const AuthenticationChallenge& b);
-
- RetainPtr<id> m_sender;
- RetainPtr<NSURLAuthenticationChallenge *> m_macChallenge;
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/network/mac/AuthenticationMac.h b/WebCore/platform/network/mac/AuthenticationMac.h
deleted file mode 100644
index f55ac24..0000000
--- a/WebCore/platform/network/mac/AuthenticationMac.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef AuthenticationMac_h
-#define AuthenticationMac_h
-
-#ifdef __OBJC__
-
-@class NSURLAuthenticationChallenge;
-@class NSURLCredential;
-@class NSURLProtectionSpace;
-
-namespace WebCore {
-
-class AuthenticationChallenge;
-class Credential;
-class ProtectionSpace;
-
-NSURLAuthenticationChallenge *mac(const AuthenticationChallenge&);
-NSURLProtectionSpace *mac(const ProtectionSpace&);
-NSURLCredential *mac(const Credential&);
-
-AuthenticationChallenge core(NSURLAuthenticationChallenge *);
-ProtectionSpace core(NSURLProtectionSpace *);
-Credential core(NSURLCredential *);
-
-}
-#endif
-
-#endif
diff --git a/WebCore/platform/network/mac/AuthenticationMac.mm b/WebCore/platform/network/mac/AuthenticationMac.mm
deleted file mode 100644
index 54e7681..0000000
--- a/WebCore/platform/network/mac/AuthenticationMac.mm
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#import "config.h"
-#import "AuthenticationMac.h"
-
-#import "AuthenticationChallenge.h"
-#import "Credential.h"
-#import "ProtectionSpace.h"
-
-#import <Foundation/NSURLAuthenticationChallenge.h>
-#import <Foundation/NSURLCredential.h>
-#import <Foundation/NSURLProtectionSpace.h>
-
-
-namespace WebCore {
-
-
-AuthenticationChallenge::AuthenticationChallenge(const ProtectionSpace& protectionSpace,
- const Credential& proposedCredential,
- unsigned previousFailureCount,
- const ResourceResponse& response,
- const ResourceError& error)
- : AuthenticationChallengeBase(protectionSpace,
- proposedCredential,
- previousFailureCount,
- response,
- error)
-{
-}
-
-AuthenticationChallenge::AuthenticationChallenge(NSURLAuthenticationChallenge *macChallenge)
- : AuthenticationChallengeBase(core([macChallenge protectionSpace]),
- core([macChallenge proposedCredential]),
- [macChallenge previousFailureCount],
- [macChallenge failureResponse],
- [macChallenge error])
- , m_sender([macChallenge sender])
- , m_macChallenge(macChallenge)
-{
-}
-
-bool AuthenticationChallenge::platformCompare(const AuthenticationChallenge& a, const AuthenticationChallenge& b)
-{
- if (a.sender() != b.sender())
- return false;
-
- if (a.nsURLAuthenticationChallenge() != b.nsURLAuthenticationChallenge())
- return false;
-
- return true;
-}
-
-NSURLAuthenticationChallenge *mac(const AuthenticationChallenge& coreChallenge)
-{
- if (coreChallenge.nsURLAuthenticationChallenge())
- return coreChallenge.nsURLAuthenticationChallenge();
-
- return [[[NSURLAuthenticationChallenge alloc] initWithProtectionSpace:mac(coreChallenge.protectionSpace())
- proposedCredential:mac(coreChallenge.proposedCredential())
- previousFailureCount:coreChallenge.previousFailureCount()
- failureResponse:coreChallenge.failureResponse().nsURLResponse()
- error:coreChallenge.error()
- sender:coreChallenge.sender()] autorelease];
-}
-
-NSURLProtectionSpace *mac(const ProtectionSpace& coreSpace)
-{
- NSString *proxyType = nil;
- NSString *protocol = nil;
- switch (coreSpace.serverType()) {
- case ProtectionSpaceServerHTTP:
- protocol = @"http";
- break;
- case ProtectionSpaceServerHTTPS:
- protocol = @"https";
- break;
- case ProtectionSpaceServerFTP:
- protocol = @"ftp";
- break;
- case ProtectionSpaceServerFTPS:
- protocol = @"ftps";
- break;
- case ProtectionSpaceProxyHTTP:
- proxyType = NSURLProtectionSpaceHTTPProxy;
- break;
- case ProtectionSpaceProxyHTTPS:
- proxyType = NSURLProtectionSpaceHTTPSProxy;
- break;
- case ProtectionSpaceProxyFTP:
- proxyType = NSURLProtectionSpaceFTPProxy;
- break;
- case ProtectionSpaceProxySOCKS:
- proxyType = NSURLProtectionSpaceSOCKSProxy;
- break;
- default:
- ASSERT_NOT_REACHED();
- }
-
- NSString *method = nil;
- switch (coreSpace.authenticationScheme()) {
- case ProtectionSpaceAuthenticationSchemeDefault:
- method = NSURLAuthenticationMethodDefault;
- break;
- case ProtectionSpaceAuthenticationSchemeHTTPBasic:
- method = NSURLAuthenticationMethodHTTPBasic;
- break;
- case ProtectionSpaceAuthenticationSchemeHTTPDigest:
- method = NSURLAuthenticationMethodHTTPDigest;
- break;
- case ProtectionSpaceAuthenticationSchemeHTMLForm:
- method = NSURLAuthenticationMethodHTMLForm;
- break;
- default:
- ASSERT_NOT_REACHED();
- }
-
- if (proxyType)
- return [[[NSURLProtectionSpace alloc] initWithProxyHost:coreSpace.host()
- port:coreSpace.port()
- type:proxyType
- realm:coreSpace.realm()
- authenticationMethod:method] autorelease];
- return [[[NSURLProtectionSpace alloc] initWithHost:coreSpace.host()
- port:coreSpace.port()
- protocol:protocol
- realm:coreSpace.realm()
- authenticationMethod:method] autorelease];
-}
-
-NSURLCredential *mac(const Credential& coreCredential)
-{
- NSURLCredentialPersistence persistence = NSURLCredentialPersistenceNone;
- switch (coreCredential.persistence()) {
- case CredentialPersistenceNone:
- break;
- case CredentialPersistenceForSession:
- persistence = NSURLCredentialPersistenceForSession;
- break;
- case CredentialPersistencePermanent:
- persistence = NSURLCredentialPersistencePermanent;
- break;
- default:
- ASSERT_NOT_REACHED();
- }
-
- return [[[NSURLCredential alloc] initWithUser:coreCredential.user()
- password:coreCredential.password()
- persistence:persistence]
- autorelease];
-}
-
-AuthenticationChallenge core(NSURLAuthenticationChallenge *macChallenge)
-{
- return AuthenticationChallenge(macChallenge);
-}
-
-ProtectionSpace core(NSURLProtectionSpace *macSpace)
-{
- ProtectionSpaceServerType serverType = ProtectionSpaceProxyHTTP;
-
- if ([macSpace isProxy]) {
- NSString *proxyType = [macSpace proxyType];
- if ([proxyType isEqualToString:NSURLProtectionSpaceHTTPProxy])
- serverType = ProtectionSpaceProxyHTTP;
- else if ([proxyType isEqualToString:NSURLProtectionSpaceHTTPSProxy])
- serverType = ProtectionSpaceProxyHTTPS;
- else if ([proxyType isEqualToString:NSURLProtectionSpaceFTPProxy])
- serverType = ProtectionSpaceProxyFTP;
- else if ([proxyType isEqualToString:NSURLProtectionSpaceSOCKSProxy])
- serverType = ProtectionSpaceProxySOCKS;
- else
- ASSERT_NOT_REACHED();
- } else {
- NSString *protocol = [macSpace protocol];
- if ([protocol caseInsensitiveCompare:@"http"] == NSOrderedSame)
- serverType = ProtectionSpaceServerHTTP;
- else if ([protocol caseInsensitiveCompare:@"https"] == NSOrderedSame)
- serverType = ProtectionSpaceServerHTTPS;
- else if ([protocol caseInsensitiveCompare:@"ftp"] == NSOrderedSame)
- serverType = ProtectionSpaceServerFTP;
- else if ([protocol caseInsensitiveCompare:@"ftps"] == NSOrderedSame)
- serverType = ProtectionSpaceServerFTPS;
- else
- ASSERT_NOT_REACHED();
- }
-
- ProtectionSpaceAuthenticationScheme scheme = ProtectionSpaceAuthenticationSchemeDefault;
- NSString *method = [macSpace authenticationMethod];
- if ([method isEqualToString:NSURLAuthenticationMethodDefault])
- scheme = ProtectionSpaceAuthenticationSchemeDefault;
- else if ([method isEqualToString:NSURLAuthenticationMethodHTTPBasic])
- scheme = ProtectionSpaceAuthenticationSchemeHTTPBasic;
- else if ([method isEqualToString:NSURLAuthenticationMethodHTTPDigest])
- scheme = ProtectionSpaceAuthenticationSchemeHTTPDigest;
- else if ([method isEqualToString:NSURLAuthenticationMethodHTMLForm])
- scheme = ProtectionSpaceAuthenticationSchemeHTMLForm;
- else
- ASSERT_NOT_REACHED();
-
- return ProtectionSpace([macSpace host], [macSpace port], serverType, [macSpace realm], scheme);
-
-}
-
-Credential core(NSURLCredential *macCredential)
-{
- CredentialPersistence persistence = CredentialPersistenceNone;
- switch ([macCredential persistence]) {
- case NSURLCredentialPersistenceNone:
- break;
- case NSURLCredentialPersistenceForSession:
- persistence = CredentialPersistenceForSession;
- break;
- case NSURLCredentialPersistencePermanent:
- persistence = CredentialPersistencePermanent;
- break;
- default:
- ASSERT_NOT_REACHED();
- }
-
- return Credential([macCredential user], [macCredential password], persistence);
-}
-
-};
diff --git a/WebCore/platform/network/mac/FormDataStreamMac.h b/WebCore/platform/network/mac/FormDataStreamMac.h
deleted file mode 100644
index 22cc8ce..0000000
--- a/WebCore/platform/network/mac/FormDataStreamMac.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef FormDataStreamMac_h
-#define FormDataStreamMac_h
-
-#include "FormData.h"
-
-@class NSMutableURLRequest;
-
-namespace WebCore {
-
- class FormData;
- class ResourceHandle;
-
- void setHTTPBody(NSMutableURLRequest *, PassRefPtr<FormData>);
- FormData* httpBodyFromStream(NSInputStream *);
-
- void associateStreamWithResourceHandle(NSInputStream *, ResourceHandle*);
- void disassociateStreamWithResourceHandle(NSInputStream *);
-
-} // namespace WebCore
-
-#endif // FormDataStreamMac_h
diff --git a/WebCore/platform/network/mac/FormDataStreamMac.mm b/WebCore/platform/network/mac/FormDataStreamMac.mm
deleted file mode 100644
index 3ef224d..0000000
--- a/WebCore/platform/network/mac/FormDataStreamMac.mm
+++ /dev/null
@@ -1,390 +0,0 @@
-/*
- * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/* originally written by Becky Willrich, additional code by Darin Adler */
-
-#import "config.h"
-#import "FormDataStreamMac.h"
-
-#import "CString.h"
-#import "FormData.h"
-#import "ResourceHandle.h"
-#import "ResourceHandleClient.h"
-#import "SchedulePair.h"
-#import "WebCoreSystemInterface.h"
-#import <sys/stat.h>
-#import <sys/types.h>
-#import <wtf/Assertions.h>
-#import <wtf/HashMap.h>
-#import <wtf/MainThread.h>
-#import <wtf/Threading.h>
-
-namespace WebCore {
-
-typedef HashMap<CFReadStreamRef, RefPtr<FormData> > StreamFormDataMap;
-static StreamFormDataMap& getStreamFormDataMap()
-{
- static StreamFormDataMap streamFormDataMap;
- return streamFormDataMap;
-}
-
-typedef HashMap<CFReadStreamRef, RefPtr<ResourceHandle> > StreamResourceHandleMap;
-static StreamResourceHandleMap& getStreamResourceHandleMap()
-{
- static StreamResourceHandleMap streamResourceHandleMap;
- return streamResourceHandleMap;
-}
-
-void associateStreamWithResourceHandle(NSInputStream *stream, ResourceHandle* resourceHandle)
-{
- ASSERT(isMainThread());
-
- ASSERT(resourceHandle);
-
- if (!stream)
- return;
-
- if (!getStreamFormDataMap().contains((CFReadStreamRef)stream))
- return;
-
- ASSERT(!getStreamResourceHandleMap().contains((CFReadStreamRef)stream));
- getStreamResourceHandleMap().set((CFReadStreamRef)stream, resourceHandle);
-}
-
-void disassociateStreamWithResourceHandle(NSInputStream *stream)
-{
- ASSERT(isMainThread());
-
- if (!stream)
- return;
-
- getStreamResourceHandleMap().remove((CFReadStreamRef)stream);
-}
-
-struct DidSendDataCallbackData {
- DidSendDataCallbackData(CFReadStreamRef stream_, unsigned long long bytesSent_, unsigned long long streamLength_)
- : stream(stream_)
- , bytesSent(bytesSent_)
- , streamLength(streamLength_)
- {
- }
-
- CFReadStreamRef stream;
- unsigned long long bytesSent;
- unsigned long long streamLength;
-};
-
-static void performDidSendDataCallback(void* context)
-{
- ASSERT(isMainThread());
-
- DidSendDataCallbackData* data = static_cast<DidSendDataCallbackData*>(context);
- ResourceHandle* resourceHandle = getStreamResourceHandleMap().get(data->stream).get();
-
- if (resourceHandle && resourceHandle->client())
- resourceHandle->client()->didSendData(resourceHandle, data->bytesSent, data->streamLength);
-
- delete data;
-}
-
-static void formEventCallback(CFReadStreamRef stream, CFStreamEventType type, void* context);
-
-struct FormContext {
- FormData* formData;
- unsigned long long streamLength;
-};
-
-struct FormStreamFields {
- SchedulePairHashSet scheduledRunLoopPairs;
- Vector<FormDataElement> remainingElements; // in reverse order
- CFReadStreamRef currentStream;
- char* currentData;
- CFReadStreamRef formStream;
- unsigned long long streamLength;
- unsigned long long bytesSent;
-};
-
-static void closeCurrentStream(FormStreamFields *form)
-{
- if (form->currentStream) {
- CFReadStreamClose(form->currentStream);
- CFReadStreamSetClient(form->currentStream, kCFStreamEventNone, NULL, NULL);
- CFRelease(form->currentStream);
- form->currentStream = NULL;
- }
- if (form->currentData) {
- fastFree(form->currentData);
- form->currentData = 0;
- }
-}
-
-static void advanceCurrentStream(FormStreamFields *form)
-{
- closeCurrentStream(form);
-
- if (form->remainingElements.isEmpty())
- return;
-
- // Create the new stream.
- FormDataElement& nextInput = form->remainingElements.last();
- if (nextInput.m_type == FormDataElement::data) {
- size_t size = nextInput.m_data.size();
- char* data = nextInput.m_data.releaseBuffer();
- form->currentStream = CFReadStreamCreateWithBytesNoCopy(0, reinterpret_cast<const UInt8*>(data), size, kCFAllocatorNull);
- form->currentData = data;
- } else {
- const String& path = nextInput.m_shouldGenerateFile ? nextInput.m_generatedFilename : nextInput.m_filename;
- CFStringRef filename = path.createCFString();
- CFURLRef fileURL = CFURLCreateWithFileSystemPath(0, filename, kCFURLPOSIXPathStyle, FALSE);
- CFRelease(filename);
- form->currentStream = CFReadStreamCreateWithFile(0, fileURL);
- CFRelease(fileURL);
- }
- form->remainingElements.removeLast();
-
- // Set up the callback.
- CFStreamClientContext context = { 0, form, NULL, NULL, NULL };
- CFReadStreamSetClient(form->currentStream, kCFStreamEventHasBytesAvailable | kCFStreamEventErrorOccurred | kCFStreamEventEndEncountered,
- formEventCallback, &context);
-
- // Schedule with the current set of run loops.
- SchedulePairHashSet::iterator end = form->scheduledRunLoopPairs.end();
- for (SchedulePairHashSet::iterator it = form->scheduledRunLoopPairs.begin(); it != end; ++it)
- CFReadStreamScheduleWithRunLoop(form->currentStream, (*it)->runLoop(), (*it)->mode());
-}
-
-static void openNextStream(FormStreamFields* form)
-{
- // Skip over any streams we can't open.
- // For some purposes we might want to return an error, but the current NSURLConnection
- // can't really do anything useful with an error at this point, so this is better.
- advanceCurrentStream(form);
- while (form->currentStream && !CFReadStreamOpen(form->currentStream))
- advanceCurrentStream(form);
-}
-
-static void* formCreate(CFReadStreamRef stream, void* context)
-{
- FormContext* formContext = static_cast<FormContext*>(context);
-
- FormStreamFields* newInfo = new FormStreamFields;
- newInfo->currentStream = NULL;
- newInfo->currentData = 0;
- newInfo->formStream = stream; // Don't retain. That would create a reference cycle.
- newInfo->streamLength = formContext->streamLength;
- newInfo->bytesSent = 0;
-
- FormData* formData = formContext->formData;
-
- // Append in reverse order since we remove elements from the end.
- size_t size = formData->elements().size();
- newInfo->remainingElements.reserveCapacity(size);
- for (size_t i = 0; i < size; ++i)
- newInfo->remainingElements.append(formData->elements()[size - i - 1]);
-
- getStreamFormDataMap().set(stream, adoptRef(formData));
-
- return newInfo;
-}
-
-static void formFinalize(CFReadStreamRef stream, void* context)
-{
- FormStreamFields* form = static_cast<FormStreamFields*>(context);
-
- getStreamFormDataMap().remove(stream);
-
- closeCurrentStream(form);
- delete form;
-}
-
-static Boolean formOpen(CFReadStreamRef stream, CFStreamError* error, Boolean* openComplete, void* context)
-{
- FormStreamFields* form = static_cast<FormStreamFields*>(context);
-
- openNextStream(form);
-
- *openComplete = TRUE;
- error->error = 0;
- return TRUE;
-}
-
-static CFIndex formRead(CFReadStreamRef stream, UInt8* buffer, CFIndex bufferLength, CFStreamError* error, Boolean* atEOF, void* context)
-{
- FormStreamFields* form = static_cast<FormStreamFields*>(context);
-
- while (form->currentStream) {
- CFIndex bytesRead = CFReadStreamRead(form->currentStream, buffer, bufferLength);
- if (bytesRead < 0) {
- *error = CFReadStreamGetError(form->currentStream);
- return -1;
- }
- if (bytesRead > 0) {
- error->error = 0;
- *atEOF = FALSE;
- form->bytesSent += bytesRead;
-
- if (!ResourceHandle::didSendBodyDataDelegateExists()) {
- // FIXME: Figure out how to only do this when a ResourceHandleClient is available.
- DidSendDataCallbackData* data = new DidSendDataCallbackData(stream, form->bytesSent, form->streamLength);
- callOnMainThread(performDidSendDataCallback, data);
- }
-
- return bytesRead;
- }
- openNextStream(form);
- }
-
- error->error = 0;
- *atEOF = TRUE;
- return 0;
-}
-
-static Boolean formCanRead(CFReadStreamRef stream, void* context)
-{
- FormStreamFields* form = static_cast<FormStreamFields*>(context);
-
- while (form->currentStream && CFReadStreamGetStatus(form->currentStream) == kCFStreamStatusAtEnd) {
- openNextStream(form);
- }
- if (!form->currentStream) {
- wkSignalCFReadStreamEnd(stream);
- return FALSE;
- }
- return CFReadStreamHasBytesAvailable(form->currentStream);
-}
-
-static void formClose(CFReadStreamRef stream, void* context)
-{
- FormStreamFields* form = static_cast<FormStreamFields*>(context);
-
- closeCurrentStream(form);
-}
-
-static void formSchedule(CFReadStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void* context)
-{
- FormStreamFields* form = static_cast<FormStreamFields*>(context);
-
- if (form->currentStream)
- CFReadStreamScheduleWithRunLoop(form->currentStream, runLoop, runLoopMode);
- form->scheduledRunLoopPairs.add(SchedulePair::create(runLoop, runLoopMode));
-}
-
-static void formUnschedule(CFReadStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void* context)
-{
- FormStreamFields* form = static_cast<FormStreamFields*>(context);
-
- if (form->currentStream)
- CFReadStreamUnscheduleFromRunLoop(form->currentStream, runLoop, runLoopMode);
- form->scheduledRunLoopPairs.remove(SchedulePair::create(runLoop, runLoopMode));
-}
-
-static void formEventCallback(CFReadStreamRef stream, CFStreamEventType type, void* context)
-{
- FormStreamFields* form = static_cast<FormStreamFields*>(context);
-
- switch (type) {
- case kCFStreamEventHasBytesAvailable:
- wkSignalCFReadStreamHasBytes(form->formStream);
- break;
- case kCFStreamEventErrorOccurred: {
- CFStreamError readStreamError = CFReadStreamGetError(stream);
- wkSignalCFReadStreamError(form->formStream, &readStreamError);
- break;
- }
- case kCFStreamEventEndEncountered:
- openNextStream(form);
- if (!form->currentStream) {
- wkSignalCFReadStreamEnd(form->formStream);
- }
- break;
- case kCFStreamEventNone:
- LOG_ERROR("unexpected kCFStreamEventNone");
- break;
- case kCFStreamEventOpenCompleted:
- LOG_ERROR("unexpected kCFStreamEventOpenCompleted");
- break;
- case kCFStreamEventCanAcceptBytes:
- LOG_ERROR("unexpected kCFStreamEventCanAcceptBytes");
- break;
- }
-}
-
-void setHTTPBody(NSMutableURLRequest *request, PassRefPtr<FormData> formData)
-{
- if (!formData)
- return;
-
- size_t count = formData->elements().size();
-
- // Handle the common special case of one piece of form data, with no files.
- if (count == 1 && !formData->alwaysStream()) {
- const FormDataElement& element = formData->elements()[0];
- if (element.m_type == FormDataElement::data) {
- NSData *data = [[NSData alloc] initWithBytes:element.m_data.data() length:element.m_data.size()];
- [request setHTTPBody:data];
- [data release];
- return;
- }
- }
-
- // Precompute the content length so NSURLConnection doesn't use chunked mode.
- long long length = 0;
- for (size_t i = 0; i < count; ++i) {
- const FormDataElement& element = formData->elements()[i];
- if (element.m_type == FormDataElement::data)
- length += element.m_data.size();
- else {
- const String& filename = element.m_shouldGenerateFile ? element.m_generatedFilename : element.m_filename;
- struct stat sb;
- int statResult = stat(filename.utf8().data(), &sb);
- if (statResult == 0 && (sb.st_mode & S_IFMT) == S_IFREG)
- length += sb.st_size;
- }
- }
-
- // Set the length.
- [request setValue:[NSString stringWithFormat:@"%lld", length] forHTTPHeaderField:@"Content-Length"];
-
- // Create and set the stream.
-
- // Pass the length along with the formData so it does not have to be recomputed.
- FormContext formContext = { formData.releaseRef(), length };
-
- CFReadStreamRef stream = wkCreateCustomCFReadStream(formCreate, formFinalize,
- formOpen, formRead, formCanRead, formClose, formSchedule, formUnschedule,
- &formContext);
- [request setHTTPBodyStream:(NSInputStream *)stream];
- CFRelease(stream);
-}
-
-FormData* httpBodyFromStream(NSInputStream* stream)
-{
- return getStreamFormDataMap().get((CFReadStreamRef)stream).get();
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/network/mac/NetworkStateNotifierMac.cpp b/WebCore/platform/network/mac/NetworkStateNotifierMac.cpp
deleted file mode 100644
index 6e0b70d..0000000
--- a/WebCore/platform/network/mac/NetworkStateNotifierMac.cpp
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "NetworkStateNotifier.h"
-
-#include <SystemConfiguration/SystemConfiguration.h>
-
-namespace WebCore {
-
-static const double StateChangeTimerInterval = 2.0;
-
-void NetworkStateNotifier::updateState()
-{
- // Assume that we're offline until proven otherwise.
- m_isOnLine = false;
-
- RetainPtr<CFStringRef> str(AdoptCF, SCDynamicStoreKeyCreateNetworkInterface(0, kSCDynamicStoreDomainState));
-
- RetainPtr<CFPropertyListRef> propertyList(AdoptCF, SCDynamicStoreCopyValue(m_store.get(), str.get()));
-
- if (!propertyList)
- return;
-
- if (CFGetTypeID(propertyList.get()) != CFDictionaryGetTypeID())
- return;
-
- CFArrayRef netInterfaces = (CFArrayRef)CFDictionaryGetValue((CFDictionaryRef)propertyList.get(), kSCDynamicStorePropNetInterfaces);
- if (CFGetTypeID(netInterfaces) != CFArrayGetTypeID())
- return;
-
- for (CFIndex i = 0; i < CFArrayGetCount(netInterfaces); i++) {
- CFStringRef interface = (CFStringRef)CFArrayGetValueAtIndex(netInterfaces, i);
- if (CFGetTypeID(interface) != CFStringGetTypeID())
- continue;
-
- // Ignore the loopback interface.
- if (CFStringFind(interface, CFSTR("lo"), kCFCompareAnchored).location != kCFNotFound)
- continue;
-
- RetainPtr<CFStringRef> key(AdoptCF, SCDynamicStoreKeyCreateNetworkInterfaceEntity(0, kSCDynamicStoreDomainState, interface, kSCEntNetIPv4));
-
- RetainPtr<CFArrayRef> keyList(AdoptCF, SCDynamicStoreCopyKeyList(m_store.get(), key.get()));
-
- if (keyList && CFArrayGetCount(keyList.get())) {
- m_isOnLine = true;
- break;
- }
- }
-}
-
-void NetworkStateNotifier::dynamicStoreCallback(SCDynamicStoreRef store, CFArrayRef changedKeys, void *info)
-{
- NetworkStateNotifier* notifier = static_cast<NetworkStateNotifier*>(info);
-
- // Calling updateState() could be expensive so we schedule a timer that will do it
- // when things have cooled down.
- notifier->m_networkStateChangeTimer.startOneShot(StateChangeTimerInterval);
-}
-
-void NetworkStateNotifier::networkStateChangeTimerFired(Timer<NetworkStateNotifier>*)
-{
- bool oldOnLine = m_isOnLine;
-
- updateState();
-
- if (m_isOnLine == oldOnLine)
- return;
-
- if (m_networkStateChangedFunction)
- m_networkStateChangedFunction();
-}
-
-NetworkStateNotifier::NetworkStateNotifier()
- : m_isOnLine(false)
- , m_networkStateChangeTimer(this, &NetworkStateNotifier::networkStateChangeTimerFired)
-{
- SCDynamicStoreContext context = { 0, this, 0, 0, 0 };
-
- m_store.adoptCF(SCDynamicStoreCreate(0, CFSTR("com.apple.WebCore"), dynamicStoreCallback, &context));
- if (!m_store)
- return;
-
- RetainPtr<CFRunLoopSourceRef> configSource = SCDynamicStoreCreateRunLoopSource(0, m_store.get(), 0);
- if (!configSource)
- return;
-
- CFRunLoopAddSource(CFRunLoopGetCurrent(), configSource.get(), kCFRunLoopCommonModes);
-
- RetainPtr<CFMutableArrayRef> keys(AdoptCF, CFArrayCreateMutable(0, 0, &kCFTypeArrayCallBacks));
- RetainPtr<CFMutableArrayRef> patterns(AdoptCF, CFArrayCreateMutable(0, 0, &kCFTypeArrayCallBacks));
-
- RetainPtr<CFStringRef> key;
- RetainPtr<CFStringRef> pattern;
-
- key.adoptCF(SCDynamicStoreKeyCreateNetworkGlobalEntity(0, kSCDynamicStoreDomainState, kSCEntNetIPv4));
- CFArrayAppendValue(keys.get(), key.get());
-
- pattern.adoptCF(SCDynamicStoreKeyCreateNetworkInterfaceEntity(0, kSCDynamicStoreDomainState, kSCCompAnyRegex, kSCEntNetIPv4));
- CFArrayAppendValue(patterns.get(), pattern.get());
-
- key.adoptCF(SCDynamicStoreKeyCreateNetworkGlobalEntity(0, kSCDynamicStoreDomainState, kSCEntNetDNS));
- CFArrayAppendValue(keys.get(), key.get());
-
- SCDynamicStoreSetNotificationKeys(m_store.get(), keys.get(), patterns.get());
-
- updateState();
-}
-
-}
diff --git a/WebCore/platform/network/mac/ResourceError.h b/WebCore/platform/network/mac/ResourceError.h
deleted file mode 100644
index 2f779c9..0000000
--- a/WebCore/platform/network/mac/ResourceError.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ResourceError_h
-#define ResourceError_h
-
-#include "ResourceErrorBase.h"
-#include <wtf/RetainPtr.h>
-
-#ifdef __OBJC__
-@class NSError;
-#else
-class NSError;
-#endif
-
-namespace WebCore {
-
- class ResourceError : public ResourceErrorBase {
- public:
- ResourceError()
- : m_dataIsUpToDate(true)
- {
- }
-
- ResourceError(const String& domain, int errorCode, const String& failingURL, const String& localizedDescription)
- : ResourceErrorBase(domain, errorCode, failingURL, localizedDescription)
- , m_dataIsUpToDate(true)
- {
- }
-
- ResourceError(NSError* error)
- : m_dataIsUpToDate(false)
- , m_platformError(error)
- {
- m_isNull = !error;
- }
-
- operator NSError*() const;
-
- private:
- friend class ResourceErrorBase;
-
- void platformLazyInit();
- static bool platformCompare(const ResourceError& a, const ResourceError& b);
-
- bool m_dataIsUpToDate;
- mutable RetainPtr<NSError> m_platformError;
-};
-
-} // namespace WebCore
-
-#endif // ResourceError_h_
diff --git a/WebCore/platform/network/mac/ResourceErrorMac.mm b/WebCore/platform/network/mac/ResourceErrorMac.mm
deleted file mode 100644
index e59eadd..0000000
--- a/WebCore/platform/network/mac/ResourceErrorMac.mm
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "ResourceError.h"
-
-#import "KURL.h"
-#import <Foundation/Foundation.h>
-
-@interface NSError (WebExtras)
-- (NSString *)_web_localizedDescription;
-@end
-
-namespace WebCore {
-
-void ResourceError::platformLazyInit()
-{
- if (m_dataIsUpToDate)
- return;
-
- m_domain = [m_platformError.get() domain];
- m_errorCode = [m_platformError.get() code];
-
- NSString* failingURLString = [[m_platformError.get() userInfo] valueForKey:@"NSErrorFailingURLStringKey"];
- if (!failingURLString)
- failingURLString = [[[m_platformError.get() userInfo] valueForKey:@"NSErrorFailingURLKey"] absoluteString];
-
- m_localizedDescription = [m_platformError.get() _web_localizedDescription];
-
- m_dataIsUpToDate = true;
-}
-
-bool ResourceError::platformCompare(const ResourceError& a, const ResourceError& b)
-{
- return (NSError*)a == (NSError*)b;
-}
-
-ResourceError::operator NSError*() const
-{
- if (m_isNull) {
- ASSERT(!m_platformError);
- return nil;
- }
-
- if (!m_platformError) {
- RetainPtr<NSMutableDictionary> userInfo(AdoptNS, [[NSMutableDictionary alloc] init]);
-
- if (!m_localizedDescription.isEmpty())
- [userInfo.get() setValue:m_localizedDescription forKey:NSLocalizedDescriptionKey];
-
- if (!m_failingURL.isEmpty()) {
- NSURL *cocoaURL = KURL(m_failingURL);
- [userInfo.get() setValue:m_failingURL forKey:@"NSErrorFailingURLStringKey"];
- [userInfo.get() setValue:cocoaURL forKey:@"NSErrorFailingURLKey"];
- }
-
- m_platformError.adoptNS([[NSError alloc] initWithDomain:m_domain code:m_errorCode userInfo:userInfo.get()]);
- }
-
- return m_platformError.get();
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/network/mac/ResourceHandleMac.mm b/WebCore/platform/network/mac/ResourceHandleMac.mm
deleted file mode 100644
index b4c5ddf..0000000
--- a/WebCore/platform/network/mac/ResourceHandleMac.mm
+++ /dev/null
@@ -1,779 +0,0 @@
-/*
- * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "ResourceHandle.h"
-#import "ResourceHandleInternal.h"
-
-#import "AuthenticationChallenge.h"
-#import "AuthenticationMac.h"
-#import "BlockExceptions.h"
-#import "DocLoader.h"
-#import "FormDataStreamMac.h"
-#import "Frame.h"
-#import "FrameLoader.h"
-#import "Page.h"
-#import "ResourceError.h"
-#import "ResourceResponse.h"
-#import "SchedulePair.h"
-#import "SharedBuffer.h"
-#import "SubresourceLoader.h"
-#import "WebCoreSystemInterface.h"
-
-#ifdef BUILDING_ON_TIGER
-typedef int NSInteger;
-#endif
-
-using namespace WebCore;
-
-@interface WebCoreResourceHandleAsDelegate : NSObject <NSURLAuthenticationChallengeSender>
-{
- ResourceHandle* m_handle;
-#ifndef BUILDING_ON_TIGER
- NSURL *m_url;
-#endif
-}
-- (id)initWithHandle:(ResourceHandle*)handle;
-- (void)detachHandle;
-@end
-
-@interface NSURLConnection (NSURLConnectionTigerPrivate)
-- (NSData *)_bufferedData;
-@end
-
-#ifndef BUILDING_ON_TIGER
-@interface WebCoreSynchronousLoader : NSObject {
- NSURL *m_url;
- NSURLResponse *m_response;
- NSMutableData *m_data;
- NSError *m_error;
- BOOL m_isDone;
-}
-+ (NSData *)loadRequest:(NSURLRequest *)request returningResponse:(NSURLResponse **)response error:(NSError **)error;
-@end
-
-static NSString *WebCoreSynchronousLoaderRunLoopMode = @"WebCoreSynchronousLoaderRunLoopMode";
-#endif
-
-namespace WebCore {
-
-#ifdef BUILDING_ON_TIGER
-static unsigned inNSURLConnectionCallback;
-#endif
-
-#ifndef NDEBUG
-static bool isInitializingConnection;
-#endif
-
-class CallbackGuard {
-public:
- CallbackGuard()
- {
-#ifdef BUILDING_ON_TIGER
- ++inNSURLConnectionCallback;
-#endif
- }
- ~CallbackGuard()
- {
-#ifdef BUILDING_ON_TIGER
- ASSERT(inNSURLConnectionCallback > 0);
- --inNSURLConnectionCallback;
-#endif
- }
-};
-
-ResourceHandleInternal::~ResourceHandleInternal()
-{
-}
-
-ResourceHandle::~ResourceHandle()
-{
- releaseDelegate();
-}
-
-static const double MaxFoundationVersionWithoutdidSendBodyDataDelegate = 677.21;
-bool ResourceHandle::didSendBodyDataDelegateExists()
-{
-// FIXME: Refine this check as the delegate becomes more widely available.
-#ifdef BUILDING_ON_LEOPARD
- return NSFoundationVersionNumber > MaxFoundationVersionWithoutdidSendBodyDataDelegate;
-#else
- return false;
-#endif
-}
-
-bool ResourceHandle::start(Frame* frame)
-{
- if (!frame)
- return false;
-
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
-
- // If we are no longer attached to a Page, this must be an attempted load from an
- // onUnload handler, so let's just block it.
- Page* page = frame->page();
- if (!page)
- return false;
-
-#ifndef NDEBUG
- isInitializingConnection = YES;
-#endif
- id delegate;
-
- if (d->m_mightDownloadFromHandle) {
- ASSERT(!d->m_proxy);
- d->m_proxy = wkCreateNSURLConnectionDelegateProxy();
- [d->m_proxy.get() setDelegate:ResourceHandle::delegate()];
- [d->m_proxy.get() release];
-
- delegate = d->m_proxy.get();
- } else
- delegate = ResourceHandle::delegate();
-
- if (!ResourceHandle::didSendBodyDataDelegateExists())
- associateStreamWithResourceHandle([d->m_request.nsURLRequest() HTTPBodyStream], this);
-
- NSURLConnection *connection;
-
- if (d->m_shouldContentSniff)
-#ifdef BUILDING_ON_TIGER
- connection = [[NSURLConnection alloc] initWithRequest:d->m_request.nsURLRequest() delegate:delegate];
-#else
- connection = [[NSURLConnection alloc] initWithRequest:d->m_request.nsURLRequest() delegate:delegate startImmediately:NO];
-#endif
- else {
- NSMutableURLRequest *request = [d->m_request.nsURLRequest() mutableCopy];
- wkSetNSURLRequestShouldContentSniff(request, NO);
-#ifdef BUILDING_ON_TIGER
- connection = [[NSURLConnection alloc] initWithRequest:request delegate:delegate];
-#else
- connection = [[NSURLConnection alloc] initWithRequest:request delegate:delegate startImmediately:NO];
-#endif
- [request release];
- }
-
-#ifndef BUILDING_ON_TIGER
- bool scheduled = false;
- if (SchedulePairHashSet* scheduledPairs = page->scheduledRunLoopPairs()) {
- SchedulePairHashSet::iterator end = scheduledPairs->end();
- for (SchedulePairHashSet::iterator it = scheduledPairs->begin(); it != end; ++it) {
- if (NSRunLoop *runLoop = (*it)->nsRunLoop()) {
- [connection scheduleInRunLoop:runLoop forMode:(NSString *)(*it)->mode()];
- scheduled = true;
- }
- }
- }
-
- // Start the connection if we did schedule with at least one runloop.
- // We can't start the connection until we have one runloop scheduled.
- if (scheduled)
- [connection start];
- else
- d->m_startWhenScheduled = true;
-#endif
-
-#ifndef NDEBUG
- isInitializingConnection = NO;
-#endif
-
- d->m_connection = connection;
-
- if (d->m_connection) {
- [connection release];
-
- if (d->m_defersLoading)
- wkSetNSURLConnectionDefersCallbacks(d->m_connection.get(), YES);
-
- return true;
- }
-
- END_BLOCK_OBJC_EXCEPTIONS;
-
- return false;
-}
-
-void ResourceHandle::cancel()
-{
- if (!ResourceHandle::didSendBodyDataDelegateExists())
- disassociateStreamWithResourceHandle([d->m_request.nsURLRequest() HTTPBodyStream]);
- [d->m_connection.get() cancel];
-}
-
-void ResourceHandle::setDefersLoading(bool defers)
-{
- d->m_defersLoading = defers;
- if (d->m_connection)
- wkSetNSURLConnectionDefersCallbacks(d->m_connection.get(), defers);
-}
-
-void ResourceHandle::schedule(SchedulePair* pair)
-{
-#ifndef BUILDING_ON_TIGER
- NSRunLoop *runLoop = pair->nsRunLoop();
- if (!runLoop)
- return;
- [d->m_connection.get() scheduleInRunLoop:runLoop forMode:(NSString *)pair->mode()];
- if (d->m_startWhenScheduled) {
- [d->m_connection.get() start];
- d->m_startWhenScheduled = false;
- }
-#endif
-}
-
-void ResourceHandle::unschedule(SchedulePair* pair)
-{
-#ifndef BUILDING_ON_TIGER
- if (NSRunLoop *runLoop = pair->nsRunLoop())
- [d->m_connection.get() unscheduleFromRunLoop:runLoop forMode:(NSString *)pair->mode()];
-#endif
-}
-
-WebCoreResourceHandleAsDelegate *ResourceHandle::delegate()
-{
- if (!d->m_delegate) {
- WebCoreResourceHandleAsDelegate *delegate = [[WebCoreResourceHandleAsDelegate alloc] initWithHandle:this];
- d->m_delegate = delegate;
- [delegate release];
- }
- return d->m_delegate.get();
-}
-
-void ResourceHandle::releaseDelegate()
-{
- if (!d->m_delegate)
- return;
- if (d->m_proxy)
- [d->m_proxy.get() setDelegate:nil];
- [d->m_delegate.get() detachHandle];
- d->m_delegate = nil;
-}
-
-bool ResourceHandle::supportsBufferedData()
-{
- static bool supportsBufferedData = [NSURLConnection instancesRespondToSelector:@selector(_bufferedData)];
- return supportsBufferedData;
-}
-
-PassRefPtr<SharedBuffer> ResourceHandle::bufferedData()
-{
- if (ResourceHandle::supportsBufferedData())
- return SharedBuffer::wrapNSData([d->m_connection.get() _bufferedData]);
-
- return 0;
-}
-
-id ResourceHandle::releaseProxy()
-{
- id proxy = [[d->m_proxy.get() retain] autorelease];
- d->m_proxy = nil;
- [proxy setDelegate:nil];
- return proxy;
-}
-
-NSURLConnection *ResourceHandle::connection() const
-{
- return d->m_connection.get();
-}
-
-bool ResourceHandle::loadsBlocked()
-{
-#ifndef BUILDING_ON_TIGER
- return false;
-#else
- // On Tiger, if we're in an NSURLConnection callback, that blocks all other NSURLConnection callbacks.
- // On Leopard and newer, it blocks only callbacks on that same NSURLConnection object, which is not
- // a problem in practice.
- return inNSURLConnectionCallback != 0;
-#endif
-}
-
-bool ResourceHandle::willLoadFromCache(ResourceRequest& request)
-{
- request.setCachePolicy(ReturnCacheDataDontLoad);
- NSURLResponse *nsURLResponse = nil;
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
-
- [NSURLConnection sendSynchronousRequest:request.nsURLRequest() returningResponse:&nsURLResponse error:nil];
-
- END_BLOCK_OBJC_EXCEPTIONS;
-
- return nsURLResponse;
-}
-
-void ResourceHandle::loadResourceSynchronously(const ResourceRequest& request, ResourceError& error, ResourceResponse& response, Vector<char>& data, Frame*)
-{
- NSError *nsError = nil;
-
- NSURLResponse *nsURLResponse = nil;
- NSData *result = nil;
-
- ASSERT(!request.isEmpty());
-
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
-
-#ifndef BUILDING_ON_TIGER
- result = [WebCoreSynchronousLoader loadRequest:request.nsURLRequest() returningResponse:&nsURLResponse error:&nsError];
-#else
- result = [NSURLConnection sendSynchronousRequest:request.nsURLRequest() returningResponse:&nsURLResponse error:&nsError];
-#endif
- END_BLOCK_OBJC_EXCEPTIONS;
-
- if (nsError == nil)
- response = nsURLResponse;
- else {
- response = ResourceResponse(request.url(), String(), 0, String(), String());
- if ([nsError domain] == NSURLErrorDomain)
- switch ([nsError code]) {
- case NSURLErrorUserCancelledAuthentication:
- // FIXME: we should really return the actual HTTP response, but sendSynchronousRequest doesn't provide us with one.
- response.setHTTPStatusCode(401);
- break;
- default:
- response.setHTTPStatusCode([nsError code]);
- }
- else
- response.setHTTPStatusCode(404);
- }
-
- data.resize([result length]);
- memcpy(data.data(), [result bytes], [result length]);
-
- error = nsError;
-}
-
-void ResourceHandle::didReceiveAuthenticationChallenge(const AuthenticationChallenge& challenge)
-{
- ASSERT(!d->m_currentMacChallenge);
- ASSERT(d->m_currentWebChallenge.isNull());
- // Since NSURLConnection networking relies on keeping a reference to the original NSURLAuthenticationChallenge,
- // we make sure that is actually present
- ASSERT(challenge.nsURLAuthenticationChallenge());
-
- d->m_currentMacChallenge = challenge.nsURLAuthenticationChallenge();
- NSURLAuthenticationChallenge *webChallenge = [[NSURLAuthenticationChallenge alloc] initWithAuthenticationChallenge:d->m_currentMacChallenge
- sender:(id<NSURLAuthenticationChallengeSender>)delegate()];
- d->m_currentWebChallenge = core(webChallenge);
- [webChallenge release];
-
- if (client())
- client()->didReceiveAuthenticationChallenge(this, d->m_currentWebChallenge);
-}
-
-void ResourceHandle::didCancelAuthenticationChallenge(const AuthenticationChallenge& challenge)
-{
- ASSERT(d->m_currentMacChallenge);
- ASSERT(!d->m_currentWebChallenge.isNull());
- ASSERT(d->m_currentWebChallenge == challenge);
-
- if (client())
- client()->didCancelAuthenticationChallenge(this, d->m_currentWebChallenge);
-}
-
-void ResourceHandle::receivedCredential(const AuthenticationChallenge& challenge, const Credential& credential)
-{
- ASSERT(!challenge.isNull());
- if (challenge != d->m_currentWebChallenge)
- return;
-
- [[d->m_currentMacChallenge sender] useCredential:mac(credential) forAuthenticationChallenge:d->m_currentMacChallenge];
-
- clearAuthentication();
-}
-
-void ResourceHandle::receivedRequestToContinueWithoutCredential(const AuthenticationChallenge& challenge)
-{
- ASSERT(!challenge.isNull());
- if (challenge != d->m_currentWebChallenge)
- return;
-
- [[d->m_currentMacChallenge sender] continueWithoutCredentialForAuthenticationChallenge:d->m_currentMacChallenge];
-
- clearAuthentication();
-}
-
-void ResourceHandle::receivedCancellation(const AuthenticationChallenge& challenge)
-{
- if (challenge != d->m_currentWebChallenge)
- return;
-
- if (client())
- client()->receivedCancellation(this, challenge);
-}
-
-} // namespace WebCore
-
-@implementation WebCoreResourceHandleAsDelegate
-
-- (id)initWithHandle:(ResourceHandle*)handle
-{
- self = [self init];
- if (!self)
- return nil;
- m_handle = handle;
- return self;
-}
-
-#ifndef BUILDING_ON_TIGER
-- (void)dealloc
-{
- [m_url release];
- [super dealloc];
-}
-#endif
-
-- (void)detachHandle
-{
- m_handle = 0;
-}
-
-- (NSURLRequest *)connection:(NSURLConnection *)con willSendRequest:(NSURLRequest *)newRequest redirectResponse:(NSURLResponse *)redirectResponse
-{
- // the willSendRequest call may cancel this load, in which case self could be deallocated
- RetainPtr<WebCoreResourceHandleAsDelegate> protect(self);
-
- if (!m_handle || !m_handle->client())
- return nil;
-
- // See <rdar://problem/5380697> . This is a workaround for a behavior change in CFNetwork where willSendRequest gets called more often.
- if (!redirectResponse)
- return newRequest;
-
- CallbackGuard guard;
- ResourceRequest request = newRequest;
- m_handle->client()->willSendRequest(m_handle, request, redirectResponse);
-#ifndef BUILDING_ON_TIGER
- NSURL *copy = [[request.nsURLRequest() URL] copy];
- [m_url release];
- m_url = copy;
-#endif
-
- if (!ResourceHandle::didSendBodyDataDelegateExists()) {
- // The client may change the request's body stream, in which case we have to re-associate
- // the handle with the new stream so upload progress callbacks continue to work correctly.
- NSInputStream* oldBodyStream = [newRequest HTTPBodyStream];
- NSInputStream* newBodyStream = [request.nsURLRequest() HTTPBodyStream];
- if (oldBodyStream != newBodyStream) {
- disassociateStreamWithResourceHandle(oldBodyStream);
- associateStreamWithResourceHandle(newBodyStream, m_handle);
- }
- }
-
- return request.nsURLRequest();
-}
-
-- (void)connection:(NSURLConnection *)con didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
-{
-#ifndef BUILDING_ON_TIGER
- if ([challenge previousFailureCount] == 0) {
- NSString *user = [m_url user];
- NSString *password = [m_url password];
-
- if (user && password) {
- NSURLCredential *credential = [[NSURLCredential alloc] initWithUser:user
- password:password
- persistence:NSURLCredentialPersistenceForSession];
- [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge];
- [credential release];
- return;
- }
- }
-#endif
-
- if (!m_handle)
- return;
- CallbackGuard guard;
- m_handle->didReceiveAuthenticationChallenge(core(challenge));
-}
-
-- (void)connection:(NSURLConnection *)con didCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
-{
- if (!m_handle)
- return;
- CallbackGuard guard;
- m_handle->didCancelAuthenticationChallenge(core(challenge));
-}
-
-- (void)connection:(NSURLConnection *)con didReceiveResponse:(NSURLResponse *)r
-{
- if (!m_handle || !m_handle->client())
- return;
- CallbackGuard guard;
- m_handle->client()->didReceiveResponse(m_handle, r);
-}
-
-- (void)connection:(NSURLConnection *)con didReceiveData:(NSData *)data lengthReceived:(long long)lengthReceived
-{
- if (!m_handle || !m_handle->client())
- return;
- // FIXME: If we get more than 2B bytes in a single chunk, this code won't do the right thing.
- // However, with today's computers and networking speeds, this won't happen in practice.
- // Could be an issue with a giant local file.
- CallbackGuard guard;
- m_handle->client()->didReceiveData(m_handle, (const char*)[data bytes], [data length], static_cast<int>(lengthReceived));
-}
-
-- (void)connection:(NSURLConnection *)con willStopBufferingData:(NSData *)data
-{
- if (!m_handle || !m_handle->client())
- return;
- // FIXME: If we get a resource with more than 2B bytes, this code won't do the right thing.
- // However, with today's computers and networking speeds, this won't happen in practice.
- // Could be an issue with a giant local file.
- CallbackGuard guard;
- m_handle->client()->willStopBufferingData(m_handle, (const char*)[data bytes], static_cast<int>([data length]));
-}
-
-- (void)connection:(NSURLConnection *)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite
-{
- if (!m_handle || !m_handle->client())
- return;
- CallbackGuard guard;
- m_handle->client()->didSendData(m_handle, totalBytesWritten, totalBytesExpectedToWrite);
-}
-
-- (void)connectionDidFinishLoading:(NSURLConnection *)con
-{
- if (!m_handle || !m_handle->client())
- return;
- CallbackGuard guard;
-
- if (!ResourceHandle::didSendBodyDataDelegateExists())
- disassociateStreamWithResourceHandle([m_handle->request().nsURLRequest() HTTPBodyStream]);
-
- m_handle->client()->didFinishLoading(m_handle);
-}
-
-- (void)connection:(NSURLConnection *)con didFailWithError:(NSError *)error
-{
- if (!m_handle || !m_handle->client())
- return;
- CallbackGuard guard;
-
- if (!ResourceHandle::didSendBodyDataDelegateExists())
- disassociateStreamWithResourceHandle([m_handle->request().nsURLRequest() HTTPBodyStream]);
-
- m_handle->client()->didFail(m_handle, error);
-}
-
-#ifdef BUILDING_ON_TIGER
-- (void)_callConnectionWillCacheResponseWithInfo:(NSMutableDictionary *)info
-{
- NSURLConnection *connection = [info objectForKey:@"connection"];
- NSCachedURLResponse *cachedResponse = [info objectForKey:@"cachedResponse"];
- NSCachedURLResponse *result = [self connection:connection willCacheResponse:cachedResponse];
- if (result)
- [info setObject:result forKey:@"result"];
-}
-#endif
-
-- (NSCachedURLResponse *)connection:(NSURLConnection *)connection willCacheResponse:(NSCachedURLResponse *)cachedResponse
-{
-#ifdef BUILDING_ON_TIGER
- // On Tiger CFURLConnection can sometimes call the connection:willCacheResponse: delegate method on
- // a secondary thread instead of the main thread. If this happens perform the work on the main thread.
- if (!pthread_main_np()) {
- NSMutableDictionary *info = [[NSMutableDictionary alloc] init];
- if (connection)
- [info setObject:connection forKey:@"connection"];
- if (cachedResponse)
- [info setObject:cachedResponse forKey:@"cachedResponse"];
-
- // Include synchronous url connection's mode as an acceptable run loopmode
- // <rdar://problem/5511842>
- NSArray *modes = [[NSArray alloc] initWithObjects:(NSString *)kCFRunLoopCommonModes, @"NSSynchronousURLConnection_PrivateMode", nil];
- [self performSelectorOnMainThread:@selector(_callConnectionWillCacheResponseWithInfo:) withObject:info waitUntilDone:YES modes:modes];
- [modes release];
-
- NSCachedURLResponse *result = [[info valueForKey:@"result"] retain];
- [info release];
-
- return [result autorelease];
- }
-#endif
-
-#ifndef NDEBUG
- if (isInitializingConnection)
- LOG_ERROR("connection:willCacheResponse: was called inside of [NSURLConnection initWithRequest:delegate:] (4067625)");
-#endif
- if (!m_handle || !m_handle->client())
- return nil;
-
- CallbackGuard guard;
-
- NSCachedURLResponse *newResponse = m_handle->client()->willCacheResponse(m_handle, cachedResponse);
- if (newResponse != cachedResponse)
- return newResponse;
-
- CacheStoragePolicy policy = static_cast<CacheStoragePolicy>([newResponse storagePolicy]);
-
- m_handle->client()->willCacheResponse(m_handle, policy);
-
- if (static_cast<NSURLCacheStoragePolicy>(policy) != [newResponse storagePolicy])
- newResponse = [[[NSCachedURLResponse alloc] initWithResponse:[newResponse response]
- data:[newResponse data]
- userInfo:[newResponse userInfo]
- storagePolicy:static_cast<NSURLCacheStoragePolicy>(policy)] autorelease];
-
- return newResponse;
-}
-
-- (void)useCredential:(NSURLCredential *)credential forAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
-{
- if (!m_handle)
- return;
- m_handle->receivedCredential(core(challenge), core(credential));
-}
-
-- (void)continueWithoutCredentialForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
-{
- if (!m_handle)
- return;
- m_handle->receivedRequestToContinueWithoutCredential(core(challenge));
-}
-
-- (void)cancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
-{
- if (!m_handle)
- return;
- m_handle->receivedCancellation(core(challenge));
-}
-
-@end
-
-#ifndef BUILDING_ON_TIGER
-@implementation WebCoreSynchronousLoader
-
-- (BOOL)_isDone
-{
- return m_isDone;
-}
-
-- (void)dealloc
-{
- [m_url release];
- [m_response release];
- [m_data release];
- [m_error release];
-
- [super dealloc];
-}
-
-- (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)newRequest redirectResponse:(NSURLResponse *)redirectResponse
-{
- NSURL *copy = [[newRequest URL] copy];
- [m_url release];
- m_url = copy;
-
- return newRequest;
-}
-
-- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
-{
- if ([challenge previousFailureCount] == 0) {
- NSString *user = [m_url user];
- NSString *password = [m_url password];
-
- if (user && password) {
- NSURLCredential *credential = [[NSURLCredential alloc] initWithUser:user
- password:password
- persistence:NSURLCredentialPersistenceForSession];
- [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge];
- [credential release];
- return;
- }
- }
-
- [[challenge sender] continueWithoutCredentialForAuthenticationChallenge:challenge];
-}
-
-- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
-{
- NSURLResponse *r = [response copy];
-
- [m_response release];
- m_response = r;
-}
-
-- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
-{
- if (!m_data)
- m_data = [[NSMutableData alloc] init];
-
- [m_data appendData:data];
-}
-
-- (void)connectionDidFinishLoading:(NSURLConnection *)connection
-{
- m_isDone = YES;
-}
-
-- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
-{
- ASSERT(!m_error);
-
- m_error = [error retain];
- m_isDone = YES;
-}
-
-- (NSData *)_data
-{
- return [[m_data retain] autorelease];
-}
-
-- (NSURLResponse *)_response
-{
- return [[m_response retain] autorelease];
-}
-
-- (NSError *)_error
-{
- return [[m_error retain] autorelease];
-}
-
-+ (NSData *)loadRequest:(NSURLRequest *)request returningResponse:(NSURLResponse **)response error:(NSError **)error
-{
- WebCoreSynchronousLoader *delegate = [[WebCoreSynchronousLoader alloc] init];
-
- NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:delegate startImmediately:NO];
- [connection scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:WebCoreSynchronousLoaderRunLoopMode];
- [connection start];
-
- while (![delegate _isDone])
- [[NSRunLoop currentRunLoop] runMode:WebCoreSynchronousLoaderRunLoopMode beforeDate:[NSDate distantFuture]];
-
- NSData *data = [delegate _data];
- *response = [delegate _response];
- *error = [delegate _error];
-
- [connection cancel];
-
- [connection release];
- [delegate release];
-
- return data;
-}
-
-@end
-#endif
diff --git a/WebCore/platform/network/mac/ResourceRequest.h b/WebCore/platform/network/mac/ResourceRequest.h
deleted file mode 100644
index 5bcb33e..0000000
--- a/WebCore/platform/network/mac/ResourceRequest.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2003, 2006, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ResourceRequest_h
-#define ResourceRequest_h
-
-#include "ResourceRequestBase.h"
-
-#include <wtf/RetainPtr.h>
-#ifdef __OBJC__
-@class NSURLRequest;
-#else
-class NSURLRequest;
-#endif
-
-namespace WebCore {
-
- class ResourceRequest : public ResourceRequestBase {
- public:
- ResourceRequest(const String& url)
- : ResourceRequestBase(KURL(url), UseProtocolCachePolicy)
- {
- }
-
- ResourceRequest(const KURL& url)
- : ResourceRequestBase(url, UseProtocolCachePolicy)
- {
- }
-
- ResourceRequest(const KURL& url, const String& referrer, ResourceRequestCachePolicy policy = UseProtocolCachePolicy)
- : ResourceRequestBase(url, policy)
- {
- setHTTPReferrer(referrer);
- }
-
- ResourceRequest()
- : ResourceRequestBase(KURL(), UseProtocolCachePolicy)
- {
- }
-
- ResourceRequest(NSURLRequest* nsRequest)
- : ResourceRequestBase()
- , m_nsRequest(nsRequest) { }
-
- void applyWebArchiveHackForMail();
- NSURLRequest* nsURLRequest() const;
-
- private:
- friend class ResourceRequestBase;
-
- void doUpdatePlatformRequest();
- void doUpdateResourceRequest();
-
- RetainPtr<NSURLRequest> m_nsRequest;
- };
-
-} // namespace WebCore
-
-#endif // ResourceRequest_h
diff --git a/WebCore/platform/network/mac/ResourceRequestMac.mm b/WebCore/platform/network/mac/ResourceRequestMac.mm
deleted file mode 100644
index 63fffe1..0000000
--- a/WebCore/platform/network/mac/ResourceRequestMac.mm
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "ResourceRequest.h"
-#import "WebCoreSystemInterface.h"
-
-#import "FormDataStreamMac.h"
-
-#import <Foundation/Foundation.h>
-
-namespace WebCore {
-
-NSURLRequest* ResourceRequest::nsURLRequest() const
-{
- updatePlatformRequest();
-
- return [[m_nsRequest.get() retain] autorelease];
-}
-
-void ResourceRequest::doUpdateResourceRequest()
-{
- m_url = [m_nsRequest.get() URL];
- m_cachePolicy = (ResourceRequestCachePolicy)[m_nsRequest.get() cachePolicy];
- m_timeoutInterval = [m_nsRequest.get() timeoutInterval];
- m_mainDocumentURL = [m_nsRequest.get() mainDocumentURL];
-
- if (NSString* method = [m_nsRequest.get() HTTPMethod])
- m_httpMethod = method;
- m_allowHTTPCookies = [m_nsRequest.get() HTTPShouldHandleCookies];
-
- NSDictionary *headers = [m_nsRequest.get() allHTTPHeaderFields];
- NSEnumerator *e = [headers keyEnumerator];
- NSString *name;
- while ((name = [e nextObject]))
- m_httpHeaderFields.set(name, [headers objectForKey:name]);
-
- if (NSData* bodyData = [m_nsRequest.get() HTTPBody])
- m_httpBody = FormData::create([bodyData bytes], [bodyData length]);
- else if (NSInputStream* bodyStream = [m_nsRequest.get() HTTPBodyStream])
- if (FormData* formData = httpBodyFromStream(bodyStream))
- m_httpBody = formData;
-}
-
-void ResourceRequest::doUpdatePlatformRequest()
-{
- if (isNull()) {
- m_nsRequest = nil;
- return;
- }
-
- NSMutableURLRequest* nsRequest = [m_nsRequest.get() mutableCopy];
-
- if (nsRequest)
- [nsRequest setURL:url()];
- else
- nsRequest = [[NSMutableURLRequest alloc] initWithURL:url()];
-
-#ifdef BUILDING_ON_TIGER
- wkSupportsMultipartXMixedReplace(nsRequest);
-#endif
-
- [nsRequest setCachePolicy:(NSURLRequestCachePolicy)cachePolicy()];
- if (timeoutInterval() != unspecifiedTimeoutInterval)
- [nsRequest setTimeoutInterval:timeoutInterval()];
- [nsRequest setMainDocumentURL:mainDocumentURL()];
- if (!httpMethod().isEmpty())
- [nsRequest setHTTPMethod:httpMethod()];
- [nsRequest setHTTPShouldHandleCookies:allowHTTPCookies()];
-
- HTTPHeaderMap::const_iterator end = httpHeaderFields().end();
- for (HTTPHeaderMap::const_iterator it = httpHeaderFields().begin(); it != end; ++it)
- [nsRequest setValue:it->second forHTTPHeaderField:it->first];
-
- RefPtr<FormData> formData = httpBody();
- if (formData && !formData->isEmpty())
- WebCore::setHTTPBody(nsRequest, formData);
-
- m_nsRequest.adoptNS(nsRequest);
-}
-
-void ResourceRequest::applyWebArchiveHackForMail()
-{
- // Hack because Mail checks for this property to detect data / archive loads
- [NSURLProtocol setProperty:@"" forKey:@"WebDataRequest" inRequest:(NSMutableURLRequest *)nsURLRequest()];
-}
-
-}
diff --git a/WebCore/platform/network/mac/ResourceResponse.h b/WebCore/platform/network/mac/ResourceResponse.h
deleted file mode 100644
index b65760c..0000000
--- a/WebCore/platform/network/mac/ResourceResponse.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ResourceResponse_h
-#define ResourceResponse_h
-
-#include "ResourceResponseBase.h"
-#include <wtf/RetainPtr.h>
-
-#ifdef __OBJC__
-@class NSURLResponse;
-#else
-class NSURLResponse;
-#endif
-
-namespace WebCore {
-
-class ResourceResponse : public ResourceResponseBase {
-public:
- ResourceResponse()
- : m_isUpToDate(true)
- {
- }
-
- ResourceResponse(NSURLResponse* nsResponse)
- : m_nsResponse(nsResponse)
- , m_isUpToDate(false)
- {
- m_isNull = !nsResponse;
- }
-
- ResourceResponse(const KURL& url, const String& mimeType, long long expectedLength, const String& textEncodingName, const String& filename)
- : ResourceResponseBase(url, mimeType, expectedLength, textEncodingName, filename)
- , m_isUpToDate(true)
- {
- }
-
- NSURLResponse *nsURLResponse() const;
-
-private:
- friend class ResourceResponseBase;
-
- void platformLazyInit();
- static bool platformCompare(const ResourceResponse& a, const ResourceResponse& b);
-
- RetainPtr<NSURLResponse> m_nsResponse;
- bool m_isUpToDate;
-};
-
-} // namespace WebCore
-
-#endif // ResourceResponse_h
diff --git a/WebCore/platform/network/mac/ResourceResponseMac.mm b/WebCore/platform/network/mac/ResourceResponseMac.mm
deleted file mode 100644
index f60b496..0000000
--- a/WebCore/platform/network/mac/ResourceResponseMac.mm
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "ResourceResponse.h"
-
-#import "WebCoreURLResponse.h"
-#import <Foundation/Foundation.h>
-#import <limits>
-
-@interface NSURLResponse (FoundationSecretsWebCoreKnowsAbout)
-- (NSTimeInterval)_calculatedExpiration;
-@end
-
-#ifdef BUILDING_ON_TIGER
-typedef int NSInteger;
-#endif
-
-namespace WebCore {
-
-NSURLResponse *ResourceResponse::nsURLResponse() const
-{
- if (!m_nsResponse && !m_isNull) {
- // Work around a mistake in the NSURLResponse class.
- // The init function takes an NSInteger, even though the accessor returns a long long.
- // For values that won't fit in an NSInteger, pass -1 instead.
- NSInteger expectedContentLength;
- if (m_expectedContentLength < 0 || m_expectedContentLength > std::numeric_limits<NSInteger>::max())
- expectedContentLength = -1;
- else
- expectedContentLength = static_cast<NSInteger>(m_expectedContentLength);
- const_cast<ResourceResponse*>(this)->m_nsResponse.adoptNS([[NSURLResponse alloc] initWithURL:m_url MIMEType:m_mimeType expectedContentLength:expectedContentLength textEncodingName:m_textEncodingName]);
- }
- return m_nsResponse.get();
-}
-
-void ResourceResponse::platformLazyInit()
-{
- if (m_isUpToDate)
- return;
- m_isUpToDate = true;
-
- if (m_isNull) {
- ASSERT(!m_nsResponse);
- return;
- }
-
- m_url = [m_nsResponse.get() URL];
- m_mimeType = [m_nsResponse.get() _webcore_MIMEType];
- m_expectedContentLength = [m_nsResponse.get() expectedContentLength];
- m_textEncodingName = [m_nsResponse.get() textEncodingName];
- m_suggestedFilename = [m_nsResponse.get() suggestedFilename];
-
- const time_t maxTime = std::numeric_limits<time_t>::max();
-
- NSTimeInterval expiration = [m_nsResponse.get() _calculatedExpiration];
- expiration += kCFAbsoluteTimeIntervalSince1970;
- m_expirationDate = expiration > maxTime ? maxTime : static_cast<time_t>(expiration);
-
- if ([m_nsResponse.get() isKindOfClass:[NSHTTPURLResponse class]]) {
- NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)m_nsResponse.get();
-
- m_httpStatusCode = [httpResponse statusCode];
-
- // FIXME: it would be nice to have a way to get the real status text eventually.
- m_httpStatusText = "OK";
-
- NSDictionary *headers = [httpResponse allHeaderFields];
- NSEnumerator *e = [headers keyEnumerator];
- while (NSString *name = [e nextObject])
- m_httpHeaderFields.set(name, [headers objectForKey:name]);
- } else {
- m_httpStatusCode = 0;
-
-#ifndef BUILDING_ON_TIGER
- // FIXME: This is a work around for <rdar://problem/5230154> (-[NSURLConnection initWithRequest:delegate:]
- // is returning incorrect MIME type for local .xhtml files) which is only required in Leopard.
- if (m_url.isLocalFile() && m_mimeType == "text/html") {
- const String& path = m_url.path();
- static const String xhtmlExt(".xhtml");
- if (path.endsWith(xhtmlExt, false))
- m_mimeType = "application/xhtml+xml";
- }
-#endif
- }
-}
-
-bool ResourceResponse::platformCompare(const ResourceResponse& a, const ResourceResponse& b)
-{
- return a.nsURLResponse() == b.nsURLResponse();
-}
-
-}
diff --git a/WebCore/platform/network/mac/WebCoreURLResponse.h b/WebCore/platform/network/mac/WebCoreURLResponse.h
deleted file mode 100644
index a06ab70..0000000
--- a/WebCore/platform/network/mac/WebCoreURLResponse.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-// FIXME: This is a workaround for <rdar://problem/5321972> REGRESSION: Plain text document from HTTP server detected
-// as application/octet-stream
-
-@interface NSURLResponse (WebCoreURLResponse)
-- (NSString *)_webcore_MIMEType;
-@end
diff --git a/WebCore/platform/network/mac/WebCoreURLResponse.mm b/WebCore/platform/network/mac/WebCoreURLResponse.mm
deleted file mode 100644
index b8843af..0000000
--- a/WebCore/platform/network/mac/WebCoreURLResponse.mm
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-
-#import "WebCoreURLResponse.h"
-
-#ifndef BUILDING_ON_TIGER
-static NSSet *createBinaryExtensionsSet()
-{
- return [[NSSet alloc] initWithObjects:
- @"3g2",
- @"3gp",
- @"ai",
- @"aif",
- @"aifc",
- @"aiff",
- @"au",
- @"avi",
- @"bcpio",
- @"bin",
- @"bmp",
- @"boz",
- @"bpk",
- @"bz",
- @"bz2",
- @"chm",
- @"class",
- @"com",
- @"cpio",
- @"dcr",
- @"dir",
- @"dist",
- @"distz",
- @"dll",
- @"dmg",
- @"dms",
- @"doc",
- @"dot",
- @"dump",
- @"dv",
- @"dvi",
- @"dxr",
- @"elc",
- @"eot",
- @"eps",
- @"exe",
- @"fgd",
- @"gif",
- @"gtar",
- @"h261",
- @"h263",
- @"h264",
- @"ico",
- @"ims",
- @"indd",
- @"iso",
- @"jp2",
- @"jpe",
- @"jpeg",
- @"jpg",
- @"jpgm",
- @"jpgv",
- @"jpm",
- @"kar",
- @"lha",
- @"lrm",
- @"lzh",
- @"m1v",
- @"m2a",
- @"m2v",
- @"m3a",
- @"m3u",
- @"m4a",
- @"m4p",
- @"m4v",
- @"mdb",
- @"mid",
- @"midi",
- @"mj2",
- @"mjp2",
- @"mov",
- @"movie",
- @"mp2",
- @"mp2a",
- @"mp3",
- @"mp4",
- @"mp4a",
- @"mp4s",
- @"mp4v",
- @"mpe",
- @"mpeg",
- @"mpg",
- @"mpg4",
- @"mpga",
- @"mpp",
- @"mpt",
- @"msi",
- @"ogg",
- @"otf",
- @"pct",
- @"pdf",
- @"pfa",
- @"pfb",
- @"pic",
- @"pict",
- @"pkg",
- @"png",
- @"pot",
- @"pps",
- @"ppt",
- @"ps",
- @"psd",
- @"qt",
- @"qti",
- @"qtif",
- @"qwd",
- @"qwt",
- @"qxb",
- @"qxd",
- @"qxl",
- @"qxp",
- @"qxt",
- @"ra",
- @"ram",
- @"rm",
- @"rmi",
- @"rmp",
- @"scpt",
- @"sit",
- @"sitx",
- @"snd",
- @"so",
- @"swf",
- @"tar",
- @"tif",
- @"tiff",
- @"ttf",
- @"wav",
- @"wcm",
- @"wdb",
- @"wks",
- @"wm",
- @"wma",
- @"wmd",
- @"wmf",
- @"wmv",
- @"wmx",
- @"wmz",
- @"wpd",
- @"wpl",
- @"wps",
- @"wvx",
- @"xla",
- @"xlc",
- @"xlm",
- @"xls",
- @"xlt",
- @"xlw",
- @"xps",
- @"zip",
- nil
- ];
-}
-#endif
-
-@implementation NSURLResponse (WebCoreURLResponse)
-
-- (NSString *)_webcore_MIMEType
-{
- NSString *MIMEType = [self MIMEType];
-#ifdef BUILDING_ON_LEOPARD
- // Workaround for <rdar://problem/5539824>
- if ([MIMEType isEqualToString:@"text/xml"])
- return @"application/xml";
-#endif
- return MIMEType;
-}
-
-@end
-
-@implementation NSHTTPURLResponse (WebCoreURLResponse)
-
-- (NSString *)_webcore_MIMEType
-{
- NSString *MIMEType = [self MIMEType];
-#ifndef BUILDING_ON_TIGER
- if ([MIMEType isEqualToString:@"application/octet-stream"] && [[[self allHeaderFields] objectForKey:@"Content-Type"] hasPrefix:@"text/plain"]) {
- static NSSet *binaryExtensions = createBinaryExtensionsSet();
- return [binaryExtensions containsObject:[[[self suggestedFilename] pathExtension] lowercaseString]] ? MIMEType : @"text/plain";
- }
-#endif
- return MIMEType;
-}
-
-@end
diff --git a/WebCore/platform/network/qt/AuthenticationChallenge.h b/WebCore/platform/network/qt/AuthenticationChallenge.h
deleted file mode 100644
index 753ac6f..0000000
--- a/WebCore/platform/network/qt/AuthenticationChallenge.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef AuthenticationChallenge_h
-#define AuthenticationChallenge_h
-
-#include "AuthenticationChallengeBase.h"
-
-namespace WebCore {
-
-class AuthenticationChallenge : public AuthenticationChallengeBase {
-public:
- AuthenticationChallenge()
- {
- }
-
- AuthenticationChallenge(const ProtectionSpace& protectionSpace, const Credential& proposedCredential, unsigned previousFailureCount, const ResourceResponse& response, const ResourceError& error)
- : AuthenticationChallengeBase(protectionSpace, proposedCredential, previousFailureCount, response, error)
- {
- }
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/network/qt/QNetworkReplyHandler.cpp b/WebCore/platform/network/qt/QNetworkReplyHandler.cpp
deleted file mode 100644
index 2de2125..0000000
--- a/WebCore/platform/network/qt/QNetworkReplyHandler.cpp
+++ /dev/null
@@ -1,435 +0,0 @@
-/*
- Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
- Copyright (C) 2007 Staikos Computing Services Inc. <info@staikos.net>
- Copyright (C) 2008 Holger Hans Peter Freyther
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-#include "config.h"
-#include "QNetworkReplyHandler.h"
-
-#if QT_VERSION >= 0x040400
-
-#include "HTTPParsers.h"
-#include "MIMETypeRegistry.h"
-#include "ResourceHandle.h"
-#include "ResourceHandleClient.h"
-#include "ResourceHandleInternal.h"
-#include "ResourceResponse.h"
-#include "ResourceRequest.h"
-#include <QDateTime>
-#include <QFile>
-#include <QNetworkReply>
-#include <QNetworkCookie>
-#include <qwebframe.h>
-#include <qwebpage.h>
-
-#include <QDebug>
-#include <QCoreApplication>
-
-namespace WebCore {
-
-// Take a deep copy of the FormDataElement
-FormDataIODevice::FormDataIODevice(FormData* data)
- : m_formElements(data ? data->elements() : Vector<FormDataElement>())
- , m_currentFile(0)
- , m_currentDelta(0)
-{
- setOpenMode(FormDataIODevice::ReadOnly);
-}
-
-FormDataIODevice::~FormDataIODevice()
-{
- delete m_currentFile;
-}
-
-void FormDataIODevice::moveToNextElement()
-{
- if (m_currentFile)
- m_currentFile->close();
- m_currentDelta = 0;
-
- m_formElements.remove(0);
-
- if (m_formElements.isEmpty() || m_formElements[0].m_type == FormDataElement::data)
- return;
-
- if (!m_currentFile)
- m_currentFile = new QFile;
-
- m_currentFile->setFileName(m_formElements[0].m_filename);
- m_currentFile->open(QFile::ReadOnly);
-}
-
-// m_formElements[0] is the current item. If the destination buffer is
-// big enough we are going to read from more than one FormDataElement
-qint64 FormDataIODevice::readData(char* destination, qint64 size)
-{
- if (m_formElements.isEmpty())
- return -1;
-
- qint64 copied = 0;
- while (copied < size && !m_formElements.isEmpty()) {
- const FormDataElement& element = m_formElements[0];
- const qint64 available = size-copied;
-
- if (element.m_type == FormDataElement::data) {
- const qint64 toCopy = qMin<qint64>(available, element.m_data.size() - m_currentDelta);
- memcpy(destination+copied, element.m_data.data()+m_currentDelta, toCopy);
- m_currentDelta += toCopy;
- copied += toCopy;
-
- if (m_currentDelta == element.m_data.size())
- moveToNextElement();
- } else {
- const QByteArray data = m_currentFile->read(available);
- memcpy(destination+copied, data.constData(), data.size());
- copied += data.size();
-
- if (m_currentFile->atEnd() || !m_currentFile->isOpen())
- moveToNextElement();
- }
- }
-
- return copied;
-}
-
-qint64 FormDataIODevice::writeData(const char*, qint64)
-{
- return -1;
-}
-
-void FormDataIODevice::setParent(QNetworkReply* reply)
-{
- QIODevice::setParent(reply);
-
- connect(reply, SIGNAL(finished()), SLOT(slotFinished()), Qt::QueuedConnection);
-}
-
-bool FormDataIODevice::isSequential() const
-{
- return true;
-}
-
-void FormDataIODevice::slotFinished()
-{
- deleteLater();
-}
-
-QNetworkReplyHandler::QNetworkReplyHandler(ResourceHandle* handle, LoadMode loadMode)
- : QObject(0)
- , m_resourceHandle(handle)
- , m_reply(0)
- , m_redirected(false)
- , m_responseSent(false)
- , m_loadMode(loadMode)
- , m_startTime(0)
- , m_shouldStart(true)
- , m_shouldFinish(false)
- , m_shouldSendResponse(false)
- , m_shouldForwardData(false)
-{
- const ResourceRequest &r = m_resourceHandle->request();
-
- if (r.httpMethod() == "GET")
- m_method = QNetworkAccessManager::GetOperation;
- else if (r.httpMethod() == "HEAD")
- m_method = QNetworkAccessManager::HeadOperation;
- else if (r.httpMethod() == "POST")
- m_method = QNetworkAccessManager::PostOperation;
- else if (r.httpMethod() == "PUT")
- m_method = QNetworkAccessManager::PutOperation;
- else
- m_method = QNetworkAccessManager::UnknownOperation;
-
- m_request = r.toNetworkRequest();
-
- if (m_loadMode == LoadNormal)
- start();
-}
-
-void QNetworkReplyHandler::setLoadMode(LoadMode mode)
-{
- m_loadMode = mode;
- if (m_loadMode == LoadNormal)
- sendQueuedItems();
-}
-
-void QNetworkReplyHandler::abort()
-{
- m_resourceHandle = 0;
- if (m_reply) {
- QNetworkReply* reply = release();
- reply->abort();
- deleteLater();
- }
-}
-
-QNetworkReply* QNetworkReplyHandler::release()
-{
- QNetworkReply* reply = m_reply;
- if (m_reply) {
- disconnect(m_reply, 0, this, 0);
- // We have queued connections to the QNetworkReply. Make sure any
- // posted meta call events that were the result of a signal emission
- // don't reach the slots in our instance.
- QCoreApplication::removePostedEvents(this, QEvent::MetaCall);
- m_reply = 0;
- }
- return reply;
-}
-
-void QNetworkReplyHandler::finish()
-{
- m_shouldFinish = (m_loadMode == LoadDeferred);
- if (m_loadMode == LoadDeferred)
- return;
-
- sendResponseIfNeeded();
-
- if (!m_resourceHandle)
- return;
- ResourceHandleClient* client = m_resourceHandle->client();
- if (!client) {
- m_reply->deleteLater();
- m_reply = 0;
- return;
- }
- QNetworkReply* oldReply = m_reply;
- if (m_redirected) {
- resetState();
- start();
- } else if (m_reply->error() != QNetworkReply::NoError
- // a web page that returns 403/404 can still have content
- && m_reply->error() != QNetworkReply::ContentOperationNotPermittedError
- && m_reply->error() != QNetworkReply::ContentNotFoundError) {
- QUrl url = m_reply->url();
- ResourceError error(url.host(), m_reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(),
- url.toString(), m_reply->errorString());
- client->didFail(m_resourceHandle, error);
- } else {
- client->didFinishLoading(m_resourceHandle);
- }
- oldReply->deleteLater();
- if (oldReply == m_reply)
- m_reply = 0;
-}
-
-void QNetworkReplyHandler::sendResponseIfNeeded()
-{
- m_shouldSendResponse = (m_loadMode == LoadDeferred);
- if (m_loadMode == LoadDeferred)
- return;
-
- if (m_responseSent || !m_resourceHandle)
- return;
- m_responseSent = true;
-
- ResourceHandleClient* client = m_resourceHandle->client();
- if (!client)
- return;
-
- WebCore::String contentType = m_reply->header(QNetworkRequest::ContentTypeHeader).toString();
- WebCore::String encoding = extractCharsetFromMediaType(contentType);
- WebCore::String mimeType = extractMIMETypeFromMediaType(contentType);
-
- if (mimeType.isEmpty()) {
- // let's try to guess from the extension
- QString extension = m_reply->url().path();
- int index = extension.lastIndexOf(QLatin1Char('.'));
- if (index > 0) {
- extension = extension.mid(index + 1);
- mimeType = MIMETypeRegistry::getMIMETypeForExtension(extension);
- }
- }
-
- KURL url(m_reply->url());
- String suggestedFilename = filenameFromHTTPContentDisposition(QString::fromAscii(m_reply->rawHeader("Content-Disposition")));
-
- if (suggestedFilename.isEmpty())
- suggestedFilename = url.lastPathComponent();
-
- ResourceResponse response(url, mimeType,
- m_reply->header(QNetworkRequest::ContentLengthHeader).toLongLong(),
- encoding,
- suggestedFilename);
-
- const bool isLocalFileReply = (m_reply->url().scheme() == QLatin1String("file"));
- int statusCode = m_reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
- if (!isLocalFileReply)
- response.setHTTPStatusCode(statusCode);
- else if (m_reply->error() == QNetworkReply::ContentNotFoundError)
- response.setHTTPStatusCode(404);
-
-
- /* Fill in the other fields
- * For local file requests remove the content length and the last-modified
- * headers as required by fast/dom/xmlhttprequest-get.xhtml
- */
- foreach (QByteArray headerName, m_reply->rawHeaderList()) {
-
- if (isLocalFileReply
- && (headerName == "Content-Length" || headerName == "Last-Modified"))
- continue;
-
- response.setHTTPHeaderField(QString::fromAscii(headerName), QString::fromAscii(m_reply->rawHeader(headerName)));
- }
-
- if (isLocalFileReply)
- response.setExpirationDate(m_startTime);
-
- QUrl redirection = m_reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
- if (redirection.isValid()) {
- QUrl newUrl = m_reply->url().resolved(redirection);
- ResourceRequest newRequest = m_resourceHandle->request();
- newRequest.setURL(newUrl);
-
- if (((statusCode >= 301 && statusCode <= 303) || statusCode == 307) && m_method == QNetworkAccessManager::PostOperation) {
- m_method = QNetworkAccessManager::GetOperation;
- newRequest.setHTTPMethod("GET");
- }
-
- client->willSendRequest(m_resourceHandle, newRequest, response);
- m_redirected = true;
- m_request = newRequest.toNetworkRequest();
- } else {
- client->didReceiveResponse(m_resourceHandle, response);
- }
-}
-
-void QNetworkReplyHandler::forwardData()
-{
- m_shouldForwardData = (m_loadMode == LoadDeferred);
- if (m_loadMode == LoadDeferred)
- return;
-
- sendResponseIfNeeded();
-
- // don't emit the "Document has moved here" type of HTML
- if (m_redirected)
- return;
-
- if (!m_resourceHandle)
- return;
-
- QByteArray data = m_reply->read(m_reply->bytesAvailable());
-
- ResourceHandleClient* client = m_resourceHandle->client();
- if (!client)
- return;
-
- if (!data.isEmpty())
- client->didReceiveData(m_resourceHandle, data.constData(), data.length(), data.length() /*FixMe*/);
-}
-
-void QNetworkReplyHandler::start()
-{
- m_shouldStart = false;
-
- ResourceHandleInternal* d = m_resourceHandle->getInternal();
-
- QNetworkAccessManager* manager = d->m_frame->page()->networkAccessManager();
-
- const QUrl url = m_request.url();
- const QString scheme = url.scheme();
- // Post requests on files and data don't really make sense, but for
- // fast/forms/form-post-urlencoded.html and for fast/forms/button-state-restore.html
- // we still need to retrieve the file/data, which means we map it to a Get instead.
- if (m_method == QNetworkAccessManager::PostOperation
- && (!url.toLocalFile().isEmpty() || url.scheme() == QLatin1String("data")))
- m_method = QNetworkAccessManager::GetOperation;
-
- m_startTime = QDateTime::currentDateTime().toTime_t();
-
- switch (m_method) {
- case QNetworkAccessManager::GetOperation:
- m_reply = manager->get(m_request);
- break;
- case QNetworkAccessManager::PostOperation: {
- FormDataIODevice* postDevice = new FormDataIODevice(d->m_request.httpBody());
- m_reply = manager->post(m_request, postDevice);
- postDevice->setParent(m_reply);
- break;
- }
- case QNetworkAccessManager::HeadOperation:
- m_reply = manager->head(m_request);
- break;
- case QNetworkAccessManager::PutOperation: {
- FormDataIODevice* putDevice = new FormDataIODevice(d->m_request.httpBody());
- m_reply = manager->put(m_request, putDevice);
- putDevice->setParent(m_reply);
- break;
- }
- case QNetworkAccessManager::UnknownOperation: {
- m_reply = 0;
- ResourceHandleClient* client = m_resourceHandle->client();
- if (client) {
- ResourceError error(url.host(), 400 /*bad request*/,
- url.toString(),
- QCoreApplication::translate("QWebPage", "Bad HTTP request"));
- client->didFail(m_resourceHandle, error);
- }
- return;
- }
- }
-
- m_reply->setParent(this);
-
- connect(m_reply, SIGNAL(finished()),
- this, SLOT(finish()), Qt::QueuedConnection);
-
- // For http(s) we know that the headers are complete upon metaDataChanged() emission, so we
- // can send the response as early as possible
- if (scheme == QLatin1String("http") || scheme == QLatin1String("https"))
- connect(m_reply, SIGNAL(metaDataChanged()),
- this, SLOT(sendResponseIfNeeded()), Qt::QueuedConnection);
-
- connect(m_reply, SIGNAL(readyRead()),
- this, SLOT(forwardData()), Qt::QueuedConnection);
-}
-
-void QNetworkReplyHandler::resetState()
-{
- m_redirected = false;
- m_responseSent = false;
- m_shouldStart = true;
- m_shouldFinish = false;
- m_shouldSendResponse = false;
- m_shouldForwardData = false;
-}
-
-void QNetworkReplyHandler::sendQueuedItems()
-{
- Q_ASSERT(m_loadMode == LoadNormal);
-
- if (m_shouldStart)
- start();
-
- if (m_shouldSendResponse)
- sendResponseIfNeeded();
-
- if (m_shouldForwardData)
- forwardData();
-
- if (m_shouldFinish)
- finish();
-}
-
-}
-
-#include "moc_QNetworkReplyHandler.cpp"
-
-#endif
diff --git a/WebCore/platform/network/qt/QNetworkReplyHandler.h b/WebCore/platform/network/qt/QNetworkReplyHandler.h
deleted file mode 100644
index 98be28d..0000000
--- a/WebCore/platform/network/qt/QNetworkReplyHandler.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-#ifndef QNETWORKREPLYHANDLER_H
-#define QNETWORKREPLYHANDLER_H
-
-#include <QObject>
-
-#if QT_VERSION >= 0x040400
-
-#include <QNetworkRequest>
-#include <QNetworkAccessManager>
-
-#include "FormData.h"
-
-QT_BEGIN_NAMESPACE
-class QFile;
-class QNetworkReply;
-QT_END_NAMESPACE
-
-namespace WebCore {
-
-class ResourceHandle;
-
-class QNetworkReplyHandler : public QObject
-{
- Q_OBJECT
-public:
- enum LoadMode {
- LoadNormal,
- LoadDeferred
- };
-
- QNetworkReplyHandler(ResourceHandle *handle, LoadMode);
- void setLoadMode(LoadMode);
-
- QNetworkReply* reply() const { return m_reply; }
-
- void abort();
-
- QNetworkReply* release();
-
-private slots:
- void finish();
- void sendResponseIfNeeded();
- void forwardData();
-
-private:
- void start();
- void resetState();
- void sendQueuedItems();
-
- QNetworkReply* m_reply;
- ResourceHandle* m_resourceHandle;
- bool m_redirected;
- bool m_responseSent;
- LoadMode m_loadMode;
- QNetworkAccessManager::Operation m_method;
- QNetworkRequest m_request;
- uint m_startTime;
-
- // defer state holding
- bool m_shouldStart;
- bool m_shouldFinish;
- bool m_shouldSendResponse;
- bool m_shouldForwardData;
-};
-
-// Self destructing QIODevice for FormData
-// For QNetworkAccessManager::put we will have to gurantee that the
-// QIODevice is valid as long finished() of the QNetworkReply has not
-// been emitted. With the presence of QNetworkReplyHandler::release I do
-// not want to gurantee this.
-class FormDataIODevice : public QIODevice {
- Q_OBJECT
-public:
- FormDataIODevice(FormData*);
- ~FormDataIODevice();
-
- void setParent(QNetworkReply*);
- bool isSequential() const;
-
-protected:
- qint64 readData(char*, qint64);
- qint64 writeData(const char*, qint64);
-
-private Q_SLOTS:
- void slotFinished();
-
-private:
- void moveToNextElement();
-
-private:
- Vector<FormDataElement> m_formElements;
- QFile* m_currentFile;
- qint64 m_currentDelta;
-};
-
-}
-
-#endif
-
-#endif // QNETWORKREPLYHANDLER_H
diff --git a/WebCore/platform/network/qt/ResourceError.h b/WebCore/platform/network/qt/ResourceError.h
deleted file mode 100644
index ca8d36b..0000000
--- a/WebCore/platform/network/qt/ResourceError.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ResourceError_h
-#define ResourceError_h
-
-#include "ResourceErrorBase.h"
-
-namespace WebCore {
-
-class ResourceError : public ResourceErrorBase
-{
-public:
- ResourceError()
- {
- }
-
- ResourceError(const String& domain, int errorCode, const String& failingURL, const String& localizedDescription)
- : ResourceErrorBase(domain, errorCode, failingURL, localizedDescription)
- {
- }
-};
-
-}
-
-#endif // ResourceError_h_
diff --git a/WebCore/platform/network/qt/ResourceHandleQt.cpp b/WebCore/platform/network/qt/ResourceHandleQt.cpp
deleted file mode 100644
index 7af5895..0000000
--- a/WebCore/platform/network/qt/ResourceHandleQt.cpp
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
- * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
- * Copyright (C) 2008 Holger Hans Peter Freyther
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "Frame.h"
-#include "DocLoader.h"
-#include "ResourceHandle.h"
-#include "ResourceHandleClient.h"
-#include "ResourceHandleInternal.h"
-#include "qwebpage_p.h"
-#include "ChromeClientQt.h"
-#include "FrameLoaderClientQt.h"
-#include "Page.h"
-#include "QNetworkReplyHandler.h"
-
-#include "NotImplemented.h"
-
-#include <QCoreApplication>
-#include <QUrl>
-#if QT_VERSION >= 0x040400
-#include <QNetworkAccessManager>
-#include <QNetworkRequest>
-#include <QNetworkReply>
-#else
-#include "qwebnetworkinterface_p.h"
-#endif
-
-namespace WebCore {
-
-class WebCoreSynchronousLoader : public ResourceHandleClient {
-public:
- WebCoreSynchronousLoader();
-
- void waitForCompletion();
-
- virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&);
- virtual void didReceiveData(ResourceHandle*, const char*, int, int lengthReceived);
- virtual void didFinishLoading(ResourceHandle*);
- virtual void didFail(ResourceHandle*, const ResourceError&);
-
- ResourceResponse resourceResponse() const { return m_response; }
- ResourceError resourceError() const { return m_error; }
- Vector<char> data() const { return m_data; }
-
-private:
- ResourceResponse m_response;
- ResourceError m_error;
- Vector<char> m_data;
- bool m_finished;
-};
-
-WebCoreSynchronousLoader::WebCoreSynchronousLoader()
- : m_finished(false)
-{
-}
-
-void WebCoreSynchronousLoader::didReceiveResponse(ResourceHandle*, const ResourceResponse& response)
-{
- m_response = response;
-}
-
-void WebCoreSynchronousLoader::didReceiveData(ResourceHandle*, const char* data, int length, int)
-{
- m_data.append(data, length);
-}
-
-void WebCoreSynchronousLoader::didFinishLoading(ResourceHandle*)
-{
- m_finished = true;
-}
-
-void WebCoreSynchronousLoader::didFail(ResourceHandle*, const ResourceError& error)
-{
- m_error = error;
- m_finished = true;
-}
-
-void WebCoreSynchronousLoader::waitForCompletion()
-{
- while (!m_finished)
- QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
-}
-
-ResourceHandleInternal::~ResourceHandleInternal()
-{
-}
-
-ResourceHandle::~ResourceHandle()
-{
- if (d->m_job)
- cancel();
-}
-
-bool ResourceHandle::start(Frame* frame)
-{
- if (!frame)
- return false;
-
- Page *page = frame->page();
- // If we are no longer attached to a Page, this must be an attempted load from an
- // onUnload handler, so let's just block it.
- if (!page)
- return false;
-
- getInternal()->m_frame = static_cast<FrameLoaderClientQt*>(frame->loader()->client())->webFrame();
-#if QT_VERSION < 0x040400
- return QWebNetworkManager::self()->add(this, getInternal()->m_frame->page()->d->networkInterface);
-#else
- ResourceHandleInternal *d = getInternal();
- d->m_job = new QNetworkReplyHandler(this, QNetworkReplyHandler::LoadMode(d->m_defersLoading));
- return true;
-#endif
-}
-
-void ResourceHandle::cancel()
-{
-#if QT_VERSION < 0x040400
- QWebNetworkManager::self()->cancel(this);
-#else
- if (d->m_job)
- d->m_job->abort();
-#endif
-}
-
-bool ResourceHandle::loadsBlocked()
-{
- return false;
-}
-
-bool ResourceHandle::willLoadFromCache(ResourceRequest& request)
-{
- notImplemented();
- return false;
-}
-
-bool ResourceHandle::supportsBufferedData()
-{
- return false;
-}
-
-PassRefPtr<SharedBuffer> ResourceHandle::bufferedData()
-{
- ASSERT_NOT_REACHED();
- return 0;
-}
-
-void ResourceHandle::loadResourceSynchronously(const ResourceRequest& request, ResourceError& error, ResourceResponse& response, Vector<char>& data, Frame* frame)
-{
- WebCoreSynchronousLoader syncLoader;
- ResourceHandle handle(request, &syncLoader, true, false, true);
-
-#if QT_VERSION < 0x040400
- if (!QWebNetworkManager::self()->add(&handle, QWebNetworkInterface::defaultInterface(), QWebNetworkManager::SynchronousJob)) {
- // FIXME Create a sane ResourceError
- error = ResourceError(String(), -1, String(), String());
- return;
- }
-#else
- ResourceHandleInternal *d = handle.getInternal();
- d->m_frame = static_cast<FrameLoaderClientQt*>(frame->loader()->client())->webFrame();
- d->m_job = new QNetworkReplyHandler(&handle, QNetworkReplyHandler::LoadNormal);
-#endif
-
- syncLoader.waitForCompletion();
- error = syncLoader.resourceError();
- data = syncLoader.data();
- response = syncLoader.resourceResponse();
-}
-
-
-void ResourceHandle::setDefersLoading(bool defers)
-{
- d->m_defersLoading = defers;
-
-#if QT_VERSION >= 0x040400
- if (d->m_job)
- d->m_job->setLoadMode(QNetworkReplyHandler::LoadMode(defers));
-#endif
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/network/qt/ResourceRequest.h b/WebCore/platform/network/qt/ResourceRequest.h
deleted file mode 100644
index af76f61..0000000
--- a/WebCore/platform/network/qt/ResourceRequest.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ResourceRequest_h
-#define ResourceRequest_h
-
-#include "ResourceRequestBase.h"
-
-QT_BEGIN_NAMESPACE
-class QNetworkRequest;
-QT_END_NAMESPACE
-
-namespace WebCore {
-
- struct ResourceRequest : ResourceRequestBase {
-
- ResourceRequest(const String& url)
- : ResourceRequestBase(KURL(url), UseProtocolCachePolicy)
- {
- }
-
- ResourceRequest(const KURL& url)
- : ResourceRequestBase(url, UseProtocolCachePolicy)
- {
- }
-
- ResourceRequest(const KURL& url, const String& referrer, ResourceRequestCachePolicy policy = UseProtocolCachePolicy)
- : ResourceRequestBase(url, policy)
- {
- setHTTPReferrer(referrer);
- }
-
- ResourceRequest()
- : ResourceRequestBase(KURL(), UseProtocolCachePolicy)
- {
- }
-
-#if QT_VERSION >= 0x040400
- QNetworkRequest toNetworkRequest() const;
-#endif
-
- private:
- friend class ResourceRequestBase;
-
- void doUpdatePlatformRequest() {}
- void doUpdateResourceRequest() {}
- };
-
-} // namespace WebCore
-
-#endif // ResourceRequest_h
diff --git a/WebCore/platform/network/qt/ResourceRequestQt.cpp b/WebCore/platform/network/qt/ResourceRequestQt.cpp
deleted file mode 100644
index 9308878..0000000
--- a/WebCore/platform/network/qt/ResourceRequestQt.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include "config.h"
-#include "ResourceRequest.h"
-
-#include <qglobal.h>
-#if QT_VERSION >= 0x040400
-
-#include <QNetworkRequest>
-#include <QUrl>
-
-namespace WebCore {
-
-QNetworkRequest ResourceRequest::toNetworkRequest() const
-{
- QNetworkRequest request;
- request.setUrl(url());
-
- const HTTPHeaderMap &headers = httpHeaderFields();
- for (HTTPHeaderMap::const_iterator it = headers.begin(), end = headers.end();
- it != end; ++it) {
- QByteArray name = QString(it->first).toAscii();
- QByteArray value = QString(it->second).toAscii();
- request.setRawHeader(name, value);
- }
-
- return request;
-}
-
-}
-
-#endif
diff --git a/WebCore/platform/network/qt/ResourceResponse.h b/WebCore/platform/network/qt/ResourceResponse.h
deleted file mode 100644
index 345ef25..0000000
--- a/WebCore/platform/network/qt/ResourceResponse.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ResourceResponse_h
-#define ResourceResponse_h
-
-#include "ResourceResponseBase.h"
-
-namespace WebCore {
-
-class ResourceResponse : public ResourceResponseBase {
-public:
- ResourceResponse()
- {
- }
-
- ResourceResponse(const KURL& url, const String& mimeType, long long expectedLength, const String& textEncodingName, const String& filename)
- : ResourceResponseBase(url, mimeType, expectedLength, textEncodingName, filename)
- {
- }
-};
-
-} // namespace WebCore
-
-#endif // ResourceResponse_h
diff --git a/WebCore/platform/network/soup/AuthenticationChallenge.h b/WebCore/platform/network/soup/AuthenticationChallenge.h
deleted file mode 100644
index 5177f1e..0000000
--- a/WebCore/platform/network/soup/AuthenticationChallenge.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef AuthenticationChallenge_h
-#define AuthenticationChallenge_h
-
-#include "AuthenticationChallengeBase.h"
-
-namespace WebCore {
-
-class AuthenticationChallenge : public AuthenticationChallengeBase {
-public:
- AuthenticationChallenge()
- {
- }
-
- AuthenticationChallenge(const ProtectionSpace& protectionSpace, const Credential& proposedCredential, unsigned previousFailureCount, const ResourceResponse& response, const ResourceError& error)
- : AuthenticationChallengeBase(protectionSpace, proposedCredential, previousFailureCount, response, error)
- {
- }
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/network/soup/CookieJarSoup.cpp b/WebCore/platform/network/soup/CookieJarSoup.cpp
deleted file mode 100644
index 4ae90e5..0000000
--- a/WebCore/platform/network/soup/CookieJarSoup.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2008 Xan Lopez <xan@gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "config.h"
-#include "CString.h"
-#include "CookieJar.h"
-
-#include "KURL.h"
-#include "PlatformString.h"
-#include "StringHash.h"
-
-#include <libsoup/soup.h>
-
-namespace WebCore {
-
-SoupCookieJar* getCookieJar()
-{
- static SoupCookieJar* jar = NULL;
-
- if (!jar)
- jar = soup_cookie_jar_new();
-
- return jar;
-}
-
-void setCookies(Document* /*document*/, const KURL& url, const KURL& /*policyURL*/, const String& value)
-{
- SoupCookieJar* jar = getCookieJar();
- if (!jar)
- return;
-
- SoupURI* origin = soup_uri_new(url.string().utf8().data());
-
- soup_cookie_jar_set_cookie(jar, origin, value.utf8().data());
- soup_uri_free(origin);
-}
-
-String cookies(const Document* /*document*/, const KURL& url)
-{
- SoupCookieJar* jar = getCookieJar();
- if (!jar)
- return String();
-
- SoupURI* uri = soup_uri_new(url.string().utf8().data());
- char* cookies = soup_cookie_jar_get_cookies(jar, uri, FALSE);
- soup_uri_free(uri);
-
- String result(cookies);
- g_free(cookies);
-
- return result;
-}
-
-bool cookiesEnabled(const Document* /*document*/)
-{
- return getCookieJar();
-}
-
-}
diff --git a/WebCore/platform/network/soup/DNSSoup.cpp b/WebCore/platform/network/soup/DNSSoup.cpp
deleted file mode 100644
index 1ffe1a0..0000000
--- a/WebCore/platform/network/soup/DNSSoup.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "DNS.h"
-
-#include "NotImplemented.h"
-
-namespace WebCore {
-
-void prefetchDNS(const String& hostname)
-{
- notImplemented();
-}
-
-}
diff --git a/WebCore/platform/network/soup/ResourceError.h b/WebCore/platform/network/soup/ResourceError.h
deleted file mode 100644
index 2d11367..0000000
--- a/WebCore/platform/network/soup/ResourceError.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ResourceError_h
-#define ResourceError_h
-
-#include "ResourceErrorBase.h"
-
-namespace WebCore {
-
-class ResourceError : public ResourceErrorBase
-{
-public:
- ResourceError()
- {
- }
-
- ResourceError(const String& domain, int errorCode, const String& failingURL, const String& localizedDescription)
- : ResourceErrorBase(domain, errorCode, failingURL, localizedDescription)
- {
- }
-};
-
-}
-
-#endif // ResourceError_h_
diff --git a/WebCore/platform/network/soup/ResourceHandleSoup.cpp b/WebCore/platform/network/soup/ResourceHandleSoup.cpp
deleted file mode 100644
index d48ce27..0000000
--- a/WebCore/platform/network/soup/ResourceHandleSoup.cpp
+++ /dev/null
@@ -1,591 +0,0 @@
-/*
- * Copyright (C) 2008 Alp Toker <alp@atoker.com>
- * Copyright (C) 2008 Xan Lopez <xan@gnome.org>
- * Copyright (C) 2008 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-#include "CString.h"
-#include "ResourceHandle.h"
-
-#include "Base64.h"
-#include "CookieJar.h"
-#include "DocLoader.h"
-#include "Frame.h"
-#include "HTTPParsers.h"
-#include "MIMETypeRegistry.h"
-#include "NotImplemented.h"
-#include "ResourceError.h"
-#include "ResourceHandleClient.h"
-#include "ResourceHandleInternal.h"
-#include "ResourceResponse.h"
-#include "TextEncoding.h"
-
-#include <gio/gio.h>
-#include <libsoup/soup.h>
-#include <libsoup/soup-message.h>
-
-#if PLATFORM(GTK)
- #if GLIB_CHECK_VERSION(2,12,0)
- #define USE_GLIB_BASE64
- #endif
-#endif
-
-namespace WebCore {
-
-static SoupSession* session = 0;
-
-enum
-{
- ERROR_TRANSPORT,
- ERROR_UNKNOWN_PROTOCOL,
- ERROR_BAD_NON_HTTP_METHOD
-};
-
-ResourceHandleInternal::~ResourceHandleInternal()
-{
- if (m_msg) {
- g_object_unref(m_msg);
- m_msg = 0;
- }
-}
-
-ResourceHandle::~ResourceHandle()
-{
-}
-
-static void fillResponseFromMessage(SoupMessage* msg, ResourceResponse* response)
-{
- SoupMessageHeadersIter iter;
- const char* name = NULL;
- const char* value = NULL;
- soup_message_headers_iter_init(&iter, msg->response_headers);
- while (soup_message_headers_iter_next(&iter, &name, &value))
- response->setHTTPHeaderField(name, value);
-
- String contentType = soup_message_headers_get(msg->response_headers, "Content-Type");
- char* uri = soup_uri_to_string(soup_message_get_uri(msg), FALSE);
- response->setUrl(KURL(uri));
- g_free(uri);
- response->setMimeType(extractMIMETypeFromMediaType(contentType));
- response->setTextEncodingName(extractCharsetFromMediaType(contentType));
- response->setExpectedContentLength(soup_message_headers_get_content_length(msg->response_headers));
- response->setHTTPStatusCode(msg->status_code);
- response->setSuggestedFilename(filenameFromHTTPContentDisposition(response->httpHeaderField("Content-Disposition")));
-}
-
-// Called each time the message is going to be sent again except the first time.
-// It's used mostly to let webkit know about redirects.
-static void restartedCallback(SoupMessage* msg, gpointer data)
-{
- ResourceHandle* handle = static_cast<ResourceHandle*>(data);
- if (!handle)
- return;
- ResourceHandleInternal* d = handle->getInternal();
- if (d->m_cancelled)
- return;
-
- char* uri = soup_uri_to_string(soup_message_get_uri(msg), FALSE);
- String location = String(uri);
- g_free(uri);
- KURL newURL = KURL(handle->request().url(), location);
-
- ResourceRequest request = handle->request();
- ResourceResponse response;
- request.setURL(newURL);
- fillResponseFromMessage(msg, &response);
- if (d->client())
- d->client()->willSendRequest(handle, request, response);
-
- d->m_request.setURL(newURL);
-}
-
-static void gotHeadersCallback(SoupMessage* msg, gpointer data)
-{
- if (!SOUP_STATUS_IS_SUCCESSFUL(msg->status_code))
- return;
-
- ResourceHandle* handle = static_cast<ResourceHandle*>(data);
- if (!handle)
- return;
- ResourceHandleInternal* d = handle->getInternal();
- if (d->m_cancelled)
- return;
- ResourceHandleClient* client = handle->client();
- if (!client)
- return;
-
- fillResponseFromMessage(msg, &d->m_response);
- client->didReceiveResponse(handle, d->m_response);
- soup_message_set_flags(msg, SOUP_MESSAGE_OVERWRITE_CHUNKS);
-}
-
-static void gotChunkCallback(SoupMessage* msg, SoupBuffer* chunk, gpointer data)
-{
- if (!SOUP_STATUS_IS_SUCCESSFUL(msg->status_code))
- return;
-
- ResourceHandle* handle = static_cast<ResourceHandle*>(data);
- if (!handle)
- return;
- ResourceHandleInternal* d = handle->getInternal();
- if (d->m_cancelled)
- return;
- ResourceHandleClient* client = handle->client();
- if (!client)
- return;
-
- client->didReceiveData(handle, chunk->data, chunk->length, false);
-}
-
-// Called at the end of the message, with all the necessary about the last informations.
-// Doesn't get called for redirects.
-static void finishedCallback(SoupSession *session, SoupMessage* msg, gpointer data)
-{
- ResourceHandle* handle = static_cast<ResourceHandle*>(data);
- // TODO: maybe we should run this code even if there's no client?
- if (!handle)
- return;
-
- ResourceHandleInternal* d = handle->getInternal();
- // The message has been handled.
- d->m_msg = NULL;
-
- ResourceHandleClient* client = handle->client();
- if (!client)
- return;
-
- if (d->m_cancelled)
- return;
-
- if (SOUP_STATUS_IS_TRANSPORT_ERROR(msg->status_code)) {
- char* uri = soup_uri_to_string(soup_message_get_uri(msg), FALSE);
- ResourceError error("webkit-network-error", ERROR_TRANSPORT, uri, String::fromUTF8(msg->reason_phrase));
- g_free(uri);
- client->didFail(handle, error);
- return;
- } else if (!SOUP_STATUS_IS_SUCCESSFUL(msg->status_code)) {
- fillResponseFromMessage(msg, &d->m_response);
- client->didReceiveResponse(handle, d->m_response);
-
- // WebCore might have cancelled the job in the while
- if (d->m_cancelled)
- return;
-
- if (msg->response_body->data)
- client->didReceiveData(handle, msg->response_body->data, msg->response_body->length, true);
- }
-
- client->didFinishLoading(handle);
-}
-
-// parseDataUrl() is taken from the CURL http backend.
-static gboolean parseDataUrl(gpointer callback_data)
-{
- ResourceHandle* handle = static_cast<ResourceHandle*>(callback_data);
- ResourceHandleClient* client = handle->client();
-
- ASSERT(client);
- if (!client)
- return FALSE;
-
- String url = handle->request().url().string();
- ASSERT(url.startsWith("data:", false));
-
- int index = url.find(',');
- if (index == -1) {
- client->cannotShowURL(handle);
- return FALSE;
- }
-
- String mediaType = url.substring(5, index - 5);
- String data = url.substring(index + 1);
-
- bool base64 = mediaType.endsWith(";base64", false);
- if (base64)
- mediaType = mediaType.left(mediaType.length() - 7);
-
- if (mediaType.isEmpty())
- mediaType = "text/plain;charset=US-ASCII";
-
- String mimeType = extractMIMETypeFromMediaType(mediaType);
- String charset = extractCharsetFromMediaType(mediaType);
-
- ResourceResponse response;
- response.setMimeType(mimeType);
-
- if (base64) {
- data = decodeURLEscapeSequences(data);
- response.setTextEncodingName(charset);
- client->didReceiveResponse(handle, response);
-
- // Use the GLib Base64 if available, since WebCore's decoder isn't
- // general-purpose and fails on Acid3 test 97 (whitespace).
-#ifdef USE_GLIB_BASE64
- size_t outLength = 0;
- char* outData = 0;
- outData = reinterpret_cast<char*>(g_base64_decode(data.utf8().data(), &outLength));
- if (outData && outLength > 0)
- client->didReceiveData(handle, outData, outLength, 0);
- g_free(outData);
-#else
- Vector<char> out;
- if (base64Decode(data.latin1().data(), data.latin1().length(), out) && out.size() > 0)
- client->didReceiveData(handle, out.data(), out.size(), 0);
-#endif
- } else {
- // We have to convert to UTF-16 early due to limitations in KURL
- data = decodeURLEscapeSequences(data, TextEncoding(charset));
- response.setTextEncodingName("UTF-16");
- client->didReceiveResponse(handle, response);
- if (data.length() > 0)
- client->didReceiveData(handle, reinterpret_cast<const char*>(data.characters()), data.length() * sizeof(UChar), 0);
- }
-
- client->didFinishLoading(handle);
-
- return FALSE;
-}
-
-bool ResourceHandle::startData(String urlString)
-{
- // If parseDataUrl is called synchronously the job is not yet effectively started
- // and webkit won't never know that the data has been parsed even didFinishLoading is called.
- g_idle_add(parseDataUrl, this);
- return true;
-}
-
-bool ResourceHandle::startHttp(String urlString)
-{
- if (!session) {
- session = soup_session_async_new();
-
- soup_session_add_feature(session, SOUP_SESSION_FEATURE(getCookieJar()));
-
- const char* soup_debug = g_getenv("WEBKIT_SOUP_LOGGING");
- if (soup_debug) {
- int soup_debug_level = atoi(soup_debug);
-
- SoupLogger* logger = soup_logger_new(static_cast<SoupLoggerLogLevel>(soup_debug_level), -1);
- soup_logger_attach(logger, session);
- g_object_unref(logger);
- }
- }
-
- SoupMessage* msg;
- msg = soup_message_new(request().httpMethod().utf8().data(), urlString.utf8().data());
- g_signal_connect(msg, "restarted", G_CALLBACK(restartedCallback), this);
-
- g_signal_connect(msg, "got-headers", G_CALLBACK(gotHeadersCallback), this);
- g_signal_connect(msg, "got-chunk", G_CALLBACK(gotChunkCallback), this);
-
- HTTPHeaderMap customHeaders = d->m_request.httpHeaderFields();
- if (!customHeaders.isEmpty()) {
- HTTPHeaderMap::const_iterator end = customHeaders.end();
- for (HTTPHeaderMap::const_iterator it = customHeaders.begin(); it != end; ++it)
- soup_message_headers_append(msg->request_headers, it->first.utf8().data(), it->second.utf8().data());
- }
-
- FormData* httpBody = d->m_request.httpBody();
- if (httpBody && !httpBody->isEmpty()) {
- // Making a copy of the request body isn't the most efficient way to
- // serialize it, but by far the most simple. Dealing with individual
- // FormData elements and shared buffers should be more memory
- // efficient.
- //
- // This possibly isn't handling file uploads/attachments, for which
- // shared buffers or streaming should definitely be used.
- Vector<char> body;
- httpBody->flatten(body);
- soup_message_set_request(msg, d->m_request.httpContentType().utf8().data(),
- SOUP_MEMORY_COPY, body.data(), body.size());
- }
-
- d->m_msg = static_cast<SoupMessage*>(g_object_ref(msg));
- soup_session_queue_message(session, d->m_msg, finishedCallback, this);
-
- return true;
-}
-
-bool ResourceHandle::start(Frame* frame)
-{
- ASSERT(!d->m_msg);
-
- // If we are no longer attached to a Page, this must be an attempted load from an
- // onUnload handler, so let's just block it.
- if (!frame->page())
- return false;
-
- KURL url = request().url();
- String urlString = url.string();
- String protocol = url.protocol();
-
- if (equalIgnoringCase(protocol, "data"))
- return startData(urlString);
- else if (equalIgnoringCase(protocol, "http") || equalIgnoringCase(protocol, "https"))
- return startHttp(urlString);
- else if (equalIgnoringCase(protocol, "file") || equalIgnoringCase(protocol, "ftp") || equalIgnoringCase(protocol, "ftps"))
- // FIXME: should we be doing any other protocols here?
- return startGio(urlString);
- else {
- // If we don't call didFail the job is not complete for webkit even false is returned.
- if (d->client()) {
- ResourceError error("webkit-network-error", ERROR_UNKNOWN_PROTOCOL, urlString, protocol);
- d->client()->didFail(this, error);
- }
- return false;
- }
-}
-
-void ResourceHandle::cancel()
-{
- d->m_cancelled = true;
- if (d->m_msg) {
- soup_session_cancel_message(session, d->m_msg, SOUP_STATUS_CANCELLED);
- // For re-entrancy troubles we call didFinishLoading when the message hasn't been handled yet.
- d->client()->didFinishLoading(this);
- } else if (d->m_cancellable) {
- g_cancellable_cancel(d->m_cancellable);
- d->client()->didFinishLoading(this);
- }
-}
-
-PassRefPtr<SharedBuffer> ResourceHandle::bufferedData()
-{
- ASSERT_NOT_REACHED();
- return 0;
-}
-
-bool ResourceHandle::supportsBufferedData()
-{
- return false;
-}
-
-void ResourceHandle::setDefersLoading(bool defers)
-{
- d->m_defersLoading = defers;
- notImplemented();
-}
-
-bool ResourceHandle::loadsBlocked()
-{
- return false;
-}
-
-bool ResourceHandle::willLoadFromCache(ResourceRequest&)
-{
- // Not having this function means that we'll ask the user about re-posting a form
- // even when we go back to a page that's still in the cache.
- notImplemented();
- return false;
-}
-
-void ResourceHandle::loadResourceSynchronously(const ResourceRequest&, ResourceError&, ResourceResponse&, Vector<char>&, Frame*)
-{
- notImplemented();
-}
-
-// GIO-based loader
-
-static inline ResourceError networkErrorForFile(GFile* file, GError* error)
-{
- // FIXME: Map gio errors to a more detailed error code when we have it in WebKit.
- gchar* uri = g_file_get_uri(file);
- ResourceError resourceError("webkit-network-error", ERROR_TRANSPORT, uri, String::fromUTF8(error->message));
- g_free(uri);
- return resourceError;
-}
-
-static void cleanupGioOperation(ResourceHandle* handle)
-{
- ResourceHandleInternal* d = handle->getInternal();
-
- if (d->m_gfile) {
- g_object_unref(d->m_gfile);
- d->m_gfile = NULL;
- }
- if (d->m_cancellable) {
- g_object_unref(d->m_cancellable);
- d->m_cancellable = NULL;
- }
- if (d->m_input_stream) {
- g_object_unref(d->m_input_stream);
- d->m_input_stream = NULL;
- }
- if (d->m_buffer) {
- g_free(d->m_buffer);
- d->m_buffer = NULL;
- }
-}
-
-static void closeCallback(GObject* source, GAsyncResult* res, gpointer data)
-{
- ResourceHandle* handle = static_cast<ResourceHandle*>(data);
- ResourceHandleInternal* d = handle->getInternal();
- ResourceHandleClient* client = handle->client();
-
- g_input_stream_close_finish(d->m_input_stream, res, NULL);
- cleanupGioOperation(handle);
- client->didFinishLoading(handle);
-}
-
-static void readCallback(GObject* source, GAsyncResult* res, gpointer data)
-{
- ResourceHandle* handle = static_cast<ResourceHandle*>(data);
- ResourceHandleInternal* d = handle->getInternal();
- ResourceHandleClient* client = handle->client();
-
- if (d->m_cancelled || !client) {
- cleanupGioOperation(handle);
- return;
- }
-
- gssize nread;
- GError *error = 0;
-
- nread = g_input_stream_read_finish(d->m_input_stream, res, &error);
- if (error) {
- client->didFail(handle, networkErrorForFile(d->m_gfile, error));
- cleanupGioOperation(handle);
- return;
- } else if (!nread) {
- g_input_stream_close_async(d->m_input_stream, G_PRIORITY_DEFAULT,
- NULL, closeCallback, handle);
- return;
- }
-
- d->m_total += nread;
- client->didReceiveData(handle, d->m_buffer, nread, d->m_total);
-
- g_input_stream_read_async(d->m_input_stream, d->m_buffer, d->m_bufsize,
- G_PRIORITY_DEFAULT, d->m_cancellable,
- readCallback, handle);
-}
-
-static void openCallback(GObject* source, GAsyncResult* res, gpointer data)
-{
- ResourceHandle* handle = static_cast<ResourceHandle*>(data);
- ResourceHandleInternal* d = handle->getInternal();
- ResourceHandleClient* client = handle->client();
-
- if (d->m_cancelled || !client) {
- cleanupGioOperation(handle);
- return;
- }
-
- GFileInputStream* in;
- GError *error = NULL;
- in = g_file_read_finish(G_FILE(source), res, &error);
- if (error) {
- client->didFail(handle, networkErrorForFile(d->m_gfile, error));
- cleanupGioOperation(handle);
- return;
- }
-
- d->m_input_stream = G_INPUT_STREAM(in);
- d->m_bufsize = 8192;
- d->m_buffer = static_cast<char*>(g_malloc(d->m_bufsize));
- d->m_total = 0;
- g_input_stream_read_async(d->m_input_stream, d->m_buffer, d->m_bufsize,
- G_PRIORITY_DEFAULT, d->m_cancellable,
- readCallback, handle);
-}
-
-static void queryInfoCallback(GObject* source, GAsyncResult* res, gpointer data)
-{
- ResourceHandle* handle = static_cast<ResourceHandle*>(data);
- ResourceHandleInternal* d = handle->getInternal();
- ResourceHandleClient* client = handle->client();
-
- if (d->m_cancelled) {
- cleanupGioOperation(handle);
- return;
- }
-
- ResourceResponse response;
-
- char* uri = g_file_get_uri(d->m_gfile);
- response.setUrl(KURL(uri));
- g_free(uri);
-
- GError *error = NULL;
- GFileInfo* info = g_file_query_info_finish(d->m_gfile, res, &error);
-
- if (error) {
- // FIXME: to be able to handle ftp URIs properly, we must
- // check if the error is G_IO_ERROR_NOT_MOUNTED, and if so,
- // call g_file_mount_enclosing_volume() to mount the ftp
- // server (and then keep track of the fact that we mounted it,
- // and set a timeout to unmount it later after it's been idle
- // for a while).
-
- client->didFail(handle, networkErrorForFile(d->m_gfile, error));
- cleanupGioOperation(handle);
- return;
- }
-
- if (g_file_info_get_file_type(info) != G_FILE_TYPE_REGULAR) {
- // FIXME: what if the URI points to a directory? Should we
- // generate a listing? How? What do other backends do here?
-
- client->didFail(handle, networkErrorForFile(d->m_gfile, error));
- cleanupGioOperation(handle);
- return;
- }
-
- response.setMimeType(g_file_info_get_content_type(info));
- response.setExpectedContentLength(g_file_info_get_size(info));
- response.setHTTPStatusCode(SOUP_STATUS_OK);
-
- GTimeVal tv;
- g_file_info_get_modification_time(info, &tv);
- response.setLastModifiedDate(tv.tv_sec);
-
- client->didReceiveResponse(handle, response);
-
- g_file_read_async(d->m_gfile, G_PRIORITY_DEFAULT, d->m_cancellable,
- openCallback, handle);
-}
-
-bool ResourceHandle::startGio(String urlString)
-{
- if (request().httpMethod() != "GET") {
- ResourceError error("webkit-network-error", ERROR_BAD_NON_HTTP_METHOD, urlString, request().httpMethod());
- d->client()->didFail(this, error);
- return false;
- }
-
- // Remove the fragment part of the URL since the file backend doesn't deal with it
- int fragPos;
- if ((fragPos = urlString.find("#")) != -1)
- urlString = urlString.left(fragPos);
-
- d->m_gfile = g_file_new_for_uri(urlString.utf8().data());
- d->m_cancellable = g_cancellable_new();
- g_file_query_info_async(d->m_gfile,
- G_FILE_ATTRIBUTE_STANDARD_TYPE ","
- G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE ","
- G_FILE_ATTRIBUTE_STANDARD_SIZE,
- G_FILE_QUERY_INFO_NONE,
- G_PRIORITY_DEFAULT, d->m_cancellable,
- queryInfoCallback, this);
- return true;
-}
-
-}
-
diff --git a/WebCore/platform/network/soup/ResourceRequest.h b/WebCore/platform/network/soup/ResourceRequest.h
deleted file mode 100644
index efb1240..0000000
--- a/WebCore/platform/network/soup/ResourceRequest.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ResourceRequest_h
-#define ResourceRequest_h
-
-#include "ResourceRequestBase.h"
-
-namespace WebCore {
-
- struct ResourceRequest : ResourceRequestBase {
-
- ResourceRequest(const String& url)
- : ResourceRequestBase(KURL(url), UseProtocolCachePolicy)
- {
- }
-
- ResourceRequest(const KURL& url)
- : ResourceRequestBase(url, UseProtocolCachePolicy)
- {
- }
-
- ResourceRequest(const KURL& url, const String& referrer, ResourceRequestCachePolicy policy = UseProtocolCachePolicy)
- : ResourceRequestBase(url, policy)
- {
- setHTTPReferrer(referrer);
- }
-
- ResourceRequest()
- : ResourceRequestBase(KURL(), UseProtocolCachePolicy)
- {
- }
-
- private:
- friend class ResourceRequestBase;
-
- void doUpdatePlatformRequest() {}
- void doUpdateResourceRequest() {}
- };
-
-} // namespace WebCore
-
-#endif // ResourceRequest_h
diff --git a/WebCore/platform/network/soup/ResourceResponse.h b/WebCore/platform/network/soup/ResourceResponse.h
deleted file mode 100644
index b8cb586..0000000
--- a/WebCore/platform/network/soup/ResourceResponse.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ResourceResponse_h
-#define ResourceResponse_h
-
-#include "ResourceResponseBase.h"
-
-namespace WebCore {
-
-class ResourceResponse : public ResourceResponseBase {
-public:
- ResourceResponse()
- : ResourceResponseBase()
- {
- }
-
- ResourceResponse(const KURL& url, const String& mimeType, long long expectedLength, const String& textEncodingName, const String& filename)
- : ResourceResponseBase(url, mimeType, expectedLength, textEncodingName, filename)
- {
- }
-
-private:
- friend class ResourceResponseBase;
-
- void doUpdateResourceResponse()
- {
- }
-};
-
-} // namespace WebCore
-
-#endif // ResourceResponse_h
diff --git a/WebCore/platform/network/win/CookieJarCFNetWin.cpp b/WebCore/platform/network/win/CookieJarCFNetWin.cpp
deleted file mode 100644
index fd795ee..0000000
--- a/WebCore/platform/network/win/CookieJarCFNetWin.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "CookieJar.h"
-
-#include "CookieStorageWin.h"
-#include "KURL.h"
-#include "PlatformString.h"
-#include "Document.h"
-#include "ResourceHandle.h"
-#include <windows.h>
-#include <CoreFoundation/CoreFoundation.h>
-#include <CFNetwork/CFHTTPCookiesPriv.h>
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
-
-namespace WebCore {
-
-static const CFStringRef s_setCookieKeyCF = CFSTR("Set-Cookie");
-static const CFStringRef s_cookieCF = CFSTR("Cookie");
-
-void setCookies(Document* /*document*/, const KURL& url, const KURL& policyURL, const String& value)
-{
- // <rdar://problem/5632883> CFHTTPCookieStorage happily stores an empty cookie, which would be sent as "Cookie: =".
- if (value.isEmpty())
- return;
-
- CFHTTPCookieStorageRef cookieStorage = currentCookieStorage();
- if (!cookieStorage)
- return;
-
- RetainPtr<CFURLRef> urlCF(AdoptCF, url.createCFURL());
- RetainPtr<CFURLRef> policyURLCF(AdoptCF, policyURL.createCFURL());
-
- // <http://bugs.webkit.org/show_bug.cgi?id=6531>, <rdar://4409034>
- // cookiesWithResponseHeaderFields doesn't parse cookies without a value
- String cookieString = value.contains('=') ? value : value + "=";
-
- RetainPtr<CFStringRef> cookieStringCF(AdoptCF, cookieString.createCFString());
- RetainPtr<CFDictionaryRef> headerFieldsCF(AdoptCF, CFDictionaryCreate(kCFAllocatorDefault, (const void**)&s_setCookieKeyCF,
- (const void**)&cookieStringCF, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
-
- RetainPtr<CFArrayRef> cookiesCF(AdoptCF, CFHTTPCookieCreateWithResponseHeaderFields(kCFAllocatorDefault,
- headerFieldsCF.get(), urlCF.get()));
-
- CFHTTPCookieStorageSetCookies(cookieStorage, cookiesCF.get(), urlCF.get(), policyURLCF.get());
-}
-
-String cookies(const Document* /*document*/, const KURL& url)
-{
- CFHTTPCookieStorageRef cookieStorage = currentCookieStorage();
- if (!cookieStorage)
- return String();
-
- String cookieString;
- RetainPtr<CFURLRef> urlCF(AdoptCF, url.createCFURL());
-
- bool secure = equalIgnoringCase(url.protocol(), "https");
-
- RetainPtr<CFArrayRef> cookiesCF(AdoptCF, CFHTTPCookieStorageCopyCookiesForURL(cookieStorage, urlCF.get(), secure));
-
- // <rdar://problem/5632883> CFHTTPCookieStorage happily stores an empty cookie, which would be sent as "Cookie: =".
- // We have a workaround in setCookies() to prevent that, but we also need to avoid sending cookies that were previously stored.
- CFIndex count = CFArrayGetCount(cookiesCF.get());
- RetainPtr<CFMutableArrayRef> cookiesForURLFilteredCopy(AdoptCF, CFArrayCreateMutable(0, count, &kCFTypeArrayCallBacks));
- for (CFIndex i = 0; i < count; ++i) {
- CFHTTPCookieRef cookie = (CFHTTPCookieRef)CFArrayGetValueAtIndex(cookiesCF.get(), i);
- if (CFStringGetLength(CFHTTPCookieGetName(cookie)) != 0)
- CFArrayAppendValue(cookiesForURLFilteredCopy.get(), cookie);
- }
- RetainPtr<CFDictionaryRef> headerCF(AdoptCF, CFHTTPCookieCopyRequestHeaderFields(kCFAllocatorDefault, cookiesForURLFilteredCopy.get()));
-
- return (CFStringRef)CFDictionaryGetValue(headerCF.get(), s_cookieCF);
-}
-
-bool cookiesEnabled(const Document* /*document*/)
-{
- CFHTTPCookieStorageAcceptPolicy policy = CFHTTPCookieStorageAcceptPolicyOnlyFromMainDocumentDomain;
- if (CFHTTPCookieStorageRef cookieStorage = currentCookieStorage())
- policy = CFHTTPCookieStorageGetCookieAcceptPolicy(cookieStorage);
- return policy == CFHTTPCookieStorageAcceptPolicyOnlyFromMainDocumentDomain || policy == CFHTTPCookieStorageAcceptPolicyAlways;
-}
-
-}
diff --git a/WebCore/platform/network/win/CookieJarWin.cpp b/WebCore/platform/network/win/CookieJarWin.cpp
deleted file mode 100644
index cdafb1b..0000000
--- a/WebCore/platform/network/win/CookieJarWin.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "CookieJar.h"
-
-#include "KURL.h"
-#include "PlatformString.h"
-#include "Document.h"
-#include "ResourceHandle.h"
-#include <windows.h>
-#include <Wininet.h>
-
-namespace WebCore {
-
-
-void setCookies(Document* /*document*/, const KURL& url, const KURL& policyURL, const String& value)
-{
- // FIXME: Deal with the policy URL.
- String str = url.string();
- String val = value;
- InternetSetCookie(str.charactersWithNullTermination(), 0, val.charactersWithNullTermination());
-}
-
-String cookies(const Document* /*document*/, const KURL& url)
-{
- String str = url.string();
-
- DWORD count = str.length() + 1;
- InternetGetCookie(str.charactersWithNullTermination(), 0, 0, &count);
- if (count <= 1) // Null terminator counts as 1.
- return String();
-
- Vector<UChar> buffer(count);
- InternetGetCookie(str.charactersWithNullTermination(), 0, buffer.data(), &count);
- buffer.shrink(count - 1); // Ignore the null terminator.
- return String::adopt(buffer);
-}
-
-bool cookiesEnabled(const Document* /*document*/)
-{
- return true;
-}
-
-}
diff --git a/WebCore/platform/network/win/CookieStorageWin.cpp b/WebCore/platform/network/win/CookieStorageWin.cpp
deleted file mode 100644
index 5e74c17..0000000
--- a/WebCore/platform/network/win/CookieStorageWin.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "CookieStorageWin.h"
-
-#include <CFNetwork/CFHTTPCookiesPriv.h>
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
-#include <wtf/RetainPtr.h>
-
-namespace WebCore {
-
-static RetainPtr<CFHTTPCookieStorageRef> s_cookieStorage;
-
-CFHTTPCookieStorageRef currentCookieStorage()
-{
- if (s_cookieStorage)
- return s_cookieStorage.get();
- return wkGetDefaultHTTPCookieStorage();
-}
-
-void setCurrentCookieStorage(CFHTTPCookieStorageRef cookieStorage)
-{
- s_cookieStorage = cookieStorage;
-}
-
-}
diff --git a/WebCore/platform/network/win/CookieStorageWin.h b/WebCore/platform/network/win/CookieStorageWin.h
deleted file mode 100644
index 4350b72..0000000
--- a/WebCore/platform/network/win/CookieStorageWin.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef CookieStorageWin_h
-#define CookieStorageWin_h
-
-typedef struct OpaqueCFHTTPCookieStorage* CFHTTPCookieStorageRef;
-
-namespace WebCore {
-
- CFHTTPCookieStorageRef currentCookieStorage();
-
- void setCurrentCookieStorage(CFHTTPCookieStorageRef cookieStorage);
-
-}
-
-#endif // CookieStorageWin_h
diff --git a/WebCore/platform/network/win/NetworkStateNotifierWin.cpp b/WebCore/platform/network/win/NetworkStateNotifierWin.cpp
deleted file mode 100644
index f8cbace..0000000
--- a/WebCore/platform/network/win/NetworkStateNotifierWin.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "NetworkStateNotifier.h"
-
-#include <wtf/MainThread.h>
-#include <wtf/Vector.h>
-
-#include <winsock2.h>
-#include <iphlpapi.h>
-
-namespace WebCore {
-
-void NetworkStateNotifier::updateState()
-{
- // Assume that we're online until proven otherwise.
- m_isOnLine = true;
-
- Vector<char> buffer;
- DWORD size = 0;
-
- if (::GetAdaptersAddresses(AF_UNSPEC, 0, 0, 0, &size) != ERROR_BUFFER_OVERFLOW)
- return;
-
- buffer.resize(size);
- PIP_ADAPTER_ADDRESSES addresses = reinterpret_cast<PIP_ADAPTER_ADDRESSES>(buffer.data());
-
- if (::GetAdaptersAddresses(AF_UNSPEC, 0, 0, addresses, &size) != ERROR_SUCCESS) {
- // We couldn't determine whether we're online or not, so assume that we are.
- return;
- }
-
- for (; addresses; addresses = addresses->Next) {
- if (addresses->IfType == MIB_IF_TYPE_LOOPBACK)
- continue;
-
- if (addresses->OperStatus != IfOperStatusUp)
- continue;
-
- // We found an interface that was up.
- return;
- }
-
- // We didn't find any valid interfaces, so we must be offline.
- m_isOnLine = false;
-}
-
-void NetworkStateNotifier::addressChanged()
-{
- bool oldOnLine = m_isOnLine;
-
- updateState();
-
- if (m_isOnLine == oldOnLine)
- return;
-
- if (m_networkStateChangedFunction)
- m_networkStateChangedFunction();
-}
-
-void NetworkStateNotifier::callAddressChanged(void* context)
-{
- static_cast<NetworkStateNotifier*>(context)->addressChanged();
-}
-
-void CALLBACK NetworkStateNotifier::addrChangeCallback(void* context, BOOLEAN timedOut)
-{
- callOnMainThread(callAddressChanged, context);
-}
-
-void NetworkStateNotifier::registerForAddressChange()
-{
- HANDLE handle;
- ::NotifyAddrChange(&handle, &m_overlapped);
-}
-
-NetworkStateNotifier::NetworkStateNotifier()
- : m_isOnLine(false)
-{
- updateState();
-
- memset(&m_overlapped, 0, sizeof(m_overlapped));
-
- m_overlapped.hEvent = ::CreateEvent(0, false, false, 0);
-
- ::RegisterWaitForSingleObject(&m_waitHandle, m_overlapped.hEvent, addrChangeCallback, this, INFINITE, 0);
-
- registerForAddressChange();
-}
-
-}
diff --git a/WebCore/platform/network/win/ResourceHandleWin.cpp b/WebCore/platform/network/win/ResourceHandleWin.cpp
deleted file mode 100644
index 337b752..0000000
--- a/WebCore/platform/network/win/ResourceHandleWin.cpp
+++ /dev/null
@@ -1,457 +0,0 @@
-/*
- * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ResourceHandle.h"
-#include "ResourceHandleClient.h"
-#include "ResourceHandleInternal.h"
-#include "ResourceHandleWin.h"
-
-#include "CString.h"
-#include "DocLoader.h"
-#include "Document.h"
-#include "Frame.h"
-#include "FrameLoader.h"
-#include "Page.h"
-#include "ResourceError.h"
-#include "Timer.h"
-#include <windows.h>
-#include <wininet.h>
-
-namespace WebCore {
-
-static unsigned transferJobId = 0;
-static HashMap<int, ResourceHandle*>* jobIdMap = 0;
-
-static HWND transferJobWindowHandle = 0;
-const LPCWSTR kResourceHandleWindowClassName = L"ResourceHandleWindowClass";
-
-// Message types for internal use (keep in sync with kMessageHandlers)
-enum {
- handleCreatedMessage = WM_USER,
- requestRedirectedMessage,
- requestCompleteMessage
-};
-
-typedef void (ResourceHandle:: *ResourceHandleEventHandler)(LPARAM);
-static const ResourceHandleEventHandler messageHandlers[] = {
- &ResourceHandle::onHandleCreated,
- &ResourceHandle::onRequestRedirected,
- &ResourceHandle::onRequestComplete
-};
-
-static int addToOutstandingJobs(ResourceHandle* job)
-{
- if (!jobIdMap)
- jobIdMap = new HashMap<int, ResourceHandle*>;
- transferJobId++;
- jobIdMap->set(transferJobId, job);
- return transferJobId;
-}
-
-static void removeFromOutstandingJobs(int jobId)
-{
- if (!jobIdMap)
- return;
- jobIdMap->remove(jobId);
-}
-
-static ResourceHandle* lookupResourceHandle(int jobId)
-{
- if (!jobIdMap)
- return 0;
- return jobIdMap->get(jobId);
-}
-
-static LRESULT CALLBACK ResourceHandleWndProc(HWND hWnd, UINT message,
- WPARAM wParam, LPARAM lParam)
-{
- if (message >= handleCreatedMessage) {
- UINT index = message - handleCreatedMessage;
- if (index < _countof(messageHandlers)) {
- unsigned jobId = (unsigned) wParam;
- ResourceHandle* job = lookupResourceHandle(jobId);
- if (job) {
- ASSERT(job->d->m_jobId == jobId);
- ASSERT(job->d->m_threadId == GetCurrentThreadId());
- (job->*(messageHandlers[index]))(lParam);
- }
- return 0;
- }
- }
- return DefWindowProc(hWnd, message, wParam, lParam);
-}
-
-static void initializeOffScreenResourceHandleWindow()
-{
- if (transferJobWindowHandle)
- return;
-
- WNDCLASSEX wcex;
- memset(&wcex, 0, sizeof(WNDCLASSEX));
- wcex.cbSize = sizeof(WNDCLASSEX);
- wcex.lpfnWndProc = ResourceHandleWndProc;
- wcex.hInstance = Page::instanceHandle();
- wcex.lpszClassName = kResourceHandleWindowClassName;
- RegisterClassEx(&wcex);
-
- transferJobWindowHandle = CreateWindow(kResourceHandleWindowClassName, 0, 0, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0,
- HWND_MESSAGE, 0, Page::instanceHandle(), 0);
-}
-
-ResourceHandleInternal::~ResourceHandleInternal()
-{
- if (m_fileHandle != INVALID_HANDLE_VALUE)
- CloseHandle(m_fileHandle);
-}
-
-ResourceHandle::~ResourceHandle()
-{
- if (d->m_jobId)
- removeFromOutstandingJobs(d->m_jobId);
-}
-
-void ResourceHandle::onHandleCreated(LPARAM lParam)
-{
- if (!d->m_resourceHandle) {
- d->m_resourceHandle = HINTERNET(lParam);
- if (d->status != 0) {
- // We were canceled before Windows actually created a handle for us, close and delete now.
- InternetCloseHandle(d->m_resourceHandle);
- delete this;
- return;
- }
-
- if (method() == "POST") {
- // FIXME: Too late to set referrer properly.
- String urlStr = url().path();
- int fragmentIndex = urlStr.find('#');
- if (fragmentIndex != -1)
- urlStr = urlStr.left(fragmentIndex);
- static LPCSTR accept[2]={"*/*", NULL};
- HINTERNET urlHandle = HttpOpenRequestA(d->m_resourceHandle,
- "POST", urlStr.latin1().data(), 0, 0, accept,
- INTERNET_FLAG_KEEP_CONNECTION |
- INTERNET_FLAG_FORMS_SUBMIT |
- INTERNET_FLAG_RELOAD |
- INTERNET_FLAG_NO_CACHE_WRITE |
- INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS |
- INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP,
- (DWORD_PTR)d->m_jobId);
- if (urlHandle == INVALID_HANDLE_VALUE) {
- InternetCloseHandle(d->m_resourceHandle);
- delete this;
- }
- }
- } else if (!d->m_secondaryHandle) {
- assert(method() == "POST");
- d->m_secondaryHandle = HINTERNET(lParam);
-
- // Need to actually send the request now.
- String headers = "Content-Type: application/x-www-form-urlencoded\n";
- headers += "Referer: ";
- headers += d->m_postReferrer;
- headers += "\n";
- const CString& headersLatin1 = headers.latin1();
- String formData = postData()->flattenToString();
- INTERNET_BUFFERSA buffers;
- memset(&buffers, 0, sizeof(buffers));
- buffers.dwStructSize = sizeof(INTERNET_BUFFERSA);
- buffers.lpcszHeader = headersLatin1;
- buffers.dwHeadersLength = headers.length();
- buffers.dwBufferTotal = formData.length();
-
- d->m_bytesRemainingToWrite = formData.length();
- d->m_formDataString = (char*)malloc(formData.length());
- d->m_formDataLength = formData.length();
- strncpy(d->m_formDataString, formData.latin1(), formData.length());
- d->m_writing = true;
- HttpSendRequestExA(d->m_secondaryHandle, &buffers, 0, 0, (DWORD_PTR)d->m_jobId);
- // FIXME: add proper error handling
- }
-}
-
-void ResourceHandle::onRequestRedirected(LPARAM lParam)
-{
- // If already canceled, then ignore this event.
- if (d->status != 0)
- return;
-
- ResourceRequest request((StringImpl*) lParam);
- ResourceResponse redirectResponse;
- client()->willSendRequest(this, request, redirectResponse);
-}
-
-void ResourceHandle::onRequestComplete(LPARAM lParam)
-{
- if (d->m_writing) {
- DWORD bytesWritten;
- InternetWriteFile(d->m_secondaryHandle,
- d->m_formDataString + (d->m_formDataLength - d->m_bytesRemainingToWrite),
- d->m_bytesRemainingToWrite,
- &bytesWritten);
- d->m_bytesRemainingToWrite -= bytesWritten;
- if (!d->m_bytesRemainingToWrite) {
- // End the request.
- d->m_writing = false;
- HttpEndRequest(d->m_secondaryHandle, 0, 0, (DWORD_PTR)d->m_jobId);
- free(d->m_formDataString);
- d->m_formDataString = 0;
- }
- return;
- }
-
- HINTERNET handle = (method() == "POST") ? d->m_secondaryHandle : d->m_resourceHandle;
- BOOL ok = FALSE;
-
- static const int bufferSize = 32768;
- char buffer[bufferSize];
- INTERNET_BUFFERSA buffers;
- buffers.dwStructSize = sizeof(INTERNET_BUFFERSA);
- buffers.lpvBuffer = buffer;
- buffers.dwBufferLength = bufferSize;
-
- bool receivedAnyData = false;
- while ((ok = InternetReadFileExA(handle, &buffers, IRF_NO_WAIT, (DWORD_PTR)this)) && buffers.dwBufferLength) {
- if (!hasReceivedResponse()) {
- setHasReceivedResponse();
- ResourceResponse response;
- client()->didReceiveResponse(this, response);
- }
- client()->didReceiveData(this, buffer, buffers.dwBufferLength, 0);
- buffers.dwBufferLength = bufferSize;
- }
-
- PlatformDataStruct platformData;
- platformData.errorString = 0;
- platformData.error = 0;
- platformData.loaded = ok;
-
- if (!ok) {
- int error = GetLastError();
- if (error == ERROR_IO_PENDING)
- return;
- DWORD errorStringChars = 0;
- if (!InternetGetLastResponseInfo(&platformData.error, 0, &errorStringChars)) {
- if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
- platformData.errorString = new TCHAR[errorStringChars];
- InternetGetLastResponseInfo(&platformData.error, platformData.errorString, &errorStringChars);
- }
- }
- _RPTF1(_CRT_WARN, "Load error: %i\n", error);
- }
-
- if (d->m_secondaryHandle)
- InternetCloseHandle(d->m_secondaryHandle);
- InternetCloseHandle(d->m_resourceHandle);
-
- client()->didFinishLoading(this);
- delete this;
-}
-
-static void __stdcall transferJobStatusCallback(HINTERNET internetHandle,
- DWORD_PTR jobId,
- DWORD internetStatus,
- LPVOID statusInformation,
- DWORD statusInformationLength)
-{
-#ifdef RESOURCE_LOADER_DEBUG
- char buf[64];
- _snprintf(buf, sizeof(buf), "status-callback: status=%u, job=%p\n",
- internetStatus, jobId);
- OutputDebugStringA(buf);
-#endif
-
- UINT msg;
- LPARAM lParam;
-
- switch (internetStatus) {
- case INTERNET_STATUS_HANDLE_CREATED:
- // tell the main thread about the newly created handle
- msg = handleCreatedMessage;
- lParam = (LPARAM) LPINTERNET_ASYNC_RESULT(statusInformation)->dwResult;
- break;
- case INTERNET_STATUS_REQUEST_COMPLETE:
-#ifdef RESOURCE_LOADER_DEBUG
- _snprintf(buf, sizeof(buf), "request-complete: result=%p, error=%u\n",
- LPINTERNET_ASYNC_RESULT(statusInformation)->dwResult,
- LPINTERNET_ASYNC_RESULT(statusInformation)->dwError);
- OutputDebugStringA(buf);
-#endif
- // tell the main thread that the request is done
- msg = requestCompleteMessage;
- lParam = 0;
- break;
- case INTERNET_STATUS_REDIRECT:
- // tell the main thread to observe this redirect (FIXME: we probably
- // need to block the redirect at this point so the application can
- // decide whether or not to follow the redirect)
- msg = requestRedirectedMessage;
- lParam = (LPARAM) new StringImpl((const UChar*) statusInformation,
- statusInformationLength);
- break;
- case INTERNET_STATUS_USER_INPUT_REQUIRED:
- // FIXME: prompt the user if necessary
- ResumeSuspendedDownload(internetHandle, 0);
- case INTERNET_STATUS_STATE_CHANGE:
- // may need to call ResumeSuspendedDownload here as well
- default:
- return;
- }
-
- PostMessage(transferJobWindowHandle, msg, (WPARAM) jobId, lParam);
-}
-
-bool ResourceHandle::start(Frame* frame)
-{
- ref();
- if (url().isLocalFile()) {
- String path = url().path();
- // windows does not enjoy a leading slash on paths
- if (path[0] == '/')
- path = path.substring(1);
- // FIXME: This is wrong. Need to use wide version of this call.
- d->m_fileHandle = CreateFileA(path.utf8().data(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
-
- // FIXME: perhaps this error should be reported asynchronously for
- // consistency.
- if (d->m_fileHandle == INVALID_HANDLE_VALUE) {
- delete this;
- return false;
- }
-
- d->m_fileLoadTimer.startOneShot(0.0);
- return true;
- } else {
- static HINTERNET internetHandle = 0;
- if (!internetHandle) {
- String userAgentStr = frame->loader()->userAgent() + String("", 1);
- LPCWSTR userAgent = reinterpret_cast<const WCHAR*>(userAgentStr.characters());
- // leak the Internet for now
- internetHandle = InternetOpen(userAgent, INTERNET_OPEN_TYPE_PRECONFIG, 0, 0, INTERNET_FLAG_ASYNC);
- }
- if (!internetHandle) {
- delete this;
- return false;
- }
- static INTERNET_STATUS_CALLBACK callbackHandle =
- InternetSetStatusCallback(internetHandle, transferJobStatusCallback);
-
- initializeOffScreenResourceHandleWindow();
- d->m_jobId = addToOutstandingJobs(this);
-
- DWORD flags =
- INTERNET_FLAG_KEEP_CONNECTION |
- INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS |
- INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP;
-
- // For form posting, we can't use InternetOpenURL. We have to use
- // InternetConnect followed by HttpSendRequest.
- HINTERNET urlHandle;
- String referrer = frame->loader()->referrer();
- if (method() == "POST") {
- d->m_postReferrer = referrer;
- String host = url().host();
- urlHandle = InternetConnectA(internetHandle, host.latin1().data(),
- url().port(),
- NULL, // no username
- NULL, // no password
- INTERNET_SERVICE_HTTP,
- flags, (DWORD_PTR)d->m_jobId);
- } else {
- String urlStr = url().string();
- int fragmentIndex = urlStr.find('#');
- if (fragmentIndex != -1)
- urlStr = urlStr.left(fragmentIndex);
- String headers;
- if (!referrer.isEmpty())
- headers += String("Referer: ") + referrer + "\r\n";
-
- urlHandle = InternetOpenUrlA(internetHandle, urlStr.latin1().data(),
- headers.latin1().data(), headers.length(),
- flags, (DWORD_PTR)d->m_jobId);
- }
-
- if (urlHandle == INVALID_HANDLE_VALUE) {
- delete this;
- return false;
- }
- d->m_threadId = GetCurrentThreadId();
-
- return true;
- }
-}
-
-void ResourceHandle::fileLoadTimer(Timer<ResourceHandle>* timer)
-{
- ResourceResponse response;
- client()->didReceiveResponse(this, response);
-
- bool result = false;
- DWORD bytesRead = 0;
-
- do {
- const int bufferSize = 8192;
- char buffer[bufferSize];
- result = ReadFile(d->m_fileHandle, &buffer, bufferSize, &bytesRead, NULL);
- if (result && bytesRead)
- client()->didReceiveData(this, buffer, bytesRead, 0);
- // Check for end of file.
- } while (result && bytesRead);
-
- // FIXME: handle errors better
-
- CloseHandle(d->m_fileHandle);
- d->m_fileHandle = INVALID_HANDLE_VALUE;
-
- client()->didFinishLoading(this);
-}
-
-void ResourceHandle::cancel()
-{
- if (d->m_resourceHandle)
- InternetCloseHandle(d->m_resourceHandle);
- else
- d->m_fileLoadTimer.stop();
-
- client()->didFinishLoading(this);
-
- if (!d->m_resourceHandle)
- // Async load canceled before we have a handle -- mark ourselves as in error, to be deleted later.
- // FIXME: need real cancel error
- client()->didFail(this, ResourceError());
-}
-
-void ResourceHandle::setHasReceivedResponse(bool b)
-{
- d->m_hasReceivedResponse = b;
-}
-
-bool ResourceHandle::hasReceivedResponse() const
-{
- return d->m_hasReceivedResponse;
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/network/win/ResourceHandleWin.h b/WebCore/platform/network/win/ResourceHandleWin.h
deleted file mode 100644
index 2964bcb..0000000
--- a/WebCore/platform/network/win/ResourceHandleWin.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ResourceHandleWin_h
-#define ResourceHandleWin_h
-
-#include <windows.h>
-
-namespace WebCore {
-
-struct PlatformDataStruct
-{
- DWORD error;
- BOOL loaded;
- LPTSTR errorString;
-};
-
-struct PlatformResponseStruct
-{
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/posix/FileSystemPOSIX.cpp b/WebCore/platform/posix/FileSystemPOSIX.cpp
deleted file mode 100644
index 82ae087..0000000
--- a/WebCore/platform/posix/FileSystemPOSIX.cpp
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FileSystem.h"
-
-#include "CString.h"
-#include "NotImplemented.h"
-#include "PlatformString.h"
-
-#include <sys/stat.h>
-#ifdef ANDROID_PLUGINS
-#include <sys/types.h>
-#include <dirent.h>
-#include <fnmatch.h>
-#endif
-#include <libgen.h>
-#include <unistd.h>
-
-namespace WebCore {
-
-bool fileExists(const String& path)
-{
- if (path.isNull())
- return false;
-
- CString fsRep = fileSystemRepresentation(path);
-
- if (!fsRep.data() || fsRep.data()[0] == '\0')
- return false;
-
- struct stat fileInfo;
-
- // stat(...) returns 0 on successful stat'ing of the file, and non-zero in any case where the file doesn't exist or cannot be accessed
- return !stat(fsRep.data(), &fileInfo);
-}
-
-bool deleteFile(const String& path)
-{
- CString fsRep = fileSystemRepresentation(path);
-
- if (!fsRep.data() || fsRep.data()[0] == '\0')
- return false;
-
- // unlink(...) returns 0 on successful deletion of the path and non-zero in any other case (including invalid permissions or non-existent file)
- return !unlink(fsRep.data());
-}
-
-bool deleteEmptyDirectory(const String& path)
-{
- CString fsRep = fileSystemRepresentation(path);
-
- if (!fsRep.data() || fsRep.data()[0] == '\0')
- return false;
-
- // rmdir(...) returns 0 on successful deletion of the path and non-zero in any other case (including invalid permissions or non-existent file)
- return !rmdir(fsRep.data());
-}
-
-bool getFileSize(const String& path, long long& result)
-{
- CString fsRep = fileSystemRepresentation(path);
-
- if (!fsRep.data() || fsRep.data()[0] == '\0')
- return false;
-
- struct stat fileInfo;
-
- if (stat(fsRep.data(), &fileInfo))
- return false;
-
- result = fileInfo.st_size;
- return true;
-}
-
-bool getFileModificationTime(const String& path, time_t& result)
-{
- CString fsRep = fileSystemRepresentation(path);
-
- if (!fsRep.data() || fsRep.data()[0] == '\0')
- return false;
-
- struct stat fileInfo;
-
- if (stat(fsRep.data(), &fileInfo))
- return false;
-
- result = fileInfo.st_mtime;
- return true;
-}
-
-String pathByAppendingComponent(const String& path, const String& component)
-{
- if (path.endsWith("/"))
- return path + component;
- else
- return path + "/" + component;
-}
-
-bool makeAllDirectories(const String& path)
-{
- CString fullPath = fileSystemRepresentation(path);
- if (!access(fullPath.data(), F_OK))
- return true;
-
- char* p = fullPath.mutableData() + 1;
- int length = fullPath.length();
-
- if(p[length - 1] == '/')
- p[length - 1] = '\0';
- for (; *p; ++p)
- if (*p == '/') {
- *p = '\0';
- if (access(fullPath.data(), F_OK))
- if (mkdir(fullPath.data(), S_IRWXU))
- return false;
- *p = '/';
- }
- if (access(fullPath.data(), F_OK))
- if (mkdir(fullPath.data(), S_IRWXU))
- return false;
-
- return true;
-}
-
-String pathGetFileName(const String& path)
-{
- return path.substring(path.reverseFind('/') + 1);
-}
-
-String directoryName(const String& path)
-{
- CString fsRep = fileSystemRepresentation(path);
-
- if (!fsRep.data() || fsRep.data()[0] == '\0')
- return String();
-
- return dirname(fsRep.mutableData());
-}
-
-Vector<String> listDirectory(const String& path, const String& filter)
-{
-#ifdef ANDROID_PLUGINS
- CString fsRepPath = fileSystemRepresentation(path);
- CString fsRepFilter = fileSystemRepresentation(filter);
-#endif
- Vector<String> entries;
-#ifdef ANDROID_PLUGINS
- DIR *dir = opendir(fsRepPath.data());
- if (dir == NULL)
- return entries;
- for (;;) {
- struct dirent *entry = readdir(dir);
- if (entry == NULL)
- break;
- if (!fnmatch(fsRepFilter.data(), entry->d_name, FNM_NOESCAPE)) {
- String fullPath = path + "/" + entry->d_name;
- entries.append(fullPath);
- }
- }
- closedir(dir);
-#else
- notImplemented();
-#endif
- return entries;
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/qt/ClipboardQt.cpp b/WebCore/platform/qt/ClipboardQt.cpp
deleted file mode 100644
index b0a1402..0000000
--- a/WebCore/platform/qt/ClipboardQt.cpp
+++ /dev/null
@@ -1,305 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ClipboardQt.h"
-
-#include "CachedImage.h"
-#include "CSSHelper.h"
-#include "Document.h"
-#include "Element.h"
-#include "Frame.h"
-#include "HTMLNames.h"
-#include "Image.h"
-#include "IntPoint.h"
-#include "KURL.h"
-#include "markup.h"
-#include "PlatformString.h"
-#include "Range.h"
-#include "RenderImage.h"
-#include "StringHash.h"
-#include <QList>
-#include <QMimeData>
-#include <QStringList>
-#include <QUrl>
-#include <QApplication>
-#include <QClipboard>
-#include <qdebug.h>
-
-#define methodDebug() qDebug("ClipboardQt: %s", __FUNCTION__)
-
-namespace WebCore {
-
-ClipboardQt::ClipboardQt(ClipboardAccessPolicy policy, const QMimeData* readableClipboard)
- : Clipboard(policy, true)
- , m_readableData(readableClipboard)
- , m_writableData(0)
-{
- Q_ASSERT(policy == ClipboardReadable || policy == ClipboardTypesReadable);
-}
-
-ClipboardQt::ClipboardQt(ClipboardAccessPolicy policy, bool forDragging)
- : Clipboard(policy, forDragging)
- , m_readableData(0)
- , m_writableData(0)
-{
- Q_ASSERT(policy == ClipboardReadable || policy == ClipboardWritable || policy == ClipboardNumb);
-
-#ifndef QT_NO_CLIPBOARD
- if (policy != ClipboardWritable) {
- Q_ASSERT(!forDragging);
- m_readableData = QApplication::clipboard()->mimeData();
- }
-#endif
-}
-
-ClipboardQt::~ClipboardQt()
-{
- if (m_writableData && !isForDragging())
- m_writableData = 0;
- else
- delete m_writableData;
- m_readableData = 0;
-}
-
-void ClipboardQt::clearData(const String& type)
-{
- if (policy() != ClipboardWritable)
- return;
-
- if (m_writableData) {
-#if QT_VERSION >= 0x040400
- m_writableData->removeFormat(type);
-#else
- const QString toClearType = type;
- QMap<QString, QByteArray> formats;
- foreach (QString format, m_writableData->formats()) {
- if (format != toClearType)
- formats[format] = m_writableData->data(format);
- }
-
- m_writableData->clear();
- QMap<QString, QByteArray>::const_iterator it, end = formats.constEnd();
- for (it = formats.begin(); it != end; ++it)
- m_writableData->setData(it.key(), it.value());
-#endif
- if (m_writableData->formats().isEmpty()) {
- if (isForDragging())
- delete m_writableData;
- m_writableData = 0;
- }
- }
-#ifndef QT_NO_CLIPBOARD
- if (!isForDragging())
- QApplication::clipboard()->setMimeData(m_writableData);
-#endif
-}
-
-void ClipboardQt::clearAllData()
-{
- if (policy() != ClipboardWritable)
- return;
-
-#ifndef QT_NO_CLIPBOARD
- if (!isForDragging())
- QApplication::clipboard()->setMimeData(0);
- else
-#endif
- delete m_writableData;
- m_writableData = 0;
-}
-
-String ClipboardQt::getData(const String& type, bool& success) const
-{
-
- if (policy() != ClipboardReadable) {
- success = false;
- return String();
- }
-
- ASSERT(m_readableData);
- QByteArray data = m_readableData->data(QString(type));
- success = !data.isEmpty();
- return String(data.data(), data.size());
-}
-
-bool ClipboardQt::setData(const String& type, const String& data)
-{
- if (policy() != ClipboardWritable)
- return false;
-
- if (!m_writableData)
- m_writableData = new QMimeData;
- QByteArray array(reinterpret_cast<const char*>(data.characters()),
- data.length()*2);
- m_writableData->setData(QString(type), array);
-#ifndef QT_NO_CLIPBOARD
- if (!isForDragging())
- QApplication::clipboard()->setMimeData(m_writableData);
-#endif
- return true;
-}
-
-// extensions beyond IE's API
-HashSet<String> ClipboardQt::types() const
-{
- if (policy() != ClipboardReadable && policy() != ClipboardTypesReadable)
- return HashSet<String>();
-
- ASSERT(m_readableData);
- HashSet<String> result;
- QStringList formats = m_readableData->formats();
- for (int i = 0; i < formats.count(); ++i)
- result.add(formats.at(i));
- return result;
-}
-
-void ClipboardQt::setDragImage(CachedImage* image, const IntPoint& point)
-{
- setDragImage(image, 0, point);
-}
-
-void ClipboardQt::setDragImageElement(Node* node, const IntPoint& point)
-{
- setDragImage(0, node, point);
-}
-
-void ClipboardQt::setDragImage(CachedImage* image, Node *node, const IntPoint &loc)
-{
- if (policy() != ClipboardImageWritable && policy() != ClipboardWritable)
- return;
-
- if (m_dragImage)
- m_dragImage->removeClient(this);
- m_dragImage = image;
- if (m_dragImage)
- m_dragImage->addClient(this);
-
- m_dragLoc = loc;
- m_dragImageElement = node;
-}
-
-DragImageRef ClipboardQt::createDragImage(IntPoint& dragLoc) const
-{
- if (!m_dragImage)
- return 0;
- dragLoc = m_dragLoc;
- return m_dragImage->image()->nativeImageForCurrentFrame();
-}
-
-
-static CachedImage* getCachedImage(Element* element)
-{
- // Attempt to pull CachedImage from element
- ASSERT(element);
- RenderObject* renderer = element->renderer();
- if (!renderer || !renderer->isImage())
- return 0;
-
- RenderImage* image = static_cast<RenderImage*>(renderer);
- if (image->cachedImage() && !image->cachedImage()->errorOccurred())
- return image->cachedImage();
-
- return 0;
-}
-
-void ClipboardQt::declareAndWriteDragImage(Element* element, const KURL& url, const String& title, Frame* frame)
-{
- ASSERT(frame);
- Q_UNUSED(url);
- Q_UNUSED(title);
-
- //WebCore::writeURL(m_writableDataObject.get(), url, title, true, false);
- if (!m_writableData)
- m_writableData = new QMimeData;
-
- CachedImage* cachedImage = getCachedImage(element);
- if (!cachedImage || !cachedImage->image() || !cachedImage->isLoaded())
- return;
- QPixmap *pixmap = cachedImage->image()->nativeImageForCurrentFrame();
- if (pixmap)
- m_writableData->setImageData(pixmap);
-
- AtomicString imageURL = element->getAttribute(HTMLNames::srcAttr);
- if (imageURL.isEmpty())
- return;
-
- KURL fullURL = frame->document()->completeURL(parseURL(imageURL));
- if (fullURL.isEmpty())
- return;
-
- QList<QUrl> urls;
- urls.append(fullURL);
-
- m_writableData->setUrls(urls);
-#ifndef QT_NO_CLIPBOARD
- if (!isForDragging())
- QApplication::clipboard()->setMimeData(m_writableData);
-#endif
-}
-
-void ClipboardQt::writeURL(const KURL& url, const String&, Frame* frame)
-{
- ASSERT(frame);
-
- QList<QUrl> urls;
- urls.append(frame->document()->completeURL(url.string()));
- if (!m_writableData)
- m_writableData = new QMimeData;
- m_writableData->setUrls(urls);
-#ifndef QT_NO_CLIPBOARD
- if (!isForDragging())
- QApplication::clipboard()->setMimeData(m_writableData);
-#endif
-}
-
-void ClipboardQt::writeRange(Range* range, Frame* frame)
-{
- ASSERT(range);
- ASSERT(frame);
-
- if (!m_writableData)
- m_writableData = new QMimeData;
- QString text = frame->selectedText();
- text.replace(QChar(0xa0), QLatin1Char(' '));
- m_writableData->setText(text);
- m_writableData->setHtml(createMarkup(range, 0, AnnotateForInterchange));
-#ifndef QT_NO_CLIPBOARD
- if (!isForDragging())
- QApplication::clipboard()->setMimeData(m_writableData);
-#endif
-}
-
-bool ClipboardQt::hasData()
-{
- const QMimeData *data = m_readableData ? m_readableData : m_writableData;
- if (!data)
- return false;
- return data->formats().count() > 0;
-}
-
-}
diff --git a/WebCore/platform/qt/ClipboardQt.h b/WebCore/platform/qt/ClipboardQt.h
deleted file mode 100644
index caf040f..0000000
--- a/WebCore/platform/qt/ClipboardQt.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ClipboardQt_h
-#define ClipboardQt_h
-
-#include "Clipboard.h"
-#include "CachedResourceClient.h"
-
-QT_BEGIN_NAMESPACE
-class QMimeData;
-QT_END_NAMESPACE
-
-namespace WebCore {
-
- class CachedImage;
-
- // State available during IE's events for drag and drop and copy/paste
- class ClipboardQt : public Clipboard, public CachedResourceClient {
- public:
- static PassRefPtr<ClipboardQt> create(ClipboardAccessPolicy policy, const QMimeData* readableClipboard)
- {
- return adoptRef(new ClipboardQt(policy, readableClipboard));
- }
- static PassRefPtr<ClipboardQt> create(ClipboardAccessPolicy policy, bool forDragging = false)
- {
- return adoptRef(new ClipboardQt(policy, forDragging));
- }
- virtual ~ClipboardQt();
-
- void clearData(const String& type);
- void clearAllData();
- String getData(const String& type, bool& success) const;
- bool setData(const String& type, const String& data);
-
- // extensions beyond IE's API
- HashSet<String> types() const;
-
- void setDragImage(CachedImage*, const IntPoint&);
- void setDragImageElement(Node*, const IntPoint&);
-
- virtual DragImageRef createDragImage(IntPoint& dragLoc) const;
- virtual void declareAndWriteDragImage(Element*, const KURL&, const String& title, Frame*);
- virtual void writeURL(const KURL&, const String&, Frame*);
- virtual void writeRange(Range*, Frame*);
-
- virtual bool hasData();
-
- QMimeData* clipboardData() const { return m_writableData; }
- void invalidateWritableData() { m_writableData = 0; }
-
- private:
- ClipboardQt(ClipboardAccessPolicy, const QMimeData* readableClipboard);
-
- // Clipboard is writable so it will create its own QMimeData object
- ClipboardQt(ClipboardAccessPolicy, bool forDragging);
-
- void setDragImage(CachedImage*, Node*, const IntPoint& loc);
-
- const QMimeData* m_readableData;
- QMimeData* m_writableData;
- };
-}
-
-#endif // ClipboardQt_h
diff --git a/WebCore/platform/qt/ContextMenuItemQt.cpp b/WebCore/platform/qt/ContextMenuItemQt.cpp
deleted file mode 100644
index c71eacd..0000000
--- a/WebCore/platform/qt/ContextMenuItemQt.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (C) 2006 Zack Rusin <zack@kde.org>
- * Copyright (C) 2007 Staikos Computing Services Inc. <info@staikos.net>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ContextMenuItem.h"
-#include "ContextMenu.h"
-
-namespace WebCore {
-
-ContextMenuItem::ContextMenuItem(ContextMenu* subMenu)
-{
- m_platformDescription.type = SubmenuType;
- m_platformDescription.action = ContextMenuItemTagNoAction;
- if (subMenu)
- setSubMenu(subMenu);
-}
-
-ContextMenuItem::ContextMenuItem(ContextMenuItemType type, ContextMenuAction action,
- const String& title, ContextMenu* subMenu)
-{
- m_platformDescription.type = type;
- m_platformDescription.action = action;
- m_platformDescription.title = title;
- if (subMenu)
- setSubMenu(subMenu);
-}
-
-ContextMenuItem::~ContextMenuItem()
-{
-}
-
-PlatformMenuItemDescription ContextMenuItem::releasePlatformDescription()
-{
- return m_platformDescription;
-}
-
-ContextMenuItemType ContextMenuItem::type() const
-{
- return m_platformDescription.type;
-}
-
-void ContextMenuItem::setType(ContextMenuItemType type)
-{
- m_platformDescription.type = type;
-}
-
-ContextMenuAction ContextMenuItem::action() const
-{
- return m_platformDescription.action;
-}
-
-void ContextMenuItem::setAction(ContextMenuAction action)
-{
- m_platformDescription.action = action;
-}
-
-String ContextMenuItem::title() const
-{
- return m_platformDescription.title;
-}
-
-void ContextMenuItem::setTitle(const String& title)
-{
- m_platformDescription.title = title;
-}
-
-
-PlatformMenuDescription ContextMenuItem::platformSubMenu() const
-{
- return &m_platformDescription.subMenuItems;
-}
-
-void ContextMenuItem::setSubMenu(ContextMenu* menu)
-{
- m_platformDescription.subMenuItems = *menu->platformDescription();
-}
-
-void ContextMenuItem::setChecked(bool on)
-{
- m_platformDescription.checked = on;
-}
-
-void ContextMenuItem::setEnabled(bool on)
-{
- m_platformDescription.enabled = on;
-}
-
-bool ContextMenuItem::enabled() const
-{
- return m_platformDescription.enabled;
-}
-
-}
-// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/qt/ContextMenuQt.cpp b/WebCore/platform/qt/ContextMenuQt.cpp
deleted file mode 100644
index 3e093b1..0000000
--- a/WebCore/platform/qt/ContextMenuQt.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2006 Zack Rusin <zack@kde.org>
- * Copyright (C) 2007 Staikos Computing Services Inc. <info@staikos.net>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ContextMenu.h"
-#include "MenuEventProxy.h"
-
-#include <wtf/Assertions.h>
-
-#include <QAction>
-
-#include <Document.h>
-#include <Frame.h>
-#include <FrameView.h>
-
-namespace WebCore {
-
-ContextMenu::ContextMenu(const HitTestResult& result)
- : m_hitTestResult(result)
-{
-}
-
-ContextMenu::~ContextMenu()
-{
-}
-
-void ContextMenu::appendItem(ContextMenuItem& item)
-{
- m_items.append(item);
-}
-
-unsigned ContextMenu::itemCount() const
-{
- return m_items.count();
-}
-
-void ContextMenu::insertItem(unsigned position, ContextMenuItem& item)
-{
- m_items.insert(position, item);
-}
-
-void ContextMenu::setPlatformDescription(PlatformMenuDescription menu)
-{
- // doesn't make sense
-}
-
-PlatformMenuDescription ContextMenu::platformDescription() const
-{
- return &m_items;
-}
-
-PlatformMenuDescription ContextMenu::releasePlatformDescription()
-{
- return PlatformMenuDescription();
-}
-
-
-}
-// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/qt/CookieJarQt.cpp b/WebCore/platform/qt/CookieJarQt.cpp
deleted file mode 100644
index 43be75a..0000000
--- a/WebCore/platform/qt/CookieJarQt.cpp
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright (C) 2006 George Staikos <staikos@kde.org>
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "CookieJar.h"
-
-#include "KURL.h"
-#include "PlatformString.h"
-
-#if QT_VERSION >= 0x040400
-#include "Document.h"
-#include "qwebpage.h"
-#include "qwebframe.h"
-#include "FrameLoaderClientQt.h"
-#include <QNetworkAccessManager>
-#include <QNetworkCookie>
-#else
-#include <qcookiejar.h>
-#endif
-
-namespace WebCore {
-
-#if QT_VERSION >= 0x040400
-static QNetworkCookieJar *cookieJar(const Document *document)
-{
- Frame *frame = document->frame();
- if (!frame)
- return 0;
- FrameLoader *loader = frame->loader();
- if (!loader)
- return 0;
- QWebFrame* webFrame = static_cast<FrameLoaderClientQt*>(loader->client())->webFrame();
- QWebPage* page = webFrame->page();
- QNetworkAccessManager* manager = page->networkAccessManager();
- QNetworkCookieJar* jar = manager->cookieJar();
- return jar;
-}
-#endif
-
-void setCookies(Document* document, const KURL& url, const KURL& policyURL, const String& value)
-{
- QUrl u(url);
- QUrl p(policyURL);
-#if QT_VERSION >= 0x040400
- QNetworkCookieJar* jar = cookieJar(document);
- if (!jar)
- return;
-
- QList<QNetworkCookie> cookies = QNetworkCookie::parseCookies(QString(value).toAscii());
- jar->setCookiesFromUrl(cookies, p);
-#else
- QCookieJar::cookieJar()->setCookies(u, p, (QString)value);
-#endif
-}
-
-String cookies(const Document* document, const KURL& url)
-{
- QUrl u(url);
-#if QT_VERSION >= 0x040400
- QNetworkCookieJar* jar = cookieJar(document);
- if (!jar)
- return String();
-
- QList<QNetworkCookie> cookies = jar->cookiesForUrl(u);
- if (cookies.isEmpty())
- return String();
-
- QStringList resultCookies;
- foreach (QNetworkCookie networkCookie, cookies)
- resultCookies.append(QString::fromAscii(
- networkCookie.toRawForm(QNetworkCookie::NameAndValueOnly).constData()));
-
- return resultCookies.join(QLatin1String("; "));
-#else
- QString cookies = QCookieJar::cookieJar()->cookies(u);
- int idx = cookies.indexOf(QLatin1Char(';'));
- if (idx > 0)
- cookies = cookies.left(idx);
- return cookies;
-#endif
-}
-
-bool cookiesEnabled(const Document* document)
-{
-#if QT_VERSION >= 0x040400
- QNetworkCookieJar* jar = cookieJar(document);
- return (jar != 0);
-#else
- return QCookieJar::cookieJar()->isEnabled();
-#endif
-}
-
-}
-
-// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/qt/CursorQt.cpp b/WebCore/platform/qt/CursorQt.cpp
deleted file mode 100644
index 0d7e100..0000000
--- a/WebCore/platform/qt/CursorQt.cpp
+++ /dev/null
@@ -1,372 +0,0 @@
-/*
- * Copyright (C) 2006 Dirk Mueller <mueller@kde.org>
- * Copyright (C) 2006 George Staikos <staikos@kde.org>
- * Copyright (C) 2006 Charles Samuels <charles@kde.org>
- * Copyright (C) 2008 Holger Hans Peter Freyther
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Cursor.h"
-
-#include "Image.h"
-#include "IntPoint.h"
-
-#include "NotImplemented.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#undef CopyCursor
-
-namespace WebCore {
-
-Cursor::Cursor(PlatformCursor p)
- : m_impl(p)
-{
-}
-
-Cursor::Cursor(const Cursor& other)
- : m_impl(other.m_impl)
-{
-}
-
-Cursor::~Cursor()
-{
-}
-
-Cursor::Cursor(Image* image, const IntPoint& hotspot)
-#ifndef QT_NO_CURSOR
- : m_impl(*(image->nativeImageForCurrentFrame()), hotspot.x(), hotspot.y())
-#endif
-{
-}
-
-Cursor& Cursor::operator=(const Cursor& other)
-{
- m_impl = other.m_impl;
- return *this;
-}
-
-namespace {
-
-// FIXME: static deleter
-class Cursors {
-protected:
- Cursors()
-#ifndef QT_NO_CURSOR
- : CrossCursor(Qt::CrossCursor)
- , MoveCursor(Qt::SizeAllCursor)
- , PointerCursor(Qt::ArrowCursor)
- , PointingHandCursor(Qt::PointingHandCursor)
- , IBeamCursor(Qt::IBeamCursor)
- , WaitCursor(Qt::WaitCursor)
- , WhatsThisCursor(Qt::WhatsThisCursor)
- , SizeHorCursor(Qt::SizeHorCursor)
- , SizeVerCursor(Qt::SizeVerCursor)
- , SizeFDiagCursor(Qt::SizeFDiagCursor)
- , SizeBDiagCursor(Qt::SizeBDiagCursor)
- , SplitHCursor(Qt::SplitHCursor)
- , SplitVCursor(Qt::SplitVCursor)
- , NoDropCursor(Qt::ForbiddenCursor)
- , BlankCursor(Qt::BlankCursor)
- , ZoomInCursor(QPixmap(QLatin1String(":/webkit/resources/zoomInCursor.png")))
- , ZoomOutCursor(QPixmap(QLatin1String(":/webkit/resources/zoomOutCursor.png")))
- , VerticalTextCursor(QPixmap(QLatin1String(":/webkit/resources/verticalTextCursor.png")))
- , CellCursor(QPixmap(QLatin1String(":/webkit/resources/cellCursor.png")))
- , ContextMenuCursor(QPixmap(QLatin1String(":/webkit/resources/contextMenuCursor.png")))
- , CopyCursor(QPixmap(QLatin1String(":/webkit/resources/copyCursor.png")))
- , ProgressCursor(QPixmap(QLatin1String(":/webkit/resources/progressCursor.png")))
- , AliasCursor(QPixmap(QLatin1String(":/webkit/resources/aliasCursor.png")))
-
-#endif
- {
- }
-
- ~Cursors()
- {
- }
-
-public:
- static Cursors* self();
- static Cursors* s_self;
-
- Cursor CrossCursor;
- Cursor MoveCursor;
- Cursor PointerCursor;
- Cursor PointingHandCursor;
- Cursor IBeamCursor;
- Cursor WaitCursor;
- Cursor WhatsThisCursor;
- Cursor SizeHorCursor;
- Cursor SizeVerCursor;
- Cursor SizeFDiagCursor;
- Cursor SizeBDiagCursor;
- Cursor SplitHCursor;
- Cursor SplitVCursor;
- Cursor NoDropCursor;
- Cursor BlankCursor;
- Cursor ZoomInCursor;
- Cursor ZoomOutCursor;
- Cursor VerticalTextCursor;
- Cursor CellCursor;
- Cursor ContextMenuCursor;
- Cursor CopyCursor;
- Cursor ProgressCursor;
- Cursor AliasCursor;
-};
-
-Cursors* Cursors::s_self = 0;
-
-Cursors* Cursors::self()
-{
- if (!s_self)
- s_self = new Cursors();
-
- return s_self;
-}
-
-}
-
-const Cursor& pointerCursor()
-{
- return Cursors::self()->PointerCursor;
-}
-
-const Cursor& moveCursor()
-{
- return Cursors::self()->MoveCursor;
-}
-
-const Cursor& crossCursor()
-{
- return Cursors::self()->CrossCursor;
-}
-
-const Cursor& handCursor()
-{
- return Cursors::self()->PointingHandCursor;
-}
-
-const Cursor& iBeamCursor()
-{
- return Cursors::self()->IBeamCursor;
-}
-
-const Cursor& waitCursor()
-{
- return Cursors::self()->WaitCursor;
-}
-
-const Cursor& helpCursor()
-{
- return Cursors::self()->WhatsThisCursor;
-}
-
-const Cursor& eastResizeCursor()
-{
- return Cursors::self()->SizeHorCursor;
-}
-
-const Cursor& northResizeCursor()
-{
- return Cursors::self()->SizeVerCursor;
-}
-
-const Cursor& northEastResizeCursor()
-{
- return Cursors::self()->SizeBDiagCursor;
-}
-
-const Cursor& northWestResizeCursor()
-{
- return Cursors::self()->SizeFDiagCursor;
-}
-
-const Cursor& southResizeCursor()
-{
- return Cursors::self()->SizeVerCursor;
-}
-
-const Cursor& southEastResizeCursor()
-{
- return Cursors::self()->SizeFDiagCursor;
-}
-
-const Cursor& southWestResizeCursor()
-{
- return Cursors::self()->SizeBDiagCursor;
-}
-
-const Cursor& westResizeCursor()
-{
- return Cursors::self()->SizeHorCursor;
-}
-
-const Cursor& northSouthResizeCursor()
-{
- return Cursors::self()->SizeVerCursor;
-}
-
-const Cursor& eastWestResizeCursor()
-{
- return Cursors::self()->SizeHorCursor;
-}
-
-const Cursor& northEastSouthWestResizeCursor()
-{
- return Cursors::self()->SizeBDiagCursor;
-}
-
-const Cursor& northWestSouthEastResizeCursor()
-{
- return Cursors::self()->SizeFDiagCursor;
-}
-
-const Cursor& columnResizeCursor()
-{
- return Cursors::self()->SplitHCursor;
-}
-
-const Cursor& rowResizeCursor()
-{
- return Cursors::self()->SplitVCursor;
-}
-
-const Cursor& middlePanningCursor()
-{
- return moveCursor();
-}
-
-const Cursor& eastPanningCursor()
-{
- return eastResizeCursor();
-}
-
-const Cursor& northPanningCursor()
-{
- return northResizeCursor();
-}
-
-const Cursor& northEastPanningCursor()
-{
- return northEastResizeCursor();
-}
-
-const Cursor& northWestPanningCursor()
-{
- return northWestResizeCursor();
-}
-
-const Cursor& southPanningCursor()
-{
- return southResizeCursor();
-}
-
-const Cursor& southEastPanningCursor()
-{
- return southEastResizeCursor();
-}
-
-const Cursor& southWestPanningCursor()
-{
- return southWestResizeCursor();
-}
-
-const Cursor& westPanningCursor()
-{
- return westResizeCursor();
-}
-
-const Cursor& verticalTextCursor()
-{
- return Cursors::self()->VerticalTextCursor;
-}
-
-const Cursor& cellCursor()
-{
- return Cursors::self()->CellCursor;
-}
-
-const Cursor& contextMenuCursor()
-{
- return Cursors::self()->ContextMenuCursor;
-}
-
-const Cursor& noDropCursor()
-{
- return Cursors::self()->NoDropCursor;
-}
-
-const Cursor& copyCursor()
-{
- return Cursors::self()->CopyCursor;
-}
-
-const Cursor& progressCursor()
-{
- return Cursors::self()->ProgressCursor;
-}
-
-const Cursor& aliasCursor()
-{
- return Cursors::self()->AliasCursor;
-}
-
-const Cursor& noneCursor()
-{
- return Cursors::self()->BlankCursor;
-}
-
-const Cursor& notAllowedCursor()
-{
- return Cursors::self()->NoDropCursor;
-}
-
-const Cursor& zoomInCursor()
-{
- return Cursors::self()->ZoomInCursor;
-}
-
-const Cursor& zoomOutCursor()
-{
- return Cursors::self()->ZoomOutCursor;
-}
-
-const Cursor& grabCursor()
-{
- notImplemented();
- return Cursors::self()->PointerCursor;
-}
-
-const Cursor& grabbingCursor()
-{
- notImplemented();
- return Cursors::self()->PointerCursor;
-}
-
-}
-
-// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/qt/DragDataQt.cpp b/WebCore/platform/qt/DragDataQt.cpp
deleted file mode 100644
index 9d95373..0000000
--- a/WebCore/platform/qt/DragDataQt.cpp
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "DragData.h"
-
-#include "ClipboardQt.h"
-#include "Document.h"
-#include "DocumentFragment.h"
-#include "markup.h"
-#include "NotImplemented.h"
-
-#include <QList>
-#include <QMimeData>
-#include <QUrl>
-#include <QColor>
-
-namespace WebCore {
-
-bool DragData::canSmartReplace() const
-{
- return false;
-}
-
-bool DragData::containsColor() const
-{
- if (!m_platformDragData)
- return false;
- return m_platformDragData->hasColor();
-}
-
-bool DragData::containsFiles() const
-{
- if (!m_platformDragData)
- return false;
- QList<QUrl> urls = m_platformDragData->urls();
- foreach(const QUrl &url, urls) {
- if (!url.toLocalFile().isEmpty())
- return true;
- }
- return false;
-}
-
-void DragData::asFilenames(Vector<String>& result) const
-{
- if (!m_platformDragData)
- return;
- QList<QUrl> urls = m_platformDragData->urls();
- foreach(const QUrl &url, urls) {
- QString file = url.toLocalFile();
- if (!file.isEmpty())
- result.append(file);
- }
-}
-
-bool DragData::containsPlainText() const
-{
- if (!m_platformDragData)
- return false;
- return m_platformDragData->hasText() || m_platformDragData->hasUrls();
-}
-
-String DragData::asPlainText() const
-{
- if (!m_platformDragData)
- return String();
- String text = m_platformDragData->text();
- if (!text.isEmpty())
- return text;
-
- // FIXME: Should handle rich text here
-
- return asURL(0);
-}
-
-Color DragData::asColor() const
-{
- if (!m_platformDragData)
- return Color();
- return qvariant_cast<QColor>(m_platformDragData->colorData());
-}
-
-PassRefPtr<Clipboard> DragData::createClipboard(ClipboardAccessPolicy policy) const
-{
- return ClipboardQt::create(policy, m_platformDragData);
-}
-
-bool DragData::containsCompatibleContent() const
-{
- if (!m_platformDragData)
- return false;
- return containsColor() || containsURL() || m_platformDragData->hasHtml() || m_platformDragData->hasText();
-}
-
-bool DragData::containsURL() const
-{
- if (!m_platformDragData)
- return false;
- return m_platformDragData->hasUrls();
-}
-
-String DragData::asURL(String* title) const
-{
- if (!m_platformDragData)
- return String();
- QList<QUrl> urls = m_platformDragData->urls();
- return urls.first().toString();
-}
-
-
-PassRefPtr<DocumentFragment> DragData::asFragment(Document* doc) const
-{
- if (m_platformDragData && m_platformDragData->hasHtml())
- return createFragmentFromMarkup(doc, m_platformDragData->html(), "");
-
- return 0;
-}
-
-}
-
diff --git a/WebCore/platform/qt/DragImageQt.cpp b/WebCore/platform/qt/DragImageQt.cpp
deleted file mode 100644
index c9cdd8d..0000000
--- a/WebCore/platform/qt/DragImageQt.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "DragImage.h"
-
-#include "CachedImage.h"
-#include "Image.h"
-
-namespace WebCore {
-
-IntSize dragImageSize(DragImageRef)
-{
- return IntSize(0, 0);
-}
-
-void deleteDragImage(DragImageRef)
-{
-}
-
-DragImageRef scaleDragImage(DragImageRef image, FloatSize)
-{
- return image;
-}
-
-DragImageRef dissolveDragImageToFraction(DragImageRef image, float)
-{
- return image;
-}
-
-DragImageRef createDragImageFromImage(Image*)
-{
- return 0;
-}
-
-DragImageRef createDragImageIconForCachedImage(CachedImage*)
-{
- return 0;
-}
-
-}
diff --git a/WebCore/platform/qt/EventLoopQt.cpp b/WebCore/platform/qt/EventLoopQt.cpp
deleted file mode 100644
index 39bb54c..0000000
--- a/WebCore/platform/qt/EventLoopQt.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include "config.h"
-#include "EventLoop.h"
-
-#include <QCoreApplication>
-
-namespace WebCore {
-
-void EventLoop::cycle()
-{
- QCoreApplication::processEvents();
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/qt/FileChooserQt.cpp b/WebCore/platform/qt/FileChooserQt.cpp
deleted file mode 100644
index b468dbe..0000000
--- a/WebCore/platform/qt/FileChooserQt.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "FileChooser.h"
-
-#include "Font.h"
-#include <QFontMetrics>
-
-namespace WebCore {
-
-String FileChooser::basenameForWidth(const Font& f, int width) const
-{
- QFontMetrics fm(f.font());
- return fm.elidedText(m_filenames[0], Qt::ElideLeft, width);
-}
-
-}
-
-// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/qt/FileSystemQt.cpp b/WebCore/platform/qt/FileSystemQt.cpp
deleted file mode 100644
index 6b56070..0000000
--- a/WebCore/platform/qt/FileSystemQt.cpp
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Copyright (C) 2007 Staikos Computing Services Inc.
- * Copyright (C) 2007 Holger Hans Peter Freyther
- * Copyright (C) 2008 Apple, Inc. All rights reserved.
- * Copyright (C) 2008 Collabora, Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FileSystem.h"
-
-#include "CString.h"
-#include "NotImplemented.h"
-#include "PlatformString.h"
-
-#include <QDateTime>
-#include <QFile>
-#include <QTemporaryFile>
-#include <QFileInfo>
-#include <QDateTime>
-#include <QDir>
-
-namespace WebCore {
-
-bool fileExists(const String& path)
-{
- return QFile::exists(path);
-}
-
-
-bool deleteFile(const String& path)
-{
- return QFile::remove(path);
-}
-
-bool deleteEmptyDirectory(const String& path)
-{
- return QDir::root().rmdir(path);
-}
-
-bool getFileSize(const String& path, long long& result)
-{
- QFileInfo info(path);
- result = info.size();
- return info.exists();
-}
-
-bool getFileModificationTime(const String& path, time_t& result)
-{
- QFileInfo info(path);
- result = info.lastModified().toTime_t();
- return info.exists();
-}
-
-bool makeAllDirectories(const String& path)
-{
- return QDir::root().mkpath(path);
-}
-
-String pathByAppendingComponent(const String& path, const String& component)
-{
- return QDir(path).filePath(component);
-}
-
-String homeDirectoryPath()
-{
- return QDir::homePath();
-}
-
-String pathGetFileName(const String& path)
-{
- return QFileInfo(path).fileName();
-}
-
-String directoryName(const String& path)
-{
- return String(QFileInfo(path).baseName());
-}
-
-Vector<String> listDirectory(const String& path, const String& filter)
-{
- Vector<String> entries;
-
- QStringList nameFilters;
- if (!filter.isEmpty())
- nameFilters.append(filter);
- QFileInfoList fileInfoList = QDir(path).entryInfoList(nameFilters, QDir::AllEntries | QDir::NoDotAndDotDot);
- foreach (const QFileInfo fileInfo, fileInfoList) {
- String entry = String(fileInfo.canonicalFilePath());
- entries.append(entry);
- }
-
- return entries;
-}
-
-CString openTemporaryFile(const char* prefix, PlatformFileHandle& handle)
-{
- QFile *temp = new QTemporaryFile(QString(prefix));
- if (temp->open(QIODevice::ReadWrite)) {
- handle = temp;
- return String(temp->fileName()).utf8();
- }
- handle = invalidPlatformFileHandle;
- return 0;
-}
-
-void closeFile(PlatformFileHandle& handle)
-{
- if (handle) {
- handle->close();
- delete handle;
- }
-}
-
-int writeToFile(PlatformFileHandle handle, const char* data, int length)
-{
- if (handle && handle->exists() && handle->isWritable())
- return handle->write(data, length);
-
- return 0;
-}
-
-#if defined(Q_WS_X11) || defined(Q_WS_QWS)
-bool unloadModule(PlatformModule module)
-{
- if (module->unload()) {
- delete module;
- return true;
- }
-
- return false;
-}
-#endif
-
-#if defined(Q_WS_MAC)
-bool unloadModule(PlatformModule module)
-{
- CFRelease(module);
- return true;
-}
-#endif
-
-#if defined(Q_OS_WIN32)
-bool unloadModule(PlatformModule module)
-{
- return ::FreeLibrary(module);
-}
-#endif
-
-}
-
-// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/qt/KURLQt.cpp b/WebCore/platform/qt/KURLQt.cpp
deleted file mode 100644
index cdc4f48..0000000
--- a/WebCore/platform/qt/KURLQt.cpp
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-#include "config.h"
-#include "KURL.h"
-#include "CString.h"
-
-#include "NotImplemented.h"
-#include "qurl.h"
-
-namespace WebCore {
-
-#if QT_VERSION < 0x040500
-static const char hexnumbers[] = "0123456789ABCDEF";
-static inline char toHex(char c)
-{
- return hexnumbers[c & 0xf];
-}
-#endif
-
-KURL::KURL(const QUrl& url)
-{
- *this = KURL(url.toEncoded().constData());
-}
-
-KURL::operator QUrl() const
-{
-#if QT_VERSION < 0x040500
- unsigned length = m_string.length();
-
- QByteArray ba;
- ba.reserve(length);
-
- int path = -1;
- int host = m_string.find("://");
- if (host != -1) {
- host += 3;
-
- path = m_string.find('/', host);
- }
-
- for (unsigned i = 0; i < length; ++i) {
- const char chr = static_cast<char>(m_string[i]);
-
- switch (chr) {
- encode:
- case '{':
- case '}':
- case '|':
- case '\\':
- case '^':
- case '`':
- ba.append('%');
- ba.append(toHex((chr & 0xf0) >> 4));
- ba.append(toHex(chr & 0xf));
- break;
- case '[':
- case ']':
- // special case: if this is the host part, don't encode
- // otherwise, encode
- if (host == -1 || (path != -1 && i >= path))
- goto encode;
- // fall through
- default:
- ba.append(chr);
- break;
- }
- }
-#else
- // Qt 4.5 or later
- // No need for special encoding
- QByteArray ba = m_string.utf8().data();
-#endif
-
- QUrl url = QUrl::fromEncoded(ba);
- return url;
-}
-
-String KURL::fileSystemPath() const
-{
- notImplemented();
- return String();
-}
-
-}
-
diff --git a/WebCore/platform/qt/KeyboardCodes.h b/WebCore/platform/qt/KeyboardCodes.h
deleted file mode 100644
index 21d3c67..0000000
--- a/WebCore/platform/qt/KeyboardCodes.h
+++ /dev/null
@@ -1,553 +0,0 @@
-/*
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef KeyboardCodes_h
-#define KeyboardCodes_h
-
-#include <wtf/Platform.h>
-
-namespace WebCore {
-
-#if !PLATFORM(WIN_OS)
-// VK_LBUTTON (01) Left mouse button
-// VK_RBUTTON (02) Right mouse button
-// VK_CANCEL (03) Control-break processing
-// VK_MBUTTON (04) Middle mouse button (three-button mouse)
-// VK_XBUTTON1 (05)
-// VK_XBUTTON2 (06)
-
-// VK_BACK (08) BACKSPACE key
-const int VK_BACK = 0x08;
-
-// VK_TAB (09) TAB key
-const int VK_TAB = 0x09;
-
-// VK_CLEAR (0C) CLEAR key
-const int VK_CLEAR = 0x0C;
-
-// VK_RETURN (0D)
-const int VK_RETURN = 0x0D;
-
-// VK_SHIFT (10) SHIFT key
-const int VK_SHIFT = 0x10;
-
-// VK_CONTROL (11) CTRL key
-const int VK_CONTROL = 0x11;
-
-// VK_MENU (12) ALT key
-const int VK_MENU = 0x12;
-
-// VK_PAUSE (13) PAUSE key
-const int VK_PAUSE = 0x13;
-
-// VK_CAPITAL (14) CAPS LOCK key
-const int VK_CAPITAL = 0x14;
-
-// VK_KANA (15) Input Method Editor (IME) Kana mode
-const int VK_KANA = 0x15;
-
-// VK_HANGUEL (15) IME Hanguel mode (maintained for compatibility; use VK_HANGUL)
-// VK_HANGUL (15) IME Hangul mode
-const int VK_HANGUL = 0x15;
-
-// VK_JUNJA (17) IME Junja mode
-const int VK_JUNJA = 0x17;
-
-// VK_FINAL (18) IME final mode
-const int VK_FINAL = 0x18;
-
-// VK_HANJA (19) IME Hanja mode
-const int VK_HANJA = 0x19;
-
-// VK_KANJI (19) IME Kanji mode
-const int VK_KANJI = 0x19;
-
-// VK_ESCAPE (1B) ESC key
-const int VK_ESCAPE = 0x1B;
-
-// VK_CONVERT (1C) IME convert
-const int VK_CONVERT = 0x1C;
-
-// VK_NONCONVERT (1D) IME nonconvert
-const int VK_NONCONVERT = 0x1D;
-
-// VK_ACCEPT (1E) IME accept
-const int VK_ACCEPT = 0x1E;
-
-// VK_MODECHANGE (1F) IME mode change request
-const int VK_MODECHANGE = 0x1F;
-
-// VK_SPACE (20) SPACEBAR
-const int VK_SPACE = 0x20;
-
-// VK_PRIOR (21) PAGE UP key
-const int VK_PRIOR = 0x21;
-
-// VK_NEXT (22) PAGE DOWN key
-const int VK_NEXT = 0x22;
-
-// VK_END (23) END key
-const int VK_END = 0x23;
-
-// VK_HOME (24) HOME key
-const int VK_HOME = 0x24;
-
-// VK_LEFT (25) LEFT ARROW key
-const int VK_LEFT = 0x25;
-
-// VK_UP (26) UP ARROW key
-const int VK_UP = 0x26;
-
-// VK_RIGHT (27) RIGHT ARROW key
-const int VK_RIGHT = 0x27;
-
-// VK_DOWN (28) DOWN ARROW key
-const int VK_DOWN = 0x28;
-
-// VK_SELECT (29) SELECT key
-const int VK_SELECT = 0x29;
-
-// VK_PRINT (2A) PRINT key
-const int VK_PRINT = 0x2A;
-
-// VK_EXECUTE (2B) EXECUTE key
-const int VK_EXECUTE = 0x2B;
-
-// VK_SNAPSHOT (2C) PRINT SCREEN key
-const int VK_SNAPSHOT = 0x2C;
-
-// VK_INSERT (2D) INS key
-const int VK_INSERT = 0x2D;
-
-// VK_DELETE (2E) DEL key
-const int VK_DELETE = 0x2E;
-
-// VK_HELP (2F) HELP key
-const int VK_HELP = 0x2F;
-
-#endif // PLATFORM(WIN_OS)
-
-// (30) 0 key
-const int VK_0 = 0x30;
-
-// (31) 1 key
-const int VK_1 = 0x31;
-
-// (32) 2 key
-const int VK_2 = 0x32;
-
-// (33) 3 key
-const int VK_3 = 0x33;
-
-// (34) 4 key
-const int VK_4 = 0x34;
-
-// (35) 5 key;
-
-const int VK_5 = 0x35;
-
-// (36) 6 key
-const int VK_6 = 0x36;
-
-// (37) 7 key
-const int VK_7 = 0x37;
-
-// (38) 8 key
-const int VK_8 = 0x38;
-
-// (39) 9 key
-const int VK_9 = 0x39;
-
-// (41) A key
-const int VK_A = 0x41;
-
-// (42) B key
-const int VK_B = 0x42;
-
-// (43) C key
-const int VK_C = 0x43;
-
-// (44) D key
-const int VK_D = 0x44;
-
-// (45) E key
-const int VK_E = 0x45;
-
-// (46) F key
-const int VK_F = 0x46;
-
-// (47) G key
-const int VK_G = 0x47;
-
-// (48) H key
-const int VK_H = 0x48;
-
-// (49) I key
-const int VK_I = 0x49;
-
-// (4A) J key
-const int VK_J = 0x4A;
-
-// (4B) K key
-const int VK_K = 0x4B;
-
-// (4C) L key
-const int VK_L = 0x4C;
-
-// (4D) M key
-const int VK_M = 0x4D;
-
-// (4E) N key
-const int VK_N = 0x4E;
-
-// (4F) O key
-const int VK_O = 0x4F;
-
-// (50) P key
-const int VK_P = 0x50;
-
-// (51) Q key
-const int VK_Q = 0x51;
-
-// (52) R key
-const int VK_R = 0x52;
-
-// (53) S key
-const int VK_S = 0x53;
-
-// (54) T key
-const int VK_T = 0x54;
-
-// (55) U key
-const int VK_U = 0x55;
-
-// (56) V key
-const int VK_V = 0x56;
-
-// (57) W key
-const int VK_W = 0x57;
-
-// (58) X key
-const int VK_X = 0x58;
-
-// (59) Y key
-const int VK_Y = 0x59;
-
-// (5A) Z key
-const int VK_Z = 0x5A;
-
-#if !PLATFORM(WIN_OS)
-
-// VK_LWIN (5B) Left Windows key (Microsoft Natural keyboard)
-const int VK_LWIN = 0x5B;
-
-// VK_RWIN (5C) Right Windows key (Natural keyboard)
-const int VK_RWIN = 0x5C;
-
-// VK_APPS (5D) Applications key (Natural keyboard)
-const int VK_APPS = 0x5D;
-
-// VK_SLEEP (5F) Computer Sleep key
-const int VK_SLEEP = 0x5F;
-
-// VK_NUMPAD0 (60) Numeric keypad 0 key
-const int VK_NUMPAD0 = 0x60;
-
-// VK_NUMPAD1 (61) Numeric keypad 1 key
-const int VK_NUMPAD1 = 0x61;
-
-// VK_NUMPAD2 (62) Numeric keypad 2 key
-const int VK_NUMPAD2 = 0x62;
-
-// VK_NUMPAD3 (63) Numeric keypad 3 key
-const int VK_NUMPAD3 = 0x63;
-
-// VK_NUMPAD4 (64) Numeric keypad 4 key
-const int VK_NUMPAD4 = 0x64;
-
-// VK_NUMPAD5 (65) Numeric keypad 5 key
-const int VK_NUMPAD5 = 0x65;
-
-// VK_NUMPAD6 (66) Numeric keypad 6 key
-const int VK_NUMPAD6 = 0x66;
-
-// VK_NUMPAD7 (67) Numeric keypad 7 key
-const int VK_NUMPAD7 = 0x67;
-
-// VK_NUMPAD8 (68) Numeric keypad 8 key
-const int VK_NUMPAD8 = 0x68;
-
-// VK_NUMPAD9 (69) Numeric keypad 9 key
-const int VK_NUMPAD9 = 0x69;
-
-// VK_MULTIPLY (6A) Multiply key
-const int VK_MULTIPLY = 0x6A;
-
-// VK_ADD (6B) Add key
-const int VK_ADD = 0x6B;
-
-// VK_SEPARATOR (6C) Separator key
-const int VK_SEPARATOR = 0x6C;
-
-// VK_SUBTRACT (6D) Subtract key
-const int VK_SUBTRACT = 0x6D;
-
-// VK_DECIMAL (6E) Decimal key
-const int VK_DECIMAL = 0x6E;
-
-// VK_DIVIDE (6F) Divide key
-const int VK_DIVIDE = 0x6F;
-
-// VK_F1 (70) F1 key
-const int VK_F1 = 0x70;
-
-// VK_F2 (71) F2 key
-const int VK_F2 = 0x71;
-
-// VK_F3 (72) F3 key
-const int VK_F3 = 0x72;
-
-// VK_F4 (73) F4 key
-const int VK_F4 = 0x73;
-
-// VK_F5 (74) F5 key
-const int VK_F5 = 0x74;
-
-// VK_F6 (75) F6 key
-const int VK_F6 = 0x75;
-
-// VK_F7 (76) F7 key
-const int VK_F7 = 0x76;
-
-// VK_F8 (77) F8 key
-const int VK_F8 = 0x77;
-
-// VK_F9 (78) F9 key
-const int VK_F9 = 0x78;
-
-// VK_F10 (79) F10 key
-const int VK_F10 = 0x79;
-
-// VK_F11 (7A) F11 key
-const int VK_F11 = 0x7A;
-
-// VK_F12 (7B) F12 key
-const int VK_F12 = 0x7B;
-
-// VK_F13 (7C) F13 key
-const int VK_F13 = 0x7C;
-
-// VK_F14 (7D) F14 key
-const int VK_F14 = 0x7D;
-
-// VK_F15 (7E) F15 key
-const int VK_F15 = 0x7E;
-
-// VK_F16 (7F) F16 key
-const int VK_F16 = 0x7F;
-
-// VK_F17 (80H) F17 key
-const int VK_F17 = 0x80;
-
-// VK_F18 (81H) F18 key
-const int VK_F18 = 0x81;
-
-// VK_F19 (82H) F19 key
-const int VK_F19 = 0x82;
-
-// VK_F20 (83H) F20 key
-const int VK_F20 = 0x83;
-
-// VK_F21 (84H) F21 key
-const int VK_F21 = 0x84;
-
-// VK_F22 (85H) F22 key
-const int VK_F22 = 0x85;
-
-// VK_F23 (86H) F23 key
-const int VK_F23 = 0x86;
-
-// VK_F24 (87H) F24 key
-const int VK_F24 = 0x87;
-
-// VK_NUMLOCK (90) NUM LOCK key
-const int VK_NUMLOCK = 0x90;
-
-// VK_SCROLL (91) SCROLL LOCK key
-const int VK_SCROLL = 0x91;
-
-// VK_LSHIFT (A0) Left SHIFT key
-const int VK_LSHIFT = 0xA0;
-
-// VK_RSHIFT (A1) Right SHIFT key
-const int VK_RSHIFT = 0xA1;
-
-// VK_LCONTROL (A2) Left CONTROL key
-const int VK_LCONTROL = 0xA2;
-
-// VK_RCONTROL (A3) Right CONTROL key
-const int VK_RCONTROL = 0xA3;
-
-// VK_LMENU (A4) Left MENU key
-const int VK_LMENU = 0xA4;
-
-// VK_RMENU (A5) Right MENU key
-const int VK_RMENU = 0xA5;
-
-// VK_BROWSER_BACK (A6) Windows 2000/XP: Browser Back key
-const int VK_BROWSER_BACK = 0xA6;
-
-// VK_BROWSER_FORWARD (A7) Windows 2000/XP: Browser Forward key
-const int VK_BROWSER_FORWARD = 0xA7;
-
-// VK_BROWSER_REFRESH (A8) Windows 2000/XP: Browser Refresh key
-const int VK_BROWSER_REFRESH = 0xA8;
-
-// VK_BROWSER_STOP (A9) Windows 2000/XP: Browser Stop key
-const int VK_BROWSER_STOP = 0xA9;
-
-// VK_BROWSER_SEARCH (AA) Windows 2000/XP: Browser Search key
-const int VK_BROWSER_SEARCH = 0xAA;
-
-// VK_BROWSER_FAVORITES (AB) Windows 2000/XP: Browser Favorites key
-const int VK_BROWSER_FAVORITES = 0xAB;
-
-// VK_BROWSER_HOME (AC) Windows 2000/XP: Browser Start and Home key
-const int VK_BROWSER_HOME = 0xAC;
-
-// VK_VOLUME_MUTE (AD) Windows 2000/XP: Volume Mute key
-const int VK_VOLUME_MUTE = 0xAD;
-
-// VK_VOLUME_DOWN (AE) Windows 2000/XP: Volume Down key
-const int VK_VOLUME_DOWN = 0xAE;
-
-// VK_VOLUME_UP (AF) Windows 2000/XP: Volume Up key
-const int VK_VOLUME_UP = 0xAF;
-
-// VK_MEDIA_NEXT_TRACK (B0) Windows 2000/XP: Next Track key
-const int VK_MEDIA_NEXT_TRACK = 0xB0;
-
-// VK_MEDIA_PREV_TRACK (B1) Windows 2000/XP: Previous Track key
-const int VK_MEDIA_PREV_TRACK = 0xB1;
-
-// VK_MEDIA_STOP (B2) Windows 2000/XP: Stop Media key
-const int VK_MEDIA_STOP = 0xB2;
-
-// VK_MEDIA_PLAY_PAUSE (B3) Windows 2000/XP: Play/Pause Media key
-const int VK_MEDIA_PLAY_PAUSE = 0xB3;
-
-// VK_LAUNCH_MAIL (B4) Windows 2000/XP: Start Mail key
-const int VK_MEDIA_LAUNCH_MAIL = 0xB4;
-
-// VK_LAUNCH_MEDIA_SELECT (B5) Windows 2000/XP: Select Media key
-const int VK_MEDIA_LAUNCH_MEDIA_SELECT = 0xB5;
-
-// VK_LAUNCH_APP1 (B6) Windows 2000/XP: Start Application 1 key
-const int VK_MEDIA_LAUNCH_APP1 = 0xB6;
-
-// VK_LAUNCH_APP2 (B7) Windows 2000/XP: Start Application 2 key
-const int VK_MEDIA_LAUNCH_APP2 = 0xB7;
-
-// VK_OEM_1 (BA) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ';:' key
-const int VK_OEM_1 = 0xBA;
-
-// VK_OEM_PLUS (BB) Windows 2000/XP: For any country/region, the '+' key
-const int VK_OEM_PLUS = 0xBB;
-
-// VK_OEM_COMMA (BC) Windows 2000/XP: For any country/region, the ',' key
-const int VK_OEM_COMMA = 0xBC;
-
-// VK_OEM_MINUS (BD) Windows 2000/XP: For any country/region, the '-' key
-const int VK_OEM_MINUS = 0xBD;
-
-// VK_OEM_PERIOD (BE) Windows 2000/XP: For any country/region, the '.' key
-const int VK_OEM_PERIOD = 0xBE;
-
-// VK_OEM_2 (BF) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '/?' key
-const int VK_OEM_2 = 0xBF;
-
-// VK_OEM_3 (C0) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '`~' key
-const int VK_OEM_3 = 0xC0;
-
-// VK_OEM_4 (DB) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '[{' key
-const int VK_OEM_4 = 0xDB;
-
-// VK_OEM_5 (DC) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '\|' key
-const int VK_OEM_5 = 0xDC;
-
-// VK_OEM_6 (DD) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ']}' key
-const int VK_OEM_6 = 0xDD;
-
-// VK_OEM_7 (DE) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the 'single-quote/double-quote' key
-const int VK_OEM_7 = 0xDE;
-
-// VK_OEM_8 (DF) Used for miscellaneous characters; it can vary by keyboard.
-const int VK_OEM_8 = 0xDF;
-
-// VK_OEM_102 (E2) Windows 2000/XP: Either the angle bracket key or the backslash key on the RT 102-key keyboard
-const int VK_OEM_102 = 0xE2;
-
-// VK_PROCESSKEY (E5) Windows 95/98/Me, Windows NT 4.0, Windows 2000/XP: IME PROCESS key
-const int VK_PROCESSKEY = 0xE5;
-
-// VK_PACKET (E7) Windows 2000/XP: Used to pass Unicode characters as if they were keystrokes. The VK_PACKET key is the low word of a 32-bit Virtual Key value used for non-keyboard input methods. For more information, see Remark in KEYBDINPUT,SendInput, WM_KEYDOWN, and WM_KEYUP
-const int VK_PACKET = 0xE7;
-
-// VK_ATTN (F6) Attn key
-const int VK_ATTN = 0xF6;
-
-// VK_CRSEL (F7) CrSel key
-const int VK_CRSEL = 0xF7;
-
-// VK_EXSEL (F8) ExSel key
-const int VK_EXSEL = 0xF8;
-
-// VK_EREOF (F9) Erase EOF key
-const int VK_EREOF = 0xF9;
-
-// VK_PLAY (FA) Play key
-const int VK_PLAY = 0xFA;
-
-// VK_ZOOM (FB) Zoom key
-const int VK_ZOOM = 0xFB;
-
-// VK_NONAME (FC) Reserved for future use
-const int VK_NONAME = 0xFC;
-
-// VK_PA1 (FD) PA1 key
-const int VK_PA1 = 0xFD;
-
-// VK_OEM_CLEAR (FE) Clear key
-const int VK_OEM_CLEAR = 0xFE;
-
-const int VK_UNKNOWN = 0;
-
-#endif // PLATFORM(WIN_OS)
-
-}
-
-#endif
diff --git a/WebCore/platform/qt/Localizations.cpp b/WebCore/platform/qt/Localizations.cpp
deleted file mode 100644
index b49b880..0000000
--- a/WebCore/platform/qt/Localizations.cpp
+++ /dev/null
@@ -1,352 +0,0 @@
-/*
- * Copyright (C) 2007 Staikos Computing Services Inc. <info@staikos.net>
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "IntSize.h"
-#include "LocalizedStrings.h"
-#include "NotImplemented.h"
-#include "PlatformString.h"
-
-#include <QCoreApplication>
-
-namespace WebCore {
-
-String submitButtonDefaultLabel()
-{
- return QCoreApplication::translate("QWebPage", "Submit", "default label for Submit buttons in forms on web pages");
-}
-
-String inputElementAltText()
-{
- return QCoreApplication::translate("QWebPage", "Submit", "Submit (input element) alt text for <input> elements with no alt, title, or value");
-}
-
-String resetButtonDefaultLabel()
-{
- return QCoreApplication::translate("QWebPage", "Reset", "default label for Reset buttons in forms on web pages");
-}
-
-String defaultLanguage()
-{
- return "en";
-}
-
-String searchableIndexIntroduction()
-{
- return QCoreApplication::translate("QWebPage", "This is a searchable index. Enter search keywords: ", "text that appears at the start of nearly-obsolete web pages in the form of a 'searchable index'");
-}
-
-String fileButtonChooseFileLabel()
-{
- return QCoreApplication::translate("QWebPage", "Choose File", "title for file button used in HTML forms");
-}
-
-String fileButtonNoFileSelectedLabel()
-{
- return QCoreApplication::translate("QWebPage", "No file selected", "text to display in file button used in HTML forms when no file is selected");
-}
-
-String contextMenuItemTagOpenLinkInNewWindow()
-{
- return QCoreApplication::translate("QWebPage", "Open in New Window", "Open in New Window context menu item");
-}
-
-String contextMenuItemTagDownloadLinkToDisk()
-{
- return QCoreApplication::translate("QWebPage", "Save Link...", "Download Linked File context menu item");
-}
-
-String contextMenuItemTagCopyLinkToClipboard()
-{
- return QCoreApplication::translate("QWebPage", "Copy Link", "Copy Link context menu item");
-}
-
-String contextMenuItemTagOpenImageInNewWindow()
-{
- return QCoreApplication::translate("QWebPage", "Open Image", "Open Image in New Window context menu item");
-}
-
-String contextMenuItemTagDownloadImageToDisk()
-{
- return QCoreApplication::translate("QWebPage", "Save Image", "Download Image context menu item");
-}
-
-String contextMenuItemTagCopyImageToClipboard()
-{
- return QCoreApplication::translate("QWebPage", "Copy Image", "Copy Link context menu item");
-}
-
-String contextMenuItemTagOpenFrameInNewWindow()
-{
- return QCoreApplication::translate("QWebPage", "Open Frame", "Open Frame in New Window context menu item");
-}
-
-String contextMenuItemTagCopy()
-{
- return QCoreApplication::translate("QWebPage", "Copy", "Copy context menu item");
-}
-
-String contextMenuItemTagGoBack()
-{
- return QCoreApplication::translate("QWebPage", "Go Back", "Back context menu item");
-}
-
-String contextMenuItemTagGoForward()
-{
- return QCoreApplication::translate("QWebPage", "Go Forward", "Forward context menu item");
-}
-
-String contextMenuItemTagStop()
-{
- return QCoreApplication::translate("QWebPage", "Stop", "Stop context menu item");
-}
-
-String contextMenuItemTagReload()
-{
- return QCoreApplication::translate("QWebPage", "Reload", "Reload context menu item");
-}
-
-String contextMenuItemTagCut()
-{
- return QCoreApplication::translate("QWebPage", "Cut", "Cut context menu item");
-}
-
-String contextMenuItemTagPaste()
-{
- return QCoreApplication::translate("QWebPage", "Paste", "Paste context menu item");
-}
-
-String contextMenuItemTagNoGuessesFound()
-{
- return QCoreApplication::translate("QWebPage", "No Guesses Found", "No Guesses Found context menu item");
-}
-
-String contextMenuItemTagIgnoreSpelling()
-{
- return QCoreApplication::translate("QWebPage", "Ignore", "Ignore Spelling context menu item");
-}
-
-String contextMenuItemTagLearnSpelling()
-{
- return QCoreApplication::translate("QWebPage", "Add To Dictionary", "Learn Spelling context menu item");
-}
-
-String contextMenuItemTagSearchWeb()
-{
- return QCoreApplication::translate("QWebPage", "Search The Web", "Search The Web context menu item");
-}
-
-String contextMenuItemTagLookUpInDictionary()
-{
- return QCoreApplication::translate("QWebPage", "Look Up In Dictionary", "Look Up in Dictionary context menu item");
-}
-
-String contextMenuItemTagOpenLink()
-{
- return QCoreApplication::translate("QWebPage", "Open Link", "Open Link context menu item");
-}
-
-String contextMenuItemTagIgnoreGrammar()
-{
- return QCoreApplication::translate("QWebPage", "Ignore", "Ignore Grammar context menu item");
-}
-
-String contextMenuItemTagSpellingMenu()
-{
- return QCoreApplication::translate("QWebPage", "Spelling", "Spelling and Grammar context sub-menu item");
-}
-
-String contextMenuItemTagShowSpellingPanel(bool show)
-{
- return show ? QCoreApplication::translate("QWebPage", "Show Spelling and Grammar", "menu item title") :
- QCoreApplication::translate("QWebPage", "Hide Spelling and Grammar", "menu item title");
-}
-
-String contextMenuItemTagCheckSpelling()
-{
- return QCoreApplication::translate("QWebPage", "Check Spelling", "Check spelling context menu item");
-}
-
-String contextMenuItemTagCheckSpellingWhileTyping()
-{
- return QCoreApplication::translate("QWebPage", "Check Spelling While Typing", "Check spelling while typing context menu item");
-}
-
-String contextMenuItemTagCheckGrammarWithSpelling()
-{
- return QCoreApplication::translate("QWebPage", "Check Grammar With Spelling", "Check grammar with spelling context menu item");
-}
-
-String contextMenuItemTagFontMenu()
-{
- return QCoreApplication::translate("QWebPage", "Fonts", "Font context sub-menu item");
-}
-
-String contextMenuItemTagBold()
-{
- return QCoreApplication::translate("QWebPage", "Bold", "Bold context menu item");
-}
-
-String contextMenuItemTagItalic()
-{
- return QCoreApplication::translate("QWebPage", "Italic", "Italic context menu item");
-}
-
-String contextMenuItemTagUnderline()
-{
- return QCoreApplication::translate("QWebPage", "Underline", "Underline context menu item");
-}
-
-String contextMenuItemTagOutline()
-{
- return QCoreApplication::translate("QWebPage", "Outline", "Outline context menu item");
-}
-
-String contextMenuItemTagWritingDirectionMenu()
-{
- return QCoreApplication::translate("QWebPage", "Direction", "Writing direction context sub-menu item");
-}
-
-String contextMenuItemTagDefaultDirection()
-{
- return QCoreApplication::translate("QWebPage", "Default", "Default writing direction context menu item");
-}
-
-String contextMenuItemTagLeftToRight()
-{
- return QCoreApplication::translate("QWebPage", "LTR", "Left to Right context menu item");
-}
-
-String contextMenuItemTagRightToLeft()
-{
- return QCoreApplication::translate("QWebPage", "RTL", "Right to Left context menu item");
-}
-
-String contextMenuItemTagInspectElement()
-{
- return QCoreApplication::translate("QWebPage", "Inspect", "Inspect Element context menu item");
-}
-
-String searchMenuNoRecentSearchesText()
-{
- return QCoreApplication::translate("QWebPage", "No recent searches", "Label for only item in menu that appears when clicking on the search field image, when no searches have been performed");
-}
-
-String searchMenuRecentSearchesText()
-{
- return QCoreApplication::translate("QWebPage", "Recent searches", "label for first item in the menu that appears when clicking on the search field image, used as embedded menu title");
-}
-
-String searchMenuClearRecentSearchesText()
-{
- return QCoreApplication::translate("QWebPage", "Clear recent searches", "menu item in Recent Searches menu that empties menu's contents");
-}
-
-String AXWebAreaText()
-{
- return String();
-}
-
-String AXLinkText()
-{
- return String();
-}
-
-String AXListMarkerText()
-{
- return String();
-}
-
-String AXImageMapText()
-{
- return String();
-}
-
-String AXHeadingText()
-{
- return String();
-}
-
-String AXDefinitionListTermText()
-{
- return String();
-}
-
-String AXDefinitionListDefinitionText()
-{
- return String();
-}
-
-String AXButtonActionVerb()
-{
- return String();
-}
-
-String AXRadioButtonActionVerb()
-{
- return String();
-}
-
-String AXTextFieldActionVerb()
-{
- return String();
-}
-
-String AXCheckedCheckBoxActionVerb()
-{
- return String();
-}
-
-String AXUncheckedCheckBoxActionVerb()
-{
- return String();
-}
-
-String AXLinkActionVerb()
-{
- return String();
-}
-
-String multipleFileUploadText(unsigned)
-{
- return String();
-}
-
-String unknownFileSizeText()
-{
- return QCoreApplication::translate("QWebPage", "Unknown", "Unknown filesize FTP directory listing item");
-}
-
-String imageTitle(const String& filename, const IntSize& size)
-{
- return QCoreApplication::translate("QWebPage", "%1 (%2x%3 pixels)", "Title string for images").arg(filename).arg(size.width()).arg(size.height());
-}
-
-}
-// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/qt/LoggingQt.cpp b/WebCore/platform/qt/LoggingQt.cpp
deleted file mode 100644
index 5f6720a..0000000
--- a/WebCore/platform/qt/LoggingQt.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include "config.h"
-#include "Logging.h"
-
-#include <QDebug>
-#include <QStringList>
-
-namespace WebCore {
-
-#if !defined(NDEBUG)
-static WTFLogChannel* getChannelFromName(const QString& channelName)
-{
- if (!channelName.length() >= 2)
- return 0;
-
- if (channelName == QLatin1String("BackForward")) return &LogBackForward;
- if (channelName == QLatin1String("Editing")) return &LogEditing;
- if (channelName == QLatin1String("Events")) return &LogEvents;
- if (channelName == QLatin1String("Frames")) return &LogFrames;
- if (channelName == QLatin1String("FTP")) return &LogFTP;
- if (channelName == QLatin1String("History")) return &LogHistory;
- if (channelName == QLatin1String("IconDatabase")) return &LogIconDatabase;
- if (channelName == QLatin1String("Loading")) return &LogLoading;
- if (channelName == QLatin1String("Media")) return &LogMedia;
- if (channelName == QLatin1String("Network")) return &LogNetwork;
- if (channelName == QLatin1String("NotYetImplemented")) return &LogNotYetImplemented;
- if (channelName == QLatin1String("PageCache")) return &LogPageCache;
- if (channelName == QLatin1String("PlatformLeaks")) return &LogPlatformLeaks;
- if (channelName == QLatin1String("Plugin")) return &LogPlugin;
- if (channelName == QLatin1String("PopupBlocking")) return &LogPopupBlocking;
- if (channelName == QLatin1String("SpellingAndGrammar")) return &LogSpellingAndGrammar;
- if (channelName == QLatin1String("SQLDatabase")) return &LogSQLDatabase;
- if (channelName == QLatin1String("StorageAPI")) return &LogStorageAPI;
- if (channelName == QLatin1String("TextConversion")) return &LogTextConversion;
- if (channelName == QLatin1String("Threading")) return &LogThreading;
-
- return 0;
-}
-#endif
-
-void InitializeLoggingChannelsIfNecessary()
-{
- static bool haveInitializedLoggingChannels = false;
- if (haveInitializedLoggingChannels)
- return;
-
- haveInitializedLoggingChannels = true;
-
- QString loggingEnv = qgetenv("QT_WEBKIT_LOG");
- if (loggingEnv.isEmpty())
- return;
-
-#if defined(NDEBUG)
- qWarning("This is a release build. Setting QT_WEBKIT_LOG will have no effect.");
-#else
- QStringList channels = loggingEnv.split(",");
- QStringListIterator iter(channels);
-
- while (iter.hasNext()) {
- QString channelName = iter.next();
- WTFLogChannel* channel = getChannelFromName(channelName);
- if (!channel) continue;
- channel->state = WTFLogChannelOn;
- }
-
- // By default we log calls to notImplemented(). This can be turned
- // off by setting the environment variable DISABLE_NI_WARNING to 1
- LogNotYetImplemented.state = WTFLogChannelOn;
-#endif
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/qt/MIMETypeRegistryQt.cpp b/WebCore/platform/qt/MIMETypeRegistryQt.cpp
deleted file mode 100644
index 9f4a786..0000000
--- a/WebCore/platform/qt/MIMETypeRegistryQt.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2006 Zack Rusin <zack@kde.org>
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "MIMETypeRegistry.h"
-
-namespace WebCore {
-
-struct ExtensionMap {
- const char* extension;
- const char* mimeType;
-};
-
-static const ExtensionMap extensionMap [] = {
- { "bmp", "image/bmp" },
- { "css", "text/css" },
- { "gif", "image/gif" },
- { "html", "text/html" },
- { "htm", "text/html" },
- { "ico", "image/x-icon" },
- { "jpeg", "image/jpeg" },
- { "jpg", "image/jpeg" },
- { "js", "application/x-javascript" },
- { "mng", "video/x-mng" },
- { "pbm", "image/x-portable-bitmap" },
- { "pgm", "image/x-portable-graymap" },
- { "pdf", "application/pdf" },
- { "png", "image/png" },
- { "ppm", "image/x-portable-pixmap" },
- { "rss", "application/rss+xml" },
- { "svg", "image/svg+xml" },
- { "text", "text/plain" },
- { "tif", "image/tiff" },
- { "tiff", "image/tiff" },
- { "txt", "text/plain" },
- { "xbm", "image/x-xbitmap" },
- { "xml", "text/xml" },
- { "xpm", "image/x-xpm" },
- { "xsl", "text/xsl" },
- { "xhtml", "application/xhtml+xml" },
- { 0, 0 }
-};
-
-String MIMETypeRegistry::getMIMETypeForExtension(const String &ext)
-{
- String s = ext.lower();
-
- const ExtensionMap *e = extensionMap;
- while (e->extension) {
- if (s == e->extension)
- return e->mimeType;
- ++e;
- }
-
- return "application/octet-stream";
-}
-
-}
diff --git a/WebCore/platform/qt/MenuEventProxy.h b/WebCore/platform/qt/MenuEventProxy.h
deleted file mode 100644
index 658d1ee..0000000
--- a/WebCore/platform/qt/MenuEventProxy.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2007 Staikos Computing Services Inc. <info@staikos.net>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-
-#ifndef MENUEVENTPROXY_H
-#define MENUEVENTPROXY_H
-
-#include "Platform.h"
-#include <qobject.h>
-#include <qmap.h>
-#include "ContextMenu.h"
-#include "ContextMenuItem.h"
-#include "ContextMenuController.h"
-
-namespace WebCore {
-class MenuEventProxy : public QObject {
- Q_OBJECT
- public:
- MenuEventProxy(WebCore::ContextMenu *m) : m_m(m) {}
- ~MenuEventProxy() {}
-
- void map(QAction* action, unsigned actionTag) { _map[action] = actionTag; }
-
- public slots:
- void trigger(QAction *action) {
- WebCore::ContextMenuItem item(WebCore::ActionType, static_cast<WebCore::ContextMenuAction>(_map[action]), WebCore::String());
- m_m->controller()->contextMenuItemSelected(&item);
- }
-
- private:
- WebCore::ContextMenu *m_m;
- QMap<QAction*, unsigned> _map;
-};
-
-}
-
-#endif
-// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/qt/PasteboardQt.cpp b/WebCore/platform/qt/PasteboardQt.cpp
deleted file mode 100644
index b535a74..0000000
--- a/WebCore/platform/qt/PasteboardQt.cpp
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Copyright (C) 2006 Zack Rusin <zack@kde.org>
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Pasteboard.h"
-
-#include "DocumentFragment.h"
-#include "Editor.h"
-#include "Frame.h"
-#include "Image.h"
-#include "markup.h"
-#include "RenderImage.h"
-
-#include <qdebug.h>
-#include <qclipboard.h>
-#include <qmimedata.h>
-#include <qapplication.h>
-#include <qurl.h>
-
-#define methodDebug() qDebug() << "PasteboardQt: " << __FUNCTION__;
-
-namespace WebCore {
-
-Pasteboard::Pasteboard()
- : m_selectionMode(false)
-{
-}
-
-Pasteboard* Pasteboard::generalPasteboard()
-{
- static Pasteboard* pasteboard = 0;
- if (!pasteboard)
- pasteboard = new Pasteboard();
- return pasteboard;
-}
-
-void Pasteboard::writeSelection(Range* selectedRange, bool, Frame* frame)
-{
- QMimeData* md = new QMimeData;
- QString text = frame->selectedText();
- text.replace(QChar(0xa0), QLatin1Char(' '));
- md->setText(text);
-
- QString html = QLatin1String("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /></head><body>");
- html += createMarkup(selectedRange, 0, AnnotateForInterchange);
- html += QLatin1String("</body></html>");
- md->setHtml(html);
-
-#ifndef QT_NO_CLIPBOARD
- QApplication::clipboard()->setMimeData(md, m_selectionMode ?
- QClipboard::Selection : QClipboard::Clipboard);
-#endif
-}
-
-bool Pasteboard::canSmartReplace()
-{
- return false;
-}
-
-String Pasteboard::plainText(Frame*)
-{
-#ifndef QT_NO_CLIPBOARD
- return QApplication::clipboard()->text(m_selectionMode ?
- QClipboard::Selection : QClipboard::Clipboard);
-#else
- return String();
-#endif
-}
-
-PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefPtr<Range> context,
- bool allowPlainText, bool& chosePlainText)
-{
-#ifndef QT_NO_CLIPBOARD
- const QMimeData* mimeData = QApplication::clipboard()->mimeData(
- m_selectionMode ? QClipboard::Selection : QClipboard::Clipboard);
-
- chosePlainText = false;
-
- if (mimeData->hasHtml()) {
- QString html = mimeData->html();
- if (!html.isEmpty()) {
- RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(frame->document(), html, "");
- if (fragment)
- return fragment.release();
- }
- }
-
- if (allowPlainText && mimeData->hasText()) {
- chosePlainText = true;
- RefPtr<DocumentFragment> fragment = createFragmentFromText(context.get(), mimeData->text());
- if (fragment)
- return fragment.release();
- }
-#endif
- return 0;
-}
-
-void Pasteboard::writeURL(const KURL& _url, const String&, Frame*)
-{
- ASSERT(!_url.isEmpty());
-
-#ifndef QT_NO_CLIPBOARD
- QMimeData* md = new QMimeData;
- QString url = _url.string();
- md->setText(url);
- md->setUrls(QList<QUrl>() << QUrl(url));
- QApplication::clipboard()->setMimeData(md, m_selectionMode ?
- QClipboard::Selection : QClipboard::Clipboard);
-#endif
-}
-
-void Pasteboard::writeImage(Node* node, const KURL&, const String&)
-{
- ASSERT(node && node->renderer() && node->renderer()->isImage());
-
-#ifndef QT_NO_CLIPBOARD
- CachedImage* cachedImage = static_cast<RenderImage*>(node->renderer())->cachedImage();
- ASSERT(cachedImage);
-
- Image* image = cachedImage->image();
- ASSERT(image);
-
- QPixmap* pixmap = image->nativeImageForCurrentFrame();
- ASSERT(pixmap);
-
- QApplication::clipboard()->setPixmap(*pixmap, QClipboard::Clipboard);
-#endif
-}
-
-/* This function is called from Editor::tryDHTMLCopy before actually set the clipboard
- * It introduce a race condition with klipper, which will try to grab the clipboard
- * It's not required to clear it anyway, since QClipboard take care about replacing the clipboard
- */
-void Pasteboard::clear()
-{
-}
-
-bool Pasteboard::isSelectionMode() const
-{
- return m_selectionMode;
-}
-
-void Pasteboard::setSelectionMode(bool selectionMode)
-{
- m_selectionMode = selectionMode;
-}
-
-}
diff --git a/WebCore/platform/qt/PlatformKeyboardEventQt.cpp b/WebCore/platform/qt/PlatformKeyboardEventQt.cpp
deleted file mode 100644
index 76342ab..0000000
--- a/WebCore/platform/qt/PlatformKeyboardEventQt.cpp
+++ /dev/null
@@ -1,478 +0,0 @@
-/*
- * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "PlatformKeyboardEvent.h"
-
-#include "KeyboardCodes.h"
-#include "NotImplemented.h"
-
-#include <ctype.h>
-
-#include <QKeyEvent>
-
-namespace WebCore {
-
-static String keyIdentifierForQtKeyCode(int keyCode)
-{
- switch (keyCode) {
- case Qt::Key_Menu:
- case Qt::Key_Alt:
- return "Alt";
- case Qt::Key_Clear:
- return "Clear";
- case Qt::Key_Down:
- return "Down";
- case Qt::Key_End:
- return "End";
- case Qt::Key_Return:
- case Qt::Key_Enter:
- return "Enter";
-#if QT_VERSION >= 0x040200
- case Qt::Key_Execute:
- return "Execute";
-#endif
- case Qt::Key_F1:
- return "F1";
- case Qt::Key_F2:
- return "F2";
- case Qt::Key_F3:
- return "F3";
- case Qt::Key_F4:
- return "F4";
- case Qt::Key_F5:
- return "F5";
- case Qt::Key_F6:
- return "F6";
- case Qt::Key_F7:
- return "F7";
- case Qt::Key_F8:
- return "F8";
- case Qt::Key_F9:
- return "F9";
- case Qt::Key_F10:
- return "F10";
- case Qt::Key_F11:
- return "F11";
- case Qt::Key_F12:
- return "F12";
- case Qt::Key_F13:
- return "F13";
- case Qt::Key_F14:
- return "F14";
- case Qt::Key_F15:
- return "F15";
- case Qt::Key_F16:
- return "F16";
- case Qt::Key_F17:
- return "F17";
- case Qt::Key_F18:
- return "F18";
- case Qt::Key_F19:
- return "F19";
- case Qt::Key_F20:
- return "F20";
- case Qt::Key_F21:
- return "F21";
- case Qt::Key_F22:
- return "F22";
- case Qt::Key_F23:
- return "F23";
- case Qt::Key_F24:
- return "F24";
- case Qt::Key_Help:
- return "Help";
- case Qt::Key_Home:
- return "Home";
- case Qt::Key_Insert:
- return "Insert";
- case Qt::Key_Left:
- return "Left";
- case Qt::Key_PageDown:
- return "PageDown";
- case Qt::Key_PageUp:
- return "PageUp";
- case Qt::Key_Pause:
- return "Pause";
- case Qt::Key_Print:
- return "PrintScreen";
- case Qt::Key_Right:
- return "Right";
- case Qt::Key_Select:
- return "Select";
- case Qt::Key_Up:
- return "Up";
- // Standard says that DEL becomes U+007F.
- case Qt::Key_Delete:
- return "U+007F";
- case Qt::Key_Tab:
- return "U+0009";
- case Qt::Key_Backtab:
- return "U+0009";
- default:
- return String::format("U+%04X", toupper(keyCode));
- }
-}
-
-static int windowsKeyCodeForKeyEvent(unsigned int keycode)
-{
- switch (keycode) {
- /* FIXME: Need to supply a bool in this func, to determine wheter the event comes from the keypad
- case Qt::Key_0:
- return VK_NUMPAD0;// (60) Numeric keypad 0 key
- case Qt::Key_1:
- return VK_NUMPAD1;// (61) Numeric keypad 1 key
- case Qt::Key_2:
- return VK_NUMPAD2; // (62) Numeric keypad 2 key
- case Qt::Key_3:
- return VK_NUMPAD3; // (63) Numeric keypad 3 key
- case Qt::Key_4:
- return VK_NUMPAD4; // (64) Numeric keypad 4 key
- case Qt::Key_5:
- return VK_NUMPAD5; //(65) Numeric keypad 5 key
- case Qt::Key_6:
- return VK_NUMPAD6; // (66) Numeric keypad 6 key
- case Qt::Key_7:
- return VK_NUMPAD7; // (67) Numeric keypad 7 key
- case Qt::Key_8:
- return VK_NUMPAD8; // (68) Numeric keypad 8 key
- case Qt::Key_9:
- return VK_NUMPAD9; // (69) Numeric keypad 9 key
- case Qt::Key_Asterisk:
- return VK_MULTIPLY; // (6A) Multiply key
- case Qt::Key_Plus:
- return VK_ADD; // (6B) Add key
- case Qt::Key_Minus:
- return VK_SUBTRACT; // (6D) Subtract key
- case Qt::Key_Period:
- return VK_DECIMAL; // (6E) Decimal key
- case Qt::Key_Slash:
- return VK_DIVIDE; // (6F) Divide key
-
- */
- case Qt::Key_Backspace:
- return VK_BACK; // (08) BACKSPACE key
- case Qt::Key_Backtab:
- case Qt::Key_Tab:
- return VK_TAB; // (09) TAB key
- case Qt::Key_Clear:
- return VK_CLEAR; // (0C) CLEAR key
- case Qt::Key_Enter:
- case Qt::Key_Return:
- return VK_RETURN; //(0D) Return key
- case Qt::Key_Shift:
- return VK_SHIFT; // (10) SHIFT key
- case Qt::Key_Control:
- return VK_CONTROL; // (11) CTRL key
- case Qt::Key_Menu:
- case Qt::Key_Alt:
- return VK_MENU; // (12) ALT key
-
- case Qt::Key_Pause:
- return VK_PAUSE; // (13) PAUSE key
- case Qt::Key_CapsLock:
- return VK_CAPITAL; // (14) CAPS LOCK key
- case Qt::Key_Kana_Lock:
- case Qt::Key_Kana_Shift:
- return VK_KANA; // (15) Input Method Editor (IME) Kana mode
- case Qt::Key_Hangul:
- return VK_HANGUL; // VK_HANGUL (15) IME Hangul mode
- // VK_JUNJA (17) IME Junja mode
- // VK_FINAL (18) IME final mode
- case Qt::Key_Hangul_Hanja:
- return VK_HANJA; // (19) IME Hanja mode
- case Qt::Key_Kanji:
- return VK_KANJI; // (19) IME Kanji mode
- case Qt::Key_Escape:
- return VK_ESCAPE; // (1B) ESC key
- // VK_CONVERT (1C) IME convert
- // VK_NONCONVERT (1D) IME nonconvert
- // VK_ACCEPT (1E) IME accept
- // VK_MODECHANGE (1F) IME mode change request
- case Qt::Key_Space:
- return VK_SPACE; // (20) SPACEBAR
- case Qt::Key_PageUp:
- return VK_PRIOR; // (21) PAGE UP key
- case Qt::Key_PageDown:
- return VK_NEXT; // (22) PAGE DOWN key
- case Qt::Key_End:
- return VK_END; // (23) END key
- case Qt::Key_Home:
- return VK_HOME; // (24) HOME key
- case Qt::Key_Left:
- return VK_LEFT; // (25) LEFT ARROW key
- case Qt::Key_Up:
- return VK_UP; // (26) UP ARROW key
- case Qt::Key_Right:
- return VK_RIGHT; // (27) RIGHT ARROW key
- case Qt::Key_Down:
- return VK_DOWN; // (28) DOWN ARROW key
- case Qt::Key_Select:
- return VK_SELECT; // (29) SELECT key
- case Qt::Key_Print:
- return VK_PRINT; // (2A) PRINT key
-#if QT_VERSION >= 0x040200
- case Qt::Key_Execute:
- return VK_EXECUTE;// (2B) EXECUTE key
-#endif
- //dunno on this
- //case Qt::Key_PrintScreen:
- // return VK_SNAPSHOT; // (2C) PRINT SCREEN key
- case Qt::Key_Insert:
- return VK_INSERT; // (2D) INS key
- case Qt::Key_Delete:
- return VK_DELETE; // (2E) DEL key
- case Qt::Key_Help:
- return VK_HELP; // (2F) HELP key
- case Qt::Key_0:
- case Qt::Key_ParenLeft:
- return VK_0; // (30) 0) key
- case Qt::Key_1:
- return VK_1; // (31) 1 ! key
- case Qt::Key_2:
- case Qt::Key_At:
- return VK_2; // (32) 2 & key
- case Qt::Key_3:
- case Qt::Key_NumberSign:
- return VK_3; //case '3': case '#';
- case Qt::Key_4:
- case Qt::Key_Dollar: // (34) 4 key '$';
- return VK_4;
- case Qt::Key_5:
- case Qt::Key_Percent:
- return VK_5; // (35) 5 key '%'
- case Qt::Key_6:
- case Qt::Key_AsciiCircum:
- return VK_6; // (36) 6 key '^'
- case Qt::Key_7:
- case Qt::Key_Ampersand:
- return VK_7; // (37) 7 key case '&'
- case Qt::Key_8:
- case Qt::Key_Asterisk:
- return VK_8; // (38) 8 key '*'
- case Qt::Key_9:
- case Qt::Key_ParenRight:
- return VK_9; // (39) 9 key '('
- case Qt::Key_A:
- return VK_A; // (41) A key case 'a': case 'A': return 0x41;
- case Qt::Key_B:
- return VK_B; // (42) B key case 'b': case 'B': return 0x42;
- case Qt::Key_C:
- return VK_C; // (43) C key case 'c': case 'C': return 0x43;
- case Qt::Key_D:
- return VK_D; // (44) D key case 'd': case 'D': return 0x44;
- case Qt::Key_E:
- return VK_E; // (45) E key case 'e': case 'E': return 0x45;
- case Qt::Key_F:
- return VK_F; // (46) F key case 'f': case 'F': return 0x46;
- case Qt::Key_G:
- return VK_G; // (47) G key case 'g': case 'G': return 0x47;
- case Qt::Key_H:
- return VK_H; // (48) H key case 'h': case 'H': return 0x48;
- case Qt::Key_I:
- return VK_I; // (49) I key case 'i': case 'I': return 0x49;
- case Qt::Key_J:
- return VK_J; // (4A) J key case 'j': case 'J': return 0x4A;
- case Qt::Key_K:
- return VK_K; // (4B) K key case 'k': case 'K': return 0x4B;
- case Qt::Key_L:
- return VK_L; // (4C) L key case 'l': case 'L': return 0x4C;
- case Qt::Key_M:
- return VK_M; // (4D) M key case 'm': case 'M': return 0x4D;
- case Qt::Key_N:
- return VK_N; // (4E) N key case 'n': case 'N': return 0x4E;
- case Qt::Key_O:
- return VK_O; // (4F) O key case 'o': case 'O': return 0x4F;
- case Qt::Key_P:
- return VK_P; // (50) P key case 'p': case 'P': return 0x50;
- case Qt::Key_Q:
- return VK_Q; // (51) Q key case 'q': case 'Q': return 0x51;
- case Qt::Key_R:
- return VK_R; // (52) R key case 'r': case 'R': return 0x52;
- case Qt::Key_S:
- return VK_S; // (53) S key case 's': case 'S': return 0x53;
- case Qt::Key_T:
- return VK_T; // (54) T key case 't': case 'T': return 0x54;
- case Qt::Key_U:
- return VK_U; // (55) U key case 'u': case 'U': return 0x55;
- case Qt::Key_V:
- return VK_V; // (56) V key case 'v': case 'V': return 0x56;
- case Qt::Key_W:
- return VK_W; // (57) W key case 'w': case 'W': return 0x57;
- case Qt::Key_X:
- return VK_X; // (58) X key case 'x': case 'X': return 0x58;
- case Qt::Key_Y:
- return VK_Y; // (59) Y key case 'y': case 'Y': return 0x59;
- case Qt::Key_Z:
- return VK_Z; // (5A) Z key case 'z': case 'Z': return 0x5A;
- case Qt::Key_Meta:
- return VK_LWIN; // (5B) Left Windows key (Microsoft Natural keyboard)
- //case Qt::Key_Meta_R: FIXME: What to do here?
- // return VK_RWIN; // (5C) Right Windows key (Natural keyboard)
- // VK_APPS (5D) Applications key (Natural keyboard)
- // VK_SLEEP (5F) Computer Sleep key
- // VK_SEPARATOR (6C) Separator key
- // VK_SUBTRACT (6D) Subtract key
- // VK_DECIMAL (6E) Decimal key
- // VK_DIVIDE (6F) Divide key
- // handled by key code above
-
- case Qt::Key_NumLock:
- return VK_NUMLOCK; // (90) NUM LOCK key
-
- case Qt::Key_ScrollLock:
- return VK_SCROLL; // (91) SCROLL LOCK key
-
- // VK_LSHIFT (A0) Left SHIFT key
- // VK_RSHIFT (A1) Right SHIFT key
- // VK_LCONTROL (A2) Left CONTROL key
- // VK_RCONTROL (A3) Right CONTROL key
- // VK_LMENU (A4) Left MENU key
- // VK_RMENU (A5) Right MENU key
- // VK_BROWSER_BACK (A6) Windows 2000/XP: Browser Back key
- // VK_BROWSER_FORWARD (A7) Windows 2000/XP: Browser Forward key
- // VK_BROWSER_REFRESH (A8) Windows 2000/XP: Browser Refresh key
- // VK_BROWSER_STOP (A9) Windows 2000/XP: Browser Stop key
- // VK_BROWSER_SEARCH (AA) Windows 2000/XP: Browser Search key
- // VK_BROWSER_FAVORITES (AB) Windows 2000/XP: Browser Favorites key
- // VK_BROWSER_HOME (AC) Windows 2000/XP: Browser Start and Home key
- // VK_VOLUME_MUTE (AD) Windows 2000/XP: Volume Mute key
- // VK_VOLUME_DOWN (AE) Windows 2000/XP: Volume Down key
- // VK_VOLUME_UP (AF) Windows 2000/XP: Volume Up key
- // VK_MEDIA_NEXT_TRACK (B0) Windows 2000/XP: Next Track key
- // VK_MEDIA_PREV_TRACK (B1) Windows 2000/XP: Previous Track key
- // VK_MEDIA_STOP (B2) Windows 2000/XP: Stop Media key
- // VK_MEDIA_PLAY_PAUSE (B3) Windows 2000/XP: Play/Pause Media key
- // VK_LAUNCH_MAIL (B4) Windows 2000/XP: Start Mail key
- // VK_LAUNCH_MEDIA_SELECT (B5) Windows 2000/XP: Select Media key
- // VK_LAUNCH_APP1 (B6) Windows 2000/XP: Start Application 1 key
- // VK_LAUNCH_APP2 (B7) Windows 2000/XP: Start Application 2 key
-
- // VK_OEM_1 (BA) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ';:' key
- case Qt::Key_Semicolon:
- case Qt::Key_Colon:
- return VK_OEM_1; //case ';': case ':': return 0xBA;
- // VK_OEM_PLUS (BB) Windows 2000/XP: For any country/region, the '+' key
- case Qt::Key_Plus:
- case Qt::Key_Equal:
- return VK_OEM_PLUS; //case '=': case '+': return 0xBB;
- // VK_OEM_COMMA (BC) Windows 2000/XP: For any country/region, the ',' key
- case Qt::Key_Comma:
- case Qt::Key_Less:
- return VK_OEM_COMMA; //case ',': case '<': return 0xBC;
- // VK_OEM_MINUS (BD) Windows 2000/XP: For any country/region, the '-' key
- case Qt::Key_Minus:
- case Qt::Key_Underscore:
- return VK_OEM_MINUS; //case '-': case '_': return 0xBD;
- // VK_OEM_PERIOD (BE) Windows 2000/XP: For any country/region, the '.' key
- case Qt::Key_Period:
- case Qt::Key_Greater:
- return VK_OEM_PERIOD; //case '.': case '>': return 0xBE;
- // VK_OEM_2 (BF) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '/?' key
- case Qt::Key_Slash:
- case Qt::Key_Question:
- return VK_OEM_2; //case '/': case '?': return 0xBF;
- // VK_OEM_3 (C0) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '`~' key
- case Qt::Key_AsciiTilde:
- case Qt::Key_QuoteLeft:
- return VK_OEM_3; //case '`': case '~': return 0xC0;
- // VK_OEM_4 (DB) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '[{' key
- case Qt::Key_BracketLeft:
- case Qt::Key_BraceLeft:
- return VK_OEM_4; //case '[': case '{': return 0xDB;
- // VK_OEM_5 (DC) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '\|' key
- case Qt::Key_Backslash:
- case Qt::Key_Bar:
- return VK_OEM_5; //case '\\': case '|': return 0xDC;
- // VK_OEM_6 (DD) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ']}' key
- case Qt::Key_BracketRight:
- case Qt::Key_BraceRight:
- return VK_OEM_6; // case ']': case '}': return 0xDD;
- // VK_OEM_7 (DE) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the 'single-quote/double-quote' key
- case Qt::Key_QuoteDbl:
- return VK_OEM_7; // case '\'': case '"': return 0xDE;
- // VK_OEM_8 (DF) Used for miscellaneous characters; it can vary by keyboard.
- // VK_OEM_102 (E2) Windows 2000/XP: Either the angle bracket key or the backslash key on the RT 102-key keyboard
- // VK_PROCESSKEY (E5) Windows 95/98/Me, Windows NT 4.0, Windows 2000/XP: IME PROCESS key
- // VK_PACKET (E7) Windows 2000/XP: Used to pass Unicode characters as if they were keystrokes. The VK_PACKET key is the low word of a 32-bit Virtual Key value used for non-keyboard input methods. For more information, see Remark in KEYBDINPUT,SendInput, WM_KEYDOWN, and WM_KEYUP
- // VK_ATTN (F6) Attn key
- // VK_CRSEL (F7) CrSel key
- // VK_EXSEL (F8) ExSel key
- // VK_EREOF (F9) Erase EOF key
- // VK_PLAY (FA) Play key
- // VK_ZOOM (FB) Zoom key
- // VK_NONAME (FC) Reserved for future use
- // VK_PA1 (FD) PA1 key
- // VK_OEM_CLEAR (FE) Clear key
- default:
- return 0;
- }
-
-}
-
-PlatformKeyboardEvent::PlatformKeyboardEvent(QKeyEvent* event)
-{
- const int state = event->modifiers();
- m_type = (event->type() == QEvent::KeyRelease) ? KeyUp : KeyDown;
- m_text = event->text();
- m_unmodifiedText = event->text(); // FIXME: not correct
- m_keyIdentifier = keyIdentifierForQtKeyCode(event->key());
- m_autoRepeat = event->isAutoRepeat();
- m_ctrlKey = (state & Qt::ControlModifier) != 0;
- m_altKey = (state & Qt::AltModifier) != 0;
- m_metaKey = (state & Qt::MetaModifier) != 0;
- m_windowsVirtualKeyCode = windowsKeyCodeForKeyEvent(event->key());
- m_nativeVirtualKeyCode = event->nativeVirtualKey();
- m_isKeypad = (state & Qt::KeypadModifier) != 0;
- m_shiftKey = (state & Qt::ShiftModifier) != 0 || event->key() == Qt::Key_Backtab; // Simulate Shift+Tab with Key_Backtab
- m_qtEvent = event;
-}
-
-void PlatformKeyboardEvent::disambiguateKeyDownEvent(Type type, bool)
-{
- // Can only change type from KeyDown to RawKeyDown or Char, as we lack information for other conversions.
- ASSERT(m_type == KeyDown);
- m_type = type;
-
- if (type == RawKeyDown) {
- m_text = String();
- m_unmodifiedText = String();
- } else {
- m_keyIdentifier = String();
- m_windowsVirtualKeyCode = 0;
- }
-}
-
-bool PlatformKeyboardEvent::currentCapsLockState()
-{
- notImplemented();
- return false;
-}
-
-}
-
-// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/qt/PlatformMouseEventQt.cpp b/WebCore/platform/qt/PlatformMouseEventQt.cpp
deleted file mode 100644
index afc7452..0000000
--- a/WebCore/platform/qt/PlatformMouseEventQt.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2006 Zack Rusin <zack@kde.org>
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "PlatformMouseEvent.h"
-
-#include "SystemTime.h"
-
-#include <QMouseEvent>
-
-namespace WebCore {
-
-PlatformMouseEvent::PlatformMouseEvent(QInputEvent* event, int clickCount)
-{
- m_timestamp = WebCore::currentTime();
-
- QMouseEvent *me = 0;
-
- switch(event->type()) {
- case QEvent::MouseMove:
- m_eventType = MouseEventMoved;
- me = static_cast<QMouseEvent *>(event);
- break;
- case QEvent::MouseButtonDblClick:
- case QEvent::MouseButtonPress:
- m_eventType = MouseEventPressed;
- me = static_cast<QMouseEvent *>(event);
- break;
- case QEvent::MouseButtonRelease:
- m_eventType = MouseEventReleased;
- me = static_cast<QMouseEvent *>(event);
- break;
-#ifndef QT_NO_CONTEXTMENU
- case QEvent::ContextMenu: {
- m_eventType = MouseEventPressed;
- QContextMenuEvent *ce = static_cast<QContextMenuEvent *>(event);
- m_position = IntPoint(ce->pos());
- m_globalPosition = IntPoint(ce->globalPos());
- m_button = RightButton;
- break;
- }
-#endif // QT_NO_CONTEXTMENU
- default:
- m_eventType = MouseEventMoved;
- }
-
- if (me) {
- m_position = IntPoint(me->pos());
- m_globalPosition = IntPoint(me->globalPos());
-
- if (me->button() == Qt::LeftButton || (me->buttons() & Qt::LeftButton))
- m_button = LeftButton;
- else if (me->button() == Qt::RightButton || (me->buttons() & Qt::RightButton))
- m_button = RightButton;
- else if (me->button() == Qt::MidButton || (me->buttons() & Qt::MidButton))
- m_button = MiddleButton;
- else
- m_button = NoButton;
- }
-
- m_clickCount = clickCount;
- m_shiftKey = (event->modifiers() & Qt::ShiftModifier) != 0;
- m_ctrlKey = (event->modifiers() & Qt::ControlModifier) != 0;
- m_altKey = (event->modifiers() & Qt::AltModifier) != 0;
- m_metaKey = (event->modifiers() & Qt::MetaModifier) != 0;
-}
-
-}
-
-// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/qt/PlatformScreenQt.cpp b/WebCore/platform/qt/PlatformScreenQt.cpp
deleted file mode 100644
index 5bc86d0..0000000
--- a/WebCore/platform/qt/PlatformScreenQt.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "PlatformScreen.h"
-
-#include "FloatRect.h"
-#include "Frame.h"
-#include "FrameView.h"
-#include "HostWindow.h"
-#include "Widget.h"
-#include <QApplication>
-#include <QDesktopWidget>
-
-namespace WebCore {
-
-int screenDepth(Widget* w)
-{
- QDesktopWidget* d = QApplication::desktop();
- QWidget *view = w->root()->hostWindow()->platformWindow();
- int screenNumber = view ? d->screenNumber(view) : 0;
- return d->screen(screenNumber)->depth();
-}
-
-int screenDepthPerComponent(Widget* w)
-{
- QWidget *view = w->root()->hostWindow()->platformWindow();
- return view ? view->depth() : QApplication::desktop()->screen(0)->depth();
-}
-
-bool screenIsMonochrome(Widget* w)
-{
- QDesktopWidget* d = QApplication::desktop();
- QWidget *view = w->root()->hostWindow()->platformWindow();
- int screenNumber = view ? d->screenNumber(view) : 0;
- return d->screen(screenNumber)->numColors() < 2;
-}
-
-FloatRect screenRect(Widget* w)
-{
- QRect r = QApplication::desktop()->screenGeometry(w->root()->hostWindow()->platformWindow());
- return FloatRect(r.x(), r.y(), r.width(), r.height());
-}
-
-FloatRect screenAvailableRect(Widget* w)
-{
- QRect r = QApplication::desktop()->availableGeometry(w->root()->hostWindow()->platformWindow());
- return FloatRect(r.x(), r.y(), r.width(), r.height());
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/qt/PopupMenuQt.cpp b/WebCore/platform/qt/PopupMenuQt.cpp
deleted file mode 100644
index 76728fa..0000000
--- a/WebCore/platform/qt/PopupMenuQt.cpp
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * This file is part of the popup menu implementation for <select> elements in WebCore.
- *
- * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
- * Copyright (C) 2006 Apple Computer, Inc.
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
- * Coypright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "PopupMenu.h"
-
-#include "Frame.h"
-#include "FrameView.h"
-#include "HostWindow.h"
-#include "PopupMenuClient.h"
-#include "NotImplemented.h"
-#include "QWebPopup.h"
-
-#include <QAction>
-#include <QDebug>
-#include <QMenu>
-#include <QPoint>
-#include <QListWidget>
-#include <QListWidgetItem>
-#include <QWidgetAction>
-
-namespace WebCore {
-
-PopupMenu::PopupMenu(PopupMenuClient* client)
- : m_popupClient(client)
-{
- m_popup = new QWebPopup(client);
-}
-
-PopupMenu::~PopupMenu()
-{
- delete m_popup;
-}
-
-void PopupMenu::clear()
-{
- m_popup->clear();
-}
-
-void PopupMenu::populate(const IntRect& r)
-{
- clear();
- Q_ASSERT(client());
-
- int size = client()->listSize();
- for (int i = 0; i < size; i++) {
- if (client()->itemIsSeparator(i)) {
- //FIXME: better seperator item
- m_popup->insertItem(i, QString::fromLatin1("---"));
- }
- else {
- //PopupMenuStyle style = client()->itemStyle(i);
- m_popup->insertItem(i, client()->itemText(i));
-#if 0
- item = new QListWidgetItem(client()->itemText(i));
- m_actions.insert(item, i);
- if (style->font() != Font())
- item->setFont(style->font());
-
- Qt::ItemFlags flags = Qt::ItemIsSelectable;
- if (client()->itemIsEnabled(i))
- flags |= Qt::ItemIsEnabled;
- item->setFlags(flags);
-#endif
- }
- }
-}
-
-void PopupMenu::show(const IntRect& r, FrameView* v, int index)
-{
- QWidget* window = v->hostWindow()->platformWindow();
- populate(r);
- QRect rect = r;
- rect.moveTopLeft(v->contentsToWindow(r.topLeft()));
- rect.setHeight(m_popup->sizeHint().height());
-
- m_popup->setParent(window);
- m_popup->setGeometry(rect);
- m_popup->setCurrentIndex(index);
- m_popup->exec();
-}
-
-void PopupMenu::hide()
-{
- m_popup->hidePopup();
-}
-
-void PopupMenu::updateFromElement()
-{
- client()->setTextFromItem(m_popupClient->selectedIndex());
-}
-
-bool PopupMenu::itemWritingDirectionIsNatural()
-{
- return false;
-}
-
-}
-
-// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/qt/QWebPopup.cpp b/WebCore/platform/qt/QWebPopup.cpp
deleted file mode 100644
index ae5c24e..0000000
--- a/WebCore/platform/qt/QWebPopup.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- *
- * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-#include "config.h"
-#include "QWebPopup.h"
-#include "PopupMenuStyle.h"
-
-#include <QCoreApplication>
-#include <QMouseEvent>
-
-namespace WebCore {
-
-QWebPopup::QWebPopup(PopupMenuClient* client)
- : m_client(client)
- , m_popupVisible(false)
-{
- Q_ASSERT(m_client);
-
- setFont(m_client->menuStyle().font().font());
- connect(this, SIGNAL(activated(int)),
- SLOT(activeChanged(int)));
-}
-
-
-void QWebPopup::exec()
-{
- QMouseEvent event(QEvent::MouseButtonPress, QCursor::pos(), Qt::LeftButton,
- Qt::LeftButton, Qt::NoModifier);
- QCoreApplication::sendEvent(this, &event);
-}
-
-void QWebPopup::showPopup()
-{
- QComboBox::showPopup();
- m_popupVisible = true;
-}
-
-void QWebPopup::hidePopup()
-{
- QComboBox::hidePopup();
- if (!m_popupVisible)
- return;
-
- m_popupVisible = false;
- m_client->hidePopup();
-}
-
-void QWebPopup::activeChanged(int index)
-{
- if (index < 0)
- return;
-
- m_client->valueChanged(index);
-}
-
-}
diff --git a/WebCore/platform/qt/QWebPopup.h b/WebCore/platform/qt/QWebPopup.h
deleted file mode 100644
index 36d6781..0000000
--- a/WebCore/platform/qt/QWebPopup.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- *
- * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-#ifndef QWebPopup_h
-#define QWebPopup_h
-
-#include <QComboBox>
-
-#include "PopupMenuClient.h"
-
-namespace WebCore {
-
-class QWebPopup : public QComboBox {
- Q_OBJECT
-public:
- QWebPopup(PopupMenuClient* client);
-
- void exec();
-
- virtual void showPopup();
- virtual void hidePopup();
-
-private slots:
- void activeChanged(int);
-private:
- PopupMenuClient* m_client;
- bool m_popupVisible;
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/qt/RenderThemeQt.cpp b/WebCore/platform/qt/RenderThemeQt.cpp
deleted file mode 100644
index 2a33e45..0000000
--- a/WebCore/platform/qt/RenderThemeQt.cpp
+++ /dev/null
@@ -1,947 +0,0 @@
-/*
- * This file is part of the WebKit project.
- *
- * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
- *
- * Copyright (C) 2006 Zack Rusin <zack@kde.org>
- * 2006 Dirk Mueller <mueller@kde.org>
- * 2006 Nikolas Zimmermann <zimmermann@kde.org>
- *
- * All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-
-#include "qwebpage.h"
-#include "RenderThemeQt.h"
-#include "ChromeClientQt.h"
-#include "NotImplemented.h"
-
-#include <QApplication>
-#include <QColor>
-#include <QDebug>
-#include <QFile>
-#include <QWidget>
-#include <QPainter>
-#include <QPushButton>
-#include <QStyleFactory>
-#include <QStyleOptionButton>
-#include <QStyleOptionFrameV2>
-
-#include "Color.h"
-#include "CSSStyleSheet.h"
-#include "Document.h"
-#include "Page.h"
-#include "Font.h"
-#include "RenderTheme.h"
-#include "GraphicsContext.h"
-#include "HTMLMediaElement.h"
-#include "HTMLNames.h"
-
-namespace WebCore {
-
-using namespace HTMLNames;
-
-
-StylePainter::StylePainter(const RenderObject::PaintInfo& paintInfo)
-{
- init(paintInfo.context ? paintInfo.context : 0);
-}
-
-StylePainter::StylePainter(GraphicsContext* context)
-{
- init(context);
-}
-
-void StylePainter::init(GraphicsContext* context)
-{
- painter = static_cast<QPainter*>(context->platformContext());
- widget = 0;
- QPaintDevice* dev = 0;
- if (painter)
- dev = painter->device();
- if (dev && dev->devType() == QInternal::Widget)
- widget = static_cast<QWidget*>(dev);
- style = (widget ? widget->style() : QApplication::style());
-
- if (painter) {
- // the styles often assume being called with a pristine painter where no brush is set,
- // so reset it manually
- oldBrush = painter->brush();
- painter->setBrush(Qt::NoBrush);
-
- // painting the widget with anti-aliasing will make it blurry
- // disable it here and restore it later
- oldAntialiasing = painter->testRenderHint(QPainter::Antialiasing);
- painter->setRenderHint(QPainter::Antialiasing, false);
- }
-}
-
-StylePainter::~StylePainter()
-{
- if (painter) {
- painter->setBrush(oldBrush);
- painter->setRenderHints(QPainter::Antialiasing, oldAntialiasing);
- }
-}
-
-RenderTheme* theme()
-{
- static RenderThemeQt rt;
- return &rt;
-}
-
-RenderThemeQt::RenderThemeQt()
- : RenderTheme()
-{
- QPushButton button;
- button.setAttribute(Qt::WA_MacSmallSize);
- QFont defaultButtonFont = QApplication::font(&button);
- QFontInfo fontInfo(defaultButtonFont);
- m_buttonFontFamily = defaultButtonFont.family();
-#ifdef Q_WS_MAC
- m_buttonFontPixelSize = fontInfo.pixelSize();
-#endif
-
- m_fallbackStyle = 0;
-}
-
-RenderThemeQt::~RenderThemeQt()
-{
- delete m_fallbackStyle;
-}
-
-// for some widget painting, we need to fallback to Windows style
-QStyle* RenderThemeQt::fallbackStyle()
-{
- if(!m_fallbackStyle)
- m_fallbackStyle = QStyleFactory::create(QLatin1String("windows"));
-
- if(!m_fallbackStyle)
- m_fallbackStyle = QApplication::style();
-
- return m_fallbackStyle;
-}
-
-bool RenderThemeQt::supportsHover(const RenderStyle*) const
-{
- return true;
-}
-
-bool RenderThemeQt::supportsFocusRing(const RenderStyle* style) const
-{
- return true; // Qt provides this through the style
-}
-
-int RenderThemeQt::baselinePosition(const RenderObject* o) const
-{
- if (o->style()->appearance() == CheckboxPart ||
- o->style()->appearance() == RadioPart)
- return o->marginTop() + o->height() - 2; // Same as in old khtml
- return RenderTheme::baselinePosition(o);
-}
-
-bool RenderThemeQt::controlSupportsTints(const RenderObject* o) const
-{
- if (!isEnabled(o))
- return false;
-
- // Checkboxes only have tint when checked.
- if (o->style()->appearance() == CheckboxPart)
- return isChecked(o);
-
- // For now assume other controls have tint if enabled.
- return true;
-}
-
-bool RenderThemeQt::supportsControlTints() const
-{
- return true;
-}
-
-static QRect inflateButtonRect(const QRect& originalRect)
-{
- QStyleOptionButton option;
- option.state |= QStyle::State_Small;
- option.rect = originalRect;
-
- QRect layoutRect = QApplication::style()->subElementRect(QStyle::SE_PushButtonLayoutItem,
- &option, 0);
- if (!layoutRect.isNull()) {
- int paddingLeft = layoutRect.left() - originalRect.left();
- int paddingRight = originalRect.right() - layoutRect.right();
- int paddingTop = layoutRect.top() - originalRect.top();
- int paddingBottom = originalRect.bottom() - layoutRect.bottom();
-
- return originalRect.adjusted(-paddingLeft, -paddingTop, paddingRight, paddingBottom);
- } else {
- return originalRect;
- }
-}
-
-void RenderThemeQt::adjustRepaintRect(const RenderObject* o, IntRect& r)
-{
- switch (o->style()->appearance()) {
- case CheckboxPart: {
- break;
- }
- case RadioPart: {
- break;
- }
- case PushButtonPart:
- case ButtonPart: {
- QRect inflatedRect = inflateButtonRect(r);
- r = IntRect(inflatedRect.x(), inflatedRect.y(), inflatedRect.width(), inflatedRect.height());
- break;
- }
- case MenulistPart: {
- break;
- }
- default:
- break;
- }
-}
-
-bool RenderThemeQt::isControlStyled(const RenderStyle* style, const BorderData& border,
- const FillLayer& background, const Color& backgroundColor) const
-{
- if (style->appearance() == TextFieldPart
- || style->appearance() == TextAreaPart
- || style->appearance() == ListboxPart) {
- return style->border() != border;
- }
-
- return RenderTheme::isControlStyled(style, border, background, backgroundColor);
-}
-
-Color RenderThemeQt::platformActiveSelectionBackgroundColor() const
-{
- QPalette pal = QApplication::palette();
- return pal.brush(QPalette::Active, QPalette::Highlight).color();
-}
-
-Color RenderThemeQt::platformInactiveSelectionBackgroundColor() const
-{
- QPalette pal = QApplication::palette();
- return pal.brush(QPalette::Inactive, QPalette::Highlight).color();
-}
-
-Color RenderThemeQt::platformActiveSelectionForegroundColor() const
-{
- QPalette pal = QApplication::palette();
- return pal.brush(QPalette::Active, QPalette::HighlightedText).color();
-}
-
-Color RenderThemeQt::platformInactiveSelectionForegroundColor() const
-{
- QPalette pal = QApplication::palette();
- return pal.brush(QPalette::Inactive, QPalette::HighlightedText).color();
-}
-
-void RenderThemeQt::systemFont(int propId, FontDescription& fontDescription) const
-{
- // no-op
-}
-
-int RenderThemeQt::minimumMenuListSize(RenderStyle*) const
-{
- const QFontMetrics &fm = QApplication::fontMetrics();
- return 7 * fm.width(QLatin1Char('x'));
-}
-
-static void computeSizeBasedOnStyle(RenderStyle* renderStyle)
-{
- // If the width and height are both specified, then we have nothing to do.
- if (!renderStyle->width().isIntrinsicOrAuto() && !renderStyle->height().isAuto())
- return;
-
- QSize size(0, 0);
- const QFontMetrics fm(renderStyle->font().font());
- QStyle* applicationStyle = QApplication::style();
-
- switch (renderStyle->appearance()) {
- case CheckboxPart: {
- QStyleOption styleOption;
- styleOption.state |= QStyle::State_Small;
- int checkBoxWidth = applicationStyle->pixelMetric(QStyle::PM_IndicatorWidth,
- &styleOption);
- size = QSize(checkBoxWidth, checkBoxWidth);
- break;
- }
- case RadioPart: {
- QStyleOption styleOption;
- styleOption.state |= QStyle::State_Small;
- int radioWidth = applicationStyle->pixelMetric(QStyle::PM_ExclusiveIndicatorWidth,
- &styleOption);
- size = QSize(radioWidth, radioWidth);
- break;
- }
- case PushButtonPart:
- case ButtonPart: {
- QStyleOptionButton styleOption;
- styleOption.state |= QStyle::State_Small;
- QSize contentSize = fm.size(Qt::TextShowMnemonic, QString::fromLatin1("X"));
- QSize pushButtonSize = applicationStyle->sizeFromContents(QStyle::CT_PushButton,
- &styleOption,
- contentSize,
- 0);
- styleOption.rect = QRect(0, 0, pushButtonSize.width(), pushButtonSize.height());
- QRect layoutRect = applicationStyle->subElementRect(QStyle::SE_PushButtonLayoutItem,
- &styleOption,
- 0);
- // If the style supports layout rects we use that, and
- // compensate accordingly in paintButton() below.
- if (!layoutRect.isNull()) {
- size.setHeight(layoutRect.height());
- } else {
- size.setHeight(pushButtonSize.height());
- }
-
- break;
- }
- case MenulistPart: {
- QStyleOptionComboBox styleOption;
- styleOption.state |= QStyle::State_Small;
- int contentHeight = qMax(fm.lineSpacing(), 14) + 2;
- QSize menuListSize = applicationStyle->sizeFromContents(QStyle::CT_ComboBox,
- &styleOption,
- QSize(0, contentHeight),
- 0);
- size.setHeight(menuListSize.height());
- break;
- }
- case TextFieldPart: {
- const int verticalMargin = 1;
- const int horizontalMargin = 2;
- int h = qMax(fm.lineSpacing(), 14) + 2*verticalMargin;
- int w = fm.width(QLatin1Char('x')) * 17 + 2*horizontalMargin;
- QStyleOptionFrameV2 opt;
- opt.lineWidth = applicationStyle->pixelMetric(QStyle::PM_DefaultFrameWidth,
- &opt, 0);
- QSize sz = applicationStyle->sizeFromContents(QStyle::CT_LineEdit,
- &opt,
- QSize(w, h).expandedTo(QApplication::globalStrut()),
- 0);
- size.setHeight(sz.height());
- break;
- }
- default:
- break;
- }
-
- // FIXME: Check is flawed, since it doesn't take min-width/max-width into account.
- if (renderStyle->width().isIntrinsicOrAuto() && size.width() > 0)
- renderStyle->setWidth(Length(size.width(), Fixed));
- if (renderStyle->height().isAuto() && size.height() > 0)
- renderStyle->setHeight(Length(size.height(), Fixed));
-}
-
-void RenderThemeQt::setCheckboxSize(RenderStyle* style) const
-{
- computeSizeBasedOnStyle(style);
-}
-
-bool RenderThemeQt::paintCheckbox(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
-{
- return paintButton(o, i, r);
-}
-
-void RenderThemeQt::setRadioSize(RenderStyle* style) const
-{
- computeSizeBasedOnStyle(style);
-}
-
-bool RenderThemeQt::paintRadio(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
-{
- return paintButton(o, i, r);
-}
-
-void RenderThemeQt::adjustButtonStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
-{
- // Ditch the border.
- style->resetBorder();
-
- // Height is locked to auto.
- style->setHeight(Length(Auto));
-
- // White-space is locked to pre
- style->setWhiteSpace(PRE);
-
- FontDescription fontDescription = style->fontDescription();
- fontDescription.setIsAbsoluteSize(true);
-
-#ifdef Q_WS_MAC // Use fixed font size and family on Mac (like Safari does)
- fontDescription.setSpecifiedSize(m_buttonFontPixelSize);
- fontDescription.setComputedSize(m_buttonFontPixelSize);
-#else
- fontDescription.setSpecifiedSize(style->fontSize());
- fontDescription.setComputedSize(style->fontSize());
-#endif
-
- FontFamily fontFamily;
- fontFamily.setFamily(m_buttonFontFamily);
- fontDescription.setFamily(fontFamily);
- style->setFontDescription(fontDescription);
- style->setLineHeight(RenderStyle::initialLineHeight());
-
- setButtonSize(style);
- setButtonPadding(style);
-
- style->setColor(QApplication::palette().text().color());
-}
-
-void RenderThemeQt::setButtonSize(RenderStyle* style) const
-{
- computeSizeBasedOnStyle(style);
-}
-
-void RenderThemeQt::setButtonPadding(RenderStyle* style) const
-{
- QStyleOptionButton styleOption;
- styleOption.state |= QStyle::State_Small;
-
- // Fake a button rect here, since we're just computing deltas
- QRect originalRect = QRect(0, 0, 100, 30);
- styleOption.rect = originalRect;
-
- // Default padding is based on the button margin pixel metric
- int buttonMargin = QApplication::style()->pixelMetric(QStyle::PM_ButtonMargin,
- &styleOption, 0);
- int paddingLeft = buttonMargin;
- int paddingRight = buttonMargin;
- int paddingTop = 1;
- int paddingBottom = 0;
-
- // Then check if the style uses layout margins
- QRect layoutRect = QApplication::style()->subElementRect(QStyle::SE_PushButtonLayoutItem,
- &styleOption, 0);
- if (!layoutRect.isNull()) {
- QRect contentsRect = QApplication::style()->subElementRect(QStyle::SE_PushButtonContents,
- &styleOption, 0);
- paddingLeft = contentsRect.left() - layoutRect.left();
- paddingRight = layoutRect.right() - contentsRect.right();
- paddingTop = contentsRect.top() - layoutRect.top();
-
- // Can't use this right now because we don't have the baseline to compensate
- // paddingBottom = layoutRect.bottom() - contentsRect.bottom();
- }
-
- style->setPaddingLeft(Length(paddingLeft, Fixed));
- style->setPaddingRight(Length(paddingRight, Fixed));
- style->setPaddingTop(Length(paddingTop, Fixed));
- style->setPaddingBottom(Length(paddingBottom, Fixed));
-}
-
-bool RenderThemeQt::paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
-{
- StylePainter p(i);
- if (!p.isValid())
- return true;
-
- QStyleOptionButton option;
- if (p.widget)
- option.initFrom(p.widget);
-
- option.rect = r;
- option.state |= QStyle::State_Small;
-
- ControlPart appearance = applyTheme(option, o);
- if(appearance == PushButtonPart || appearance == ButtonPart) {
- option.rect = inflateButtonRect(option.rect);
- p.drawControl(QStyle::CE_PushButton, option);
- } else if(appearance == RadioPart) {
- p.drawControl(QStyle::CE_RadioButton, option);
- } else if(appearance == CheckboxPart) {
- p.drawControl(QStyle::CE_CheckBox, option);
- }
-
- return false;
-}
-
-void RenderThemeQt::adjustTextFieldStyle(CSSStyleSelector*, RenderStyle* style, Element*) const
-{
- style->setBackgroundColor(Color::transparent);
- style->setColor(QApplication::palette().text().color());
-}
-
-bool RenderThemeQt::paintTextField(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
-{
- StylePainter p(i);
- if (!p.isValid())
- return true;
-
- QStyleOptionFrameV2 panel;
- if (p.widget)
- panel.initFrom(p.widget);
-
- panel.rect = r;
- panel.lineWidth = p.style->pixelMetric(QStyle::PM_DefaultFrameWidth, &panel, p.widget);
- panel.state |= QStyle::State_Sunken;
- panel.features = QStyleOptionFrameV2::None;
-
- // Get the correct theme data for a text field
- ControlPart appearance = applyTheme(panel, o);
- if (appearance != TextFieldPart
- && appearance != SearchFieldPart
- && appearance != TextAreaPart
- && appearance != ListboxPart)
- return true;
-
- // Now paint the text field.
- p.drawPrimitive(QStyle::PE_PanelLineEdit, panel);
-
- return false;
-}
-
-void RenderThemeQt::adjustTextAreaStyle(CSSStyleSelector* selector, RenderStyle* style, Element* element) const
-{
- adjustTextFieldStyle(selector, style, element);
-}
-
-bool RenderThemeQt::paintTextArea(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
-{
- return paintTextField(o, i, r);
-}
-
-void RenderThemeQt::adjustMenuListStyle(CSSStyleSelector*, RenderStyle* style, Element*) const
-{
- style->resetBorder();
-
- // Height is locked to auto.
- style->setHeight(Length(Auto));
-
- // White-space is locked to pre
- style->setWhiteSpace(PRE);
-
- computeSizeBasedOnStyle(style);
-
- // Add in the padding that we'd like to use.
- setPopupPadding(style);
-
- style->setColor(QApplication::palette().text().color());
-}
-
-void RenderThemeQt::setPopupPadding(RenderStyle* style) const
-{
- const int padding = 8;
- style->setPaddingLeft(Length(padding, Fixed));
-
- QStyleOptionComboBox opt;
- int w = QApplication::style()->pixelMetric(QStyle::PM_ButtonIconSize, &opt, 0);
- style->setPaddingRight(Length(padding + w, Fixed));
-
- style->setPaddingTop(Length(2, Fixed));
- style->setPaddingBottom(Length(0, Fixed));
-}
-
-
-bool RenderThemeQt::paintMenuList(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
-{
- StylePainter p(i);
- if (!p.isValid())
- return true;
-
- QStyleOptionComboBox opt;
- if (p.widget)
- opt.initFrom(p.widget);
- ControlPart appearance = applyTheme(opt, o);
-
- const QPoint topLeft = r.topLeft();
- p.painter->translate(topLeft);
- opt.rect.moveTo(QPoint(0,0));
- opt.rect.setSize(r.size());
-
- opt.frame = false;
-
- p.drawComplexControl(QStyle::CC_ComboBox, opt);
- p.painter->translate(-topLeft);
- return false;
-}
-
-void RenderThemeQt::adjustMenuListButtonStyle(CSSStyleSelector* selector, RenderStyle* style,
- Element* e) const
-{
- // WORKAROUND because html4.css specifies -webkit-border-radius for <select> so we override it here
- // see also http://bugs.webkit.org/show_bug.cgi?id=18399
- style->resetBorderRadius();
-
- // Height is locked to auto.
- style->setHeight(Length(Auto));
-
- // White-space is locked to pre
- style->setWhiteSpace(PRE);
-
- computeSizeBasedOnStyle(style);
-
- // Add in the padding that we'd like to use.
- setPopupPadding(style);
-
- style->setColor(QApplication::palette().text().color());
-}
-
-bool RenderThemeQt::paintMenuListButton(RenderObject* o, const RenderObject::PaintInfo& i,
- const IntRect& r)
-{
- StylePainter p(i);
- if (!p.isValid())
- return true;
-
- QStyleOptionComboBox option;
- if (p.widget)
- option.initFrom(p.widget);
- applyTheme(option, o);
- option.rect = r;
-
- // for drawing the combo box arrow, rely only on the fallback style
- p.style = fallbackStyle();
- option.subControls = QStyle::SC_ComboBoxArrow;
- p.drawComplexControl(QStyle::CC_ComboBox, option);
-
- return false;
-}
-
-bool RenderThemeQt::paintSliderTrack(RenderObject* o, const RenderObject::PaintInfo& pi,
- const IntRect& r)
-{
- notImplemented();
- return RenderTheme::paintSliderTrack(o, pi, r);
-}
-
-bool RenderThemeQt::paintSliderThumb(RenderObject* o, const RenderObject::PaintInfo& pi,
- const IntRect& r)
-{
- notImplemented();
- return RenderTheme::paintSliderThumb(o, pi, r);
-}
-
-bool RenderThemeQt::paintSearchField(RenderObject* o, const RenderObject::PaintInfo& pi,
- const IntRect& r)
-{
- paintTextField(o, pi, r);
- return false;
-}
-
-void RenderThemeQt::adjustSearchFieldStyle(CSSStyleSelector* selector, RenderStyle* style,
- Element* e) const
-{
- notImplemented();
- RenderTheme::adjustSearchFieldStyle(selector, style, e);
-}
-
-void RenderThemeQt::adjustSearchFieldCancelButtonStyle(CSSStyleSelector* selector, RenderStyle* style,
- Element* e) const
-{
- notImplemented();
- RenderTheme::adjustSearchFieldCancelButtonStyle(selector, style, e);
-}
-
-bool RenderThemeQt::paintSearchFieldCancelButton(RenderObject* o, const RenderObject::PaintInfo& pi,
- const IntRect& r)
-{
- notImplemented();
- return RenderTheme::paintSearchFieldCancelButton(o, pi, r);
-}
-
-void RenderThemeQt::adjustSearchFieldDecorationStyle(CSSStyleSelector* selector, RenderStyle* style,
- Element* e) const
-{
- notImplemented();
- RenderTheme::adjustSearchFieldDecorationStyle(selector, style, e);
-}
-
-bool RenderThemeQt::paintSearchFieldDecoration(RenderObject* o, const RenderObject::PaintInfo& pi,
- const IntRect& r)
-{
- notImplemented();
- return RenderTheme::paintSearchFieldDecoration(o, pi, r);
-}
-
-void RenderThemeQt::adjustSearchFieldResultsDecorationStyle(CSSStyleSelector* selector, RenderStyle* style,
- Element* e) const
-{
- notImplemented();
- RenderTheme::adjustSearchFieldResultsDecorationStyle(selector, style, e);
-}
-
-bool RenderThemeQt::paintSearchFieldResultsDecoration(RenderObject* o, const RenderObject::PaintInfo& pi,
- const IntRect& r)
-{
- notImplemented();
- return RenderTheme::paintSearchFieldResultsDecoration(o, pi, r);
-}
-
-bool RenderThemeQt::supportsFocus(ControlPart appearance) const
-{
- switch (appearance) {
- case PushButtonPart:
- case ButtonPart:
- case TextFieldPart:
- case TextAreaPart:
- case ListboxPart:
- case MenulistPart:
- case RadioPart:
- case CheckboxPart:
- return true;
- default: // No for all others...
- return false;
- }
-}
-
-ControlPart RenderThemeQt::applyTheme(QStyleOption& option, RenderObject* o) const
-{
- // Default bits: no focus, no mouse over
- option.state &= ~(QStyle::State_HasFocus | QStyle::State_MouseOver);
-
- if (!isEnabled(o))
- option.state &= ~QStyle::State_Enabled;
-
- if (isReadOnlyControl(o))
- // Readonly is supported on textfields.
- option.state |= QStyle::State_ReadOnly;
-
- if (supportsFocus(o->style()->appearance()) && isFocused(o))
- option.state |= QStyle::State_HasFocus;
-
- if (isHovered(o))
- option.state |= QStyle::State_MouseOver;
-
- ControlPart result = o->style()->appearance();
-
- switch (result) {
- case PushButtonPart:
- case SquareButtonPart:
- case ButtonPart:
- case ButtonBevelPart:
- case ListItemPart:
- case MenulistButtonPart:
- case SearchFieldResultsButtonPart:
- case SearchFieldCancelButtonPart: {
- if (isPressed(o))
- option.state |= QStyle::State_Sunken;
- else if (result == PushButtonPart)
- option.state |= QStyle::State_Raised;
- break;
- }
- }
-
- if(result == RadioPart || result == CheckboxPart)
- option.state |= (isChecked(o) ? QStyle::State_On : QStyle::State_Off);
-
- // If the webview has a custom palette, use it
- Page* page = o->document()->page();
- if (page) {
- QWidget* view = static_cast<ChromeClientQt*>(page->chrome()->client())->m_webPage->view();
- if (view)
- option.palette = view->palette();
- }
-
- return result;
-}
-
-void RenderTheme::adjustDefaultStyleSheet(CSSStyleSheet* style)
-{
- QFile platformStyleSheet(":/webcore/resources/html4-adjustments-qt.css");
- if (platformStyleSheet.open(QFile::ReadOnly)) {
- QByteArray sheetData = platformStyleSheet.readAll();
- style->parseString(QString::fromUtf8(sheetData.constData(), sheetData.length()));
- }
-}
-
-#if ENABLE(VIDEO)
-
-// Helper class to transform the painter's world matrix to the object's content area, scaled to 0,0,100,100
-class WorldMatrixTransformer
-{
-public:
- WorldMatrixTransformer(QPainter* painter, RenderObject* renderObject, const IntRect& r) : m_painter(painter) {
- RenderStyle* style = renderObject->style();
- m_originalTransform = m_painter->transform();
- m_painter->translate(r.x() + style->paddingLeft().value(), r.y() + style->paddingTop().value());
- m_painter->scale((r.width() - style->paddingLeft().value() - style->paddingRight().value()) / 100.0,
- (r.height() - style->paddingTop().value() - style->paddingBottom().value()) / 100.0);
- }
-
- ~WorldMatrixTransformer() { m_painter->setTransform(m_originalTransform); }
-
-private:
- QPainter* m_painter;
- QTransform m_originalTransform;
-};
-
-HTMLMediaElement* RenderThemeQt::getMediaElementFromRenderObject(RenderObject* o) const
-{
- Node* node = o->element();
- Node* mediaNode = node ? node->shadowAncestorNode() : 0;
- if (!mediaNode || (!mediaNode->hasTagName(videoTag) && !mediaNode->hasTagName(audioTag)))
- return 0;
-
- return static_cast<HTMLMediaElement*>(mediaNode);
-}
-
-void RenderThemeQt::paintMediaBackground(QPainter* painter, const IntRect& r) const
-{
- painter->setPen(Qt::NoPen);
- static QColor transparentBlack(0,0,0,100);
- painter->setBrush(transparentBlack);
- painter->drawRoundedRect(r.x(), r.y(), r.width(), r.height(), 5.0, 5.0);
-}
-
-QColor RenderThemeQt::getMediaControlForegroundColor(RenderObject* o) const
-{
- QColor fgColor = platformActiveSelectionBackgroundColor();
- if (o && o->element()->active())
- fgColor = fgColor.lighter();
- return fgColor;
-}
-
-bool RenderThemeQt::paintMediaFullscreenButton(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r)
-{
- return RenderTheme::paintMediaFullscreenButton(o, paintInfo, r);
-}
-
-bool RenderThemeQt::paintMediaMuteButton(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r)
-{
- HTMLMediaElement* mediaElement = getMediaElementFromRenderObject(o);
- if (!mediaElement)
- return false;
-
- StylePainter p(paintInfo);
- if (!p.isValid())
- return true;
-
- p.painter->setRenderHint(QPainter::Antialiasing, true);
-
- paintMediaBackground(p.painter, r);
-
- WorldMatrixTransformer transformer(p.painter, o, r);
- const QPointF speakerPolygon[6] = { QPointF(20, 30), QPointF(50, 30), QPointF(80, 0),
- QPointF(80, 100), QPointF(50, 70), QPointF(20, 70)};
-
- p.painter->setBrush(getMediaControlForegroundColor(o));
- p.painter->drawPolygon(speakerPolygon, 6);
-
- if (mediaElement->muted()) {
- p.painter->setPen(Qt::red);
- p.painter->drawLine(0, 100, 100, 0);
- }
-
- return false;
-}
-
-bool RenderThemeQt::paintMediaPlayButton(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r)
-{
- HTMLMediaElement* mediaElement = getMediaElementFromRenderObject(o);
- if (!mediaElement)
- return false;
-
- StylePainter p(paintInfo);
- if (!p.isValid())
- return true;
-
- p.painter->setRenderHint(QPainter::Antialiasing, true);
-
- paintMediaBackground(p.painter, r);
-
- WorldMatrixTransformer transformer(p.painter, o, r);
- p.painter->setBrush(getMediaControlForegroundColor(o));
- if (mediaElement->canPlay()) {
- const QPointF playPolygon[3] = { QPointF(0, 0), QPointF(100, 50), QPointF(0, 100)};
- p.painter->drawPolygon(playPolygon, 3);
- } else {
- p.painter->drawRect(0, 0, 30, 100);
- p.painter->drawRect(70, 0, 30, 100);
- }
-
- return false;
-}
-
-bool RenderThemeQt::paintMediaSeekBackButton(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r)
-{
- // We don't want to paint this at the moment.
- return false;
-}
-
-bool RenderThemeQt::paintMediaSeekForwardButton(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r)
-{
- // We don't want to paint this at the moment.
- return false;
-}
-
-bool RenderThemeQt::paintMediaSliderTrack(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r)
-{
- HTMLMediaElement* mediaElement = getMediaElementFromRenderObject(o);
- if (!mediaElement)
- return false;
-
- StylePainter p(paintInfo);
- if (!p.isValid())
- return true;
-
- p.painter->setRenderHint(QPainter::Antialiasing, true);
-
- paintMediaBackground(p.painter, r);
-
- if (MediaPlayer* player = mediaElement->player()) {
- if (player->totalBytesKnown()) {
- float percentLoaded = static_cast<float>(player->bytesLoaded()) / player->totalBytes();
-
- WorldMatrixTransformer transformer(p.painter, o, r);
- p.painter->setBrush(getMediaControlForegroundColor());
- p.painter->drawRect(0, 37, 100 * percentLoaded, 26);
- }
- }
-
- return false;
-}
-
-bool RenderThemeQt::paintMediaSliderThumb(RenderObject* o, const RenderObject::PaintInfo& paintInfo, const IntRect& r)
-{
- HTMLMediaElement* mediaElement = getMediaElementFromRenderObject(o->parent());
- if (!mediaElement)
- return false;
-
- StylePainter p(paintInfo);
- if (!p.isValid())
- return true;
-
- p.painter->setRenderHint(QPainter::Antialiasing, true);
-
- p.painter->setPen(Qt::NoPen);
- p.painter->setBrush(getMediaControlForegroundColor(o));
- p.painter->drawRect(r.x(), r.y(), r.width(), r.height());
-
- return false;
-}
-#endif
-
-void RenderThemeQt::adjustSliderThumbSize(RenderObject* o) const
-{
- if (o->style()->appearance() == MediaSliderThumbPart) {
- RenderStyle* parentStyle = o->parent()->style();
- Q_ASSERT(parentStyle);
-
- int parentHeight = parentStyle->height().value();
- o->style()->setWidth(Length(parentHeight / 3, Fixed));
- o->style()->setHeight(Length(parentHeight, Fixed));
- }
-}
-
-}
-
-// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/qt/RenderThemeQt.h b/WebCore/platform/qt/RenderThemeQt.h
deleted file mode 100644
index 76e1855..0000000
--- a/WebCore/platform/qt/RenderThemeQt.h
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * This file is part of the theme implementation for form controls in WebCore.
- *
- * Copyright (C) 2007 Trolltech
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-#ifndef RenderThemeQt_H
-#define RenderThemeQt_H
-
-#include "RenderTheme.h"
-
-#include <QStyle>
-
-QT_BEGIN_NAMESPACE
-class QPainter;
-class QWidget;
-QT_END_NAMESPACE
-
-namespace WebCore {
-
-class RenderStyle;
-class HTMLMediaElement;
-
-class RenderThemeQt : public RenderTheme
-{
-public:
- RenderThemeQt();
- virtual ~RenderThemeQt();
-
- virtual bool supportsHover(const RenderStyle*) const;
- virtual bool supportsFocusRing(const RenderStyle* style) const;
-
- virtual int baselinePosition(const RenderObject* o) const;
-
- // A method asking if the control changes its tint when the window has focus or not.
- virtual bool controlSupportsTints(const RenderObject*) const;
-
- // A general method asking if any control tinting is supported at all.
- virtual bool supportsControlTints() const;
-
- virtual void adjustRepaintRect(const RenderObject* o, IntRect& r);
-
- virtual bool isControlStyled(const RenderStyle*, const BorderData&,
- const FillLayer&, const Color&) const;
-
- // The platform selection color.
- virtual Color platformActiveSelectionBackgroundColor() const;
- virtual Color platformInactiveSelectionBackgroundColor() const;
- virtual Color platformActiveSelectionForegroundColor() const;
- virtual Color platformInactiveSelectionForegroundColor() const;
-
- virtual void systemFont(int propId, FontDescription&) const;
-
- virtual int minimumMenuListSize(RenderStyle*) const;
-
- virtual void adjustSliderThumbSize(RenderObject*) const;
-
-protected:
- virtual bool paintCheckbox(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r);
- virtual void setCheckboxSize(RenderStyle*) const;
-
- virtual bool paintRadio(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r);
- virtual void setRadioSize(RenderStyle*) const;
-
- virtual void adjustButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
- virtual bool paintButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
- virtual void setButtonSize(RenderStyle*) const;
-
- virtual bool paintTextField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
- virtual void adjustTextFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
-
- virtual bool paintTextArea(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
- virtual void adjustTextAreaStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
-
- virtual bool paintMenuList(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r);
- virtual void adjustMenuListStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
-
- virtual bool paintMenuListButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
- virtual void adjustMenuListButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
-
- virtual bool paintSliderTrack(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
- virtual bool paintSliderThumb(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
-
- virtual bool paintSearchField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
- virtual void adjustSearchFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
-
- virtual void adjustSearchFieldCancelButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
- virtual bool paintSearchFieldCancelButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
-
- virtual void adjustSearchFieldDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
- virtual bool paintSearchFieldDecoration(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
-
- virtual void adjustSearchFieldResultsDecorationStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
- virtual bool paintSearchFieldResultsDecoration(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
-
-#if ENABLE(VIDEO)
- virtual bool paintMediaFullscreenButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
- virtual bool paintMediaPlayButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
- virtual bool paintMediaMuteButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
- virtual bool paintMediaSeekBackButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
- virtual bool paintMediaSeekForwardButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
- virtual bool paintMediaSliderTrack(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
- virtual bool paintMediaSliderThumb(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
-
-private:
- HTMLMediaElement* getMediaElementFromRenderObject(RenderObject* o) const;
- void paintMediaBackground(QPainter* painter, const IntRect& r) const;
- QColor getMediaControlForegroundColor(RenderObject* o = 0) const;
-#endif
-
-private:
- bool supportsFocus(ControlPart) const;
-
- ControlPart applyTheme(QStyleOption&, RenderObject*) const;
-
- void setButtonPadding(RenderStyle*) const;
- void setPopupPadding(RenderStyle*) const;
-
-#ifdef Q_WS_MAC
- int m_buttonFontPixelSize;
-#endif
- QString m_buttonFontFamily;
-
- QStyle* m_fallbackStyle;
- QStyle* fallbackStyle();
-};
-
-class StylePainter
-{
-public:
- explicit StylePainter(const RenderObject::PaintInfo& paintInfo);
- explicit StylePainter(GraphicsContext* context);
- ~StylePainter();
-
- bool isValid() const { return painter && style; }
-
- QPainter* painter;
- QWidget* widget;
- QStyle* style;
-
- void drawPrimitive(QStyle::PrimitiveElement pe, const QStyleOption& opt)
- { style->drawPrimitive(pe, &opt, painter, widget); }
- void drawControl(QStyle::ControlElement ce, const QStyleOption& opt)
- { style->drawControl(ce, &opt, painter, widget); }
- void drawComplexControl(QStyle::ComplexControl cc, const QStyleOptionComplex& opt)
- { style->drawComplexControl(cc, &opt, painter, widget); }
-
-private:
- void init(GraphicsContext* context);
-
- QBrush oldBrush;
- bool oldAntialiasing;
-
- Q_DISABLE_COPY(StylePainter)
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/qt/ScreenQt.cpp b/WebCore/platform/qt/ScreenQt.cpp
deleted file mode 100644
index eda1446..0000000
--- a/WebCore/platform/qt/ScreenQt.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (C) 2006 Dirk Mueller <mueller@kde.org>
- * (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Screen.h"
-
-#include "Page.h"
-#include "Frame.h"
-#include "FrameView.h"
-#include "Widget.h"
-#include "IntRect.h"
-#include "FloatRect.h"
-
-#include <QApplication>
-#include <QDesktopWidget>
-
-namespace WebCore {
-
-static QWidget* qwidgetForPage(const Page* page)
-{
- Frame* frame = (page ? page->mainFrame() : 0);
- FrameView* frameView = (frame ? frame->view() : 0);
-
- if (!frameView)
- return 0;
-
- return frameView->qwidget();
-}
-
-FloatRect screenRect(const Page* page)
-{
- QWidget* qw = qwidgetForPage(page);
- if (!qw)
- return FloatRect();
-
- // Taken from KGlobalSettings::desktopGeometry
- QDesktopWidget* dw = QApplication::desktop();
- if (!dw)
- return FloatRect();
-
- return IntRect(dw->screenGeometry(qw));
-}
-
-int screenDepth(const Page* page)
-{
- QWidget* qw = qwidgetForPage(page);
- if (!qw)
- return 32;
-
- return qw->depth();
-}
-
-FloatRect usableScreenRect(const Page* page)
-{
- QWidget* qw = qwidgetForPage(page);
- if (!qw)
- return FloatRect();
-
- // Taken from KGlobalSettings::desktopGeometry
- QDesktopWidget* dw = QApplication::desktop();
- if (!dw)
- return FloatRect();
-
- return IntRect(dw->availableGeometry(qw));
-}
-
-float scaleFactor(const Page*)
-{
- return 1.0f;
-}
-
-}
-
-// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/qt/ScrollViewQt.cpp b/WebCore/platform/qt/ScrollViewQt.cpp
deleted file mode 100644
index 76d9f01..0000000
--- a/WebCore/platform/qt/ScrollViewQt.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2006 Dirk Mueller <mueller@kde.org>
- * Copyright (C) 2006 Zack Rusin <zack@kde.org>
- * Copyright (C) 2006 George Staikos <staikos@kde.org>
- * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ScrollView.h"
-
-namespace WebCore {
-
-void ScrollView::platformInit()
-{
- m_widgetsThatPreventBlitting = 0;
-}
-
-void ScrollView::platformDestroy()
-{
-}
-
-void ScrollView::platformAddChild(Widget* child)
-{
- root()->m_widgetsThatPreventBlitting++;
- if (parent())
- parent()->platformAddChild(child);
-}
-
-void ScrollView::platformRemoveChild(Widget* child)
-{
- ASSERT(root()->m_widgetsThatPreventBlitting);
- root()->m_widgetsThatPreventBlitting--;
- child->hide();
-}
-
-}
-
-// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/qt/ScrollbarQt.cpp b/WebCore/platform/qt/ScrollbarQt.cpp
deleted file mode 100644
index 2d65282..0000000
--- a/WebCore/platform/qt/ScrollbarQt.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2007 Staikos Computing Services Inc. <info@staikos.net>
- * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Scrollbar.h"
-
-#include "EventHandler.h"
-#include "FrameView.h"
-#include "Frame.h"
-#include "GraphicsContext.h"
-#include "IntRect.h"
-#include "PlatformMouseEvent.h"
-#include "ScrollbarTheme.h"
-
-#include <QApplication>
-#include <QDebug>
-#include <QPainter>
-#include <QStyle>
-#include <QMenu>
-
-using namespace std;
-
-namespace WebCore {
-
-bool Scrollbar::contextMenu(const PlatformMouseEvent& event)
-{
-#ifndef QT_NO_CONTEXTMENU
- bool horizontal = (m_orientation == HorizontalScrollbar);
-
- QMenu menu;
- QAction* actScrollHere = menu.addAction(QCoreApplication::translate("QWebPage", "Scroll here"));
- menu.addSeparator();
-
- QAction* actScrollTop = menu.addAction(horizontal ? QCoreApplication::translate("QWebPage", "Left edge") : QCoreApplication::translate("QWebPage", "Top"));
- QAction* actScrollBottom = menu.addAction(horizontal ? QCoreApplication::translate("QWebPage", "Right edge") : QCoreApplication::translate("QWebPage", "Bottom"));
- menu.addSeparator();
-
- QAction* actPageUp = menu.addAction(horizontal ? QCoreApplication::translate("QWebPage", "Page left") : QCoreApplication::translate("QWebPage", "Page up"));
- QAction* actPageDown = menu.addAction(horizontal ? QCoreApplication::translate("QWebPage", "Page right") : QCoreApplication::translate("QWebPage", "Page down"));
- menu.addSeparator();
-
- QAction* actScrollUp = menu.addAction(horizontal ? QCoreApplication::translate("QWebPage", "Scroll left") : QCoreApplication::translate("QWebPage", "Scroll up"));
- QAction* actScrollDown = menu.addAction(horizontal ? QCoreApplication::translate("QWebPage", "Scroll right") : QCoreApplication::translate("QWebPage", "Scroll down"));
-
- const QPoint globalPos = QPoint(event.globalX(), event.globalY());
- QAction* actionSelected = menu.exec(globalPos);
-
- if (actionSelected == 0)
- /* Do nothing */ ;
- else if (actionSelected == actScrollHere) {
- const QPoint pos = convertFromContainingWindow(event.pos());
- moveThumb(horizontal ? pos.x() : pos.y());
- } else if (actionSelected == actScrollTop)
- setValue(0);
- else if (actionSelected == actScrollBottom)
- setValue(maximum());
- else if (actionSelected == actPageUp)
- scroll(horizontal ? ScrollLeft: ScrollUp, ScrollByPage, 1);
- else if (actionSelected == actPageDown)
- scroll(horizontal ? ScrollRight : ScrollDown, ScrollByPage, 1);
- else if (actionSelected == actScrollUp)
- scroll(horizontal ? ScrollLeft : ScrollUp, ScrollByLine, 1);
- else if (actionSelected == actScrollDown)
- scroll(horizontal ? ScrollRight : ScrollDown, ScrollByLine, 1);
-#endif // QT_NO_CONTEXTMENU
- return true;
-}
-
-}
-
-// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/qt/ScrollbarThemeQt.cpp b/WebCore/platform/qt/ScrollbarThemeQt.cpp
deleted file mode 100644
index 1995719..0000000
--- a/WebCore/platform/qt/ScrollbarThemeQt.cpp
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * Copyright (C) 2007, 2008 Apple Inc. All Rights Reserved.
- * Copyright (C) 2007 Staikos Computing Services Inc. <info@staikos.net>
- * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ScrollbarThemeQt.h"
-
-#include "GraphicsContext.h"
-#include "PlatformMouseEvent.h"
-#include "RenderThemeQt.h"
-#include "Scrollbar.h"
-#include "ScrollView.h"
-
-#include <QApplication>
-#include <QDebug>
-#include <QPainter>
-#include <QStyle>
-#include <QStyleOptionSlider>
-#include <QMenu>
-
-namespace WebCore {
-
-ScrollbarTheme* ScrollbarTheme::nativeTheme()
-{
- static ScrollbarThemeQt theme;
- return &theme;
-}
-
-ScrollbarThemeQt::~ScrollbarThemeQt()
-{
-}
-
-static QStyle::SubControl scPart(const ScrollbarPart& part)
-{
- switch (part) {
- case NoPart:
- return QStyle::SC_None;
- case BackButtonStartPart:
- case BackButtonEndPart:
- return QStyle::SC_ScrollBarSubLine;
- case BackTrackPart:
- return QStyle::SC_ScrollBarSubPage;
- case ThumbPart:
- return QStyle::SC_ScrollBarSlider;
- case ForwardTrackPart:
- return QStyle::SC_ScrollBarAddPage;
- case ForwardButtonStartPart:
- case ForwardButtonEndPart:
- return QStyle::SC_ScrollBarAddLine;
- }
-
- return QStyle::SC_None;
-}
-
-static ScrollbarPart scrollbarPart(const QStyle::SubControl& sc)
-{
- switch (sc) {
- case QStyle::SC_None:
- return NoPart;
- case QStyle::SC_ScrollBarSubLine:
- return BackButtonStartPart;
- case QStyle::SC_ScrollBarSubPage:
- return BackTrackPart;
- case QStyle::SC_ScrollBarSlider:
- return ThumbPart;
- case QStyle::SC_ScrollBarAddPage:
- return ForwardTrackPart;
- case QStyle::SC_ScrollBarAddLine:
- return ForwardButtonStartPart;
- }
- return NoPart;
-}
-
-static QStyleOptionSlider* styleOptionSlider(Scrollbar* scrollbar)
-{
- static QStyleOptionSlider opt;
- opt.rect = scrollbar->frameRect();
- opt.state = 0;
- if (scrollbar->enabled())
- opt.state |= QStyle::State_Enabled;
- if (scrollbar->controlSize() != RegularScrollbar)
- opt.state |= QStyle::State_Mini;
- opt.orientation = (scrollbar->orientation() == VerticalScrollbar) ? Qt::Vertical : Qt::Horizontal;
- if (scrollbar->orientation() == HorizontalScrollbar)
- opt.state |= QStyle::State_Horizontal;
- opt.sliderValue = scrollbar->value();
- opt.sliderPosition = opt.sliderValue;
- opt.pageStep = scrollbar->visibleSize();
- opt.singleStep = scrollbar->lineStep();
- opt.minimum = 0;
- opt.maximum = qMax(0, scrollbar->maximum());
- ScrollbarPart pressedPart = scrollbar->pressedPart();
- ScrollbarPart hoveredPart = scrollbar->hoveredPart();
- if (pressedPart != NoPart) {
- opt.activeSubControls = scPart(scrollbar->pressedPart());
- if (pressedPart == BackButtonStartPart || pressedPart == ForwardButtonStartPart ||
- pressedPart == BackButtonEndPart || pressedPart == ForwardButtonEndPart ||
- pressedPart == ThumbPart)
- opt.state |= QStyle::State_Sunken;
- } else
- opt.activeSubControls = scPart(hoveredPart);
- if (hoveredPart != NoPart)
- opt.state |= QStyle::State_MouseOver;
- return &opt;
-}
-
-bool ScrollbarThemeQt::paint(Scrollbar* scrollbar, GraphicsContext* graphicsContext, const IntRect& damageRect)
-{
- if (graphicsContext->updatingControlTints()) {
- scrollbar->invalidateRect(damageRect);
- return false;
- }
-
- StylePainter p(graphicsContext);
- if (!p.isValid())
- return true;
-
- p.painter->save();
- QStyleOptionSlider* opt = styleOptionSlider(scrollbar);
- p.painter->setClipRect(opt->rect.intersected(damageRect));
-
-#ifdef Q_WS_MAC
- p.drawComplexControl(QStyle::CC_ScrollBar, *opt);
-#else
- const QPoint topLeft = opt->rect.topLeft();
- p.painter->translate(topLeft);
- opt->rect.moveTo(QPoint(0, 0));
-
- // The QStyle expects the background to be already filled
- p.painter->fillRect(opt->rect, opt->palette.background());
-
- p.drawComplexControl(QStyle::CC_ScrollBar, *opt);
- opt->rect.moveTo(topLeft);
-#endif
- p.painter->restore();
-
- return true;
-}
-
-ScrollbarPart ScrollbarThemeQt::hitTest(Scrollbar* scrollbar, const PlatformMouseEvent& evt)
-{
- QStyleOptionSlider* opt = styleOptionSlider(scrollbar);
- const QPoint pos = scrollbar->convertFromContainingWindow(evt.pos());
- opt->rect.moveTo(QPoint(0, 0));
- QStyle::SubControl sc = QApplication::style()->hitTestComplexControl(QStyle::CC_ScrollBar, opt, pos, 0);
- return scrollbarPart(sc);
-}
-
-bool ScrollbarThemeQt::shouldCenterOnThumb(Scrollbar*, const PlatformMouseEvent& evt)
-{
- // Middle click centers slider thumb (if supported)
- return QApplication::style()->styleHint(QStyle::SH_ScrollBar_MiddleClickAbsolutePosition) && evt.button() == MiddleButton;
-}
-
-void ScrollbarThemeQt::invalidatePart(Scrollbar* scrollbar, ScrollbarPart)
-{
- // FIXME: Do more precise invalidation.
- scrollbar->invalidate();
-}
-
-int ScrollbarThemeQt::scrollbarThickness(ScrollbarControlSize controlSize)
-{
- QStyle* s = QApplication::style();
- QStyleOptionSlider o;
- o.orientation = Qt::Vertical;
- o.state &= ~QStyle::State_Horizontal;
- if (controlSize != RegularScrollbar)
- o.state |= QStyle::State_Mini;
- return s->pixelMetric(QStyle::PM_ScrollBarExtent, &o, 0);
-}
-
-int ScrollbarThemeQt::thumbPosition(Scrollbar* scrollbar)
-{
- if (scrollbar->enabled())
- return (int)((float)scrollbar->currentPos() * (trackLength(scrollbar) - thumbLength(scrollbar)) / scrollbar->maximum());
- return 0;
-}
-
-int ScrollbarThemeQt::thumbLength(Scrollbar* scrollbar)
-{
- QStyleOptionSlider* opt = styleOptionSlider(scrollbar);
- IntRect thumb = QApplication::style()->subControlRect(QStyle::CC_ScrollBar, opt, QStyle::SC_ScrollBarSlider, 0);
- return scrollbar->orientation() == HorizontalScrollbar ? thumb.width() : thumb.height();
-}
-
-int ScrollbarThemeQt::trackPosition(Scrollbar* scrollbar)
-{
- QStyleOptionSlider* opt = styleOptionSlider(scrollbar);
- IntRect track = QApplication::style()->subControlRect(QStyle::CC_ScrollBar, opt, QStyle::SC_ScrollBarGroove, 0);
- return scrollbar->orientation() == HorizontalScrollbar ? track.x() - scrollbar->x() : track.y() - scrollbar->y();
-}
-
-int ScrollbarThemeQt::trackLength(Scrollbar* scrollbar)
-{
- QStyleOptionSlider* opt = styleOptionSlider(scrollbar);
- IntRect track = QApplication::style()->subControlRect(QStyle::CC_ScrollBar, opt, QStyle::SC_ScrollBarGroove, 0);
- return scrollbar->orientation() == HorizontalScrollbar ? track.width() : track.height();
-}
-
-void ScrollbarThemeQt::paintScrollCorner(ScrollView* scrollView, GraphicsContext* context, const IntRect& rect)
-{
- if (context->updatingControlTints()) {
- scrollView->invalidateRect(rect);
- return;
- }
-
-#if QT_VERSION < 0x040500
- context->fillRect(rect, QApplication::palette().color(QPalette::Normal, QPalette::Window));
-#else
- StylePainter p(context);
- if (!p.isValid())
- return;
-
- QStyleOption option;
- option.rect = rect;
- p.drawPrimitive(QStyle::PE_PanelScrollAreaCorner, option);
-#endif
-}
-
-}
-
diff --git a/WebCore/platform/qt/ScrollbarThemeQt.h b/WebCore/platform/qt/ScrollbarThemeQt.h
deleted file mode 100644
index 787b15a..0000000
--- a/WebCore/platform/qt/ScrollbarThemeQt.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ScrollbarThemeQt_h
-#define ScrollbarThemeQt_h
-
-#include "ScrollbarTheme.h"
-
-namespace WebCore {
-
-class ScrollbarThemeQt : public ScrollbarTheme {
-public:
- virtual ~ScrollbarThemeQt();
-
- virtual bool paint(Scrollbar*, GraphicsContext*, const IntRect& damageRect);
- virtual void paintScrollCorner(ScrollView*, GraphicsContext*, const IntRect& cornerRect);
-
- virtual ScrollbarPart hitTest(Scrollbar*, const PlatformMouseEvent&);
-
- virtual bool shouldCenterOnThumb(Scrollbar*, const PlatformMouseEvent&);
-
- virtual void invalidatePart(Scrollbar*, ScrollbarPart);
-
- virtual int thumbPosition(Scrollbar*);
- virtual int thumbLength(Scrollbar*);
- virtual int trackPosition(Scrollbar*);
- virtual int trackLength(Scrollbar*);
-
- virtual int scrollbarThickness(ScrollbarControlSize = RegularScrollbar);
-};
-
-}
-#endif
diff --git a/WebCore/platform/qt/SearchPopupMenuQt.cpp b/WebCore/platform/qt/SearchPopupMenuQt.cpp
deleted file mode 100644
index 7822b2c..0000000
--- a/WebCore/platform/qt/SearchPopupMenuQt.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright C 2006 Zack Rusin <zack@kde.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-#include "SearchPopupMenu.h"
-
-#include "AtomicString.h"
-
-namespace WebCore {
-
-SearchPopupMenu::SearchPopupMenu(PopupMenuClient* client)
- : PopupMenu(client)
-{
-}
-
-void SearchPopupMenu::saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems)
-{
-}
-
-void SearchPopupMenu::loadRecentSearches(const AtomicString& name, Vector<String>& searchItems)
-{
-}
-
-bool SearchPopupMenu::enabled()
-{
- return true;
-}
-
-}
diff --git a/WebCore/platform/qt/SharedBufferQt.cpp b/WebCore/platform/qt/SharedBufferQt.cpp
deleted file mode 100644
index 38ba6d1..0000000
--- a/WebCore/platform/qt/SharedBufferQt.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2008 Holger Hans Peter Freyther
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "SharedBuffer.h"
-
-#include <QFile>
-
-namespace WebCore {
-
-PassRefPtr<SharedBuffer> SharedBuffer::createWithContentsOfFile(const String& fileName)
-{
- if (fileName.isEmpty())
- return 0;
-
- QFile file(fileName);
- if (!file.exists() || !file.open(QFile::ReadOnly))
- return 0;
-
-
- RefPtr<SharedBuffer> result = SharedBuffer::create();
- result->m_buffer.resize(file.size());
- if (result->m_buffer.size() != file.size())
- return 0;
-
- file.read(result->m_buffer.data(), result->m_buffer.size());
- return result.release();
-}
-
-}
diff --git a/WebCore/platform/qt/SharedTimerQt.cpp b/WebCore/platform/qt/SharedTimerQt.cpp
deleted file mode 100644
index 49f55c1..0000000
--- a/WebCore/platform/qt/SharedTimerQt.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2006 George Staikos <staikos@kde.org>
- * Copyright (C) 2006 Dirk Mueller <mueller@kde.org>
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "SharedTimerQt.h"
-
-#include <QApplication>
-
-namespace WebCore {
-
-SharedTimerQt* SharedTimerQt::s_self = 0; // FIXME: staticdeleter
-
-void setSharedTimerFiredFunction(void (*f)())
-{
- SharedTimerQt::inst()->m_timerFunction = f;
-}
-
-void setSharedTimerFireTime(double fireTime)
-{
- if (!qApp)
- return;
-
- qreal fireTimeMs = (fireTime - currentTime()) * 1000;
- SharedTimerQt::inst()->start(qMax(0, int(fireTimeMs)));
-}
-
-void stopSharedTimer()
-{
- SharedTimerQt::inst()->stop();
-}
-
-}
-
-// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/qt/SharedTimerQt.h b/WebCore/platform/qt/SharedTimerQt.h
deleted file mode 100644
index 30e1e21..0000000
--- a/WebCore/platform/qt/SharedTimerQt.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2006 George Staikos <staikos@kde.org>
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef SharedTimerQt_h
-#define SharedTimerQt_h
-
-#include "SharedTimerQt.h"
-#include "SystemTime.h"
-
-#include <QTimer>
-#include <QCoreApplication>
-
-namespace WebCore {
-
-class SharedTimerQt : public QTimer {
-Q_OBJECT
-protected:
- SharedTimerQt()
- : QTimer()
- , m_timerFunction(0)
- {
- connect(this, SIGNAL(timeout()), this, SLOT(fire()));
- setSingleShot(true);
- }
-
- ~SharedTimerQt()
- {
- }
-
-public:
- static void cleanup()
- {
- if (s_self->isActive())
- s_self->fire();
-
- delete s_self;
- s_self = 0;
- }
-
- static SharedTimerQt* inst()
- {
- if (!s_self) {
- s_self = new SharedTimerQt();
- qAddPostRoutine(SharedTimerQt::cleanup);
- }
-
- return s_self;
- }
-
- void (*m_timerFunction)();
-
-public Q_SLOTS:
- void fire()
- {
- if (m_timerFunction)
- (m_timerFunction)();
- }
-
-private:
- static SharedTimerQt* s_self;
-};
-
-}
-
-#endif
-
-// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/qt/SoundQt.cpp b/WebCore/platform/qt/SoundQt.cpp
deleted file mode 100644
index 0996328..0000000
--- a/WebCore/platform/qt/SoundQt.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include <QApplication>
-
-#include "Sound.h"
-
-namespace WebCore {
-
-void systemBeep()
-{
- QApplication::beep();
-}
-
-}
-
-// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/qt/SystemTimeQt.cpp b/WebCore/platform/qt/SystemTimeQt.cpp
deleted file mode 100644
index a9f3d98..0000000
--- a/WebCore/platform/qt/SystemTimeQt.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2006 Dirk Mueller <mueller@kde.org>
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "SystemTime.h"
-
-#include <sys/time.h>
-
-namespace WebCore {
-
-double currentTime()
-{
- struct timeval tv;
- struct timezone tz;
-
- gettimeofday(&tv, &tz);
- return (double)tv.tv_sec + (double)(tv.tv_usec / 1000000.0);
-}
-
-}
-
-// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/qt/TemporaryLinkStubs.cpp b/WebCore/platform/qt/TemporaryLinkStubs.cpp
deleted file mode 100644
index f262684..0000000
--- a/WebCore/platform/qt/TemporaryLinkStubs.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
- * Copyright (C) 2006 George Staikos <staikos@kde.org>
- * Copyright (C) 2006 Dirk Mueller <mueller@kde.org>
- * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
- * Copyright (C) 2008 Collabora, Ltd.
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "AXObjectCache.h"
-#include "DNS.h"
-#include "CString.h"
-#include "CachedResource.h"
-#include "CookieJar.h"
-#include "Cursor.h"
-#include "Font.h"
-#include "Frame.h"
-#include "FrameLoader.h"
-#include "FTPDirectoryDocument.h"
-#include "IntPoint.h"
-#include "Widget.h"
-#include "GraphicsContext.h"
-#include "Cursor.h"
-#include "loader.h"
-#include "FileSystem.h"
-#include "FrameView.h"
-#include "GraphicsContext.h"
-#include "IconLoader.h"
-#include "IntPoint.h"
-#include "KURL.h"
-#include "Language.h"
-#include "loader.h"
-#include "LocalizedStrings.h"
-#include "Node.h"
-#include "NotImplemented.h"
-#include "Path.h"
-#include "PlatformMouseEvent.h"
-#include "PluginDatabase.h"
-#include "PluginPackage.h"
-#include "PluginView.h"
-#include "RenderTheme.h"
-#include "SharedBuffer.h"
-#include "SystemTime.h"
-#include "TextBoundaries.h"
-#include "Widget.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <float.h>
-
-using namespace WebCore;
-
-#if !defined(Q_WS_X11) && !defined(Q_WS_WIN)
-
-bool PluginPackage::fetchInfo() { notImplemented(); return false; }
-unsigned PluginPackage::hash() const { notImplemented(); return 0; }
-bool PluginPackage::equal(const PluginPackage&, const PluginPackage&) { notImplemented(); return false; }
-int PluginPackage::compareFileVersion(const PlatformModuleVersion&) const { notImplemented(); return -1; }
-
-void PluginView::setNPWindowRect(const IntRect&) { notImplemented(); }
-const char* PluginView::userAgent() { notImplemented(); return 0; }
-void PluginView::invalidateRect(NPRect*) { notImplemented(); }
-void PluginView::invalidateRegion(NPRegion) { notImplemented(); }
-void PluginView::forceRedraw() { notImplemented(); }
-void PluginView::setFocus() { Widget::setFocus(); }
-void PluginView::show() { Widget::show(); }
-void PluginView::hide() { Widget::hide(); }
-void PluginView::paint(GraphicsContext*, const IntRect&) { notImplemented(); }
-void PluginView::setParent(ScrollView* view) { Widget::setParent(view); }
-void PluginView::setParentVisible(bool) { notImplemented(); }
-void PluginView::updatePluginWidget() const { notImplemented(); }
-void PluginView::handleKeyboardEvent(KeyboardEvent*) { notImplemented(); }
-void PluginView::handleMouseEvent(MouseEvent*) { notImplemented(); }
-NPError PluginView::handlePostReadFile(Vector<char>&, uint32, const char*) { notImplemented(); return NPERR_GENERIC_ERROR; }
-NPError PluginView::getValue(NPNVariable, void*) { notImplemented(); return NPERR_GENERIC_ERROR; }
-PluginView::~PluginView() {}
-#endif
-
-namespace WebCore {
-
-void getSupportedKeySizes(Vector<String>&) { notImplemented(); }
-String signedPublicKeyAndChallengeString(unsigned keySizeIndex, const String &challengeString, const KURL &url) { return String(); }
-
-#if !defined(Q_OS_WIN)
-// defined in win/SystemTimeWin.cpp, which is compiled for the Qt/Windows port
-float userIdleTime() { notImplemented(); return FLT_MAX; } // return an arbitrarily high userIdleTime so that releasing pages from the page cache isn't postponed
-#endif
-
-void prefetchDNS(const String& hostname) { notImplemented(); }
-
-}
-
-// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/qt/WebCoreResources.qrc b/WebCore/platform/qt/WebCoreResources.qrc
deleted file mode 100644
index e42cd7f..0000000
--- a/WebCore/platform/qt/WebCoreResources.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource prefix="/webcore/resources">
- <file>html4-adjustments-qt.css</file>
-</qresource>
-</RCC> \ No newline at end of file
diff --git a/WebCore/platform/qt/WheelEventQt.cpp b/WebCore/platform/qt/WheelEventQt.cpp
deleted file mode 100644
index 135f15a..0000000
--- a/WebCore/platform/qt/WheelEventQt.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include "config.h"
-#include "PlatformWheelEvent.h"
-
-#include "PlatformMouseEvent.h"
-
-#include <QWheelEvent>
-
-namespace WebCore {
-
-
-PlatformWheelEvent::PlatformWheelEvent(QWheelEvent* e)
-#ifdef QT_NO_WHEELEVENT
-{
- Q_UNUSED(e);
-}
-#else
- : m_position(e->pos())
- , m_globalPosition(e->globalPos())
- , m_granularity(ScrollByLineWheelEvent)
- , m_isAccepted(false)
- , m_shiftKey(e->modifiers() & Qt::ShiftModifier)
- , m_ctrlKey(e->modifiers() & Qt::ControlModifier)
- , m_altKey(e->modifiers() & Qt::AltModifier)
- , m_metaKey(e->modifiers() & Qt::MetaModifier)
-{
- if (e->orientation() == Qt::Horizontal) {
- m_deltaX = (e->delta() / 120);
- m_deltaY = 0;
- } else {
- m_deltaX = 0;
- m_deltaY = (e->delta() / 120);
- }
-
- // FIXME: retrieve the user setting for the number of lines to scroll on each wheel event
- m_deltaX *= horizontalLineMultiplier();
- m_deltaY *= verticalLineMultiplier();
-}
-#endif // QT_NO_WHEELEVENT
-
-} // namespace WebCore
diff --git a/WebCore/platform/qt/WidgetQt.cpp b/WebCore/platform/qt/WidgetQt.cpp
deleted file mode 100644
index 68cf383..0000000
--- a/WebCore/platform/qt/WidgetQt.cpp
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (C) 2006 Dirk Mueller <mueller@kde.org>
- * Copyright (C) 2006 George Stiakos <staikos@kde.org>
- * Copyright (C) 2006 Zack Rusin <zack@kde.org>
- * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
- * Copyright (C) 2008 Holger Hans Peter Freyther
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "Cursor.h"
-#include "Font.h"
-#include "GraphicsContext.h"
-#include "HostWindow.h"
-#include "IntRect.h"
-#include "ScrollView.h"
-#include "Widget.h"
-#include "NotImplemented.h"
-
-#include "qwebframe.h"
-#include "qwebframe_p.h"
-#include "qwebpage.h"
-
-#include <QCoreApplication>
-#include <QPainter>
-#include <QPaintEngine>
-
-#include <QDebug>
-
-namespace WebCore {
-
-Widget::Widget(QWidget* widget)
-{
- init(widget);
-}
-
-Widget::~Widget()
-{
- Q_ASSERT(!parent());
-}
-
-IntRect Widget::frameRect() const
-{
- return m_frame;
-}
-
-void Widget::setFrameRect(const IntRect& rect)
-{
- if (platformWidget())
- platformWidget()->setGeometry(convertToContainingWindow(IntRect(0, 0, rect.width(), rect.height())));
- m_frame = rect;
-}
-
-void Widget::setFocus()
-{
-}
-
-void Widget::setCursor(const Cursor& cursor)
-{
-#ifndef QT_NO_CURSOR
- if (QWidget* widget = root()->hostWindow()->platformWindow())
- QCoreApplication::postEvent(widget, new SetCursorEvent(cursor.impl()));
-#endif
-}
-
-void Widget::show()
-{
- if (platformWidget())
- platformWidget()->show();
-}
-
-void Widget::hide()
-{
- if (platformWidget())
- platformWidget()->hide();
-}
-
-void Widget::paint(GraphicsContext *, const IntRect &rect)
-{
-}
-
-void Widget::setIsSelected(bool)
-{
- notImplemented();
-}
-
-}
-
-// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/qt/html4-adjustments-qt.css b/WebCore/platform/qt/html4-adjustments-qt.css
deleted file mode 100644
index 129c164..0000000
--- a/WebCore/platform/qt/html4-adjustments-qt.css
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * QtWebKit specific style sheet.
- *
- * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-audio {
- height: 34px;
- width: 400px;
-}
-
-audio::-webkit-media-controls-mute-button, video::-webkit-media-controls-mute-button {
- left: auto;
- right: 5px;
- width: 12px;
- height: 12px;
- padding: 6px;
- margin: 5px 0px;
-}
-
-audio::-webkit-media-controls-play-button, video::-webkit-media-controls-play-button {
- left: 5px;
- width: 9px;
- height: 12px;
- padding: 6px 12px 6px 11px;
- margin: 5px 0px;
-}
-
-audio::-webkit-media-controls-time-display, video::-webkit-media-controls-time-display {
- /* Since MediaControlElements are always created with a renderer we have to hide
- the controls we don't use, so they don't mess up activation and event handling */
- left: 0px;
- top: 0px;
- width: 0px;
- height: 0px;
-
- display: none;
-}
-
-audio::-webkit-media-controls-timeline, video::-webkit-media-controls-timeline {
- left: 42px;
- right: 34px;
- height: 12px;
- padding: 6px 8px;
- margin: 5px 0px;
-}
-
-audio::-webkit-media-controls-seek-back-button, video::-webkit-media-controls-seek-back-button {
- /* Since MediaControlElements are always created with a renderer we have to hide
- the controls we don't use, so they don't mess up activation and event handling */
- left: 0px;
- top: 0px;
- width: 0px;
- height: 0px;
-
- display: none;
-}
-
-audio::-webkit-media-controls-seek-forward-button, video::-webkit-media-controls-seek-forward-button {
- /* Since MediaControlElements are always created with a renderer we have to hide
- the controls we don't use, so they don't mess up activation and event handling */
- left: 0px;
- top: 0px;
- width: 0px;
- height: 0px;
-
- display: none;
-}
-
-audio::-webkit-media-controls-fullscreen-button, video::-webkit-media-controls-fullscreen-button {
- /* Since MediaControlElements are always created with a renderer we have to hide
- the controls we don't use, so they don't mess up activation and event handling */
- left: 0px;
- top: 0px;
- width: 0px;
- height: 0px;
-
- display: none;
-}
-
diff --git a/WebCore/platform/sql/SQLValue.cpp b/WebCore/platform/sql/SQLValue.cpp
deleted file mode 100644
index 7e178f9..0000000
--- a/WebCore/platform/sql/SQLValue.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following condition
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "SQLValue.h"
-
-namespace WebCore {
-
-SQLValue::SQLValue(const SQLValue& val)
-{
- m_number = val.m_number;
- m_string = val.m_string.copy();
- m_type = val.m_type;
-}
-
-String SQLValue::string() const
-{
- ASSERT(m_type == StringValue);
-
- // Must return a copy since ref-shared Strings are not thread safe
- return m_string.copy();
-}
-
-double SQLValue::number() const
-{
- ASSERT(m_type == NumberValue);
-
- return m_number;
-}
-
-}
diff --git a/WebCore/platform/sql/SQLValue.h b/WebCore/platform/sql/SQLValue.h
deleted file mode 100644
index 7d85051..0000000
--- a/WebCore/platform/sql/SQLValue.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following condition
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef SQLValue_h
-#define SQLValue_h
-
-#include "PlatformString.h"
-#include <wtf/Threading.h>
-
-namespace WebCore {
-
- class SQLValue {
- public:
- enum Type { NullValue, NumberValue, StringValue };
-
- SQLValue() : m_type(NullValue) { }
- SQLValue(double number) : m_type(NumberValue), m_number(number) { }
- SQLValue(const String& s) : m_type(StringValue), m_string(s) { }
- SQLValue(const SQLValue&);
-
- Type type() const { return m_type; }
-
- String string() const;
- double number() const;
-
- private:
- Type m_type;
- double m_number;
- String m_string;
- };
-};
-
-#endif
diff --git a/WebCore/platform/sql/SQLiteAuthorizer.cpp b/WebCore/platform/sql/SQLiteAuthorizer.cpp
deleted file mode 100644
index f9da260..0000000
--- a/WebCore/platform/sql/SQLiteAuthorizer.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following condition
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "config.h"
-#include "DatabaseAuthorizer.h"
-
-#include <sqlite3.h>
-
-namespace WebCore {
-
-const int SQLAuthAllow = SQLITE_OK;
-const int SQLAuthIgnore = SQLITE_IGNORE;
-const int SQLAuthDeny = SQLITE_DENY;
-
-} // namespace WebCore
diff --git a/WebCore/platform/sql/SQLiteDatabase.cpp b/WebCore/platform/sql/SQLiteDatabase.cpp
deleted file mode 100644
index 702cf02..0000000
--- a/WebCore/platform/sql/SQLiteDatabase.cpp
+++ /dev/null
@@ -1,353 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com)
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "SQLiteDatabase.h"
-
-#include "DatabaseAuthorizer.h"
-#include "Logging.h"
-#include "SQLiteStatement.h"
-
-#include <sqlite3.h>
-
-namespace WebCore {
-
-const int SQLResultDone = SQLITE_DONE;
-const int SQLResultError = SQLITE_ERROR;
-const int SQLResultOk = SQLITE_OK;
-const int SQLResultRow = SQLITE_ROW;
-const int SQLResultSchema = SQLITE_SCHEMA;
-const int SQLResultFull = SQLITE_FULL;
-
-
-SQLiteDatabase::SQLiteDatabase()
- : m_db(0)
- , m_pageSize(-1)
- , m_transactionInProgress(false)
- , m_openingThread(0)
-{
-}
-
-SQLiteDatabase::~SQLiteDatabase()
-{
- close();
-}
-
-bool SQLiteDatabase::open(const String& filename)
-{
- close();
-
- // SQLite expects a null terminator on its UTF-16 strings.
- String path = filename;
- m_lastError = sqlite3_open16(path.charactersWithNullTermination(), &m_db);
- if (m_lastError != SQLITE_OK) {
- LOG_ERROR("SQLite database failed to load from %s\nCause - %s", filename.ascii().data(),
- sqlite3_errmsg(m_db));
- sqlite3_close(m_db);
- m_db = 0;
- return false;
- }
-
- if (isOpen())
- m_openingThread = currentThread();
-
- if (!SQLiteStatement(*this, "PRAGMA temp_store = MEMORY;").executeCommand())
- LOG_ERROR("SQLite database could not set temp_store to memory");
-
- return isOpen();
-}
-
-void SQLiteDatabase::close()
-{
- if (m_db) {
- // FIXME: This is being called on themain thread during JS GC. <rdar://problem/5739818>
- // ASSERT(currentThread() == m_openingThread);
- sqlite3_close(m_db);
- m_db = 0;
- }
-
- m_openingThread = 0;
-}
-
-void SQLiteDatabase::setFullsync(bool fsync)
-{
- if (fsync)
- executeCommand("PRAGMA fullfsync = 1;");
- else
- executeCommand("PRAGMA fullfsync = 0;");
-}
-
-int64_t SQLiteDatabase::maximumSize()
-{
- MutexLocker locker(m_authorizerLock);
- enableAuthorizer(false);
-
- SQLiteStatement statement(*this, "PRAGMA max_page_count");
- int64_t size = statement.getColumnInt64(0) * pageSize();
-
- enableAuthorizer(true);
- return size;
-}
-
-void SQLiteDatabase::setMaximumSize(int64_t size)
-{
- if (size < 0)
- size = 0;
-
- int currentPageSize = pageSize();
-
- ASSERT(currentPageSize);
- int64_t newMaxPageCount = currentPageSize ? size / currentPageSize : 0;
-
- MutexLocker locker(m_authorizerLock);
- enableAuthorizer(false);
-
- SQLiteStatement statement(*this, "PRAGMA max_page_count = " + String::number(newMaxPageCount));
- statement.prepare();
- if (statement.step() != SQLResultRow)
- LOG_ERROR("Failed to set maximum size of database to %lli bytes", size);
-
- enableAuthorizer(true);
-
-}
-
-int SQLiteDatabase::pageSize()
-{
- // Since the page size of a database is locked in at creation and therefore cannot be dynamic,
- // we can cache the value for future use
- if (m_pageSize == -1) {
- MutexLocker locker(m_authorizerLock);
- enableAuthorizer(false);
-
- SQLiteStatement statement(*this, "PRAGMA page_size");
- m_pageSize = statement.getColumnInt(0);
-
- enableAuthorizer(true);
- }
-
- return m_pageSize;
-}
-
-void SQLiteDatabase::setSynchronous(SynchronousPragma sync)
-{
- executeCommand(String::format("PRAGMA synchronous = %i", sync));
-}
-
-void SQLiteDatabase::setBusyTimeout(int ms)
-{
- if (m_db)
- sqlite3_busy_timeout(m_db, ms);
- else
- LOG(SQLDatabase, "BusyTimeout set on non-open database");
-}
-
-void SQLiteDatabase::setBusyHandler(int(*handler)(void*, int))
-{
- if (m_db)
- sqlite3_busy_handler(m_db, handler, NULL);
- else
- LOG(SQLDatabase, "Busy handler set on non-open database");
-}
-
-bool SQLiteDatabase::executeCommand(const String& sql)
-{
- return SQLiteStatement(*this, sql).executeCommand();
-}
-
-bool SQLiteDatabase::returnsAtLeastOneResult(const String& sql)
-{
- return SQLiteStatement(*this, sql).returnsAtLeastOneResult();
-}
-
-bool SQLiteDatabase::tableExists(const String& tablename)
-{
- if (!isOpen())
- return false;
-
- String statement = "SELECT name FROM sqlite_master WHERE type = 'table' AND name = '" + tablename + "';";
-
- SQLiteStatement sql(*this, statement);
- sql.prepare();
- return sql.step() == SQLITE_ROW;
-}
-
-void SQLiteDatabase::clearAllTables()
-{
- String query = "SELECT name FROM sqlite_master WHERE type='table';";
- Vector<String> tables;
- if (!SQLiteStatement(*this, query).returnTextResults(0, tables)) {
- LOG(SQLDatabase, "Unable to retrieve list of tables from database");
- return;
- }
-
- for (Vector<String>::iterator table = tables.begin(); table != tables.end(); ++table ) {
- if (*table == "sqlite_sequence")
- continue;
- if (!executeCommand("DROP TABLE " + *table))
- LOG(SQLDatabase, "Unable to drop table %s", (*table).ascii().data());
- }
-}
-
-void SQLiteDatabase::runVacuumCommand()
-{
- if (!executeCommand("VACUUM;"))
- LOG(SQLDatabase, "Unable to vacuum database - %s", lastErrorMsg());
-}
-
-int64_t SQLiteDatabase::lastInsertRowID()
-{
- if (!m_db)
- return 0;
- return sqlite3_last_insert_rowid(m_db);
-}
-
-int SQLiteDatabase::lastChanges()
-{
- if (!m_db)
- return 0;
- return sqlite3_changes(m_db);
-}
-
-int SQLiteDatabase::lastError()
-{
- return m_db ? sqlite3_errcode(m_db) : SQLITE_ERROR;
-}
-
-const char* SQLiteDatabase::lastErrorMsg()
-{
- return sqlite3_errmsg(m_db);
-}
-
-int SQLiteDatabase::authorizerFunction(void* userData, int actionCode, const char* parameter1, const char* parameter2, const char* /*databaseName*/, const char* /*trigger_or_view*/)
-{
- DatabaseAuthorizer* auth = static_cast<DatabaseAuthorizer*>(userData);
- ASSERT(auth);
-
- switch (actionCode) {
- case SQLITE_CREATE_INDEX:
- return auth->createIndex(parameter1, parameter2);
- case SQLITE_CREATE_TABLE:
- return auth->createTable(parameter1);
- case SQLITE_CREATE_TEMP_INDEX:
- return auth->createTempIndex(parameter1, parameter2);
- case SQLITE_CREATE_TEMP_TABLE:
- return auth->createTempTable(parameter1);
- case SQLITE_CREATE_TEMP_TRIGGER:
- return auth->createTempTrigger(parameter1, parameter2);
- case SQLITE_CREATE_TEMP_VIEW:
- return auth->createTempView(parameter1);
- case SQLITE_CREATE_TRIGGER:
- return auth->createTrigger(parameter1, parameter2);
- case SQLITE_CREATE_VIEW:
- return auth->createView(parameter1);
- case SQLITE_DELETE:
- return auth->allowDelete(parameter1);
- case SQLITE_DROP_INDEX:
- return auth->dropIndex(parameter1, parameter2);
- case SQLITE_DROP_TABLE:
- return auth->dropTable(parameter1);
- case SQLITE_DROP_TEMP_INDEX:
- return auth->dropTempIndex(parameter1, parameter2);
- case SQLITE_DROP_TEMP_TABLE:
- return auth->dropTempTable(parameter1);
- case SQLITE_DROP_TEMP_TRIGGER:
- return auth->dropTempTrigger(parameter1, parameter2);
- case SQLITE_DROP_TEMP_VIEW:
- return auth->dropTempView(parameter1);
- case SQLITE_DROP_TRIGGER:
- return auth->dropTrigger(parameter1, parameter2);
- case SQLITE_DROP_VIEW:
- return auth->dropView(parameter1);
- case SQLITE_INSERT:
- return auth->allowInsert(parameter1);
- case SQLITE_PRAGMA:
- return auth->allowPragma(parameter1, parameter2);
- case SQLITE_READ:
- return auth->allowRead(parameter1, parameter2);
- case SQLITE_SELECT:
- return auth->allowSelect();
- case SQLITE_TRANSACTION:
- return auth->allowTransaction();
- case SQLITE_UPDATE:
- return auth->allowUpdate(parameter1, parameter2);
- case SQLITE_ATTACH:
- return auth->allowAttach(parameter1);
- case SQLITE_DETACH:
- return auth->allowDetach(parameter1);
- case SQLITE_ALTER_TABLE:
- return auth->allowAlterTable(parameter1, parameter2);
- case SQLITE_REINDEX:
- return auth->allowReindex(parameter1);
-#if SQLITE_VERSION_NUMBER >= 3003013
- case SQLITE_ANALYZE:
- return auth->allowAnalyze(parameter1);
- case SQLITE_CREATE_VTABLE:
- return auth->createVTable(parameter1, parameter2);
- case SQLITE_DROP_VTABLE:
- return auth->dropVTable(parameter1, parameter2);
- case SQLITE_FUNCTION:
- return auth->allowFunction(parameter1);
-#endif
- default:
- ASSERT_NOT_REACHED();
- return SQLAuthDeny;
- }
-}
-
-void SQLiteDatabase::setAuthorizer(PassRefPtr<DatabaseAuthorizer> auth)
-{
- if (!m_db) {
- LOG_ERROR("Attempt to set an authorizer on a non-open SQL database");
- ASSERT_NOT_REACHED();
- return;
- }
-
- MutexLocker locker(m_authorizerLock);
-
- m_authorizer = auth;
-
- enableAuthorizer(true);
-}
-
-void SQLiteDatabase::enableAuthorizer(bool enable)
-{
- if (m_authorizer && enable)
- sqlite3_set_authorizer(m_db, SQLiteDatabase::authorizerFunction, m_authorizer.get());
- else
- sqlite3_set_authorizer(m_db, NULL, 0);
-}
-
-void SQLiteDatabase::lock()
-{
- m_lockingMutex.lock();
-}
-
-void SQLiteDatabase::unlock()
-{
- m_lockingMutex.unlock();
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/sql/SQLiteDatabase.h b/WebCore/platform/sql/SQLiteDatabase.h
deleted file mode 100644
index 76700dc..0000000
--- a/WebCore/platform/sql/SQLiteDatabase.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com)
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef SQLDatabase_h
-#define SQLDatabase_h
-
-#include "PlatformString.h"
-#include <wtf/Threading.h>
-
-#if COMPILER(MSVC)
-#pragma warning(disable: 4800)
-#endif
-
-struct sqlite3;
-
-namespace WebCore {
-
-class DatabaseAuthorizer;
-class SQLiteStatement;
-class SQLiteTransaction;
-
-extern const int SQLResultDone;
-extern const int SQLResultError;
-extern const int SQLResultOk;
-extern const int SQLResultRow;
-extern const int SQLResultSchema;
-extern const int SQLResultFull;
-
-class SQLiteDatabase : public Noncopyable {
- friend class SQLiteTransaction;
-public:
- SQLiteDatabase();
- ~SQLiteDatabase();
-
- bool open(const String& filename);
- bool isOpen() const { return m_db; }
- void close();
-
- bool executeCommand(const String&);
- bool returnsAtLeastOneResult(const String&);
-
- bool tableExists(const String&);
- void clearAllTables();
- void runVacuumCommand();
-
- bool transactionInProgress() const { return m_transactionInProgress; }
-
- int64_t lastInsertRowID();
- int lastChanges();
-
- void setBusyTimeout(int ms);
- void setBusyHandler(int(*)(void*, int));
-
- void setFullsync(bool);
-
- // Gets/sets the maximum size in bytes
- // Depending on per-database attributes, the size will only be settable in units that are the page size of the database, which is established at creation
- // These chunks will never be anything other than 512, 1024, 2048, 4096, 8192, 16384, or 32768 bytes in size.
- // setMaximumSize() will round the size down to the next smallest chunk if the passed size doesn't align.
- int64_t maximumSize();
- void setMaximumSize(int64_t);
-
- // The SQLite SYNCHRONOUS pragma can be either FULL, NORMAL, or OFF
- // FULL - Any writing calls to the DB block until the data is actually on the disk surface
- // NORMAL - SQLite pauses at some critical moments when writing, but much less than FULL
- // OFF - Calls return immediately after the data has been passed to disk
- enum SynchronousPragma { SyncOff = 0, SyncNormal = 1, SyncFull = 2 };
- void setSynchronous(SynchronousPragma);
-
- int lastError();
- const char* lastErrorMsg();
-
- sqlite3* sqlite3Handle() const {
- ASSERT(currentThread() == m_openingThread);
- return m_db;
- }
-
- void setAuthorizer(PassRefPtr<DatabaseAuthorizer>);
-
- // (un)locks the database like a mutex
- void lock();
- void unlock();
-
-private:
- static int authorizerFunction(void*, int, const char*, const char*, const char*, const char*);
-
- void enableAuthorizer(bool enable);
-
- int pageSize();
-
- sqlite3* m_db;
- int m_lastError;
- int m_pageSize;
-
- bool m_transactionInProgress;
-
- Mutex m_authorizerLock;
- RefPtr<DatabaseAuthorizer> m_authorizer;
-
- Mutex m_lockingMutex;
- ThreadIdentifier m_openingThread;
-
-}; // class SQLiteDatabase
-
-} // namespace WebCore
-
-#endif
diff --git a/WebCore/platform/sql/SQLiteStatement.cpp b/WebCore/platform/sql/SQLiteStatement.cpp
deleted file mode 100644
index ac96034..0000000
--- a/WebCore/platform/sql/SQLiteStatement.cpp
+++ /dev/null
@@ -1,453 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "SQLiteStatement.h"
-
-#include "Logging.h"
-#include "SQLValue.h"
-#include <sqlite3.h>
-#include <wtf/Assertions.h>
-
-namespace WebCore {
-
-#if SQLITE_VERSION_NUMBER < 3003009
-
-// FIXME: This overload helps us compile with older versions of SQLite 3, but things like quotas will not work.
-static inline int sqlite3_prepare16_v2(sqlite3* db, const void* zSql, int nBytes, sqlite3_stmt** ppStmt, const void** pzTail)
-{
- return sqlite3_prepare16(db, zSql, nBytes, ppStmt, pzTail);
-}
-
-#endif
-
-SQLiteStatement::SQLiteStatement(SQLiteDatabase& db, const String& sql)
- : m_database(db)
- , m_query(sql)
- , m_statement(0)
-#ifndef NDEBUG
- , m_isPrepared(false)
-#endif
-{
-}
-
-SQLiteStatement::~SQLiteStatement()
-{
- finalize();
-}
-
-int SQLiteStatement::prepare()
-{
- ASSERT(!m_isPrepared);
- const void* tail;
- LOG(SQLDatabase, "SQL - prepare - %s", m_query.ascii().data());
- int error = sqlite3_prepare16_v2(m_database.sqlite3Handle(), m_query.charactersWithNullTermination(), -1, &m_statement, &tail);
- if (error != SQLITE_OK)
- LOG(SQLDatabase, "sqlite3_prepare16 failed (%i)\n%s\n%s", error, m_query.ascii().data(), sqlite3_errmsg(m_database.sqlite3Handle()));
-#ifndef NDEBUG
- m_isPrepared = error == SQLITE_OK;
-#endif
- return error;
-}
-
-int SQLiteStatement::step()
-{
- ASSERT(m_isPrepared);
- if (!m_statement)
- return SQLITE_OK;
- LOG(SQLDatabase, "SQL - step - %s", m_query.ascii().data());
- int error = sqlite3_step(m_statement);
- if (error != SQLITE_DONE && error != SQLITE_ROW) {
- LOG(SQLDatabase, "sqlite3_step failed (%i)\nQuery - %s\nError - %s",
- error, m_query.ascii().data(), sqlite3_errmsg(m_database.sqlite3Handle()));
- }
- return error;
-}
-
-int SQLiteStatement::finalize()
-{
-#ifndef NDEBUG
- m_isPrepared = false;
-#endif
- if (!m_statement)
- return SQLITE_OK;
- LOG(SQLDatabase, "SQL - finalize - %s", m_query.ascii().data());
- int result = sqlite3_finalize(m_statement);
- m_statement = 0;
- return result;
-}
-
-int SQLiteStatement::reset()
-{
- ASSERT(m_isPrepared);
- if (!m_statement)
- return SQLITE_OK;
- LOG(SQLDatabase, "SQL - reset - %s", m_query.ascii().data());
- return sqlite3_reset(m_statement);
-}
-
-bool SQLiteStatement::executeCommand()
-{
- if (!m_statement && prepare() != SQLITE_OK)
- return false;
- ASSERT(m_isPrepared);
- if (step() != SQLITE_DONE) {
- finalize();
- return false;
- }
- finalize();
- return true;
-}
-
-bool SQLiteStatement::returnsAtLeastOneResult()
-{
- if (!m_statement && prepare() != SQLITE_OK)
- return false;
- ASSERT(m_isPrepared);
- if (step() != SQLITE_ROW) {
- finalize();
- return false;
- }
- finalize();
- return true;
-
-}
-
-int SQLiteStatement::bindBlob(int index, const void* blob, int size)
-{
- ASSERT(m_isPrepared);
- ASSERT(index > 0);
- ASSERT(static_cast<unsigned>(index) <= bindParameterCount());
- ASSERT(blob);
- ASSERT(size >= 0);
-
- if (!m_statement)
- return SQLITE_ERROR;
-
- return sqlite3_bind_blob(m_statement, index, blob, size, SQLITE_TRANSIENT);
-}
-
-int SQLiteStatement::bindText(int index, const String& text)
-{
- ASSERT(m_isPrepared);
- ASSERT(index > 0);
- ASSERT(static_cast<unsigned>(index) <= bindParameterCount());
-
- // String::characters() returns 0 for the empty string, which SQLite
- // treats as a null, so we supply a non-null pointer for that case.
- UChar anyCharacter = 0;
- const UChar* characters;
- if (text.isEmpty() && !text.isNull())
- characters = &anyCharacter;
- else
- characters = text.characters();
-
- return sqlite3_bind_text16(m_statement, index, characters, sizeof(UChar) * text.length(), SQLITE_TRANSIENT);
-}
-
-
-int SQLiteStatement::bindInt64(int index, int64_t integer)
-{
- ASSERT(m_isPrepared);
- ASSERT(index > 0);
- ASSERT(static_cast<unsigned>(index) <= bindParameterCount());
-
- return sqlite3_bind_int64(m_statement, index, integer);
-}
-
-int SQLiteStatement::bindDouble(int index, double number)
-{
- ASSERT(m_isPrepared);
- ASSERT(index > 0);
- ASSERT(static_cast<unsigned>(index) <= bindParameterCount());
-
- return sqlite3_bind_double(m_statement, index, number);
-}
-
-int SQLiteStatement::bindNull(int index)
-{
- ASSERT(m_isPrepared);
- ASSERT(index > 0);
- ASSERT(static_cast<unsigned>(index) <= bindParameterCount());
-
- return sqlite3_bind_null(m_statement, index);
-}
-
-int SQLiteStatement::bindValue(int index, const SQLValue& value)
-{
- switch (value.type()) {
- case SQLValue::StringValue:
- return bindText(index, value.string());
- case SQLValue::NumberValue:
- return bindDouble(index, value.number());
- case SQLValue::NullValue:
- return bindNull(index);
- }
-
- ASSERT_NOT_REACHED();
- return SQLITE_ERROR;
-}
-
-unsigned SQLiteStatement::bindParameterCount() const
-{
- ASSERT(m_isPrepared);
- if (!m_statement)
- return 0;
- return sqlite3_bind_parameter_count(m_statement);
-}
-
-int SQLiteStatement::columnCount()
-{
- ASSERT(m_isPrepared);
- if (!m_statement)
- return 0;
- return sqlite3_data_count(m_statement);
-}
-
-String SQLiteStatement::getColumnName(int col)
-{
- ASSERT(col >= 0);
- if (!m_statement)
- if (prepareAndStep() != SQLITE_ROW)
- return String();
- if (columnCount() <= col)
- return String();
- return String(reinterpret_cast<const UChar*>(sqlite3_column_name16(m_statement, col)));
-}
-
-SQLValue SQLiteStatement::getColumnValue(int col)
-{
- ASSERT(col >= 0);
- if (!m_statement)
- if (prepareAndStep() != SQLITE_ROW)
- return SQLValue();
- if (columnCount() <= col)
- return SQLValue();
-
- // SQLite is typed per value. optional column types are
- // "(mostly) ignored"
- sqlite3_value* value = sqlite3_column_value(m_statement, col);
- switch (sqlite3_value_type(value)) {
- case SQLITE_INTEGER: // SQLValue and JS don't represent integers, so use FLOAT -case
- case SQLITE_FLOAT:
- return SQLValue(sqlite3_value_double(value));
- case SQLITE_BLOB: // SQLValue and JS don't represent blobs, so use TEXT -case
- case SQLITE_TEXT:
- return SQLValue(String(reinterpret_cast<const UChar*>(sqlite3_value_text16(value))));
- case SQLITE_NULL:
- return SQLValue();
- default:
- break;
- }
- ASSERT_NOT_REACHED();
- return SQLValue();
-}
-
-String SQLiteStatement::getColumnText(int col)
-{
- ASSERT(col >= 0);
- if (!m_statement)
- if (prepareAndStep() != SQLITE_ROW)
- return String();
- if (columnCount() <= col)
- return String();
- return String(reinterpret_cast<const UChar*>(sqlite3_column_text16(m_statement, col)));
-}
-
-double SQLiteStatement::getColumnDouble(int col)
-{
- ASSERT(col >= 0);
- if (!m_statement)
- if (prepareAndStep() != SQLITE_ROW)
- return 0.0;
- if (columnCount() <= col)
- return 0.0;
- return sqlite3_column_double(m_statement, col);
-}
-
-int SQLiteStatement::getColumnInt(int col)
-{
- ASSERT(col >= 0);
- if (!m_statement)
- if (prepareAndStep() != SQLITE_ROW)
- return 0;
- if (columnCount() <= col)
- return 0;
- return sqlite3_column_int(m_statement, col);
-}
-
-int64_t SQLiteStatement::getColumnInt64(int col)
-{
- ASSERT(col >= 0);
- if (!m_statement)
- if (prepareAndStep() != SQLITE_ROW)
- return 0;
- if (columnCount() <= col)
- return 0;
- return sqlite3_column_int64(m_statement, col);
-}
-
-void SQLiteStatement::getColumnBlobAsVector(int col, Vector<char>& result)
-{
- ASSERT(col >= 0);
-
- if (!m_statement && prepareAndStep() != SQLITE_ROW) {
- result.clear();
- return;
- }
-
- if (columnCount() <= col) {
- result.clear();
- return;
- }
-
- const void* blob = sqlite3_column_blob(m_statement, col);
- if (!blob) {
- result.clear();
- return;
- }
-
- int size = sqlite3_column_bytes(m_statement, col);
- result.resize((size_t)size);
- for (int i = 0; i < size; ++i)
- result[i] = ((const unsigned char*)blob)[i];
-}
-
-const void* SQLiteStatement::getColumnBlob(int col, int& size)
-{
- ASSERT(col >= 0);
-
- size = 0;
-
- if (finalize() != SQLITE_OK)
- LOG(SQLDatabase, "Finalize failed");
- if (prepare() != SQLITE_OK) {
- LOG(SQLDatabase, "Prepare failed");
- return 0;
- }
- if (step() != SQLITE_ROW) {
- LOG(SQLDatabase, "Step wasn't a row");
- return 0;
- }
-
- if (columnCount() <= col)
- return 0;
-
- const void* blob = sqlite3_column_blob(m_statement, col);
- if (!blob)
- return 0;
-
- size = sqlite3_column_bytes(m_statement, col);
- return blob;
-}
-
-bool SQLiteStatement::returnTextResults(int col, Vector<String>& v)
-{
- ASSERT(col >= 0);
-
- v.clear();
-
- if (m_statement)
- finalize();
- if (prepare() != SQLITE_OK)
- return false;
-
- while (step() == SQLITE_ROW)
- v.append(getColumnText(col));
- bool result = true;
- if (m_database.lastError() != SQLITE_DONE) {
- result = false;
- LOG(SQLDatabase, "Error reading results from database query %s", m_query.ascii().data());
- }
- finalize();
- return result;
-}
-
-bool SQLiteStatement::returnIntResults(int col, Vector<int>& v)
-{
- v.clear();
-
- if (m_statement)
- finalize();
- if (prepare() != SQLITE_OK)
- return false;
-
- while (step() == SQLITE_ROW)
- v.append(getColumnInt(col));
- bool result = true;
- if (m_database.lastError() != SQLITE_DONE) {
- result = false;
- LOG(SQLDatabase, "Error reading results from database query %s", m_query.ascii().data());
- }
- finalize();
- return result;
-}
-
-bool SQLiteStatement::returnInt64Results(int col, Vector<int64_t>& v)
-{
- v.clear();
-
- if (m_statement)
- finalize();
- if (prepare() != SQLITE_OK)
- return false;
-
- while (step() == SQLITE_ROW)
- v.append(getColumnInt64(col));
- bool result = true;
- if (m_database.lastError() != SQLITE_DONE) {
- result = false;
- LOG(SQLDatabase, "Error reading results from database query %s", m_query.ascii().data());
- }
- finalize();
- return result;
-}
-
-bool SQLiteStatement::returnDoubleResults(int col, Vector<double>& v)
-{
- v.clear();
-
- if (m_statement)
- finalize();
- if (prepare() != SQLITE_OK)
- return false;
-
- while (step() == SQLITE_ROW)
- v.append(getColumnDouble(col));
- bool result = true;
- if (m_database.lastError() != SQLITE_DONE) {
- result = false;
- LOG(SQLDatabase, "Error reading results from database query %s", m_query.ascii().data());
- }
- finalize();
- return result;
-}
-
-bool SQLiteStatement::isExpired()
-{
- return !m_statement || sqlite3_expired(m_statement);
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/sql/SQLiteStatement.h b/WebCore/platform/sql/SQLiteStatement.h
deleted file mode 100644
index e62b4f0..0000000
--- a/WebCore/platform/sql/SQLiteStatement.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef SQLiteStatement_h
-#define SQLiteStatement_h
-
-#include "SQLiteDatabase.h"
-
-struct sqlite3_stmt;
-
-namespace WebCore {
-
-class SQLValue;
-
-class SQLiteStatement : public Noncopyable {
-public:
- SQLiteStatement(SQLiteDatabase&, const String&);
- ~SQLiteStatement();
-
- int prepare();
- int bindBlob(int index, const void* blob, int size);
- int bindText(int index, const String&);
- int bindInt64(int index, int64_t);
- int bindDouble(int index, double);
- int bindNull(int index);
- int bindValue(int index, const SQLValue&);
- unsigned bindParameterCount() const;
-
- int step();
- int finalize();
- int reset();
-
- int prepareAndStep() { if (int error = prepare()) return error; return step(); }
-
- // prepares, steps, and finalizes the query.
- // returns true if all 3 steps succeed with step() returning SQLITE_DONE
- // returns false otherwise
- bool executeCommand();
-
- // prepares, steps, and finalizes.
- // returns true is step() returns SQLITE_ROW
- // returns false otherwise
- bool returnsAtLeastOneResult();
-
- bool isExpired();
-
- // Returns -1 on last-step failing. Otherwise, returns number of rows
- // returned in the last step()
- int columnCount();
-
- String getColumnName(int col);
- SQLValue getColumnValue(int col);
- String getColumnText(int col);
- double getColumnDouble(int col);
- int getColumnInt(int col);
- int64_t getColumnInt64(int col);
- const void* getColumnBlob(int col, int& size);
- void getColumnBlobAsVector(int col, Vector<char>&);
-
- bool returnTextResults(int col, Vector<String>&);
- bool returnIntResults(int col, Vector<int>&);
- bool returnInt64Results(int col, Vector<int64_t>&);
- bool returnDoubleResults(int col, Vector<double>&);
-
- SQLiteDatabase* database() { return &m_database; }
-
- const String& query() const { return m_query; }
-
-private:
- SQLiteDatabase& m_database;
- String m_query;
- sqlite3_stmt* m_statement;
-#ifndef NDEBUG
- bool m_isPrepared;
-#endif
-};
-
-} // namespace WebCore
-
-#endif // SQLiteStatement_h
diff --git a/WebCore/platform/sql/SQLiteTransaction.cpp b/WebCore/platform/sql/SQLiteTransaction.cpp
deleted file mode 100644
index 5018f5a..0000000
--- a/WebCore/platform/sql/SQLiteTransaction.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "SQLiteTransaction.h"
-
-#include "SQLiteDatabase.h"
-
-namespace WebCore {
-
-SQLiteTransaction::SQLiteTransaction(SQLiteDatabase& db)
- : m_db(db)
- , m_inProgress(false)
-{
-}
-
-SQLiteTransaction::~SQLiteTransaction()
-{
- if (m_inProgress)
- rollback();
-}
-
-void SQLiteTransaction::begin()
-{
- if (!m_inProgress) {
- ASSERT(!m_db.m_transactionInProgress);
- m_inProgress = m_db.executeCommand("BEGIN;");
- m_db.m_transactionInProgress = true;
- }
-}
-
-void SQLiteTransaction::commit()
-{
- if (m_inProgress) {
- ASSERT(m_db.m_transactionInProgress);
- m_db.executeCommand("COMMIT;");
- m_inProgress = false;
- m_db.m_transactionInProgress = false;
- }
-}
-
-void SQLiteTransaction::rollback()
-{
- if (m_inProgress) {
- ASSERT(m_db.m_transactionInProgress);
- m_db.executeCommand("ROLLBACK;");
- m_inProgress = false;
- m_db.m_transactionInProgress = false;
- }
-}
-
-void SQLiteTransaction::stop()
-{
- m_inProgress = false;
- m_db.m_transactionInProgress = false;
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/sql/SQLiteTransaction.h b/WebCore/platform/sql/SQLiteTransaction.h
deleted file mode 100644
index cf5a180..0000000
--- a/WebCore/platform/sql/SQLiteTransaction.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef SQLiteTransaction_h
-#define SQLiteTransaction_h
-
-#include <wtf/Noncopyable.h>
-
-namespace WebCore {
-
-class SQLiteDatabase;
-
-class SQLiteTransaction : public Noncopyable
-{
-public:
- SQLiteTransaction(SQLiteDatabase& db);
- ~SQLiteTransaction();
-
- void begin();
- void commit();
- void rollback();
- void stop();
-
- bool inProgress() const { return m_inProgress; }
-private:
- SQLiteDatabase& m_db;
- bool m_inProgress;
-
-};
-
-} // namespace WebCore
-
-#endif // SQLiteTransation_H
-
diff --git a/WebCore/platform/symbian/FloatPointSymbian.cpp b/WebCore/platform/symbian/FloatPointSymbian.cpp
deleted file mode 100644
index 2cdf838..0000000
--- a/WebCore/platform/symbian/FloatPointSymbian.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
-* ==============================================================================
-* Copyright (c) 2006, Nokia Corporation
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions
-* are met:
-*
-* * Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in
-* the documentation and/or other materials provided with the
-* distribution.
-* * Neither the name of the Nokia Corporation nor the names of its
-* contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
-* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
-* DAMAGE.
-*
-* ==============================================================================
-*/
-
-#include "config.h"
-#include "FloatPoint.h"
-#include <e32cmn.h>
-
-namespace WebCore {
-
-FloatPoint::FloatPoint(const TPoint& p)
- : m_x(p.iX)
- , m_y(p.iY)
-{
-}
-
-FloatPoint::operator TPoint() const
-{
- return TPoint(m_x, m_y);
-}
-
-}
diff --git a/WebCore/platform/symbian/FloatRectSymbian.cpp b/WebCore/platform/symbian/FloatRectSymbian.cpp
deleted file mode 100644
index b565b0c..0000000
--- a/WebCore/platform/symbian/FloatRectSymbian.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
-* ==============================================================================
-* Copyright (c) 2006, Nokia Corporation
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions
-* are met:
-*
-* * Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in
-* the documentation and/or other materials provided with the
-* distribution.
-* * Neither the name of the Nokia Corporation nor the names of its
-* contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
-* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
-* DAMAGE.
-*
-* ==============================================================================
-*/
-
-#include "config.h"
-#include "FloatRect.h"
-#include "IntSize.h"
-#include "IntPoint.h"
-#include <e32std.h>
-
-namespace WebCore {
-
-FloatRect::FloatRect(const TRect& r)
- : m_location(IntPoint(r.iTl.iX, r.iTl.iY))
- , m_size(IntSize(r.Size().iWidth, r.Size().iHeight))
-{
-}
-
-FloatRect::operator TRect() const
-{
- return TRect(x(), y(), right(), bottom());
-}
-
-TRect FloatRect::rect() const
-{
- return TRect(x(), y(), right(), bottom());
-}
-
-}
diff --git a/WebCore/platform/symbian/IntPointSymbian.cpp b/WebCore/platform/symbian/IntPointSymbian.cpp
deleted file mode 100644
index 8ccfb00..0000000
--- a/WebCore/platform/symbian/IntPointSymbian.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
-* ==============================================================================
-* Copyright (c) 2006, Nokia Corporation
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions
-* are met:
-*
-* * Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in
-* the documentation and/or other materials provided with the
-* distribution.
-* * Neither the name of the Nokia Corporation nor the names of its
-* contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
-* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
-* DAMAGE.
-*
-* ==============================================================================
-*/
-
-#include "config.h"
-#include "IntPoint.h"
-#include <e32std.h>
-
-namespace WebCore {
-
-IntPoint::IntPoint(const TPoint& p)
- : m_x(p.iX)
- , m_y(p.iY)
-{
-}
-
-IntPoint::operator TPoint() const
-{
- return TPoint(m_x, m_y);
-}
-
-}
diff --git a/WebCore/platform/symbian/IntRectSymbian.cpp b/WebCore/platform/symbian/IntRectSymbian.cpp
deleted file mode 100644
index f480005..0000000
--- a/WebCore/platform/symbian/IntRectSymbian.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
-* ==============================================================================
-* Copyright (c) 2006, Nokia Corporation
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions
-* are met:
-*
-* * Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in
-* the documentation and/or other materials provided with the
-* distribution.
-* * Neither the name of the Nokia Corporation nor the names of its
-* contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
-* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
-* DAMAGE.
-*
-* ==============================================================================
-*/
-
-#include "config.h"
-#include "IntRect.h"
-#include <e32std.h>
-
-namespace WebCore {
-
-IntRect::IntRect(const TRect& r)
- : m_location(IntPoint(r.iTl.iX, r.iTl.iY))
- , m_size(IntSize(r.Size().iWidth, r.Size().iHeight))
-{
-}
-
-IntRect::operator TRect() const
-{
- return TRect(x(), y(), right(), bottom());
-}
-
-TRect IntRect::Rect() const
-{
- return TRect(x(), y(), right(), bottom());
-}
-
-}
diff --git a/WebCore/platform/symbian/IntSizeSymbian.cpp b/WebCore/platform/symbian/IntSizeSymbian.cpp
deleted file mode 100644
index 5c0e117..0000000
--- a/WebCore/platform/symbian/IntSizeSymbian.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
-* ==============================================================================
-* Copyright (c) 2006, Nokia Corporation
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions
-* are met:
-*
-* * Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in
-* the documentation and/or other materials provided with the
-* distribution.
-* * Neither the name of the Nokia Corporation nor the names of its
-* contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
-* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
-* DAMAGE.
-*
-* ==============================================================================
-*/
-
-#include "config.h"
-#include "IntSize.h"
-#include <e32std.h>
-
-namespace WebCore {
-
-IntSize::IntSize(const TSize& s)
- : m_width(s.iWidth)
- , m_height(s.iHeight)
-{
-}
-
-IntSize::operator TSize() const
-{
- return TSize(m_width, m_height);
-}
-
-}
diff --git a/WebCore/platform/text/AtomicString.cpp b/WebCore/platform/text/AtomicString.cpp
deleted file mode 100644
index dc573e1..0000000
--- a/WebCore/platform/text/AtomicString.cpp
+++ /dev/null
@@ -1,326 +0,0 @@
-/*
- * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-
-#ifdef SKIP_STATIC_CONSTRUCTORS_ON_GCC
-#define ATOMICSTRING_HIDE_GLOBALS 1
-#endif
-
-#include "AtomicString.h"
-
-#include "StaticConstructors.h"
-#include "StringHash.h"
-#include <kjs/identifier.h>
-#include <wtf/Threading.h>
-#include <wtf/HashSet.h>
-
-#if ENABLE(WORKERS)
-#include <wtf/ThreadSpecific.h>
-using namespace WTF;
-#endif
-
-#if USE(JSC)
-using JSC::Identifier;
-using JSC::UString;
-#endif
-
-namespace WebCore {
-
-#if ENABLE(WORKERS)
-static ThreadSpecific<HashSet<StringImpl*> >* staticStringTable;
-#else
-static HashSet<StringImpl*>* staticStringTable;
-#endif
-
-static inline HashSet<StringImpl*>* stringTable()
-{
-#if ENABLE(WORKERS)
- return *staticStringTable;
-#else
- return staticStringTable;
-#endif
-}
-
-struct CStringTranslator {
- static unsigned hash(const char* c)
- {
- return StringImpl::computeHash(c);
- }
-
- static bool equal(StringImpl* r, const char* s)
- {
- int length = r->length();
- const UChar* d = r->characters();
- for (int i = 0; i != length; ++i) {
- unsigned char c = s[i];
- if (d[i] != c)
- return false;
- }
- return s[length] == 0;
- }
-
- static void translate(StringImpl*& location, const char* const& c, unsigned hash)
- {
- location = new StringImpl(c, strlen(c), hash);
- }
-};
-
-bool operator==(const AtomicString& a, const char* b)
-{
- StringImpl* impl = a.impl();
- if ((!impl || !impl->characters()) && !b)
- return true;
- if ((!impl || !impl->characters()) || !b)
- return false;
- return CStringTranslator::equal(impl, b);
-}
-
-PassRefPtr<StringImpl> AtomicString::add(const char* c)
-{
- if (!c)
- return 0;
- if (!*c)
- return StringImpl::empty();
- pair<HashSet<StringImpl*>::iterator, bool> addResult = stringTable()->add<const char*, CStringTranslator>(c);
- if (!addResult.second)
- return *addResult.first;
- return adoptRef(*addResult.first);
-}
-
-struct UCharBuffer {
- const UChar* s;
- unsigned length;
-};
-
-static inline bool equal(StringImpl* string, const UChar* characters, unsigned length)
-{
- if (string->length() != length)
- return false;
-
-#if PLATFORM(ARM)
- const UChar* stringCharacters = string->characters();
- for (unsigned i = 0; i != length; ++i) {
- if (*stringCharacters++ != *characters++)
- return false;
- }
- return true;
-#else
- /* Do it 4-bytes-at-a-time on architectures where it's safe */
-
- const uint32_t* stringCharacters = reinterpret_cast<const uint32_t*>(string->characters());
- const uint32_t* bufferCharacters = reinterpret_cast<const uint32_t*>(characters);
-
- unsigned halfLength = length >> 1;
- for (unsigned i = 0; i != halfLength; ++i) {
- if (*stringCharacters++ != *bufferCharacters++)
- return false;
- }
-
- if (length & 1 && *reinterpret_cast<const uint16_t*>(stringCharacters) != *reinterpret_cast<const uint16_t*>(bufferCharacters))
- return false;
-
- return true;
-#endif
-}
-
-struct UCharBufferTranslator {
- static unsigned hash(const UCharBuffer& buf)
- {
- return StringImpl::computeHash(buf.s, buf.length);
- }
-
- static bool equal(StringImpl* const& str, const UCharBuffer& buf)
- {
- return WebCore::equal(str, buf.s, buf.length);
- }
-
- static void translate(StringImpl*& location, const UCharBuffer& buf, unsigned hash)
- {
- location = new StringImpl(buf.s, buf.length, hash);
- }
-};
-
-struct HashAndCharacters {
- unsigned hash;
- const UChar* characters;
- unsigned length;
-};
-
-struct HashAndCharactersTranslator {
- static unsigned hash(const HashAndCharacters& buffer)
- {
- ASSERT(buffer.hash == StringImpl::computeHash(buffer.characters, buffer.length));
- return buffer.hash;
- }
-
- static bool equal(StringImpl* const& string, const HashAndCharacters& buffer)
- {
- return WebCore::equal(string, buffer.characters, buffer.length);
- }
-
- static void translate(StringImpl*& location, const HashAndCharacters& buffer, unsigned hash)
- {
- location = new StringImpl(buffer.characters, buffer.length, hash);
- }
-};
-
-PassRefPtr<StringImpl> AtomicString::add(const UChar* s, int length)
-{
- if (!s)
- return 0;
-
- if (length == 0)
- return StringImpl::empty();
-
- UCharBuffer buf = { s, length };
- pair<HashSet<StringImpl*>::iterator, bool> addResult = stringTable()->add<UCharBuffer, UCharBufferTranslator>(buf);
- if (!addResult.second)
- return *addResult.first;
- return adoptRef(*addResult.first);
-}
-
-PassRefPtr<StringImpl> AtomicString::add(const UChar* s)
-{
- if (!s)
- return 0;
-
- int length = 0;
- while (s[length] != UChar(0))
- length++;
-
- if (length == 0)
- return StringImpl::empty();
-
- UCharBuffer buf = {s, length};
- pair<HashSet<StringImpl*>::iterator, bool> addResult = stringTable()->add<UCharBuffer, UCharBufferTranslator>(buf);
- if (!addResult.second)
- return *addResult.first;
- return adoptRef(*addResult.first);
-}
-
-PassRefPtr<StringImpl> AtomicString::add(StringImpl* r)
-{
- if (!r || r->m_inTable)
- return r;
-
- if (r->length() == 0)
- return StringImpl::empty();
-
- StringImpl* result = *stringTable()->add(r).first;
- if (result == r)
- r->m_inTable = true;
- return result;
-}
-
-void AtomicString::remove(StringImpl* r)
-{
- stringTable()->remove(r);
-}
-
-#if USE(JSC)
-PassRefPtr<StringImpl> AtomicString::add(const JSC::Identifier& identifier)
-{
- if (identifier.isNull())
- return 0;
-
- UString::Rep* string = identifier.ustring().rep();
- unsigned length = string->size();
- if (!length)
- return StringImpl::empty();
-
- HashAndCharacters buffer = { string->computedHash(), string->data(), length };
- pair<HashSet<StringImpl*>::iterator, bool> addResult = stringTable()->add<HashAndCharacters, HashAndCharactersTranslator>(buffer);
- if (!addResult.second)
- return *addResult.first;
- return adoptRef(*addResult.first);
-}
-
-PassRefPtr<StringImpl> AtomicString::add(const JSC::UString& ustring)
-{
- if (ustring.isNull())
- return 0;
-
- UString::Rep* string = ustring.rep();
- unsigned length = string->size();
- if (!length)
- return StringImpl::empty();
-
- HashAndCharacters buffer = { string->hash(), string->data(), length };
- pair<HashSet<StringImpl*>::iterator, bool> addResult = stringTable()->add<HashAndCharacters, HashAndCharactersTranslator>(buffer);
- if (!addResult.second)
- return *addResult.first;
- return adoptRef(*addResult.first);
-}
-#endif
-
-AtomicStringImpl* AtomicString::find(const JSC::Identifier& identifier)
-{
- if (identifier.isNull())
- return 0;
-
- UString::Rep* string = identifier.ustring().rep();
- unsigned length = string->size();
- if (!length)
- return static_cast<AtomicStringImpl*>(StringImpl::empty());
-
- HashAndCharacters buffer = { string->computedHash(), string->data(), length };
- HashSet<StringImpl*>::iterator iterator = stringTable()->find<HashAndCharacters, HashAndCharactersTranslator>(buffer);
- if (iterator == stringTable()->end())
- return 0;
- return static_cast<AtomicStringImpl*>(*iterator);
-}
-
-AtomicString::operator UString() const
-{
- return m_string;
-}
-
-DEFINE_GLOBAL(AtomicString, nullAtom)
-DEFINE_GLOBAL(AtomicString, emptyAtom, "")
-DEFINE_GLOBAL(AtomicString, textAtom, "#text")
-DEFINE_GLOBAL(AtomicString, commentAtom, "#comment")
-DEFINE_GLOBAL(AtomicString, starAtom, "*")
-
-void AtomicString::init()
-{
- static bool initialized;
- if (!initialized) {
- // Initialization is not thread safe, so this function must be called from the main thread first.
- ASSERT(isMainThread());
-
-#if ENABLE(WORKERS)
- staticStringTable = new ThreadSpecific<HashSet<StringImpl*> >;
-#else
- staticStringTable = new HashSet<StringImpl*>;
-#endif
-
- // Use placement new to initialize the globals.
- new ((void*)&nullAtom) AtomicString;
- new ((void*)&emptyAtom) AtomicString("");
- new ((void*)&textAtom) AtomicString("#text");
- new ((void*)&commentAtom) AtomicString("#comment");
- new ((void*)&starAtom) AtomicString("*");
-
- initialized = true;
- }
-}
-
-}
diff --git a/WebCore/platform/text/AtomicString.h b/WebCore/platform/text/AtomicString.h
deleted file mode 100644
index ad034d9..0000000
--- a/WebCore/platform/text/AtomicString.h
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef AtomicString_h
-#define AtomicString_h
-
-#include "AtomicStringImpl.h"
-#include "PlatformString.h"
-
-namespace WebCore {
-
-struct AtomicStringHash;
-
-class AtomicString {
-public:
- static void init();
-
- AtomicString() { }
- AtomicString(const char* s) : m_string(add(s)) { }
- AtomicString(const UChar* s, int length) : m_string(add(s, length)) { }
- AtomicString(const UChar* s) : m_string(add(s)) { }
-#if USE(JSC)
- AtomicString(const JSC::UString& s) : m_string(add(s)) { }
- AtomicString(const JSC::Identifier& s) : m_string(add(s)) { }
-#endif
- AtomicString(StringImpl* imp) : m_string(add(imp)) { }
- AtomicString(AtomicStringImpl* imp) : m_string(imp) { }
- AtomicString(const String& s) : m_string(add(s.impl())) { }
-
- // Hash table deleted values, which are only constructed and never copied or destroyed.
- AtomicString(WTF::HashTableDeletedValueType) : m_string(WTF::HashTableDeletedValue) { }
- bool isHashTableDeletedValue() const { return m_string.isHashTableDeletedValue(); }
-
-#if USE(JSC)
- static AtomicStringImpl* find(const JSC::Identifier&);
-#endif
-
- operator const String&() const { return m_string; }
- const String& string() const { return m_string; };
-
-#if USE(JSC)
- operator JSC::UString() const;
-#endif
-
- AtomicStringImpl* impl() const { return static_cast<AtomicStringImpl *>(m_string.impl()); }
-
- const UChar* characters() const { return m_string.characters(); }
- unsigned length() const { return m_string.length(); }
-
- UChar operator[](unsigned int i) const { return m_string[i]; }
-
- bool contains(UChar c) const { return m_string.contains(c); }
- bool contains(const AtomicString& s, bool caseSensitive = true) const
- { return m_string.contains(s.string(), caseSensitive); }
-
- int find(UChar c, int start = 0) const { return m_string.find(c, start); }
- int find(const AtomicString& s, int start = 0, bool caseSentitive = true) const
- { return m_string.find(s.string(), start, caseSentitive); }
-
- bool startsWith(const AtomicString& s, bool caseSensitive = true) const
- { return m_string.startsWith(s.string(), caseSensitive); }
- bool endsWith(const AtomicString& s, bool caseSensitive = true) const
- { return m_string.endsWith(s.string(), caseSensitive); }
-
- int toInt(bool* ok = 0) const { return m_string.toInt(ok); }
- double toDouble(bool* ok = 0) const { return m_string.toDouble(ok); }
- float toFloat(bool* ok = 0) const { return m_string.toFloat(ok); }
- bool percentage(int& p) const { return m_string.percentage(p); }
-
- bool isNull() const { return m_string.isNull(); }
- bool isEmpty() const { return m_string.isEmpty(); }
-
- static void remove(StringImpl*);
-
-#ifdef __OBJC__
- AtomicString(NSString* s) : m_string(add(String(s).impl())) { }
- operator NSString*() const { return m_string; }
-#endif
-#if PLATFORM(SYMBIAN)
- AtomicString(const TDesC& s) : m_string(add(String(s).impl())) { }
- operator TPtrC() const { return m_string; }
-#endif
-#if PLATFORM(QT)
- AtomicString(const QString& s) : m_string(add(String(s).impl())) { }
- operator QString() const { return m_string; }
-#endif
-
-private:
- String m_string;
-
- static PassRefPtr<StringImpl> add(const char*);
- static PassRefPtr<StringImpl> add(const UChar*, int length);
- static PassRefPtr<StringImpl> add(const UChar*);
- static PassRefPtr<StringImpl> add(StringImpl*);
-#if USE(JSC)
- static PassRefPtr<StringImpl> add(const JSC::UString&);
- static PassRefPtr<StringImpl> add(const JSC::Identifier&);
-#endif
-};
-
-inline bool operator==(const AtomicString& a, const AtomicString& b) { return a.impl() == b.impl(); }
-bool operator==(const AtomicString& a, const char* b);
-inline bool operator==(const AtomicString& a, const String& b) { return equal(a.impl(), b.impl()); }
-inline bool operator==(const char* a, const AtomicString& b) { return b == a; }
-inline bool operator==(const String& a, const AtomicString& b) { return equal(a.impl(), b.impl()); }
-
-inline bool operator!=(const AtomicString& a, const AtomicString& b) { return a.impl() != b.impl(); }
-inline bool operator!=(const AtomicString& a, const char *b) { return !(a == b); }
-inline bool operator!=(const AtomicString& a, const String& b) { return !equal(a.impl(), b.impl()); }
-inline bool operator!=(const char* a, const AtomicString& b) { return !(b == a); }
-inline bool operator!=(const String& a, const AtomicString& b) { return !equal(a.impl(), b.impl()); }
-
-inline bool equalIgnoringCase(const AtomicString& a, const AtomicString& b) { return equalIgnoringCase(a.impl(), b.impl()); }
-inline bool equalIgnoringCase(const AtomicString& a, const char* b) { return equalIgnoringCase(a.impl(), b); }
-inline bool equalIgnoringCase(const AtomicString& a, const String& b) { return equalIgnoringCase(a.impl(), b.impl()); }
-inline bool equalIgnoringCase(const char* a, const AtomicString& b) { return equalIgnoringCase(a, b.impl()); }
-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.
-// These are only usable from the main thread.
-#ifndef ATOMICSTRING_HIDE_GLOBALS
- extern const AtomicString nullAtom;
- extern const AtomicString emptyAtom;
- extern const AtomicString textAtom;
- extern const AtomicString commentAtom;
- extern const AtomicString starAtom;
-#endif
-
-} // namespace WebCore
-
-
-namespace WTF {
-
- // AtomicStringHash is the default hash for AtomicString
- template<typename T> struct DefaultHash;
- template<> struct DefaultHash<WebCore::AtomicString> {
- typedef WebCore::AtomicStringHash Hash;
- };
-
-} // namespace WTF
-
-#endif // AtomicString_h
diff --git a/WebCore/platform/text/AtomicStringHash.h b/WebCore/platform/text/AtomicStringHash.h
deleted file mode 100644
index 67a45de..0000000
--- a/WebCore/platform/text/AtomicStringHash.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef AtomicStringHash_h
-#define AtomicStringHash_h
-
-#include "AtomicString.h"
-#include <wtf/HashTraits.h>
-
-namespace WebCore {
-
- struct AtomicStringHash {
- static unsigned hash(const AtomicString& key)
- {
- return key.impl()->existingHash();
- }
-
- static bool equal(const AtomicString& a, const AtomicString& b)
- {
- return a == b;
- }
-
- static const bool safeToCompareToEmptyOrDeleted = false;
- };
-
-}
-
-namespace WTF {
-
- // WebCore::AtomicStringHash is the default hash for AtomicString
- template<> struct HashTraits<WebCore::AtomicString> : GenericHashTraits<WebCore::AtomicString> {
- static const bool emptyValueIsZero = true;
- static void constructDeletedValue(WebCore::AtomicString& slot) { new (&slot) WebCore::AtomicString(HashTableDeletedValue); }
- static bool isDeletedValue(const WebCore::AtomicString& slot) { return slot.isHashTableDeletedValue(); }
- };
-
-}
-
-#endif
diff --git a/WebCore/platform/text/AtomicStringImpl.h b/WebCore/platform/text/AtomicStringImpl.h
deleted file mode 100644
index d905afc..0000000
--- a/WebCore/platform/text/AtomicStringImpl.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * This file is part of the DOM implementation for KDE.
- *
- * Copyright (C) 2006 Apple Computer, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef AtomicStringImpl_h
-#define AtomicStringImpl_h
-
-#include "StringImpl.h"
-
-namespace WebCore {
-
-class AtomicStringImpl : public StringImpl
-{
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/text/Base64.cpp b/WebCore/platform/text/Base64.cpp
deleted file mode 100644
index 920fa89..0000000
--- a/WebCore/platform/text/Base64.cpp
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- Copyright (C) 2000-2001 Dawit Alemayehu <adawit@kde.org>
- Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org>
- Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License (LGPL)
- version 2 as published by the Free Software Foundation.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
- This code is based on the java implementation in HTTPClient
- package by Ronald Tschalär Copyright (C) 1996-1999.
-*/
-
-#include "config.h"
-#include "Base64.h"
-
-#include <limits.h>
-
-#include <wtf/Platform.h>
-#include <wtf/StringExtras.h>
-
-namespace WebCore {
-
-static const char base64EncMap[64] = {
- 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
- 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50,
- 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
- 0x59, 0x5A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
- 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E,
- 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76,
- 0x77, 0x78, 0x79, 0x7A, 0x30, 0x31, 0x32, 0x33,
- 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2B, 0x2F
-};
-
-static const char base64DecMap[128] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x3F,
- 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B,
- 0x3C, 0x3D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
- 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E,
- 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
- 0x17, 0x18, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20,
- 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
- 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30,
- 0x31, 0x32, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00
-};
-
-void base64Encode(const Vector<char>& in, Vector<char>& out, bool insertLFs)
-{
- out.clear();
- if (in.isEmpty())
- return;
-
- // If the input string is pathologically large, just return nothing.
- // Note: Keep this in sync with the "out_len" computation below.
- // Rather than being perfectly precise, this is a bit conservative.
- const unsigned maxInputBufferSize = UINT_MAX / 77 * 76 / 4 * 3 - 2;
- if (in.size() > maxInputBufferSize)
- return;
-
- unsigned sidx = 0;
- unsigned didx = 0;
- const char* data = in.data();
- const unsigned len = in.size();
-
- unsigned out_len = ((len + 2) / 3) * 4;
-
- // Deal with the 76 character per line limit specified in RFC 2045.
- insertLFs = (insertLFs && out_len > 76);
- if (insertLFs)
- out_len += ((out_len - 1) / 76);
-
- int count = 0;
- out.grow(out_len);
-
- // 3-byte to 4-byte conversion + 0-63 to ascii printable conversion
- if (len > 1) {
- while (sidx < len - 2) {
- if (insertLFs) {
- if (count && (count % 76) == 0)
- out[didx++] = '\n';
- count += 4;
- }
- out[didx++] = base64EncMap[(data[sidx] >> 2) & 077];
- out[didx++] = base64EncMap[(data[sidx + 1] >> 4) & 017 | (data[sidx] << 4) & 077];
- out[didx++] = base64EncMap[(data[sidx + 2] >> 6) & 003 | (data[sidx + 1] << 2) & 077];
- out[didx++] = base64EncMap[data[sidx + 2] & 077];
- sidx += 3;
- }
- }
-
- if (sidx < len) {
- if (insertLFs && (count > 0) && (count % 76) == 0)
- out[didx++] = '\n';
-
- out[didx++] = base64EncMap[(data[sidx] >> 2) & 077];
- if (sidx < len - 1) {
- out[didx++] = base64EncMap[(data[sidx + 1] >> 4) & 017 | (data[sidx] << 4) & 077];
- out[didx++] = base64EncMap[(data[sidx + 1] << 2) & 077];
- } else
- out[didx++] = base64EncMap[(data[sidx] << 4) & 077];
- }
-
- // Add padding
- while (didx < out.size()) {
- out[didx] = '=';
- didx++;
- }
-}
-
-bool base64Decode(const Vector<char>& in, Vector<char>& out)
-{
- out.clear();
-
- // If the input string is pathologically large, just return nothing.
- if (in.size() > UINT_MAX)
- return false;
-
- return base64Decode(in.data(), in.size(), out);
-}
-
-bool base64Decode(const char* data, unsigned len, Vector<char>& out)
-{
- out.clear();
- if (len == 0)
- return true;
-
- while (len && data[len-1] == '=')
- --len;
-
- out.grow(len);
- for (unsigned idx = 0; idx < len; idx++) {
- unsigned char ch = data[idx];
- if ((ch > 47 && ch < 58) || (ch > 64 && ch < 91) || (ch > 96 && ch < 123) || ch == '+' || ch == '/' || ch == '=')
- out[idx] = base64DecMap[ch];
- else
- return false;
- }
-
- // 4-byte to 3-byte conversion
- unsigned outLen = len - ((len + 3) / 4);
- if (!outLen || ((outLen + 2) / 3) * 4 < len)
- return false;
-
- unsigned sidx = 0;
- unsigned didx = 0;
- if (outLen > 1) {
- while (didx < outLen - 2) {
- out[didx] = (((out[sidx] << 2) & 255) | ((out[sidx + 1] >> 4) & 003));
- out[didx + 1] = (((out[sidx + 1] << 4) & 255) | ((out[sidx + 2] >> 2) & 017));
- out[didx + 2] = (((out[sidx + 2] << 6) & 255) | (out[sidx + 3] & 077));
- sidx += 4;
- didx += 3;
- }
- }
-
- if (didx < outLen)
- out[didx] = (((out[sidx] << 2) & 255) | ((out[sidx + 1] >> 4) & 003));
-
- if (++didx < outLen)
- out[didx] = (((out[sidx + 1] << 4) & 255) | ((out[sidx + 2] >> 2) & 017));
-
- if (outLen < out.size())
- out.shrink(outLen);
-
- return true;
-}
-
-}
diff --git a/WebCore/platform/text/Base64.h b/WebCore/platform/text/Base64.h
deleted file mode 100644
index 0b176e6..0000000
--- a/WebCore/platform/text/Base64.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef Base64_h
-#define Base64_h
-
-#include <wtf/Vector.h>
-
-namespace WebCore {
-
-void base64Encode(const Vector<char>&, Vector<char>&, bool insertLFs = false);
-
-// this decoder is not general purpose - it returns an error if it encounters a linefeed, as needed for window.atob
-bool base64Decode(const Vector<char>&, Vector<char>&);
-bool base64Decode(const char*, unsigned, Vector<char>&);
-
-}
-
-#endif // Base64_h
diff --git a/WebCore/platform/text/BidiContext.cpp b/WebCore/platform/text/BidiContext.cpp
deleted file mode 100644
index ef3c225..0000000
--- a/WebCore/platform/text/BidiContext.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
- * Copyright (C) 2003, 2004, 2006, 2007 Apple Inc. All right reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "BidiContext.h"
-
-namespace WebCore {
-
-bool operator==(const BidiContext& c1, const BidiContext& c2)
-{
- if (&c1 == &c2)
- return true;
- if (c1.level() != c2.level() || c1.override() != c2.override() || c1.dir() != c2.dir())
- return false;
- if (!c1.parent())
- return !c2.parent();
- return c2.parent() && *c1.parent() == *c2.parent();
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/text/BidiContext.h b/WebCore/platform/text/BidiContext.h
deleted file mode 100644
index 89123c8..0000000
--- a/WebCore/platform/text/BidiContext.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
- * Copyright (C) 2003, 2004, 2006, 2007 Apple Inc. All right reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef BidiContext_h
-#define BidiContext_h
-
-#include <wtf/Assertions.h>
-#include <wtf/RefPtr.h>
-#include <wtf/unicode/Unicode.h>
-
-namespace WebCore {
-
-// Used to keep track of explicit embeddings.
-class BidiContext {
-public:
- BidiContext(unsigned char level, WTF::Unicode::Direction direction, bool override = false, BidiContext* parent = 0)
- : m_level(level)
- , m_direction(direction)
- , m_override(override)
- , m_parent(parent)
- , m_refCount(0)
- {
- ASSERT(direction == WTF::Unicode::LeftToRight || direction == WTF::Unicode::RightToLeft);
- }
-
- void ref() const { m_refCount++; }
- void deref() const
- {
- m_refCount--;
- if (m_refCount <= 0)
- delete this;
- }
-
- BidiContext* parent() const { return m_parent.get(); }
- unsigned char level() const { return m_level; }
- WTF::Unicode::Direction dir() const { return static_cast<WTF::Unicode::Direction>(m_direction); }
- bool override() const { return m_override; }
-
-private:
- unsigned char m_level;
- unsigned m_direction : 5; // Direction
- bool m_override : 1;
- RefPtr<BidiContext> m_parent;
- mutable int m_refCount;
-};
-
-bool operator==(const BidiContext&, const BidiContext&);
-
-} // namespace WebCore
-
-#endif // BidiContext_h
diff --git a/WebCore/platform/text/BidiResolver.h b/WebCore/platform/text/BidiResolver.h
deleted file mode 100644
index ffd3d51..0000000
--- a/WebCore/platform/text/BidiResolver.h
+++ /dev/null
@@ -1,937 +0,0 @@
-/*
- * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
- * Copyright (C) 2003, 2004, 2006, 2007, 2008 Apple Inc. All right reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef BidiResolver_h
-#define BidiResolver_h
-
-#include "BidiContext.h"
-#include <wtf/Noncopyable.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/Vector.h>
-
-namespace WebCore {
-
-// The BidiStatus at a given position (typically the end of a line) can
-// be cached and then used to restart bidi resolution at that position.
-struct BidiStatus {
- BidiStatus()
- : eor(WTF::Unicode::OtherNeutral)
- , lastStrong(WTF::Unicode::OtherNeutral)
- , last(WTF::Unicode::OtherNeutral)
- {
- }
-
- BidiStatus(WTF::Unicode::Direction eorDir, WTF::Unicode::Direction lastStrongDir, WTF::Unicode::Direction lastDir, PassRefPtr<BidiContext> bidiContext)
- : eor(eorDir)
- , lastStrong(lastStrongDir)
- , last(lastDir)
- , context(bidiContext)
- {
- }
-
- WTF::Unicode::Direction eor;
- WTF::Unicode::Direction lastStrong;
- WTF::Unicode::Direction last;
- RefPtr<BidiContext> context;
-};
-
-inline bool operator==(const BidiStatus& status1, const BidiStatus& status2)
-{
- return status1.eor == status2.eor && status1.last == status2.last && status1.lastStrong == status2.lastStrong && *(status1.context) == *(status2.context);
-}
-
-inline bool operator!=(const BidiStatus& status1, const BidiStatus& status2)
-{
- return !(status1 == status2);
-}
-
-struct BidiCharacterRun {
- BidiCharacterRun(int start, int stop, BidiContext* context, WTF::Unicode::Direction dir)
- : m_start(start)
- , m_stop(stop)
- , m_override(context->override())
- , m_next(0)
- {
- if (dir == WTF::Unicode::OtherNeutral)
- dir = context->dir();
-
- m_level = context->level();
-
- // add level of run (cases I1 & I2)
- if (m_level % 2) {
- if (dir == WTF::Unicode::LeftToRight || dir == WTF::Unicode::ArabicNumber || dir == WTF::Unicode::EuropeanNumber)
- m_level++;
- } else {
- if (dir == WTF::Unicode::RightToLeft)
- m_level++;
- else if (dir == WTF::Unicode::ArabicNumber || dir == WTF::Unicode::EuropeanNumber)
- m_level += 2;
- }
- }
-
- void destroy() { delete this; }
-
- int start() const { return m_start; }
- int stop() const { return m_stop; }
- unsigned char level() const { return m_level; }
- bool reversed(bool visuallyOrdered) { return m_level % 2 && !visuallyOrdered; }
- bool dirOverride(bool visuallyOrdered) { return m_override || visuallyOrdered; }
-
- BidiCharacterRun* next() const { return m_next; }
-
- unsigned char m_level;
- int m_start;
- int m_stop;
- bool m_override;
- BidiCharacterRun* m_next;
-};
-
-template <class Iterator, class Run> class BidiResolver : public Noncopyable {
-public :
- BidiResolver()
- : m_direction(WTF::Unicode::OtherNeutral)
- , reachedEndOfLine(false)
- , emptyRun(true)
- , m_firstRun(0)
- , m_lastRun(0)
- , m_logicallyLastRun(0)
- , m_runCount(0)
- {
- }
-
- const Iterator& position() const { return current; }
- void setPosition(const Iterator& position) { current = position; }
-
- void increment() { current.increment(); }
-
- BidiContext* context() const { return m_status.context.get(); }
- void setContext(PassRefPtr<BidiContext> c) { m_status.context = c; }
-
- void setLastDir(WTF::Unicode::Direction lastDir) { m_status.last = lastDir; }
- void setLastStrongDir(WTF::Unicode::Direction lastStrongDir) { m_status.lastStrong = lastStrongDir; }
- void setEorDir(WTF::Unicode::Direction eorDir) { m_status.eor = eorDir; }
-
- WTF::Unicode::Direction dir() const { return m_direction; }
- void setDir(WTF::Unicode::Direction d) { m_direction = d; }
-
- const BidiStatus& status() const { return m_status; }
- void setStatus(const BidiStatus s) { m_status = s; }
-
- void embed(WTF::Unicode::Direction);
- void commitExplicitEmbedding();
-
- void createBidiRunsForLine(const Iterator& end, bool visualOrder = false, bool hardLineBreak = false);
-
- Run* firstRun() const { return m_firstRun; }
- Run* lastRun() const { return m_lastRun; }
- Run* logicallyLastRun() const { return m_logicallyLastRun; }
- unsigned runCount() const { return m_runCount; }
-
- void addRun(Run*);
- void prependRun(Run*);
-
- void moveRunToEnd(Run*);
- void moveRunToBeginning(Run*);
-
- void deleteRuns();
-
-protected:
- void appendRun();
- void reverseRuns(unsigned start, unsigned end);
-
- Iterator current;
- Iterator sor;
- Iterator eor;
- Iterator last;
- BidiStatus m_status;
- WTF::Unicode::Direction m_direction;
- Iterator endOfLine;
- bool reachedEndOfLine;
- Iterator lastBeforeET;
- bool emptyRun;
-
- Run* m_firstRun;
- Run* m_lastRun;
- Run* m_logicallyLastRun;
- unsigned m_runCount;
-
-private:
- void raiseExplicitEmbeddingLevel(WTF::Unicode::Direction from, WTF::Unicode::Direction to);
- void lowerExplicitEmbeddingLevel(WTF::Unicode::Direction from);
-
- Vector<WTF::Unicode::Direction, 8> m_currentExplicitEmbeddingSequence;
-};
-
-template <class Iterator, class Run>
-inline void BidiResolver<Iterator, Run>::addRun(Run* run)
-{
- if (!m_firstRun)
- m_firstRun = run;
- else
- m_lastRun->m_next = run;
- m_lastRun = run;
- m_runCount++;
-}
-
-template <class Iterator, class Run>
-inline void BidiResolver<Iterator, Run>::prependRun(Run* run)
-{
- ASSERT(!run->m_next);
-
- if (!m_lastRun)
- m_lastRun = run;
- else
- run->m_next = m_firstRun;
- m_firstRun = run;
- m_runCount++;
-}
-
-template <class Iterator, class Run>
-inline void BidiResolver<Iterator, Run>::moveRunToEnd(Run* run)
-{
- ASSERT(m_firstRun);
- ASSERT(m_lastRun);
- ASSERT(run->m_next);
-
- Run* current = 0;
- Run* next = m_firstRun;
- while (next != run) {
- current = next;
- next = current->next();
- }
-
- if (!current)
- m_firstRun = run->next();
- else
- current->m_next = run->m_next;
-
- run->m_next = 0;
- m_lastRun->m_next = run;
- m_lastRun = run;
-}
-
-template <class Iterator, class Run>
-inline void BidiResolver<Iterator, Run>::moveRunToBeginning(Run* run)
-{
- ASSERT(m_firstRun);
- ASSERT(m_lastRun);
- ASSERT(run != m_firstRun);
-
- Run* current = m_firstRun;
- Run* next = current->next();
- while (next != run) {
- current = next;
- next = current->next();
- }
-
- current->m_next = run->m_next;
- if (run == m_lastRun)
- m_lastRun = current;
-
- run->m_next = m_firstRun;
- m_firstRun = run;
-}
-
-template <class Iterator, class Run>
-void BidiResolver<Iterator, Run>::appendRun()
-{
- if (!emptyRun && !eor.atEnd()) {
- addRun(new Run(sor.offset(), eor.offset() + 1, context(), m_direction));
-
- eor.increment();
- sor = eor;
- }
-
- m_direction = WTF::Unicode::OtherNeutral;
- m_status.eor = WTF::Unicode::OtherNeutral;
-}
-
-template <class Iterator, class Run>
-void BidiResolver<Iterator, Run>::embed(WTF::Unicode::Direction d)
-{
- using namespace WTF::Unicode;
-
- ASSERT(d == PopDirectionalFormat || d == LeftToRightEmbedding || d == LeftToRightOverride || d == RightToLeftEmbedding || d == RightToLeftOverride);
- m_currentExplicitEmbeddingSequence.append(d);
-}
-
-template <class Iterator, class Run>
-void BidiResolver<Iterator, Run>::lowerExplicitEmbeddingLevel(WTF::Unicode::Direction from)
-{
- using namespace WTF::Unicode;
-
- if (!emptyRun && eor != last) {
- ASSERT(m_status.eor != OtherNeutral || eor.atEnd());
- // bidi.sor ... bidi.eor ... bidi.last eor; need to append the bidi.sor-bidi.eor run or extend it through bidi.last
- ASSERT(m_status.last == EuropeanNumberSeparator
- || m_status.last == EuropeanNumberTerminator
- || m_status.last == CommonNumberSeparator
- || m_status.last == BoundaryNeutral
- || m_status.last == BlockSeparator
- || m_status.last == SegmentSeparator
- || m_status.last == WhiteSpaceNeutral
- || m_status.last == OtherNeutral);
- if (m_direction == OtherNeutral)
- m_direction = m_status.lastStrong == LeftToRight ? LeftToRight : RightToLeft;
- if (from == LeftToRight) {
- // bidi.sor ... bidi.eor ... bidi.last L
- if (m_status.eor == EuropeanNumber) {
- if (m_status.lastStrong != LeftToRight) {
- m_direction = EuropeanNumber;
- appendRun();
- }
- } else if (m_status.eor == ArabicNumber) {
- m_direction = ArabicNumber;
- appendRun();
- } else if (m_status.lastStrong != LeftToRight) {
- appendRun();
- m_direction = LeftToRight;
- }
- } else if (m_status.eor == EuropeanNumber || m_status.eor == ArabicNumber || m_status.lastStrong == LeftToRight) {
- appendRun();
- m_direction = RightToLeft;
- }
- eor = last;
- }
- appendRun();
- emptyRun = true;
- // sor for the new run is determined by the higher level (rule X10)
- setLastDir(from);
- setLastStrongDir(from);
- eor = Iterator();
-}
-
-template <class Iterator, class Run>
-void BidiResolver<Iterator, Run>::raiseExplicitEmbeddingLevel(WTF::Unicode::Direction from, WTF::Unicode::Direction to)
-{
- using namespace WTF::Unicode;
-
- if (!emptyRun && eor != last) {
- ASSERT(m_status.eor != OtherNeutral || eor.atEnd());
- // bidi.sor ... bidi.eor ... bidi.last eor; need to append the bidi.sor-bidi.eor run or extend it through bidi.last
- ASSERT(m_status.last == EuropeanNumberSeparator
- || m_status.last == EuropeanNumberTerminator
- || m_status.last == CommonNumberSeparator
- || m_status.last == BoundaryNeutral
- || m_status.last == BlockSeparator
- || m_status.last == SegmentSeparator
- || m_status.last == WhiteSpaceNeutral
- || m_status.last == OtherNeutral);
- if (m_direction == OtherNeutral)
- m_direction = m_status.lastStrong == LeftToRight ? LeftToRight : RightToLeft;
- if (to == LeftToRight) {
- // bidi.sor ... bidi.eor ... bidi.last L
- if (m_status.eor == EuropeanNumber) {
- if (m_status.lastStrong != LeftToRight) {
- m_direction = EuropeanNumber;
- appendRun();
- }
- } else if (m_status.eor == ArabicNumber) {
- m_direction = ArabicNumber;
- appendRun();
- } else if (m_status.lastStrong != LeftToRight && from == LeftToRight) {
- appendRun();
- m_direction = LeftToRight;
- }
- } else if (m_status.eor == ArabicNumber
- || m_status.eor == EuropeanNumber && (m_status.lastStrong != LeftToRight || from == RightToLeft)
- || m_status.eor != EuropeanNumber && m_status.lastStrong == LeftToRight && from == RightToLeft) {
- appendRun();
- m_direction = RightToLeft;
- }
- eor = last;
- }
- appendRun();
- emptyRun = true;
- setLastDir(to);
- setLastStrongDir(to);
- eor = Iterator();
-}
-
-template <class Iterator, class Run>
-void BidiResolver<Iterator, Run>::commitExplicitEmbedding()
-{
- using namespace WTF::Unicode;
-
- unsigned char fromLevel = context()->level();
- RefPtr<BidiContext> toContext = context();
-
- for (size_t i = 0; i < m_currentExplicitEmbeddingSequence.size(); ++i) {
- Direction embedding = m_currentExplicitEmbeddingSequence[i];
- if (embedding == PopDirectionalFormat) {
- if (BidiContext* parentContext = toContext->parent())
- toContext = parentContext;
- } else {
- Direction direction = (embedding == RightToLeftEmbedding || embedding == RightToLeftOverride) ? RightToLeft : LeftToRight;
- bool override = embedding == LeftToRightOverride || embedding == RightToLeftOverride;
- unsigned char level = toContext->level();
- if (direction == RightToLeft) {
- // Go to the least greater odd integer
- level += 1;
- level |= 1;
- } else {
- // Go to the least greater even integer
- level += 2;
- level &= ~1;
- }
- if (level < 61)
- toContext = new BidiContext(level, direction, override, toContext.get());
- }
- }
-
- unsigned char toLevel = toContext->level();
-
- if (toLevel > fromLevel)
- raiseExplicitEmbeddingLevel(fromLevel % 2 ? RightToLeft : LeftToRight, toLevel % 2 ? RightToLeft : LeftToRight);
- else if (toLevel < fromLevel)
- lowerExplicitEmbeddingLevel(fromLevel % 2 ? RightToLeft : LeftToRight);
-
- setContext(toContext);
-
- m_currentExplicitEmbeddingSequence.clear();
-}
-
-template <class Iterator, class Run>
-void BidiResolver<Iterator, Run>::deleteRuns()
-{
- emptyRun = true;
- if (!m_firstRun)
- return;
-
- Run* curr = m_firstRun;
- while (curr) {
- Run* s = curr->next();
- curr->destroy();
- curr = s;
- }
-
- m_firstRun = 0;
- m_lastRun = 0;
- m_runCount = 0;
-}
-
-template <class Iterator, class Run>
-void BidiResolver<Iterator, Run>::reverseRuns(unsigned start, unsigned end)
-{
- if (start >= end)
- return;
-
- ASSERT(end < m_runCount);
-
- // Get the item before the start of the runs to reverse and put it in
- // |beforeStart|. |curr| should point to the first run to reverse.
- Run* curr = m_firstRun;
- Run* beforeStart = 0;
- unsigned i = 0;
- while (i < start) {
- i++;
- beforeStart = curr;
- curr = curr->next();
- }
-
- Run* startRun = curr;
- while (i < end) {
- i++;
- curr = curr->next();
- }
- Run* endRun = curr;
- Run* afterEnd = curr->next();
-
- i = start;
- curr = startRun;
- Run* newNext = afterEnd;
- while (i <= end) {
- // Do the reversal.
- Run* next = curr->next();
- curr->m_next = newNext;
- newNext = curr;
- curr = next;
- i++;
- }
-
- // Now hook up beforeStart and afterEnd to the startRun and endRun.
- if (beforeStart)
- beforeStart->m_next = endRun;
- else
- m_firstRun = endRun;
-
- startRun->m_next = afterEnd;
- if (!afterEnd)
- m_lastRun = startRun;
-}
-
-template <class Iterator, class Run>
-void BidiResolver<Iterator, Run>::createBidiRunsForLine(const Iterator& end, bool visualOrder, bool hardLineBreak)
-{
- using namespace WTF::Unicode;
-
- ASSERT(m_direction == OtherNeutral);
-
- emptyRun = true;
-
- eor = Iterator();
-
- last = current;
- bool pastEnd = false;
- BidiResolver<Iterator, Run> stateAtEnd;
-
- while (true) {
- Direction dirCurrent;
- if (pastEnd && (hardLineBreak || current.atEnd())) {
- BidiContext* c = context();
- while (c->parent())
- c = c->parent();
- dirCurrent = c->dir();
- if (hardLineBreak) {
- // A deviation from the Unicode Bidi Algorithm in order to match
- // Mac OS X text and WinIE: a hard line break resets bidi state.
- stateAtEnd.setContext(c);
- stateAtEnd.setEorDir(dirCurrent);
- stateAtEnd.setLastDir(dirCurrent);
- stateAtEnd.setLastStrongDir(dirCurrent);
- }
- } else {
- dirCurrent = current.direction();
- if (context()->override()
- && dirCurrent != RightToLeftEmbedding
- && dirCurrent != LeftToRightEmbedding
- && dirCurrent != RightToLeftOverride
- && dirCurrent != LeftToRightOverride
- && dirCurrent != PopDirectionalFormat)
- dirCurrent = context()->dir();
- else if (dirCurrent == NonSpacingMark)
- dirCurrent = m_status.last;
- }
-
- ASSERT(m_status.eor != OtherNeutral || eor.atEnd());
- switch (dirCurrent) {
-
- // embedding and overrides (X1-X9 in the Bidi specs)
- case RightToLeftEmbedding:
- case LeftToRightEmbedding:
- case RightToLeftOverride:
- case LeftToRightOverride:
- case PopDirectionalFormat:
- embed(dirCurrent);
- commitExplicitEmbedding();
- break;
-
- // strong types
- case LeftToRight:
- switch(m_status.last) {
- case RightToLeft:
- case RightToLeftArabic:
- case EuropeanNumber:
- case ArabicNumber:
- if (m_status.last != EuropeanNumber || m_status.lastStrong != LeftToRight)
- appendRun();
- break;
- case LeftToRight:
- break;
- case EuropeanNumberSeparator:
- case EuropeanNumberTerminator:
- case CommonNumberSeparator:
- case BoundaryNeutral:
- case BlockSeparator:
- case SegmentSeparator:
- case WhiteSpaceNeutral:
- case OtherNeutral:
- if (m_status.eor == EuropeanNumber) {
- if (m_status.lastStrong != LeftToRight) {
- // the numbers need to be on a higher embedding level, so let's close that run
- m_direction = EuropeanNumber;
- appendRun();
- if (context()->dir() != LeftToRight) {
- // the neutrals take the embedding direction, which is R
- eor = last;
- m_direction = RightToLeft;
- appendRun();
- }
- }
- } else if (m_status.eor == ArabicNumber) {
- // Arabic numbers are always on a higher embedding level, so let's close that run
- m_direction = ArabicNumber;
- appendRun();
- if (context()->dir() != LeftToRight) {
- // the neutrals take the embedding direction, which is R
- eor = last;
- m_direction = RightToLeft;
- appendRun();
- }
- } else if (m_status.lastStrong != LeftToRight) {
- //last stuff takes embedding dir
- if (context()->dir() == RightToLeft) {
- eor = last;
- m_direction = RightToLeft;
- }
- appendRun();
- }
- default:
- break;
- }
- eor = current;
- m_status.eor = LeftToRight;
- m_status.lastStrong = LeftToRight;
- m_direction = LeftToRight;
- break;
- case RightToLeftArabic:
- case RightToLeft:
- switch (m_status.last) {
- case LeftToRight:
- case EuropeanNumber:
- case ArabicNumber:
- appendRun();
- case RightToLeft:
- case RightToLeftArabic:
- break;
- case EuropeanNumberSeparator:
- case EuropeanNumberTerminator:
- case CommonNumberSeparator:
- case BoundaryNeutral:
- case BlockSeparator:
- case SegmentSeparator:
- case WhiteSpaceNeutral:
- case OtherNeutral:
- if (m_status.eor == EuropeanNumber) {
- if (m_status.lastStrong == LeftToRight && context()->dir() == LeftToRight)
- eor = last;
- appendRun();
- } else if (m_status.eor == ArabicNumber)
- appendRun();
- else if (m_status.lastStrong == LeftToRight) {
- if (context()->dir() == LeftToRight)
- eor = last;
- appendRun();
- }
- default:
- break;
- }
- eor = current;
- m_status.eor = RightToLeft;
- m_status.lastStrong = dirCurrent;
- m_direction = RightToLeft;
- break;
-
- // weak types:
-
- case EuropeanNumber:
- if (m_status.lastStrong != RightToLeftArabic) {
- // if last strong was AL change EN to AN
- switch (m_status.last) {
- case EuropeanNumber:
- case LeftToRight:
- break;
- case RightToLeft:
- case RightToLeftArabic:
- case ArabicNumber:
- eor = last;
- appendRun();
- m_direction = EuropeanNumber;
- break;
- case EuropeanNumberSeparator:
- case CommonNumberSeparator:
- if (m_status.eor == EuropeanNumber)
- break;
- case EuropeanNumberTerminator:
- case BoundaryNeutral:
- case BlockSeparator:
- case SegmentSeparator:
- case WhiteSpaceNeutral:
- case OtherNeutral:
- if (m_status.eor == EuropeanNumber) {
- if (m_status.lastStrong == RightToLeft) {
- // ENs on both sides behave like Rs, so the neutrals should be R.
- // Terminate the EN run.
- appendRun();
- // Make an R run.
- eor = m_status.last == EuropeanNumberTerminator ? lastBeforeET : last;
- m_direction = RightToLeft;
- appendRun();
- // Begin a new EN run.
- m_direction = EuropeanNumber;
- }
- } else if (m_status.eor == ArabicNumber) {
- // Terminate the AN run.
- appendRun();
- if (m_status.lastStrong == RightToLeft || context()->dir() == RightToLeft) {
- // Make an R run.
- eor = m_status.last == EuropeanNumberTerminator ? lastBeforeET : last;
- m_direction = RightToLeft;
- appendRun();
- // Begin a new EN run.
- m_direction = EuropeanNumber;
- }
- } else if (m_status.lastStrong == RightToLeft) {
- // Extend the R run to include the neutrals.
- eor = m_status.last == EuropeanNumberTerminator ? lastBeforeET : last;
- m_direction = RightToLeft;
- appendRun();
- // Begin a new EN run.
- m_direction = EuropeanNumber;
- }
- default:
- break;
- }
- eor = current;
- m_status.eor = EuropeanNumber;
- if (m_direction == OtherNeutral)
- m_direction = LeftToRight;
- break;
- }
- case ArabicNumber:
- dirCurrent = ArabicNumber;
- switch (m_status.last) {
- case LeftToRight:
- if (context()->dir() == LeftToRight)
- appendRun();
- break;
- case ArabicNumber:
- break;
- case RightToLeft:
- case RightToLeftArabic:
- case EuropeanNumber:
- eor = last;
- appendRun();
- break;
- case CommonNumberSeparator:
- if (m_status.eor == ArabicNumber)
- break;
- case EuropeanNumberSeparator:
- case EuropeanNumberTerminator:
- case BoundaryNeutral:
- case BlockSeparator:
- case SegmentSeparator:
- case WhiteSpaceNeutral:
- case OtherNeutral:
- if (m_status.eor == ArabicNumber
- || m_status.eor == EuropeanNumber && (m_status.lastStrong == RightToLeft || context()->dir() == RightToLeft)
- || m_status.eor != EuropeanNumber && m_status.lastStrong == LeftToRight && context()->dir() == RightToLeft) {
- // Terminate the run before the neutrals.
- appendRun();
- // Begin an R run for the neutrals.
- m_direction = RightToLeft;
- } else if (m_direction == OtherNeutral)
- m_direction = m_status.lastStrong == LeftToRight ? LeftToRight : RightToLeft;
- eor = last;
- appendRun();
- default:
- break;
- }
- eor = current;
- m_status.eor = ArabicNumber;
- if (m_direction == OtherNeutral)
- m_direction = ArabicNumber;
- break;
- case EuropeanNumberSeparator:
- case CommonNumberSeparator:
- break;
- case EuropeanNumberTerminator:
- if (m_status.last == EuropeanNumber) {
- dirCurrent = EuropeanNumber;
- eor = current;
- m_status.eor = dirCurrent;
- } else if (m_status.last != EuropeanNumberTerminator)
- lastBeforeET = emptyRun ? eor : last;
- break;
-
- // boundary neutrals should be ignored
- case BoundaryNeutral:
- if (eor == last)
- eor = current;
- break;
- // neutrals
- case BlockSeparator:
- // ### what do we do with newline and paragraph seperators that come to here?
- break;
- case SegmentSeparator:
- // ### implement rule L1
- break;
- case WhiteSpaceNeutral:
- break;
- case OtherNeutral:
- break;
- default:
- break;
- }
-
- if (pastEnd) {
- if (eor == current) {
- if (!reachedEndOfLine) {
- eor = endOfLine;
- switch (m_status.eor) {
- case LeftToRight:
- case RightToLeft:
- case ArabicNumber:
- m_direction = m_status.eor;
- break;
- case EuropeanNumber:
- m_direction = m_status.lastStrong == LeftToRight ? LeftToRight : EuropeanNumber;
- break;
- default:
- ASSERT(false);
- }
- appendRun();
- }
- current = end;
- m_status = stateAtEnd.m_status;
- sor = stateAtEnd.sor;
- eor = stateAtEnd.eor;
- last = stateAtEnd.last;
- reachedEndOfLine = stateAtEnd.reachedEndOfLine;
- lastBeforeET = stateAtEnd.lastBeforeET;
- emptyRun = stateAtEnd.emptyRun;
- m_direction = OtherNeutral;
- break;
- }
- }
-
- // set m_status.last as needed.
- switch (dirCurrent) {
- case EuropeanNumberTerminator:
- if (m_status.last != EuropeanNumber)
- m_status.last = EuropeanNumberTerminator;
- break;
- case EuropeanNumberSeparator:
- case CommonNumberSeparator:
- case SegmentSeparator:
- case WhiteSpaceNeutral:
- case OtherNeutral:
- switch(m_status.last) {
- case LeftToRight:
- case RightToLeft:
- case RightToLeftArabic:
- case EuropeanNumber:
- case ArabicNumber:
- m_status.last = dirCurrent;
- break;
- default:
- m_status.last = OtherNeutral;
- }
- break;
- case NonSpacingMark:
- case BoundaryNeutral:
- case RightToLeftEmbedding:
- case LeftToRightEmbedding:
- case RightToLeftOverride:
- case LeftToRightOverride:
- case PopDirectionalFormat:
- // ignore these
- break;
- case EuropeanNumber:
- // fall through
- default:
- m_status.last = dirCurrent;
- }
-
- last = current;
-
- if (emptyRun && !(dirCurrent == RightToLeftEmbedding
- || dirCurrent == LeftToRightEmbedding
- || dirCurrent == RightToLeftOverride
- || dirCurrent == LeftToRightOverride
- || dirCurrent == PopDirectionalFormat)) {
- sor = current;
- emptyRun = false;
- }
-
- increment();
- if (!m_currentExplicitEmbeddingSequence.isEmpty())
- commitExplicitEmbedding();
-
- if (emptyRun && (dirCurrent == RightToLeftEmbedding
- || dirCurrent == LeftToRightEmbedding
- || dirCurrent == RightToLeftOverride
- || dirCurrent == LeftToRightOverride
- || dirCurrent == PopDirectionalFormat)) {
- // exclude the embedding char itself from the new run so that ATSUI will never see it
- eor = Iterator();
- last = current;
- sor = current;
- }
-
- if (!pastEnd && (current == end || current.atEnd())) {
- if (emptyRun)
- break;
- stateAtEnd.m_status = m_status;
- stateAtEnd.sor = sor;
- stateAtEnd.eor = eor;
- stateAtEnd.last = last;
- stateAtEnd.reachedEndOfLine = reachedEndOfLine;
- stateAtEnd.lastBeforeET = lastBeforeET;
- stateAtEnd.emptyRun = emptyRun;
- endOfLine = last;
- pastEnd = true;
- }
- }
-
- m_logicallyLastRun = m_lastRun;
-
- // reorder line according to run structure...
- // do not reverse for visually ordered web sites
- if (!visualOrder) {
-
- // first find highest and lowest levels
- unsigned char levelLow = 128;
- unsigned char levelHigh = 0;
- Run* r = firstRun();
- while (r) {
- if (r->m_level > levelHigh)
- levelHigh = r->m_level;
- if (r->m_level < levelLow)
- levelLow = r->m_level;
- r = r->next();
- }
-
- // implements reordering of the line (L2 according to Bidi spec):
- // L2. From the highest level found in the text to the lowest odd level on each line,
- // reverse any contiguous sequence of characters that are at that level or higher.
-
- // reversing is only done up to the lowest odd level
- if (!(levelLow % 2))
- levelLow++;
-
- unsigned count = runCount() - 1;
-
- while (levelHigh >= levelLow) {
- unsigned i = 0;
- Run* currRun = firstRun();
- while (i < count) {
- while (i < count && currRun && currRun->m_level < levelHigh) {
- i++;
- currRun = currRun->next();
- }
- unsigned start = i;
- while (i <= count && currRun && currRun->m_level >= levelHigh) {
- i++;
- currRun = currRun->next();
- }
- unsigned end = i - 1;
- reverseRuns(start, end);
- }
- levelHigh--;
- }
- }
- endOfLine = Iterator();
-}
-
-} // namespace WebCore
-
-#endif // BidiResolver_h
diff --git a/WebCore/platform/text/CString.cpp b/WebCore/platform/text/CString.cpp
deleted file mode 100644
index 8e68628..0000000
--- a/WebCore/platform/text/CString.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (C) 2003, 2006, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-
-#include "config.h"
-#include "CString.h"
-
-using std::min;
-
-namespace WebCore {
-
-CString::CString(const char* str)
-{
- init(str, strlen(str));
-}
-
-CString::CString(const char* str, unsigned length)
-{
- init(str, length);
-}
-
-void CString::init(const char* str, unsigned length)
-{
- if (!str)
- return;
-
- m_buffer = CStringBuffer::create(length + 1);
- memcpy(m_buffer->data(), str, length);
- m_buffer->data()[length] = '\0';
-}
-
-const char* CString::data() const
-{
- return m_buffer ? m_buffer->data() : 0;
-}
-
-char* CString::mutableData()
-{
- copyBufferIfNeeded();
- if (!m_buffer)
- return 0;
- return m_buffer->data();
-}
-
-unsigned CString::length() const
-{
- return m_buffer ? m_buffer->length() - 1 : 0;
-}
-
-CString CString::newUninitialized(size_t length, char*& characterBuffer)
-{
- CString result;
- result.m_buffer = CStringBuffer::create(length + 1);
- char* bytes = result.m_buffer->data();
- bytes[length] = '\0';
- characterBuffer = bytes;
- return result;
-}
-
-void CString::copyBufferIfNeeded()
-{
- if (!m_buffer || m_buffer->hasOneRef())
- return;
-
- int len = m_buffer->length();
- RefPtr<CStringBuffer> m_temp = m_buffer;
- m_buffer = CStringBuffer::create(len);
- memcpy(m_buffer->data(), m_temp->data(), len);
-}
-
-bool operator==(const CString& a, const CString& b)
-{
- if (a.isNull() != b.isNull())
- return false;
- if (a.length() != b.length())
- return false;
- return !strncmp(a.data(), b.data(), min(a.length(), b.length()));
-}
-
-PassRefPtr<SharedBuffer> CString::releaseBuffer()
-{
- if (!m_buffer)
- return 0;
-
- copyBufferIfNeeded();
-
- RefPtr<SharedBuffer> result = m_buffer->releaseBuffer();
- m_buffer = 0;
- return result.release();
-}
-
-
-}
diff --git a/WebCore/platform/text/CString.h b/WebCore/platform/text/CString.h
deleted file mode 100644
index 09f112f..0000000
--- a/WebCore/platform/text/CString.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2003, 2006, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef CString_h
-#define CString_h
-
-#include "SharedBuffer.h"
-
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/Vector.h>
-
-namespace WebCore {
-
- class CStringBuffer : public RefCounted<CStringBuffer> {
- public:
- static PassRefPtr<CStringBuffer> create(unsigned length) { return adoptRef(new CStringBuffer(length)); }
-
- char* data() { return m_vector.data(); }
- size_t length() const { return m_vector.size(); }
-
- PassRefPtr<SharedBuffer> releaseBuffer() { return SharedBuffer::adoptVector(m_vector); }
-
- private:
- CStringBuffer(unsigned length) : m_vector(length) { }
-
- Vector<char> m_vector;
- };
-
- // A container for a null-terminated char array supporting copy-on-write
- // assignment. The contained char array may be null.
- class CString {
- public:
- CString() { }
- CString(const char*);
- CString(const char*, unsigned length);
- static CString newUninitialized(size_t length, char*& characterBuffer);
-
- const char* data() const;
- char* mutableData();
- unsigned length() const;
-
- bool isNull() const { return !m_buffer; }
-
- PassRefPtr<SharedBuffer> releaseBuffer();
-
- private:
- void copyBufferIfNeeded();
- void init(const char*, unsigned length);
- RefPtr<CStringBuffer> m_buffer;
- };
-
- bool operator==(const CString& a, const CString& b);
- inline bool operator!=(const CString& a, const CString& b) { return !(a == b); }
-
-} // namespace WebCore
-
-#endif // CString_h
diff --git a/WebCore/platform/text/CharacterNames.h b/WebCore/platform/text/CharacterNames.h
deleted file mode 100644
index f589a6c..0000000
--- a/WebCore/platform/text/CharacterNames.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef CharacterNames_h
-#define CharacterNames_h
-
-#include <wtf/unicode/Unicode.h>
-
-namespace WebCore {
-
- // Names here are taken from the Unicode standard.
-
- // Note, these are UChar constants, not UChar32, which makes them
- // more convenient for WebCore code that mostly uses UTF-16.
-
- const UChar blackSquare = 0x25A0;
- const UChar bullet = 0x2022;
- const UChar horizontalEllipsis = 0x2026;
- const UChar ideographicSpace = 0x3000;
- const UChar ideographicComma = 0x3001;
- const UChar ideographicFullStop = 0x3002;
- const UChar leftToRightMark = 0x200E;
- const UChar leftToRightEmbed = 0x202A;
- const UChar leftToRightOverride = 0x202D;
- const UChar newlineCharacter = 0x000A;
- const UChar noBreakSpace = 0x00A0;
- const UChar objectReplacementCharacter = 0xFFFC;
- const UChar popDirectionalFormatting = 0x202C;
- const UChar replacementCharacter = 0xFFFD;
- const UChar rightToLeftMark = 0x200F;
- const UChar rightToLeftEmbed = 0x202B;
- const UChar rightToLeftOverride = 0x202E;
- const UChar softHyphen = 0x00AD;
- const UChar whiteBullet = 0x25E6;
- const UChar zeroWidthSpace = 0x200B;
-
-}
-
-#endif // CharacterNames_h
diff --git a/WebCore/platform/text/ParserUtilities.h b/WebCore/platform/text/ParserUtilities.h
deleted file mode 100644
index 3105214..0000000
--- a/WebCore/platform/text/ParserUtilities.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
- * Copyright (C) 2002, 2003 The Karbon Developers
- * Copyright (C) 2006, 2007 Rob Buis <buis@kde.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef ParserUtilities_h
-#define ParserUtilities_h
-
-#include "PlatformString.h"
-
-namespace WebCore {
-
- inline bool skipString(const UChar*& ptr, const UChar* end, const UChar* name, int length)
- {
- if (end - ptr < length)
- return false;
- if (memcmp(name, ptr, sizeof(UChar) * length))
- return false;
- ptr += length;
- return true;
- }
-
- inline bool skipString(const UChar*& ptr, const UChar* end, const char* str)
- {
- int length = strlen(str);
- if (end - ptr < length)
- return false;
- for (int i = 0; i < length; ++i) {
- if (ptr[i] != str[i])
- return false;
- }
- ptr += length;
- return true;
- }
-
-} // namspace WebCore
-
-#endif // ParserUtilities_h
diff --git a/WebCore/platform/text/PlatformString.h b/WebCore/platform/text/PlatformString.h
deleted file mode 100644
index 73a44bd..0000000
--- a/WebCore/platform/text/PlatformString.h
+++ /dev/null
@@ -1,357 +0,0 @@
-/*
- * (C) 1999 Lars Knoll (knoll@kde.org)
- * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef PlatformString_h
-#define PlatformString_h
-
-// This file would be called String.h, but that conflicts with <string.h>
-// on systems without case-sensitive file systems.
-
-#include "StringImpl.h"
-
-#include <wtf/PassRefPtr.h>
-
-#if USE(JSC)
-#include <kjs/identifier.h>
-#else
-// kjs/identifier.h includes HashMap.h. We explicitly include it in the case of
-// non-JSC builds to keep things consistent.
-#include <wtf/HashMap.h>
-#endif
-
-#if PLATFORM(CF) || (PLATFORM(QT) && PLATFORM(DARWIN))
-typedef const struct __CFString * CFStringRef;
-#endif
-
-#if PLATFORM(QT)
-QT_BEGIN_NAMESPACE
-class QString;
-QT_END_NAMESPACE
-#endif
-
-#if PLATFORM(WX)
-class wxString;
-#endif
-
-namespace WebCore {
-
-class CString;
-class SharedBuffer;
-struct StringHash;
-
-class String {
-public:
- String() { } // gives null string, distinguishable from an empty string
- String(const UChar*, unsigned length);
- String(const UChar*); // Specifically for null terminated UTF-16
-#if USE(JSC)
- String(const JSC::Identifier&);
- String(const JSC::UString&);
-#endif
- String(const char*);
- String(const char*, unsigned length);
- String(StringImpl* i) : m_impl(i) { }
- String(PassRefPtr<StringImpl> i) : m_impl(i) { }
- String(RefPtr<StringImpl> i) : m_impl(i) { }
-
- void swap(String& o) { m_impl.swap(o.m_impl); }
-
- // Hash table deleted values, which are only constructed and never copied or destroyed.
- String(WTF::HashTableDeletedValueType) : m_impl(WTF::HashTableDeletedValue) { }
- bool isHashTableDeletedValue() const { return m_impl.isHashTableDeletedValue(); }
-
- static String adopt(StringBuffer& buffer) { return StringImpl::adopt(buffer); }
- static String adopt(Vector<UChar>& vector) { return StringImpl::adopt(vector); }
-
-#if USE(JSC)
- operator JSC::UString() const;
-#endif
-
- unsigned length() const;
- const UChar* characters() const;
- const UChar* charactersWithNullTermination();
-
- UChar operator[](unsigned i) const; // if i >= length(), returns 0
- UChar32 characterStartingAt(unsigned) const; // Ditto.
-
- bool contains(UChar c) const { return find(c) != -1; }
- bool contains(const char* str, bool caseSensitive = true) const { return find(str, 0, caseSensitive) != -1; }
- bool contains(const String& str, bool caseSensitive = true) const { return find(str, 0, caseSensitive) != -1; }
-
- int find(UChar c, int start = 0) const
- { return m_impl ? m_impl->find(c, start) : -1; }
- int find(const char* str, int start = 0, bool caseSensitive = true) const
- { return m_impl ? m_impl->find(str, start, caseSensitive) : -1; }
- int find(const String& str, int start = 0, bool caseSensitive = true) const
- { return m_impl ? m_impl->find(str.impl(), start, caseSensitive) : -1; }
-
- int reverseFind(UChar c, int start = -1) const
- { return m_impl ? m_impl->reverseFind(c, start) : -1; }
- int reverseFind(const String& str, int start = -1, bool caseSensitive = true) const
- { return m_impl ? m_impl->reverseFind(str.impl(), start, caseSensitive) : -1; }
-
- bool startsWith(const String& s, bool caseSensitive = true) const
- { return m_impl ? m_impl->startsWith(s.impl(), caseSensitive) : s.isEmpty(); }
- bool endsWith(const String& s, bool caseSensitive = true) const
- { return m_impl ? m_impl->endsWith(s.impl(), caseSensitive) : s.isEmpty(); }
-
- void append(const String&);
- void append(char);
- void append(UChar);
- void append(const UChar*, unsigned length);
- void insert(const String&, unsigned pos);
- void insert(const UChar*, unsigned length, unsigned pos);
-
- String& replace(UChar a, UChar b) { if (m_impl) m_impl = m_impl->replace(a, b); return *this; }
- String& replace(UChar a, const String& b) { if (m_impl) m_impl = m_impl->replace(a, b.impl()); return *this; }
- String& replace(const String& a, const String& b) { if (m_impl) m_impl = m_impl->replace(a.impl(), b.impl()); return *this; }
- String& replace(unsigned index, unsigned len, const String& b) { if (m_impl) m_impl = m_impl->replace(index, len, b.impl()); return *this; }
-
- void truncate(unsigned len);
- void remove(unsigned pos, int len = 1);
-
- String substring(unsigned pos, unsigned len = UINT_MAX) const;
- String left(unsigned len) const { return substring(0, len); }
- String right(unsigned len) const { return substring(length() - len, len); }
-
- // Returns a lowercase/uppercase version of the string
- String lower() const;
- String upper() const;
-
- String stripWhiteSpace() const;
- String simplifyWhiteSpace() const;
-
- // Return the string with case folded for case insensitive comparison.
- String foldCase() const;
-
- static String number(int);
- static String number(unsigned);
- static String number(long);
- static String number(unsigned long);
- static String number(long long);
- static String number(unsigned long long);
- static String number(double);
-
- static String format(const char *, ...) WTF_ATTRIBUTE_PRINTF(1, 2);
-
- void split(const String& separator, Vector<String>& result) const;
- void split(const String& separator, bool allowEmptyEntries, Vector<String>& result) const;
- void split(UChar separator, Vector<String>& result) const;
- void split(UChar separator, bool allowEmptyEntries, Vector<String>& result) const;
-
- int toIntStrict(bool* ok = 0, int base = 10) const;
- unsigned toUIntStrict(bool* ok = 0, int base = 10) const;
- int64_t toInt64Strict(bool* ok = 0, int base = 10) const;
- uint64_t toUInt64Strict(bool* ok = 0, int base = 10) const;
-
- int toInt(bool* ok = 0) const;
- unsigned toUInt(bool* ok = 0) const;
- int64_t toInt64(bool* ok = 0) const;
- uint64_t toUInt64(bool* ok = 0) const;
- double toDouble(bool* ok = 0) const;
- float toFloat(bool* ok = 0) const;
-
- bool percentage(int& percentage) const;
-
- // Makes a deep copy. Helpful only if you need to use a String on another thread.
- // Since the underlying StringImpl objects are immutable, there's no other reason
- // to ever prefer copy() over plain old assignment.
- String copy() const;
-
- bool isNull() const { return !m_impl; }
- bool isEmpty() const;
-
- StringImpl* impl() const { return m_impl.get(); }
-
-#if PLATFORM(CF) || (PLATFORM(QT) && PLATFORM(DARWIN))
- String(CFStringRef);
- CFStringRef createCFString() const;
-#endif
-
-#ifdef __OBJC__
- String(NSString*);
-
- // This conversion maps NULL to "", which loses the meaning of NULL, but we
- // need this mapping because AppKit crashes when passed nil NSStrings.
- operator NSString*() const { if (!m_impl) return @""; return *m_impl; }
-#endif
-
-#if PLATFORM(QT)
- String(const QString&);
- String(const QStringRef&);
- operator QString() const;
-#endif
-
-#if PLATFORM(SYMBIAN)
- String(const TDesC&);
- operator TPtrC() const { return des(); }
- TPtrC des() const { if (!m_impl) return KNullDesC(); return m_impl->des(); }
-#endif
-
-#if PLATFORM(WX)
- String(const wxString&);
- operator wxString() const;
-#endif
-
-#ifndef NDEBUG
- Vector<char> ascii() const;
-#endif
-
- CString latin1() const;
- CString utf8() const;
-
- static String fromUTF8(const char*, size_t);
- static String fromUTF8(const char*);
-
- // Determines the writing direction using the Unicode Bidi Algorithm rules P2 and P3.
- WTF::Unicode::Direction defaultWritingDirection() const { return m_impl ? m_impl->defaultWritingDirection() : WTF::Unicode::LeftToRight; }
-
-private:
- RefPtr<StringImpl> m_impl;
-};
-
-String operator+(const String&, const String&);
-String operator+(const String&, const char*);
-String operator+(const char*, const String&);
-
-inline String& operator+=(String& a, const String& b) { a.append(b); return a; }
-
-inline bool operator==(const String& a, const String& b) { return equal(a.impl(), b.impl()); }
-inline bool operator==(const String& a, const char* b) { return equal(a.impl(), b); }
-inline bool operator==(const char* a, const String& b) { return equal(a, b.impl()); }
-
-inline bool operator!=(const String& a, const String& b) { return !equal(a.impl(), b.impl()); }
-inline bool operator!=(const String& a, const char* b) { return !equal(a.impl(), b); }
-inline bool operator!=(const char* a, const String& b) { return !equal(a, b.impl()); }
-
-inline bool equalIgnoringCase(const String& a, const String& b) { return equalIgnoringCase(a.impl(), b.impl()); }
-inline bool equalIgnoringCase(const String& a, const char* b) { return equalIgnoringCase(a.impl(), b); }
-inline bool equalIgnoringCase(const char* a, const String& b) { return equalIgnoringCase(a, b.impl()); }
-
-inline bool operator!(const String& str) { return str.isNull(); }
-
-inline void swap(String& a, String& b) { a.swap(b); }
-
-// String Operations
-
-bool charactersAreAllASCII(const UChar*, size_t);
-
-int charactersToIntStrict(const UChar*, size_t, bool* ok = 0, int base = 10);
-unsigned charactersToUIntStrict(const UChar*, size_t, bool* ok = 0, int base = 10);
-int64_t charactersToInt64Strict(const UChar*, size_t, bool* ok = 0, int base = 10);
-uint64_t charactersToUInt64Strict(const UChar*, size_t, bool* ok = 0, int base = 10);
-
-int charactersToInt(const UChar*, size_t, bool* ok = 0); // ignores trailing garbage
-unsigned charactersToUInt(const UChar*, size_t, bool* ok = 0); // ignores trailing garbage
-int64_t charactersToInt64(const UChar*, size_t, bool* ok = 0); // ignores trailing garbage
-uint64_t charactersToUInt64(const UChar*, size_t, bool* ok = 0); // ignores trailing garbage
-
-double charactersToDouble(const UChar*, size_t, bool* ok = 0);
-float charactersToFloat(const UChar*, size_t, bool* ok = 0);
-
-int find(const UChar*, size_t, UChar, int startPosition = 0);
-int reverseFind(const UChar*, size_t, UChar, int startPosition = -1);
-
-#ifdef __OBJC__
-// This is for situations in WebKit where the long standing behavior has been
-// "nil if empty", so we try to maintain longstanding behavior for the sake of
-// entrenched clients
-inline NSString* nsStringNilIfEmpty(const String& str) { return str.isEmpty() ? nil : (NSString*)str; }
-#endif
-
-inline bool charactersAreAllASCII(const UChar* characters, size_t length)
-{
- UChar ored = 0;
- for (size_t i = 0; i < length; ++i)
- ored |= characters[i];
- return !(ored & 0xFF80);
-}
-
-inline int find(const UChar* characters, size_t length, UChar character, int startPosition)
-{
- if (startPosition >= static_cast<int>(length))
- return -1;
- for (size_t i = startPosition; i < length; ++i) {
- if (characters[i] == character)
- return static_cast<int>(i);
- }
- return -1;
-}
-
-inline int reverseFind(const UChar* characters, size_t length, UChar character, int startPosition)
-{
- if (startPosition >= static_cast<int>(length) || !length)
- return -1;
- if (startPosition < 0)
- startPosition += static_cast<int>(length);
- while (true) {
- if (characters[startPosition] == character)
- return startPosition;
- if (!startPosition)
- return -1;
- startPosition--;
- }
- ASSERT_NOT_REACHED();
- return -1;
-}
-
-inline void append(Vector<UChar>& vector, const String& string)
-{
- vector.append(string.characters(), string.length());
-}
-
-inline void appendNumber(Vector<UChar>& vector, unsigned char number)
-{
- int numberLength = number > 99 ? 3 : (number > 9 ? 2 : 1);
- size_t vectorSize = vector.size();
- vector.grow(vectorSize + numberLength);
-
- switch (numberLength) {
- case 3:
- vector[vectorSize + 2] = number % 10 + '0';
- number /= 10;
-
- case 2:
- vector[vectorSize + 1] = number % 10 + '0';
- number /= 10;
-
- case 1:
- vector[vectorSize] = number % 10 + '0';
- }
-}
-
-
-
-PassRefPtr<SharedBuffer> utf8Buffer(const String&);
-
-} // namespace WebCore
-
-namespace WTF {
-
- // StringHash is the default hash for String
- template<typename T> struct DefaultHash;
- template<> struct DefaultHash<WebCore::String> {
- typedef WebCore::StringHash Hash;
- };
-
-}
-
-#endif
diff --git a/WebCore/platform/text/RegularExpression.cpp b/WebCore/platform/text/RegularExpression.cpp
deleted file mode 100644
index 1b933ff..0000000
--- a/WebCore/platform/text/RegularExpression.cpp
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Copyright (C) 2004, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2008 Collabora Ltd.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "RegularExpression.h"
-
-#include "PlatformString.h"
-#include "Logging.h"
-#include <wtf/RefCounted.h>
-#include <pcre/pcre.h>
-#include <sys/types.h>
-
-namespace WebCore {
-
-const size_t maxSubstrings = 10;
-const size_t maxOffsets = 3 * maxSubstrings;
-
-class RegularExpression::Private : public RefCounted<Private> {
-public:
- static PassRefPtr<Private> create() { return adoptRef(new Private); }
- static PassRefPtr<Private> create(const String& pattern, bool caseSensitive) { return adoptRef(new Private(pattern, caseSensitive)); }
-
- ~Private();
-
- void compile(bool caseSensitive);
-
- String pattern;
- JSRegExp* regex;
-
- String lastMatchString;
- int lastMatchOffsets[maxOffsets];
- int lastMatchCount;
- int lastMatchPos;
- int lastMatchLength;
-
-private:
- Private();
- Private(const String& pattern, bool caseSensitive);
-};
-
-RegularExpression::Private::Private()
- : pattern("")
-{
- compile(true);
-}
-
-RegularExpression::Private::Private(const String& p, bool caseSensitive)
- : pattern(p)
- , lastMatchPos(-1)
- , lastMatchLength(-1)
-{
- compile(caseSensitive);
-}
-
-void RegularExpression::Private::compile(bool caseSensitive)
-{
- const char* errorMessage;
- regex = jsRegExpCompile(pattern.characters(), pattern.length(),
- caseSensitive ? JSRegExpDoNotIgnoreCase : JSRegExpIgnoreCase, JSRegExpSingleLine,
- 0, &errorMessage);
- if (!regex)
- LOG_ERROR("RegularExpression: pcre_compile failed with '%s'", errorMessage);
-}
-
-RegularExpression::Private::~Private()
-{
- jsRegExpFree(regex);
-}
-
-
-RegularExpression::RegularExpression()
- : d(Private::create())
-{
-}
-
-RegularExpression::RegularExpression(const String& pattern, bool caseSensitive)
- : d(Private::create(pattern, caseSensitive))
-{
-}
-
-RegularExpression::RegularExpression(const char* pattern)
- : d(Private::create(pattern, true))
-{
-}
-
-
-RegularExpression::RegularExpression(const RegularExpression& re)
- : d(re.d)
-{
-}
-
-RegularExpression::~RegularExpression()
-{
-}
-
-RegularExpression& RegularExpression::operator=(const RegularExpression& re)
-{
- RegularExpression tmp(re);
- tmp.d.swap(d);
- return *this;
-}
-
-String RegularExpression::pattern() const
-{
- return d->pattern;
-}
-
-int RegularExpression::match(const String& str, int startFrom, int* matchLength) const
-{
- if (str.isNull())
- return -1;
-
- d->lastMatchString = str;
- // First 2 offsets are start and end offsets; 3rd entry is used internally by pcre
- d->lastMatchCount = jsRegExpExecute(d->regex, d->lastMatchString.characters(),
- d->lastMatchString.length(), startFrom, d->lastMatchOffsets, maxOffsets);
- if (d->lastMatchCount < 0) {
- if (d->lastMatchCount != JSRegExpErrorNoMatch)
- LOG_ERROR("RegularExpression: pcre_exec() failed with result %d", d->lastMatchCount);
- d->lastMatchPos = -1;
- d->lastMatchLength = -1;
- d->lastMatchString = String();
- return -1;
- }
-
- // 1 means 1 match; 0 means more than one match. First match is recorded in offsets.
- d->lastMatchPos = d->lastMatchOffsets[0];
- d->lastMatchLength = d->lastMatchOffsets[1] - d->lastMatchOffsets[0];
- if (matchLength)
- *matchLength = d->lastMatchLength;
- return d->lastMatchPos;
-}
-
-int RegularExpression::search(const String& str, int startFrom) const
-{
- if (startFrom < 0)
- startFrom = str.length() - startFrom;
- return match(str, startFrom, 0);
-}
-
-int RegularExpression::searchRev(const String& str) const
-{
- // FIXME: Total hack for now. Search forward, return the last, greedy match
- int start = 0;
- int pos;
- int lastPos = -1;
- int lastMatchLength = -1;
- do {
- int matchLength;
- pos = match(str, start, &matchLength);
- if (pos >= 0) {
- if (pos + matchLength > lastPos + lastMatchLength) {
- // replace last match if this one is later and not a subset of the last match
- lastPos = pos;
- lastMatchLength = matchLength;
- }
- start = pos + 1;
- }
- } while (pos != -1);
- d->lastMatchPos = lastPos;
- d->lastMatchLength = lastMatchLength;
- return lastPos;
-}
-
-int RegularExpression::pos(int n)
-{
- ASSERT(n == 0);
- return d->lastMatchPos;
-}
-
-int RegularExpression::matchedLength() const
-{
- return d->lastMatchLength;
-}
-
-void replace(String& string, const RegularExpression& target, const String& replacement)
-{
- int index = 0;
- while (index < static_cast<int>(string.length())) {
- int matchLength;
- index = target.match(string, index, &matchLength);
- if (index < 0)
- break;
- string.replace(index, matchLength, replacement);
- index += replacement.length();
- if (!matchLength)
- break; // Avoid infinite loop on 0-length matches, e.g. [a-z]*
- }
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/text/RegularExpression.h b/WebCore/platform/text/RegularExpression.h
deleted file mode 100644
index 5d1991e..0000000
--- a/WebCore/platform/text/RegularExpression.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2003, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef RegularExpression_h
-#define RegularExpression_h
-
-#include <wtf/RefPtr.h>
-
-namespace WebCore {
-
-class String;
-
-class RegularExpression {
-public:
- RegularExpression();
- RegularExpression(const String&, bool caseSensitive = false);
- RegularExpression(const char*);
- ~RegularExpression();
-
- RegularExpression(const RegularExpression&);
- RegularExpression& operator=(const RegularExpression&);
-
- String pattern() const;
- int match(const String&, int startFrom = 0, int* matchLength = 0) const;
-
- int search(const String&, int startFrom = 0) const;
- int searchRev(const String&) const;
-
- int pos(int n = 0);
- int matchedLength() const;
-
-private:
- class Private;
- RefPtr<Private> d;
-};
-
-void replace(String&, const RegularExpression&, const String&);
-
-} // namespace WebCore
-
-#endif // RegularExpression_h
diff --git a/WebCore/platform/text/SegmentedString.cpp b/WebCore/platform/text/SegmentedString.cpp
deleted file mode 100644
index 9f5eb26..0000000
--- a/WebCore/platform/text/SegmentedString.cpp
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#include "config.h"
-#include "SegmentedString.h"
-
-namespace WebCore {
-
-SegmentedString::SegmentedString(const SegmentedString &other) :
- m_pushedChar1(other.m_pushedChar1), m_pushedChar2(other.m_pushedChar2), m_currentString(other.m_currentString),
- m_substrings(other.m_substrings), m_composite(other.m_composite)
-{
- if (other.m_currentChar == &other.m_pushedChar1)
- m_currentChar = &m_pushedChar1;
- else if (other.m_currentChar == &other.m_pushedChar2)
- m_currentChar = &m_pushedChar2;
- else
- m_currentChar = other.m_currentChar;
-}
-
-const SegmentedString& SegmentedString::operator=(const SegmentedString &other)
-{
- m_pushedChar1 = other.m_pushedChar1;
- m_pushedChar2 = other.m_pushedChar2;
- m_currentString = other.m_currentString;
- m_substrings = other.m_substrings;
- m_composite = other.m_composite;
- if (other.m_currentChar == &other.m_pushedChar1)
- m_currentChar = &m_pushedChar1;
- else if (other.m_currentChar == &other.m_pushedChar2)
- m_currentChar = &m_pushedChar2;
- else
- m_currentChar = other.m_currentChar;
- return *this;
-}
-
-unsigned SegmentedString::length() const
-{
- unsigned length = m_currentString.m_length;
- if (m_pushedChar1) {
- ++length;
- if (m_pushedChar2)
- ++length;
- }
- if (m_composite) {
- Deque<SegmentedSubstring>::const_iterator it = m_substrings.begin();
- Deque<SegmentedSubstring>::const_iterator e = m_substrings.end();
- for (; it != e; ++it)
- length += it->m_length;
- }
- return length;
-}
-
-void SegmentedString::setExcludeLineNumbers()
-{
- if (m_composite) {
- Deque<SegmentedSubstring>::iterator it = m_substrings.begin();
- Deque<SegmentedSubstring>::iterator e = m_substrings.end();
- for (; it != e; ++it)
- it->setExcludeLineNumbers();
- } else
- m_currentString.setExcludeLineNumbers();
-}
-
-void SegmentedString::clear()
-{
- m_pushedChar1 = 0;
- m_pushedChar2 = 0;
- m_currentChar = 0;
- m_currentString.clear();
- m_substrings.clear();
- m_composite = false;
-}
-
-void SegmentedString::append(const SegmentedSubstring &s)
-{
- if (s.m_length) {
- if (!m_currentString.m_length) {
- m_currentString = s;
- } else {
- m_substrings.append(s);
- m_composite = true;
- }
- }
-}
-
-void SegmentedString::prepend(const SegmentedSubstring &s)
-{
- ASSERT(!escaped());
- if (s.m_length) {
- if (!m_currentString.m_length)
- m_currentString = s;
- else {
- // Shift our m_currentString into our list.
- m_substrings.prepend(m_currentString);
- m_currentString = s;
- m_composite = true;
- }
- }
-}
-
-void SegmentedString::append(const SegmentedString &s)
-{
- ASSERT(!s.escaped());
- append(s.m_currentString);
- if (s.m_composite) {
- Deque<SegmentedSubstring>::const_iterator it = s.m_substrings.begin();
- Deque<SegmentedSubstring>::const_iterator e = s.m_substrings.end();
- for (; it != e; ++it)
- append(*it);
- }
- m_currentChar = m_pushedChar1 ? &m_pushedChar1 : m_currentString.m_current;
-}
-
-void SegmentedString::prepend(const SegmentedString &s)
-{
- ASSERT(!escaped());
- ASSERT(!s.escaped());
- if (s.m_composite) {
- Deque<SegmentedSubstring>::const_reverse_iterator it = s.m_substrings.rbegin();
- Deque<SegmentedSubstring>::const_reverse_iterator e = s.m_substrings.rend();
- for (; it != e; ++it)
- prepend(*it);
- }
- prepend(s.m_currentString);
- m_currentChar = m_pushedChar1 ? &m_pushedChar1 : m_currentString.m_current;
-}
-
-void SegmentedString::advanceSubstring()
-{
- if (m_composite) {
- m_currentString = m_substrings.first();
- m_substrings.removeFirst();
- if (m_substrings.isEmpty())
- m_composite = false;
- } else {
- m_currentString.clear();
- }
-}
-
-String SegmentedString::toString() const
-{
- String result;
- if (m_pushedChar1) {
- result.append(m_pushedChar1);
- if (m_pushedChar2)
- result.append(m_pushedChar2);
- }
- m_currentString.appendTo(result);
- if (m_composite) {
- Deque<SegmentedSubstring>::const_iterator it = m_substrings.begin();
- Deque<SegmentedSubstring>::const_iterator e = m_substrings.end();
- for (; it != e; ++it)
- it->appendTo(result);
- }
- return result;
-}
-
-void SegmentedString::advanceSlowCase()
-{
- if (m_pushedChar1) {
- m_pushedChar1 = m_pushedChar2;
- m_pushedChar2 = 0;
- } else if (m_currentString.m_current) {
- ++m_currentString.m_current;
- if (--m_currentString.m_length == 0)
- advanceSubstring();
- }
- m_currentChar = m_pushedChar1 ? &m_pushedChar1 : m_currentString.m_current;
-}
-
-void SegmentedString::advanceSlowCase(int& lineNumber)
-{
- if (m_pushedChar1) {
- m_pushedChar1 = m_pushedChar2;
- m_pushedChar2 = 0;
- } else if (m_currentString.m_current) {
- if (*m_currentString.m_current++ == '\n' && m_currentString.doNotExcludeLineNumbers())
- ++lineNumber;
- if (--m_currentString.m_length == 0)
- advanceSubstring();
- }
- m_currentChar = m_pushedChar1 ? &m_pushedChar1 : m_currentString.m_current;
-}
-
-}
diff --git a/WebCore/platform/text/SegmentedString.h b/WebCore/platform/text/SegmentedString.h
deleted file mode 100644
index 79ed1f0..0000000
--- a/WebCore/platform/text/SegmentedString.h
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-#ifndef SegmentedString_h
-#define SegmentedString_h
-
-#include "PlatformString.h"
-#include <wtf/Deque.h>
-
-namespace WebCore {
-
-class SegmentedString;
-
-class SegmentedSubstring {
-public:
- SegmentedSubstring() : m_length(0), m_current(0), m_doNotExcludeLineNumbers(true) {}
- SegmentedSubstring(const String& str)
- : m_length(str.length())
- , m_current(str.isEmpty() ? 0 : str.characters())
- , m_string(str)
- , m_doNotExcludeLineNumbers(true)
- {
- }
-
- SegmentedSubstring(const UChar* str, int length) : m_length(length), m_current(length == 0 ? 0 : str), m_doNotExcludeLineNumbers(true) {}
-
- void clear() { m_length = 0; m_current = 0; }
-
- bool excludeLineNumbers() const { return !m_doNotExcludeLineNumbers; }
- bool doNotExcludeLineNumbers() const { return m_doNotExcludeLineNumbers; }
-
- void setExcludeLineNumbers() { m_doNotExcludeLineNumbers = false; }
-
- void appendTo(String& str) const
- {
- if (m_string.characters() == m_current) {
- if (str.isEmpty())
- str = m_string;
- else
- str.append(m_string);
- } else {
- str.append(String(m_current, m_length));
- }
- }
-
-public:
- int m_length;
- const UChar* m_current;
-
-private:
- String m_string;
- bool m_doNotExcludeLineNumbers;
-};
-
-class SegmentedString {
-public:
- SegmentedString()
- : m_pushedChar1(0), m_pushedChar2(0), m_currentChar(0), m_composite(false) {}
- SegmentedString(const UChar* str, int length) : m_pushedChar1(0), m_pushedChar2(0)
- , m_currentString(str, length), m_currentChar(m_currentString.m_current), m_composite(false) {}
- SegmentedString(const String& str)
- : m_pushedChar1(0), m_pushedChar2(0), m_currentString(str)
- , m_currentChar(m_currentString.m_current), m_composite(false) {}
- SegmentedString(const SegmentedString&);
-
- const SegmentedString& operator=(const SegmentedString&);
-
- void clear();
-
- void append(const SegmentedString&);
- void prepend(const SegmentedString&);
-
- bool excludeLineNumbers() const { return m_currentString.excludeLineNumbers(); }
- void setExcludeLineNumbers();
-
- void push(UChar c)
- {
- if (!m_pushedChar1) {
- m_pushedChar1 = c;
- m_currentChar = m_pushedChar1 ? &m_pushedChar1 : m_currentString.m_current;
- } else {
- ASSERT(!m_pushedChar2);
- m_pushedChar2 = c;
- }
- }
-
- bool isEmpty() const { return !current(); }
- unsigned length() const;
-
- void advance()
- {
- if (!m_pushedChar1 && m_currentString.m_length > 1) {
- --m_currentString.m_length;
- m_currentChar = ++m_currentString.m_current;
- return;
- }
- advanceSlowCase();
- }
-
- void advancePastNewline(int& lineNumber)
- {
- ASSERT(*current() == '\n');
- if (!m_pushedChar1 && m_currentString.m_length > 1) {
- lineNumber += m_currentString.doNotExcludeLineNumbers();
- --m_currentString.m_length;
- m_currentChar = ++m_currentString.m_current;
- return;
- }
- advanceSlowCase(lineNumber);
- }
-
- void advancePastNonNewline()
- {
- ASSERT(*current() != '\n');
- if (!m_pushedChar1 && m_currentString.m_length > 1) {
- --m_currentString.m_length;
- m_currentChar = ++m_currentString.m_current;
- return;
- }
- advanceSlowCase();
- }
-
- void advance(int& lineNumber)
- {
- if (!m_pushedChar1 && m_currentString.m_length > 1) {
- lineNumber += (*m_currentString.m_current == '\n') & m_currentString.doNotExcludeLineNumbers();
- --m_currentString.m_length;
- m_currentChar = ++m_currentString.m_current;
- return;
- }
- advanceSlowCase(lineNumber);
- }
-
- bool escaped() const { return m_pushedChar1; }
-
- String toString() const;
-
- const UChar& operator*() const { return *current(); }
- const UChar* operator->() const { return current(); }
-
-private:
- void append(const SegmentedSubstring&);
- void prepend(const SegmentedSubstring&);
-
- void advanceSlowCase();
- void advanceSlowCase(int& lineNumber);
- void advanceSubstring();
- const UChar* current() const { return m_currentChar; }
-
- UChar m_pushedChar1;
- UChar m_pushedChar2;
- SegmentedSubstring m_currentString;
- const UChar* m_currentChar;
- Deque<SegmentedSubstring> m_substrings;
- bool m_composite;
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/text/String.cpp b/WebCore/platform/text/String.cpp
deleted file mode 100644
index 44500e1..0000000
--- a/WebCore/platform/text/String.cpp
+++ /dev/null
@@ -1,831 +0,0 @@
-/*
- * (C) 1999 Lars Knoll (knoll@kde.org)
- * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-#include "PlatformString.h"
-
-#include "CString.h"
-#include "FloatConversion.h"
-#include "StringBuffer.h"
-#include "TextEncoding.h"
-#include <kjs/dtoa.h>
-#include <limits>
-#include <stdarg.h>
-#include <wtf/ASCIICType.h>
-#include <wtf/StringExtras.h>
-#include <wtf/Vector.h>
-#include <wtf/unicode/Unicode.h>
-#include <wtf/unicode/UTF8.h>
-
-#if USE(JSC)
-using JSC::Identifier;
-using JSC::UString;
-#endif
-
-using namespace WTF;
-using namespace WTF::Unicode;
-
-namespace WebCore {
-
-String::String(const UChar* str, unsigned len)
-{
- if (!str)
- return;
- m_impl = StringImpl::create(str, len);
-}
-
-String::String(const UChar* str)
-{
- if (!str)
- return;
-
- int len = 0;
- while (str[len] != UChar(0))
- len++;
-
- m_impl = StringImpl::create(str, len);
-}
-
-String::String(const char* str)
-{
- if (!str)
- return;
- m_impl = StringImpl::create(str);
-}
-
-String::String(const char* str, unsigned length)
-{
- if (!str)
- return;
- m_impl = StringImpl::create(str, length);
-}
-
-void String::append(const String& str)
-{
- // FIXME: This is extremely inefficient. So much so that we might want to take this
- // out of String's API. We can make it better by optimizing the case where exactly
- // one String is pointing at this StringImpl, but even then it's going to require a
- // call to fastMalloc every single time.
- if (str.m_impl) {
- if (m_impl) {
- StringBuffer buffer(m_impl->length() + str.length());
- memcpy(buffer.characters(), m_impl->characters(), m_impl->length() * sizeof(UChar));
- memcpy(buffer.characters() + m_impl->length(), str.characters(), str.length() * sizeof(UChar));
- m_impl = StringImpl::adopt(buffer);
- } else
- m_impl = str.m_impl;
- }
-}
-
-void String::append(char c)
-{
- // FIXME: This is extremely inefficient. So much so that we might want to take this
- // out of String's API. We can make it better by optimizing the case where exactly
- // one String is pointing at this StringImpl, but even then it's going to require a
- // call to fastMalloc every single time.
- if (m_impl) {
- StringBuffer buffer(m_impl->length() + 1);
- memcpy(buffer.characters(), m_impl->characters(), m_impl->length() * sizeof(UChar));
- buffer[m_impl->length()] = c;
- m_impl = StringImpl::adopt(buffer);
- } else
- m_impl = StringImpl::create(&c, 1);
-}
-
-void String::append(UChar c)
-{
- // FIXME: This is extremely inefficient. So much so that we might want to take this
- // out of String's API. We can make it better by optimizing the case where exactly
- // one String is pointing at this StringImpl, but even then it's going to require a
- // call to fastMalloc every single time.
- if (m_impl) {
- StringBuffer buffer(m_impl->length() + 1);
- memcpy(buffer.characters(), m_impl->characters(), m_impl->length() * sizeof(UChar));
- buffer[m_impl->length()] = c;
- m_impl = StringImpl::adopt(buffer);
- } else
- m_impl = StringImpl::create(&c, 1);
-}
-
-String operator+(const String& a, const String& b)
-{
- if (a.isEmpty())
- return b;
- if (b.isEmpty())
- return a;
- String c = a;
- c += b;
- return c;
-}
-
-String operator+(const String& s, const char* cs)
-{
- return s + String(cs);
-}
-
-String operator+(const char* cs, const String& s)
-{
- return String(cs) + s;
-}
-
-void String::insert(const String& str, unsigned pos)
-{
- if (str.isEmpty()) {
- if (str.isNull())
- return;
- if (isNull())
- m_impl = str.impl();
- return;
- }
- insert(str.characters(), str.length(), pos);
-}
-
-void String::append(const UChar* charactersToAppend, unsigned lengthToAppend)
-{
- if (!m_impl) {
- if (!charactersToAppend)
- return;
- m_impl = StringImpl::create(charactersToAppend, lengthToAppend);
- return;
- }
-
- if (!lengthToAppend)
- return;
-
- ASSERT(charactersToAppend);
- StringBuffer buffer(length() + lengthToAppend);
- memcpy(buffer.characters(), characters(), length() * sizeof(UChar));
- memcpy(buffer.characters() + length(), charactersToAppend, lengthToAppend * sizeof(UChar));
- m_impl = StringImpl::adopt(buffer);
-}
-
-void String::insert(const UChar* charactersToInsert, unsigned lengthToInsert, unsigned position)
-{
- if (position >= length()) {
- append(charactersToInsert, lengthToInsert);
- return;
- }
-
- ASSERT(m_impl);
-
- if (!lengthToInsert)
- return;
-
- ASSERT(charactersToInsert);
- StringBuffer buffer(length() + lengthToInsert);
- memcpy(buffer.characters(), characters(), position * sizeof(UChar));
- memcpy(buffer.characters() + position, charactersToInsert, lengthToInsert * sizeof(UChar));
- memcpy(buffer.characters() + position + lengthToInsert, characters() + position, (length() - position) * sizeof(UChar));
- m_impl = StringImpl::adopt(buffer);
-}
-
-UChar String::operator[](unsigned i) const
-{
- if (!m_impl || i >= m_impl->length())
- return 0;
- return m_impl->characters()[i];
-}
-
-UChar32 String::characterStartingAt(unsigned i) const
-{
- if (!m_impl || i >= m_impl->length())
- return 0;
- return m_impl->characterStartingAt(i);
-}
-
-unsigned String::length() const
-{
- if (!m_impl)
- return 0;
- return m_impl->length();
-}
-
-void String::truncate(unsigned position)
-{
- if (position >= length())
- return;
- StringBuffer buffer(position);
- memcpy(buffer.characters(), characters(), position * sizeof(UChar));
- m_impl = StringImpl::adopt(buffer);
-}
-
-void String::remove(unsigned position, int lengthToRemove)
-{
- if (lengthToRemove <= 0)
- return;
- if (position >= length())
- return;
- if (static_cast<unsigned>(lengthToRemove) > length() - position)
- lengthToRemove = length() - position;
- StringBuffer buffer(length() - lengthToRemove);
- memcpy(buffer.characters(), characters(), position * sizeof(UChar));
- memcpy(buffer.characters() + position, characters() + position + lengthToRemove,
- (length() - lengthToRemove - position) * sizeof(UChar));
- m_impl = StringImpl::adopt(buffer);
-}
-
-String String::substring(unsigned pos, unsigned len) const
-{
- if (!m_impl)
- return String();
- return m_impl->substring(pos, len);
-}
-
-String String::lower() const
-{
- if (!m_impl)
- return String();
- return m_impl->lower();
-}
-
-String String::upper() const
-{
- if (!m_impl)
- return String();
- return m_impl->upper();
-}
-
-String String::stripWhiteSpace() const
-{
- if (!m_impl)
- return String();
- return m_impl->stripWhiteSpace();
-}
-
-String String::simplifyWhiteSpace() const
-{
- if (!m_impl)
- return String();
- return m_impl->simplifyWhiteSpace();
-}
-
-String String::foldCase() const
-{
- if (!m_impl)
- return String();
- return m_impl->foldCase();
-}
-
-bool String::percentage(int& result) const
-{
- if (!m_impl || !m_impl->length())
- return false;
-
- if ((*m_impl)[m_impl->length() - 1] != '%')
- return false;
-
- result = charactersToIntStrict(m_impl->characters(), m_impl->length() - 1);
- return true;
-}
-
-const UChar* String::characters() const
-{
- if (!m_impl)
- return 0;
- return m_impl->characters();
-}
-
-const UChar* String::charactersWithNullTermination()
-{
- if (!m_impl)
- return 0;
- if (m_impl->hasTerminatingNullCharacter())
- return m_impl->characters();
- m_impl = StringImpl::createWithTerminatingNullCharacter(*m_impl);
- return m_impl->characters();
-}
-
-String String::format(const char *format, ...)
-{
-#if PLATFORM(QT)
- // Use QString::vsprintf to avoid the locale dependent formatting of vsnprintf.
- // https://bugs.webkit.org/show_bug.cgi?id=18994
- va_list args;
- va_start(args, format);
-
- QString buffer;
- buffer.vsprintf(format, args);
-
- va_end(args);
-
- return buffer;
-#else
- va_list args;
- va_start(args, format);
-
- Vector<char, 256> buffer;
-
- // Do the format once to get the length.
-#if COMPILER(MSVC)
- int result = _vscprintf(format, args);
-#else
- char ch;
- int result = vsnprintf(&ch, 1, format, args);
- // We need to call va_end() and then va_start() again here, as the
- // contents of args is undefined after the call to vsnprintf
- // according to http://man.cx/snprintf(3)
- //
- // Not calling va_end/va_start here happens to work on lots of
- // systems, but fails e.g. on 64bit Linux.
- va_end(args);
- va_start(args, format);
-#endif
-
- if (result == 0)
- return String("");
- if (result < 0)
- return String();
- unsigned len = result;
- buffer.grow(len + 1);
-
- // Now do the formatting again, guaranteed to fit.
- vsnprintf(buffer.data(), buffer.size(), format, args);
-
- va_end(args);
-
- return StringImpl::create(buffer.data(), len);
-#endif
-}
-
-String String::number(int n)
-{
- return String::format("%d", n);
-}
-
-String String::number(unsigned n)
-{
- return String::format("%u", n);
-}
-
-String String::number(long n)
-{
- return String::format("%ld", n);
-}
-
-String String::number(unsigned long n)
-{
- return String::format("%lu", n);
-}
-
-String String::number(long long n)
-{
-#if PLATFORM(WIN_OS)
- return String::format("%I64i", n);
-#else
- return String::format("%lli", n);
-#endif
-}
-
-String String::number(unsigned long long n)
-{
-#if PLATFORM(WIN_OS)
- return String::format("%I64u", n);
-#else
- return String::format("%llu", n);
-#endif
-}
-
-String String::number(double n)
-{
- return String::format("%.6lg", n);
-}
-
-int String::toIntStrict(bool* ok, int base) const
-{
- if (!m_impl) {
- if (ok)
- *ok = false;
- return 0;
- }
- return m_impl->toIntStrict(ok, base);
-}
-
-unsigned String::toUIntStrict(bool* ok, int base) const
-{
- if (!m_impl) {
- if (ok)
- *ok = false;
- return 0;
- }
- return m_impl->toUIntStrict(ok, base);
-}
-
-int64_t String::toInt64Strict(bool* ok, int base) const
-{
- if (!m_impl) {
- if (ok)
- *ok = false;
- return 0;
- }
- return m_impl->toInt64Strict(ok, base);
-}
-
-uint64_t String::toUInt64Strict(bool* ok, int base) const
-{
- if (!m_impl) {
- if (ok)
- *ok = false;
- return 0;
- }
- return m_impl->toUInt64Strict(ok, base);
-}
-
-int String::toInt(bool* ok) const
-{
- if (!m_impl) {
- if (ok)
- *ok = false;
- return 0;
- }
- return m_impl->toInt(ok);
-}
-
-unsigned String::toUInt(bool* ok) const
-{
- if (!m_impl) {
- if (ok)
- *ok = false;
- return 0;
- }
- return m_impl->toUInt(ok);
-}
-
-int64_t String::toInt64(bool* ok) const
-{
- if (!m_impl) {
- if (ok)
- *ok = false;
- return 0;
- }
- return m_impl->toInt64(ok);
-}
-
-uint64_t String::toUInt64(bool* ok) const
-{
- if (!m_impl) {
- if (ok)
- *ok = false;
- return 0;
- }
- return m_impl->toUInt64(ok);
-}
-
-double String::toDouble(bool* ok) const
-{
- if (!m_impl) {
- if (ok)
- *ok = false;
- return 0.0;
- }
- return m_impl->toDouble(ok);
-}
-
-float String::toFloat(bool* ok) const
-{
- if (!m_impl) {
- if (ok)
- *ok = false;
- return 0.0f;
- }
- return m_impl->toFloat(ok);
-}
-
-String String::copy() const
-{
- if (!m_impl)
- return String();
- return m_impl->copy();
-}
-
-bool String::isEmpty() const
-{
- return !m_impl || !m_impl->length();
-}
-
-void String::split(const String& separator, bool allowEmptyEntries, Vector<String>& result) const
-{
- result.clear();
-
- int startPos = 0;
- int endPos;
- while ((endPos = find(separator, startPos)) != -1) {
- if (allowEmptyEntries || startPos != endPos)
- result.append(substring(startPos, endPos - startPos));
- startPos = endPos + separator.length();
- }
- if (allowEmptyEntries || startPos != static_cast<int>(length()))
- result.append(substring(startPos));
-}
-
-void String::split(const String& separator, Vector<String>& result) const
-{
- return split(separator, false, result);
-}
-
-void String::split(UChar separator, bool allowEmptyEntries, Vector<String>& result) const
-{
- result.clear();
-
- int startPos = 0;
- int endPos;
- while ((endPos = find(separator, startPos)) != -1) {
- if (allowEmptyEntries || startPos != endPos)
- result.append(substring(startPos, endPos - startPos));
- startPos = endPos + 1;
- }
- if (allowEmptyEntries || startPos != static_cast<int>(length()))
- result.append(substring(startPos));
-}
-
-void String::split(UChar separator, Vector<String>& result) const
-{
- return split(String(&separator, 1), false, result);
-}
-
-#ifndef NDEBUG
-Vector<char> String::ascii() const
-{
- if (m_impl)
- return m_impl->ascii();
-
- const char* nullMsg = "(null impl)";
- Vector<char, 2048> buffer;
- for (int i = 0; nullMsg[i]; ++i)
- buffer.append(nullMsg[i]);
-
- buffer.append('\0');
- return buffer;
-}
-#endif
-
-CString String::latin1() const
-{
- return Latin1Encoding().encode(characters(), length(), QuestionMarksForUnencodables);
-}
-
-CString String::utf8() const
-{
- return UTF8Encoding().encode(characters(), length(), QuestionMarksForUnencodables);
-}
-
-String String::fromUTF8(const char* string, size_t size)
-{
- if (!string)
- return String();
- return UTF8Encoding().decode(string, size);
-}
-
-String String::fromUTF8(const char* string)
-{
- if (!string)
- return String();
- return UTF8Encoding().decode(string, strlen(string));
-}
-
-#if USE(JSC)
-String::String(const Identifier& str)
-{
- if (str.isNull())
- return;
- m_impl = StringImpl::create(str.data(), str.size());
-}
-
-String::String(const UString& str)
-{
- if (str.isNull())
- return;
- m_impl = StringImpl::create(str.data(), str.size());
-}
-
-String::operator UString() const
-{
- if (!m_impl)
- return UString();
- return UString(m_impl->characters(), m_impl->length());
-}
-#endif
-
-// String Operations
-
-static bool isCharacterAllowedInBase(UChar c, int base)
-{
- if (c > 0x7F)
- return false;
- if (isASCIIDigit(c))
- return c - '0' < base;
- if (isASCIIAlpha(c)) {
- if (base > 36)
- base = 36;
- return (c >= 'a' && c < 'a' + base - 10)
- || (c >= 'A' && c < 'A' + base - 10);
- }
- return false;
-}
-
-template <typename IntegralType>
-static inline IntegralType toIntegralType(const UChar* data, size_t length, bool* ok, int base)
-{
- static const IntegralType integralMax = std::numeric_limits<IntegralType>::max();
- static const bool isSigned = std::numeric_limits<IntegralType>::is_signed;
- const IntegralType maxMultiplier = integralMax / base;
-
- IntegralType value = 0;
- bool isOk = false;
- bool isNegative = false;
-
- if (!data)
- goto bye;
-
- // skip leading whitespace
- while (length && isSpaceOrNewline(*data)) {
- length--;
- data++;
- }
-
- if (isSigned && length && *data == '-') {
- length--;
- data++;
- isNegative = true;
- } else if (length && *data == '+') {
- length--;
- data++;
- }
-
- if (!length || !isCharacterAllowedInBase(*data, base))
- goto bye;
-
- while (length && isCharacterAllowedInBase(*data, base)) {
- length--;
- IntegralType digitValue;
- UChar c = *data;
- if (isASCIIDigit(c))
- digitValue = c - '0';
- else if (c >= 'a')
- digitValue = c - 'a' + 10;
- else
- digitValue = c - 'A' + 10;
-
- if (value > maxMultiplier || (value == maxMultiplier && digitValue > (integralMax % base) + isNegative))
- goto bye;
-
- value = base * value + digitValue;
- data++;
- }
-
-#if COMPILER(MSVC)
-#pragma warning(push, 0)
-#pragma warning(disable:4146)
-#endif
-
- if (isNegative)
- value = -value;
-
-#if COMPILER(MSVC)
-#pragma warning(pop)
-#endif
-
- // skip trailing space
- while (length && isSpaceOrNewline(*data)) {
- length--;
- data++;
- }
-
- if (!length)
- isOk = true;
-bye:
- if (ok)
- *ok = isOk;
- return isOk ? value : 0;
-}
-
-static unsigned lengthOfCharactersAsInteger(const UChar* data, size_t length)
-{
- size_t i = 0;
-
- // Allow leading spaces.
- for (; i != length; ++i) {
- if (!isSpaceOrNewline(data[i]))
- break;
- }
-
- // Allow sign.
- if (i != length && (data[i] == '+' || data[i] == '-'))
- ++i;
-
- // Allow digits.
- for (; i != length; ++i) {
- if (!isASCIIDigit(data[i]))
- break;
- }
-
- return i;
-}
-
-int charactersToIntStrict(const UChar* data, size_t length, bool* ok, int base)
-{
- return toIntegralType<int>(data, length, ok, base);
-}
-
-unsigned charactersToUIntStrict(const UChar* data, size_t length, bool* ok, int base)
-{
- return toIntegralType<unsigned>(data, length, ok, base);
-}
-
-int64_t charactersToInt64Strict(const UChar* data, size_t length, bool* ok, int base)
-{
- return toIntegralType<int64_t>(data, length, ok, base);
-}
-
-uint64_t charactersToUInt64Strict(const UChar* data, size_t length, bool* ok, int base)
-{
- return toIntegralType<uint64_t>(data, length, ok, base);
-}
-
-int charactersToInt(const UChar* data, size_t length, bool* ok)
-{
- return toIntegralType<int>(data, lengthOfCharactersAsInteger(data, length), ok, 10);
-}
-
-unsigned charactersToUInt(const UChar* data, size_t length, bool* ok)
-{
- return toIntegralType<unsigned>(data, lengthOfCharactersAsInteger(data, length), ok, 10);
-}
-
-int64_t charactersToInt64(const UChar* data, size_t length, bool* ok)
-{
- return toIntegralType<int64_t>(data, lengthOfCharactersAsInteger(data, length), ok, 10);
-}
-
-uint64_t charactersToUInt64(const UChar* data, size_t length, bool* ok)
-{
- return toIntegralType<uint64_t>(data, lengthOfCharactersAsInteger(data, length), ok, 10);
-}
-
-double charactersToDouble(const UChar* data, size_t length, bool* ok)
-{
- if (!length) {
- if (ok)
- *ok = false;
- return 0.0;
- }
-
- Vector<char, 256> bytes(length + 1);
- for (unsigned i = 0; i < length; ++i)
- bytes[i] = data[i] < 0x7F ? data[i] : '?';
- bytes[length] = '\0';
- char* end;
- double val = JSC::strtod(bytes.data(), &end);
- if (ok)
- *ok = (end == 0 || *end == '\0');
- return val;
-}
-
-float charactersToFloat(const UChar* data, size_t length, bool* ok)
-{
- // FIXME: This will return ok even when the string fits into a double but not a float.
- return narrowPrecisionToFloat(charactersToDouble(data, length, ok));
-}
-
-PassRefPtr<SharedBuffer> utf8Buffer(const String& string)
-{
- // Allocate a buffer big enough to hold all the characters.
- const int length = string.length();
- Vector<char> buffer(length * 3);
-
- // Convert to runs of 8-bit characters.
- char* p = buffer.data();
- const UChar* d = string.characters();
- ConversionResult result = convertUTF16ToUTF8(&d, d + length, &p, p + buffer.size(), true);
- if (result != conversionOK)
- return 0;
-
- buffer.shrink(p - buffer.data());
- return SharedBuffer::adoptVector(buffer);
-}
-
-} // namespace WebCore
-
-#ifndef NDEBUG
-// For debugging only -- leaks memory
-WebCore::String* string(const char* s)
-{
- return new WebCore::String(s);
-}
-#endif
diff --git a/WebCore/platform/text/StringBuffer.h b/WebCore/platform/text/StringBuffer.h
deleted file mode 100644
index 28d4e89..0000000
--- a/WebCore/platform/text/StringBuffer.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Inc. ("Apple") nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef StringBuffer_h
-#define StringBuffer_h
-
-#include <wtf/Assertions.h>
-#include <wtf/Noncopyable.h>
-#include <wtf/unicode/Unicode.h>
-
-namespace WebCore {
-
-class StringBuffer : Noncopyable {
-public:
- explicit StringBuffer(unsigned length)
- : m_length(length)
- , m_data(static_cast<UChar*>(fastMalloc(length * sizeof(UChar))))
- {
- }
- ~StringBuffer()
- {
- fastFree(m_data);
- }
-
- void shrink(unsigned newLength)
- {
- ASSERT(newLength <= m_length);
- m_length = newLength;
- }
-
- void resize(unsigned newLength)
- {
- if (newLength > m_length)
- m_data = static_cast<UChar*>(fastRealloc(m_data, newLength * sizeof(UChar)));
- m_length = newLength;
- }
-
- unsigned length() const { return m_length; }
- UChar* characters() { return m_data; }
-
- UChar& operator[](unsigned i) { ASSERT(i < m_length); return m_data[i]; }
-
- UChar* release() { UChar* data = m_data; m_data = 0; return data; }
-
-private:
- unsigned m_length;
- UChar* m_data;
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/text/StringBuilder.cpp b/WebCore/platform/text/StringBuilder.cpp
deleted file mode 100644
index 0e9555c..0000000
--- a/WebCore/platform/text/StringBuilder.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "StringBuilder.h"
-
-#include "StringBuffer.h"
-
-namespace WebCore {
-
-void StringBuilder::append(const String& string)
-{
- if (string.isNull())
- return;
-
- if (m_totalLength == UINT_MAX)
- m_totalLength = string.length();
- else
- m_totalLength += string.length();
-
- if (!string.isEmpty())
- m_strings.append(string);
-}
-
-void StringBuilder::append(UChar c)
-{
- if (m_totalLength == UINT_MAX)
- m_totalLength = 1;
- else
- m_totalLength += 1;
-
- m_strings.append(String(&c, 1));
-}
-
-void StringBuilder::append(char c)
-{
- if (m_totalLength == UINT_MAX)
- m_totalLength = 1;
- else
- m_totalLength += 1;
-
- m_strings.append(String(&c, 1));
-}
-
-String StringBuilder::toString() const
-{
- if (isNull())
- return String();
-
- unsigned count = m_strings.size();
-
- if (!count)
- return String(StringImpl::empty());
- if (count == 1)
- return m_strings[0];
-
- StringBuffer buffer(m_totalLength);
-
- UChar* p = buffer.characters();
- for (unsigned i = 0; i < count; ++i) {
- StringImpl* string = m_strings[i].impl();
- unsigned length = string->length();
- memcpy(p, string->characters(), length * 2);
- p += length;
- }
-
- ASSERT(p == m_totalLength + buffer.characters());
-
- return String::adopt(buffer);
-}
-
-}
diff --git a/WebCore/platform/text/StringBuilder.h b/WebCore/platform/text/StringBuilder.h
deleted file mode 100644
index 8d76b9c..0000000
--- a/WebCore/platform/text/StringBuilder.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef StringBuilder_h
-#define StringBuilder_h
-
-#include "PlatformString.h"
-
-namespace WebCore {
-
- class StringBuilder {
- public:
- StringBuilder() : m_totalLength(UINT_MAX) {}
-
- void setNonNull() { if (m_totalLength == UINT_MAX) m_totalLength = 0; }
-
- void append(const String&);
- void append(UChar);
- void append(char);
-
- String toString() const;
-
- private:
- bool isNull() const { return m_totalLength == UINT_MAX; }
-
- unsigned m_totalLength;
- Vector<String, 16> m_strings;
- };
-
-}
-
-#endif
diff --git a/WebCore/platform/text/StringHash.h b/WebCore/platform/text/StringHash.h
deleted file mode 100644
index c6e08a6..0000000
--- a/WebCore/platform/text/StringHash.h
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef StringHash_h
-#define StringHash_h
-
-#include "AtomicStringImpl.h"
-#include "PlatformString.h"
-#include <wtf/HashTraits.h>
-#include <wtf/unicode/Unicode.h>
-
-namespace WebCore {
-
- // FIXME: We should really figure out a way to put the computeHash function that's
- // currently a member function of StringImpl into this file so we can be a little
- // closer to having all the nearly-identical hash functions in one place.
-
- struct StringHash {
- static unsigned hash(StringImpl* key) { return key->hash(); }
- static bool equal(StringImpl* a, StringImpl* b)
- {
- if (a == b)
- return true;
- if (!a || !b)
- return false;
-
- unsigned aLength = a->length();
- unsigned bLength = b->length();
- if (aLength != bLength)
- return false;
-
- const uint32_t* aChars = reinterpret_cast<const uint32_t*>(a->characters());
- const uint32_t* bChars = reinterpret_cast<const uint32_t*>(b->characters());
-
- unsigned halfLength = aLength >> 1;
- for (unsigned i = 0; i != halfLength; ++i)
- if (*aChars++ != *bChars++)
- return false;
-
- if (aLength & 1 && *reinterpret_cast<const uint16_t*>(aChars) != *reinterpret_cast<const uint16_t*>(bChars))
- return false;
-
- return true;
- }
-
- static unsigned hash(const RefPtr<StringImpl>& key) { return key->hash(); }
- static bool equal(const RefPtr<StringImpl>& a, const RefPtr<StringImpl>& b)
- {
- return equal(a.get(), b.get());
- }
-
- static unsigned hash(const String& key) { return key.impl()->hash(); }
- static bool equal(const String& a, const String& b)
- {
- return equal(a.impl(), b.impl());
- }
-
- static const bool safeToCompareToEmptyOrDeleted = false;
- };
-
- class CaseFoldingHash {
- private:
- // Golden ratio - arbitrary start value to avoid mapping all 0's to all 0's
- static const unsigned PHI = 0x9e3779b9U;
- public:
- // Paul Hsieh's SuperFastHash
- // http://www.azillionmonkeys.com/qed/hash.html
- static unsigned hash(const UChar* data, unsigned length)
- {
- unsigned l = length;
- const UChar* s = data;
- uint32_t hash = PHI;
- uint32_t tmp;
-
- int rem = l & 1;
- l >>= 1;
-
- // Main loop.
- for (; l > 0; l--) {
- hash += WTF::Unicode::foldCase(s[0]);
- tmp = (WTF::Unicode::foldCase(s[1]) << 11) ^ hash;
- hash = (hash << 16) ^ tmp;
- s += 2;
- hash += hash >> 11;
- }
-
- // Handle end case.
- if (rem) {
- hash += WTF::Unicode::foldCase(s[0]);
- hash ^= hash << 11;
- hash += hash >> 17;
- }
-
- // Force "avalanching" of final 127 bits.
- hash ^= hash << 3;
- hash += hash >> 5;
- hash ^= hash << 2;
- hash += hash >> 15;
- hash ^= hash << 10;
-
- // This avoids ever returning a hash code of 0, since that is used to
- // signal "hash not computed yet", using a value that is likely to be
- // effectively the same as 0 when the low bits are masked.
- hash |= !hash << 31;
-
- return hash;
- }
-
- static unsigned hash(StringImpl* str)
- {
- return hash(str->characters(), str->length());
- }
-
- static unsigned hash(const char* str, unsigned length)
- {
- // This hash is designed to work on 16-bit chunks at a time. But since the normal case
- // (above) is to hash UTF-16 characters, we just treat the 8-bit chars as if they
- // were 16-bit chunks, which will give matching results.
-
- unsigned l = length;
- const char* s = str;
- uint32_t hash = PHI;
- uint32_t tmp;
-
- int rem = l & 1;
- l >>= 1;
-
- // Main loop
- for (; l > 0; l--) {
- hash += WTF::Unicode::foldCase(s[0]);
- tmp = (WTF::Unicode::foldCase(s[1]) << 11) ^ hash;
- hash = (hash << 16) ^ tmp;
- s += 2;
- hash += hash >> 11;
- }
-
- // Handle end case
- if (rem) {
- hash += WTF::Unicode::foldCase(s[0]);
- hash ^= hash << 11;
- hash += hash >> 17;
- }
-
- // Force "avalanching" of final 127 bits
- hash ^= hash << 3;
- hash += hash >> 5;
- hash ^= hash << 2;
- hash += hash >> 15;
- hash ^= hash << 10;
-
- // this avoids ever returning a hash code of 0, since that is used to
- // signal "hash not computed yet", using a value that is likely to be
- // effectively the same as 0 when the low bits are masked
- hash |= !hash << 31;
-
- return hash;
- }
-
- static bool equal(StringImpl* a, StringImpl* b)
- {
- if (a == b)
- return true;
- if (!a || !b)
- return false;
- unsigned length = a->length();
- if (length != b->length())
- return false;
- return WTF::Unicode::umemcasecmp(a->characters(), b->characters(), length) == 0;
- }
-
- static unsigned hash(const RefPtr<StringImpl>& key)
- {
- return hash(key.get());
- }
-
- static bool equal(const RefPtr<StringImpl>& a, const RefPtr<StringImpl>& b)
- {
- return equal(a.get(), b.get());
- }
-
- static unsigned hash(const String& key)
- {
- return hash(key.impl());
- }
- static bool equal(const String& a, const String& b)
- {
- return equal(a.impl(), b.impl());
- }
-
- static const bool safeToCompareToEmptyOrDeleted = false;
- };
-
- // This hash can be used in cases where the key is a hash of a string, but we don't
- // want to store the string. It's not really specific to string hashing, but all our
- // current uses of it are for strings.
- struct AlreadyHashed : IntHash<unsigned> {
- static unsigned hash(unsigned key) { return key; }
-
- // To use a hash value as a key for a hash table, we need to eliminate the
- // "deleted" value, which is negative one. That could be done by changing
- // the string hash function to never generate negative one, but this works
- // and is still relatively efficient.
- static unsigned avoidDeletedValue(unsigned hash)
- {
- ASSERT(hash);
- unsigned newHash = hash | (!(hash + 1) << 31);
- ASSERT(newHash);
- ASSERT(newHash != 0xFFFFFFFF);
- return newHash;
- }
- };
-
-}
-
-namespace WTF {
-
- template<> struct HashTraits<WebCore::String> : GenericHashTraits<WebCore::String> {
- static const bool emptyValueIsZero = true;
- static void constructDeletedValue(WebCore::String& slot) { new (&slot) WebCore::String(HashTableDeletedValue); }
- static bool isDeletedValue(const WebCore::String& slot) { return slot.isHashTableDeletedValue(); }
- };
-
-}
-
-#endif
diff --git a/WebCore/platform/text/StringImpl.cpp b/WebCore/platform/text/StringImpl.cpp
deleted file mode 100644
index 911c0dc..0000000
--- a/WebCore/platform/text/StringImpl.cpp
+++ /dev/null
@@ -1,942 +0,0 @@
-/*
- * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
- * (C) 1999 Antti Koivisto (koivisto@kde.org)
- * (C) 2001 Dirk Mueller ( mueller@kde.org )
- * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "StringImpl.h"
-
-#include "AtomicString.h"
-#include "CString.h"
-#include "CharacterNames.h"
-#include "FloatConversion.h"
-#include "StringBuffer.h"
-#include "StringHash.h"
-#include "TextBreakIterator.h"
-#include "TextEncoding.h"
-#include <kjs/dtoa.h>
-#include <wtf/Assertions.h>
-#include <wtf/unicode/Unicode.h>
-
-using namespace WTF;
-using namespace Unicode;
-
-namespace WebCore {
-
-static inline UChar* newUCharVector(unsigned n)
-{
- return static_cast<UChar*>(fastMalloc(sizeof(UChar) * n));
-}
-
-static inline void deleteUCharVector(const UChar* p)
-{
- fastFree(const_cast<UChar*>(p));
-}
-
-// This constructor is used only to create the empty string.
-StringImpl::StringImpl()
- : m_length(0)
- , m_data(0)
- , m_hash(0)
- , m_inTable(false)
- , m_hasTerminatingNullCharacter(false)
-{
- // Ensure that the hash is computed so that AtomicStringHash can call existingHash()
- // with impunity. The empty string is special because it is never entered into
- // AtomicString's HashKey, but still needs to compare correctly.
- hash();
-}
-
-// This is one of the most common constructors, but it's also used for the copy()
-// operation. Because of that, it's the one constructor that doesn't assert the
-// length is non-zero, since we support copying the empty string.
-inline StringImpl::StringImpl(const UChar* characters, unsigned length)
- : m_length(length)
- , m_hash(0)
- , m_inTable(false)
- , m_hasTerminatingNullCharacter(false)
-{
- UChar* data = newUCharVector(length);
- memcpy(data, characters, length * sizeof(UChar));
- m_data = data;
-}
-
-inline StringImpl::StringImpl(const StringImpl& str, WithTerminatingNullCharacter)
- : m_length(str.m_length)
- , m_hash(str.m_hash)
- , m_inTable(false)
- , m_hasTerminatingNullCharacter(true)
-{
- UChar* data = newUCharVector(str.m_length + 1);
- memcpy(data, str.m_data, str.m_length * sizeof(UChar));
- data[str.m_length] = 0;
- m_data = data;
-}
-
-inline StringImpl::StringImpl(const char* characters, unsigned length)
- : m_length(length)
- , m_hash(0)
- , m_inTable(false)
- , m_hasTerminatingNullCharacter(false)
-{
- ASSERT(characters);
- ASSERT(length);
-
- UChar* data = newUCharVector(length);
- for (unsigned i = 0; i != length; ++i) {
- unsigned char c = characters[i];
- data[i] = c;
- }
- m_data = data;
-}
-
-inline StringImpl::StringImpl(UChar* characters, unsigned length, AdoptBuffer)
- : m_length(length)
- , m_data(characters)
- , m_hash(0)
- , m_inTable(false)
- , m_hasTerminatingNullCharacter(false)
-{
- ASSERT(characters);
- ASSERT(length);
-}
-
-// This constructor is only for use by AtomicString.
-StringImpl::StringImpl(const UChar* characters, unsigned length, unsigned hash)
- : m_length(length)
- , m_hash(hash)
- , m_inTable(true)
- , m_hasTerminatingNullCharacter(false)
-{
- ASSERT(hash);
- ASSERT(characters);
- ASSERT(length);
-
- UChar* data = newUCharVector(length);
- memcpy(data, characters, length * sizeof(UChar));
- m_data = data;
-}
-
-// This constructor is only for use by AtomicString.
-StringImpl::StringImpl(const char* characters, unsigned length, unsigned hash)
- : m_length(length)
- , m_hash(hash)
- , m_inTable(true)
- , m_hasTerminatingNullCharacter(false)
-{
- ASSERT(hash);
- ASSERT(characters);
- ASSERT(length);
-
- UChar* data = newUCharVector(length);
- for (unsigned i = 0; i != length; ++i) {
- unsigned char c = characters[i];
- data[i] = c;
- }
- m_data = data;
-}
-
-StringImpl::~StringImpl()
-{
- if (m_inTable)
- AtomicString::remove(this);
- deleteUCharVector(m_data);
-}
-
-StringImpl* StringImpl::empty()
-{
- static StringImpl* e = new StringImpl;
- return e;
-}
-
-bool StringImpl::containsOnlyWhitespace()
-{
- // FIXME: The definition of whitespace here includes a number of characters
- // that are not whitespace from the point of view of RenderText; I wonder if
- // that's a problem in practice.
- for (unsigned i = 0; i < m_length; i++)
- if (!isASCIISpace(m_data[i]))
- return false;
- return true;
-}
-
-PassRefPtr<StringImpl> StringImpl::substring(unsigned pos, unsigned len)
-{
- if (pos >= m_length)
- return empty();
- if (len > m_length - pos)
- len = m_length - pos;
- return create(m_data + pos, len);
-}
-
-UChar32 StringImpl::characterStartingAt(unsigned i)
-{
- if (U16_IS_SINGLE(m_data[i]))
- return m_data[i];
- if (i + 1 < m_length && U16_IS_LEAD(m_data[i]) && U16_IS_TRAIL(m_data[i + 1]))
- return U16_GET_SUPPLEMENTARY(m_data[i], m_data[i + 1]);
- return 0;
-}
-
-bool StringImpl::isLower()
-{
- // Do a faster loop for the case where all the characters are ASCII.
- bool allLower = true;
- UChar ored = 0;
- for (unsigned i = 0; i < m_length; i++) {
- UChar c = m_data[i];
- allLower = allLower && isASCIILower(c);
- ored |= c;
- }
- if (!(ored & ~0x7F))
- return allLower;
-
- // Do a slower check for cases that include non-ASCII characters.
- allLower = true;
- unsigned i = 0;
- while (i < m_length) {
- UChar32 character;
- U16_NEXT(m_data, i, m_length, character)
- allLower = allLower && Unicode::isLower(character);
- }
- return allLower;
-}
-
-PassRefPtr<StringImpl> StringImpl::lower()
-{
- StringBuffer data(m_length);
- int32_t length = m_length;
-
- // Do a faster loop for the case where all the characters are ASCII.
- UChar ored = 0;
- for (int i = 0; i < length; i++) {
- UChar c = m_data[i];
- ored |= c;
- data[i] = toASCIILower(c);
- }
- if (!(ored & ~0x7F))
- return adopt(data);
-
- // Do a slower implementation for cases that include non-ASCII characters.
- bool error;
- int32_t realLength = Unicode::toLower(data.characters(), length, m_data, m_length, &error);
- if (!error && realLength == length)
- return adopt(data);
- data.resize(realLength);
- Unicode::toLower(data.characters(), realLength, m_data, m_length, &error);
- if (error)
- return this;
- return adopt(data);
-}
-
-PassRefPtr<StringImpl> StringImpl::upper()
-{
- StringBuffer data(m_length);
- int32_t length = m_length;
-
- // Do a faster loop for the case where all the characters are ASCII.
- UChar ored = 0;
- for (int i = 0; i < length; i++) {
- UChar c = m_data[i];
- ored |= c;
- data[i] = toASCIIUpper(c);
- }
- if (!(ored & ~0x7F))
- return adopt(data);
-
- // Do a slower implementation for cases that include non-ASCII characters.
- bool error;
- int32_t realLength = Unicode::toUpper(data.characters(), length, m_data, m_length, &error);
- if (!error && realLength == length)
- return adopt(data);
- data.resize(realLength);
- Unicode::toUpper(data.characters(), realLength, m_data, m_length, &error);
- if (error)
- return this;
- return adopt(data);
-}
-
-PassRefPtr<StringImpl> StringImpl::secure(UChar aChar)
-{
- int length = m_length;
- StringBuffer data(length);
- for (int i = 0; i < length; ++i)
- data[i] = aChar;
- return adopt(data);
-}
-
-PassRefPtr<StringImpl> StringImpl::foldCase()
-{
- StringBuffer data(m_length);
- int32_t length = m_length;
-
- // Do a faster loop for the case where all the characters are ASCII.
- UChar ored = 0;
- for (int i = 0; i < length; i++) {
- UChar c = m_data[i];
- ored |= c;
- data[i] = toASCIILower(c);
- }
- if (!(ored & ~0x7F))
- return adopt(data);
-
- // Do a slower implementation for cases that include non-ASCII characters.
- bool error;
- int32_t realLength = Unicode::foldCase(data.characters(), length, m_data, m_length, &error);
- if (!error && realLength == length)
- return adopt(data);
- data.resize(realLength);
- Unicode::foldCase(data.characters(), realLength, m_data, m_length, &error);
- if (error)
- return this;
- return adopt(data);
-}
-
-PassRefPtr<StringImpl> StringImpl::stripWhiteSpace()
-{
- if (!m_length)
- return empty();
-
- unsigned start = 0;
- unsigned end = m_length - 1;
-
- // skip white space from start
- while (start <= end && isSpaceOrNewline(m_data[start]))
- start++;
-
- // only white space
- if (start > end)
- return empty();
-
- // skip white space from end
- while (end && isSpaceOrNewline(m_data[end]))
- end--;
-
- return create(m_data + start, end + 1 - start);
-}
-
-PassRefPtr<StringImpl> StringImpl::simplifyWhiteSpace()
-{
- StringBuffer data(m_length);
-
- const UChar* from = m_data;
- const UChar* fromend = from + m_length;
- int outc = 0;
-
- UChar* to = data.characters();
-
- while (true) {
- while (from != fromend && isSpaceOrNewline(*from))
- from++;
- while (from != fromend && !isSpaceOrNewline(*from))
- to[outc++] = *from++;
- if (from != fromend)
- to[outc++] = ' ';
- else
- break;
- }
-
- if (outc > 0 && to[outc - 1] == ' ')
- outc--;
-
- data.shrink(outc);
-
- return adopt(data);
-}
-
-PassRefPtr<StringImpl> StringImpl::capitalize(UChar previous)
-{
- StringBuffer stringWithPrevious(m_length + 1);
- stringWithPrevious[0] = previous == noBreakSpace ? ' ' : previous;
- for (unsigned i = 1; i < m_length + 1; i++) {
- // Replace &nbsp with a real space since ICU no longer treats &nbsp as a word separator.
- if (m_data[i - 1] == noBreakSpace)
- stringWithPrevious[i] = ' ';
- else
- stringWithPrevious[i] = m_data[i - 1];
- }
-
- TextBreakIterator* boundary = wordBreakIterator(stringWithPrevious.characters(), m_length + 1);
- if (!boundary)
- return this;
-
- StringBuffer data(m_length);
-
- int32_t endOfWord;
- int32_t startOfWord = textBreakFirst(boundary);
- for (endOfWord = textBreakNext(boundary); endOfWord != TextBreakDone; startOfWord = endOfWord, endOfWord = textBreakNext(boundary)) {
- if (startOfWord != 0) // Ignore first char of previous string
- data[startOfWord - 1] = m_data[startOfWord - 1] == noBreakSpace ? noBreakSpace : toTitleCase(stringWithPrevious[startOfWord]);
- for (int i = startOfWord + 1; i < endOfWord; i++)
- data[i - 1] = m_data[i - 1];
- }
-
- return adopt(data);
-}
-
-int StringImpl::toIntStrict(bool* ok, int base)
-{
- return charactersToIntStrict(m_data, m_length, ok, base);
-}
-
-unsigned StringImpl::toUIntStrict(bool* ok, int base)
-{
- return charactersToUIntStrict(m_data, m_length, ok, base);
-}
-
-int64_t StringImpl::toInt64Strict(bool* ok, int base)
-{
- return charactersToInt64Strict(m_data, m_length, ok, base);
-}
-
-uint64_t StringImpl::toUInt64Strict(bool* ok, int base)
-{
- return charactersToUInt64Strict(m_data, m_length, ok, base);
-}
-
-int StringImpl::toInt(bool* ok)
-{
- return charactersToInt(m_data, m_length, ok);
-}
-
-unsigned StringImpl::toUInt(bool* ok)
-{
- return charactersToUInt(m_data, m_length, ok);
-}
-
-int64_t StringImpl::toInt64(bool* ok)
-{
- return charactersToInt64(m_data, m_length, ok);
-}
-
-uint64_t StringImpl::toUInt64(bool* ok)
-{
- return charactersToUInt64(m_data, m_length, ok);
-}
-
-double StringImpl::toDouble(bool* ok)
-{
- return charactersToDouble(m_data, m_length, ok);
-}
-
-float StringImpl::toFloat(bool* ok)
-{
- return charactersToFloat(m_data, m_length, ok);
-}
-
-static bool equal(const UChar* a, const char* b, int length)
-{
- ASSERT(length >= 0);
- while (length--) {
- unsigned char bc = *b++;
- if (*a++ != bc)
- return false;
- }
- return true;
-}
-
-static bool equalIgnoringCase(const UChar* a, const char* b, int length)
-{
- ASSERT(length >= 0);
- while (length--) {
- unsigned char bc = *b++;
- if (foldCase(*a++) != foldCase(bc))
- return false;
- }
- return true;
-}
-
-static inline bool equalIgnoringCase(const UChar* a, const UChar* b, int length)
-{
- ASSERT(length >= 0);
- return umemcasecmp(a, b, length) == 0;
-}
-
-int StringImpl::find(const char* chs, int index, bool caseSensitive)
-{
- if (!chs || index < 0)
- return -1;
-
- int chsLength = strlen(chs);
- int n = m_length - index;
- if (n < 0)
- return -1;
- n -= chsLength - 1;
- if (n <= 0)
- return -1;
-
- const char* chsPlusOne = chs + 1;
- int chsLengthMinusOne = chsLength - 1;
-
- const UChar* ptr = m_data + index - 1;
- if (caseSensitive) {
- UChar c = *chs;
- do {
- if (*++ptr == c && equal(ptr + 1, chsPlusOne, chsLengthMinusOne))
- return m_length - chsLength - n + 1;
- } while (--n);
- } else {
- UChar lc = Unicode::foldCase(*chs);
- do {
- if (Unicode::foldCase(*++ptr) == lc && equalIgnoringCase(ptr + 1, chsPlusOne, chsLengthMinusOne))
- return m_length - chsLength - n + 1;
- } while (--n);
- }
-
- return -1;
-}
-
-int StringImpl::find(UChar c, int start)
-{
- return WebCore::find(m_data, m_length, c, start);
-}
-
-int StringImpl::find(StringImpl* str, int index, bool caseSensitive)
-{
- /*
- We use a simple trick for efficiency's sake. Instead of
- comparing strings, we compare the sum of str with that of
- a part of this string. Only if that matches, we call memcmp
- or ucstrnicmp.
- */
- ASSERT(str);
- if (index < 0)
- index += m_length;
- int lstr = str->m_length;
- int lthis = m_length - index;
- if ((unsigned)lthis > m_length)
- return -1;
- int delta = lthis - lstr;
- if (delta < 0)
- return -1;
-
- const UChar* uthis = m_data + index;
- const UChar* ustr = str->m_data;
- unsigned hthis = 0;
- unsigned hstr = 0;
- if (caseSensitive) {
- for (int i = 0; i < lstr; i++) {
- hthis += uthis[i];
- hstr += ustr[i];
- }
- int i = 0;
- while (1) {
- if (hthis == hstr && memcmp(uthis + i, ustr, lstr * sizeof(UChar)) == 0)
- return index + i;
- if (i == delta)
- return -1;
- hthis += uthis[i + lstr];
- hthis -= uthis[i];
- i++;
- }
- } else {
- for (int i = 0; i < lstr; i++ ) {
- hthis += toASCIILower(uthis[i]);
- hstr += toASCIILower(ustr[i]);
- }
- int i = 0;
- while (1) {
- if (hthis == hstr && equalIgnoringCase(uthis + i, ustr, lstr))
- return index + i;
- if (i == delta)
- return -1;
- hthis += toASCIILower(uthis[i + lstr]);
- hthis -= toASCIILower(uthis[i]);
- i++;
- }
- }
-}
-
-int StringImpl::reverseFind(UChar c, int index)
-{
- return WebCore::reverseFind(m_data, m_length, c, index);
-}
-
-int StringImpl::reverseFind(StringImpl* str, int index, bool caseSensitive)
-{
- /*
- See StringImpl::find() for explanations.
- */
- ASSERT(str);
- int lthis = m_length;
- if (index < 0)
- index += lthis;
-
- int lstr = str->m_length;
- int delta = lthis - lstr;
- if ( index < 0 || index > lthis || delta < 0 )
- return -1;
- if ( index > delta )
- index = delta;
-
- const UChar *uthis = m_data;
- const UChar *ustr = str->m_data;
- unsigned hthis = 0;
- unsigned hstr = 0;
- int i;
- if (caseSensitive) {
- for ( i = 0; i < lstr; i++ ) {
- hthis += uthis[index + i];
- hstr += ustr[i];
- }
- i = index;
- while (1) {
- if (hthis == hstr && memcmp(uthis + i, ustr, lstr * sizeof(UChar)) == 0)
- return i;
- if (i == 0)
- return -1;
- i--;
- hthis -= uthis[i + lstr];
- hthis += uthis[i];
- }
- } else {
- for (i = 0; i < lstr; i++) {
- hthis += toASCIILower(uthis[index + i]);
- hstr += toASCIILower(ustr[i]);
- }
- i = index;
- while (1) {
- if (hthis == hstr && equalIgnoringCase(uthis + i, ustr, lstr) )
- return i;
- if (i == 0)
- return -1;
- i--;
- hthis -= toASCIILower(uthis[i + lstr]);
- hthis += toASCIILower(uthis[i]);
- }
- }
-
- // Should never get here.
- return -1;
-}
-
-bool StringImpl::endsWith(StringImpl* m_data, bool caseSensitive)
-{
- ASSERT(m_data);
- int start = m_length - m_data->m_length;
- if (start >= 0)
- return (find(m_data, start, caseSensitive) == start);
- return false;
-}
-
-PassRefPtr<StringImpl> StringImpl::replace(UChar oldC, UChar newC)
-{
- if (oldC == newC)
- return this;
- unsigned i;
- for (i = 0; i != m_length; ++i)
- if (m_data[i] == oldC)
- break;
- if (i == m_length)
- return this;
-
- StringBuffer data(m_length);
- for (i = 0; i != m_length; ++i) {
- UChar ch = m_data[i];
- if (ch == oldC)
- ch = newC;
- data[i] = ch;
- }
- return adopt(data);
-}
-
-PassRefPtr<StringImpl> StringImpl::replace(unsigned position, unsigned lengthToReplace, StringImpl* str)
-{
- position = min(position, length());
- lengthToReplace = min(lengthToReplace, length() - position);
- unsigned lengthToInsert = str ? str->length() : 0;
- if (!lengthToReplace && !lengthToInsert)
- return this;
- StringBuffer buffer(length() - lengthToReplace + lengthToInsert);
- memcpy(buffer.characters(), characters(), position * sizeof(UChar));
- if (str)
- memcpy(buffer.characters() + position, str->characters(), lengthToInsert * sizeof(UChar));
- memcpy(buffer.characters() + position + lengthToInsert, characters() + position + lengthToReplace,
- (length() - position - lengthToReplace) * sizeof(UChar));
- return adopt(buffer);
-}
-
-PassRefPtr<StringImpl> StringImpl::replace(UChar pattern, StringImpl* replacement)
-{
- if (!replacement)
- return this;
-
- int repStrLength = replacement->length();
- int srcSegmentStart = 0;
- int matchCount = 0;
-
- // Count the matches
- while ((srcSegmentStart = find(pattern, srcSegmentStart)) >= 0) {
- ++matchCount;
- ++srcSegmentStart;
- }
-
- // If we have 0 matches, we don't have to do any more work
- if (!matchCount)
- return this;
-
- StringBuffer data(m_length - matchCount + (matchCount * repStrLength));
-
- // Construct the new data
- int srcSegmentEnd;
- int srcSegmentLength;
- srcSegmentStart = 0;
- int dstOffset = 0;
-
- while ((srcSegmentEnd = find(pattern, srcSegmentStart)) >= 0) {
- srcSegmentLength = srcSegmentEnd - srcSegmentStart;
- memcpy(data.characters() + dstOffset, m_data + srcSegmentStart, srcSegmentLength * sizeof(UChar));
- dstOffset += srcSegmentLength;
- memcpy(data.characters() + dstOffset, replacement->m_data, repStrLength * sizeof(UChar));
- dstOffset += repStrLength;
- srcSegmentStart = srcSegmentEnd + 1;
- }
-
- srcSegmentLength = m_length - srcSegmentStart;
- memcpy(data.characters() + dstOffset, m_data + srcSegmentStart, srcSegmentLength * sizeof(UChar));
-
- ASSERT(dstOffset + srcSegmentLength == static_cast<int>(data.length()));
-
- return adopt(data);
-}
-
-PassRefPtr<StringImpl> StringImpl::replace(StringImpl* pattern, StringImpl* replacement)
-{
- if (!pattern || !replacement)
- return this;
-
- int patternLength = pattern->length();
- if (!patternLength)
- return this;
-
- int repStrLength = replacement->length();
- int srcSegmentStart = 0;
- int matchCount = 0;
-
- // Count the matches
- while ((srcSegmentStart = find(pattern, srcSegmentStart)) >= 0) {
- ++matchCount;
- srcSegmentStart += patternLength;
- }
-
- // If we have 0 matches, we don't have to do any more work
- if (!matchCount)
- return this;
-
- StringBuffer data(m_length + matchCount * (repStrLength - patternLength));
-
- // Construct the new data
- int srcSegmentEnd;
- int srcSegmentLength;
- srcSegmentStart = 0;
- int dstOffset = 0;
-
- while ((srcSegmentEnd = find(pattern, srcSegmentStart)) >= 0) {
- srcSegmentLength = srcSegmentEnd - srcSegmentStart;
- memcpy(data.characters() + dstOffset, m_data + srcSegmentStart, srcSegmentLength * sizeof(UChar));
- dstOffset += srcSegmentLength;
- memcpy(data.characters() + dstOffset, replacement->m_data, repStrLength * sizeof(UChar));
- dstOffset += repStrLength;
- srcSegmentStart = srcSegmentEnd + patternLength;
- }
-
- srcSegmentLength = m_length - srcSegmentStart;
- memcpy(data.characters() + dstOffset, m_data + srcSegmentStart, srcSegmentLength * sizeof(UChar));
-
- ASSERT(dstOffset + srcSegmentLength == static_cast<int>(data.length()));
-
- return adopt(data);
-}
-
-bool equal(StringImpl* a, StringImpl* b)
-{
- return StringHash::equal(a, b);
-}
-
-bool equal(StringImpl* a, const char* b)
-{
- if (!a)
- return !b;
- if (!b)
- return !a;
-
- unsigned length = a->length();
- const UChar* as = a->characters();
- for (unsigned i = 0; i != length; ++i) {
- unsigned char bc = b[i];
- if (!bc)
- return false;
- if (as[i] != bc)
- return false;
- }
-
- return !b[length];
-}
-
-bool equalIgnoringCase(StringImpl* a, StringImpl* b)
-{
- return CaseFoldingHash::equal(a, b);
-}
-
-bool equalIgnoringCase(StringImpl* a, const char* b)
-{
- if (!a)
- return !b;
- if (!b)
- return !a;
-
- unsigned length = a->length();
- const UChar* as = a->characters();
-
- // Do a faster loop for the case where all the characters are ASCII.
- UChar ored = 0;
- bool equal = true;
- for (unsigned i = 0; i != length; ++i) {
- char bc = b[i];
- if (!bc)
- return false;
- UChar ac = as[i];
- ored |= ac;
- equal = equal && (toASCIILower(ac) == toASCIILower(bc));
- }
-
- // Do a slower implementation for cases that include non-ASCII characters.
- if (ored & ~0x7F) {
- equal = true;
- for (unsigned i = 0; i != length; ++i) {
- unsigned char bc = b[i];
- equal = equal && (foldCase(as[i]) == foldCase(bc));
- }
- }
-
- return equal && !b[length];
-}
-
-Vector<char> StringImpl::ascii()
-{
- Vector<char> buffer(m_length + 1);
- for (unsigned i = 0; i != m_length; ++i) {
- UChar c = m_data[i];
- if ((c >= 0x20 && c < 0x7F) || c == 0x00)
- buffer[i] = c;
- else
- buffer[i] = '?';
- }
- buffer[m_length] = '\0';
- return buffer;
-}
-
-WTF::Unicode::Direction StringImpl::defaultWritingDirection()
-{
- for (unsigned i = 0; i < m_length; ++i) {
- WTF::Unicode::Direction charDirection = WTF::Unicode::direction(m_data[i]);
- if (charDirection == WTF::Unicode::LeftToRight)
- return WTF::Unicode::LeftToRight;
- if (charDirection == WTF::Unicode::RightToLeft || charDirection == WTF::Unicode::RightToLeftArabic)
- return WTF::Unicode::RightToLeft;
- }
- return WTF::Unicode::LeftToRight;
-}
-
-// This is a hot function because it's used when parsing HTML.
-PassRefPtr<StringImpl> StringImpl::createStrippingNullCharacters(const UChar* characters, unsigned length)
-{
- ASSERT(characters);
- ASSERT(length);
-
- // Optimize for the case where there are no Null characters by quickly
- // searching for nulls, and then using StringImpl::create, which will
- // memcpy the whole buffer. This is faster than assigning character by
- // character during the loop.
-
- // Fast case.
- int foundNull = 0;
- for (unsigned i = 0; !foundNull && i < length; i++) {
- int c = characters[i]; // more efficient than using UChar here (at least on Intel Mac OS)
- foundNull |= !c;
- }
- if (!foundNull)
- return StringImpl::create(characters, length);
-
- // Slow case.
- StringBuffer strippedCopy(length);
- unsigned strippedLength = 0;
- for (unsigned i = 0; i < length; i++) {
- if (int c = characters[i])
- strippedCopy[strippedLength++] = c;
- }
- ASSERT(strippedLength < length); // Only take the slow case when stripping.
- strippedCopy.shrink(strippedLength);
- return adopt(strippedCopy);
-}
-
-PassRefPtr<StringImpl> StringImpl::adopt(StringBuffer& buffer)
-{
- unsigned length = buffer.length();
- if (length == 0)
- return empty();
- return adoptRef(new StringImpl(buffer.release(), length, AdoptBuffer()));
-}
-
-PassRefPtr<StringImpl> StringImpl::adopt(Vector<UChar>& vector)
-{
- size_t size = vector.size();
- if (size == 0)
- return empty();
- return adoptRef(new StringImpl(vector.releaseBuffer(), size, AdoptBuffer()));
-}
-
-PassRefPtr<StringImpl> StringImpl::create(const UChar* characters, unsigned length)
-{
- if (!characters || !length)
- return empty();
- return adoptRef(new StringImpl(characters, length));
-}
-
-PassRefPtr<StringImpl> StringImpl::create(const char* characters, unsigned length)
-{
- if (!characters || !length)
- return empty();
- return adoptRef(new StringImpl(characters, length));
-}
-
-PassRefPtr<StringImpl> StringImpl::create(const char* string)
-{
- if (!string)
- return empty();
- unsigned length = strlen(string);
- if (!length)
- return empty();
- return adoptRef(new StringImpl(string, length));
-}
-
-PassRefPtr<StringImpl> StringImpl::createWithTerminatingNullCharacter(const StringImpl& string)
-{
- return adoptRef(new StringImpl(string, WithTerminatingNullCharacter()));
-}
-
-PassRefPtr<StringImpl> StringImpl::copy()
-{
- return adoptRef(new StringImpl(m_data, m_length));
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/text/StringImpl.h b/WebCore/platform/text/StringImpl.h
deleted file mode 100644
index 57f64c8..0000000
--- a/WebCore/platform/text/StringImpl.h
+++ /dev/null
@@ -1,278 +0,0 @@
-/*
- * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
- * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef StringImpl_h
-#define StringImpl_h
-
-#include <limits.h>
-#include <wtf/ASCIICType.h>
-#include <wtf/Forward.h>
-#include <wtf/RefCounted.h>
-#include <wtf/Vector.h>
-#include <wtf/unicode/Unicode.h>
-
-#if PLATFORM(CF) || (PLATFORM(QT) && PLATFORM(DARWIN))
-typedef const struct __CFString * CFStringRef;
-#endif
-
-#ifdef __OBJC__
-@class NSString;
-#endif
-
-namespace WebCore {
-
-class AtomicString;
-class StringBuffer;
-
-struct CStringTranslator;
-struct HashAndCharactersTranslator;
-struct StringHash;
-struct UCharBufferTranslator;
-
-class StringImpl : public RefCounted<StringImpl> {
- friend class AtomicString;
- friend struct CStringTranslator;
- friend struct HashAndCharactersTranslator;
- friend struct UCharBufferTranslator;
-private:
- StringImpl();
- StringImpl(const UChar*, unsigned length);
- StringImpl(const char*, unsigned length);
-
- struct AdoptBuffer { };
- StringImpl(UChar*, unsigned length, AdoptBuffer);
-
- struct WithTerminatingNullCharacter { };
- StringImpl(const StringImpl&, WithTerminatingNullCharacter);
-
- // For AtomicString.
- StringImpl(const UChar*, unsigned length, unsigned hash);
- StringImpl(const char*, unsigned length, unsigned hash);
-
-public:
- ~StringImpl();
-
- static PassRefPtr<StringImpl> create(const UChar*, unsigned length);
- static PassRefPtr<StringImpl> create(const char*, unsigned length);
- static PassRefPtr<StringImpl> create(const char*);
-
- static PassRefPtr<StringImpl> createWithTerminatingNullCharacter(const StringImpl&);
-
- static PassRefPtr<StringImpl> createStrippingNullCharacters(const UChar*, unsigned length);
- static PassRefPtr<StringImpl> adopt(StringBuffer&);
- static PassRefPtr<StringImpl> adopt(Vector<UChar>&);
-
- const UChar* characters() { return m_data; }
- unsigned length() { return m_length; }
-
- bool hasTerminatingNullCharacter() { return m_hasTerminatingNullCharacter; }
-
- unsigned hash() { if (m_hash == 0) m_hash = computeHash(m_data, m_length); return m_hash; }
- unsigned existingHash() const { ASSERT(m_hash); return m_hash; }
- static unsigned computeHash(const UChar*, unsigned len);
- static unsigned computeHash(const char*);
-
- // Makes a deep copy. Helpful only if you need to use a String on another thread.
- // Since StringImpl objects are immutable, there's no other reason to make a copy.
- PassRefPtr<StringImpl> copy();
-
- PassRefPtr<StringImpl> substring(unsigned pos, unsigned len = UINT_MAX);
-
- UChar operator[](unsigned i) { ASSERT(i < m_length); return m_data[i]; }
- UChar32 characterStartingAt(unsigned);
-
- bool containsOnlyWhitespace();
-
- int toIntStrict(bool* ok = 0, int base = 10);
- unsigned toUIntStrict(bool* ok = 0, int base = 10);
- int64_t toInt64Strict(bool* ok = 0, int base = 10);
- uint64_t toUInt64Strict(bool* ok = 0, int base = 10);
-
- int toInt(bool* ok = 0); // ignores trailing garbage
- unsigned toUInt(bool* ok = 0); // ignores trailing garbage
- int64_t toInt64(bool* ok = 0); // ignores trailing garbage
- uint64_t toUInt64(bool* ok = 0); // ignores trailing garbage
-
- double toDouble(bool* ok = 0);
- float toFloat(bool* ok = 0);
-
- bool isLower();
- PassRefPtr<StringImpl> lower();
- PassRefPtr<StringImpl> upper();
- PassRefPtr<StringImpl> secure(UChar aChar);
- PassRefPtr<StringImpl> capitalize(UChar previousCharacter);
- PassRefPtr<StringImpl> foldCase();
-
- PassRefPtr<StringImpl> stripWhiteSpace();
- PassRefPtr<StringImpl> simplifyWhiteSpace();
-
- int find(const char*, int index = 0, bool caseSensitive = true);
- int find(UChar, int index = 0);
- int find(StringImpl*, int index, bool caseSensitive = true);
-
- int reverseFind(UChar, int index);
- int reverseFind(StringImpl*, int index, bool caseSensitive = true);
-
- bool startsWith(StringImpl* m_data, bool caseSensitive = true) { return find(m_data, 0, caseSensitive) == 0; }
- bool endsWith(StringImpl*, bool caseSensitive = true);
-
- PassRefPtr<StringImpl> replace(UChar, UChar);
- PassRefPtr<StringImpl> replace(UChar, StringImpl*);
- PassRefPtr<StringImpl> replace(StringImpl*, StringImpl*);
- PassRefPtr<StringImpl> replace(unsigned index, unsigned len, StringImpl*);
-
- static StringImpl* empty();
-
- Vector<char> ascii();
-
- WTF::Unicode::Direction defaultWritingDirection();
-
-#if PLATFORM(CF) || (PLATFORM(QT) && PLATFORM(DARWIN))
- CFStringRef createCFString();
-#endif
-#ifdef __OBJC__
- operator NSString*();
-#endif
-
-private:
- unsigned m_length;
- const UChar* m_data;
- mutable unsigned m_hash;
- bool m_inTable;
- bool m_hasTerminatingNullCharacter;
-};
-
-bool equal(StringImpl*, StringImpl*);
-bool equal(StringImpl*, const char*);
-inline bool equal(const char* a, StringImpl* b) { return equal(b, a); }
-
-bool equalIgnoringCase(StringImpl*, StringImpl*);
-bool equalIgnoringCase(StringImpl*, const char*);
-inline bool equalIgnoringCase(const char* a, StringImpl* b) { return equalIgnoringCase(b, a); }
-
-// Golden ratio - arbitrary start value to avoid mapping all 0's to all 0's
-// or anything like that.
-const unsigned phi = 0x9e3779b9U;
-
-// Paul Hsieh's SuperFastHash
-// http://www.azillionmonkeys.com/qed/hash.html
-inline unsigned StringImpl::computeHash(const UChar* data, unsigned length)
-{
- unsigned hash = phi;
-
- // Main loop.
- for (unsigned pairCount = length >> 1; pairCount; pairCount--) {
- hash += data[0];
- unsigned tmp = (data[1] << 11) ^ hash;
- hash = (hash << 16) ^ tmp;
- data += 2;
- hash += hash >> 11;
- }
-
- // Handle end case.
- if (length & 1) {
- hash += data[0];
- hash ^= hash << 11;
- hash += hash >> 17;
- }
-
- // Force "avalanching" of final 127 bits.
- hash ^= hash << 3;
- hash += hash >> 5;
- hash ^= hash << 2;
- hash += hash >> 15;
- hash ^= hash << 10;
-
- // This avoids ever returning a hash code of 0, since that is used to
- // signal "hash not computed yet", using a value that is likely to be
- // effectively the same as 0 when the low bits are masked.
- hash |= !hash << 31;
-
- return hash;
-}
-
-// Paul Hsieh's SuperFastHash
-// http://www.azillionmonkeys.com/qed/hash.html
-inline unsigned StringImpl::computeHash(const char* data)
-{
- // This hash is designed to work on 16-bit chunks at a time. But since the normal case
- // (above) is to hash UTF-16 characters, we just treat the 8-bit chars as if they
- // were 16-bit chunks, which should give matching results
-
- unsigned hash = phi;
-
- // Main loop
- for (;;) {
- unsigned char b0 = data[0];
- if (!b0)
- break;
- unsigned char b1 = data[1];
- if (!b1) {
- hash += b0;
- hash ^= hash << 11;
- hash += hash >> 17;
- break;
- }
- hash += b0;
- unsigned tmp = (b1 << 11) ^ hash;
- hash = (hash << 16) ^ tmp;
- data += 2;
- hash += hash >> 11;
- }
-
- // Force "avalanching" of final 127 bits.
- hash ^= hash << 3;
- hash += hash >> 5;
- hash ^= hash << 2;
- hash += hash >> 15;
- hash ^= hash << 10;
-
- // This avoids ever returning a hash code of 0, since that is used to
- // signal "hash not computed yet", using a value that is likely to be
- // effectively the same as 0 when the low bits are masked.
- hash |= !hash << 31;
-
- return hash;
-}
-
-static inline bool isSpaceOrNewline(UChar c)
-{
- // Use isASCIISpace() for basic Latin-1.
- // This will include newlines, which aren't included in Unicode DirWS.
- return c <= 0x7F ? WTF::isASCIISpace(c) : WTF::Unicode::direction(c) == WTF::Unicode::WhiteSpaceNeutral;
-}
-
-}
-
-namespace WTF {
-
- // WebCore::StringHash is the default hash for StringImpl* and RefPtr<StringImpl>
- template<typename T> struct DefaultHash;
- template<> struct DefaultHash<WebCore::StringImpl*> {
- typedef WebCore::StringHash Hash;
- };
- template<> struct DefaultHash<RefPtr<WebCore::StringImpl> > {
- typedef WebCore::StringHash Hash;
- };
-
-}
-
-#endif
diff --git a/WebCore/platform/text/TextBoundaries.h b/WebCore/platform/text/TextBoundaries.h
deleted file mode 100644
index 118dd1a..0000000
--- a/WebCore/platform/text/TextBoundaries.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef TextBoundaries_h
-#define TextBoundaries_h
-
-#include <wtf/unicode/Unicode.h>
-
-namespace WebCore {
-
- void findWordBoundary(const UChar*, int len, int position, int* start, int* end);
- int findNextWordFromIndex(const UChar*, int len, int position, bool forward);
-
-}
-
-#endif
diff --git a/WebCore/platform/text/TextBoundariesICU.cpp b/WebCore/platform/text/TextBoundariesICU.cpp
deleted file mode 100644
index d226048..0000000
--- a/WebCore/platform/text/TextBoundariesICU.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "TextBoundaries.h"
-
-#include <unicode/ubrk.h>
-
-#include "StringImpl.h"
-#include "TextBreakIterator.h"
-
-namespace WebCore {
-
-int findNextWordFromIndex(const UChar* chars, int len, int position, bool forward)
-{
- UBreakIterator* it = wordBreakIterator(chars, len);
-
- if (forward) {
- position = ubrk_following(it, position);
- while (position != UBRK_DONE) {
- // We stop searching when the character preceeding the break
- // is alphanumeric.
- if (position < len && u_isalnum(chars[position - 1]))
- return position;
-
- position = ubrk_following(it, position);
- }
-
- return len;
- } else {
- position = ubrk_preceding(it, position);
- while (position != UBRK_DONE) {
- // We stop searching when the character following the break
- // is alphanumeric.
- if (position > 0 && u_isalnum(chars[position]))
- return position;
-
- position = ubrk_preceding(it, position);
- }
-
- return 0;
- }
-}
-
-void findWordBoundary(const UChar* chars, int len, int position, int* start, int* end)
-{
- UBreakIterator* it = wordBreakIterator(chars, len);
- *end = ubrk_following(it, position);
- if (*end < 0)
- *end = ubrk_last(it);
- *start = ubrk_previous(it);
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/text/TextBreakIterator.h b/WebCore/platform/text/TextBreakIterator.h
deleted file mode 100644
index 64717a4..0000000
--- a/WebCore/platform/text/TextBreakIterator.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2006 Lars Knoll <lars@trolltech.com>
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef TextBreakIterator_h
-#define TextBreakIterator_h
-
-#include <wtf/unicode/Unicode.h>
-
-namespace WebCore {
-
- class TextBreakIterator;
-
- // Note: The returned iterator is good only until you get another iterator.
- TextBreakIterator* characterBreakIterator(const UChar*, int length);
- TextBreakIterator* wordBreakIterator(const UChar*, int length);
- TextBreakIterator* lineBreakIterator(const UChar*, int length);
- TextBreakIterator* sentenceBreakIterator(const UChar*, int length);
-
- int textBreakFirst(TextBreakIterator*);
- int textBreakNext(TextBreakIterator*);
- int textBreakCurrent(TextBreakIterator*);
- int textBreakPreceding(TextBreakIterator*, int);
- int textBreakFollowing(TextBreakIterator*, int);
- bool isTextBreak(TextBreakIterator*, int);
-
- const int TextBreakDone = -1;
-
-}
-
-#endif
diff --git a/WebCore/platform/text/TextBreakIteratorICU.cpp b/WebCore/platform/text/TextBreakIteratorICU.cpp
deleted file mode 100644
index 9941f58..0000000
--- a/WebCore/platform/text/TextBreakIteratorICU.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (C) 2006 Lars Knoll <lars@trolltech.com>
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "TextBreakIterator.h"
-
-#include "TextBreakIteratorInternalICU.h"
-
-#include <unicode/ubrk.h>
-#include <wtf/Assertions.h>
-
-namespace WebCore {
-
-static TextBreakIterator* setUpIterator(bool& createdIterator, TextBreakIterator*& iterator,
- UBreakIteratorType type, const UChar* string, int length)
-{
- if (!string)
- return 0;
-
- if (!createdIterator) {
- UErrorCode openStatus = U_ZERO_ERROR;
- iterator = static_cast<TextBreakIterator*>(ubrk_open(type, currentTextBreakLocaleID(), 0, 0, &openStatus));
- createdIterator = true;
- ASSERT_WITH_MESSAGE(U_SUCCESS(openStatus), "ICU could not open a break iterator: %s (%d)", u_errorName(openStatus), openStatus);
- }
- if (!iterator)
- return 0;
-
- UErrorCode setTextStatus = U_ZERO_ERROR;
- ubrk_setText(iterator, string, length, &setTextStatus);
- if (U_FAILURE(setTextStatus))
- return 0;
-
- return iterator;
-}
-
-TextBreakIterator* characterBreakIterator(const UChar* string, int length)
-{
- static bool createdCharacterBreakIterator = false;
- static TextBreakIterator* staticCharacterBreakIterator;
- return setUpIterator(createdCharacterBreakIterator,
- staticCharacterBreakIterator, UBRK_CHARACTER, string, length);
-}
-
-TextBreakIterator* wordBreakIterator(const UChar* string, int length)
-{
- static bool createdWordBreakIterator = false;
- static TextBreakIterator* staticWordBreakIterator;
- return setUpIterator(createdWordBreakIterator,
- staticWordBreakIterator, UBRK_WORD, string, length);
-}
-
-TextBreakIterator* lineBreakIterator(const UChar* string, int length)
-{
- static bool createdLineBreakIterator = false;
- static TextBreakIterator* staticLineBreakIterator;
- return setUpIterator(createdLineBreakIterator,
- staticLineBreakIterator, UBRK_LINE, string, length);
-}
-
-TextBreakIterator* sentenceBreakIterator(const UChar* string, int length)
-{
- static bool createdSentenceBreakIterator = false;
- static TextBreakIterator* staticSentenceBreakIterator;
- return setUpIterator(createdSentenceBreakIterator,
- staticSentenceBreakIterator, UBRK_SENTENCE, string, length);
-}
-
-int textBreakFirst(TextBreakIterator* bi)
-{
- return ubrk_first(bi);
-}
-
-int textBreakNext(TextBreakIterator* bi)
-{
- return ubrk_next(bi);
-}
-
-int textBreakPreceding(TextBreakIterator* bi, int pos)
-{
- return ubrk_preceding(bi, pos);
-}
-
-int textBreakFollowing(TextBreakIterator* bi, int pos)
-{
- return ubrk_following(bi, pos);
-}
-
-int textBreakCurrent(TextBreakIterator* bi)
-{
- return ubrk_current(bi);
-}
-
-bool isTextBreak(TextBreakIterator* bi, int pos)
-{
- return ubrk_isBoundary(bi, pos);
-}
-
-}
diff --git a/WebCore/platform/text/TextBreakIteratorInternalICU.h b/WebCore/platform/text/TextBreakIteratorInternalICU.h
deleted file mode 100644
index d4b25e7..0000000
--- a/WebCore/platform/text/TextBreakIteratorInternalICU.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef TextBreakIteratorInternalICU_h
-#define TextBreakIteratorInternalICU_h
-
-#include <wtf/unicode/Unicode.h>
-
-namespace WebCore {
-
- const char* currentTextBreakLocaleID();
-
-}
-
-#endif
diff --git a/WebCore/platform/text/TextCodec.cpp b/WebCore/platform/text/TextCodec.cpp
deleted file mode 100644
index 4222ee1..0000000
--- a/WebCore/platform/text/TextCodec.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2006 Alexey Proskuryakov <ap@nypop.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "TextCodec.h"
-
-#include "PlatformString.h"
-#include <wtf/StringExtras.h>
-
-namespace WebCore {
-
-TextCodec::~TextCodec()
-{
-}
-
-int TextCodec::getUnencodableReplacement(unsigned codePoint, UnencodableHandling handling, UnencodableReplacementArray replacement)
-{
- switch (handling) {
- case QuestionMarksForUnencodables:
- replacement[0] = '?';
- replacement[1] = 0;
- return 1;
- case EntitiesForUnencodables:
- snprintf(replacement, sizeof(UnencodableReplacementArray), "&#%u;", codePoint);
- return static_cast<int>(strlen(replacement));
- case URLEncodedEntitiesForUnencodables:
- snprintf(replacement, sizeof(UnencodableReplacementArray), "%%26%%23%u%%3B", codePoint);
- return static_cast<int>(strlen(replacement));
- }
- ASSERT_NOT_REACHED();
- replacement[0] = 0;
- return 0;
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/text/TextCodec.h b/WebCore/platform/text/TextCodec.h
deleted file mode 100644
index 0a56262..0000000
--- a/WebCore/platform/text/TextCodec.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2006 Alexey Proskuryakov <ap@nypop.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef TextCodec_h
-#define TextCodec_h
-
-#include <memory>
-#include <wtf/Noncopyable.h>
-#include <wtf/Vector.h>
-#include <wtf/unicode/Unicode.h>
-
-#include "PlatformString.h"
-
-namespace WebCore {
- class TextEncoding;
-
- // Specifies what will happen when a character is encountered that is
- // not encodable in the character set.
- enum UnencodableHandling {
- // Substitutes the replacement character "?".
- QuestionMarksForUnencodables,
-
- // Encodes the character as an XML entity. For example, U+06DE
- // would be "&#1758;" (0x6DE = 1758 in octal).
- EntitiesForUnencodables,
-
- // Encodes the character as en entity as above, but escaped
- // non-alphanumeric characters. This is used in URLs.
- // For example, U+6DE would be "%26%231758%3B".
- URLEncodedEntitiesForUnencodables,
- };
-
- typedef char UnencodableReplacementArray[32];
-
- class TextCodec : Noncopyable {
- public:
- virtual ~TextCodec();
-
- String decode(const char* str, size_t length, bool flush = false)
- {
- bool ignored;
- return decode(str, length, flush, false, ignored);
- }
-
- virtual String decode(const char*, size_t length, bool flush, bool stopOnError, bool& sawError) = 0;
- virtual CString encode(const UChar*, size_t length, UnencodableHandling) = 0;
-
- // Fills a null-terminated string representation of the given
- // unencodable character into the given replacement buffer.
- // The length of the string (not including the null) will be returned.
- static int getUnencodableReplacement(unsigned codePoint, UnencodableHandling, UnencodableReplacementArray);
- };
-
- typedef void (*EncodingNameRegistrar)(const char* alias, const char* name);
-
- typedef std::auto_ptr<TextCodec> (*NewTextCodecFunction)(const TextEncoding&, const void* additionalData);
- typedef void (*TextCodecRegistrar)(const char* name, NewTextCodecFunction, const void* additionalData);
-
-} // namespace WebCore
-
-#endif // TextCodec_h
diff --git a/WebCore/platform/text/TextCodecICU.cpp b/WebCore/platform/text/TextCodecICU.cpp
deleted file mode 100644
index 0a324a2..0000000
--- a/WebCore/platform/text/TextCodecICU.cpp
+++ /dev/null
@@ -1,467 +0,0 @@
-/*
- * Copyright (C) 2004, 2006, 2007, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2006 Alexey Proskuryakov <ap@nypop.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "TextCodecICU.h"
-
-#include "CharacterNames.h"
-#include "CString.h"
-#include "PlatformString.h"
-#include <unicode/ucnv.h>
-#include <unicode/ucnv_cb.h>
-#include <wtf/Assertions.h>
-#include <wtf/StringExtras.h>
-
-using std::auto_ptr;
-using std::min;
-
-namespace WebCore {
-
-const size_t ConversionBufferSize = 16384;
-
-static UConverter* cachedConverterICU;
-
-static auto_ptr<TextCodec> newTextCodecICU(const TextEncoding& encoding, const void*)
-{
- return auto_ptr<TextCodec>(new TextCodecICU(encoding));
-}
-
-void TextCodecICU::registerBaseEncodingNames(EncodingNameRegistrar registrar)
-{
- registrar("UTF-8", "UTF-8");
-}
-
-void TextCodecICU::registerBaseCodecs(TextCodecRegistrar registrar)
-{
- registrar("UTF-8", newTextCodecICU, 0);
-}
-
-// FIXME: Registering all the encodings we get from ucnv_getAvailableName
-// includes encodings we don't want or need. For example, all
-// the encodings with commas and version numbers.
-
-void TextCodecICU::registerExtendedEncodingNames(EncodingNameRegistrar registrar)
-{
- // We register Hebrew with logical ordering using a separate name.
- // Otherwise, this would share the same canonical name as the
- // visual ordering case, and then TextEncoding could not tell them
- // apart; ICU treats these names as synonyms.
- registrar("ISO-8859-8-I", "ISO-8859-8-I");
-
- int32_t numEncodings = ucnv_countAvailable();
- for (int32_t i = 0; i < numEncodings; ++i) {
- const char* name = ucnv_getAvailableName(i);
- UErrorCode error = U_ZERO_ERROR;
- // Try MIME before trying IANA to pick up commonly used names like
- // 'EUC-JP' instead of horrendeously long names like
- // 'Extended_UNIX_Code_Packed_Format_for_Japanese'.
- const char* standardName = ucnv_getStandardName(name, "MIME", &error);
- if (!U_SUCCESS(error) || !standardName) {
- error = U_ZERO_ERROR;
- // Try IANA to pick up 'windows-12xx' and other names
- // which are not preferred MIME names but are widely used.
- standardName = ucnv_getStandardName(name, "IANA", &error);
- if (!U_SUCCESS(error) || !standardName)
- continue;
- }
-
- // 1. Treat GB2312 encoding as GBK (its more modern superset), to match other browsers.
- // 2. On the Web, GB2312 is encoded as EUC-CN or HZ, while ICU provides a native encoding
- // for encoding GB_2312-80 and several others. So, we need to override this behavior, too.
- if (strcmp(standardName, "GB2312") == 0 || strcmp(standardName, "GB_2312-80") == 0)
- standardName = "GBK";
- // Similarly, EUC-KR encodings all map to an extended version.
- else if (strcmp(standardName, "KSC_5601") == 0 || strcmp(standardName, "EUC-KR") == 0 || strcmp(standardName, "cp1363") == 0)
- standardName = "windows-949-2000";
- // And so on.
- else if (strcasecmp(standardName, "iso-8859-9") == 0) // This name is returned in different case by ICU 3.2 and 3.6.
- standardName = "windows-1254";
- else if (strcmp(standardName, "TIS-620") == 0)
- standardName = "windows-874-2000";
-
- registrar(standardName, standardName);
-
- uint16_t numAliases = ucnv_countAliases(name, &error);
- ASSERT(U_SUCCESS(error));
- if (U_SUCCESS(error))
- for (uint16_t j = 0; j < numAliases; ++j) {
- error = U_ZERO_ERROR;
- const char* alias = ucnv_getAlias(name, j, &error);
- ASSERT(U_SUCCESS(error));
- if (U_SUCCESS(error) && alias != standardName)
- registrar(alias, standardName);
- }
- }
-
- // Additional aliases.
- // These are present in modern versions of ICU, but not in ICU 3.2 (shipped with Mac OS X 10.4).
- registrar("macroman", "macintosh");
-#ifndef ANDROID // Android does not have x-mac-cyrillic in its ICU library
- registrar("maccyrillic", "x-mac-cyrillic");
-#endif
-
- // Additional aliases that historically were present in the encoding
- // table in WebKit on Macintosh that don't seem to be present in ICU.
- // Perhaps we can prove these are not used on the web and remove them.
- // Or perhaps we can get them added to ICU.
- registrar("xmacroman", "macintosh");
-#ifndef ANDROID // Android does not have x-mac-cyrillic in its ICU library
- registrar("xmacukrainian", "x-mac-cyrillic");
-#endif
- registrar("cnbig5", "Big5");
- registrar("cngb", "EUC-CN");
- registrar("csISO88598I", "ISO_8859-8-I");
- registrar("csgb231280", "EUC-CN");
- registrar("dos874", "cp874");
- registrar("koi", "KOI8-R");
- registrar("logical", "ISO-8859-8-I");
- registrar("unicode11utf8", "UTF-8");
- registrar("unicode20utf8", "UTF-8");
- registrar("visual", "ISO-8859-8");
- registrar("winarabic", "windows-1256");
- registrar("winbaltic", "windows-1257");
- registrar("wincyrillic", "windows-1251");
- registrar("iso885911", "windows874-2000");
- registrar("wingreek", "windows-1253");
- registrar("winhebrew", "windows-1255");
- registrar("winlatin2", "windows-1250");
- registrar("winturkish", "windows-1254");
- registrar("winvietnamese", "windows-1258");
- registrar("xcp1250", "windows-1250");
- registrar("xcp1251", "windows-1251");
- registrar("xeuc", "EUC-JP");
- registrar("xeuccn", "EUC-CN");
- registrar("xgbk", "EUC-CN");
- registrar("xunicode20utf8", "UTF-8");
- registrar("xwindows949", "windows-949-2000");
- registrar("xxbig5", "Big5");
-
- // This alias is present in modern versions of ICU, but it has no standard name,
- // so we give one to it manually. It is not present in ICU 3.2.
- registrar("windows874", "windows874-2000");
-
- // These aliases are present in modern versions of ICU, but use different codecs, and have no standard names.
- // They are not present in ICU 3.2.
- registrar("dos720", "cp864");
- registrar("jis7", "ISO-2022-JP");
-}
-
-void TextCodecICU::registerExtendedCodecs(TextCodecRegistrar registrar)
-{
- // See comment above in registerEncodingNames.
- registrar("ISO-8859-8-I", newTextCodecICU, 0);
-
- int32_t numEncodings = ucnv_countAvailable();
- for (int32_t i = 0; i < numEncodings; ++i) {
- const char* name = ucnv_getAvailableName(i);
- UErrorCode error = U_ZERO_ERROR;
- const char* standardName = ucnv_getStandardName(name, "MIME", &error);
- if (!U_SUCCESS(error) || !standardName) {
- error = U_ZERO_ERROR;
- standardName = ucnv_getStandardName(name, "IANA", &error);
- if (!U_SUCCESS(error) || !standardName)
- continue;
- }
- registrar(standardName, newTextCodecICU, 0);
- }
-}
-
-TextCodecICU::TextCodecICU(const TextEncoding& encoding)
- : m_encoding(encoding)
- , m_numBufferedBytes(0)
- , m_converterICU(0)
- , m_needsGBKFallbacks(false)
-{
-}
-
-TextCodecICU::~TextCodecICU()
-{
- releaseICUConverter();
-}
-
-void TextCodecICU::releaseICUConverter() const
-{
- if (m_converterICU) {
- if (cachedConverterICU)
- ucnv_close(cachedConverterICU);
- cachedConverterICU = m_converterICU;
- m_converterICU = 0;
- }
-}
-
-void TextCodecICU::createICUConverter() const
-{
- ASSERT(!m_converterICU);
-
- const char* name = m_encoding.name();
- m_needsGBKFallbacks = name[0] == 'G' && name[1] == 'B' && name[2] == 'K' && !name[3];
-
- UErrorCode err;
-
- if (cachedConverterICU) {
- err = U_ZERO_ERROR;
- const char* cachedName = ucnv_getName(cachedConverterICU, &err);
- if (U_SUCCESS(err) && m_encoding == cachedName) {
- m_converterICU = cachedConverterICU;
- cachedConverterICU = 0;
- return;
- }
- }
-
- err = U_ZERO_ERROR;
- m_converterICU = ucnv_open(m_encoding.name(), &err);
-#if !LOG_DISABLED
- if (err == U_AMBIGUOUS_ALIAS_WARNING)
- LOG_ERROR("ICU ambiguous alias warning for encoding: %s", m_encoding.name());
-#endif
- if (m_converterICU)
- ucnv_setFallback(m_converterICU, TRUE);
-}
-
-int TextCodecICU::decodeToBuffer(UChar* target, UChar* targetLimit, const char*& source, const char* sourceLimit, int32_t* offsets, bool flush, UErrorCode& err)
-{
- UChar* targetStart = target;
- err = U_ZERO_ERROR;
- ucnv_toUnicode(m_converterICU, &target, targetLimit, &source, sourceLimit, offsets, flush, &err);
- return target - targetStart;
-}
-
-class ErrorCallbackSetter {
-public:
- ErrorCallbackSetter(UConverter* converter, bool stopOnError)
- : m_converter(converter)
- , m_shouldStopOnEncodingErrors(stopOnError)
- {
- if (m_shouldStopOnEncodingErrors) {
- UErrorCode err = U_ZERO_ERROR;
- ucnv_setToUCallBack(m_converter, UCNV_TO_U_CALLBACK_SUBSTITUTE,
- UCNV_SUB_STOP_ON_ILLEGAL, &m_savedAction,
- &m_savedContext, &err);
- ASSERT(err == U_ZERO_ERROR);
- }
- }
- ~ErrorCallbackSetter()
- {
- if (m_shouldStopOnEncodingErrors) {
- UErrorCode err = U_ZERO_ERROR;
- const void* oldContext;
- UConverterToUCallback oldAction;
- ucnv_setToUCallBack(m_converter, m_savedAction,
- m_savedContext, &oldAction,
- &oldContext, &err);
- ASSERT(oldAction == UCNV_TO_U_CALLBACK_SUBSTITUTE);
- ASSERT(!strcmp(static_cast<const char*>(oldContext), UCNV_SUB_STOP_ON_ILLEGAL));
- ASSERT(err == U_ZERO_ERROR);
- }
- }
-private:
- UConverter* m_converter;
- bool m_shouldStopOnEncodingErrors;
- const void* m_savedContext;
- UConverterToUCallback m_savedAction;
-};
-
-String TextCodecICU::decode(const char* bytes, size_t length, bool flush, bool stopOnError, bool& sawError)
-{
- // Get a converter for the passed-in encoding.
- if (!m_converterICU) {
- createICUConverter();
- ASSERT(m_converterICU);
- if (!m_converterICU) {
- LOG_ERROR("error creating ICU encoder even though encoding was in table");
- return String();
- }
- }
-
- ErrorCallbackSetter callbackSetter(m_converterICU, stopOnError);
-
- Vector<UChar> result;
-
- UChar buffer[ConversionBufferSize];
- UChar* bufferLimit = buffer + ConversionBufferSize;
- const char* source = reinterpret_cast<const char*>(bytes);
- const char* sourceLimit = source + length;
- int32_t* offsets = NULL;
- UErrorCode err = U_ZERO_ERROR;
-
- do {
- int ucharsDecoded = decodeToBuffer(buffer, bufferLimit, source, sourceLimit, offsets, flush, err);
- result.append(buffer, ucharsDecoded);
- } while (err == U_BUFFER_OVERFLOW_ERROR);
-
- if (U_FAILURE(err)) {
- // flush the converter so it can be reused, and not be bothered by this error.
- do {
- decodeToBuffer(buffer, bufferLimit, source, sourceLimit, offsets, true, err);
- } while (source < sourceLimit);
- sawError = true;
- }
-
- String resultString = String::adopt(result);
-
- // <http://bugs.webkit.org/show_bug.cgi?id=17014>
- // Simplified Chinese pages use the code A3A0 to mean "full-width space", but ICU decodes it as U+E5E5.
- if (m_encoding == "GBK" || m_encoding == "gb18030")
- resultString.replace(0xE5E5, ideographicSpace);
-
- return resultString;
-}
-
-// We need to apply these fallbacks ourselves as they are not currently supported by ICU and
-// they were provided by the old TEC encoding path
-// Needed to fix <rdar://problem/4708689>
-static UChar getGbkEscape(UChar32 codePoint)
-{
- switch (codePoint) {
- case 0x01F9:
- return 0xE7C8;
- case 0x1E3F:
- return 0xE7C7;
- case 0x22EF:
- return 0x2026;
- case 0x301C:
- return 0xFF5E;
- default:
- return 0;
- }
-}
-
-// Invalid character handler when writing escaped entities for unrepresentable
-// characters. See the declaration of TextCodec::encode for more.
-static void urlEscapedEntityCallback(const void* context, UConverterFromUnicodeArgs* fromUArgs, const UChar* codeUnits, int32_t length,
- UChar32 codePoint, UConverterCallbackReason reason, UErrorCode* err)
-{
- if (reason == UCNV_UNASSIGNED) {
- *err = U_ZERO_ERROR;
-
- UnencodableReplacementArray entity;
- int entityLen = TextCodec::getUnencodableReplacement(codePoint, URLEncodedEntitiesForUnencodables, entity);
- ucnv_cbFromUWriteBytes(fromUArgs, entity, entityLen, 0, err);
- } else
- UCNV_FROM_U_CALLBACK_ESCAPE(context, fromUArgs, codeUnits, length, codePoint, reason, err);
-}
-
-// Substitutes special GBK characters, escaping all other unassigned entities.
-static void gbkCallbackEscape(const void* context, UConverterFromUnicodeArgs* fromUArgs, const UChar* codeUnits, int32_t length,
- UChar32 codePoint, UConverterCallbackReason reason, UErrorCode* err)
-{
- UChar outChar;
- if (reason == UCNV_UNASSIGNED && (outChar = getGbkEscape(codePoint))) {
- const UChar* source = &outChar;
- *err = U_ZERO_ERROR;
- ucnv_cbFromUWriteUChars(fromUArgs, &source, source + 1, 0, err);
- return;
- }
- UCNV_FROM_U_CALLBACK_ESCAPE(context, fromUArgs, codeUnits, length, codePoint, reason, err);
-}
-
-// Combines both gbkUrlEscapedEntityCallback and GBK character substitution.
-static void gbkUrlEscapedEntityCallack(const void* context, UConverterFromUnicodeArgs* fromUArgs, const UChar* codeUnits, int32_t length,
- UChar32 codePoint, UConverterCallbackReason reason, UErrorCode* err)
-{
- if (reason == UCNV_UNASSIGNED) {
- if (UChar outChar = getGbkEscape(codePoint)) {
- const UChar* source = &outChar;
- *err = U_ZERO_ERROR;
- ucnv_cbFromUWriteUChars(fromUArgs, &source, source + 1, 0, err);
- return;
- }
- urlEscapedEntityCallback(context, fromUArgs, codeUnits, length, codePoint, reason, err);
- return;
- }
- UCNV_FROM_U_CALLBACK_ESCAPE(context, fromUArgs, codeUnits, length, codePoint, reason, err);
-}
-
-static void gbkCallbackSubstitute(const void* context, UConverterFromUnicodeArgs* fromUArgs, const UChar* codeUnits, int32_t length,
- UChar32 codePoint, UConverterCallbackReason reason, UErrorCode* err)
-{
- UChar outChar;
- if (reason == UCNV_UNASSIGNED && (outChar = getGbkEscape(codePoint))) {
- const UChar* source = &outChar;
- *err = U_ZERO_ERROR;
- ucnv_cbFromUWriteUChars(fromUArgs, &source, source + 1, 0, err);
- return;
- }
- UCNV_FROM_U_CALLBACK_SUBSTITUTE(context, fromUArgs, codeUnits, length, codePoint, reason, err);
-}
-
-CString TextCodecICU::encode(const UChar* characters, size_t length, UnencodableHandling handling)
-{
- if (!length)
- return "";
-
- if (!m_converterICU)
- createICUConverter();
- if (!m_converterICU)
- return CString();
-
- // FIXME: We should see if there is "force ASCII range" mode in ICU;
- // until then, we change the backslash into a yen sign.
- // Encoding will change the yen sign back into a backslash.
- String copy(characters, length);
- copy.replace('\\', m_encoding.backslashAsCurrencySymbol());
-
- const UChar* source = copy.characters();
- const UChar* sourceLimit = source + copy.length();
-
- UErrorCode err = U_ZERO_ERROR;
-
- switch (handling) {
- case QuestionMarksForUnencodables:
- ucnv_setSubstChars(m_converterICU, "?", 1, &err);
- ucnv_setFromUCallBack(m_converterICU, m_needsGBKFallbacks ? gbkCallbackSubstitute : UCNV_FROM_U_CALLBACK_SUBSTITUTE, 0, 0, 0, &err);
- break;
- case EntitiesForUnencodables:
- ucnv_setFromUCallBack(m_converterICU, m_needsGBKFallbacks ? gbkCallbackEscape : UCNV_FROM_U_CALLBACK_ESCAPE, UCNV_ESCAPE_XML_DEC, 0, 0, &err);
- break;
- case URLEncodedEntitiesForUnencodables:
- ucnv_setFromUCallBack(m_converterICU, m_needsGBKFallbacks ? gbkUrlEscapedEntityCallack : urlEscapedEntityCallback, 0, 0, 0, &err);
- break;
- }
-
- ASSERT(U_SUCCESS(err));
- if (U_FAILURE(err))
- return CString();
-
- Vector<char> result;
- size_t size = 0;
- do {
- char buffer[ConversionBufferSize];
- char* target = buffer;
- char* targetLimit = target + ConversionBufferSize;
- err = U_ZERO_ERROR;
- ucnv_fromUnicode(m_converterICU, &target, targetLimit, &source, sourceLimit, 0, true, &err);
- size_t count = target - buffer;
- result.grow(size + count);
- memcpy(result.data() + size, buffer, count);
- size += count;
- } while (err == U_BUFFER_OVERFLOW_ERROR);
-
- return CString(result.data(), size);
-}
-
-
-} // namespace WebCore
diff --git a/WebCore/platform/text/TextCodecICU.h b/WebCore/platform/text/TextCodecICU.h
deleted file mode 100644
index 9c9a4a7b..0000000
--- a/WebCore/platform/text/TextCodecICU.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2006 Alexey Proskuryakov <ap@nypop.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef TextCodecICU_h
-#define TextCodecICU_h
-
-#include "TextCodec.h"
-#include "TextEncoding.h"
-
-typedef struct UConverter UConverter;
-
-namespace WebCore {
-
- class TextCodecICU : public TextCodec {
- public:
- static void registerBaseEncodingNames(EncodingNameRegistrar);
- static void registerBaseCodecs(TextCodecRegistrar);
-
- static void registerExtendedEncodingNames(EncodingNameRegistrar);
- static void registerExtendedCodecs(TextCodecRegistrar);
-
- TextCodecICU(const TextEncoding&);
- virtual ~TextCodecICU();
-
- virtual String decode(const char*, size_t length, bool flush, bool stopOnError, bool& sawError);
- virtual CString encode(const UChar*, size_t length, UnencodableHandling);
-
- private:
- void createICUConverter() const;
- void releaseICUConverter() const;
- bool needsGBKFallbacks() const { return m_needsGBKFallbacks; }
- void setNeedsGBKFallbacks(bool needsFallbacks) { m_needsGBKFallbacks = needsFallbacks; }
-
- int decodeToBuffer(UChar* buffer, UChar* bufferLimit, const char*& source,
- const char* sourceLimit, int32_t* offsets, bool flush, UErrorCode& err);
-
- TextEncoding m_encoding;
- unsigned m_numBufferedBytes;
- unsigned char m_bufferedBytes[16]; // bigger than any single multi-byte character
- mutable UConverter* m_converterICU;
- mutable bool m_needsGBKFallbacks;
- };
-
-} // namespace WebCore
-
-#endif // TextCodecICU_h
diff --git a/WebCore/platform/text/TextCodecLatin1.cpp b/WebCore/platform/text/TextCodecLatin1.cpp
deleted file mode 100644
index 50f9f97..0000000
--- a/WebCore/platform/text/TextCodecLatin1.cpp
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "TextCodecLatin1.h"
-
-#include "CString.h"
-#include "PlatformString.h"
-#include "StringBuffer.h"
-#include <stdio.h>
-
-using std::auto_ptr;
-
-namespace WebCore {
-
-static const UChar table[256] = {
- 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, // 00-07
- 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F, // 08-0F
- 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, // 10-17
- 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F, // 18-1F
- 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, // 20-27
- 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, // 28-2F
- 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, // 30-37
- 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F, // 38-3F
- 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, // 40-47
- 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, // 48-4F
- 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, // 50-57
- 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F, // 58-5F
- 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, // 60-67
- 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, // 68-6F
- 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, // 70-77
- 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F, // 78-7F
- 0x20AC, 0x0081, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, // 80-87
- 0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, 0x008D, 0x017D, 0x008F, // 88-8F
- 0x0090, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, // 90-97
- 0x02DC, 0x2122, 0x0161, 0x203A, 0x0153, 0x009D, 0x017E, 0x0178, // 98-9F
- 0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, // A0-A7
- 0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF, // A8-AF
- 0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, // B0-B7
- 0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF, // B8-BF
- 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7, // C0-C7
- 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, // C8-CF
- 0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7, // D0-D7
- 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF, // D8-DF
- 0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, // E0-E7
- 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, // E8-EF
- 0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7, // F0-F7
- 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF // F8-FF
-};
-
-void TextCodecLatin1::registerEncodingNames(EncodingNameRegistrar registrar)
-{
- registrar("windows-1252", "windows-1252");
- registrar("ISO-8859-1", "ISO-8859-1");
- registrar("US-ASCII", "US-ASCII");
-
- registrar("WinLatin1", "windows-1252");
- registrar("ibm-1252", "windows-1252");
- registrar("ibm-1252_P100-2000", "windows-1252");
-
- registrar("8859-1", "ISO-8859-1");
- registrar("CP819", "ISO-8859-1");
- registrar("IBM819", "ISO-8859-1");
- registrar("csISOLatin1", "ISO-8859-1");
- registrar("iso-ir-100", "ISO-8859-1");
- registrar("iso_8859-1:1987", "ISO-8859-1");
- registrar("l1", "ISO-8859-1");
- registrar("latin1", "ISO-8859-1");
-
- registrar("ANSI_X3.4-1968", "US-ASCII");
- registrar("ANSI_X3.4-1986", "US-ASCII");
- registrar("ASCII", "US-ASCII");
- registrar("IBM367", "US-ASCII");
- registrar("ISO646-US", "US-ASCII");
- registrar("ISO_646.irv:1991", "US-ASCII");
- registrar("cp367", "US-ASCII");
- registrar("csASCII", "US-ASCII");
- registrar("ibm-367_P100-1995", "US-ASCII");
- registrar("iso-ir-6", "US-ASCII");
- registrar("iso-ir-6-us", "US-ASCII");
- registrar("us", "US-ASCII");
- registrar("x-ansi", "US-ASCII");
-}
-
-static auto_ptr<TextCodec> newStreamingTextDecoderWindowsLatin1(const TextEncoding&, const void*)
-{
- return auto_ptr<TextCodec>(new TextCodecLatin1);
-}
-
-void TextCodecLatin1::registerCodecs(TextCodecRegistrar registrar)
-{
- registrar("windows-1252", newStreamingTextDecoderWindowsLatin1, 0);
-
- // ASCII and Latin-1 both decode as Windows Latin-1 although they retain unique identities.
- registrar("ISO-8859-1", newStreamingTextDecoderWindowsLatin1, 0);
- registrar("US-ASCII", newStreamingTextDecoderWindowsLatin1, 0);
-}
-
-String TextCodecLatin1::decode(const char* bytes, size_t length, bool, bool, bool&)
-{
- StringBuffer characters(length);
-
- // Convert the string a fast way and simultaneously do an efficient check to see if it's all ASCII.
- unsigned char ored = 0;
- for (size_t i = 0; i < length; ++i) {
- unsigned char c = bytes[i];
- characters[i] = c;
- ored |= c;
- }
-
- if (!(ored & 0x80))
- return String::adopt(characters);
-
- // Convert the slightly slower way when there are non-ASCII characters.
- for (size_t i = 0; i < length; ++i) {
- unsigned char c = bytes[i];
- characters[i] = table[c];
- }
-
- return String::adopt(characters);
-}
-
-static CString encodeComplexWindowsLatin1(const UChar* characters, size_t length, UnencodableHandling handling)
-{
- Vector<char> result(length);
- char* bytes = result.data();
-
- size_t resultLength = 0;
- for (size_t i = 0; i < length; ) {
- UChar32 c;
- U16_NEXT(characters, i, length, c);
- unsigned char b = c;
- // Do an efficient check to detect characters other than 00-7F and A0-FF.
- if (b != c || (c & 0xE0) == 0x80) {
- // Look for a way to encode this with Windows Latin-1.
- for (b = 0x80; b < 0xA0; ++b)
- if (table[b] == c)
- goto gotByte;
- // No way to encode this character with Windows Latin-1.
- UnencodableReplacementArray replacement;
- int replacementLength = TextCodec::getUnencodableReplacement(c, handling, replacement);
- result.grow(resultLength + replacementLength + length - i);
- bytes = result.data();
- memcpy(bytes + resultLength, replacement, replacementLength);
- resultLength += replacementLength;
- continue;
- }
- gotByte:
- bytes[resultLength++] = b;
- }
-
- return CString(bytes, resultLength);
-}
-
-CString TextCodecLatin1::encode(const UChar* characters, size_t length, UnencodableHandling handling)
-{
- {
- char* bytes;
- CString string = CString::newUninitialized(length, bytes);
-
- // Convert the string a fast way and simultaneously do an efficient check to see if it's all ASCII.
- UChar ored = 0;
- for (size_t i = 0; i < length; ++i) {
- UChar c = characters[i];
- bytes[i] = c;
- ored |= c;
- }
-
- if (!(ored & 0xFF80))
- return string;
- }
-
- // If it wasn't all ASCII, call the function that handles more-complex cases.
- return encodeComplexWindowsLatin1(characters, length, handling);
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/text/TextCodecLatin1.h b/WebCore/platform/text/TextCodecLatin1.h
deleted file mode 100644
index f035d01..0000000
--- a/WebCore/platform/text/TextCodecLatin1.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef TextCodecLatin1_h
-#define TextCodecLatin1_h
-
-#include "TextCodec.h"
-
-namespace WebCore {
-
- class TextCodecLatin1 : public TextCodec {
- public:
- static void registerEncodingNames(EncodingNameRegistrar);
- static void registerCodecs(TextCodecRegistrar);
-
- virtual String decode(const char*, size_t length, bool flush, bool stopOnError, bool& sawError);
- virtual CString encode(const UChar*, size_t length, UnencodableHandling);
- };
-
-} // namespace WebCore
-
-#endif // TextCodecLatin1_h
diff --git a/WebCore/platform/text/TextCodecUTF16.cpp b/WebCore/platform/text/TextCodecUTF16.cpp
deleted file mode 100644
index 88e4e73..0000000
--- a/WebCore/platform/text/TextCodecUTF16.cpp
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "TextCodecUTF16.h"
-
-#include "CString.h"
-#include "PlatformString.h"
-#include "StringBuffer.h"
-
-using std::auto_ptr;
-
-namespace WebCore {
-
-void TextCodecUTF16::registerEncodingNames(EncodingNameRegistrar registrar)
-{
- registrar("UTF-16LE", "UTF-16LE");
- registrar("UTF-16BE", "UTF-16BE");
-
- registrar("ISO-10646-UCS-2", "UTF-16LE");
- registrar("UCS-2", "UTF-16LE");
- registrar("UTF-16", "UTF-16LE");
- registrar("Unicode", "UTF-16LE");
- registrar("csUnicode", "UTF-16LE");
- registrar("unicodeFEFF", "UTF-16LE");
-
- registrar("unicodeFFFE", "UTF-16BE");
-}
-
-static auto_ptr<TextCodec> newStreamingTextDecoderUTF16LE(const TextEncoding&, const void*)
-{
- return auto_ptr<TextCodec>(new TextCodecUTF16(true));
-}
-
-static auto_ptr<TextCodec> newStreamingTextDecoderUTF16BE(const TextEncoding&, const void*)
-{
- return auto_ptr<TextCodec>(new TextCodecUTF16(false));
-}
-
-void TextCodecUTF16::registerCodecs(TextCodecRegistrar registrar)
-{
- registrar("UTF-16LE", newStreamingTextDecoderUTF16LE, 0);
- registrar("UTF-16BE", newStreamingTextDecoderUTF16BE, 0);
-}
-
-String TextCodecUTF16::decode(const char* bytes, size_t length, bool, bool stopOnError, bool& sawError)
-{
- if (!length)
- return String();
-
- const unsigned char* p = reinterpret_cast<const unsigned char*>(bytes);
- size_t numBytes = length + m_haveBufferedByte;
- size_t numChars = numBytes / 2;
-
- StringBuffer buffer(numChars);
- UChar* q = buffer.characters();
-
- if (m_haveBufferedByte) {
- UChar c;
- if (m_littleEndian)
- c = m_bufferedByte | (p[0] << 8);
- else
- c = (m_bufferedByte << 8) | p[0];
- *q++ = c;
- m_haveBufferedByte = false;
- p += 1;
- numChars -= 1;
- }
-
- if (m_littleEndian)
- for (size_t i = 0; i < numChars; ++i) {
- UChar c = p[0] | (p[1] << 8);
- p += 2;
- *q++ = c;
- }
- else
- for (size_t i = 0; i < numChars; ++i) {
- UChar c = (p[0] << 8) | p[1];
- p += 2;
- *q++ = c;
- }
-
- if (numBytes & 1) {
- ASSERT(!m_haveBufferedByte);
- m_haveBufferedByte = true;
- m_bufferedByte = p[0];
- }
-
- buffer.shrink(q - buffer.characters());
-
- return String::adopt(buffer);
-}
-
-CString TextCodecUTF16::encode(const UChar* characters, size_t length, UnencodableHandling)
-{
- char* bytes;
- CString string = CString::newUninitialized(length * 2, bytes);
-
- // FIXME: CString is not a reasonable data structure for encoded UTF-16, which will have
- // null characters inside it. Perhaps the result of encode should not be a CString?
- if (m_littleEndian)
- for (size_t i = 0; i < length; ++i) {
- UChar c = characters[i];
- bytes[i * 2] = c;
- bytes[i * 2 + 1] = c >> 8;
- }
- else
- for (size_t i = 0; i < length; ++i) {
- UChar c = characters[i];
- bytes[i * 2] = c >> 8;
- bytes[i * 2 + 1] = c;
- }
-
- return string;
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/text/TextCodecUTF16.h b/WebCore/platform/text/TextCodecUTF16.h
deleted file mode 100644
index 8ce9476..0000000
--- a/WebCore/platform/text/TextCodecUTF16.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef TextCodecUTF16_h
-#define TextCodecUTF16_h
-
-#include "TextCodec.h"
-
-namespace WebCore {
-
- class TextCodecUTF16 : public TextCodec {
- public:
- static void registerEncodingNames(EncodingNameRegistrar);
- static void registerCodecs(TextCodecRegistrar);
-
- TextCodecUTF16(bool littleEndian) : m_littleEndian(littleEndian), m_haveBufferedByte(false) { }
-
- virtual String decode(const char*, size_t length, bool flush, bool stopOnError, bool& sawError);
- virtual CString encode(const UChar*, size_t length, UnencodableHandling);
-
- private:
- bool m_littleEndian;
- bool m_haveBufferedByte;
- unsigned char m_bufferedByte;
- };
-
-} // namespace WebCore
-
-#endif // TextCodecUTF16_h
diff --git a/WebCore/platform/text/TextCodecUserDefined.cpp b/WebCore/platform/text/TextCodecUserDefined.cpp
deleted file mode 100644
index 2dae0f3..0000000
--- a/WebCore/platform/text/TextCodecUserDefined.cpp
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (C) 2007, 2008 Apple, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "TextCodecUserDefined.h"
-
-#include "CString.h"
-#include "PlatformString.h"
-#include "StringBuffer.h"
-#include <stdio.h>
-
-using std::auto_ptr;
-
-namespace WebCore {
-
-void TextCodecUserDefined::registerEncodingNames(EncodingNameRegistrar registrar)
-{
- registrar("x-user-defined", "x-user-defined");
-}
-
-static auto_ptr<TextCodec> newStreamingTextDecoderUserDefined(const TextEncoding&, const void*)
-{
- return auto_ptr<TextCodec>(new TextCodecUserDefined);
-}
-
-void TextCodecUserDefined::registerCodecs(TextCodecRegistrar registrar)
-{
- registrar("x-user-defined", newStreamingTextDecoderUserDefined, 0);
-}
-
-String TextCodecUserDefined::decode(const char* bytes, size_t length, bool, bool, bool&)
-{
- StringBuffer buffer(length);
-
- for (size_t i = 0; i < length; ++i) {
- signed char c = bytes[i];
- buffer[i] = c & 0xF7FF;
- }
-
- return String::adopt(buffer);
-}
-
-static CString encodeComplexUserDefined(const UChar* characters, size_t length, UnencodableHandling handling)
-{
- Vector<char> result(length);
- char* bytes = result.data();
-
- size_t resultLength = 0;
- for (size_t i = 0; i < length; ) {
- UChar32 c;
- U16_NEXT(characters, i, length, c);
- signed char signedByte = c;
- if ((signedByte & 0xF7FF) == c)
- bytes[resultLength++] = signedByte;
- else {
- // No way to encode this character with x-user-defined.
- UnencodableReplacementArray replacement;
- int replacementLength = TextCodec::getUnencodableReplacement(c, handling, replacement);
- result.grow(resultLength + replacementLength + length - i);
- bytes = result.data();
- memcpy(bytes + resultLength, replacement, replacementLength);
- resultLength += replacementLength;
- }
- }
-
- return CString(bytes, resultLength);
-}
-
-CString TextCodecUserDefined::encode(const UChar* characters, size_t length, UnencodableHandling handling)
-{
- char* bytes;
- CString string = CString::newUninitialized(length, bytes);
-
- // Convert the string a fast way and simultaneously do an efficient check to see if it's all ASCII.
- UChar ored = 0;
- for (size_t i = 0; i < length; ++i) {
- UChar c = characters[i];
- bytes[i] = c;
- ored |= c;
- }
-
- if (!(ored & 0xFF80))
- return string;
-
- // If it wasn't all ASCII, call the function that handles more-complex cases.
- return encodeComplexUserDefined(characters, length, handling);
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/text/TextCodecUserDefined.h b/WebCore/platform/text/TextCodecUserDefined.h
deleted file mode 100644
index d1b3160..0000000
--- a/WebCore/platform/text/TextCodecUserDefined.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2007 Apple, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef TextCodecUserDefined_h
-#define TextCodecUserDefined_h
-
-#include "TextCodec.h"
-
-namespace WebCore {
-
- class TextCodecUserDefined : public TextCodec {
- public:
- static void registerEncodingNames(EncodingNameRegistrar);
- static void registerCodecs(TextCodecRegistrar);
-
- virtual String decode(const char*, size_t length, bool flush, bool stopOnError, bool& sawError);
- virtual CString encode(const UChar*, size_t length, UnencodableHandling);
- };
-
-} // namespace WebCore
-
-#endif // TextCodecUserDefined_h
diff --git a/WebCore/platform/text/TextDecoder.cpp b/WebCore/platform/text/TextDecoder.cpp
deleted file mode 100644
index e39a6b7..0000000
--- a/WebCore/platform/text/TextDecoder.cpp
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "TextDecoder.h"
-
-#include "TextEncodingRegistry.h"
-
-// FIXME: Would be nice to also handle BOM for UTF-7 and UTF-32.
-
-namespace WebCore {
-
-TextDecoder::TextDecoder(const TextEncoding& encoding)
- : m_encoding(encoding)
- , m_checkedForBOM(false)
- , m_numBufferedBytes(0)
-{
-}
-
-void TextDecoder::reset(const TextEncoding& encoding)
-{
- m_encoding = encoding;
- m_codec.clear();
- m_checkedForBOM = false;
- m_numBufferedBytes = 0;
-}
-
-String TextDecoder::checkForBOM(const char* data, size_t length, bool flush, bool stopOnError, bool& sawError)
-{
- ASSERT(!m_checkedForBOM);
-
- // Check to see if we found a BOM.
- size_t numBufferedBytes = m_numBufferedBytes;
- size_t buf1Len = numBufferedBytes;
- size_t buf2Len = length;
- const unsigned char* buf1 = m_bufferedBytes;
- const unsigned char* buf2 = reinterpret_cast<const unsigned char*>(data);
- unsigned char c1 = buf1Len ? (--buf1Len, *buf1++) : buf2Len ? (--buf2Len, *buf2++) : 0;
- unsigned char c2 = buf1Len ? (--buf1Len, *buf1++) : buf2Len ? (--buf2Len, *buf2++) : 0;
- unsigned char c3 = buf1Len ? (--buf1Len, *buf1++) : buf2Len ? (--buf2Len, *buf2++) : 0;
- unsigned char c4 = buf2Len ? (--buf2Len, *buf2++) : 0;
-
- const TextEncoding* encodingConsideringBOM = &m_encoding;
- bool foundBOM = true;
- size_t lengthOfBOM = 0;
- if (c1 == 0xFF && c2 == 0xFE) {
- if (c3 != 0 || c4 != 0) {
- encodingConsideringBOM = &UTF16LittleEndianEncoding();
- lengthOfBOM = 2;
- } else if (numBufferedBytes + length > sizeof(m_bufferedBytes)) {
- encodingConsideringBOM = &UTF32LittleEndianEncoding();
- lengthOfBOM = 4;
- } else
- foundBOM = false;
- } else if (c1 == 0xEF && c2 == 0xBB && c3 == 0xBF) {
- encodingConsideringBOM = &UTF8Encoding();
- lengthOfBOM = 3;
- } else if (c1 == 0xFE && c2 == 0xFF) {
- encodingConsideringBOM = &UTF16BigEndianEncoding();
- lengthOfBOM = 2;
- } else if (c1 == 0 && c2 == 0 && c3 == 0xFE && c4 == 0xFF) {
- encodingConsideringBOM = &UTF32BigEndianEncoding();
- lengthOfBOM = 4;
- } else
- foundBOM = false;
-
- if (!foundBOM && numBufferedBytes + length <= sizeof(m_bufferedBytes) && !flush) {
- // Continue to look for the BOM.
- memcpy(&m_bufferedBytes[numBufferedBytes], data, length);
- m_numBufferedBytes += length;
- return "";
- }
-
- // Done checking for BOM.
- m_codec.set(newTextCodec(*encodingConsideringBOM).release());
- if (!m_codec)
- return String();
- m_checkedForBOM = true;
-
- // Skip the BOM.
- if (foundBOM) {
- ASSERT(numBufferedBytes < lengthOfBOM);
- size_t numUnbufferedBOMBytes = lengthOfBOM - numBufferedBytes;
- ASSERT(numUnbufferedBOMBytes <= length);
-
- data += numUnbufferedBOMBytes;
- length -= numUnbufferedBOMBytes;
- numBufferedBytes = 0;
- m_numBufferedBytes = 0;
- }
-
- // Handle case where we have some buffered bytes to deal with.
- if (numBufferedBytes) {
- char bufferedBytes[sizeof(m_bufferedBytes)];
- memcpy(bufferedBytes, m_bufferedBytes, numBufferedBytes);
- m_numBufferedBytes = 0;
-
- String bufferedResult = m_codec->decode(bufferedBytes, numBufferedBytes, false, stopOnError, sawError);
- if (stopOnError && sawError)
- return bufferedResult;
- return bufferedResult + m_codec->decode(data, length, flush, stopOnError, sawError);
- }
-
- return m_codec->decode(data, length, flush, stopOnError, sawError);
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/text/TextDecoder.h b/WebCore/platform/text/TextDecoder.h
deleted file mode 100644
index 171cb59..0000000
--- a/WebCore/platform/text/TextDecoder.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef TextDecoder_h
-#define TextDecoder_h
-
-#include "PlatformString.h"
-#include "TextCodec.h"
-#include "TextEncoding.h"
-#include <wtf/OwnPtr.h>
-
-namespace WebCore {
-
- class TextCodec;
-
- class TextDecoder {
- public:
- TextDecoder(const TextEncoding&);
- void reset(const TextEncoding&);
- const TextEncoding& encoding() const { return m_encoding; };
-
- String decode(const char* data, size_t length, bool flush, bool stopOnError, bool& sawError)
- {
- if (!m_checkedForBOM)
- return checkForBOM(data, length, flush, stopOnError, sawError);
- return m_codec->decode(data, length, flush, stopOnError, sawError);
- }
-
- private:
- String checkForBOM(const char*, size_t length, bool flush, bool stopOnError, bool& sawError);
-
- TextEncoding m_encoding;
- OwnPtr<TextCodec> m_codec;
-
- bool m_checkedForBOM;
- unsigned char m_numBufferedBytes;
- unsigned char m_bufferedBytes[3];
- };
-
-} // namespace WebCore
-
-#endif // TextDecoder_h
diff --git a/WebCore/platform/text/TextDirection.h b/WebCore/platform/text/TextDirection.h
deleted file mode 100644
index 5be416e..0000000
--- a/WebCore/platform/text/TextDirection.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef TextDirection_h
-#define TextDirection_h
-
-namespace WebCore {
-
- enum TextDirection { RTL, LTR };
-
-}
-
-#endif
diff --git a/WebCore/platform/text/TextEncoding.cpp b/WebCore/platform/text/TextEncoding.cpp
deleted file mode 100644
index 9026049..0000000
--- a/WebCore/platform/text/TextEncoding.cpp
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Copyright (C) 2004, 2006, 2007, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2006 Alexey Proskuryakov <ap@nypop.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "TextEncoding.h"
-
-#include "CString.h"
-#include "PlatformString.h"
-#include "TextCodec.h"
-#include "TextDecoder.h"
-#include "TextEncodingRegistry.h"
-#if USE(ICU_UNICODE)
-#include <unicode/unorm.h>
-#elif USE(QT4_UNICODE)
-#include <QString>
-#endif
-#include <wtf/HashSet.h>
-#include <wtf/OwnPtr.h>
-
-namespace WebCore {
-
-static void addEncodingName(HashSet<const char*>& set, const char* name)
-{
- const char* atomicName = atomicCanonicalTextEncodingName(name);
- if (atomicName)
- set.add(atomicName);
-}
-
-TextEncoding::TextEncoding(const char* name)
- : m_name(atomicCanonicalTextEncodingName(name))
-{
-}
-
-TextEncoding::TextEncoding(const String& name)
- : m_name(atomicCanonicalTextEncodingName(name.characters(), name.length()))
-{
-}
-
-String TextEncoding::decode(const char* data, size_t length, bool stopOnError, bool& sawError) const
-{
- if (!m_name)
- return String();
-
- return TextDecoder(*this).decode(data, length, true, stopOnError, sawError);
-}
-
-CString TextEncoding::encode(const UChar* characters, size_t length, UnencodableHandling handling) const
-{
- if (!m_name)
- return CString();
-
- if (!length)
- return "";
-
-#if USE(ICU_UNICODE)
- // FIXME: What's the right place to do normalization?
- // It's a little strange to do it inside the encode function.
- // Perhaps normalization should be an explicit step done before calling encode.
-
- const UChar* source = characters;
- size_t sourceLength = length;
-
- Vector<UChar> normalizedCharacters;
-
- UErrorCode err = U_ZERO_ERROR;
- if (unorm_quickCheck(source, sourceLength, UNORM_NFC, &err) != UNORM_YES) {
- // First try using the length of the original string, since normalization to NFC rarely increases length.
- normalizedCharacters.grow(sourceLength);
- int32_t normalizedLength = unorm_normalize(source, length, UNORM_NFC, 0, normalizedCharacters.data(), length, &err);
- if (err == U_BUFFER_OVERFLOW_ERROR) {
- err = U_ZERO_ERROR;
- normalizedCharacters.resize(normalizedLength);
- normalizedLength = unorm_normalize(source, length, UNORM_NFC, 0, normalizedCharacters.data(), normalizedLength, &err);
- }
- ASSERT(U_SUCCESS(err));
-
- source = normalizedCharacters.data();
- sourceLength = normalizedLength;
- }
- return newTextCodec(*this)->encode(source, sourceLength, handling);
-#elif USE(QT4_UNICODE)
- QString str(reinterpret_cast<const QChar*>(characters), length);
- str = str.normalized(QString::NormalizationForm_C);
- return newTextCodec(*this)->encode(reinterpret_cast<const UChar *>(str.utf16()), str.length(), handling);
-#endif
-}
-
-bool TextEncoding::usesVisualOrdering() const
-{
- if (noExtendedTextEncodingNameUsed())
- return false;
-
- static const char* const a = atomicCanonicalTextEncodingName("ISO-8859-8");
- return m_name == a;
-}
-
-bool TextEncoding::isJapanese() const
-{
- if (noExtendedTextEncodingNameUsed())
- return false;
-
- static HashSet<const char*> set;
- if (set.isEmpty()) {
- addEncodingName(set, "x-mac-japanese");
- addEncodingName(set, "cp932");
- addEncodingName(set, "JIS_X0201");
- addEncodingName(set, "JIS_X0208-1983");
- addEncodingName(set, "JIS_X0208-1990");
- addEncodingName(set, "JIS_X0212-1990");
- addEncodingName(set, "JIS_C6226-1978");
- addEncodingName(set, "Shift_JIS_X0213-2000");
- addEncodingName(set, "ISO-2022-JP");
- addEncodingName(set, "ISO-2022-JP-2");
- addEncodingName(set, "ISO-2022-JP-1");
- addEncodingName(set, "ISO-2022-JP-3");
- addEncodingName(set, "EUC-JP");
- addEncodingName(set, "Shift_JIS");
- }
- return m_name && set.contains(m_name);
-}
-
-UChar TextEncoding::backslashAsCurrencySymbol() const
-{
- if (noExtendedTextEncodingNameUsed())
- return '\\';
-
- // The text encodings below treat backslash as a currency symbol.
- // See http://blogs.msdn.com/michkap/archive/2005/09/17/469941.aspx for more information.
- static const char* const a = atomicCanonicalTextEncodingName("Shift_JIS_X0213-2000");
- static const char* const b = atomicCanonicalTextEncodingName("EUC-JP");
- return (m_name == a || m_name == b) ? 0x00A5 : '\\';
-}
-
-const TextEncoding& TextEncoding::closest8BitEquivalent() const
-{
- if (*this == UTF16BigEndianEncoding() || *this == UTF16LittleEndianEncoding())
- return UTF8Encoding();
- return *this;
-}
-
-const TextEncoding& ASCIIEncoding()
-{
- static TextEncoding globalASCIIEncoding("ASCII");
- return globalASCIIEncoding;
-}
-
-const TextEncoding& Latin1Encoding()
-{
- static TextEncoding globalLatin1Encoding("Latin-1");
- return globalLatin1Encoding;
-}
-
-const TextEncoding& UTF16BigEndianEncoding()
-{
- static TextEncoding globalUTF16BigEndianEncoding("UTF-16BE");
- return globalUTF16BigEndianEncoding;
-}
-
-const TextEncoding& UTF16LittleEndianEncoding()
-{
- static TextEncoding globalUTF16LittleEndianEncoding("UTF-16LE");
- return globalUTF16LittleEndianEncoding;
-}
-
-const TextEncoding& UTF32BigEndianEncoding()
-{
- static TextEncoding globalUTF32BigEndianEncoding("UTF-32BE");
- return globalUTF32BigEndianEncoding;
-}
-
-const TextEncoding& UTF32LittleEndianEncoding()
-{
- static TextEncoding globalUTF32LittleEndianEncoding("UTF-32LE");
- return globalUTF32LittleEndianEncoding;
-}
-
-
-const TextEncoding& UTF8Encoding()
-{
- static TextEncoding globalUTF8Encoding("UTF-8");
- return globalUTF8Encoding;
-}
-
-const TextEncoding& WindowsLatin1Encoding()
-{
- static TextEncoding globalWindowsLatin1Encoding("WinLatin-1");
- return globalWindowsLatin1Encoding;
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/text/TextEncoding.h b/WebCore/platform/text/TextEncoding.h
deleted file mode 100644
index 0a0ab8c..0000000
--- a/WebCore/platform/text/TextEncoding.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef TextEncoding_h
-#define TextEncoding_h
-
-#include "TextCodec.h"
-#include <wtf/unicode/Unicode.h>
-
-namespace WebCore {
-
- class CString;
- class String;
-
- class TextEncoding {
- public:
- TextEncoding() : m_name(0) { }
- TextEncoding(const char* name);
- TextEncoding(const String& name);
-
- bool isValid() const { return m_name; }
- const char* name() const { return m_name; }
- bool usesVisualOrdering() const;
- bool isJapanese() const;
- UChar backslashAsCurrencySymbol() const;
- const TextEncoding& closest8BitEquivalent() const;
-
- String decode(const char* str, size_t length) const
- {
- bool ignored;
- return decode(str, length, false, ignored);
- }
- String decode(const char*, size_t length, bool stopOnError, bool& sawError) const;
- CString encode(const UChar*, size_t length, UnencodableHandling) const;
-
- private:
- const char* m_name;
- };
-
- inline bool operator==(const TextEncoding& a, const TextEncoding& b) { return a.name() == b.name(); }
- inline bool operator!=(const TextEncoding& a, const TextEncoding& b) { return a.name() != b.name(); }
-
- const TextEncoding& ASCIIEncoding();
- const TextEncoding& Latin1Encoding();
- const TextEncoding& UTF16BigEndianEncoding();
- const TextEncoding& UTF16LittleEndianEncoding();
- const TextEncoding& UTF32BigEndianEncoding();
- const TextEncoding& UTF32LittleEndianEncoding();
- const TextEncoding& UTF8Encoding();
- const TextEncoding& WindowsLatin1Encoding();
-
-} // namespace WebCore
-
-#endif // TextEncoding_h
diff --git a/WebCore/platform/text/TextEncodingRegistry.cpp b/WebCore/platform/text/TextEncodingRegistry.cpp
deleted file mode 100644
index 3f1f078..0000000
--- a/WebCore/platform/text/TextEncodingRegistry.cpp
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "TextEncodingRegistry.h"
-
-#include "PlatformString.h"
-#include "TextCodecLatin1.h"
-#include "TextCodecUserDefined.h"
-#include "TextCodecUTF16.h"
-#include <wtf/ASCIICType.h>
-#include <wtf/Assertions.h>
-#include <wtf/HashMap.h>
-#include <wtf/StringExtras.h>
-
-#if USE(ICU_UNICODE)
-#include "TextCodecICU.h"
-#endif
-#if PLATFORM(MAC)
-#include "TextCodecMac.h"
-#endif
-#if PLATFORM(QT)
-#include "qt/TextCodecQt.h"
-#endif
-
-using namespace WTF;
-
-namespace WebCore {
-
-const size_t maxEncodingNameLength = 63;
-
-// Hash for all-ASCII strings that does case folding and skips any characters
-// that are not alphanumeric. If passed any non-ASCII characters, depends on
-// the behavior of isalnum -- if that returns false as it does on OS X, then
-// it will properly skip those characters too.
-struct TextEncodingNameHash {
-
- // Golden ratio - arbitrary start value to avoid mapping all 0's to all 0's
- // or anything like that.
- static const unsigned PHI = 0x9e3779b9U;
-
- static bool equal(const char* s1, const char* s2)
- {
- char c1;
- char c2;
- do {
- do
- c1 = *s1++;
- while (c1 && !isASCIIAlphanumeric(c1));
- do
- c2 = *s2++;
- while (c2 && !isASCIIAlphanumeric(c2));
- if (toASCIILower(c1) != toASCIILower(c2))
- return false;
- } while (c1 && c2);
- return !c1 && !c2;
- }
-
- // This algorithm is the one-at-a-time hash from:
- // http://burtleburtle.net/bob/hash/hashfaq.html
- // http://burtleburtle.net/bob/hash/doobs.html
- static unsigned hash(const char* s)
- {
- unsigned h = PHI;
- for (;;) {
- char c;
- do {
- c = *s++;
- if (!c) {
- h += (h << 3);
- h ^= (h >> 11);
- h += (h << 15);
- return h;
- }
- } while (!isASCIIAlphanumeric(c));
- h += toASCIILower(c);
- h += (h << 10);
- h ^= (h >> 6);
- }
- }
-
- static const bool safeToCompareToEmptyOrDeleted = false;
-};
-
-struct TextCodecFactory {
- NewTextCodecFunction function;
- const void* additionalData;
- TextCodecFactory(NewTextCodecFunction f = 0, const void* d = 0) : function(f), additionalData(d) { }
-};
-
-typedef HashMap<const char*, const char*, TextEncodingNameHash> TextEncodingNameMap;
-typedef HashMap<const char*, TextCodecFactory> TextCodecMap;
-
-static TextEncodingNameMap* textEncodingNameMap;
-static TextCodecMap* textCodecMap;
-static bool didExtendTextCodecMaps;
-
-#if ERROR_DISABLED
-
-static inline void checkExistingName(const char*, const char*) { }
-
-#else
-
-static void checkExistingName(const char* alias, const char* atomicName)
-{
- const char* oldAtomicName = textEncodingNameMap->get(alias);
- if (!oldAtomicName)
- return;
- if (oldAtomicName == atomicName)
- return;
- // Keep the warning silent about one case where we know this will happen.
- if (strcmp(alias, "ISO-8859-8-I") == 0
- && strcmp(oldAtomicName, "ISO-8859-8-I") == 0
- && strcasecmp(atomicName, "iso-8859-8") == 0)
- return;
- LOG_ERROR("alias %s maps to %s already, but someone is trying to make it map to %s",
- alias, oldAtomicName, atomicName);
-}
-
-#endif
-
-static void addToTextEncodingNameMap(const char* alias, const char* name)
-{
- ASSERT(strlen(alias) <= maxEncodingNameLength);
- const char* atomicName = textEncodingNameMap->get(name);
- ASSERT(strcmp(alias, name) == 0 || atomicName);
- if (!atomicName)
- atomicName = name;
- checkExistingName(alias, atomicName);
- textEncodingNameMap->add(alias, atomicName);
-}
-
-static void addToTextCodecMap(const char* name, NewTextCodecFunction function, const void* additionalData)
-{
- TextEncoding encoding(name);
- ASSERT(encoding.isValid());
- textCodecMap->add(encoding.name(), TextCodecFactory(function, additionalData));
-}
-
-static void buildBaseTextCodecMaps()
-{
- textCodecMap = new TextCodecMap;
- textEncodingNameMap = new TextEncodingNameMap;
-
- TextCodecLatin1::registerEncodingNames(addToTextEncodingNameMap);
- TextCodecLatin1::registerCodecs(addToTextCodecMap);
-
- TextCodecUTF16::registerEncodingNames(addToTextEncodingNameMap);
- TextCodecUTF16::registerCodecs(addToTextCodecMap);
-
- TextCodecUserDefined::registerEncodingNames(addToTextEncodingNameMap);
- TextCodecUserDefined::registerCodecs(addToTextCodecMap);
-
-#if USE(ICU_UNICODE)
- TextCodecICU::registerBaseEncodingNames(addToTextEncodingNameMap);
- TextCodecICU::registerBaseCodecs(addToTextCodecMap);
-#endif
-}
-
-static void extendTextCodecMaps()
-{
-#if USE(ICU_UNICODE)
- TextCodecICU::registerExtendedEncodingNames(addToTextEncodingNameMap);
- TextCodecICU::registerExtendedCodecs(addToTextCodecMap);
-#endif
-
-#if USE(QT4_UNICODE)
- TextCodecQt::registerEncodingNames(addToTextEncodingNameMap);
- TextCodecQt::registerCodecs(addToTextCodecMap);
-#endif
-
-#if PLATFORM(MAC)
- TextCodecMac::registerEncodingNames(addToTextEncodingNameMap);
- TextCodecMac::registerCodecs(addToTextCodecMap);
-#endif
-}
-
-std::auto_ptr<TextCodec> newTextCodec(const TextEncoding& encoding)
-{
- ASSERT(textCodecMap);
- TextCodecFactory factory = textCodecMap->get(encoding.name());
- ASSERT(factory.function);
- return factory.function(encoding, factory.additionalData);
-}
-
-const char* atomicCanonicalTextEncodingName(const char* name)
-{
- if (!name || !name[0])
- return 0;
- if (!textEncodingNameMap)
- buildBaseTextCodecMaps();
- if (const char* atomicName = textEncodingNameMap->get(name))
- return atomicName;
- if (didExtendTextCodecMaps)
- return 0;
- extendTextCodecMaps();
- didExtendTextCodecMaps = true;
- return textEncodingNameMap->get(name);
-}
-
-const char* atomicCanonicalTextEncodingName(const UChar* characters, size_t length)
-{
- char buffer[maxEncodingNameLength + 1];
- size_t j = 0;
- for (size_t i = 0; i < length; ++i) {
- UChar c = characters[i];
- if (isASCIIAlphanumeric(c)) {
- if (j == maxEncodingNameLength)
- return 0;
- buffer[j++] = c;
- }
- }
- buffer[j] = 0;
- return atomicCanonicalTextEncodingName(buffer);
-}
-
-bool noExtendedTextEncodingNameUsed()
-{
- return !didExtendTextCodecMaps;
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/text/TextEncodingRegistry.h b/WebCore/platform/text/TextEncodingRegistry.h
deleted file mode 100644
index 5ca2039..0000000
--- a/WebCore/platform/text/TextEncodingRegistry.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef TextEncodingRegistry_h
-#define TextEncodingRegistry_h
-
-#include <memory>
-#include <wtf/unicode/Unicode.h>
-
-namespace WebCore {
-
- class TextCodec;
- class TextEncoding;
-
- // Only TextEncoding and TextDecoder should use this function directly.
- // - Use TextDecoder::decode to decode, since it handles BOMs.
- // - Use TextEncoding::decode to decode if you have all the data at once.
- // It's implemented by calling TextDecoder::decode so works just as well.
- // - Use TextEncoding::encode to encode, since it takes care of normalization.
- std::auto_ptr<TextCodec> newTextCodec(const TextEncoding&);
-
- // Only TextEncoding should use this function directly.
- const char* atomicCanonicalTextEncodingName(const char* alias);
- const char* atomicCanonicalTextEncodingName(const UChar* aliasCharacters, size_t aliasLength);
-
- // Only TextEncoding should use this function directly.
- bool noExtendedTextEncodingNameUsed();
-
-}
-
-#endif // TextEncodingRegistry_h
diff --git a/WebCore/platform/text/TextStream.cpp b/WebCore/platform/text/TextStream.cpp
deleted file mode 100644
index 5b7a0c7..0000000
--- a/WebCore/platform/text/TextStream.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (C) 2004, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "TextStream.h"
-
-#include "PlatformString.h"
-#include <wtf/StringExtras.h>
-
-namespace WebCore {
-
-static const size_t printBufferSize = 100; // large enough for any integer or floating point value in string format, including trailing null character
-
-TextStream& TextStream::operator<<(int i)
-{
- char buffer[printBufferSize];
- snprintf(buffer, sizeof(buffer) - 1, "%d", i);
- return *this << buffer;
-}
-
-TextStream& TextStream::operator<<(unsigned i)
-{
- char buffer[printBufferSize];
- snprintf(buffer, sizeof(buffer) - 1, "%u", i);
- return *this << buffer;
-}
-
-TextStream& TextStream::operator<<(long i)
-{
- char buffer[printBufferSize];
- snprintf(buffer, sizeof(buffer) - 1, "%ld", i);
- return *this << buffer;
-}
-
-TextStream& TextStream::operator<<(unsigned long i)
-{
- char buffer[printBufferSize];
- snprintf(buffer, sizeof(buffer) - 1, "%lu", i);
- return *this << buffer;
-}
-
-TextStream& TextStream::operator<<(float f)
-{
- char buffer[printBufferSize];
- snprintf(buffer, sizeof(buffer) - 1, "%.2f", f);
- return *this << buffer;
-}
-
-TextStream& TextStream::operator<<(double d)
-{
- char buffer[printBufferSize];
- snprintf(buffer, sizeof(buffer) - 1, "%.2f", d);
- return *this << buffer;
-}
-
-TextStream& TextStream::operator<<(const char* string)
-{
- size_t stringLength = strlen(string);
- size_t textLength = m_text.size();
- m_text.grow(textLength + stringLength);
- for (size_t i = 0; i < stringLength; ++i)
- m_text[textLength + i] = string[i];
- return *this;
-}
-
-TextStream& TextStream::operator<<(const String& string)
-{
- append(m_text, string);
- return *this;
-}
-
-String TextStream::release()
-{
- return String::adopt(m_text);
-}
-
-#if PLATFORM(WIN_OS) && PLATFORM(X86_64) && COMPILER(MSVC)
-TextStream& TextStream::operator<<(__int64 i)
-{
- char buffer[printBufferSize];
- snprintf(buffer, sizeof(buffer) - 1, "%I64i", i);
- return *this << buffer;
-}
-TextStream& TextStream::operator<<(unsigned __int64 i)
-{
- char buffer[printBufferSize];
- snprintf(buffer, sizeof(buffer) - 1, "%I64u", i);
- return *this << buffer;
-}
-#endif
-
-}
diff --git a/WebCore/platform/text/TextStream.h b/WebCore/platform/text/TextStream.h
deleted file mode 100644
index 6fb3f4b..0000000
--- a/WebCore/platform/text/TextStream.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2004, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef TextStream_h
-#define TextStream_h
-
-#include <wtf/Vector.h>
-#include <wtf/unicode/Unicode.h>
-
-namespace WebCore {
-
-class String;
-
-class TextStream {
-public:
- TextStream& operator<<(int);
- TextStream& operator<<(unsigned);
- TextStream& operator<<(long);
- TextStream& operator<<(unsigned long);
- TextStream& operator<<(float);
- TextStream& operator<<(double);
- TextStream& operator<<(const char*);
- TextStream& operator<<(const String&);
-#if PLATFORM(WIN_OS) && PLATFORM(X86_64) && COMPILER(MSVC)
- TextStream& operator<<(unsigned __int64);
- TextStream& operator<<(__int64);
-#endif
-
- String release();
-
-private:
- Vector<UChar> m_text;
-};
-
-}
-
-#endif
diff --git a/WebCore/platform/text/UnicodeRange.cpp b/WebCore/platform/text/UnicodeRange.cpp
deleted file mode 100644
index 0373441..0000000
--- a/WebCore/platform/text/UnicodeRange.cpp
+++ /dev/null
@@ -1,462 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Computer, Inc.
- *
- * Portions are Copyright (C) 1998 Netscape Communications Corporation.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Alternatively, the contents of this file may be used under the terms
- * of either the Mozilla Public License Version 1.1, found at
- * http://www.mozilla.org/MPL/ (the "MPL") or the GNU General Public
- * License Version 2.0, found at http://www.fsf.org/copyleft/gpl.html
- * (the "GPL"), in which case the provisions of the MPL or the GPL are
- * applicable instead of those above. If you wish to allow use of your
- * version of this file only under the terms of one of those two
- * licenses (the MPL or the GPL) and not to allow others to use your
- * version of this file under the LGPL, indicate your decision by
- * deletingthe provisions above and replace them with the notice and
- * other provisions required by the MPL or the GPL, as the case may be.
- * If you do not delete the provisions above, a recipient may use your
- * version of this file under any of the LGPL, the MPL or the GPL.
- */
-
-#include "config.h"
-#include "UnicodeRange.h"
-
-namespace WebCore {
-
-// This table depends on unicode range definitions.
-// Each item's index must correspond to a unicode range value
-// eg. x-cyrillic = LangGroupTable[cRangeCyrillic]
-static const char* gUnicodeRangeToLangGroupTable[] =
-{
- "x-cyrillic",
- "el",
- "tr",
- "he",
- "ar",
- "x-baltic",
- "th",
- "ko",
- "ja",
- "zh-CN",
- "zh-TW",
- "x-devanagari",
- "x-tamil",
- "x-armn",
- "x-beng",
- "x-cans",
- "x-ethi",
- "x-geor",
- "x-gujr",
- "x-guru",
- "x-khmr",
- "x-mlym"
-};
-
-/**********************************************************************
- * Unicode subranges as defined in unicode 3.0
- * x-western, x-central-euro, tr, x-baltic -> latin
- * 0000 - 036f
- * 1e00 - 1eff
- * 2000 - 206f (general punctuation)
- * 20a0 - 20cf (currency symbols)
- * 2100 - 214f (letterlike symbols)
- * 2150 - 218f (Number Forms)
- * el -> greek
- * 0370 - 03ff
- * 1f00 - 1fff
- * x-cyrillic -> cyrillic
- * 0400 - 04ff
- * he -> hebrew
- * 0590 - 05ff
- * ar -> arabic
- * 0600 - 06ff
- * fb50 - fdff (arabic presentation forms)
- * fe70 - feff (arabic presentation forms b)
- * th - thai
- * 0e00 - 0e7f
- * ko -> korean
- * ac00 - d7af (hangul Syllables)
- * 1100 - 11ff (jamo)
- * 3130 - 318f (hangul compatibility jamo)
- * ja
- * 3040 - 309f (hiragana)
- * 30a0 - 30ff (katakana)
- * zh-CN
- * zh-TW
- *
- * CJK
- * 3100 - 312f (bopomofo)
- * 31a0 - 31bf (bopomofo extended)
- * 3000 - 303f (CJK Symbols and Punctuation)
- * 2e80 - 2eff (CJK radicals supplement)
- * 2f00 - 2fdf (Kangxi Radicals)
- * 2ff0 - 2fff (Ideographic Description Characters)
- * 3190 - 319f (kanbun)
- * 3200 - 32ff (Enclosed CJK letters and Months)
- * 3300 - 33ff (CJK compatibility)
- * 3400 - 4dbf (CJK Unified Ideographs Extension A)
- * 4e00 - 9faf (CJK Unified Ideographs)
- * f900 - fa5f (CJK Compatibility Ideographs)
- * fe30 - fe4f (CJK compatibility Forms)
- * ff00 - ffef (halfwidth and fullwidth forms)
- *
- * Armenian
- * 0530 - 058f
- * Sriac
- * 0700 - 074f
- * Thaana
- * 0780 - 07bf
- * Devanagari
- * 0900 - 097f
- * Bengali
- * 0980 - 09ff
- * Gurmukhi
- * 0a00 - 0a7f
- * Gujarati
- * 0a80 - 0aff
- * Oriya
- * 0b00 - 0b7f
- * Tamil
- * 0b80 - 0bff
- * Telugu
- * 0c00 - 0c7f
- * Kannada
- * 0c80 - 0cff
- * Malayalam
- * 0d00 - 0d7f
- * Sinhala
- * 0d80 - 0def
- * Lao
- * 0e80 - 0eff
- * Tibetan
- * 0f00 - 0fbf
- * Myanmar
- * 1000 - 109f
- * Georgian
- * 10a0 - 10ff
- * Ethiopic
- * 1200 - 137f
- * Cherokee
- * 13a0 - 13ff
- * Canadian Aboriginal Syllabics
- * 1400 - 167f
- * Ogham
- * 1680 - 169f
- * Runic
- * 16a0 - 16ff
- * Khmer
- * 1780 - 17ff
- * Mongolian
- * 1800 - 18af
- * Misc - superscripts and subscripts
- * 2070 - 209f
- * Misc - Combining Diacritical Marks for Symbols
- * 20d0 - 20ff
- * Misc - Arrows
- * 2190 - 21ff
- * Misc - Mathematical Operators
- * 2200 - 22ff
- * Misc - Miscellaneous Technical
- * 2300 - 23ff
- * Misc - Control picture
- * 2400 - 243f
- * Misc - Optical character recognition
- * 2440 - 2450
- * Misc - Enclose Alphanumerics
- * 2460 - 24ff
- * Misc - Box Drawing
- * 2500 - 257f
- * Misc - Block Elements
- * 2580 - 259f
- * Misc - Geometric Shapes
- * 25a0 - 25ff
- * Misc - Miscellaneous Symbols
- * 2600 - 267f
- * Misc - Dingbats
- * 2700 - 27bf
- * Misc - Braille Patterns
- * 2800 - 28ff
- * Yi Syllables
- * a000 - a48f
- * Yi radicals
- * a490 - a4cf
- * Alphabetic Presentation Forms
- * fb00 - fb4f
- * Misc - Combining half Marks
- * fe20 - fe2f
- * Misc - small form variants
- * fe50 - fe6f
- * Misc - Specials
- * fff0 - ffff
- *********************************************************************/
-
-static const unsigned cNumSubTables = 9;
-static const unsigned cSubTableSize = 16;
-
-static const unsigned char gUnicodeSubrangeTable[cNumSubTables][cSubTableSize] =
-{
- { // table for X---
- cRangeTableBase+1, //u0xxx
- cRangeTableBase+2, //u1xxx
- cRangeTableBase+3, //u2xxx
- cRangeSetCJK, //u3xxx
- cRangeSetCJK, //u4xxx
- cRangeSetCJK, //u5xxx
- cRangeSetCJK, //u6xxx
- cRangeSetCJK, //u7xxx
- cRangeSetCJK, //u8xxx
- cRangeSetCJK, //u9xxx
- cRangeTableBase+4, //uaxxx
- cRangeKorean, //ubxxx
- cRangeKorean, //ucxxx
- cRangeTableBase+5, //udxxx
- cRangePrivate, //uexxx
- cRangeTableBase+6 //ufxxx
- },
- { //table for 0X--
- cRangeSetLatin, //u00xx
- cRangeSetLatin, //u01xx
- cRangeSetLatin, //u02xx
- cRangeGreek, //u03xx XXX 0300-036f is in fact cRangeCombiningDiacriticalMarks
- cRangeCyrillic, //u04xx
- cRangeTableBase+7, //u05xx, includes Cyrillic supplement, Hebrew, and Armenian
- cRangeArabic, //u06xx
- cRangeTertiaryTable, //u07xx
- cRangeUnassigned, //u08xx
- cRangeTertiaryTable, //u09xx
- cRangeTertiaryTable, //u0axx
- cRangeTertiaryTable, //u0bxx
- cRangeTertiaryTable, //u0cxx
- cRangeTertiaryTable, //u0dxx
- cRangeTertiaryTable, //u0exx
- cRangeTibetan, //u0fxx
- },
- { //table for 1x--
- cRangeTertiaryTable, //u10xx
- cRangeKorean, //u11xx
- cRangeEthiopic, //u12xx
- cRangeTertiaryTable, //u13xx
- cRangeCanadian, //u14xx
- cRangeCanadian, //u15xx
- cRangeTertiaryTable, //u16xx
- cRangeKhmer, //u17xx
- cRangeMongolian, //u18xx
- cRangeUnassigned, //u19xx
- cRangeUnassigned, //u1axx
- cRangeUnassigned, //u1bxx
- cRangeUnassigned, //u1cxx
- cRangeUnassigned, //u1dxx
- cRangeSetLatin, //u1exx
- cRangeGreek, //u1fxx
- },
- { //table for 2x--
- cRangeSetLatin, //u20xx
- cRangeSetLatin, //u21xx
- cRangeMathOperators, //u22xx
- cRangeMiscTechnical, //u23xx
- cRangeControlOpticalEnclose, //u24xx
- cRangeBoxBlockGeometrics, //u25xx
- cRangeMiscSymbols, //u26xx
- cRangeDingbats, //u27xx
- cRangeBraillePattern, //u28xx
- cRangeUnassigned, //u29xx
- cRangeUnassigned, //u2axx
- cRangeUnassigned, //u2bxx
- cRangeUnassigned, //u2cxx
- cRangeUnassigned, //u2dxx
- cRangeSetCJK, //u2exx
- cRangeSetCJK, //u2fxx
- },
- { //table for ax--
- cRangeYi, //ua0xx
- cRangeYi, //ua1xx
- cRangeYi, //ua2xx
- cRangeYi, //ua3xx
- cRangeYi, //ua4xx
- cRangeUnassigned, //ua5xx
- cRangeUnassigned, //ua6xx
- cRangeUnassigned, //ua7xx
- cRangeUnassigned, //ua8xx
- cRangeUnassigned, //ua9xx
- cRangeUnassigned, //uaaxx
- cRangeUnassigned, //uabxx
- cRangeKorean, //uacxx
- cRangeKorean, //uadxx
- cRangeKorean, //uaexx
- cRangeKorean, //uafxx
- },
- { //table for dx--
- cRangeKorean, //ud0xx
- cRangeKorean, //ud1xx
- cRangeKorean, //ud2xx
- cRangeKorean, //ud3xx
- cRangeKorean, //ud4xx
- cRangeKorean, //ud5xx
- cRangeKorean, //ud6xx
- cRangeKorean, //ud7xx
- cRangeSurrogate, //ud8xx
- cRangeSurrogate, //ud9xx
- cRangeSurrogate, //udaxx
- cRangeSurrogate, //udbxx
- cRangeSurrogate, //udcxx
- cRangeSurrogate, //uddxx
- cRangeSurrogate, //udexx
- cRangeSurrogate, //udfxx
- },
- { // table for fx--
- cRangePrivate, //uf0xx
- cRangePrivate, //uf1xx
- cRangePrivate, //uf2xx
- cRangePrivate, //uf3xx
- cRangePrivate, //uf4xx
- cRangePrivate, //uf5xx
- cRangePrivate, //uf6xx
- cRangePrivate, //uf7xx
- cRangePrivate, //uf8xx
- cRangeSetCJK, //uf9xx
- cRangeSetCJK, //ufaxx
- cRangeArabic, //ufbxx, includes alphabic presentation form
- cRangeArabic, //ufcxx
- cRangeArabic, //ufdxx
- cRangeArabic, //ufexx, includes Combining half marks,
- // CJK compatibility forms,
- // CJK compatibility forms,
- // small form variants
- cRangeTableBase+8, //uffxx, halfwidth and fullwidth forms, includes Specials
- },
- { //table for 0x0500 - 0x05ff
- cRangeCyrillic, //u050x
- cRangeCyrillic, //u051x
- cRangeCyrillic, //u052x
- cRangeArmenian, //u053x
- cRangeArmenian, //u054x
- cRangeArmenian, //u055x
- cRangeArmenian, //u056x
- cRangeArmenian, //u057x
- cRangeArmenian, //u058x
- cRangeHebrew, //u059x
- cRangeHebrew, //u05ax
- cRangeHebrew, //u05bx
- cRangeHebrew, //u05cx
- cRangeHebrew, //u05dx
- cRangeHebrew, //u05ex
- cRangeHebrew, //u05fx
- },
- { //table for 0xff00 - 0xffff
- cRangeSetCJK, //uff0x, fullwidth latin
- cRangeSetCJK, //uff1x, fullwidth latin
- cRangeSetCJK, //uff2x, fullwidth latin
- cRangeSetCJK, //uff3x, fullwidth latin
- cRangeSetCJK, //uff4x, fullwidth latin
- cRangeSetCJK, //uff5x, fullwidth latin
- cRangeSetCJK, //uff6x, halfwidth katakana
- cRangeSetCJK, //uff7x, halfwidth katakana
- cRangeSetCJK, //uff8x, halfwidth katakana
- cRangeSetCJK, //uff9x, halfwidth katakana
- cRangeSetCJK, //uffax, halfwidth hangul jamo
- cRangeSetCJK, //uffbx, halfwidth hangul jamo
- cRangeSetCJK, //uffcx, halfwidth hangul jamo
- cRangeSetCJK, //uffdx, halfwidth hangul jamo
- cRangeSetCJK, //uffex, fullwidth symbols
- cRangeSpecials, //ufffx, Specials
- },
-};
-
-// Most scripts between U+0700 and U+16FF are assigned a chunk of 128 (0x80)
-// code points so that the number of entries in the tertiary range
-// table for that range is obtained by dividing (0x1700 - 0x0700) by 128.
-// Exceptions: Ethiopic, Tibetan, Hangul Jamo and Canadian aboriginal
-// syllabaries take multiple chunks and Ogham and Runic share a single chunk.
-static const unsigned cTertiaryTableSize = ((0x1700 - 0x0700) / 0x80);
-
-static const unsigned char gUnicodeTertiaryRangeTable[cTertiaryTableSize] =
-{ //table for 0x0700 - 0x1600
- cRangeSyriac, //u070x
- cRangeThaana, //u078x
- cRangeUnassigned, //u080x place holder(resolved in the 2ndary tab.)
- cRangeUnassigned, //u088x place holder(resolved in the 2ndary tab.)
- cRangeDevanagari, //u090x
- cRangeBengali, //u098x
- cRangeGurmukhi, //u0a0x
- cRangeGujarati, //u0a8x
- cRangeOriya, //u0b0x
- cRangeTamil, //u0b8x
- cRangeTelugu, //u0c0x
- cRangeKannada, //u0c8x
- cRangeMalayalam, //u0d0x
- cRangeSinhala, //u0d8x
- cRangeThai, //u0e0x
- cRangeLao, //u0e8x
- cRangeTibetan, //u0f0x place holder(resolved in the 2ndary tab.)
- cRangeTibetan, //u0f8x place holder(resolved in the 2ndary tab.)
- cRangeMyanmar, //u100x
- cRangeGeorgian, //u108x
- cRangeKorean, //u110x place holder(resolved in the 2ndary tab.)
- cRangeKorean, //u118x place holder(resolved in the 2ndary tab.)
- cRangeEthiopic, //u120x place holder(resolved in the 2ndary tab.)
- cRangeEthiopic, //u128x place holder(resolved in the 2ndary tab.)
- cRangeEthiopic, //u130x
- cRangeCherokee, //u138x
- cRangeCanadian, //u140x place holder(resolved in the 2ndary tab.)
- cRangeCanadian, //u148x place holder(resolved in the 2ndary tab.)
- cRangeCanadian, //u150x place holder(resolved in the 2ndary tab.)
- cRangeCanadian, //u158x place holder(resolved in the 2ndary tab.)
- cRangeCanadian, //u160x
- cRangeOghamRunic, //u168x this contains two scripts, Ogham & Runic
-};
-
-// A two level index is almost enough for locating a range, with the
-// exception of u03xx and u05xx. Since we don't really care about range for
-// combining diacritical marks in our font application, they are
-// not discriminated further. Future adoption of this method for other use
-// should be aware of this limitation. The implementation can be extended if
-// there is such a need.
-// For Indic, Southeast Asian scripts and some other scripts between
-// U+0700 and U+16FF, it's extended to the third level.
-unsigned int findCharUnicodeRange(UChar32 ch)
-{
- if (ch >= 0xFFFF)
- return 0;
-
- unsigned int range;
-
- //search the first table
- range = gUnicodeSubrangeTable[0][ch >> 12];
-
- if (range < cRangeTableBase)
- // we try to get a specific range
- return range;
-
- // otherwise, we have one more table to look at
- range = gUnicodeSubrangeTable[range - cRangeTableBase][(ch & 0x0f00) >> 8];
- if (range < cRangeTableBase)
- return range;
- if (range < cRangeTertiaryTable)
- return gUnicodeSubrangeTable[range - cRangeTableBase][(ch & 0x00f0) >> 4];
-
- // Yet another table to look at : U+0700 - U+16FF : 128 code point blocks
- return gUnicodeTertiaryRangeTable[(ch - 0x0700) >> 7];
-}
-
-const char* langGroupFromUnicodeRange(unsigned char unicodeRange)
-{
- if (cRangeSpecificItemNum > unicodeRange)
- return gUnicodeRangeToLangGroupTable[unicodeRange];
- return 0;
-}
-
-}
diff --git a/WebCore/platform/text/UnicodeRange.h b/WebCore/platform/text/UnicodeRange.h
deleted file mode 100644
index 7ecf03f..0000000
--- a/WebCore/platform/text/UnicodeRange.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Computer, Inc.
- *
- * Portions are Copyright (C) 1998 Netscape Communications Corporation.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Alternatively, the contents of this file may be used under the terms
- * of either the Mozilla Public License Version 1.1, found at
- * http://www.mozilla.org/MPL/ (the "MPL") or the GNU General Public
- * License Version 2.0, found at http://www.fsf.org/copyleft/gpl.html
- * (the "GPL"), in which case the provisions of the MPL or the GPL are
- * applicable instead of those above. If you wish to allow use of your
- * version of this file only under the terms of one of those two
- * licenses (the MPL or the GPL) and not to allow others to use your
- * version of this file under the LGPL, indicate your decision by
- * deletingthe provisions above and replace them with the notice and
- * other provisions required by the MPL or the GPL, as the case may be.
- * If you do not delete the provisions above, a recipient may use your
- * version of this file under any of the LGPL, the MPL or the GPL.
- */
-
-#ifndef UnicodeRange_H
-#define UnicodeRange_H
-
-#include <wtf/unicode/Unicode.h>
-
-namespace WebCore {
-
-// The following constants define unicode subranges
-// values below cRangeNum must be continuous so that we can map to
-// a lang group directly.
-// All ranges we care about should fit within 32 bits.
-
-// Frequently used range definitions
-const unsigned char cRangeCyrillic = 0;
-const unsigned char cRangeGreek = 1;
-const unsigned char cRangeTurkish = 2;
-const unsigned char cRangeHebrew = 3;
-const unsigned char cRangeArabic = 4;
-const unsigned char cRangeBaltic = 5;
-const unsigned char cRangeThai = 6;
-const unsigned char cRangeKorean = 7;
-const unsigned char cRangeJapanese = 8;
-const unsigned char cRangeSChinese = 9;
-const unsigned char cRangeTChinese = 10;
-const unsigned char cRangeDevanagari = 11;
-const unsigned char cRangeTamil = 12;
-const unsigned char cRangeArmenian = 13;
-const unsigned char cRangeBengali = 14;
-const unsigned char cRangeCanadian = 15;
-const unsigned char cRangeEthiopic = 16;
-const unsigned char cRangeGeorgian = 17;
-const unsigned char cRangeGujarati = 18;
-const unsigned char cRangeGurmukhi = 19;
-const unsigned char cRangeKhmer = 20;
-const unsigned char cRangeMalayalam = 21;
-
-const unsigned char cRangeSpecificItemNum = 22;
-
-//range/rangeSet grow to this place 22-29
-
-const unsigned char cRangeSetStart = 30; // range set definition starts from here
-const unsigned char cRangeSetLatin = 30;
-const unsigned char cRangeSetCJK = 31;
-const unsigned char cRangeSetEnd = 31; // range set definition ends here
-
-// less frequently used range definition
-const unsigned char cRangeSurrogate = 32;
-const unsigned char cRangePrivate = 33;
-const unsigned char cRangeMisc = 34;
-const unsigned char cRangeUnassigned = 35;
-const unsigned char cRangeSyriac = 36;
-const unsigned char cRangeThaana = 37;
-const unsigned char cRangeOriya = 38;
-const unsigned char cRangeTelugu = 39;
-const unsigned char cRangeKannada = 40;
-const unsigned char cRangeSinhala = 41;
-const unsigned char cRangeLao = 42;
-const unsigned char cRangeTibetan = 43;
-const unsigned char cRangeMyanmar = 44;
-const unsigned char cRangeCherokee = 45;
-const unsigned char cRangeOghamRunic = 46;
-const unsigned char cRangeMongolian = 47;
-const unsigned char cRangeMathOperators = 48;
-const unsigned char cRangeMiscTechnical = 49;
-const unsigned char cRangeControlOpticalEnclose = 50;
-const unsigned char cRangeBoxBlockGeometrics = 51;
-const unsigned char cRangeMiscSymbols = 52;
-const unsigned char cRangeDingbats = 53;
-const unsigned char cRangeBraillePattern = 54;
-const unsigned char cRangeYi = 55;
-const unsigned char cRangeCombiningDiacriticalMarks = 56;
-const unsigned char cRangeSpecials = 57;
-
-const unsigned char cRangeTableBase = 128; //values over 127 are reserved for internal use only
-const unsigned char cRangeTertiaryTable = 145; // leave room for 16 subtable
- // indices (cRangeTableBase + 1 ..
- // cRangeTableBase + 16)
-
-
-
-unsigned int findCharUnicodeRange(UChar32 ch);
-const char* langGroupFromUnicodeRange(unsigned char unicodeRange);
-
-}
-
-#endif // UnicodeRange_H
diff --git a/WebCore/platform/text/cf/StringCF.cpp b/WebCore/platform/text/cf/StringCF.cpp
deleted file mode 100644
index 5e12ba9..0000000
--- a/WebCore/platform/text/cf/StringCF.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * Copyright (C) 2006 Apple Computer, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "PlatformString.h"
-
-#if PLATFORM(CF) || (PLATFORM(QT) && PLATFORM(DARWIN))
-
-#include <CoreFoundation/CoreFoundation.h>
-
-namespace WebCore {
-
-String::String(CFStringRef str)
-{
- if (!str)
- return;
-
- CFIndex size = CFStringGetLength(str);
- if (size == 0)
- m_impl = StringImpl::empty();
- else {
- Vector<UChar, 1024> buffer(size);
- CFStringGetCharacters(str, CFRangeMake(0, size), (UniChar*)buffer.data());
- m_impl = StringImpl::create(buffer.data(), size);
- }
-}
-
-CFStringRef String::createCFString() const
-{
- if (!m_impl)
- return CFSTR("");
-
- return m_impl->createCFString();
-}
-
-}
-
-#endif // PLATFORM(CF) || (PLATFORM(QT) && PLATFORM(DARWIN))
diff --git a/WebCore/platform/text/cf/StringImplCF.cpp b/WebCore/platform/text/cf/StringImplCF.cpp
deleted file mode 100644
index ff595a5..0000000
--- a/WebCore/platform/text/cf/StringImplCF.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * Copyright (C) 2006 Apple Computer, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "StringImpl.h"
-
-#if PLATFORM(CF) || (PLATFORM(QT) && PLATFORM(DARWIN))
-
-#include <CoreFoundation/CoreFoundation.h>
-
-namespace WebCore {
-
-CFStringRef StringImpl::createCFString()
-{
- return CFStringCreateWithCharacters(NULL, reinterpret_cast<const UniChar*>(m_data), m_length);
-}
-
-}
-
-#endif // PLATFORM(CF) || (PLATFORM(QT) && PLATFORM(DARWIN))
diff --git a/WebCore/platform/text/gtk/TextBreakIteratorInternalICUGtk.cpp b/WebCore/platform/text/gtk/TextBreakIteratorInternalICUGtk.cpp
deleted file mode 100644
index 9b9bd1f..0000000
--- a/WebCore/platform/text/gtk/TextBreakIteratorInternalICUGtk.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2007 Alp Toker <alp@atoker.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-#include "TextBreakIteratorInternalICU.h"
-
-namespace WebCore {
-
-const char* currentTextBreakLocaleID()
-{
- return "en_us";
-}
-
-}
diff --git a/WebCore/platform/text/mac/CharsetData.h b/WebCore/platform/text/mac/CharsetData.h
deleted file mode 100644
index 458cecb..0000000
--- a/WebCore/platform/text/mac/CharsetData.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-namespace WebCore {
-
- #define kTextEncodingISOLatinThai kCFStringEncodingISOLatinThai
-
- struct CharsetEntry {
- const char* name;
- ::TextEncoding encoding;
- };
-
- extern const CharsetEntry CharsetTable[];
-
-}
diff --git a/WebCore/platform/text/mac/ShapeArabic.c b/WebCore/platform/text/mac/ShapeArabic.c
deleted file mode 100644
index 6dbc008..0000000
--- a/WebCore/platform/text/mac/ShapeArabic.c
+++ /dev/null
@@ -1,555 +0,0 @@
-/*
-******************************************************************************
-*
-* Copyright (C) 2000-2004, International Business Machines
-* Corporation and others. All Rights Reserved.
-* Copyright (C) 2007 Apple Inc. All rights reserved.
-*
-* Permission is hereby granted, free of charge, to any person obtaining a copy of this
-* software and associated documentation files (the "Software"), to deal in the Software
-* without restriction, including without limitation the rights to use, copy, modify,
-* merge, publish, distribute, and/or sell copies of the Software, and to permit persons
-* to whom the Software is furnished to do so, provided that the above copyright notice(s)
-* and this permission notice appear in all copies of the Software and that both the above
-* copyright notice(s) and this permission notice appear in supporting documentation.
-*
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
-* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
-* PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER
-* OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR
-* CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
-* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
-* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-*
-* Except as contained in this notice, the name of a copyright holder shall not be used in
-* advertising or otherwise to promote the sale, use or other dealings in this Software
-* without prior written authorization of the copyright holder.
-*
-******************************************************************************
-*
-* Arabic letter shaping implemented by Ayman Roshdy
-*/
-
-#include "config.h"
-
-#if USE(ATSUI)
-
-#include "ShapeArabic.h"
-
-#include <unicode/utypes.h>
-#include <unicode/uchar.h>
-#include <unicode/ustring.h>
-#include <unicode/ushape.h>
-#include <wtf/Assertions.h>
-
-/*
- * ### TODO in general for letter shaping:
- * - the letter shaping code is UTF-16-unaware; needs update
- * + especially invertBuffer()?!
- * - needs to handle the "Arabic Tail" that is used in some legacy codepages
- * as a glyph fragment of wide-glyph letters
- * + IBM Unicode conversion tables map it to U+200B (ZWSP)
- * + IBM Egypt has proposed to encode the tail in Unicode among Arabic Presentation Forms
- */
-
-/* definitions for Arabic letter shaping ------------------------------------ */
-
-#define IRRELEVANT 4
-#define LAMTYPE 16
-#define ALEFTYPE 32
-#define LINKR 1
-#define LINKL 2
-
-static const UChar IrrelevantPos[] = {
- 0x0, 0x2, 0x4, 0x6,
- 0x8, 0xA, 0xC, 0xE,
-};
-
-static const UChar araLink[178]=
-{
- 1 + 32 + 256 * 0x11,/*0x0622*/
- 1 + 32 + 256 * 0x13,/*0x0623*/
- 1 + 256 * 0x15,/*0x0624*/
- 1 + 32 + 256 * 0x17,/*0x0625*/
- 1 + 2 + 256 * 0x19,/*0x0626*/
- 1 + 32 + 256 * 0x1D,/*0x0627*/
- 1 + 2 + 256 * 0x1F,/*0x0628*/
- 1 + 256 * 0x23,/*0x0629*/
- 1 + 2 + 256 * 0x25,/*0x062A*/
- 1 + 2 + 256 * 0x29,/*0x062B*/
- 1 + 2 + 256 * 0x2D,/*0x062C*/
- 1 + 2 + 256 * 0x31,/*0x062D*/
- 1 + 2 + 256 * 0x35,/*0x062E*/
- 1 + 256 * 0x39,/*0x062F*/
- 1 + 256 * 0x3B,/*0x0630*/
- 1 + 256 * 0x3D,/*0x0631*/
- 1 + 256 * 0x3F,/*0x0632*/
- 1 + 2 + 256 * 0x41,/*0x0633*/
- 1 + 2 + 256 * 0x45,/*0x0634*/
- 1 + 2 + 256 * 0x49,/*0x0635*/
- 1 + 2 + 256 * 0x4D,/*0x0636*/
- 1 + 2 + 256 * 0x51,/*0x0637*/
- 1 + 2 + 256 * 0x55,/*0x0638*/
- 1 + 2 + 256 * 0x59,/*0x0639*/
- 1 + 2 + 256 * 0x5D,/*0x063A*/
- 0, 0, 0, 0, 0, /*0x063B-0x063F*/
- 1 + 2, /*0x0640*/
- 1 + 2 + 256 * 0x61,/*0x0641*/
- 1 + 2 + 256 * 0x65,/*0x0642*/
- 1 + 2 + 256 * 0x69,/*0x0643*/
- 1 + 2 + 16 + 256 * 0x6D,/*0x0644*/
- 1 + 2 + 256 * 0x71,/*0x0645*/
- 1 + 2 + 256 * 0x75,/*0x0646*/
- 1 + 2 + 256 * 0x79,/*0x0647*/
- 1 + 256 * 0x7D,/*0x0648*/
- 1 + 256 * 0x7F,/*0x0649*/
- 1 + 2 + 256 * 0x81,/*0x064A*/
- 4, 4, 4, 4, /*0x064B-0x064E*/
- 4, 4, 4, 4, /*0x064F-0x0652*/
- 4, 4, 4, 0, 0, /*0x0653-0x0657*/
- 0, 0, 0, 0, /*0x0658-0x065B*/
- 1 + 256 * 0x85,/*0x065C*/
- 1 + 256 * 0x87,/*0x065D*/
- 1 + 256 * 0x89,/*0x065E*/
- 1 + 256 * 0x8B,/*0x065F*/
- 0, 0, 0, 0, 0, /*0x0660-0x0664*/
- 0, 0, 0, 0, 0, /*0x0665-0x0669*/
- 0, 0, 0, 0, 0, 0, /*0x066A-0x066F*/
- 4, /*0x0670*/
- 0, /*0x0671*/
- 1 + 32, /*0x0672*/
- 1 + 32, /*0x0673*/
- 0, /*0x0674*/
- 1 + 32, /*0x0675*/
- 1, 1, /*0x0676-0x0677*/
- 1+2, /*0x0678*/
- 1+2 + 256 * 0x16,/*0x0679*/
- 1+2 + 256 * 0x0E,/*0x067A*/
- 1+2 + 256 * 0x02,/*0x067B*/
- 1+2, 1+2, /*0x067C-0x067D*/
- 1+2 + 256 * 0x06,/*0x067E*/
- 1+2 + 256 * 0x12,/*0x067F*/
- 1+2 + 256 * 0x0A,/*0x0680*/
- 1+2, 1+2, /*0x0681-0x0682*/
- 1+2 + 256 * 0x26,/*0x0683*/
- 1+2 + 256 * 0x22,/*0x0684*/
- 1+2, /*0x0685*/
- 1+2 + 256 * 0x2A,/*0x0686*/
- 1+2 + 256 * 0x2E,/*0x0687*/
- 1 + 256 * 0x38,/*0x0688*/
- 1, 1, 1, /*0x0689-0x068B*/
- 1 + 256 * 0x34,/*0x068C*/
- 1 + 256 * 0x32,/*0x068D*/
- 1 + 256 * 0x36,/*0x068E*/
- 1, 1, /*0x068F-0x0690*/
- 1 + 256 * 0x3C,/*0x0691*/
- 1, 1, 1, 1, 1, 1, /*0x0692-0x0697*/
- 1 + 256 * 0x3A,/*0x0698*/
- 1, /*0x0699*/
- 1+2, 1+2, 1+2, 1+2, 1+2, 1+2, /*0x069A-0x069F*/
- 1+2, 1+2, 1+2, 1+2, /*0x06A0-0x06A3*/
- 1+2 + 256 * 0x2E,/*0x06A4*/
- 1+2, /*0x06A5*/
- 1+2 + 256 * 0x1E,/*0x06A6*/
- 1+2, 1+2, /*0x06A7-0x06A8*/
- 1+2 + 256 * 0x3E,/*0x06A9*/
- 1+2, 1+2, 1+2, /*0x06AA-0x06AC*/
- 1+2 + 256 * 0x83,/*0x06AD*/
- 1+2, /*0x06AE*/
- 1+2 + 256 * 0x42,/*0x06AF*/
- 1+2, /*0x06B0*/
- 1+2 + 256 * 0x4A,/*0x06B1*/
- 1+2, /*0x06B2*/
- 1+2 + 256 * 0x46,/*0x06B3*/
- 1+2, 1+2, 1+2, 1+2, 1+2, 1+2, /*0x06B4-0x06B9*/
- 1+2, /*0x06BA*/ // FIXME: Seems to have a final form
- 1+2 + 256 * 0x50,/*0x06BB*/
- 1+2, 1+2, /*0x06BC-0x06BD*/
- 1+2 + 256 * 0x5A,/*0x06BE*/
- 1+2, /*0x06BF*/
- 1, /*0x06C0*/
- 1+2 + 256 * 0x56,/*0x06C1*/
- 1+2, /*0x06C2*/
- 1, 1, /*0x06C3-0x06C4*/
- 1 + 256 * 0x90,/*0x06C5*/
- 1 + 256 * 0x89,/*0x06C6*/
- 1 + 256 * 0x87,/*0x06C7*/
- 1 + 256 * 0x8B,/*0x06C8*/
- 1 + 256 * 0x92,/*0x06C9*/
- 1, /*0x06CA*/
- 1 + 256 * 0x8E,/*0x06CB*/
- 1+2 + 256 * 0xAC,/*0x06CC*/
- 1, /*0x06CD*/
- 1+2, /*0x06CE*/
- 1, /*0x06CF*/
- 1+2 + 256 * 0x94,/*0x06D0*/
- 1+2, /*0x06D1*/
- 1 + 256 * 0x5E,/*0x06D2*/
- 1 + 256 * 0x60 /*0x06D3*/
-};
-
-static const UChar presLink[141]=
-{
- 1 + 2, /*0xFE70*/
- 1 + 2, /*0xFE71*/
- 1 + 2, 0, 1+ 2, 0, 1+ 2, /*0xFE72-0xFE76*/
- 1 + 2, /*0xFE77*/
- 1+ 2, 1 + 2, 1+2, 1 + 2, /*0xFE78-0xFE81*/
- 1+ 2, 1 + 2, 1+2, 1 + 2, /*0xFE82-0xFE85*/
- 0, 0 + 32, 1 + 32, 0 + 32, /*0xFE86-0xFE89*/
- 1 + 32, 0, 1, 0 + 32, /*0xFE8A-0xFE8D*/
- 1 + 32, 0, 2, 1 + 2, /*0xFE8E-0xFE91*/
- 1, 0 + 32, 1 + 32, 0, /*0xFE92-0xFE95*/
- 2, 1 + 2, 1, 0, /*0xFE96-0xFE99*/
- 1, 0, 2, 1 + 2, /*0xFE9A-0xFE9D*/
- 1, 0, 2, 1 + 2, /*0xFE9E-0xFEA1*/
- 1, 0, 2, 1 + 2, /*0xFEA2-0xFEA5*/
- 1, 0, 2, 1 + 2, /*0xFEA6-0xFEA9*/
- 1, 0, 2, 1 + 2, /*0xFEAA-0xFEAD*/
- 1, 0, 1, 0, /*0xFEAE-0xFEB1*/
- 1, 0, 1, 0, /*0xFEB2-0xFEB5*/
- 1, 0, 2, 1+2, /*0xFEB6-0xFEB9*/
- 1, 0, 2, 1+2, /*0xFEBA-0xFEBD*/
- 1, 0, 2, 1+2, /*0xFEBE-0xFEC1*/
- 1, 0, 2, 1+2, /*0xFEC2-0xFEC5*/
- 1, 0, 2, 1+2, /*0xFEC6-0xFEC9*/
- 1, 0, 2, 1+2, /*0xFECA-0xFECD*/
- 1, 0, 2, 1+2, /*0xFECE-0xFED1*/
- 1, 0, 2, 1+2, /*0xFED2-0xFED5*/
- 1, 0, 2, 1+2, /*0xFED6-0xFED9*/
- 1, 0, 2, 1+2, /*0xFEDA-0xFEDD*/
- 1, 0, 2, 1+2, /*0xFEDE-0xFEE1*/
- 1, 0 + 16, 2 + 16, 1 + 2 +16, /*0xFEE2-0xFEE5*/
- 1 + 16, 0, 2, 1+2, /*0xFEE6-0xFEE9*/
- 1, 0, 2, 1+2, /*0xFEEA-0xFEED*/
- 1, 0, 2, 1+2, /*0xFEEE-0xFEF1*/
- 1, 0, 1, 0, /*0xFEF2-0xFEF5*/
- 1, 0, 2, 1+2, /*0xFEF6-0xFEF9*/
- 1, 0, 1, 0, /*0xFEFA-0xFEFD*/
- 1, 0, 1, 0,
- 1
-};
-
-static const UChar convertFEto06[] =
-{
-/***********0******1******2******3******4******5******6******7******8******9******A******B******C******D******E******F***/
-/*FE7*/ 0x64B, 0x64B, 0x64C, 0x64C, 0x64D, 0x64D, 0x64E, 0x64E, 0x64F, 0x64F, 0x650, 0x650, 0x651, 0x651, 0x652, 0x652,
-/*FE8*/ 0x621, 0x622, 0x622, 0x623, 0x623, 0x624, 0x624, 0x625, 0x625, 0x626, 0x626, 0x626, 0x626, 0x627, 0x627, 0x628,
-/*FE9*/ 0x628, 0x628, 0x628, 0x629, 0x629, 0x62A, 0x62A, 0x62A, 0x62A, 0x62B, 0x62B, 0x62B, 0x62B, 0x62C, 0x62C, 0x62C,
-/*FEA*/ 0x62C, 0x62D, 0x62D, 0x62D, 0x62D, 0x62E, 0x62E, 0x62E, 0x62E, 0x62F, 0x62F, 0x630, 0x630, 0x631, 0x631, 0x632,
-/*FEB*/ 0x632, 0x633, 0x633, 0x633, 0x633, 0x634, 0x634, 0x634, 0x634, 0x635, 0x635, 0x635, 0x635, 0x636, 0x636, 0x636,
-/*FEC*/ 0x636, 0x637, 0x637, 0x637, 0x637, 0x638, 0x638, 0x638, 0x638, 0x639, 0x639, 0x639, 0x639, 0x63A, 0x63A, 0x63A,
-/*FED*/ 0x63A, 0x641, 0x641, 0x641, 0x641, 0x642, 0x642, 0x642, 0x642, 0x643, 0x643, 0x643, 0x643, 0x644, 0x644, 0x644,
-/*FEE*/ 0x644, 0x645, 0x645, 0x645, 0x645, 0x646, 0x646, 0x646, 0x646, 0x647, 0x647, 0x647, 0x647, 0x648, 0x648, 0x649,
-/*FEF*/ 0x649, 0x64A, 0x64A, 0x64A, 0x64A, 0x65C, 0x65C, 0x65D, 0x65D, 0x65E, 0x65E, 0x65F, 0x65F
-};
-
-static const UChar shapeTable[4][4][4]=
-{
- { {0,0,0,0}, {0,0,0,0}, {0,1,0,3}, {0,1,0,1} },
- { {0,0,2,2}, {0,0,1,2}, {0,1,1,2}, {0,1,1,3} },
- { {0,0,0,0}, {0,0,0,0}, {0,1,0,3}, {0,1,0,3} },
- { {0,0,1,2}, {0,0,1,2}, {0,1,1,2}, {0,1,1,3} }
-};
-
-/*
- *Name : changeLamAlef
- *Function : Converts the Alef characters into an equivalent
- * LamAlef location in the 0x06xx Range, this is an
- * intermediate stage in the operation of the program
- * later it'll be converted into the 0xFExx LamAlefs
- * in the shaping function.
- */
-static UChar
-changeLamAlef(UChar ch) {
-
- switch(ch) {
- case 0x0622 :
- return(0x065C);
- break;
- case 0x0623 :
- return(0x065D);
- break;
- case 0x0625 :
- return(0x065E);
- break;
- case 0x0627 :
- return(0x065F);
- break;
- default :
- return(0);
- break;
- }
-}
-
-/*
- *Name : specialChar
- *Function : Special Arabic characters need special handling in the shapeUnicode
- * function, this function returns 1 or 2 for these special characters
- */
-static int32_t
-specialChar(UChar ch) {
-
- if( (ch>0x0621 && ch<0x0626)||(ch==0x0627)||(ch>0x062e && ch<0x0633)||
- (ch>0x0647 && ch<0x064a)||(ch==0x0629) ) {
- return (1);
- }
- else
- if( ch>=0x064B && ch<= 0x0652 )
- return (2);
- else
- if( (ch>=0x0653 && ch<= 0x0655) || ch == 0x0670 ||
- (ch>=0xFE70 && ch<= 0xFE7F) )
- return (3);
- else
- return (0);
-}
-
-/*
- *Name : getLink
- *Function : Resolves the link between the characters as
- * Arabic characters have four forms :
- * Isolated, Initial, Middle and Final Form
- */
-static UChar
-getLink(UChar ch) {
-
- if(ch >= 0x0622 && ch <= 0x06D3) {
- return(araLink[ch-0x0622]);
- } else if(ch == 0x200D) {
- return(3);
- } else if(ch >= 0x206D && ch <= 0x206F) {
- return(4);
- } else if(ch >= 0xFE70 && ch <= 0xFEFC) {
- return(presLink[ch-0xFE70]);
- } else {
- return(0);
- }
-}
-
-/*
- *Name : isTashkeelChar
- *Function : Returns 1 for Tashkeel characters else return 0
- */
-static int32_t
-isTashkeelChar(UChar ch) {
-
- if( ch>=0x064B && ch<= 0x0652 )
- return (1);
- else
- return (0);
-}
-
-/*
- *Name : shapeUnicode
- *Function : Converts an Arabic Unicode buffer in 06xx Range into a shaped
- * arabic Unicode buffer in FExx Range
- */
-static int32_t
-shapeUnicode(UChar *dest, int32_t sourceLength,
- int32_t destSize,uint32_t options,
- UErrorCode *pErrorCode,
- int tashkeelFlag) {
-
- int32_t i, iend;
- int32_t prevPos, lastPos,Nx, Nw;
- unsigned int Shape;
- int32_t flag;
- int32_t lamalef_found = 0;
- UChar prevLink = 0, lastLink = 0, currLink, nextLink = 0;
- UChar wLamalef;
-
- /*
- * Converts the input buffer from FExx Range into 06xx Range
- * to make sure that all characters are in the 06xx range
- * even the lamalef is converted to the special region in
- * the 06xx range
- */
- for (i = 0; i < sourceLength; i++) {
- UChar inputChar = dest[i];
- if ( (inputChar >= 0xFE70) && (inputChar <= 0xFEFC)) {
- dest[i] = convertFEto06 [ (inputChar - 0xFE70) ] ;
- }
- }
-
- /* sets the index to the end of the buffer, together with the step point to -1 */
- i = 0;
- iend = sourceLength;
-
- /*
- * This function resolves the link between the characters .
- * Arabic characters have four forms :
- * Isolated Form, Initial Form, Middle Form and Final Form
- */
- currLink = getLink(dest[i]);
-
- prevPos = i;
- lastPos = i;
- Nx = sourceLength + 2, Nw = 0;
-
- while (i != iend) {
- /* If high byte of currLink > 0 then more than one shape */
- if ((currLink & 0xFF00) > 0 || isTashkeelChar(dest[i])) {
- Nw = i + 1;
- while (Nx >= sourceLength) { /* we need to know about next char */
- if(Nw == iend) {
- nextLink = 0;
- Nx = -1;
- } else {
- nextLink = getLink(dest[Nw]);
- if((nextLink & IRRELEVANT) == 0) {
- Nx = Nw;
- } else {
- Nw = Nw + 1;
- }
- }
- }
-
- if ( ((currLink & ALEFTYPE) > 0) && ((lastLink & LAMTYPE) > 0) ) {
- lamalef_found = 1;
- wLamalef = changeLamAlef(dest[i]); /*get from 0x065C-0x065f */
- if ( wLamalef != 0) {
- dest[i] = ' '; /* The default case is to drop the Alef and replace */
- dest[lastPos] =wLamalef; /* it by a space. */
- i=lastPos;
- }
- lastLink = prevLink;
- currLink = getLink(wLamalef);
- }
- /*
- * get the proper shape according to link ability of neighbors
- * and of character; depends on the order of the shapes
- * (isolated, initial, middle, final) in the compatibility area
- */
- flag = specialChar(dest[i]);
-
- Shape = shapeTable[nextLink & (LINKR + LINKL)]
- [lastLink & (LINKR + LINKL)]
- [currLink & (LINKR + LINKL)];
-
- if (flag == 1) {
- Shape = (Shape == 1 || Shape == 3) ? 1 : 0;
- }
- else
- if(flag == 2) {
- if( (lastLink & LINKL) && (nextLink & LINKR) && (tashkeelFlag == 1) &&
- dest[i] != 0x064C && dest[i] != 0x064D ) {
- Shape = 1;
- if( (nextLink&ALEFTYPE) == ALEFTYPE && (lastLink&LAMTYPE) == LAMTYPE )
- Shape = 0;
- }
- else {
- Shape = 0;
- }
- }
-
- if(flag == 2) {
- dest[i] = 0xFE70 + IrrelevantPos[(dest[i] - 0x064B)] + Shape;
- }
- else
- dest[i] = (UChar)((dest[i] < 0x0670 ? 0xFE70 : 0xFB50) + (currLink >> 8) + Shape);
- }
-
- /* move one notch forward */
- if ((currLink & IRRELEVANT) == 0) {
- prevLink = lastLink;
- lastLink = currLink;
- prevPos = lastPos;
- lastPos = i;
- }
-
- i++;
- if (i == Nx) {
- currLink = nextLink;
- Nx = sourceLength + 2;
- }
- else if(i != iend) {
- currLink = getLink(dest[i]);
- }
- }
-
- destSize = sourceLength;
-
- return destSize;
-}
-
-int32_t shapeArabic(const UChar *source, int32_t sourceLength, UChar *dest, int32_t destCapacity, uint32_t options, UErrorCode *pErrorCode) {
- int32_t destLength;
-
- /* usual error checking */
- if(pErrorCode==NULL || U_FAILURE(*pErrorCode)) {
- return 0;
- }
-
- /* make sure that no reserved options values are used; allow dest==NULL only for preflighting */
- if( source==NULL || sourceLength<-1 ||
- (dest==NULL && destCapacity!=0) || destCapacity<0 ||
- options>=U_SHAPE_DIGIT_TYPE_RESERVED ||
- (options&U_SHAPE_DIGITS_MASK)>=U_SHAPE_DIGITS_RESERVED
- ) {
- *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
- return 0;
- }
-
- /* determine the source length */
- if(sourceLength==-1) {
- sourceLength=u_strlen(source);
- }
- if(sourceLength==0) {
- return 0;
- }
-
- /* check that source and destination do not overlap */
- if( dest!=NULL &&
- ((source<=dest && dest<source+sourceLength) ||
- (dest<=source && source<dest+destCapacity))
- ) {
- *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
- return 0;
- }
-
- if((options&U_SHAPE_LETTERS_MASK)!=U_SHAPE_LETTERS_NOOP) {
- int32_t outputSize = sourceLength;
-
- /* calculate destination size */
- /* TODO: do we ever need to do this pure preflighting? */
- ASSERT((options&U_SHAPE_LENGTH_MASK) != U_SHAPE_LENGTH_GROW_SHRINK);
-
- if(outputSize>destCapacity) {
- *pErrorCode=U_BUFFER_OVERFLOW_ERROR;
- return outputSize;
- }
-
- /* Start of Arabic letter shaping part */
- memcpy(dest, source, sourceLength*U_SIZEOF_UCHAR);
-
- ASSERT((options&U_SHAPE_TEXT_DIRECTION_MASK) == U_SHAPE_TEXT_DIRECTION_LOGICAL);
-
- switch(options&U_SHAPE_LETTERS_MASK) {
- case U_SHAPE_LETTERS_SHAPE :
- /* Call the shaping function with tashkeel flag == 1 */
- destLength = shapeUnicode(dest,sourceLength,destCapacity,options,pErrorCode,1);
- break;
- case U_SHAPE_LETTERS_SHAPE_TASHKEEL_ISOLATED :
- /* Call the shaping function with tashkeel flag == 0 */
- destLength = shapeUnicode(dest,sourceLength,destCapacity,options,pErrorCode,0);
- break;
- case U_SHAPE_LETTERS_UNSHAPE :
- ASSERT_NOT_REACHED();
- break;
- default :
- /* will never occur because of validity checks above */
- destLength = 0;
- break;
- }
-
- /* End of Arabic letter shaping part */
- } else
- ASSERT_NOT_REACHED();
-
- ASSERT((options & U_SHAPE_DIGITS_MASK) == U_SHAPE_DIGITS_NOOP);
-
- return sourceLength;
-}
-
-#endif // USE(ATSUI)
diff --git a/WebCore/platform/text/mac/ShapeArabic.h b/WebCore/platform/text/mac/ShapeArabic.h
deleted file mode 100644
index 8aa577d..0000000
--- a/WebCore/platform/text/mac/ShapeArabic.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ShapeArabic_h
-#define ShapeArabic_h
-
-#if USE(ATSUI)
-
-#include <unicode/ushape.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int32_t shapeArabic(const UChar *source, int32_t sourceLength, UChar *dest, int32_t destCapacity, uint32_t options, UErrorCode *pErrorCode);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // USE(ATSUI)
-#endif // ShapeArabic_h
diff --git a/WebCore/platform/text/mac/StringImplMac.mm b/WebCore/platform/text/mac/StringImplMac.mm
deleted file mode 100644
index 2180b94..0000000
--- a/WebCore/platform/text/mac/StringImplMac.mm
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * Copyright (C) 2006 Apple Computer, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "StringImpl.h"
-
-namespace WebCore {
-
-StringImpl::operator NSString *()
-{
- return [NSString stringWithCharacters:m_data length:m_length];
-}
-
-}
diff --git a/WebCore/platform/text/mac/StringMac.mm b/WebCore/platform/text/mac/StringMac.mm
deleted file mode 100644
index 77942ea..0000000
--- a/WebCore/platform/text/mac/StringMac.mm
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * Copyright (C) 2006 Apple Computer, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "PlatformString.h"
-
-namespace WebCore {
-
-String::String(NSString* str)
-{
- if (!str)
- return;
-
- CFIndex size = CFStringGetLength(reinterpret_cast<CFStringRef>(str));
- if (size == 0)
- m_impl = StringImpl::empty();
- else {
- Vector<UChar, 1024> buffer(size);
- CFStringGetCharacters(reinterpret_cast<CFStringRef>(str), CFRangeMake(0, size), buffer.data());
- m_impl = StringImpl::create(buffer.data(), size);
- }
-}
-
-}
diff --git a/WebCore/platform/text/mac/TextBoundaries.mm b/WebCore/platform/text/mac/TextBoundaries.mm
deleted file mode 100644
index ff1dfd2..0000000
--- a/WebCore/platform/text/mac/TextBoundaries.mm
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "TextBoundaries.h"
-
-namespace WebCore {
-
-void findWordBoundary(const UChar* chars, int len, int position, int* start, int* end)
-{
- NSString* string = [[NSString alloc] initWithCharactersNoCopy:const_cast<unichar*>(chars)
- length:len freeWhenDone:NO];
- NSAttributedString* attr = [[NSAttributedString alloc] initWithString:string];
- NSRange range = [attr doubleClickAtIndex:(position >= len) ? len - 1 : position];
- [attr release];
- [string release];
- *start = range.location;
- *end = range.location + range.length;
-}
-
-int findNextWordFromIndex(const UChar* chars, int len, int position, bool forward)
-{
- NSString* string = [[NSString alloc] initWithCharactersNoCopy:const_cast<unichar*>(chars)
- length:len freeWhenDone:NO];
- NSAttributedString* attr = [[NSAttributedString alloc] initWithString:string];
- int result = [attr nextWordFromIndex:position forward:forward];
- [attr release];
- [string release];
- return result;
-}
-
-}
diff --git a/WebCore/platform/text/mac/TextBreakIteratorInternalICUMac.mm b/WebCore/platform/text/mac/TextBreakIteratorInternalICUMac.mm
deleted file mode 100644
index 92983eb..0000000
--- a/WebCore/platform/text/mac/TextBreakIteratorInternalICUMac.mm
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "TextBreakIteratorInternalICU.h"
-
-namespace WebCore {
-
-static const int maxLocaleStringLength = 32;
-
-// This code was swiped from the CarbonCore UnicodeUtilities. One change from that is to use the empty
-// string instead of the "old locale model" as the ultimate fallback. This change is per the UnicodeUtilities
-// engineer.
-static void getTextBreakLocale(char localeStringBuffer[maxLocaleStringLength])
-{
- // Empty string means "root locale", which is what we use if we can't use a pref.
-
- // We get the parts string from AppleTextBreakLocale pref.
- // If that fails then look for the first language in the AppleLanguages pref.
- CFStringRef prefLocaleStr = (CFStringRef)CFPreferencesCopyValue(CFSTR("AppleTextBreakLocale"),
- kCFPreferencesAnyApplication, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
- if (!prefLocaleStr) {
- CFArrayRef appleLangArr = (CFArrayRef)CFPreferencesCopyValue(CFSTR("AppleLanguages"),
- kCFPreferencesAnyApplication, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
- if (appleLangArr) {
- // Take the topmost language. Retain so that we can blindly release later.
- prefLocaleStr = (CFStringRef)CFArrayGetValueAtIndex(appleLangArr, 0);
- if (prefLocaleStr)
- CFRetain(prefLocaleStr);
- CFRelease(appleLangArr);
- }
- }
- if (prefLocaleStr) {
- // Canonicalize pref string in case it is not in the canonical format.
- CFStringRef canonLocaleCFStr = CFLocaleCreateCanonicalLanguageIdentifierFromString(kCFAllocatorDefault, prefLocaleStr);
- if (canonLocaleCFStr) {
- CFStringGetCString(canonLocaleCFStr, localeStringBuffer, maxLocaleStringLength, kCFStringEncodingASCII);
- CFRelease(canonLocaleCFStr);
- }
- CFRelease(prefLocaleStr);
- }
-}
-
-const char* currentTextBreakLocaleID()
-{
- static char localeStringBuffer[maxLocaleStringLength];
- static bool gotTextBreakLocale = false;
- if (!gotTextBreakLocale) {
- getTextBreakLocale(localeStringBuffer);
- gotTextBreakLocale = true;
- }
- return localeStringBuffer;
-}
-
-}
diff --git a/WebCore/platform/text/mac/TextCodecMac.cpp b/WebCore/platform/text/mac/TextCodecMac.cpp
deleted file mode 100644
index ac1f0fb..0000000
--- a/WebCore/platform/text/mac/TextCodecMac.cpp
+++ /dev/null
@@ -1,321 +0,0 @@
-/*
- * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2006 Alexey Proskuryakov <ap@nypop.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "TextCodecMac.h"
-
-#include "CString.h"
-#include "CharacterNames.h"
-#include "CharsetData.h"
-#include "PlatformString.h"
-#include <wtf/Assertions.h>
-
-using std::auto_ptr;
-using std::min;
-
-namespace WebCore {
-
-// We need to keep this because ICU doesn't support some of the encodings that we need:
-// <http://bugs.webkit.org/show_bug.cgi?id=4195>.
-
-const size_t ConversionBufferSize = 16384;
-
-static TECObjectRef cachedConverterTEC;
-static TECTextEncodingID cachedConverterEncoding = invalidEncoding;
-
-void TextCodecMac::registerEncodingNames(EncodingNameRegistrar registrar)
-{
- TECTextEncodingID lastEncoding = invalidEncoding;
- const char* lastName = 0;
-
- for (size_t i = 0; CharsetTable[i].name; ++i) {
- if (CharsetTable[i].encoding != lastEncoding) {
- lastEncoding = CharsetTable[i].encoding;
- lastName = CharsetTable[i].name;
- }
- registrar(CharsetTable[i].name, lastName);
- }
-}
-
-static auto_ptr<TextCodec> newTextCodecMac(const TextEncoding&, const void* additionalData)
-{
- return auto_ptr<TextCodec>(new TextCodecMac(*static_cast<const TECTextEncodingID*>(additionalData)));
-}
-
-void TextCodecMac::registerCodecs(TextCodecRegistrar registrar)
-{
- TECTextEncodingID lastEncoding = invalidEncoding;
-
- for (size_t i = 0; CharsetTable[i].name; ++i)
- if (CharsetTable[i].encoding != lastEncoding) {
- registrar(CharsetTable[i].name, newTextCodecMac, &CharsetTable[i].encoding);
- lastEncoding = CharsetTable[i].encoding;
- }
-}
-
-TextCodecMac::TextCodecMac(TECTextEncodingID encoding)
- : m_encoding(encoding)
- , m_numBufferedBytes(0)
- , m_converterTEC(0)
-{
-}
-
-TextCodecMac::~TextCodecMac()
-{
- releaseTECConverter();
-}
-
-void TextCodecMac::releaseTECConverter() const
-{
- if (m_converterTEC) {
- if (cachedConverterTEC != 0)
- TECDisposeConverter(cachedConverterTEC);
- cachedConverterTEC = m_converterTEC;
- cachedConverterEncoding = m_encoding;
- m_converterTEC = 0;
- }
-}
-
-OSStatus TextCodecMac::createTECConverter() const
-{
- bool cachedEncodingEqual = cachedConverterEncoding == m_encoding;
- cachedConverterEncoding = invalidEncoding;
-
- if (cachedEncodingEqual && cachedConverterTEC) {
- m_converterTEC = cachedConverterTEC;
- cachedConverterTEC = 0;
- TECClearConverterContextInfo(m_converterTEC);
- } else {
- OSStatus status = TECCreateConverter(&m_converterTEC, m_encoding,
- CreateTextEncoding(kTextEncodingUnicodeDefault, kTextEncodingDefaultVariant, kUnicode16BitFormat));
- if (status)
- return status;
-
- TECSetBasicOptions(m_converterTEC, kUnicodeForceASCIIRangeMask);
- }
-
- return noErr;
-}
-
-OSStatus TextCodecMac::decode(const unsigned char* inputBuffer, int inputBufferLength, int& inputLength,
- void *outputBuffer, int outputBufferLength, int& outputLength)
-{
- OSStatus status;
- unsigned long bytesRead = 0;
- unsigned long bytesWritten = 0;
-
- if (m_numBufferedBytes != 0) {
- // Finish converting a partial character that's in our buffer.
-
- // First, fill the partial character buffer with as many bytes as are available.
- ASSERT(m_numBufferedBytes < sizeof(m_bufferedBytes));
- const int spaceInBuffer = sizeof(m_bufferedBytes) - m_numBufferedBytes;
- const int bytesToPutInBuffer = MIN(spaceInBuffer, inputBufferLength);
- ASSERT(bytesToPutInBuffer != 0);
- memcpy(m_bufferedBytes + m_numBufferedBytes, inputBuffer, bytesToPutInBuffer);
-
- // Now, do a conversion on the buffer.
- status = TECConvertText(m_converterTEC, m_bufferedBytes, m_numBufferedBytes + bytesToPutInBuffer, &bytesRead,
- reinterpret_cast<unsigned char*>(outputBuffer), outputBufferLength, &bytesWritten);
- ASSERT(bytesRead <= m_numBufferedBytes + bytesToPutInBuffer);
-
- if (status == kTECPartialCharErr && bytesRead == 0) {
- // Handle the case where the partial character was not converted.
- if (bytesToPutInBuffer >= spaceInBuffer) {
- LOG_ERROR("TECConvertText gave a kTECPartialCharErr but read none of the %zu bytes in the buffer", sizeof(m_bufferedBytes));
- m_numBufferedBytes = 0;
- status = kTECUnmappableElementErr; // should never happen, but use this error code
- } else {
- // Tell the caller we read all the source bytes and keep them in the buffer.
- m_numBufferedBytes += bytesToPutInBuffer;
- bytesRead = bytesToPutInBuffer;
- status = noErr;
- }
- } else {
- // We are done with the partial character buffer.
- // Also, we have read some of the bytes from the main buffer.
- if (bytesRead > m_numBufferedBytes) {
- bytesRead -= m_numBufferedBytes;
- } else {
- LOG_ERROR("TECConvertText accepted some bytes it previously rejected with kTECPartialCharErr");
- bytesRead = 0;
- }
- m_numBufferedBytes = 0;
- if (status == kTECPartialCharErr) {
- // While there may be a partial character problem in the small buffer,
- // we have to try again and not get confused and think there is a partial
- // character problem in the large buffer.
- status = noErr;
- }
- }
- } else {
- status = TECConvertText(m_converterTEC, inputBuffer, inputBufferLength, &bytesRead,
- static_cast<unsigned char*>(outputBuffer), outputBufferLength, &bytesWritten);
- ASSERT(static_cast<int>(bytesRead) <= inputBufferLength);
- }
-
- // Work around bug 3351093, where sometimes we get kTECBufferBelowMinimumSizeErr instead of kTECOutputBufferFullStatus.
- if (status == kTECBufferBelowMinimumSizeErr && bytesWritten != 0)
- status = kTECOutputBufferFullStatus;
-
- inputLength = bytesRead;
- outputLength = bytesWritten;
- return status;
-}
-
-String TextCodecMac::decode(const char* bytes, size_t length, bool flush, bool stopOnError, bool& sawError)
-{
- // Get a converter for the passed-in encoding.
- if (!m_converterTEC && createTECConverter() != noErr)
- return String();
-
- Vector<UChar> result;
-
- const unsigned char* sourcePointer = reinterpret_cast<const unsigned char*>(bytes);
- int sourceLength = length;
- bool bufferWasFull = false;
- UniChar buffer[ConversionBufferSize];
-
- while ((sourceLength || bufferWasFull) && !sawError) {
- int bytesRead = 0;
- int bytesWritten = 0;
- OSStatus status = decode(sourcePointer, sourceLength, bytesRead, buffer, sizeof(buffer), bytesWritten);
- ASSERT(bytesRead <= sourceLength);
- sourcePointer += bytesRead;
- sourceLength -= bytesRead;
-
- switch (status) {
- case noErr:
- case kTECOutputBufferFullStatus:
- break;
- case kTextMalformedInputErr:
- case kTextUndefinedElementErr:
- // FIXME: Put FFFD character into the output string in this case?
- TECClearConverterContextInfo(m_converterTEC);
- if (stopOnError) {
- sawError = true;
- break;
- }
- if (sourceLength) {
- sourcePointer += 1;
- sourceLength -= 1;
- }
- break;
- case kTECPartialCharErr: {
- // Put the partial character into the buffer.
- ASSERT(m_numBufferedBytes == 0);
- const int bufferSize = sizeof(m_numBufferedBytes);
- if (sourceLength < bufferSize) {
- memcpy(m_bufferedBytes, sourcePointer, sourceLength);
- m_numBufferedBytes = sourceLength;
- } else {
- LOG_ERROR("TECConvertText gave a kTECPartialCharErr, but left %u bytes in the buffer", sourceLength);
- }
- sourceLength = 0;
- break;
- }
- default:
- sawError = true;
- return String();
- }
-
- ASSERT(!(bytesWritten % sizeof(UChar)));
- result.append(buffer, bytesWritten / sizeof(UChar));
-
- bufferWasFull = status == kTECOutputBufferFullStatus;
- }
-
- if (flush) {
- unsigned long bytesWritten = 0;
- TECFlushText(m_converterTEC, reinterpret_cast<unsigned char*>(buffer), sizeof(buffer), &bytesWritten);
- ASSERT(!(bytesWritten % sizeof(UChar)));
- result.append(buffer, bytesWritten / sizeof(UChar));
- }
-
- String resultString = String::adopt(result);
-
- // <rdar://problem/3225472>
- // Simplified Chinese pages use the code A3A0 to mean "full-width space".
- // But GB18030 decodes it to U+E5E5, which is correct in theory but not in practice.
- // To work around, just change all occurences of U+E5E5 to U+3000 (ideographic space).
- if (m_encoding == kCFStringEncodingGB_18030_2000)
- resultString.replace(0xE5E5, ideographicSpace);
-
- return resultString;
-}
-
-CString TextCodecMac::encode(const UChar* characters, size_t length, UnencodableHandling handling)
-{
- // FIXME: We should really use TEC here instead of CFString for consistency with the other direction.
-
- // FIXME: Since there's no "force ASCII range" mode in CFString, we change the backslash into a yen sign.
- // Encoding will change the yen sign back into a backslash.
- String copy(characters, length);
- copy.replace('\\', m_backslashAsCurrencySymbol);
- CFStringRef cfs = copy.createCFString();
-
- CFIndex startPos = 0;
- CFIndex charactersLeft = CFStringGetLength(cfs);
- Vector<char> result;
- size_t size = 0;
- UInt8 lossByte = handling == QuestionMarksForUnencodables ? '?' : 0;
- while (charactersLeft > 0) {
- CFRange range = CFRangeMake(startPos, charactersLeft);
- CFIndex bufferLength;
- CFStringGetBytes(cfs, range, m_encoding, lossByte, false, NULL, 0x7FFFFFFF, &bufferLength);
-
- result.grow(size + bufferLength);
- unsigned char* buffer = reinterpret_cast<unsigned char*>(result.data() + size);
- CFIndex charactersConverted = CFStringGetBytes(cfs, range, m_encoding, lossByte, false, buffer, bufferLength, &bufferLength);
- size += bufferLength;
-
- if (charactersConverted != charactersLeft) {
- unsigned badChar = CFStringGetCharacterAtIndex(cfs, startPos + charactersConverted);
- ++charactersConverted;
- if ((badChar & 0xFC00) == 0xD800 && charactersConverted != charactersLeft) { // is high surrogate
- UniChar low = CFStringGetCharacterAtIndex(cfs, startPos + charactersConverted);
- if ((low & 0xFC00) == 0xDC00) { // is low surrogate
- badChar <<= 10;
- badChar += low;
- badChar += 0x10000 - (0xD800 << 10) - 0xDC00;
- ++charactersConverted;
- }
- }
- UnencodableReplacementArray entity;
- int entityLength = getUnencodableReplacement(badChar, handling, entity);
- result.grow(size + entityLength);
- memcpy(result.data() + size, entity, entityLength);
- size += entityLength;
- }
-
- startPos += charactersConverted;
- charactersLeft -= charactersConverted;
- }
- CFRelease(cfs);
- return CString(result.data(), size);
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/text/mac/TextCodecMac.h b/WebCore/platform/text/mac/TextCodecMac.h
deleted file mode 100644
index aee4a97..0000000
--- a/WebCore/platform/text/mac/TextCodecMac.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2006 Alexey Proskuryakov <ap@nypop.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef TextCodecMac_h
-#define TextCodecMac_h
-
-#include "TextCodec.h"
-#include <CoreServices/CoreServices.h>
-
-namespace WebCore {
-
- typedef ::TextEncoding TECTextEncodingID;
- const TECTextEncodingID invalidEncoding = kCFStringEncodingInvalidId;
-
- class TextCodecMac : public TextCodec {
- public:
- static void registerEncodingNames(EncodingNameRegistrar);
- static void registerCodecs(TextCodecRegistrar);
-
- explicit TextCodecMac(TECTextEncodingID);
- virtual ~TextCodecMac();
-
- virtual String decode(const char*, size_t length, bool flush, bool stopOnError, bool& sawError);
- virtual CString encode(const UChar*, size_t length, UnencodableHandling);
-
- private:
- OSStatus decode(const unsigned char* inputBuffer, int inputBufferLength, int& inputLength,
- void* outputBuffer, int outputBufferLength, int& outputLength);
-
- OSStatus createTECConverter() const;
- void releaseTECConverter() const;
-
- TECTextEncodingID m_encoding;
- UChar m_backslashAsCurrencySymbol;
- unsigned m_numBufferedBytes;
- unsigned char m_bufferedBytes[16]; // bigger than any single multi-byte character
- mutable TECObjectRef m_converterTEC;
- };
-
-} // namespace WebCore
-
-#endif // TextCodecMac_h
diff --git a/WebCore/platform/text/mac/character-sets.txt b/WebCore/platform/text/mac/character-sets.txt
deleted file mode 100644
index 475e78e..0000000
--- a/WebCore/platform/text/mac/character-sets.txt
+++ /dev/null
@@ -1,1868 +0,0 @@
-
-===================================================================
-CHARACTER SETS
-
-(last updated 28 January 2005)
-
-These are the official names for character sets that may be used in
-the Internet and may be referred to in Internet documentation. These
-names are expressed in ANSI_X3.4-1968 which is commonly called
-US-ASCII or simply ASCII. The character set most commonly use in the
-Internet and used especially in protocol standards is US-ASCII, this
-is strongly encouraged. The use of the name US-ASCII is also
-encouraged.
-
-The character set names may be up to 40 characters taken from the
-printable characters of US-ASCII. However, no distinction is made
-between use of upper and lower case letters.
-
-The MIBenum value is a unique value for use in MIBs to identify coded
-character sets.
-
-The value space for MIBenum values has been divided into three
-regions. The first region (3-999) consists of coded character sets
-that have been standardized by some standard setting organization.
-This region is intended for standards that do not have subset
-implementations. The second region (1000-1999) is for the Unicode and
-ISO/IEC 10646 coded character sets together with a specification of a
-(set of) sub-repertoires that may occur. The third region (>1999) is
-intended for vendor specific coded character sets.
-
- Assigned MIB enum Numbers
- -------------------------
- 0-2 Reserved
- 3-999 Set By Standards Organizations
- 1000-1999 Unicode / 10646
- 2000-2999 Vendor
-
-The aliases that start with "cs" have been added for use with the
-IANA-CHARSET-MIB as originally defined in RFC3808, and as currently
-maintained by IANA at http://www/iana.org/assignments/ianacharset-mib.
-Note that the ianacharset-mib needs to be kept in sync with this
-registry. These aliases that start with "cs" contain the standard
-numbers along with suggestive names in order to facilitate applications
-that want to display the names in user interfaces. The "cs" stands
-for character set and is provided for applications that need a lower
-case first letter but want to use mixed case thereafter that cannot
-contain any special characters, such as underbar ("_") and dash ("-").
-
-If the character set is from an ISO standard, its cs alias is the ISO
-standard number or name. If the character set is not from an ISO
-standard, but is registered with ISO (IPSJ/ITSCJ is the current ISO
-Registration Authority), the ISO Registry number is specified as
-ISOnnn followed by letters suggestive of the name or standards number
-of the code set. When a national or international standard is
-revised, the year of revision is added to the cs alias of the new
-character set entry in the IANA Registry in order to distinguish the
-revised character set from the original character set.
-
-
-Character Set Reference
-------------- ---------
-
-Name: ANSI_X3.4-1968 [RFC1345,KXS2]
-MIBenum: 3
-Source: ECMA registry
-Alias: iso-ir-6
-Alias: ANSI_X3.4-1986
-Alias: ISO_646.irv:1991
-Alias: ASCII
-Alias: ISO646-US
-Alias: US-ASCII (preferred MIME name)
-Alias: us
-Alias: IBM367
-Alias: cp367
-Alias: csASCII
-
-Name: ISO-10646-UTF-1
-MIBenum: 27
-Source: Universal Transfer Format (1), this is the multibyte
- encoding, that subsets ASCII-7. It does not have byte
- ordering issues.
-Alias: csISO10646UTF1
-
-Name: ISO_646.basic:1983 [RFC1345,KXS2]
-MIBenum: 28
-Source: ECMA registry
-Alias: ref
-Alias: csISO646basic1983
-
-Name: INVARIANT [RFC1345,KXS2]
-MIBenum: 29
-Alias: csINVARIANT
-
-Name: ISO_646.irv:1983 [RFC1345,KXS2]
-MIBenum: 30
-Source: ECMA registry
-Alias: iso-ir-2
-Alias: irv
-Alias: csISO2IntlRefVersion
-
-Name: BS_4730 [RFC1345,KXS2]
-MIBenum: 20
-Source: ECMA registry
-Alias: iso-ir-4
-Alias: ISO646-GB
-Alias: gb
-Alias: uk
-Alias: csISO4UnitedKingdom
-
-Name: NATS-SEFI [RFC1345,KXS2]
-MIBenum: 31
-Source: ECMA registry
-Alias: iso-ir-8-1
-Alias: csNATSSEFI
-
-Name: NATS-SEFI-ADD [RFC1345,KXS2]
-MIBenum: 32
-Source: ECMA registry
-Alias: iso-ir-8-2
-Alias: csNATSSEFIADD
-
-Name: NATS-DANO [RFC1345,KXS2]
-MIBenum: 33
-Source: ECMA registry
-Alias: iso-ir-9-1
-Alias: csNATSDANO
-
-Name: NATS-DANO-ADD [RFC1345,KXS2]
-MIBenum: 34
-Source: ECMA registry
-Alias: iso-ir-9-2
-Alias: csNATSDANOADD
-
-Name: SEN_850200_B [RFC1345,KXS2]
-MIBenum: 35
-Source: ECMA registry
-Alias: iso-ir-10
-Alias: FI
-Alias: ISO646-FI
-Alias: ISO646-SE
-Alias: se
-Alias: csISO10Swedish
-
-Name: SEN_850200_C [RFC1345,KXS2]
-MIBenum: 21
-Source: ECMA registry
-Alias: iso-ir-11
-Alias: ISO646-SE2
-Alias: se2
-Alias: csISO11SwedishForNames
-
-Name: KS_C_5601-1987 [RFC1345,KXS2]
-MIBenum: 36
-Source: ECMA registry
-Alias: iso-ir-149
-Alias: KS_C_5601-1989
-Alias: KSC_5601
-Alias: korean
-Alias: csKSC56011987
-
-Name: ISO-2022-KR (preferred MIME name) [RFC1557,Choi]
-MIBenum: 37
-Source: RFC-1557 (see also KS_C_5601-1987)
-Alias: csISO2022KR
-
-Name: EUC-KR (preferred MIME name) [RFC1557,Choi]
-MIBenum: 38
-Source: RFC-1557 (see also KS_C_5861-1992)
-Alias: csEUCKR
-
-Name: ISO-2022-JP (preferred MIME name) [RFC1468,Murai]
-MIBenum: 39
-Source: RFC-1468 (see also RFC-2237)
-Alias: csISO2022JP
-
-Name: ISO-2022-JP-2 (preferred MIME name) [RFC1554,Ohta]
-MIBenum: 40
-Source: RFC-1554
-Alias: csISO2022JP2
-
-Name: ISO-2022-CN [RFC1922]
-MIBenum: 104
-Source: RFC-1922
-
-Name: ISO-2022-CN-EXT [RFC1922]
-MIBenum: 105
-Source: RFC-1922
-
-Name: JIS_C6220-1969-jp [RFC1345,KXS2]
-MIBenum: 41
-Source: ECMA registry
-Alias: JIS_C6220-1969
-Alias: iso-ir-13
-Alias: katakana
-Alias: x0201-7
-Alias: csISO13JISC6220jp
-
-Name: JIS_C6220-1969-ro [RFC1345,KXS2]
-MIBenum: 42
-Source: ECMA registry
-Alias: iso-ir-14
-Alias: jp
-Alias: ISO646-JP
-Alias: csISO14JISC6220ro
-
-Name: IT [RFC1345,KXS2]
-MIBenum: 22
-Source: ECMA registry
-Alias: iso-ir-15
-Alias: ISO646-IT
-Alias: csISO15Italian
-
-Name: PT [RFC1345,KXS2]
-MIBenum: 43
-Source: ECMA registry
-Alias: iso-ir-16
-Alias: ISO646-PT
-Alias: csISO16Portuguese
-
-Name: ES [RFC1345,KXS2]
-MIBenum: 23
-Source: ECMA registry
-Alias: iso-ir-17
-Alias: ISO646-ES
-Alias: csISO17Spanish
-
-Name: greek7-old [RFC1345,KXS2]
-MIBenum: 44
-Source: ECMA registry
-Alias: iso-ir-18
-Alias: csISO18Greek7Old
-
-Name: latin-greek [RFC1345,KXS2]
-MIBenum: 45
-Source: ECMA registry
-Alias: iso-ir-19
-Alias: csISO19LatinGreek
-
-Name: DIN_66003 [RFC1345,KXS2]
-MIBenum: 24
-Source: ECMA registry
-Alias: iso-ir-21
-Alias: de
-Alias: ISO646-DE
-Alias: csISO21German
-
-Name: NF_Z_62-010_(1973) [RFC1345,KXS2]
-MIBenum: 46
-Source: ECMA registry
-Alias: iso-ir-25
-Alias: ISO646-FR1
-Alias: csISO25French
-
-Name: Latin-greek-1 [RFC1345,KXS2]
-MIBenum: 47
-Source: ECMA registry
-Alias: iso-ir-27
-Alias: csISO27LatinGreek1
-
-Name: ISO_5427 [RFC1345,KXS2]
-MIBenum: 48
-Source: ECMA registry
-Alias: iso-ir-37
-Alias: csISO5427Cyrillic
-
-Name: JIS_C6226-1978 [RFC1345,KXS2]
-MIBenum: 49
-Source: ECMA registry
-Alias: iso-ir-42
-Alias: csISO42JISC62261978
-
-Name: BS_viewdata [RFC1345,KXS2]
-MIBenum: 50
-Source: ECMA registry
-Alias: iso-ir-47
-Alias: csISO47BSViewdata
-
-Name: INIS [RFC1345,KXS2]
-MIBenum: 51
-Source: ECMA registry
-Alias: iso-ir-49
-Alias: csISO49INIS
-
-Name: INIS-8 [RFC1345,KXS2]
-MIBenum: 52
-Source: ECMA registry
-Alias: iso-ir-50
-Alias: csISO50INIS8
-
-Name: INIS-cyrillic [RFC1345,KXS2]
-MIBenum: 53
-Source: ECMA registry
-Alias: iso-ir-51
-Alias: csISO51INISCyrillic
-
-Name: ISO_5427:1981 [RFC1345,KXS2]
-MIBenum: 54
-Source: ECMA registry
-Alias: iso-ir-54
-Alias: ISO5427Cyrillic1981
-
-Name: ISO_5428:1980 [RFC1345,KXS2]
-MIBenum: 55
-Source: ECMA registry
-Alias: iso-ir-55
-Alias: csISO5428Greek
-
-Name: GB_1988-80 [RFC1345,KXS2]
-MIBenum: 56
-Source: ECMA registry
-Alias: iso-ir-57
-Alias: cn
-Alias: ISO646-CN
-Alias: csISO57GB1988
-
-Name: GB_2312-80 [RFC1345,KXS2]
-MIBenum: 57
-Source: ECMA registry
-Alias: iso-ir-58
-Alias: chinese
-Alias: csISO58GB231280
-
-Name: NS_4551-1 [RFC1345,KXS2]
-MIBenum: 25
-Source: ECMA registry
-Alias: iso-ir-60
-Alias: ISO646-NO
-Alias: no
-Alias: csISO60DanishNorwegian
-Alias: csISO60Norwegian1
-
-Name: NS_4551-2 [RFC1345,KXS2]
-MIBenum: 58
-Source: ECMA registry
-Alias: ISO646-NO2
-Alias: iso-ir-61
-Alias: no2
-Alias: csISO61Norwegian2
-
-Name: NF_Z_62-010 [RFC1345,KXS2]
-MIBenum: 26
-Source: ECMA registry
-Alias: iso-ir-69
-Alias: ISO646-FR
-Alias: fr
-Alias: csISO69French
-
-Name: videotex-suppl [RFC1345,KXS2]
-MIBenum: 59
-Source: ECMA registry
-Alias: iso-ir-70
-Alias: csISO70VideotexSupp1
-
-Name: PT2 [RFC1345,KXS2]
-MIBenum: 60
-Source: ECMA registry
-Alias: iso-ir-84
-Alias: ISO646-PT2
-Alias: csISO84Portuguese2
-
-Name: ES2 [RFC1345,KXS2]
-MIBenum: 61
-Source: ECMA registry
-Alias: iso-ir-85
-Alias: ISO646-ES2
-Alias: csISO85Spanish2
-
-Name: MSZ_7795.3 [RFC1345,KXS2]
-MIBenum: 62
-Source: ECMA registry
-Alias: iso-ir-86
-Alias: ISO646-HU
-Alias: hu
-Alias: csISO86Hungarian
-
-Name: JIS_C6226-1983 [RFC1345,KXS2]
-MIBenum: 63
-Source: ECMA registry
-Alias: iso-ir-87
-Alias: x0208
-Alias: JIS_X0208-1983
-Alias: csISO87JISX0208
-
-Name: greek7 [RFC1345,KXS2]
-MIBenum: 64
-Source: ECMA registry
-Alias: iso-ir-88
-Alias: csISO88Greek7
-
-Name: ASMO_449 [RFC1345,KXS2]
-MIBenum: 65
-Source: ECMA registry
-Alias: ISO_9036
-Alias: arabic7
-Alias: iso-ir-89
-Alias: csISO89ASMO449
-
-Name: iso-ir-90 [RFC1345,KXS2]
-MIBenum: 66
-Source: ECMA registry
-Alias: csISO90
-
-Name: JIS_C6229-1984-a [RFC1345,KXS2]
-MIBenum: 67
-Source: ECMA registry
-Alias: iso-ir-91
-Alias: jp-ocr-a
-Alias: csISO91JISC62291984a
-
-Name: JIS_C6229-1984-b [RFC1345,KXS2]
-MIBenum: 68
-Source: ECMA registry
-Alias: iso-ir-92
-Alias: ISO646-JP-OCR-B
-Alias: jp-ocr-b
-Alias: csISO92JISC62991984b
-
-Name: JIS_C6229-1984-b-add [RFC1345,KXS2]
-MIBenum: 69
-Source: ECMA registry
-Alias: iso-ir-93
-Alias: jp-ocr-b-add
-Alias: csISO93JIS62291984badd
-
-Name: JIS_C6229-1984-hand [RFC1345,KXS2]
-MIBenum: 70
-Source: ECMA registry
-Alias: iso-ir-94
-Alias: jp-ocr-hand
-Alias: csISO94JIS62291984hand
-
-Name: JIS_C6229-1984-hand-add [RFC1345,KXS2]
-MIBenum: 71
-Source: ECMA registry
-Alias: iso-ir-95
-Alias: jp-ocr-hand-add
-Alias: csISO95JIS62291984handadd
-
-Name: JIS_C6229-1984-kana [RFC1345,KXS2]
-MIBenum: 72
-Source: ECMA registry
-Alias: iso-ir-96
-Alias: csISO96JISC62291984kana
-
-Name: ISO_2033-1983 [RFC1345,KXS2]
-MIBenum: 73
-Source: ECMA registry
-Alias: iso-ir-98
-Alias: e13b
-Alias: csISO2033
-
-Name: ANSI_X3.110-1983 [RFC1345,KXS2]
-MIBenum: 74
-Source: ECMA registry
-Alias: iso-ir-99
-Alias: CSA_T500-1983
-Alias: NAPLPS
-Alias: csISO99NAPLPS
-
-Name: ISO_8859-1:1987 [RFC1345,KXS2]
-MIBenum: 4
-Source: ECMA registry
-Alias: iso-ir-100
-Alias: ISO_8859-1
-Alias: ISO-8859-1 (preferred MIME name)
-Alias: latin1
-Alias: l1
-Alias: IBM819
-Alias: CP819
-Alias: csISOLatin1
-
-Name: ISO_8859-2:1987 [RFC1345,KXS2]
-MIBenum: 5
-Source: ECMA registry
-Alias: iso-ir-101
-Alias: ISO_8859-2
-Alias: ISO-8859-2 (preferred MIME name)
-Alias: latin2
-Alias: l2
-Alias: csISOLatin2
-
-Name: T.61-7bit [RFC1345,KXS2]
-MIBenum: 75
-Source: ECMA registry
-Alias: iso-ir-102
-Alias: csISO102T617bit
-
-Name: T.61-8bit [RFC1345,KXS2]
-MIBenum: 76
-Alias: T.61
-Source: ECMA registry
-Alias: iso-ir-103
-Alias: csISO103T618bit
-
-Name: ISO_8859-3:1988 [RFC1345,KXS2]
-MIBenum: 6
-Source: ECMA registry
-Alias: iso-ir-109
-Alias: ISO_8859-3
-Alias: ISO-8859-3 (preferred MIME name)
-Alias: latin3
-Alias: l3
-Alias: csISOLatin3
-
-Name: ISO_8859-4:1988 [RFC1345,KXS2]
-MIBenum: 7
-Source: ECMA registry
-Alias: iso-ir-110
-Alias: ISO_8859-4
-Alias: ISO-8859-4 (preferred MIME name)
-Alias: latin4
-Alias: l4
-Alias: csISOLatin4
-
-Name: ECMA-cyrillic
-MIBenum: 77
-Source: ISO registry (formerly ECMA registry)
- http://www.itscj.ipsj.jp/ISO-IR/111.pdf
-Alias: iso-ir-111
-Alias: KOI8-E
-Alias: csISO111ECMACyrillic
-
-Name: CSA_Z243.4-1985-1 [RFC1345,KXS2]
-MIBenum: 78
-Source: ECMA registry
-Alias: iso-ir-121
-Alias: ISO646-CA
-Alias: csa7-1
-Alias: ca
-Alias: csISO121Canadian1
-
-Name: CSA_Z243.4-1985-2 [RFC1345,KXS2]
-MIBenum: 79
-Source: ECMA registry
-Alias: iso-ir-122
-Alias: ISO646-CA2
-Alias: csa7-2
-Alias: csISO122Canadian2
-
-Name: CSA_Z243.4-1985-gr [RFC1345,KXS2]
-MIBenum: 80
-Source: ECMA registry
-Alias: iso-ir-123
-Alias: csISO123CSAZ24341985gr
-
-Name: ISO_8859-6:1987 [RFC1345,KXS2]
-MIBenum: 9
-Source: ECMA registry
-Alias: iso-ir-127
-Alias: ISO_8859-6
-Alias: ISO-8859-6 (preferred MIME name)
-Alias: ECMA-114
-Alias: ASMO-708
-Alias: arabic
-Alias: csISOLatinArabic
-
-Name: ISO_8859-6-E [RFC1556,IANA]
-MIBenum: 81
-Source: RFC1556
-Alias: csISO88596E
-Alias: ISO-8859-6-E (preferred MIME name)
-
-Name: ISO_8859-6-I [RFC1556,IANA]
-MIBenum: 82
-Source: RFC1556
-Alias: csISO88596I
-Alias: ISO-8859-6-I (preferred MIME name)
-
-Name: ISO_8859-7:1987 [RFC1947,RFC1345,KXS2]
-MIBenum: 10
-Source: ECMA registry
-Alias: iso-ir-126
-Alias: ISO_8859-7
-Alias: ISO-8859-7 (preferred MIME name)
-Alias: ELOT_928
-Alias: ECMA-118
-Alias: greek
-Alias: greek8
-Alias: csISOLatinGreek
-
-Name: T.101-G2 [RFC1345,KXS2]
-MIBenum: 83
-Source: ECMA registry
-Alias: iso-ir-128
-Alias: csISO128T101G2
-
-Name: ISO_8859-8:1988 [RFC1345,KXS2]
-MIBenum: 11
-Source: ECMA registry
-Alias: iso-ir-138
-Alias: ISO_8859-8
-Alias: ISO-8859-8 (preferred MIME name)
-Alias: hebrew
-Alias: csISOLatinHebrew
-
-Name: ISO_8859-8-E [RFC1556,Nussbacher]
-MIBenum: 84
-Source: RFC1556
-Alias: csISO88598E
-Alias: ISO-8859-8-E (preferred MIME name)
-
-Name: ISO_8859-8-I [RFC1556,Nussbacher]
-MIBenum: 85
-Source: RFC1556
-Alias: csISO88598I
-Alias: ISO-8859-8-I (preferred MIME name)
-
-Name: CSN_369103 [RFC1345,KXS2]
-MIBenum: 86
-Source: ECMA registry
-Alias: iso-ir-139
-Alias: csISO139CSN369103
-
-Name: JUS_I.B1.002 [RFC1345,KXS2]
-MIBenum: 87
-Source: ECMA registry
-Alias: iso-ir-141
-Alias: ISO646-YU
-Alias: js
-Alias: yu
-Alias: csISO141JUSIB1002
-
-Name: ISO_6937-2-add [RFC1345,KXS2]
-MIBenum: 14
-Source: ECMA registry and ISO 6937-2:1983
-Alias: iso-ir-142
-Alias: csISOTextComm
-
-Name: IEC_P27-1 [RFC1345,KXS2]
-MIBenum: 88
-Source: ECMA registry
-Alias: iso-ir-143
-Alias: csISO143IECP271
-
-Name: ISO_8859-5:1988 [RFC1345,KXS2]
-MIBenum: 8
-Source: ECMA registry
-Alias: iso-ir-144
-Alias: ISO_8859-5
-Alias: ISO-8859-5 (preferred MIME name)
-Alias: cyrillic
-Alias: csISOLatinCyrillic
-
-Name: JUS_I.B1.003-serb [RFC1345,KXS2]
-MIBenum: 89
-Source: ECMA registry
-Alias: iso-ir-146
-Alias: serbian
-Alias: csISO146Serbian
-
-Name: JUS_I.B1.003-mac [RFC1345,KXS2]
-MIBenum: 90
-Source: ECMA registry
-Alias: macedonian
-Alias: iso-ir-147
-Alias: csISO147Macedonian
-
-Name: ISO_8859-9:1989 [RFC1345,KXS2]
-MIBenum: 12
-Source: ECMA registry
-Alias: iso-ir-148
-Alias: ISO_8859-9
-Alias: ISO-8859-9 (preferred MIME name)
-Alias: latin5
-Alias: l5
-Alias: csISOLatin5
-
-Name: greek-ccitt [RFC1345,KXS2]
-MIBenum: 91
-Source: ECMA registry
-Alias: iso-ir-150
-Alias: csISO150
-Alias: csISO150GreekCCITT
-
-Name: NC_NC00-10:81 [RFC1345,KXS2]
-MIBenum: 92
-Source: ECMA registry
-Alias: cuba
-Alias: iso-ir-151
-Alias: ISO646-CU
-Alias: csISO151Cuba
-
-Name: ISO_6937-2-25 [RFC1345,KXS2]
-MIBenum: 93
-Source: ECMA registry
-Alias: iso-ir-152
-Alias: csISO6937Add
-
-Name: GOST_19768-74 [RFC1345,KXS2]
-MIBenum: 94
-Source: ECMA registry
-Alias: ST_SEV_358-88
-Alias: iso-ir-153
-Alias: csISO153GOST1976874
-
-Name: ISO_8859-supp [RFC1345,KXS2]
-MIBenum: 95
-Source: ECMA registry
-Alias: iso-ir-154
-Alias: latin1-2-5
-Alias: csISO8859Supp
-
-Name: ISO_10367-box [RFC1345,KXS2]
-MIBenum: 96
-Source: ECMA registry
-Alias: iso-ir-155
-Alias: csISO10367Box
-
-Name: ISO-8859-10 (preferred MIME name) [RFC1345,KXS2]
-MIBenum: 13
-Source: ECMA registry
-Alias: iso-ir-157
-Alias: l6
-Alias: ISO_8859-10:1992
-Alias: csISOLatin6
-Alias: latin6
-
-Name: latin-lap [RFC1345,KXS2]
-MIBenum: 97
-Source: ECMA registry
-Alias: lap
-Alias: iso-ir-158
-Alias: csISO158Lap
-
-Name: JIS_X0212-1990 [RFC1345,KXS2]
-MIBenum: 98
-Source: ECMA registry
-Alias: x0212
-Alias: iso-ir-159
-Alias: csISO159JISX02121990
-
-Name: DS_2089 [RFC1345,KXS2]
-MIBenum: 99
-Source: Danish Standard, DS 2089, February 1974
-Alias: DS2089
-Alias: ISO646-DK
-Alias: dk
-Alias: csISO646Danish
-
-Name: us-dk [RFC1345,KXS2]
-MIBenum: 100
-Alias: csUSDK
-
-Name: dk-us [RFC1345,KXS2]
-MIBenum: 101
-Alias: csDKUS
-
-Name: JIS_X0201 [RFC1345,KXS2]
-MIBenum: 15
-Source: JIS X 0201-1976. One byte only, this is equivalent to
- JIS/Roman (similar to ASCII) plus eight-bit half-width
- Katakana
-Alias: X0201
-Alias: csHalfWidthKatakana
-
-Name: KSC5636 [RFC1345,KXS2]
-MIBenum: 102
-Alias: ISO646-KR
-Alias: csKSC5636
-
-Name: ISO-10646-UCS-2
-MIBenum: 1000
-Source: the 2-octet Basic Multilingual Plane, aka Unicode
- this needs to specify network byte order: the standard
- does not specify (it is a 16-bit integer space)
-Alias: csUnicode
-
-Name: ISO-10646-UCS-4
-MIBenum: 1001
-Source: the full code space. (same comment about byte order,
- these are 31-bit numbers.
-Alias: csUCS4
-
-Name: DEC-MCS [RFC1345,KXS2]
-MIBenum: 2008
-Source: VAX/VMS User's Manual,
- Order Number: AI-Y517A-TE, April 1986.
-Alias: dec
-Alias: csDECMCS
-
-Name: hp-roman8 [HP-PCL5,RFC1345,KXS2]
-MIBenum: 2004
-Source: LaserJet IIP Printer User's Manual,
- HP part no 33471-90901, Hewlet-Packard, June 1989.
-Alias: roman8
-Alias: r8
-Alias: csHPRoman8
-
-Name: macintosh [RFC1345,KXS2]
-MIBenum: 2027
-Source: The Unicode Standard ver1.0, ISBN 0-201-56788-1, Oct 1991
-Alias: mac
-Alias: csMacintosh
-
-Name: IBM037 [RFC1345,KXS2]
-MIBenum: 2028
-Source: IBM NLS RM Vol2 SE09-8002-01, March 1990
-Alias: cp037
-Alias: ebcdic-cp-us
-Alias: ebcdic-cp-ca
-Alias: ebcdic-cp-wt
-Alias: ebcdic-cp-nl
-Alias: csIBM037
-
-Name: IBM038 [RFC1345,KXS2]
-MIBenum: 2029
-Source: IBM 3174 Character Set Ref, GA27-3831-02, March 1990
-Alias: EBCDIC-INT
-Alias: cp038
-Alias: csIBM038
-
-Name: IBM273 [RFC1345,KXS2]
-MIBenum: 2030
-Source: IBM NLS RM Vol2 SE09-8002-01, March 1990
-Alias: CP273
-Alias: csIBM273
-
-Name: IBM274 [RFC1345,KXS2]
-MIBenum: 2031
-Source: IBM 3174 Character Set Ref, GA27-3831-02, March 1990
-Alias: EBCDIC-BE
-Alias: CP274
-Alias: csIBM274
-
-Name: IBM275 [RFC1345,KXS2]
-MIBenum: 2032
-Source: IBM NLS RM Vol2 SE09-8002-01, March 1990
-Alias: EBCDIC-BR
-Alias: cp275
-Alias: csIBM275
-
-Name: IBM277 [RFC1345,KXS2]
-MIBenum: 2033
-Source: IBM NLS RM Vol2 SE09-8002-01, March 1990
-Alias: EBCDIC-CP-DK
-Alias: EBCDIC-CP-NO
-Alias: csIBM277
-
-Name: IBM278 [RFC1345,KXS2]
-MIBenum: 2034
-Source: IBM NLS RM Vol2 SE09-8002-01, March 1990
-Alias: CP278
-Alias: ebcdic-cp-fi
-Alias: ebcdic-cp-se
-Alias: csIBM278
-
-Name: IBM280 [RFC1345,KXS2]
-MIBenum: 2035
-Source: IBM NLS RM Vol2 SE09-8002-01, March 1990
-Alias: CP280
-Alias: ebcdic-cp-it
-Alias: csIBM280
-
-Name: IBM281 [RFC1345,KXS2]
-MIBenum: 2036
-Source: IBM 3174 Character Set Ref, GA27-3831-02, March 1990
-Alias: EBCDIC-JP-E
-Alias: cp281
-Alias: csIBM281
-
-Name: IBM284 [RFC1345,KXS2]
-MIBenum: 2037
-Source: IBM NLS RM Vol2 SE09-8002-01, March 1990
-Alias: CP284
-Alias: ebcdic-cp-es
-Alias: csIBM284
-
-Name: IBM285 [RFC1345,KXS2]
-MIBenum: 2038
-Source: IBM NLS RM Vol2 SE09-8002-01, March 1990
-Alias: CP285
-Alias: ebcdic-cp-gb
-Alias: csIBM285
-
-Name: IBM290 [RFC1345,KXS2]
-MIBenum: 2039
-Source: IBM 3174 Character Set Ref, GA27-3831-02, March 1990
-Alias: cp290
-Alias: EBCDIC-JP-kana
-Alias: csIBM290
-
-Name: IBM297 [RFC1345,KXS2]
-MIBenum: 2040
-Source: IBM NLS RM Vol2 SE09-8002-01, March 1990
-Alias: cp297
-Alias: ebcdic-cp-fr
-Alias: csIBM297
-
-Name: IBM420 [RFC1345,KXS2]
-MIBenum: 2041
-Source: IBM NLS RM Vol2 SE09-8002-01, March 1990,
- IBM NLS RM p 11-11
-Alias: cp420
-Alias: ebcdic-cp-ar1
-Alias: csIBM420
-
-Name: IBM423 [RFC1345,KXS2]
-MIBenum: 2042
-Source: IBM NLS RM Vol2 SE09-8002-01, March 1990
-Alias: cp423
-Alias: ebcdic-cp-gr
-Alias: csIBM423
-
-Name: IBM424 [RFC1345,KXS2]
-MIBenum: 2043
-Source: IBM NLS RM Vol2 SE09-8002-01, March 1990
-Alias: cp424
-Alias: ebcdic-cp-he
-Alias: csIBM424
-
-Name: IBM437 [RFC1345,KXS2]
-MIBenum: 2011
-Source: IBM NLS RM Vol2 SE09-8002-01, March 1990
-Alias: cp437
-Alias: 437
-Alias: csPC8CodePage437
-
-Name: IBM500 [RFC1345,KXS2]
-MIBenum: 2044
-Source: IBM NLS RM Vol2 SE09-8002-01, March 1990
-Alias: CP500
-Alias: ebcdic-cp-be
-Alias: ebcdic-cp-ch
-Alias: csIBM500
-
-Name: IBM775 [HP-PCL5]
-MIBenum: 2087
-Source: HP PCL 5 Comparison Guide (P/N 5021-0329) pp B-13, 1996
-Alias: cp775
-Alias: csPC775Baltic
-
-Name: IBM850 [RFC1345,KXS2]
-MIBenum: 2009
-Source: IBM NLS RM Vol2 SE09-8002-01, March 1990
-Alias: cp850
-Alias: 850
-Alias: csPC850Multilingual
-
-Name: IBM851 [RFC1345,KXS2]
-MIBenum: 2045
-Source: IBM NLS RM Vol2 SE09-8002-01, March 1990
-Alias: cp851
-Alias: 851
-Alias: csIBM851
-
-Name: IBM852 [RFC1345,KXS2]
-MIBenum: 2010
-Source: IBM NLS RM Vol2 SE09-8002-01, March 1990
-Alias: cp852
-Alias: 852
-Alias: csPCp852
-
-Name: IBM855 [RFC1345,KXS2]
-MIBenum: 2046
-Source: IBM NLS RM Vol2 SE09-8002-01, March 1990
-Alias: cp855
-Alias: 855
-Alias: csIBM855
-
-Name: IBM857 [RFC1345,KXS2]
-MIBenum: 2047
-Source: IBM NLS RM Vol2 SE09-8002-01, March 1990
-Alias: cp857
-Alias: 857
-Alias: csIBM857
-
-Name: IBM860 [RFC1345,KXS2]
-MIBenum: 2048
-Source: IBM NLS RM Vol2 SE09-8002-01, March 1990
-Alias: cp860
-Alias: 860
-Alias: csIBM860
-
-Name: IBM861 [RFC1345,KXS2]
-MIBenum: 2049
-Source: IBM NLS RM Vol2 SE09-8002-01, March 1990
-Alias: cp861
-Alias: 861
-Alias: cp-is
-Alias: csIBM861
-
-Name: IBM862 [RFC1345,KXS2]
-MIBenum: 2013
-Source: IBM NLS RM Vol2 SE09-8002-01, March 1990
-Alias: cp862
-Alias: 862
-Alias: csPC862LatinHebrew
-
-Name: IBM863 [RFC1345,KXS2]
-MIBenum: 2050
-Source: IBM Keyboard layouts and code pages, PN 07G4586 June 1991
-Alias: cp863
-Alias: 863
-Alias: csIBM863
-
-Name: IBM864 [RFC1345,KXS2]
-MIBenum: 2051
-Source: IBM Keyboard layouts and code pages, PN 07G4586 June 1991
-Alias: cp864
-Alias: csIBM864
-
-Name: IBM865 [RFC1345,KXS2]
-MIBenum: 2052
-Source: IBM DOS 3.3 Ref (Abridged), 94X9575 (Feb 1987)
-Alias: cp865
-Alias: 865
-Alias: csIBM865
-
-Name: IBM866 [Pond]
-MIBenum: 2086
-Source: IBM NLDG Volume 2 (SE09-8002-03) August 1994
-Alias: cp866
-Alias: 866
-Alias: csIBM866
-
-Name: IBM868 [RFC1345,KXS2]
-MIBenum: 2053
-Source: IBM NLS RM Vol2 SE09-8002-01, March 1990
-Alias: CP868
-Alias: cp-ar
-Alias: csIBM868
-
-Name: IBM869 [RFC1345,KXS2]
-MIBenum: 2054
-Source: IBM Keyboard layouts and code pages, PN 07G4586 June 1991
-Alias: cp869
-Alias: 869
-Alias: cp-gr
-Alias: csIBM869
-
-Name: IBM870 [RFC1345,KXS2]
-MIBenum: 2055
-Source: IBM NLS RM Vol2 SE09-8002-01, March 1990
-Alias: CP870
-Alias: ebcdic-cp-roece
-Alias: ebcdic-cp-yu
-Alias: csIBM870
-
-Name: IBM871 [RFC1345,KXS2]
-MIBenum: 2056
-Source: IBM NLS RM Vol2 SE09-8002-01, March 1990
-Alias: CP871
-Alias: ebcdic-cp-is
-Alias: csIBM871
-
-Name: IBM880 [RFC1345,KXS2]
-MIBenum: 2057
-Source: IBM NLS RM Vol2 SE09-8002-01, March 1990
-Alias: cp880
-Alias: EBCDIC-Cyrillic
-Alias: csIBM880
-
-Name: IBM891 [RFC1345,KXS2]
-MIBenum: 2058
-Source: IBM NLS RM Vol2 SE09-8002-01, March 1990
-Alias: cp891
-Alias: csIBM891
-
-Name: IBM903 [RFC1345,KXS2]
-MIBenum: 2059
-Source: IBM NLS RM Vol2 SE09-8002-01, March 1990
-Alias: cp903
-Alias: csIBM903
-
-Name: IBM904 [RFC1345,KXS2]
-MIBenum: 2060
-Source: IBM NLS RM Vol2 SE09-8002-01, March 1990
-Alias: cp904
-Alias: 904
-Alias: csIBBM904
-
-Name: IBM905 [RFC1345,KXS2]
-MIBenum: 2061
-Source: IBM 3174 Character Set Ref, GA27-3831-02, March 1990
-Alias: CP905
-Alias: ebcdic-cp-tr
-Alias: csIBM905
-
-Name: IBM918 [RFC1345,KXS2]
-MIBenum: 2062
-Source: IBM NLS RM Vol2 SE09-8002-01, March 1990
-Alias: CP918
-Alias: ebcdic-cp-ar2
-Alias: csIBM918
-
-Name: IBM1026 [RFC1345,KXS2]
-MIBenum: 2063
-Source: IBM NLS RM Vol2 SE09-8002-01, March 1990
-Alias: CP1026
-Alias: csIBM1026
-
-Name: EBCDIC-AT-DE [RFC1345,KXS2]
-MIBenum: 2064
-Source: IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987
-Alias: csIBMEBCDICATDE
-
-Name: EBCDIC-AT-DE-A [RFC1345,KXS2]
-MIBenum: 2065
-Source: IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987
-Alias: csEBCDICATDEA
-
-Name: EBCDIC-CA-FR [RFC1345,KXS2]
-MIBenum: 2066
-Source: IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987
-Alias: csEBCDICCAFR
-
-Name: EBCDIC-DK-NO [RFC1345,KXS2]
-MIBenum: 2067
-Source: IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987
-Alias: csEBCDICDKNO
-
-Name: EBCDIC-DK-NO-A [RFC1345,KXS2]
-MIBenum: 2068
-Source: IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987
-Alias: csEBCDICDKNOA
-
-Name: EBCDIC-FI-SE [RFC1345,KXS2]
-MIBenum: 2069
-Source: IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987
-Alias: csEBCDICFISE
-
-Name: EBCDIC-FI-SE-A [RFC1345,KXS2]
-MIBenum: 2070
-Source: IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987
-Alias: csEBCDICFISEA
-
-Name: EBCDIC-FR [RFC1345,KXS2]
-MIBenum: 2071
-Source: IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987
-Alias: csEBCDICFR
-
-Name: EBCDIC-IT [RFC1345,KXS2]
-MIBenum: 2072
-Source: IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987
-Alias: csEBCDICIT
-
-Name: EBCDIC-PT [RFC1345,KXS2]
-MIBenum: 2073
-Source: IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987
-Alias: csEBCDICPT
-
-Name: EBCDIC-ES [RFC1345,KXS2]
-MIBenum: 2074
-Source: IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987
-Alias: csEBCDICES
-
-Name: EBCDIC-ES-A [RFC1345,KXS2]
-MIBenum: 2075
-Source: IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987
-Alias: csEBCDICESA
-
-Name: EBCDIC-ES-S [RFC1345,KXS2]
-MIBenum: 2076
-Source: IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987
-Alias: csEBCDICESS
-
-Name: EBCDIC-UK [RFC1345,KXS2]
-MIBenum: 2077
-Source: IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987
-Alias: csEBCDICUK
-
-Name: EBCDIC-US [RFC1345,KXS2]
-MIBenum: 2078
-Source: IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987
-Alias: csEBCDICUS
-
-Name: UNKNOWN-8BIT [RFC1428]
-MIBenum: 2079
-Alias: csUnknown8BiT
-
-Name: MNEMONIC [RFC1345,KXS2]
-MIBenum: 2080
-Source: RFC 1345, also known as "mnemonic+ascii+38"
-Alias: csMnemonic
-
-Name: MNEM [RFC1345,KXS2]
-MIBenum: 2081
-Source: RFC 1345, also known as "mnemonic+ascii+8200"
-Alias: csMnem
-
-Name: VISCII [RFC1456]
-MIBenum: 2082
-Source: RFC 1456
-Alias: csVISCII
-
-Name: VIQR [RFC1456]
-MIBenum: 2083
-Source: RFC 1456
-Alias: csVIQR
-
-Name: KOI8-R (preferred MIME name) [RFC1489]
-MIBenum: 2084
-Source: RFC 1489, based on GOST-19768-74, ISO-6937/8,
- INIS-Cyrillic, ISO-5427.
-Alias: csKOI8R
-
-Name: KOI8-U [RFC2319]
-MIBenum: 2088
-Source: RFC 2319
-
-Name: IBM00858
-MIBenum: 2089
-Source: IBM See (http://www.iana.org/assignments/charset-reg/IBM00858) [Mahdi]
-Alias: CCSID00858
-Alias: CP00858
-Alias: PC-Multilingual-850+euro
-
-Name: IBM00924
-MIBenum: 2090
-Source: IBM See (http://www.iana.org/assignments/charset-reg/IBM00924) [Mahdi]
-Alias: CCSID00924
-Alias: CP00924
-Alias: ebcdic-Latin9--euro
-
-Name: IBM01140
-MIBenum: 2091
-Source: IBM See (http://www.iana.org/assignments/charset-reg/IBM01140) [Mahdi]
-Alias: CCSID01140
-Alias: CP01140
-Alias: ebcdic-us-37+euro
-
-Name: IBM01141
-MIBenum: 2092
-Source: IBM See (http://www.iana.org/assignments/charset-reg/IBM01141) [Mahdi]
-Alias: CCSID01141
-Alias: CP01141
-Alias: ebcdic-de-273+euro
-
-Name: IBM01142
-MIBenum: 2093
-Source: IBM See (http://www.iana.org/assignments/charset-reg/IBM01142) [Mahdi]
-Alias: CCSID01142
-Alias: CP01142
-Alias: ebcdic-dk-277+euro
-Alias: ebcdic-no-277+euro
-
-Name: IBM01143
-MIBenum: 2094
-Source: IBM See (http://www.iana.org/assignments/charset-reg/IBM01143) [Mahdi]
-Alias: CCSID01143
-Alias: CP01143
-Alias: ebcdic-fi-278+euro
-Alias: ebcdic-se-278+euro
-
-Name: IBM01144
-MIBenum: 2095
-Source: IBM See (http://www.iana.org/assignments/charset-reg/IBM01144) [Mahdi]
-Alias: CCSID01144
-Alias: CP01144
-Alias: ebcdic-it-280+euro
-
-Name: IBM01145
-MIBenum: 2096
-Source: IBM See (http://www.iana.org/assignments/charset-reg/IBM01145) [Mahdi]
-Alias: CCSID01145
-Alias: CP01145
-Alias: ebcdic-es-284+euro
-
-Name: IBM01146
-MIBenum: 2097
-Source: IBM See (http://www.iana.org/assignments/charset-reg/IBM01146) [Mahdi]
-Alias: CCSID01146
-Alias: CP01146
-Alias: ebcdic-gb-285+euro
-
-Name: IBM01147
-MIBenum: 2098
-Source: IBM See (http://www.iana.org/assignments/charset-reg/IBM01147) [Mahdi]
-Alias: CCSID01147
-Alias: CP01147
-Alias: ebcdic-fr-297+euro
-
-Name: IBM01148
-MIBenum: 2099
-Source: IBM See (http://www.iana.org/assignments/charset-reg/IBM01148) [Mahdi]
-Alias: CCSID01148
-Alias: CP01148
-Alias: ebcdic-international-500+euro
-
-Name: IBM01149
-MIBenum: 2100
-Source: IBM See (http://www.iana.org/assignments/charset-reg/IBM01149) [Mahdi]
-Alias: CCSID01149
-Alias: CP01149
-Alias: ebcdic-is-871+euro
-
-Name: Big5-HKSCS [Yick]
-MIBenum: 2101
-Source: See (http://www.iana.org/assignments/charset-reg/Big5-HKSCS)
-Alias: None
-
-Name: IBM1047 [Robrigado]
-MIBenum: 2102
-Source: IBM1047 (EBCDIC Latin 1/Open Systems)
-http://www-1.ibm.com/servers/eserver/iseries/software/globalization/pdf/cp01047z.pdf
-Alias: IBM-1047
-
-Name: PTCP154 [Uskov]
-MIBenum: 2103
-Source: See (http://www.iana.org/assignments/charset-reg/PTCP154)
-Alias: csPTCP154
-Alias: PT154
-Alias: CP154
-Alias: Cyrillic-Asian
-
-Name: Amiga-1251
-MIBenum: 2104
-Source: See (http://www.amiga.ultranet.ru/Amiga-1251.html)
-Alias: Ami1251
-Alias: Amiga1251
-Alias: Ami-1251
-(Aliases are provided for historical reasons and should not be used)
- [Malyshev]
-
-Name: KOI7-switched
-MIBenum: 2105
-Source: See <http://www.iana.org/assignments/charset-reg/KOI7-switched>
-Aliases: None
-
-Name: UNICODE-1-1 [RFC1641]
-MIBenum: 1010
-Source: RFC 1641
-Alias: csUnicode11
-
-Name: SCSU
-MIBenum: 1011
-Source: SCSU See (http://www.iana.org/assignments/charset-reg/SCSU) [Scherer]
-Alias: None
-
-Name: UTF-7 [RFC2152]
-MIBenum: 1012
-Source: RFC 2152
-Alias: None
-
-Name: UTF-16BE [RFC2781]
-MIBenum: 1013
-Source: RFC 2781
-Alias: None
-
-Name: UTF-16LE [RFC2781]
-MIBenum: 1014
-Source: RFC 2781
-Alias: None
-
-Name: UTF-16 [RFC2781]
-MIBenum: 1015
-Source: RFC 2781
-Alias: None
-
-Name: CESU-8 [Phipps]
-MIBenum: 1016
-Source: <http://www.unicode.org/unicode/reports/tr26>
-Alias: csCESU-8
-
-Name: UTF-32 [Davis]
-MIBenum: 1017
-Source: <http://www.unicode.org/unicode/reports/tr19/>
-Alias: None
-
-Name: UTF-32BE [Davis]
-MIBenum: 1018
-Source: <http://www.unicode.org/unicode/reports/tr19/>
-Alias: None
-
-Name: UTF-32LE [Davis]
-MIBenum: 1019
-Source: <http://www.unicode.org/unicode/reports/tr19/>
-Alias: None
-
-Name: BOCU-1 [Scherer]
-MIBenum: 1020
-Source: http://www.unicode.org/notes/tn6/
-Alias: csBOCU-1
-
-Name: UNICODE-1-1-UTF-7 [RFC1642]
-MIBenum: 103
-Source: RFC 1642
-Alias: csUnicode11UTF7
-
-Name: UTF-8 [RFC3629]
-MIBenum: 106
-Source: RFC 3629
-Alias: None
-
-Name: ISO-8859-13
-MIBenum: 109
-Source: ISO See (http://www.iana.org/assignments/charset-reg/iso-8859-13)[Tumasonis]
-Alias: None
-
-Name: ISO-8859-14
-MIBenum: 110
-Source: ISO See (http://www.iana.org/assignments/charset-reg/iso-8859-14) [Simonsen]
-Alias: iso-ir-199
-Alias: ISO_8859-14:1998
-Alias: ISO_8859-14
-Alias: latin8
-Alias: iso-celtic
-Alias: l8
-
-Name: ISO-8859-15
-MIBenum: 111
-Source: ISO
- Please see: <http://www.iana.org/assignments/charset-reg/ISO-8859-15>
-Alias: ISO_8859-15
-Alias: Latin-9
-
-Name: ISO-8859-16
-MIBenum: 112
-Source: ISO
-Alias: iso-ir-226
-Alias: ISO_8859-16:2001
-Alias: ISO_8859-16
-Alias: latin10
-Alias: l10
-
-Name: GBK
-MIBenum: 113
-Source: Chinese IT Standardization Technical Committee
- Please see: <http://www.iana.org/assignments/charset-reg/GBK>
-Alias: CP936
-Alias: MS936
-Alias: windows-936
-
-Name: GB18030
-MIBenum: 114
-Source: Chinese IT Standardization Technical Committee
- Please see: <http://www.iana.org/assignments/charset-reg/GB18030>
-Alias: None
-
-Name: OSD_EBCDIC_DF04_15
-MIBenum: 115
-Source: Fujitsu-Siemens standard mainframe EBCDIC encoding
- Please see: <http://www.iana.org/assignments/charset-reg/OSD-EBCDIC-DF04-15>
-Alias: None
-
-Name: OSD_EBCDIC_DF03_IRV
-MIBenum: 116
-Source: Fujitsu-Siemens standard mainframe EBCDIC encoding
- Please see: <http://www.iana.org/assignments/charset-reg/OSD-EBCDIC-DF03-IRV>
-Alias: None
-
-Name: OSD_EBCDIC_DF04_1
-MIBenum: 117
-Source: Fujitsu-Siemens standard mainframe EBCDIC encoding
- Please see: <http://www.iana.org/assignments/charset-reg/OSD-EBCDIC-DF04-1>
-Alias: None
-
-Name: JIS_Encoding
-MIBenum: 16
-Source: JIS X 0202-1991. Uses ISO 2022 escape sequences to
- shift code sets as documented in JIS X 0202-1991.
-Alias: csJISEncoding
-
-Name: Shift_JIS (preferred MIME name)
-MIBenum: 17
-Source: This charset is an extension of csHalfWidthKatakana by
- adding graphic characters in JIS X 0208. The CCS's are
- JIS X0201:1997 and JIS X0208:1997. The
- complete definition is shown in Appendix 1 of JIS
- X0208:1997.
- This charset can be used for the top-level media type "text".
-Alias: MS_Kanji
-Alias: csShiftJIS
-
-Name: Extended_UNIX_Code_Packed_Format_for_Japanese
-MIBenum: 18
-Source: Standardized by OSF, UNIX International, and UNIX Systems
- Laboratories Pacific. Uses ISO 2022 rules to select
- code set 0: US-ASCII (a single 7-bit byte set)
- code set 1: JIS X0208-1990 (a double 8-bit byte set)
- restricted to A0-FF in both bytes
- code set 2: Half Width Katakana (a single 7-bit byte set)
- requiring SS2 as the character prefix
- code set 3: JIS X0212-1990 (a double 7-bit byte set)
- restricted to A0-FF in both bytes
- requiring SS3 as the character prefix
-Alias: csEUCPkdFmtJapanese
-Alias: EUC-JP (preferred MIME name)
-
-Name: Extended_UNIX_Code_Fixed_Width_for_Japanese
-MIBenum: 19
-Source: Used in Japan. Each character is 2 octets.
- code set 0: US-ASCII (a single 7-bit byte set)
- 1st byte = 00
- 2nd byte = 20-7E
- code set 1: JIS X0208-1990 (a double 7-bit byte set)
- restricted to A0-FF in both bytes
- code set 2: Half Width Katakana (a single 7-bit byte set)
- 1st byte = 00
- 2nd byte = A0-FF
- code set 3: JIS X0212-1990 (a double 7-bit byte set)
- restricted to A0-FF in
- the first byte
- and 21-7E in the second byte
-Alias: csEUCFixWidJapanese
-
-Name: ISO-10646-UCS-Basic
-MIBenum: 1002
-Source: ASCII subset of Unicode. Basic Latin = collection 1
- See ISO 10646, Appendix A
-Alias: csUnicodeASCII
-
-Name: ISO-10646-Unicode-Latin1
-MIBenum: 1003
-Source: ISO Latin-1 subset of Unicode. Basic Latin and Latin-1
- Supplement = collections 1 and 2. See ISO 10646,
- Appendix A. See RFC 1815.
-Alias: csUnicodeLatin1
-Alias: ISO-10646
-
-Name: ISO-10646-J-1
-Source: ISO 10646 Japanese, see RFC 1815.
-
-Name: ISO-Unicode-IBM-1261
-MIBenum: 1005
-Source: IBM Latin-2, -3, -5, Extended Presentation Set, GCSGID: 1261
-Alias: csUnicodeIBM1261
-
-Name: ISO-Unicode-IBM-1268
-MIBenum: 1006
-Source: IBM Latin-4 Extended Presentation Set, GCSGID: 1268
-Alias: csUnicodeIBM1268
-
-Name: ISO-Unicode-IBM-1276
-MIBenum: 1007
-Source: IBM Cyrillic Greek Extended Presentation Set, GCSGID: 1276
-Alias: csUnicodeIBM1276
-
-Name: ISO-Unicode-IBM-1264
-MIBenum: 1008
-Source: IBM Arabic Presentation Set, GCSGID: 1264
-Alias: csUnicodeIBM1264
-
-Name: ISO-Unicode-IBM-1265
-MIBenum: 1009
-Source: IBM Hebrew Presentation Set, GCSGID: 1265
-Alias: csUnicodeIBM1265
-
-Name: ISO-8859-1-Windows-3.0-Latin-1 [HP-PCL5]
-MIBenum: 2000
-Source: Extended ISO 8859-1 Latin-1 for Windows 3.0.
- PCL Symbol Set id: 9U
-Alias: csWindows30Latin1
-
-Name: ISO-8859-1-Windows-3.1-Latin-1 [HP-PCL5]
-MIBenum: 2001
-Source: Extended ISO 8859-1 Latin-1 for Windows 3.1.
- PCL Symbol Set id: 19U
-Alias: csWindows31Latin1
-
-Name: ISO-8859-2-Windows-Latin-2 [HP-PCL5]
-MIBenum: 2002
-Source: Extended ISO 8859-2. Latin-2 for Windows 3.1.
- PCL Symbol Set id: 9E
-Alias: csWindows31Latin2
-
-Name: ISO-8859-9-Windows-Latin-5 [HP-PCL5]
-MIBenum: 2003
-Source: Extended ISO 8859-9. Latin-5 for Windows 3.1
- PCL Symbol Set id: 5T
-Alias: csWindows31Latin5
-
-Name: Adobe-Standard-Encoding [Adobe]
-MIBenum: 2005
-Source: PostScript Language Reference Manual
- PCL Symbol Set id: 10J
-Alias: csAdobeStandardEncoding
-
-Name: Ventura-US [HP-PCL5]
-MIBenum: 2006
-Source: Ventura US. ASCII plus characters typically used in
- publishing, like pilcrow, copyright, registered, trade mark,
- section, dagger, and double dagger in the range A0 (hex)
- to FF (hex).
- PCL Symbol Set id: 14J
-Alias: csVenturaUS
-
-Name: Ventura-International [HP-PCL5]
-MIBenum: 2007
-Source: Ventura International. ASCII plus coded characters similar
- to Roman8.
- PCL Symbol Set id: 13J
-Alias: csVenturaInternational
-
-Name: PC8-Danish-Norwegian [HP-PCL5]
-MIBenum: 2012
-Source: PC Danish Norwegian
- 8-bit PC set for Danish Norwegian
- PCL Symbol Set id: 11U
-Alias: csPC8DanishNorwegian
-
-Name: PC8-Turkish [HP-PCL5]
-MIBenum: 2014
-Source: PC Latin Turkish. PCL Symbol Set id: 9T
-Alias: csPC8Turkish
-
-Name: IBM-Symbols [IBM-CIDT]
-MIBenum: 2015
-Source: Presentation Set, CPGID: 259
-Alias: csIBMSymbols
-
-Name: IBM-Thai [IBM-CIDT]
-MIBenum: 2016
-Source: Presentation Set, CPGID: 838
-Alias: csIBMThai
-
-Name: HP-Legal [HP-PCL5]
-MIBenum: 2017
-Source: PCL 5 Comparison Guide, Hewlett-Packard,
- HP part number 5961-0510, October 1992
- PCL Symbol Set id: 1U
-Alias: csHPLegal
-
-Name: HP-Pi-font [HP-PCL5]
-MIBenum: 2018
-Source: PCL 5 Comparison Guide, Hewlett-Packard,
- HP part number 5961-0510, October 1992
- PCL Symbol Set id: 15U
-Alias: csHPPiFont
-
-Name: HP-Math8 [HP-PCL5]
-MIBenum: 2019
-Source: PCL 5 Comparison Guide, Hewlett-Packard,
- HP part number 5961-0510, October 1992
- PCL Symbol Set id: 8M
-Alias: csHPMath8
-
-Name: Adobe-Symbol-Encoding [Adobe]
-MIBenum: 2020
-Source: PostScript Language Reference Manual
- PCL Symbol Set id: 5M
-Alias: csHPPSMath
-
-Name: HP-DeskTop [HP-PCL5]
-MIBenum: 2021
-Source: PCL 5 Comparison Guide, Hewlett-Packard,
- HP part number 5961-0510, October 1992
- PCL Symbol Set id: 7J
-Alias: csHPDesktop
-
-Name: Ventura-Math [HP-PCL5]
-MIBenum: 2022
-Source: PCL 5 Comparison Guide, Hewlett-Packard,
- HP part number 5961-0510, October 1992
- PCL Symbol Set id: 6M
-Alias: csVenturaMath
-
-Name: Microsoft-Publishing [HP-PCL5]
-MIBenum: 2023
-Source: PCL 5 Comparison Guide, Hewlett-Packard,
- HP part number 5961-0510, October 1992
- PCL Symbol Set id: 6J
-Alias: csMicrosoftPublishing
-
-Name: Windows-31J
-MIBenum: 2024
-Source: Windows Japanese. A further extension of Shift_JIS
- to include NEC special characters (Row 13), NEC
- selection of IBM extensions (Rows 89 to 92), and IBM
- extensions (Rows 115 to 119). The CCS's are
- JIS X0201:1997, JIS X0208:1997, and these extensions.
- This charset can be used for the top-level media type "text",
- but it is of limited or specialized use (see RFC2278).
- PCL Symbol Set id: 19K
-Alias: csWindows31J
-
-Name: GB2312 (preferred MIME name)
-MIBenum: 2025
-Source: Chinese for People's Republic of China (PRC) mixed one byte,
- two byte set:
- 20-7E = one byte ASCII
- A1-FE = two byte PRC Kanji
- See GB 2312-80
- PCL Symbol Set Id: 18C
-Alias: csGB2312
-
-Name: Big5 (preferred MIME name)
-MIBenum: 2026
-Source: Chinese for Taiwan Multi-byte set.
- PCL Symbol Set Id: 18T
-Alias: csBig5
-
-Name: windows-1250
-MIBenum: 2250
-Source: Microsoft (http://www.iana.org/assignments/charset-reg/windows-1250) [Lazhintseva]
-Alias: None
-
-Name: windows-1251
-MIBenum: 2251
-Source: Microsoft (http://www.iana.org/assignments/charset-reg/windows-1251) [Lazhintseva]
-Alias: None
-
-Name: windows-1252
-MIBenum: 2252
-Source: Microsoft (http://www.iana.org/assignments/charset-reg/windows-1252) [Wendt]
-Alias: None
-
-Name: windows-1253
-MIBenum: 2253
-Source: Microsoft (http://www.iana.org/assignments/charset-reg/windows-1253) [Lazhintseva]
-Alias: None
-
-Name: windows-1254
-MIBenum: 2254
-Source: Microsoft (http://www.iana.org/assignments/charset-reg/windows-1254) [Lazhintseva]
-Alias: None
-
-Name: windows-1255
-MIBenum: 2255
-Source: Microsoft (http://www.iana.org/assignments/charset-reg/windows-1255) [Lazhintseva]
-Alias: None
-
-Name: windows-1256
-MIBenum: 2256
-Source: Microsoft (http://www.iana.org/assignments/charset-reg/windows-1256) [Lazhintseva]
-Alias: None
-
-Name: windows-1257
-MIBenum: 2257
-Source: Microsoft (http://www.iana.org/assignments/charset-reg/windows-1257) [Lazhintseva]
-Alias: None
-
-Name: windows-1258
-MIBenum: 2258
-Source: Microsoft (http://www.iana.org/assignments/charset-reg/windows-1258) [Lazhintseva]
-Alias: None
-
-Name: TIS-620
-MIBenum: 2259
-Source: Thai Industrial Standards Institute (TISI) [Tantsetthi]
-
-Name: HZ-GB-2312
-MIBenum: 2085
-Source: RFC 1842, RFC 1843 [RFC1842, RFC1843]
-
-
-REFERENCES
-----------
-
-[RFC1345] Simonsen, K., "Character Mnemonics & Character Sets",
- RFC 1345, Rationel Almen Planlaegning, Rationel Almen
- Planlaegning, June 1992.
-
-[RFC1428] Vaudreuil, G., "Transition of Internet Mail from
- Just-Send-8 to 8bit-SMTP/MIME", RFC1428, CNRI, February
- 1993.
-
-[RFC1456] Vietnamese Standardization Working Group, "Conventions for
- Encoding the Vietnamese Language VISCII: VIetnamese
- Standard Code for Information Interchange VIQR: VIetnamese
- Quoted-Readable Specification Revision 1.1", RFC 1456, May
- 1993.
-
-[RFC1468] Murai, J., Crispin, M., and E. van der Poel, "Japanese
- Character Encoding for Internet Messages", RFC 1468,
- Keio University, Panda Programming, June 1993.
-
-[RFC1489] Chernov, A., "Registration of a Cyrillic Character Set",
- RFC1489, RELCOM Development Team, July 1993.
-
-[RFC1554] Ohta, M., and K. Handa, "ISO-2022-JP-2: Multilingual
- Extension of ISO-2022-JP", RFC1554, Tokyo Institute of
- Technology, ETL, December 1993.
-
-[RFC1556] Nussbacher, H., "Handling of Bi-directional Texts in MIME",
- RFC1556, Israeli Inter-University, December 1993.
-
-[RFC1557] Choi, U., Chon, K., and H. Park, "Korean Character Encoding
- for Internet Messages", KAIST, Solvit Chosun Media,
- December 1993.
-
-[RFC1641] Goldsmith, D., and M. Davis, "Using Unicode with MIME",
- RFC1641, Taligent, Inc., July 1994.
-
-[RFC1642] Goldsmith, D., and M. Davis, "UTF-7", RFC1642, Taligent,
- Inc., July 1994.
-
-[RFC1815] Ohta, M., "Character Sets ISO-10646 and ISO-10646-J-1",
- RFC 1815, Tokyo Institute of Technology, July 1995.
-
-
-[Adobe] Adobe Systems Incorporated, PostScript Language Reference
- Manual, second edition, Addison-Wesley Publishing Company,
- Inc., 1990.
-
-[ECMA Registry] ISO-IR: International Register of Escape Sequences
- http://www.itscj.ipsj.or.jp/ISO-IE/ Note: The current
- registration authority is IPSJ/ITSCJ, Japan.
-
-[HP-PCL5] Hewlett-Packard Company, "HP PCL 5 Comparison Guide",
- (P/N 5021-0329) pp B-13, 1996.
-
-[IBM-CIDT] IBM Corporation, "ABOUT TYPE: IBM's Technical Reference
- for Core Interchange Digitized Type", Publication number
- S544-3708-01
-
-[RFC1842] Wei, Y., J. Li, and Y. Jiang, "ASCII Printable
- Characters-Based Chinese Character Encoding for Internet
- Messages", RFC 1842, Harvard University, Rice University,
- University of Maryland, August 1995.
-
-[RFC1843] Lee, F., "HZ - A Data Format for Exchanging Files of
- Arbitrarily Mixed Chinese and ASCII Characters", RFC 1843,
- Stanford University, August 1995.
-
-[RFC2152] Goldsmith, D., M. Davis, "UTF-7: A Mail-Safe Transformation
- Format of Unicode", RFC 2152, Apple Computer, Inc.,
- Taligent Inc., May 1997.
-
-[RFC2279] Yergeau, F., "UTF-8, A Transformation Format of ISO 10646",
- RFC 2279, Alis Technologies, January, 1998.
-
-[RFC2781] Hoffman, P., Yergeau, F., "UTF-16, an encoding of ISO 10646",
- RFC 2781, February 2000.
-
-[RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 10646",
- RFC3629, November 2003.
-
-PEOPLE
-------
-
-[KXS2] Keld Simonsen <Keld.Simonsen@dkuug.dk>
-
-[Choi] Woohyong Choi <whchoi@cosmos.kaist.ac.kr>
-
-[Davis] Mark Davis, <mark@unicode.org>, April 2002.
-
-[Lazhintseva] Katya Lazhintseva, <katyal@MICROSOFT.com>, May 1996.
-
-[Mahdi] Tamer Mahdi, <tamer@ca.ibm.com>, August 2000.
-
-[Malyshev] Michael Malyshev, <michael_malyshev@mail.ru>, January 2004
-
-[Murai] Jun Murai <jun@wide.ad.jp>
-
-[Nussbacher] Hank Nussbacher, <hank@vm.tau.ac.il>
-
-[Ohta] Masataka Ohta, <mohta@cc.titech.ac.jp>, July 1995.
-
-[Phipps] Toby Phipps, <tphipps@peoplesoft.com>, March 2002.
-
-[Pond] Rick Pond, <rickpond@vnet.ibm.com>, March 1997.
-
-[Robrigado] Reuel Robrigado, <reuelr@ca.ibm.com>, September 2002.
-
-[Scherer] Markus Scherer, <markus.scherer@jtcsv.com>, August 2000,
- September 2002.
-
-[Simonsen] Keld Simonsen, <Keld.Simonsen@rap.dk>, August 2000.
-
-[Tantsetthi] Trin Tantsetthi, <trin@mozart.inet.co.th>, September 1998.
-
-[Tumasonis] Vladas Tumasonis, <vladas.tumasonis@maf.vu.lt>, August 2000.
-
-[Uskov] Alexander Uskov, <auskov@idc.kz>, September 2002.
-
-[Wendt] Chris Wendt, <christw@microsoft.com>, December 1999.
-
-[Yick] Nicky Yick, <cliac@itsd.gcn.gov.hk>, October 2000.
-
-[]
-
-
-
-
-
-
-
diff --git a/WebCore/platform/text/mac/mac-encodings.txt b/WebCore/platform/text/mac/mac-encodings.txt
deleted file mode 100644
index bb45e22..0000000
--- a/WebCore/platform/text/mac/mac-encodings.txt
+++ /dev/null
@@ -1,45 +0,0 @@
-# We'd like to eliminate this file.
-# It would be nice to get rid of dependence on the TextEncodingConvert entirely.
-# Perhaps we can prove these are not used on the web and remove them.
-# Or perhaps we can get them added to ICU.
-
-# The items on the left are names of TEC TextEncoding values (without the leading kTextEncoding).
-# The items on the right are IANA character set names. Names listed in character-sets.txt are not
-# repeated here; mentioning any one character set from a group in there pulls in all the aliases in
-# that group.
-
-DOSChineseTrad: cp950
-DOSGreek: cp737, ibm737
-EUC_TW: EUC-TW
-ISOLatin10: ISO-8859-16
-ISOLatin6: ISO-8859-10
-ISOLatin8: ISO-8859-14
-ISOLatinThai: ISO-8859-11
-ISO_2022_JP_3: ISO-2022-JP-3
-JIS_C6226_78: JIS_C6226-1978
-JIS_X0208_83: JIS_X0208-1983
-JIS_X0208_90: JIS_X0208-1990
-JIS_X0212_90: JIS_X0212-1990
-KOI8_U: KOI8-U
-MacArabic: x-mac-arabic
-MacChineseSimp: x-mac-chinesesimp, xmacsimpchinese
-MacChineseTrad: x-mac-chinesetrad, xmactradchinese
-MacCroatian: x-mac-croatian
-MacDevanagari: x-mac-devanagari
-MacDingbats: x-mac-dingbats
-MacFarsi: x-mac-farsi
-MacGujarati: x-mac-gujarati
-MacGurmukhi: x-mac-gurmukhi
-MacHebrew: x-mac-hebrew
-MacIcelandic: x-mac-icelandic
-MacJapanese: x-mac-japanese
-MacKorean: x-mac-korean
-MacRomanLatin1: x-mac-roman-latin1
-MacRomanian: x-mac-romanian
-MacSymbol: x-mac-symbol
-MacThai: x-mac-thai
-MacTibetan: x-mac-tibetan
-MacVT100: x-mac-vt100
-NextStepLatin: x-nextstep
-ShiftJIS_X0213_00: Shift_JIS_X0213-2000
-WindowsKoreanJohab: johab
diff --git a/WebCore/platform/text/mac/make-charset-table.pl b/WebCore/platform/text/mac/make-charset-table.pl
deleted file mode 100755
index 16fd25a..0000000
--- a/WebCore/platform/text/mac/make-charset-table.pl
+++ /dev/null
@@ -1,225 +0,0 @@
-#!/usr/bin/perl -w
-
-# Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
-# its contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
-# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-# DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
-# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-use strict;
-
-my %aliasesFromCharsetsFile;
-my %namesWritten;
-
-my $output = "";
-
-my $error = 0;
-
-sub error ($)
-{
- print STDERR @_, "\n";
- $error = 1;
-}
-
-sub emit_line
-{
- my ($name, $prefix, $encoding, $flags) = @_;
-
- error "$name shows up twice in output" if $namesWritten{$name};
- $namesWritten{$name} = 1;
-
- $output .= " { \"$name\", $prefix$encoding },\n";
-}
-
-sub process_platform_encodings
-{
- my ($filename, $PlatformPrefix) = @_;
- my $baseFilename = $filename;
- $baseFilename =~ s|.*/||;
-
- my %seenPlatformNames;
- my %seenIANANames;
-
- open PLATFORM_ENCODINGS, $filename or die;
-
- while (<PLATFORM_ENCODINGS>) {
- chomp;
- s/\#.*$//;
- s/\s+$//;
- if (my ($PlatformName, undef, $flags, $IANANames) = /^(.+?)(, (.+))?: (.+)$/) {
- my %aliases;
-
- my $PlatformNameWithFlags = $PlatformName;
- if ($flags) {
- $PlatformNameWithFlags .= ", " . $flags;
- } else {
- $flags = "NoEncodingFlags";
- }
- error "Platform encoding name $PlatformName is mentioned twice in $baseFilename" if $seenPlatformNames{$PlatformNameWithFlags};
- $seenPlatformNames{$PlatformNameWithFlags} = 1;
-
- # Build the aliases list.
- # Also check that no two names are part of the same entry in the charsets file.
- my @IANANames = split ", ", $IANANames;
- my $firstName = "";
- my $canonicalFirstName = "";
- my $prevName = "";
- for my $name (@IANANames) {
- if ($firstName eq "") {
- if ($name !~ /^[-A-Za-z0-9_]+$/) {
- error "$name, in $baseFilename, has illegal characters in it";
- next;
- }
- $firstName = $name;
- } else {
- if ($name !~ /^[a-z0-9]+$/) {
- error "$name, in $baseFilename, has illegal characters in it (must be all lowercase alphanumeric)";
- next;
- }
- if ($name le $prevName) {
- error "$name comes after $prevName in $baseFilename, but everything must be in alphabetical order";
- }
- $prevName = $name;
- }
-
- my $canonicalName = lc $name;
- $canonicalName =~ tr/-_//d;
-
- $canonicalFirstName = $canonicalName if $canonicalFirstName eq "";
-
- error "$name is mentioned twice in $baseFilename" if $seenIANANames{$canonicalName};
- $seenIANANames{$canonicalName} = 1;
-
- $aliases{$canonicalName} = 1;
- next if !$aliasesFromCharsetsFile{$canonicalName};
- for my $alias (@{$aliasesFromCharsetsFile{$canonicalName}}) {
- $aliases{$alias} = 1;
- }
- for my $otherName (@IANANames) {
- next if $canonicalName eq $otherName;
- if ($aliasesFromCharsetsFile{$otherName}
- && $aliasesFromCharsetsFile{$canonicalName} eq $aliasesFromCharsetsFile{$otherName}
- && $canonicalName le $otherName) {
- error "$baseFilename lists both $name and $otherName under $PlatformName, but that aliasing is already specified in character-sets.txt";
- }
- }
- }
-
- # write out
- emit_line($firstName, $PlatformPrefix, $PlatformName, $flags);
- for my $alias (sort keys %aliases) {
- emit_line($alias, $PlatformPrefix, $PlatformName, $flags) if $alias ne $canonicalFirstName;
- }
- } elsif (/^([a-zA-Z0-9_]+)(, (.+))?$/) {
- my $PlatformName = $1;
-
- error "Platform encoding name $PlatformName is mentioned twice in $baseFilename" if $seenPlatformNames{$PlatformName};
- $seenPlatformNames{$PlatformName} = 1;
- } elsif (/./) {
- error "syntax error in $baseFilename, line $.";
- }
- }
-
- close PLATFORM_ENCODINGS;
-}
-
-sub process_iana_charset
-{
- my ($canonical_name, @aliases) = @_;
-
- return if !$canonical_name;
-
- my @names = sort $canonical_name, @aliases;
-
- for my $name (@names) {
- $aliasesFromCharsetsFile{$name} = \@names;
- }
-}
-
-sub process_iana_charsets
-{
- my ($filename) = @_;
-
- open CHARSETS, $filename or die;
-
- my %seen;
-
- my $canonical_name;
- my @aliases;
-
- my %exceptions = ( isoir91 => 1, isoir92 => 1 );
-
- while (<CHARSETS>) {
- chomp;
- if ((my $new_canonical_name) = /Name: ([^ \t]*).*/) {
- $new_canonical_name = lc $new_canonical_name;
- $new_canonical_name =~ tr/a-z0-9//cd;
-
- error "saw $new_canonical_name twice in character-sets.txt", if $seen{$new_canonical_name};
- $seen{$new_canonical_name} = $new_canonical_name;
-
- process_iana_charset $canonical_name, @aliases;
-
- $canonical_name = $new_canonical_name;
- @aliases = ();
- } elsif ((my $new_alias) = /Alias: ([^ \t]*).*/) {
- $new_alias = lc $new_alias;
- $new_alias =~ tr/a-z0-9//cd;
-
- # do this after normalizing the alias, sometimes character-sets.txt
- # has weird escape characters, e.g. \b after None
- next if $new_alias eq "none";
-
- error "saw $new_alias twice in character-sets.txt $seen{$new_alias}, $canonical_name", if $seen{$new_alias} && $seen{$new_alias} ne $canonical_name && !$exceptions{$new_alias};
- push @aliases, $new_alias if !$seen{$new_alias};
- $seen{$new_alias} = $canonical_name;
- }
- }
-
- process_iana_charset $canonical_name, @aliases;
-
- close CHARSETS;
-}
-
-# Program body
-
-process_iana_charsets($ARGV[0]);
-process_platform_encodings($ARGV[1], $ARGV[2]);
-
-exit 1 if $error;
-
-print <<EOF
-// File generated by make-charset-table.pl. Do not edit!
-
-#include "config.h"
-#include "CharsetData.h"
-
-namespace WebCore {
-
- const CharsetEntry CharsetTable[] = {
-$output
- { 0, 0 }
- };
-
-}
-EOF
diff --git a/WebCore/platform/text/qt/StringQt.cpp b/WebCore/platform/text/qt/StringQt.cpp
deleted file mode 100644
index de9f527..0000000
--- a/WebCore/platform/text/qt/StringQt.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "PlatformString.h"
-
-#include <QString>
-
-namespace WebCore {
-
-// String conversions
-String::String(const QString& qstr)
-{
- if (qstr.isNull())
- return;
- m_impl = StringImpl::create(reinterpret_cast<const UChar*>(qstr.constData()), qstr.length());
-}
-
-String::String(const QStringRef& ref)
-{
- if (!ref.string())
- return;
- m_impl = StringImpl::create(reinterpret_cast<const UChar*>(ref.unicode()), ref.length());
-}
-
-String::operator QString() const
-{
- return QString(reinterpret_cast<const QChar*>(characters()), length());
-}
-
-}
-
-// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/text/qt/TextBoundaries.cpp b/WebCore/platform/text/qt/TextBoundaries.cpp
deleted file mode 100644
index bdc851b..0000000
--- a/WebCore/platform/text/qt/TextBoundaries.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (C) 2006 Zack Rusin <zack@kde.org>
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "TextBoundaries.h"
-#include "NotImplemented.h"
-
-#include <QString>
-#include <QChar>
-
-#include <QDebug>
-#include <stdio.h>
-
-#if QT_VERSION >= 0x040400
-#include <qtextboundaryfinder.h>
-
-namespace WebCore
-{
-
-int findNextWordFromIndex(UChar const* buffer, int len, int position, bool forward)
-{
- QString str(reinterpret_cast<QChar const*>(buffer), len);
- QTextBoundaryFinder iterator(QTextBoundaryFinder::Word, str);
- iterator.setPosition(position >= len ? len - 1 : position);
- if (forward) {
- int pos = iterator.toNextBoundary();
- while (pos > 0) {
- if (QChar(buffer[pos-1]).isLetterOrNumber())
- return pos;
- pos = iterator.toNextBoundary();
- }
- return len;
- } else {
- int pos = iterator.toPreviousBoundary();
- while (pos > 0) {
- if (QChar(buffer[pos]).isLetterOrNumber())
- return pos;
- pos = iterator.toPreviousBoundary();
- }
- return 0;
- }
-}
-
-void findWordBoundary(UChar const* buffer, int len, int position, int* start, int* end)
-{
- QString str(reinterpret_cast<QChar const*>(buffer), len);
- QTextBoundaryFinder iterator(QTextBoundaryFinder::Word, str);
- iterator.setPosition(position);
- *start = position > 0 ? iterator.toPreviousBoundary() : 0;
- *end = position == len ? len : iterator.toNextBoundary();
-}
-
-}
-
-#else
-namespace WebCore
-{
-
-int findNextWordFromIndex(UChar const* buffer, int len, int position, bool forward)
-{
- QString str(reinterpret_cast<QChar const*>(buffer), len);
- notImplemented();
- return 0;
-}
-
-void findWordBoundary(UChar const* buffer, int len, int position, int* start, int* end)
-{
- QString str(reinterpret_cast<QChar const*>(buffer), len);
-
- if (position > str.length()) {
- *start = 0;
- *end = 0;
- return;
- }
-
- int currentPosition = position - 1;
- QString foundWord;
- while (currentPosition >= 0 &&
- str[currentPosition].isLetter()) {
- foundWord.prepend(str[currentPosition]);
- --currentPosition;
- }
-
- // currentPosition == 0 means the first char is not letter
- // currentPosition == -1 means we reached the beginning
- int startPos = (currentPosition < 0) ? 0 : ++currentPosition;
- currentPosition = position;
- if (str[currentPosition].isLetter()) {
- while (str[currentPosition].isLetter()) {
- foundWord.append(str[currentPosition]);
- ++currentPosition;
- }
- }
-
- *start = startPos;
- *end = currentPosition;
-}
-
-}
-#endif
diff --git a/WebCore/platform/text/qt/TextBreakIteratorQt.cpp b/WebCore/platform/text/qt/TextBreakIteratorQt.cpp
deleted file mode 100644
index 88b9680..0000000
--- a/WebCore/platform/text/qt/TextBreakIteratorQt.cpp
+++ /dev/null
@@ -1,297 +0,0 @@
-/*
- * This file is part of the DOM implementation for KDE.
- *
- * Copyright (C) 2006 Lars Knoll <lars@trolltech.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "TextBreakIterator.h"
-
-#if QT_VERSION >= 0x040400
-#include <QtCore/qtextboundaryfinder.h>
-#include <qdebug.h>
-
-// #define DEBUG_TEXT_ITERATORS
-#ifdef DEBUG_TEXT_ITERATORS
-#define DEBUG qDebug
-#else
-#define DEBUG if (1) {} else qDebug
-#endif
-
-namespace WebCore {
-
- class TextBreakIterator : public QTextBoundaryFinder
- {
- };
- static QTextBoundaryFinder* iterator = 0;
- static unsigned char buffer[1024];
-
- TextBreakIterator* wordBreakIterator(const UChar* string, int length)
- {
- if (!string)
- return 0;
- if (!iterator)
- iterator = new QTextBoundaryFinder;
-
- *iterator = QTextBoundaryFinder(QTextBoundaryFinder::Word, (const QChar *)string, length, buffer, sizeof(buffer));
- return static_cast<TextBreakIterator*>(iterator);
- }
-
- TextBreakIterator* characterBreakIterator(const UChar* string, int length)
- {
- if (!string)
- return 0;
- if (!iterator)
- iterator = new QTextBoundaryFinder;
-
- *iterator = QTextBoundaryFinder(QTextBoundaryFinder::Grapheme, (const QChar *)string, length, buffer, sizeof(buffer));
- return static_cast<TextBreakIterator*>(iterator);
- }
-
- TextBreakIterator* lineBreakIterator(const UChar* string, int length)
- {
- static QTextBoundaryFinder *iterator = 0;
- if (!string)
- return 0;
- if (!iterator)
- iterator = new QTextBoundaryFinder;
-
- *iterator = QTextBoundaryFinder(QTextBoundaryFinder::Line, (const QChar *)string, length, buffer, sizeof(buffer));
- return static_cast<TextBreakIterator*>(iterator);
- }
-
- TextBreakIterator* sentenceBreakIterator(const UChar* string, int length)
- {
- if (!string)
- return 0;
- if (!iterator)
- iterator = new QTextBoundaryFinder;
-
- *iterator = QTextBoundaryFinder(QTextBoundaryFinder::Sentence, (const QChar *)string, length, buffer, sizeof(buffer));
- return static_cast<TextBreakIterator*>(iterator);
- }
-
- int textBreakFirst(TextBreakIterator* bi)
- {
- bi->toStart();
- DEBUG() << "textBreakFirst" << bi->position();
- return bi->position();
- }
-
- int textBreakNext(TextBreakIterator* bi)
- {
- int pos = bi->toNextBoundary();
- DEBUG() << "textBreakNext" << pos;
- return pos;
- }
-
- int textBreakPreceding(TextBreakIterator* bi, int pos)
- {
- bi->setPosition(pos);
- int newpos = bi->toPreviousBoundary();
- DEBUG() << "textBreakPreceding" << pos << newpos;
- return newpos;
- }
-
- int textBreakFollowing(TextBreakIterator* bi, int pos)
- {
- bi->setPosition(pos);
- int newpos = bi->toNextBoundary();
- DEBUG() << "textBreakFollowing" << pos << newpos;
- return newpos;
- }
-
- int textBreakCurrent(TextBreakIterator* bi)
- {
- return bi->position();
- }
-
- bool isTextBreak(TextBreakIterator*, int)
- {
- return true;
- }
-
-}
-#else
-#include <qtextlayout.h>
-
-namespace WebCore {
-
- class TextBreakIterator
- {
- public:
- virtual int first() = 0;
- virtual int next() = 0;
- virtual int previous() = 0;
- inline int following(int pos) {
- currentPos = pos;
- return next();
- }
- inline int preceding(int pos) {
- currentPos = pos;
- return previous();
- }
- int currentPos;
- const UChar *string;
- int length;
- };
-
- class WordBreakIteratorQt : public TextBreakIterator
- {
- public:
- virtual int first();
- virtual int next();
- virtual int previous();
- };
-
- class CharBreakIteratorQt : public TextBreakIterator
- {
- public:
- virtual int first();
- virtual int next();
- virtual int previous();
- QTextLayout layout;
- };
-
- int WordBreakIteratorQt::first() {
- currentPos = 0;
- return currentPos;
- }
-
- int WordBreakIteratorQt::next() {
- if (currentPos >= length) {
- currentPos = -1;
- return currentPos;
- }
- bool haveSpace = false;
- while (currentPos < length) {
- if (haveSpace && !QChar(string[currentPos]).isSpace())
- break;
- if (QChar(string[currentPos]).isSpace())
- haveSpace = true;
- ++currentPos;
- }
- return currentPos;
- }
- int WordBreakIteratorQt::previous() {
- if (currentPos <= 0) {
- currentPos = -1;
- return currentPos;
- }
- bool haveSpace = false;
- while (currentPos > 0) {
- if (haveSpace && !QChar(string[currentPos]).isSpace())
- break;
- if (QChar(string[currentPos]).isSpace())
- haveSpace = true;
- --currentPos;
- }
- return currentPos;
- }
-
- int CharBreakIteratorQt::first() {
- currentPos = 0;
- return currentPos;
- }
-
- int CharBreakIteratorQt::next() {
- if (currentPos >= length)
- return -1;
- currentPos = layout.nextCursorPosition(currentPos);
- return currentPos;
- }
- int CharBreakIteratorQt::previous() {
- if (currentPos <= 0)
- return -1;
- currentPos = layout.previousCursorPosition(currentPos);
- return currentPos;
- }
-
-
-TextBreakIterator* wordBreakIterator(const UChar* string, int length)
-{
- static WordBreakIteratorQt *iterator = 0;
- if (!iterator)
- iterator = new WordBreakIteratorQt;
-
- iterator->string = string;
- iterator->length = length;
- iterator->currentPos = 0;
-
- return iterator;
-}
-
-TextBreakIterator* characterBreakIterator(const UChar* string, int length)
-{
- static CharBreakIteratorQt *iterator = 0;
- if (!iterator)
- iterator = new CharBreakIteratorQt;
-
- iterator->string = string;
- iterator->length = length;
- iterator->currentPos = 0;
- iterator->layout.setText(QString(reinterpret_cast<const QChar*>(string), length));
-
- return iterator;
-}
-
-TextBreakIterator* lineBreakIterator(const UChar*, int)
-{
- // not yet implemented
- return 0;
-}
-
-TextBreakIterator* sentenceBreakIterator(const UChar*, int)
-{
- // not yet implemented
- return 0;
-}
-
-int textBreakFirst(TextBreakIterator* bi)
-{
- return bi->first();
-}
-
-int textBreakNext(TextBreakIterator* bi)
-{
- return bi->next();
-}
-
-int textBreakPreceding(TextBreakIterator* bi, int pos)
-{
- return bi->preceding(pos);
-}
-
-int textBreakFollowing(TextBreakIterator* bi, int pos)
-{
- return bi->following(pos);
-}
-
-int textBreakCurrent(TextBreakIterator* bi)
-{
- return bi->currentPos;
-}
-
-bool isTextBreak(TextBreakIterator*, int)
-{
- return true;
-}
-
-}
-
-#endif
diff --git a/WebCore/platform/text/qt/TextCodecQt.cpp b/WebCore/platform/text/qt/TextCodecQt.cpp
deleted file mode 100644
index 0f385dd..0000000
--- a/WebCore/platform/text/qt/TextCodecQt.cpp
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (C) 2006 Lars Knoll <lars@trolltech.com>
- * Copyright (C) 2008 Holger Hans Peter Freyther
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "TextCodecQt.h"
-#include "PlatformString.h"
-#include "CString.h"
-#include <qset.h>
-// #include <QDebug>
-
-namespace WebCore {
-
-static QSet<QByteArray> *unique_names = 0;
-
-static const char *getAtomicName(const QByteArray &name)
-{
- if (!unique_names)
- unique_names = new QSet<QByteArray>;
-
- unique_names->insert(name);
- return unique_names->find(name)->constData();
-}
-
-void TextCodecQt::registerEncodingNames(EncodingNameRegistrar registrar)
-{
- QList<int> mibs = QTextCodec::availableMibs();
-// qDebug() << ">>>>>>>>> registerEncodingNames";
-
- for (int i = 0; i < mibs.size(); ++i) {
- QTextCodec *c = QTextCodec::codecForMib(mibs.at(i));
- const char *name = getAtomicName(c->name());
- registrar(name, name);
-// qDebug() << " " << name << name;
- QList<QByteArray> aliases = c->aliases();
- for (int i = 0; i < aliases.size(); ++i) {
- const char *a = getAtomicName(aliases.at(i));
-// qDebug() << " (a) " << a << name;
- registrar(a, name);
- }
- }
-}
-
-static std::auto_ptr<TextCodec> newTextCodecQt(const TextEncoding& encoding, const void*)
-{
- return std::auto_ptr<TextCodec>(new TextCodecQt(encoding));
-}
-
-void TextCodecQt::registerCodecs(TextCodecRegistrar registrar)
-{
- QList<int> mibs = QTextCodec::availableMibs();
-// qDebug() << ">>>>>>>>> registerCodecs";
-
- for (int i = 0; i < mibs.size(); ++i) {
- QTextCodec *c = QTextCodec::codecForMib(mibs.at(i));
- const char *name = getAtomicName(c->name());
-// qDebug() << " " << name;
- registrar(name, newTextCodecQt, 0);
- }
-}
-
-TextCodecQt::TextCodecQt(const TextEncoding& encoding)
- : m_encoding(encoding)
-{
- m_codec = QTextCodec::codecForName(m_encoding.name());
-}
-
-TextCodecQt::~TextCodecQt()
-{
-}
-
-
-String TextCodecQt::decode(const char* bytes, size_t length, bool flush, bool /*stopOnError*/, bool& sawError)
-{
- QString unicode = m_codec->toUnicode(bytes, length, &m_state);
- sawError = m_state.invalidChars != 0;
-
- if (flush) {
- m_state.flags = QTextCodec::DefaultConversion;
- m_state.remainingChars = 0;
- m_state.invalidChars = 0;
- }
-
- return unicode;
-}
-
-CString TextCodecQt::encode(const UChar* characters, size_t length, UnencodableHandling)
-{
- if (!length)
- return "";
-
- // FIXME: do something sensible with UnencodableHandling
-
- QByteArray ba = m_codec->fromUnicode(reinterpret_cast<const QChar*>(characters), length, 0);
- return CString(ba.constData(), ba.length());
-}
-
-
-} // namespace WebCore
diff --git a/WebCore/platform/text/qt/TextCodecQt.h b/WebCore/platform/text/qt/TextCodecQt.h
deleted file mode 100644
index f28f0bb..0000000
--- a/WebCore/platform/text/qt/TextCodecQt.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2006 Lars Knoll <lars@trolltech.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef TextCodecQt_h
-#define TextCodecQt_h
-
-#include "TextCodec.h"
-#include "TextEncoding.h"
-#include <QTextCodec>
-
-namespace WebCore {
-
- class TextCodecQt : public TextCodec {
- public:
- static void registerEncodingNames(EncodingNameRegistrar);
- static void registerCodecs(TextCodecRegistrar);
-
- TextCodecQt(const TextEncoding&);
- virtual ~TextCodecQt();
-
- virtual String decode(const char*, size_t length, bool flush, bool stopOnError, bool& sawError);
- virtual CString encode(const UChar*, size_t length, UnencodableHandling);
-
- private:
- TextEncoding m_encoding;
- QTextCodec *m_codec;
- QTextCodec::ConverterState m_state;
- };
-
-} // namespace WebCore
-
-#endif // TextCodecICU_h
diff --git a/WebCore/platform/text/symbian/StringImplSymbian.cpp b/WebCore/platform/text/symbian/StringImplSymbian.cpp
deleted file mode 100644
index 3a1245f..0000000
--- a/WebCore/platform/text/symbian/StringImplSymbian.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
-* ==============================================================================
-* Copyright (c) 2006, Nokia Corporation
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions
-* are met:
-*
-* * Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in
-* the documentation and/or other materials provided with the
-* distribution.
-* * Neither the name of the Nokia Corporation nor the names of its
-* contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
-* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
-* DAMAGE.
-*
-* ==============================================================================
-*/
-
-#include "config.h"
-#include "StringImpl.h"
-#include <e32std.h>
-
-namespace WebCore {
-
-StringImpl::StringImpl(const TDesC& des)
-{
- init(des.Ptr(), des.Length());
-}
-
-TPtrC StringImpl::des() const
-{
- TPtrC tstr((const TUint16 *)m_data, m_length);
- return tstr;
-}
-
-}
diff --git a/WebCore/platform/text/symbian/StringSymbian.cpp b/WebCore/platform/text/symbian/StringSymbian.cpp
deleted file mode 100644
index 27b6a13..0000000
--- a/WebCore/platform/text/symbian/StringSymbian.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
-* ==============================================================================
-* Copyright (c) 2006, Nokia Corporation
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions
-* are met:
-*
-* * Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in
-* the documentation and/or other materials provided with the
-* distribution.
-* * Neither the name of the Nokia Corporation nor the names of its
-* contributors may be used to endorse or promote products derived
-* from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
-* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
-* DAMAGE.
-*
-* ==============================================================================
-*/
-
-#include "config.h"
-#include "PlatformString.h"
-#include <e32std.h>
-
-namespace WebCore {
-
-String::String(const TDesC& des)
-{
- if (!des.Length())
- m_impl = StringImpl::empty();
- else
- m_impl = new StringImpl(des);
-}
-
-} \ No newline at end of file
diff --git a/WebCore/platform/text/win/TextBreakIteratorInternalICUWin.cpp b/WebCore/platform/text/win/TextBreakIteratorInternalICUWin.cpp
deleted file mode 100644
index 14cf130..0000000
--- a/WebCore/platform/text/win/TextBreakIteratorInternalICUWin.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "TextBreakIteratorInternalICU.h"
-
-namespace WebCore {
-
-const char* currentTextBreakLocaleID()
-{
- return "en_us";
-}
-
-}
diff --git a/WebCore/platform/text/wx/StringWx.cpp b/WebCore/platform/text/wx/StringWx.cpp
deleted file mode 100644
index 50919c4..0000000
--- a/WebCore/platform/text/wx/StringWx.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (C) 2007 Vaclav Slavik, Kevin Ollivier <kevino@theolliviers.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "PlatformString.h"
-
-#include "CString.h"
-#include "unicode/ustring.h"
-
-#include <wx/defs.h>
-#include <wx/string.h>
-
-namespace WebCore {
-
-// String conversions
-String::String(const wxString& wxstr)
-{
-#if !wxUSE_UNICODE
- #error "This code only works in Unicode build of wxWidgets"
-#endif
-
- // ICU's UChar is 16bit wide, UTF-16, and the code below counts on it, so
- // it would break if the definition changed:
- wxCOMPILE_TIME_ASSERT(sizeof(UChar) == 2, UCharSizeMustBe16Bit);
-
-#if SIZEOF_WCHAR_T == 2 // wchar_t==UChar
-
- const UChar* str = wxstr.wc_str();
- const size_t len = wxstr.length();
-
-#else // SIZEOF_WCHAR_T == 4
-
- // NB: we can't simply use wxstr.mb_str(wxMBConvUTF16()) here because
- // the number of characters in UTF-16 encoding of the string may differ
- // from the number of UTF-32 values and we can't get the length from
- // returned buffer:
-
-#if defined(wxUSE_UNICODE_UTF8) && wxUSE_UNICODE_UTF8
- // in wx3's UTF8 mode, wc_str() returns a buffer, not raw pointer
- wxWCharBuffer widestr(wxstr.wc_str());
-#else
- const wxChar *widestr = wxstr.wc_str();
-#endif
- const size_t widelen = wxstr.length();
-
- // allocate buffer for the UTF-16 string:
- wxMBConvUTF16 conv;
- const size_t utf16bufLen = conv.FromWChar(NULL, 0, widestr, widelen);
- wxCharBuffer utf16buf(utf16bufLen);
-
- // and convert wxString to UTF-16 (=UChar*):
- const UChar* str = (const UChar*)utf16buf.data();
- size_t len = conv.FromWChar(utf16buf.data(), utf16bufLen, widestr, widelen) / 2;
-
-#endif // SIZEOF_WCHAR_T == 4
-
- // conversion to UTF-16 or getting internal buffer isn't supposed to fail:
- wxASSERT_MSG(str != NULL, _T("failed string conversion?"));
-
- m_impl = StringImpl::create(str, len);
-}
-
-String::operator wxString() const
-{
- return wxString(utf8().data(), wxConvUTF8);
-}
-
-}
-
-// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/win/BString.cpp b/WebCore/platform/win/BString.cpp
deleted file mode 100644
index 618ecf3..0000000
--- a/WebCore/platform/win/BString.cpp
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "BString.h"
-
-#include "AtomicString.h"
-#include "KURL.h"
-#include "PlatformString.h"
-#include <tchar.h>
-#include <windows.h>
-
-#if PLATFORM(CF)
-#include <CoreFoundation/CoreFoundation.h>
-#endif
-
-using namespace JSC;
-
-namespace WebCore {
-
-BString::BString()
- : m_bstr(0)
-{
-}
-
-BString::BString(const wchar_t* characters)
-{
- if (!characters)
- m_bstr = 0;
- else
- m_bstr = SysAllocString(characters);
-}
-
-BString::BString(const wchar_t* characters, size_t length)
-{
- if (!characters)
- m_bstr = 0;
- else
- m_bstr = SysAllocStringLen(characters, length);
-}
-
-BString::BString(const String& s)
-{
- if (s.isNull())
- m_bstr = 0;
- else
- m_bstr = SysAllocStringLen(s.characters(), s.length());
-}
-
-BString::BString(const KURL& url)
-{
- if (url.isNull())
- m_bstr = 0;
- else
- m_bstr = SysAllocStringLen(url.string().characters(), url.string().length());
-}
-
-BString::BString(const AtomicString& s)
-{
- if (s.isNull())
- m_bstr = 0;
- else
- m_bstr = SysAllocStringLen(s.characters(), s.length());
-}
-
-BString::BString(const UString& s)
-{
- if (s.isNull())
- m_bstr = 0;
- else
- m_bstr = SysAllocStringLen(s.data(), s.size());
-}
-
-#if PLATFORM(CF)
-BString::BString(CFStringRef cfstr)
- : m_bstr(0)
-{
- if (!cfstr)
- return;
-
- const UniChar* uniChars = CFStringGetCharactersPtr(cfstr);
- if (uniChars) {
- m_bstr = SysAllocStringLen((LPCTSTR)uniChars, CFStringGetLength(cfstr));
- return;
- }
-
- CFIndex length = CFStringGetLength(cfstr);
- m_bstr = SysAllocStringLen(0, length);
- CFStringGetCharacters(cfstr, CFRangeMake(0, length), (UniChar*)m_bstr);
- m_bstr[length] = 0;
-}
-#endif
-
-BString::~BString()
-{
- SysFreeString(m_bstr);
-}
-
-BString::BString(const BString& other)
-{
- if (!other.m_bstr)
- m_bstr = 0;
- else
- m_bstr = SysAllocString(other.m_bstr);
-}
-
-void BString::adoptBSTR(BSTR bstr)
-{
- if (m_bstr)
- SysFreeString(m_bstr);
- m_bstr = bstr;
-}
-
-BString& BString::operator=(const BString& other)
-{
- if (this != &other)
- *this = other.m_bstr;
- return *this;
-}
-
-BString& BString::operator=(const BSTR& other)
-{
- if (other != m_bstr) {
- SysFreeString(m_bstr);
- m_bstr = other ? SysAllocString(other) : 0;
- }
-
- return *this;
-}
-
-bool operator ==(const BString& a, const BString& b)
-{
- if (SysStringLen((BSTR)a) != SysStringLen((BSTR)b))
- return false;
- if (!(BSTR)a && !(BSTR)b)
- return true;
- if (!(BSTR)a || !(BSTR)b)
- return false;
- return !_tcscmp((BSTR)a, (BSTR)b);
-}
-
-bool operator !=(const BString& a, const BString& b)
-{
- return !(a==b);
-}
-
-bool operator ==(const BString& a, BSTR b)
-{
- if (SysStringLen((BSTR)a) != SysStringLen(b))
- return false;
- if (!(BSTR)a && !b)
- return true;
- if (!(BSTR)a || !b)
- return false;
- return !_tcscmp((BSTR)a, b);
-}
-
-bool operator !=(const BString& a, BSTR b)
-{
- return !(a==b);
-}
-
-bool operator ==(BSTR a, const BString& b)
-{
- if (SysStringLen(a) != SysStringLen((BSTR)b))
- return false;
- if (!a && !(BSTR)b)
- return true;
- if (!a || !(BSTR)b)
- return false;
- return !_tcscmp(a, (BSTR)b);
-}
-
-bool operator !=(BSTR a, const BString& b)
-{
- return !(a==b);
-}
-
-}
diff --git a/WebCore/platform/win/BString.h b/WebCore/platform/win/BString.h
deleted file mode 100644
index c32a49d..0000000
--- a/WebCore/platform/win/BString.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef BString_h
-#define BString_h
-
-#if PLATFORM(CF)
-typedef const struct __CFString * CFStringRef;
-#endif
-
-typedef wchar_t* BSTR;
-
-namespace JSC {
- class UString;
-}
-
-namespace WebCore {
-
- class AtomicString;
- class KURL;
- class String;
-
- class BString {
- public:
- BString();
- BString(const wchar_t*);
- BString(const wchar_t*, size_t length);
- BString(const String&);
- BString(const AtomicString&);
- BString(const KURL&);
- BString(const JSC::UString&);
-#if PLATFORM(CF)
- BString(CFStringRef);
-#endif
- ~BString();
-
- void adoptBSTR(BSTR);
-
- BString(const BString&);
- BString& operator=(const BString&);
- BString& operator=(const BSTR&);
-
- operator BSTR() const { return m_bstr; }
-
- BSTR release() { BSTR result = m_bstr; m_bstr = 0; return result; }
-
- private:
- BSTR m_bstr;
- };
-
- bool operator ==(const BString&, const BString&);
- bool operator !=(const BString&, const BString&);
- bool operator ==(const BString&, BSTR);
- bool operator !=(const BString&, BSTR);
- bool operator ==(BSTR, const BString&);
- bool operator !=(BSTR, const BString&);
-
-}
-
-#endif
diff --git a/WebCore/platform/win/COMPtr.h b/WebCore/platform/win/COMPtr.h
deleted file mode 100644
index 784495a..0000000
--- a/WebCore/platform/win/COMPtr.h
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef COMPtr_h
-#define COMPtr_h
-
-#define NOMINMAX
-
-#include <guiddef.h>
-#include <unknwn.h>
-#include <WTF/Assertions.h>
-#include <WTF/HashTraits.h>
-
-typedef long HRESULT;
-
-// FIXME: Should we put this into the WebCore namespace and use "using" on it
-// as we do with things in WTF?
-
-enum AdoptCOMTag { AdoptCOM };
-enum QueryTag { Query };
-enum CreateTag { Create };
-
-template <typename T> class COMPtr {
-public:
- COMPtr() : m_ptr(0) { }
- COMPtr(T* ptr) : m_ptr(ptr) { if (m_ptr) m_ptr->AddRef(); }
- COMPtr(AdoptCOMTag, T* ptr) : m_ptr(ptr) { }
- COMPtr(const COMPtr& o) : m_ptr(o.m_ptr) { if (T* ptr = m_ptr) ptr->AddRef(); }
-
- COMPtr(QueryTag, IUnknown* ptr) : m_ptr(copyQueryInterfaceRef(ptr)) { }
- template <typename U> COMPtr(QueryTag, const COMPtr<U>& ptr) : m_ptr(copyQueryInterfaceRef(ptr.get())) { }
-
- COMPtr(CreateTag, const IID& clsid) : m_ptr(createInstance(clsid)) { }
-
- // Hash table deleted values, which are only constructed and never copied or destroyed.
- COMPtr(WTF::HashTableDeletedValueType) : m_ptr(hashTableDeletedValue()) { }
- bool isHashTableDeletedValue() const { return m_ptr == hashTableDeletedValue(); }
-
- ~COMPtr() { if (m_ptr) m_ptr->Release(); }
-
- T* get() const { return m_ptr; }
- T* releaseRef() { T* tmp = m_ptr; m_ptr = 0; return tmp; }
-
- T& operator*() const { return *m_ptr; }
- T* operator->() const { return m_ptr; }
-
- T** operator&() { ASSERT(!m_ptr); return &m_ptr; }
-
- bool operator!() const { return !m_ptr; }
-
- // This conversion operator allows implicit conversion to bool but not to other integer types.
- typedef T* (COMPtr::*UnspecifiedBoolType)() const;
- operator UnspecifiedBoolType() const { return m_ptr ? &COMPtr::get : 0; }
-
- COMPtr& operator=(const COMPtr&);
- COMPtr& operator=(T*);
- template <typename U> COMPtr& operator=(const COMPtr<U>&);
-
- void query(IUnknown* ptr) { adoptRef(copyQueryInterfaceRef(ptr)); }
- template <typename U> void query(const COMPtr<U>& ptr) { query(ptr.get()); }
-
- void create(const IID& clsid) { adoptRef(createInstance(clsid)); }
-
- template <typename U> HRESULT copyRefTo(U**);
- void adoptRef(T*);
-
-private:
- static T* copyQueryInterfaceRef(IUnknown*);
- static T* createInstance(const IID& clsid);
- static T* hashTableDeletedValue() { return reinterpret_cast<T*>(-1); }
-
- T* m_ptr;
-};
-
-template <typename T> inline T* COMPtr<T>::createInstance(const IID& clsid)
-{
- T* result;
- if (FAILED(CoCreateInstance(clsid, 0, CLSCTX_ALL, __uuidof(result), reinterpret_cast<void**>(&result))))
- return 0;
- return result;
-}
-
-template <typename T> inline T* COMPtr<T>::copyQueryInterfaceRef(IUnknown* ptr)
-{
- if (!ptr)
- return 0;
- T* result;
- if (FAILED(ptr->QueryInterface(&result)))
- return 0;
- return result;
-}
-
-template <typename T> template <typename U> inline HRESULT COMPtr<T>::copyRefTo(U** ptr)
-{
- if (!ptr)
- return E_POINTER;
- *ptr = m_ptr;
- if (m_ptr)
- m_ptr->AddRef();
- return S_OK;
-}
-
-template <typename T> inline void COMPtr<T>::adoptRef(T *ptr)
-{
- if (m_ptr)
- m_ptr->Release();
- m_ptr = ptr;
-}
-
-template <typename T> inline COMPtr<T>& COMPtr<T>::operator=(const COMPtr<T>& o)
-{
- T* optr = o.get();
- if (optr)
- optr->AddRef();
- T* ptr = m_ptr;
- m_ptr = optr;
- if (ptr)
- ptr->Release();
- return *this;
-}
-
-template <typename T> template <typename U> inline COMPtr<T>& COMPtr<T>::operator=(const COMPtr<U>& o)
-{
- T* optr = o.get();
- if (optr)
- optr->AddRef();
- T* ptr = m_ptr;
- m_ptr = optr;
- if (ptr)
- ptr->Release();
- return *this;
-}
-
-template <typename T> inline COMPtr<T>& COMPtr<T>::operator=(T* optr)
-{
- if (optr)
- optr->AddRef();
- T* ptr = m_ptr;
- m_ptr = optr;
- if (ptr)
- ptr->Release();
- return *this;
-}
-
-template <typename T, typename U> inline bool operator==(const COMPtr<T>& a, const COMPtr<U>& b)
-{
- return a.get() == b.get();
-}
-
-template <typename T, typename U> inline bool operator==(const COMPtr<T>& a, U* b)
-{
- return a.get() == b;
-}
-
-template <typename T, typename U> inline bool operator==(T* a, const COMPtr<U>& b)
-{
- return a == b.get();
-}
-
-template <typename T, typename U> inline bool operator!=(const COMPtr<T>& a, const COMPtr<U>& b)
-{
- return a.get() != b.get();
-}
-
-template <typename T, typename U> inline bool operator!=(const COMPtr<T>& a, U* b)
-{
- return a.get() != b;
-}
-
-template <typename T, typename U> inline bool operator!=(T* a, const COMPtr<U>& b)
-{
- return a != b.get();
-}
-
-namespace WTF {
-
- template<typename P> struct HashTraits<COMPtr<P> > : GenericHashTraits<COMPtr<P> > {
- static const bool emptyValueIsZero = true;
- static void constructDeletedValue(COMPtr<P>& slot) { slot.releaseRef(); *&slot = reinterpret_cast<P*>(-1); }
- static bool isDeletedValue(const COMPtr<P>& value) { return value == reinterpret_cast<P*>(-1); }
- };
-
- template<typename P> struct PtrHash<COMPtr<P> > : PtrHash<P*> {
- using PtrHash<P*>::hash;
- static unsigned hash(const COMPtr<P>& key) { return hash(key.get()); }
- using PtrHash<P*>::equal;
- static bool equal(const COMPtr<P>& a, const COMPtr<P>& b) { return a == b; }
- static bool equal(P* a, const COMPtr<P>& b) { return a == b; }
- static bool equal(const COMPtr<P>& a, P* b) { return a == b; }
- };
-
- template<typename P> struct DefaultHash<COMPtr<P> > { typedef PtrHash<COMPtr<P> > Hash; };
-}
-
-#endif
diff --git a/WebCore/platform/win/ClipboardUtilitiesWin.cpp b/WebCore/platform/win/ClipboardUtilitiesWin.cpp
deleted file mode 100644
index 3762a1a..0000000
--- a/WebCore/platform/win/ClipboardUtilitiesWin.cpp
+++ /dev/null
@@ -1,452 +0,0 @@
-/*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ClipboardUtilitiesWin.h"
-
-#include "CString.h"
-#include "DocumentFragment.h"
-#include "KURL.h"
-#include "PlatformString.h"
-#include "TextEncoding.h"
-#include "markup.h"
-#include <CoreFoundation/CoreFoundation.h>
-#include <wtf/RetainPtr.h>
-#include <shlwapi.h>
-#include <wininet.h> // for INTERNET_MAX_URL_LENGTH
-
-namespace WebCore {
-
-FORMATETC* cfHDropFormat()
-{
- static FORMATETC urlFormat = {CF_HDROP, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
- return &urlFormat;
-}
-
-static bool getWebLocData(IDataObject* dataObject, String& url, String* title)
-{
- bool succeeded = false;
- WCHAR filename[MAX_PATH];
- WCHAR urlBuffer[INTERNET_MAX_URL_LENGTH];
-
- STGMEDIUM medium;
- if (FAILED(dataObject->GetData(cfHDropFormat(), &medium)))
- return false;
-
- HDROP hdrop = (HDROP)GlobalLock(medium.hGlobal);
-
- if (!hdrop)
- return false;
-
- if (!DragQueryFileW(hdrop, 0, filename, ARRAYSIZE(filename)))
- goto exit;
-
- if (_wcsicmp(PathFindExtensionW(filename), L".url"))
- goto exit;
-
- if (!GetPrivateProfileStringW(L"InternetShortcut", L"url", 0, urlBuffer, ARRAYSIZE(urlBuffer), filename))
- goto exit;
-
- if (title) {
- PathRemoveExtension(filename);
- *title = String((UChar*)filename);
- }
-
- url = String((UChar*)urlBuffer);
- succeeded = true;
-
-exit:
- // Free up memory.
- DragFinish(hdrop);
- GlobalUnlock(medium.hGlobal);
- return succeeded;
-}
-
-static String extractURL(const String &inURL, String* title)
-{
- String url = inURL;
- int splitLoc = url.find('\n');
- if (splitLoc > 0) {
- if (title)
- *title = url.substring(splitLoc+1);
- url.truncate(splitLoc);
- } else if (title)
- *title = url;
- return url;
-}
-
-//Firefox text/html
-static FORMATETC* texthtmlFormat()
-{
- static UINT cf = RegisterClipboardFormat(L"text/html");
- static FORMATETC texthtmlFormat = {cf, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
- return &texthtmlFormat;
-}
-
-HGLOBAL createGlobalData(const KURL& url, const String& title)
-{
- String mutableURL(url.string());
- String mutableTitle(title);
- SIZE_T size = mutableURL.length() + mutableTitle.length() + 2; // +1 for "\n" and +1 for null terminator
- HGLOBAL cbData = ::GlobalAlloc(GPTR, size * sizeof(UChar));
-
- if (cbData) {
- PWSTR buffer = (PWSTR)::GlobalLock(cbData);
- swprintf_s(buffer, size, L"%s\n%s", mutableURL.charactersWithNullTermination(), mutableTitle.charactersWithNullTermination());
- ::GlobalUnlock(cbData);
- }
- return cbData;
-}
-
-HGLOBAL createGlobalData(const String& str)
-{
- HGLOBAL globalData = ::GlobalAlloc(GPTR, (str.length() + 1) * sizeof(UChar));
- if (!globalData)
- return 0;
- UChar* buffer = static_cast<UChar*>(::GlobalLock(globalData));
- memcpy(buffer, str.characters(), str.length() * sizeof(UChar));
- buffer[str.length()] = 0;
- ::GlobalUnlock(globalData);
- return globalData;
-}
-
-HGLOBAL createGlobalData(const Vector<char>& vector)
-{
- HGLOBAL globalData = ::GlobalAlloc(GPTR, vector.size() + 1);
- if (!globalData)
- return 0;
- char* buffer = static_cast<char*>(::GlobalLock(globalData));
- memcpy(buffer, vector.data(), vector.size());
- buffer[vector.size()] = 0;
- ::GlobalUnlock(globalData);
- return globalData;
-}
-
-static void append(Vector<char>& vector, const char* string)
-{
- vector.append(string, strlen(string));
-}
-
-static void append(Vector<char>& vector, const CString& string)
-{
- vector.append(string.data(), string.length());
-}
-
-// Documentation for the CF_HTML format is available at http://msdn.microsoft.com/workshop/networking/clipboard/htmlclipboard.asp
-void markupToCF_HTML(const String& markup, const String& srcURL, Vector<char>& result)
-{
- if (markup.isEmpty())
- return;
-
- #define MAX_DIGITS 10
- #define MAKE_NUMBER_FORMAT_1(digits) MAKE_NUMBER_FORMAT_2(digits)
- #define MAKE_NUMBER_FORMAT_2(digits) "%0" #digits "u"
- #define NUMBER_FORMAT MAKE_NUMBER_FORMAT_1(MAX_DIGITS)
-
- const char* header = "Version:0.9\n"
- "StartHTML:" NUMBER_FORMAT "\n"
- "EndHTML:" NUMBER_FORMAT "\n"
- "StartFragment:" NUMBER_FORMAT "\n"
- "EndFragment:" NUMBER_FORMAT "\n";
- const char* sourceURLPrefix = "SourceURL:";
-
- const char* startMarkup = "<HTML>\n<BODY>\n<!--StartFragment-->\n";
- const char* endMarkup = "\n<!--EndFragment-->\n</BODY>\n</HTML>";
-
- CString sourceURLUTF8 = srcURL == blankURL() ? "" : srcURL.utf8();
- CString markupUTF8 = markup.utf8();
-
- // calculate offsets
- unsigned startHTMLOffset = strlen(header) - strlen(NUMBER_FORMAT) * 4 + MAX_DIGITS * 4;
- if (sourceURLUTF8.length())
- startHTMLOffset += strlen(sourceURLPrefix) + sourceURLUTF8.length() + 1;
- unsigned startFragmentOffset = startHTMLOffset + strlen(startMarkup);
- unsigned endFragmentOffset = startFragmentOffset + markupUTF8.length();
- unsigned endHTMLOffset = endFragmentOffset + strlen(endMarkup);
-
- append(result, String::format(header, startHTMLOffset, endHTMLOffset, startFragmentOffset, endFragmentOffset).utf8());
- if (sourceURLUTF8.length()) {
- append(result, sourceURLPrefix);
- append(result, sourceURLUTF8);
- result.append('\n');
- }
- append(result, startMarkup);
- append(result, markupUTF8);
- append(result, endMarkup);
-
- #undef MAX_DIGITS
- #undef MAKE_NUMBER_FORMAT_1
- #undef MAKE_NUMBER_FORMAT_2
- #undef NUMBER_FORMAT
-}
-
-String urlToMarkup(const KURL& url, const String& title)
-{
- Vector<UChar> markup;
- append(markup, "<a href=\"");
- append(markup, url.string());
- append(markup, "\">");
- append(markup, title);
- append(markup, "</a>");
- return String::adopt(markup);
-}
-
-void replaceNewlinesWithWindowsStyleNewlines(String& str)
-{
- static const UChar Newline = '\n';
- static const char* const WindowsNewline("\r\n");
- str.replace(Newline, WindowsNewline);
-}
-
-void replaceNBSPWithSpace(String& str)
-{
- static const UChar NonBreakingSpaceCharacter = 0xA0;
- static const UChar SpaceCharacter = ' ';
- str.replace(NonBreakingSpaceCharacter, SpaceCharacter);
-}
-
-FORMATETC* urlWFormat()
-{
- static UINT cf = RegisterClipboardFormat(L"UniformResourceLocatorW");
- static FORMATETC urlFormat = {cf, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
- return &urlFormat;
-}
-
-FORMATETC* urlFormat()
-{
- static UINT cf = RegisterClipboardFormat(L"UniformResourceLocator");
- static FORMATETC urlFormat = {cf, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
- return &urlFormat;
-}
-
-FORMATETC* plainTextFormat()
-{
- static FORMATETC textFormat = {CF_TEXT, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
- return &textFormat;
-}
-
-FORMATETC* plainTextWFormat()
-{
- static FORMATETC textFormat = {CF_UNICODETEXT, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
- return &textFormat;
-}
-
-FORMATETC* filenameWFormat()
-{
- static UINT cf = RegisterClipboardFormat(L"FileNameW");
- static FORMATETC urlFormat = {cf, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
- return &urlFormat;
-}
-
-FORMATETC* filenameFormat()
-{
- static UINT cf = RegisterClipboardFormat(L"FileName");
- static FORMATETC urlFormat = {cf, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
- return &urlFormat;
-}
-
-//MSIE HTML Format
-FORMATETC* htmlFormat()
-{
- static UINT cf = RegisterClipboardFormat(L"HTML Format");
- static FORMATETC htmlFormat = {cf, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
- return &htmlFormat;
-}
-
-FORMATETC* smartPasteFormat()
-{
- static UINT cf = RegisterClipboardFormat(L"WebKit Smart Paste Format");
- static FORMATETC htmlFormat = {cf, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
- return &htmlFormat;
-}
-
-static bool urlFromPath(CFStringRef path, String& url)
-{
- if (!path)
- return false;
-
- RetainPtr<CFURLRef> cfURL(AdoptCF, CFURLCreateWithFileSystemPath(0, path, kCFURLWindowsPathStyle, false));
- if (!cfURL)
- return false;
-
- url = String(CFURLGetString(cfURL.get()));
- return true;
-}
-
-String getURL(IDataObject* dataObject, bool& success, String* title)
-{
- STGMEDIUM store;
- String url;
- success = false;
- if (getWebLocData(dataObject, url, title)) {
- success = true;
- return url;
- } else if (SUCCEEDED(dataObject->GetData(urlWFormat(), &store))) {
- //URL using unicode
- UChar* data = (UChar*)GlobalLock(store.hGlobal);
- url = extractURL(String(data), title);
- GlobalUnlock(store.hGlobal);
- ReleaseStgMedium(&store);
- success = true;
- } else if (SUCCEEDED(dataObject->GetData(urlFormat(), &store))) {
- //URL using ascii
- char* data = (char*)GlobalLock(store.hGlobal);
- url = extractURL(String(data), title);
- GlobalUnlock(store.hGlobal);
- ReleaseStgMedium(&store);
- success = true;
- } else if (SUCCEEDED(dataObject->GetData(filenameWFormat(), &store))) {
- //file using unicode
- wchar_t* data = (wchar_t*)GlobalLock(store.hGlobal);
- if (data && data[0] && (PathFileExists(data) || PathIsUNC(data))) {
- RetainPtr<CFStringRef> pathAsCFString(AdoptCF, CFStringCreateWithCharacters(kCFAllocatorDefault, (const UniChar*)data, wcslen(data)));
- if (urlFromPath(pathAsCFString.get(), url)) {
- if (title)
- *title = url;
- success = true;
- }
- }
- GlobalUnlock(store.hGlobal);
- ReleaseStgMedium(&store);
- } else if (SUCCEEDED(dataObject->GetData(filenameFormat(), &store))) {
- //filename using ascii
- char* data = (char*)GlobalLock(store.hGlobal);
- if (data && data[0] && (PathFileExistsA(data) || PathIsUNCA(data))) {
- RetainPtr<CFStringRef> pathAsCFString(AdoptCF, CFStringCreateWithCString(kCFAllocatorDefault, data, kCFStringEncodingASCII));
- if (urlFromPath(pathAsCFString.get(), url)) {
- if (title)
- *title = url;
- success = true;
- }
- }
- GlobalUnlock(store.hGlobal);
- ReleaseStgMedium(&store);
- }
- return url;
-}
-
-String getPlainText(IDataObject* dataObject, bool& success)
-{
- STGMEDIUM store;
- String text;
- success = false;
- if (SUCCEEDED(dataObject->GetData(plainTextWFormat(), &store))) {
- //unicode text
- UChar* data = (UChar*)GlobalLock(store.hGlobal);
- text = String(data);
- GlobalUnlock(store.hGlobal);
- ReleaseStgMedium(&store);
- success = true;
- } else if (SUCCEEDED(dataObject->GetData(plainTextFormat(), &store))) {
- //ascii text
- char* data = (char*)GlobalLock(store.hGlobal);
- text = String(data);
- GlobalUnlock(store.hGlobal);
- ReleaseStgMedium(&store);
- success = true;
- } else {
- //If a file is dropped on the window, it does not provide either of the
- //plain text formats, so here we try to forcibly get a url.
- text = getURL(dataObject, success);
- success = true;
- }
- return text;
-}
-
-PassRefPtr<DocumentFragment> fragmentFromFilenames(Document*, const IDataObject*)
-{
- //FIXME: We should be able to create fragments from files
- return 0;
-}
-
-bool containsFilenames(const IDataObject*)
-{
- //FIXME: We'll want to update this once we can produce fragments from files
- return false;
-}
-
-//Convert a String containing CF_HTML formatted text to a DocumentFragment
-PassRefPtr<DocumentFragment> fragmentFromCF_HTML(Document* doc, const String& cf_html)
-{
- // obtain baseURL if present
- String srcURLStr("sourceURL:");
- String srcURL;
- unsigned lineStart = cf_html.find(srcURLStr, 0, false);
- if (lineStart != -1) {
- unsigned srcEnd = cf_html.find("\n", lineStart, false);
- unsigned srcStart = lineStart+srcURLStr.length();
- String rawSrcURL = cf_html.substring(srcStart, srcEnd-srcStart);
- replaceNBSPWithSpace(rawSrcURL);
- srcURL = rawSrcURL.stripWhiteSpace();
- }
-
- // find the markup between "<!--StartFragment -->" and "<!--EndFragment -->", accounting for browser quirks
- unsigned markupStart = cf_html.find("<html", 0, false);
- unsigned tagStart = cf_html.find("startfragment", markupStart, false);
- unsigned fragmentStart = cf_html.find('>', tagStart) + 1;
- unsigned tagEnd = cf_html.find("endfragment", fragmentStart, false);
- unsigned fragmentEnd = cf_html.reverseFind('<', tagEnd);
- String markup = cf_html.substring(fragmentStart, fragmentEnd - fragmentStart).stripWhiteSpace();
-
- return createFragmentFromMarkup(doc, markup, srcURL);
-}
-
-
-PassRefPtr<DocumentFragment> fragmentFromHTML(Document* doc, IDataObject* data)
-{
- if (!doc || !data)
- return 0;
-
- STGMEDIUM store;
- String html;
- String srcURL;
- if (SUCCEEDED(data->GetData(htmlFormat(), &store))) {
- //MS HTML Format parsing
- char* data = (char*)GlobalLock(store.hGlobal);
- SIZE_T dataSize = ::GlobalSize(store.hGlobal);
- String cf_html(UTF8Encoding().decode(data, dataSize));
- GlobalUnlock(store.hGlobal);
- ReleaseStgMedium(&store);
- if (PassRefPtr<DocumentFragment> fragment = fragmentFromCF_HTML(doc, cf_html))
- return fragment;
- }
- if (SUCCEEDED(data->GetData(texthtmlFormat(), &store))) {
- //raw html
- UChar* data = (UChar*)GlobalLock(store.hGlobal);
- html = String(data);
- GlobalUnlock(store.hGlobal);
- ReleaseStgMedium(&store);
- return createFragmentFromMarkup(doc, html, srcURL);
- }
-
- return 0;
-}
-
-bool containsHTML(IDataObject* data)
-{
- return SUCCEEDED(data->QueryGetData(texthtmlFormat())) || SUCCEEDED(data->QueryGetData(htmlFormat()));
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/win/ClipboardUtilitiesWin.h b/WebCore/platform/win/ClipboardUtilitiesWin.h
deleted file mode 100644
index a92a4bf..0000000
--- a/WebCore/platform/win/ClipboardUtilitiesWin.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ClipboardUtilitiesWin_h
-#define ClipboardUtilitiesWin_h
-
-#include "DragData.h"
-#include <windows.h>
-
-namespace WebCore {
-
-class Document;
-class KURL;
-class String;
-
-HGLOBAL createGlobalData(const String&);
-HGLOBAL createGlobalData(const Vector<char>&);
-HGLOBAL createGlobalData(const KURL& url, const String& title);
-
-FORMATETC* urlWFormat();
-FORMATETC* urlFormat();
-FORMATETC* plainTextWFormat();
-FORMATETC* plainTextFormat();
-FORMATETC* filenameWFormat();
-FORMATETC* filenameFormat();
-FORMATETC* htmlFormat();
-FORMATETC* cfHDropFormat();
-FORMATETC* smartPasteFormat();
-
-void markupToCF_HTML(const String& markup, const String& srcURL, Vector<char>& result);
-String urlToMarkup(const KURL& url, const String& title);
-
-void replaceNewlinesWithWindowsStyleNewlines(String&);
-void replaceNBSPWithSpace(String&);
-
-bool containsFilenames(const IDataObject*);
-bool containsHTML(IDataObject*);
-
-PassRefPtr<DocumentFragment> fragmentFromFilenames(Document*, const IDataObject*);
-PassRefPtr<DocumentFragment> fragmentFromHTML(Document*, IDataObject*);
-PassRefPtr<DocumentFragment> fragmentFromCF_HTML(Document*, const String& cf_html);
-
-String getURL(IDataObject*, bool& success, String* title = 0);
-String getPlainText(IDataObject*, bool& success);
-
-} // namespace WebCore
-
-#endif // ClipboardUtilitiesWin_h \ No newline at end of file
diff --git a/WebCore/platform/win/ClipboardWin.cpp b/WebCore/platform/win/ClipboardWin.cpp
deleted file mode 100644
index 129d881..0000000
--- a/WebCore/platform/win/ClipboardWin.cpp
+++ /dev/null
@@ -1,767 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ClipboardWin.h"
-
-#include "CString.h"
-#include "CachedImage.h"
-#include "ClipboardUtilitiesWin.h"
-#include "Document.h"
-#include "DragData.h"
-#include "Editor.h"
-#include "Element.h"
-#include "EventHandler.h"
-#include "Frame.h"
-#include "FrameLoader.h"
-#include "FrameView.h"
-#include "HTMLNames.h"
-#include "Image.h"
-#include "MIMETypeRegistry.h"
-#include "Page.h"
-#include "Pasteboard.h"
-#include "PlatformMouseEvent.h"
-#include "PlatformString.h"
-#include "Range.h"
-#include "RenderImage.h"
-#include "ResourceResponse.h"
-#include "StringHash.h"
-#include "WCDataObject.h"
-#include "csshelper.h"
-#include "markup.h"
-
-#include <shlwapi.h>
-#include <wininet.h>
-
-#include <wtf/RefPtr.h>
-
-using namespace std;
-
-namespace WebCore {
-
-using namespace HTMLNames;
-
-// format string for
-static const char szShellDotUrlTemplate[] = "[InternetShortcut]\r\nURL=%s\r\n";
-
-// We provide the IE clipboard types (URL and Text), and the clipboard types specified in the WHATWG Web Applications 1.0 draft
-// see http://www.whatwg.org/specs/web-apps/current-work/ Section 6.3.5.3
-
-enum ClipboardDataType { ClipboardDataTypeNone, ClipboardDataTypeURL, ClipboardDataTypeText };
-
-static ClipboardDataType clipboardTypeFromMIMEType(const String& type)
-{
- String qType = type.stripWhiteSpace().lower();
-
- // two special cases for IE compatibility
- if (qType == "text" || qType == "text/plain" || qType.startsWith("text/plain;"))
- return ClipboardDataTypeText;
- if (qType == "url" || qType == "text/uri-list")
- return ClipboardDataTypeURL;
-
- return ClipboardDataTypeNone;
-}
-
-static inline FORMATETC* fileDescriptorFormat()
-{
- static UINT cf = RegisterClipboardFormat(CFSTR_FILEDESCRIPTOR);
- static FORMATETC fileDescriptorFormat = {cf, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
- return &fileDescriptorFormat;
-}
-
-static inline FORMATETC* fileContentFormatZero()
-{
- static UINT cf = RegisterClipboardFormat(CFSTR_FILECONTENTS);
- static FORMATETC fileContentFormat = {cf, 0, DVASPECT_CONTENT, 0, TYMED_HGLOBAL};
- return &fileContentFormat;
-}
-
-static inline void pathRemoveBadFSCharacters(PWSTR psz, size_t length)
-{
- size_t writeTo = 0;
- size_t readFrom = 0;
- while (readFrom < length) {
- UINT type = PathGetCharType(psz[readFrom]);
- if (psz[readFrom] == 0 || type & (GCT_LFNCHAR | GCT_SHORTCHAR)) {
- psz[writeTo++] = psz[readFrom];
- }
-
- readFrom++;
- }
- psz[writeTo] = 0;
-}
-
-static String filesystemPathFromUrlOrTitle(const String& url, const String& title, TCHAR* extension, bool isLink)
-{
- bool usedURL = false;
- WCHAR fsPathBuffer[MAX_PATH + 1];
- fsPathBuffer[0] = 0;
- int extensionLen = extension ? lstrlen(extension) : 0;
-
- if (!title.isEmpty()) {
- size_t len = min<size_t>(title.length(), MAX_PATH - extensionLen);
- CopyMemory(fsPathBuffer, title.characters(), len * sizeof(UChar));
- fsPathBuffer[len] = 0;
- pathRemoveBadFSCharacters(fsPathBuffer, len);
- }
-
- if (!lstrlen(fsPathBuffer)) {
- DWORD len = MAX_PATH;
- String nullTermURL = url;
- usedURL = true;
- if (UrlIsFileUrl((LPCWSTR)nullTermURL.charactersWithNullTermination())
- && SUCCEEDED(PathCreateFromUrl((LPCWSTR)nullTermURL.charactersWithNullTermination(), fsPathBuffer, &len, 0))) {
- // When linking to a file URL we can trivially find the file name
- PWSTR fn = PathFindFileName(fsPathBuffer);
- if (fn && fn != fsPathBuffer)
- lstrcpyn(fsPathBuffer, fn, lstrlen(fn) + 1);
- } else {
- // The filename for any content based drag should be the last element of
- // the path. If we can't find it, or we're coming up with the name for a link
- // we just use the entire url.
- KURL kurl(url);
- String lastComponent;
- if (!isLink && !(lastComponent = kurl.lastPathComponent()).isEmpty()) {
- len = min<DWORD>(MAX_PATH, lastComponent.length());
- CopyMemory(fsPathBuffer, lastComponent.characters(), len * sizeof(UChar));
- } else {
- len = min<DWORD>(MAX_PATH, nullTermURL.length());
- CopyMemory(fsPathBuffer, nullTermURL.characters(), len * sizeof(UChar));
- }
- fsPathBuffer[len] = 0;
- pathRemoveBadFSCharacters(fsPathBuffer, len);
- }
- }
-
- if (!extension)
- return String((UChar*)fsPathBuffer);
-
- if (!isLink && usedURL) {
- PathRenameExtension(fsPathBuffer, extension);
- return String((UChar*)fsPathBuffer);
- }
-
- String result((UChar*)fsPathBuffer);
- result += String((UChar*)extension);
- return result;
-}
-
-static HGLOBAL createGlobalURLContent(const String& url, int estimatedFileSize)
-{
- HRESULT hr = S_OK;
- HGLOBAL memObj = 0;
-
- char* fileContents;
- char ansiUrl[INTERNET_MAX_URL_LENGTH + 1];
- // Used to generate the buffer. This is null terminated whereas the fileContents won't be.
- char contentGenerationBuffer[INTERNET_MAX_URL_LENGTH + ARRAYSIZE(szShellDotUrlTemplate) + 1];
-
- if (estimatedFileSize > 0 && estimatedFileSize > ARRAYSIZE(contentGenerationBuffer))
- return 0;
-
- int ansiUrlSize = ::WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)url.characters(), url.length(), ansiUrl, ARRAYSIZE(ansiUrl) - 1, 0, 0);
- if (!ansiUrlSize)
- return 0;
-
- ansiUrl[ansiUrlSize] = 0;
-
- int fileSize = (int) (ansiUrlSize+strlen(szShellDotUrlTemplate)-2); // -2 to remove the %s
- ASSERT(estimatedFileSize < 0 || fileSize == estimatedFileSize);
-
- memObj = GlobalAlloc(GPTR, fileSize);
- if (!memObj)
- return 0;
-
- fileContents = (PSTR)GlobalLock(memObj);
-
- sprintf_s(contentGenerationBuffer, ARRAYSIZE(contentGenerationBuffer), szShellDotUrlTemplate, ansiUrl);
- CopyMemory(fileContents, contentGenerationBuffer, fileSize);
-
- GlobalUnlock(memObj);
-
- return memObj;
-}
-
-static HGLOBAL createGlobalImageFileContent(SharedBuffer* data)
-{
- HGLOBAL memObj = GlobalAlloc(GPTR, data->size());
- if (!memObj)
- return 0;
-
- char* fileContents = (PSTR)GlobalLock(memObj);
-
- CopyMemory(fileContents, data->data(), data->size());
-
- GlobalUnlock(memObj);
-
- return memObj;
-}
-
-static HGLOBAL createGlobalHDropContent(const KURL& url, String& fileName, SharedBuffer* data)
-{
- if (fileName.isEmpty() || !data )
- return 0;
-
- WCHAR filePath[MAX_PATH];
-
- if (url.isLocalFile()) {
- String localPath = url.path();
- // windows does not enjoy a leading slash on paths
- if (localPath[0] == '/')
- localPath = localPath.substring(1);
- LPCTSTR localPathStr = localPath.charactersWithNullTermination();
- if (wcslen(localPathStr) + 1 < MAX_PATH)
- wcscpy_s(filePath, MAX_PATH, localPathStr);
- else
- return 0;
- } else {
- WCHAR tempPath[MAX_PATH];
- WCHAR extension[MAX_PATH];
- if (!::GetTempPath(ARRAYSIZE(tempPath), tempPath))
- return 0;
- if (!::PathAppend(tempPath, fileName.charactersWithNullTermination()))
- return 0;
- LPCWSTR foundExtension = ::PathFindExtension(tempPath);
- if (foundExtension) {
- if (wcscpy_s(extension, MAX_PATH, foundExtension))
- return 0;
- } else
- *extension = 0;
- ::PathRemoveExtension(tempPath);
- for (int i = 1; i < 10000; i++) {
- if (swprintf_s(filePath, MAX_PATH, TEXT("%s-%d%s"), tempPath, i, extension) == -1)
- return 0;
- if (!::PathFileExists(filePath))
- break;
- }
- HANDLE tempFileHandle = CreateFile(filePath, GENERIC_READ | GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
- if (tempFileHandle == INVALID_HANDLE_VALUE)
- return 0;
-
- // Write the data to this temp file.
- DWORD written;
- BOOL tempWriteSucceeded = WriteFile(tempFileHandle, data->data(), data->size(), &written, 0);
- CloseHandle(tempFileHandle);
- if (!tempWriteSucceeded)
- return 0;
- }
-
- SIZE_T dropFilesSize = sizeof(DROPFILES) + (sizeof(WCHAR) * (wcslen(filePath) + 2));
- HGLOBAL memObj = GlobalAlloc(GHND | GMEM_SHARE, dropFilesSize);
- if (!memObj)
- return 0;
-
- DROPFILES* dropFiles = (DROPFILES*) GlobalLock(memObj);
- dropFiles->pFiles = sizeof(DROPFILES);
- dropFiles->fWide = TRUE;
- wcscpy((LPWSTR)(dropFiles + 1), filePath);
- GlobalUnlock(memObj);
-
- return memObj;
-}
-
-static HGLOBAL createGlobalUrlFileDescriptor(const String& url, const String& title, int& /*out*/ estimatedSize)
-{
- HRESULT hr = S_OK;
- HGLOBAL memObj = 0;
- String fsPath;
- memObj = GlobalAlloc(GPTR, sizeof(FILEGROUPDESCRIPTOR));
- if (!memObj)
- return 0;
-
- FILEGROUPDESCRIPTOR* fgd = (FILEGROUPDESCRIPTOR*)GlobalLock(memObj);
- memset(fgd, 0, sizeof(FILEGROUPDESCRIPTOR));
- fgd->cItems = 1;
- fgd->fgd[0].dwFlags = FD_FILESIZE;
- int fileSize = ::WideCharToMultiByte(CP_ACP, 0, url.characters(), url.length(), 0, 0, 0, 0);
- fileSize += strlen(szShellDotUrlTemplate) - 2; // -2 is for getting rid of %s in the template string
- fgd->fgd[0].nFileSizeLow = fileSize;
- estimatedSize = fileSize;
- fsPath = filesystemPathFromUrlOrTitle(url, title, L".URL", true);
-
- if (fsPath.length() <= 0) {
- GlobalUnlock(memObj);
- GlobalFree(memObj);
- return 0;
- }
-
- int maxSize = min(fsPath.length(), ARRAYSIZE(fgd->fgd[0].cFileName));
- CopyMemory(fgd->fgd[0].cFileName, (LPCWSTR)fsPath.characters(), maxSize * sizeof(UChar));
- GlobalUnlock(memObj);
-
- return memObj;
-}
-
-
-static HGLOBAL createGlobalImageFileDescriptor(const String& url, const String& title, CachedImage* image)
-{
- ASSERT_ARG(image, image);
- ASSERT(image->image()->data());
-
- HRESULT hr = S_OK;
- HGLOBAL memObj = 0;
- String fsPath;
- memObj = GlobalAlloc(GPTR, sizeof(FILEGROUPDESCRIPTOR));
- if (!memObj)
- return 0;
-
- FILEGROUPDESCRIPTOR* fgd = (FILEGROUPDESCRIPTOR*)GlobalLock(memObj);
- memset(fgd, 0, sizeof(FILEGROUPDESCRIPTOR));
- fgd->cItems = 1;
- fgd->fgd[0].dwFlags = FD_FILESIZE;
- fgd->fgd[0].nFileSizeLow = image->image()->data()->size();
-
- String extension(".");
- extension += WebCore::MIMETypeRegistry::getPreferredExtensionForMIMEType(image->response().mimeType());
- const String& preferredTitle = title.isEmpty() ? image->response().suggestedFilename() : title;
- fsPath = filesystemPathFromUrlOrTitle(url, preferredTitle, extension.length() ? (TCHAR*)extension.charactersWithNullTermination() : 0, false);
-
- if (fsPath.length() <= 0) {
- GlobalUnlock(memObj);
- GlobalFree(memObj);
- return 0;
- }
-
- int maxSize = min(fsPath.length(), ARRAYSIZE(fgd->fgd[0].cFileName));
- CopyMemory(fgd->fgd[0].cFileName, (LPCWSTR)fsPath.characters(), maxSize * sizeof(UChar));
- GlobalUnlock(memObj);
-
- return memObj;
-}
-
-
-// writeFileToDataObject takes ownership of fileDescriptor and fileContent
-static HRESULT writeFileToDataObject(IDataObject* dataObject, HGLOBAL fileDescriptor, HGLOBAL fileContent, HGLOBAL hDropContent)
-{
- HRESULT hr = S_OK;
- FORMATETC* fe;
- STGMEDIUM medium = {0};
- medium.tymed = TYMED_HGLOBAL;
-
- if (!fileDescriptor || !fileContent)
- goto exit;
-
- // Descriptor
- fe = fileDescriptorFormat();
-
- medium.hGlobal = fileDescriptor;
-
- if (FAILED(hr = dataObject->SetData(fe, &medium, TRUE)))
- goto exit;
-
- // Contents
- fe = fileContentFormatZero();
- medium.hGlobal = fileContent;
- if (FAILED(hr = dataObject->SetData(fe, &medium, TRUE)))
- goto exit;
-
- // HDROP
- if (hDropContent) {
- medium.hGlobal = hDropContent;
- hr = dataObject->SetData(cfHDropFormat(), &medium, TRUE);
- }
-
-exit:
- if (FAILED(hr)) {
- if (fileDescriptor)
- GlobalFree(fileDescriptor);
- if (fileContent)
- GlobalFree(fileContent);
- if (hDropContent)
- GlobalFree(hDropContent);
- }
- return hr;
-}
-
-ClipboardWin::ClipboardWin(bool isForDragging, IDataObject* dataObject, ClipboardAccessPolicy policy)
- : Clipboard(policy, isForDragging)
- , m_dataObject(dataObject)
- , m_writableDataObject(0)
-{
-}
-
-ClipboardWin::ClipboardWin(bool isForDragging, WCDataObject* dataObject, ClipboardAccessPolicy policy)
- : Clipboard(policy, isForDragging)
- , m_dataObject(dataObject)
- , m_writableDataObject(dataObject)
-{
-}
-
-ClipboardWin::~ClipboardWin()
-{
-}
-
-static bool writeURL(WCDataObject *data, const KURL& url, String title, bool withPlainText, bool withHTML)
-{
- ASSERT(data);
-
- if (url.isEmpty())
- return false;
-
- if (title.isEmpty()) {
- title = url.lastPathComponent();
- if (title.isEmpty())
- title = url.host();
- }
-
- STGMEDIUM medium = {0};
- medium.tymed = TYMED_HGLOBAL;
-
- medium.hGlobal = createGlobalData(url, title);
- bool success = false;
- if (medium.hGlobal && FAILED(data->SetData(urlWFormat(), &medium, TRUE)))
- ::GlobalFree(medium.hGlobal);
- else
- success = true;
-
- if (withHTML) {
- Vector<char> cfhtmlData;
- markupToCF_HTML(urlToMarkup(url, title), "", cfhtmlData);
- medium.hGlobal = createGlobalData(cfhtmlData);
- if (medium.hGlobal && FAILED(data->SetData(htmlFormat(), &medium, TRUE)))
- ::GlobalFree(medium.hGlobal);
- else
- success = true;
- }
-
- if (withPlainText) {
- medium.hGlobal = createGlobalData(url.string());
- if (medium.hGlobal && FAILED(data->SetData(plainTextWFormat(), &medium, TRUE)))
- ::GlobalFree(medium.hGlobal);
- else
- success = true;
- }
-
- return success;
-}
-
-void ClipboardWin::clearData(const String& type)
-{
- //FIXME: Need to be able to write to the system clipboard <rdar://problem/5015941>
- ASSERT(isForDragging());
- if (policy() != ClipboardWritable || !m_writableDataObject)
- return;
-
- ClipboardDataType dataType = clipboardTypeFromMIMEType(type);
-
- if (dataType == ClipboardDataTypeURL) {
- m_writableDataObject->clearData(urlWFormat()->cfFormat);
- m_writableDataObject->clearData(urlFormat()->cfFormat);
- }
- if (dataType == ClipboardDataTypeText) {
- m_writableDataObject->clearData(plainTextFormat()->cfFormat);
- m_writableDataObject->clearData(plainTextWFormat()->cfFormat);
- }
-
-}
-
-void ClipboardWin::clearAllData()
-{
- //FIXME: Need to be able to write to the system clipboard <rdar://problem/5015941>
- ASSERT(isForDragging());
- if (policy() != ClipboardWritable)
- return;
-
- m_writableDataObject = 0;
- WCDataObject::createInstance(&m_writableDataObject);
- m_dataObject = m_writableDataObject;
-}
-
-String ClipboardWin::getData(const String& type, bool& success) const
-{
- success = false;
- if (policy() != ClipboardReadable || !m_dataObject) {
- return "";
- }
-
- ClipboardDataType dataType = clipboardTypeFromMIMEType(type);
- if (dataType == ClipboardDataTypeText)
- return getPlainText(m_dataObject.get(), success);
- else if (dataType == ClipboardDataTypeURL)
- return getURL(m_dataObject.get(), success);
-
- return "";
-}
-
-bool ClipboardWin::setData(const String& type, const String& data)
-{
- // FIXME: Need to be able to write to the system clipboard <rdar://problem/5015941>
- ASSERT(isForDragging());
- if (policy() != ClipboardWritable || !m_writableDataObject)
- return false;
-
- ClipboardDataType winType = clipboardTypeFromMIMEType(type);
-
- if (winType == ClipboardDataTypeURL)
- return WebCore::writeURL(m_writableDataObject.get(), KURL(data), String(), false, true);
-
- if (winType == ClipboardDataTypeText) {
- STGMEDIUM medium = {0};
- medium.tymed = TYMED_HGLOBAL;
- medium.hGlobal = createGlobalData(data);
- if (!medium.hGlobal)
- return false;
-
- if (FAILED(m_writableDataObject->SetData(plainTextWFormat(), &medium, TRUE))) {
- ::GlobalFree(medium.hGlobal);
- return false;
- }
- return true;
- }
-
- return false;
-}
-
-static void addMimeTypesForFormat(HashSet<String>& results, FORMATETC& format)
-{
- // URL and Text are provided for compatibility with IE's model
- if (format.cfFormat == urlFormat()->cfFormat || format.cfFormat == urlWFormat()->cfFormat) {
- results.add("URL");
- results.add("text/uri-list");
- }
-
- if (format.cfFormat == plainTextWFormat()->cfFormat || format.cfFormat == plainTextFormat()->cfFormat) {
- results.add("Text");
- results.add("text/plain");
- }
-}
-
-// extensions beyond IE's API
-HashSet<String> ClipboardWin::types() const
-{
- HashSet<String> results;
- if (policy() != ClipboardReadable && policy() != ClipboardTypesReadable)
- return results;
-
- if (!m_dataObject)
- return results;
-
- COMPtr<IEnumFORMATETC> itr;
-
- if (FAILED(m_dataObject->EnumFormatEtc(0, &itr)))
- return results;
-
- if (!itr)
- return results;
-
- FORMATETC data;
-
- while (SUCCEEDED(itr->Next(1, &data, 0))) {
- addMimeTypesForFormat(results, data);
- }
-
- return results;
-}
-
-void ClipboardWin::setDragImage(CachedImage* image, Node *node, const IntPoint &loc)
-{
- if (policy() != ClipboardImageWritable && policy() != ClipboardWritable)
- return;
-
- if (m_dragImage)
- m_dragImage->removeClient(this);
- m_dragImage = image;
- if (m_dragImage)
- m_dragImage->addClient(this);
-
- m_dragLoc = loc;
- m_dragImageElement = node;
-}
-
-void ClipboardWin::setDragImage(CachedImage* img, const IntPoint &loc)
-{
- setDragImage(img, 0, loc);
-}
-
-void ClipboardWin::setDragImageElement(Node *node, const IntPoint &loc)
-{
- setDragImage(0, node, loc);
-}
-
-DragImageRef ClipboardWin::createDragImage(IntPoint& loc) const
-{
- HBITMAP result = 0;
- //FIXME: Need to be able to draw element <rdar://problem/5015942>
- if (m_dragImage) {
- result = createDragImageFromImage(m_dragImage->image());
- loc = m_dragLoc;
- }
- return result;
-}
-
-static String imageToMarkup(const String& url)
-{
- String markup("<img src=\"");
- markup.append(url);
- markup.append("\"/>");
- return markup;
-}
-
-static CachedImage* getCachedImage(Element* element)
-{
- // Attempt to pull CachedImage from element
- ASSERT(element);
- RenderObject* renderer = element->renderer();
- if (!renderer || !renderer->isImage())
- return 0;
-
- RenderImage* image = static_cast<RenderImage*>(renderer);
- if (image->cachedImage() && !image->cachedImage()->errorOccurred())
- return image->cachedImage();
-
- return 0;
-}
-
-static void writeImageToDataObject(IDataObject* dataObject, Element* element, const KURL& url)
-{
- // Shove image data into a DataObject for use as a file
- CachedImage* cachedImage = getCachedImage(element);
- if (!cachedImage || !cachedImage->image() || !cachedImage->isLoaded())
- return;
-
- SharedBuffer* imageBuffer = cachedImage->image()->data();
- if (!imageBuffer || !imageBuffer->size())
- return;
-
- HGLOBAL imageFileDescriptor = createGlobalImageFileDescriptor(url.string(), element->getAttribute(altAttr), cachedImage);
- if (!imageFileDescriptor)
- return;
-
- HGLOBAL imageFileContent = createGlobalImageFileContent(imageBuffer);
- if (!imageFileContent) {
- GlobalFree(imageFileDescriptor);
- return;
- }
-
- String fileName = cachedImage->response().suggestedFilename();
- HGLOBAL hDropContent = createGlobalHDropContent(url, fileName, imageBuffer);
- if (!hDropContent) {
- GlobalFree(hDropContent);
- return;
- }
-
- writeFileToDataObject(dataObject, imageFileDescriptor, imageFileContent, hDropContent);
-}
-
-void ClipboardWin::declareAndWriteDragImage(Element* element, const KURL& url, const String& title, Frame* frame)
-{
- // Order is important here for Explorer's sake
- if (!m_writableDataObject)
- return;
- WebCore::writeURL(m_writableDataObject.get(), url, title, true, false);
-
- writeImageToDataObject(m_writableDataObject.get(), element, url);
-
- AtomicString imageURL = element->getAttribute(srcAttr);
- if (imageURL.isEmpty())
- return;
-
- String fullURL = frame->document()->completeURL(parseURL(imageURL)).string();
- if (fullURL.isEmpty())
- return;
- STGMEDIUM medium = {0};
- medium.tymed = TYMED_HGLOBAL;
- ExceptionCode ec = 0;
-
- // Put img tag on the clipboard referencing the image
- Vector<char> data;
- markupToCF_HTML(imageToMarkup(fullURL), "", data);
- medium.hGlobal = createGlobalData(data);
- if (medium.hGlobal && FAILED(m_writableDataObject->SetData(htmlFormat(), &medium, TRUE)))
- ::GlobalFree(medium.hGlobal);
-}
-
-void ClipboardWin::writeURL(const KURL& kurl, const String& titleStr, Frame*)
-{
- if (!m_writableDataObject)
- return;
- WebCore::writeURL(m_writableDataObject.get(), kurl, titleStr, true, true);
-
- int estimatedSize = 0;
- String url = kurl.string();
-
- HGLOBAL urlFileDescriptor = createGlobalUrlFileDescriptor(url, titleStr, estimatedSize);
- if (!urlFileDescriptor)
- return;
- HGLOBAL urlFileContent = createGlobalURLContent(url, estimatedSize);
- if (!urlFileContent) {
- GlobalFree(urlFileDescriptor);
- return;
- }
- writeFileToDataObject(m_writableDataObject.get(), urlFileDescriptor, urlFileContent, 0);
-}
-
-void ClipboardWin::writeRange(Range* selectedRange, Frame* frame)
-{
- ASSERT(selectedRange);
- if (!m_writableDataObject)
- return;
-
- STGMEDIUM medium = {0};
- medium.tymed = TYMED_HGLOBAL;
- ExceptionCode ec = 0;
-
- Vector<char> data;
- markupToCF_HTML(createMarkup(selectedRange, 0, AnnotateForInterchange),
- selectedRange->startContainer(ec)->document()->url().string(), data);
- medium.hGlobal = createGlobalData(data);
- if (medium.hGlobal && FAILED(m_writableDataObject->SetData(htmlFormat(), &medium, TRUE)))
- ::GlobalFree(medium.hGlobal);
-
- String str = frame->selectedText();
- replaceNewlinesWithWindowsStyleNewlines(str);
- replaceNBSPWithSpace(str);
- medium.hGlobal = createGlobalData(str);
- if (medium.hGlobal && FAILED(m_writableDataObject->SetData(plainTextWFormat(), &medium, TRUE)))
- ::GlobalFree(medium.hGlobal);
-
- medium.hGlobal = 0;
- if (frame->editor()->canSmartCopyOrDelete())
- m_writableDataObject->SetData(smartPasteFormat(), &medium, TRUE);
-}
-
-bool ClipboardWin::hasData()
-{
- if (!m_dataObject)
- return false;
-
- COMPtr<IEnumFORMATETC> itr;
- if (FAILED(m_dataObject->EnumFormatEtc(0, &itr)))
- return false;
-
- if (!itr)
- return false;
-
- FORMATETC data;
-
- if (SUCCEEDED(itr->Next(1, &data, 0))) {
- // There is at least one item in the IDataObject
- return true;
- }
-
- return false;
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/win/ClipboardWin.h b/WebCore/platform/win/ClipboardWin.h
deleted file mode 100644
index 01f7332..0000000
--- a/WebCore/platform/win/ClipboardWin.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ClipboardWin_h
-#define ClipboardWin_h
-
-#include "CachedResourceClient.h"
-#include "Clipboard.h"
-#include "COMPtr.h"
-
-struct IDataObject;
-
-namespace WebCore {
-
- class CachedImage;
- class IntPoint;
- class WCDataObject;
-
- // State available during IE's events for drag and drop and copy/paste
- class ClipboardWin : public Clipboard, public CachedResourceClient {
- public:
- static PassRefPtr<ClipboardWin> create(bool isForDragging, IDataObject* dataObject, ClipboardAccessPolicy policy)
- {
- return adoptRef(new ClipboardWin(isForDragging, dataObject, policy));
- }
- static PassRefPtr<ClipboardWin> create(bool isForDragging, WCDataObject* dataObject, ClipboardAccessPolicy policy)
- {
- return adoptRef(new ClipboardWin(isForDragging, dataObject, policy));
- }
- ~ClipboardWin();
-
- void clearData(const String& type);
- void clearAllData();
- String getData(const String& type, bool& success) const;
- bool setData(const String& type, const String& data);
-
- // extensions beyond IE's API
- HashSet<String> types() const;
-
- void setDragImage(CachedImage*, const IntPoint&);
- void setDragImageElement(Node*, const IntPoint&);
-
- virtual DragImageRef createDragImage(IntPoint& dragLoc) const;
- virtual void declareAndWriteDragImage(Element*, const KURL&, const String& title, Frame*);
- virtual void writeURL(const KURL&, const String&, Frame*);
- virtual void writeRange(Range*, Frame*);
-
- virtual bool hasData();
-
- COMPtr<IDataObject> dataObject() { return m_dataObject; }
-
- private:
- ClipboardWin(bool isForDragging, IDataObject*, ClipboardAccessPolicy);
- ClipboardWin(bool isForDragging, WCDataObject*, ClipboardAccessPolicy);
-
- void resetFromClipboard();
- void setDragImage(CachedImage*, Node*, const IntPoint&);
-
- COMPtr<IDataObject> m_dataObject;
- COMPtr<WCDataObject> m_writableDataObject;
- Frame* m_frame;
- };
-
-} // namespace WebCore
-
-#endif // ClipboardWin_h
diff --git a/WebCore/platform/win/ContextMenuItemWin.cpp b/WebCore/platform/win/ContextMenuItemWin.cpp
deleted file mode 100644
index bd10c91..0000000
--- a/WebCore/platform/win/ContextMenuItemWin.cpp
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ContextMenuItem.h"
-
-#include "ContextMenu.h"
-
-#include "CString.h"
-#include <windows.h>
-
-namespace WebCore {
-
-ContextMenuItem::ContextMenuItem(LPMENUITEMINFO item)
- : m_platformDescription(item)
-{
-}
-
-ContextMenuItem::ContextMenuItem(ContextMenu* subMenu)
-{
- m_platformDescription = (LPMENUITEMINFO)malloc(sizeof(MENUITEMINFO));
- if (!m_platformDescription)
- return;
-
- memset(m_platformDescription, 0, sizeof(MENUITEMINFO));
- m_platformDescription->cbSize = sizeof(MENUITEMINFO);
-
- m_platformDescription->wID = ContextMenuItemTagNoAction;
- if (subMenu) {
- m_platformDescription->fMask |= MIIM_SUBMENU;
- m_platformDescription->hSubMenu = subMenu->platformDescription();
- }
-}
-
-ContextMenuItem::ContextMenuItem(ContextMenuItemType type, ContextMenuAction action, const String& title, ContextMenu* subMenu)
-{
- m_platformDescription = (LPMENUITEMINFO)malloc(sizeof(MENUITEMINFO));
- if (!m_platformDescription)
- return;
-
- memset(m_platformDescription, 0, sizeof(MENUITEMINFO));
- m_platformDescription->cbSize = sizeof(MENUITEMINFO);
- m_platformDescription->fMask = MIIM_FTYPE;
-
- if (type == SeparatorType) {
- m_platformDescription->fType = MFT_SEPARATOR;
- return;
- }
-
- if (subMenu) {
- m_platformDescription->fMask |= MIIM_STRING | MIIM_SUBMENU;
- m_platformDescription->hSubMenu = subMenu->platformDescription();
- } else
- m_platformDescription->fMask |= MIIM_STRING | MIIM_ID;
-
- m_platformDescription->fType = MFT_STRING;
- m_platformDescription->wID = action;
-
- String t = title;
- m_platformDescription->cch = t.length();
- m_platformDescription->dwTypeData = wcsdup(t.charactersWithNullTermination());
-}
-
-ContextMenuItem::~ContextMenuItem()
-{
- if (m_platformDescription) {
- if (m_platformDescription->fType == MFT_STRING)
- free(m_platformDescription->dwTypeData);
- free(m_platformDescription);
- }
-}
-
-LPMENUITEMINFO ContextMenuItem::releasePlatformDescription()
-{
- LPMENUITEMINFO info = m_platformDescription;
- m_platformDescription = 0;
- return info;
-}
-
-ContextMenuItemType ContextMenuItem::type() const
-{
- ContextMenuItemType type = ActionType;
-
- if ((m_platformDescription->fType & MFT_STRING) && m_platformDescription->hSubMenu)
- type = SubmenuType;
- else if (m_platformDescription->fType & MFT_SEPARATOR)
- type = SeparatorType;
-
- return type;
-}
-
-ContextMenuAction ContextMenuItem::action() const
-{
- return static_cast<ContextMenuAction>(m_platformDescription->wID);
-}
-
-String ContextMenuItem::title() const
-{
- return String(m_platformDescription->dwTypeData, wcslen(m_platformDescription->dwTypeData));
-}
-
-PlatformMenuDescription ContextMenuItem::platformSubMenu() const
-{
- return m_platformDescription->hSubMenu;
-}
-
-void ContextMenuItem::setType(ContextMenuItemType type)
-{
- if (type == SeparatorType)
- m_platformDescription->fType = MFT_SEPARATOR;
- else
- m_platformDescription->fType = MFT_STRING;
-}
-
-void ContextMenuItem::setAction(ContextMenuAction action)
-{
- m_platformDescription->wID = action;
-}
-
-void ContextMenuItem::setTitle(const String& title)
-{
- if (m_platformDescription->dwTypeData)
- free(m_platformDescription->dwTypeData);
-
- m_platformDescription->cch = title.length();
- String titleCopy = title;
- m_platformDescription->dwTypeData = wcsdup(titleCopy.charactersWithNullTermination());
-}
-
-void ContextMenuItem::setSubMenu(ContextMenu* subMenu)
-{
- if (subMenu->platformDescription() == m_platformDescription->hSubMenu)
- return;
-
- if (m_platformDescription->hSubMenu)
- ::DestroyMenu(m_platformDescription->hSubMenu);
-
- m_platformDescription->fMask |= MIIM_SUBMENU;
- m_platformDescription->hSubMenu = subMenu->releasePlatformDescription();
-}
-
-void ContextMenuItem::setChecked(bool checked)
-{
- m_platformDescription->fMask |= MIIM_STATE;
- if (checked) {
- m_platformDescription->fState &= ~MFS_UNCHECKED;
- m_platformDescription->fState |= MFS_CHECKED;
- } else {
- m_platformDescription->fState &= ~MFS_CHECKED;
- m_platformDescription->fState |= MFS_UNCHECKED;
- }
-}
-
-void ContextMenuItem::setEnabled(bool enabled)
-{
- m_platformDescription->fMask |= MIIM_STATE;
- if (enabled) {
- m_platformDescription->fState &= ~MFS_DISABLED;
- m_platformDescription->fState |= MFS_ENABLED;
- } else {
- m_platformDescription->fState &= ~MFS_ENABLED;
- m_platformDescription->fState |= MFS_DISABLED;
- }
-}
-
-bool ContextMenuItem::enabled() const
-{
- return m_platformDescription->fState & MFS_ENABLED;
-}
-
-}
diff --git a/WebCore/platform/win/ContextMenuWin.cpp b/WebCore/platform/win/ContextMenuWin.cpp
deleted file mode 100644
index 26b081a..0000000
--- a/WebCore/platform/win/ContextMenuWin.cpp
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ContextMenu.h"
-
-#include "CString.h"
-#include "Document.h"
-#include "Frame.h"
-#include "FrameView.h"
-#include "Node.h"
-#include <tchar.h>
-#include <windows.h>
-
-namespace WebCore {
-
-ContextMenu::ContextMenu(const HitTestResult& result)
- : m_hitTestResult(result)
- , m_platformDescription(0)
-{
- setPlatformDescription(::CreatePopupMenu());
-}
-
-ContextMenu::ContextMenu(const HitTestResult& result, const PlatformMenuDescription menu)
- : m_hitTestResult(result)
- , m_platformDescription(0)
-{
- setPlatformDescription(menu);
-}
-
-ContextMenu::~ContextMenu()
-{
- if (m_platformDescription)
- ::DestroyMenu(m_platformDescription);
-}
-
-unsigned ContextMenu::itemCount() const
-{
- if (!m_platformDescription)
- return 0;
-
- return ::GetMenuItemCount(m_platformDescription);
-}
-
-void ContextMenu::insertItem(unsigned int position, ContextMenuItem& item)
-{
- if (!m_platformDescription)
- return;
-
- checkOrEnableIfNeeded(item);
- ::InsertMenuItem(m_platformDescription, position, TRUE, item.releasePlatformDescription());
-}
-
-void ContextMenu::appendItem(ContextMenuItem& item)
-{
- insertItem(itemCount(), item);
-}
-
-static ContextMenuItem* contextMenuItemByIdOrPosition(HMENU menu, unsigned id, BOOL byPosition)
-{
- if (!menu)
- return 0;
- LPMENUITEMINFO info = (LPMENUITEMINFO)malloc(sizeof(MENUITEMINFO));
- if (!info)
- return 0;
-
- memset(info, 0, sizeof(MENUITEMINFO));
-
- info->cbSize = sizeof(MENUITEMINFO);
-
- info->fMask = MIIM_FTYPE | MIIM_ID | MIIM_STRING;
-
- if (!::GetMenuItemInfo(menu, id, byPosition, info)) {
- free(info);
- return 0;
- }
-
- UINT type = info->fType & ~(MFT_MENUBARBREAK | MFT_MENUBREAK | MFT_OWNERDRAW | MFT_RADIOCHECK | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY);
- if (type == MFT_STRING) {
- LPTSTR buffer = (LPTSTR)malloc(++info->cch * sizeof(TCHAR));
- if (!buffer) {
- free(info);
- return 0;
- }
- info->dwTypeData = buffer;
- ::GetMenuItemInfo(menu, id, byPosition, info);
- }
-
- return new ContextMenuItem(info);
-}
-
-ContextMenuItem* ContextMenu::itemWithAction(unsigned action)
-{
- return contextMenuItemByIdOrPosition(m_platformDescription, action, FALSE);
-}
-
-ContextMenuItem* ContextMenu::itemAtIndex(unsigned index, const PlatformMenuDescription platformDescription)
-{
- return contextMenuItemByIdOrPosition(platformDescription, index, TRUE);
-}
-
-void ContextMenu::setPlatformDescription(HMENU menu)
-{
- if (menu == m_platformDescription)
- return;
-
- if (m_platformDescription)
- ::DestroyMenu(m_platformDescription);
-
- m_platformDescription = menu;
- if (!m_platformDescription)
- return;
-
- MENUINFO menuInfo = {0};
- menuInfo.cbSize = sizeof(MENUINFO);
- menuInfo.fMask = MIM_STYLE;
- ::GetMenuInfo(m_platformDescription, &menuInfo);
- menuInfo.fMask = MIM_STYLE;
- menuInfo.dwStyle |= MNS_NOTIFYBYPOS;
- ::SetMenuInfo(m_platformDescription, &menuInfo);
-}
-
-HMENU ContextMenu::platformDescription() const
-{
- return m_platformDescription;
-}
-
-HMENU ContextMenu::releasePlatformDescription()
-{
- HMENU description = m_platformDescription;
- m_platformDescription = 0;
- return description;
-}
-
-}
diff --git a/WebCore/platform/win/CursorWin.cpp b/WebCore/platform/win/CursorWin.cpp
deleted file mode 100644
index e91e86b..0000000
--- a/WebCore/platform/win/CursorWin.cpp
+++ /dev/null
@@ -1,415 +0,0 @@
-/*
- * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Cursor.h"
-
-#include "Image.h"
-#include "IntPoint.h"
-
-#include <wtf/OwnPtr.h>
-
-#include <windows.h>
-
-#define ALPHA_CURSORS
-
-namespace WebCore {
-
-Cursor::Cursor(const Cursor& other)
- : m_impl(other.m_impl)
-{
-}
-
-static inline bool supportsAlphaCursors()
-{
- OSVERSIONINFO osinfo = {0};
- osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
- GetVersionEx(&osinfo);
- return osinfo.dwMajorVersion > 5 || (osinfo.dwMajorVersion == 5 && osinfo.dwMinorVersion > 0);
-}
-
-Cursor::Cursor(Image* img, const IntPoint& hotspot)
-{
- static bool doAlpha = supportsAlphaCursors();
- BITMAPINFO cursorImage = {0};
- cursorImage.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- cursorImage.bmiHeader.biWidth = img->width();
- cursorImage.bmiHeader.biHeight = img->height();
- cursorImage.bmiHeader.biPlanes = 1;
- cursorImage.bmiHeader.biBitCount = 32;
- cursorImage.bmiHeader.biCompression = BI_RGB;
- HDC dc = GetDC(0);
- HDC workingDC = CreateCompatibleDC(dc);
- if (doAlpha) {
- OwnPtr<HBITMAP> hCursor(CreateDIBSection(dc, (BITMAPINFO *)&cursorImage, DIB_RGB_COLORS, 0, 0, 0));
- ASSERT(hCursor);
-
- img->getHBITMAP(hCursor.get());
- HBITMAP hOldBitmap = (HBITMAP)SelectObject(workingDC, hCursor.get());
- SetBkMode(workingDC, TRANSPARENT);
- SelectObject(workingDC, hOldBitmap);
-
- Vector<unsigned char, 128> maskBits;
- maskBits.fill(0xff, (img->width() + 7) / 8 * img->height());
- OwnPtr<HBITMAP> hMask(CreateBitmap(img->width(), img->height(), 1, 1, maskBits.data()));
-
- ICONINFO ii;
- ii.fIcon = FALSE;
- ii.xHotspot = hotspot.x();
- ii.yHotspot = hotspot.y();
- ii.hbmMask = hMask.get();
- ii.hbmColor = hCursor.get();
-
- m_impl = SharedCursor::create(CreateIconIndirect(&ii));
- } else {
- // Platform doesn't support alpha blended cursors, so we need
- // to create the mask manually
- HDC andMaskDC = CreateCompatibleDC(dc);
- HDC xorMaskDC = CreateCompatibleDC(dc);
- OwnPtr<HBITMAP> hCursor(CreateDIBSection(dc, &cursorImage, DIB_RGB_COLORS, 0, 0, 0));
- ASSERT(hCursor);
- img->getHBITMAP(hCursor.get());
- BITMAP cursor;
- GetObject(hCursor.get(), sizeof(BITMAP), &cursor);
- OwnPtr<HBITMAP> andMask(CreateBitmap(cursor.bmWidth, cursor.bmHeight, 1, 1, NULL));
- OwnPtr<HBITMAP> xorMask(CreateCompatibleBitmap(dc, cursor.bmWidth, cursor.bmHeight));
- HBITMAP oldCursor = (HBITMAP)SelectObject(workingDC, hCursor.get());
- HBITMAP oldAndMask = (HBITMAP)SelectObject(andMaskDC, andMask.get());
- HBITMAP oldXorMask = (HBITMAP)SelectObject(xorMaskDC, xorMask.get());
-
- SetBkColor(workingDC, RGB(0,0,0));
- BitBlt(andMaskDC, 0, 0, cursor.bmWidth, cursor.bmHeight, workingDC, 0, 0, SRCCOPY);
-
- SetBkColor(xorMaskDC, RGB(255, 255, 255));
- SetTextColor(xorMaskDC, RGB(255, 255, 255));
- BitBlt(xorMaskDC, 0, 0, cursor.bmWidth, cursor.bmHeight, andMaskDC, 0, 0, SRCCOPY);
- BitBlt(xorMaskDC, 0, 0, cursor.bmWidth, cursor.bmHeight, workingDC, 0,0, SRCAND);
-
- SelectObject(workingDC, oldCursor);
- SelectObject(andMaskDC, oldAndMask);
- SelectObject(xorMaskDC, oldXorMask);
-
- ICONINFO icon = {0};
- icon.fIcon = FALSE;
- icon.xHotspot = hotspot.x();
- icon.yHotspot = hotspot.y();
- icon.hbmMask = andMask.get();
- icon.hbmColor = xorMask.get();
- m_impl = SharedCursor::create(CreateIconIndirect(&icon));
-
- DeleteDC(xorMaskDC);
- DeleteDC(andMaskDC);
- }
- DeleteDC(workingDC);
- ReleaseDC(0, dc);
-}
-
-Cursor::~Cursor()
-{
-}
-
-Cursor& Cursor::operator=(const Cursor& other)
-{
- m_impl = other.m_impl;
- return *this;
-}
-
-Cursor::Cursor(PlatformCursor c)
- : m_impl(c)
-{
-}
-
-static Cursor loadCursorByName(char* name, int x, int y)
-{
- IntPoint hotSpot(x, y);
- Cursor c;
- RefPtr<Image> cursorImage(Image::loadPlatformResource(name));
- if (cursorImage && !cursorImage->isNull())
- c = Cursor(cursorImage.get(), hotSpot);
- else
- c = pointerCursor();
- return c;
-}
-
-static PassRefPtr<SharedCursor> loadSharedCursor(HINSTANCE hInstance, LPCTSTR lpCursorName)
-{
- return SharedCursor::create(LoadCursor(hInstance, lpCursorName));
-}
-
-const Cursor& pointerCursor()
-{
- static Cursor c = loadSharedCursor(0, IDC_ARROW);
- return c;
-}
-
-const Cursor& crossCursor()
-{
- static Cursor c = loadSharedCursor(0, IDC_CROSS);
- return c;
-}
-
-const Cursor& handCursor()
-{
- static Cursor c = loadSharedCursor(0, IDC_HAND);
- return c;
-}
-
-const Cursor& iBeamCursor()
-{
- static Cursor c = loadSharedCursor(0, IDC_IBEAM);
- return c;
-}
-
-const Cursor& waitCursor()
-{
- static Cursor c = loadSharedCursor(0, IDC_WAIT);
- return c;
-}
-
-const Cursor& helpCursor()
-{
- static Cursor c = loadSharedCursor(0, IDC_HELP);
- return c;
-}
-
-const Cursor& eastResizeCursor()
-{
- static Cursor c = loadSharedCursor(0, IDC_SIZEWE);
- return c;
-}
-
-const Cursor& northResizeCursor()
-{
- static Cursor c = loadSharedCursor(0, IDC_SIZENS);
- return c;
-}
-
-const Cursor& northEastResizeCursor()
-{
- static Cursor c = loadSharedCursor(0, IDC_SIZENESW);
- return c;
-}
-
-const Cursor& northWestResizeCursor()
-{
- static Cursor c = loadSharedCursor(0, IDC_SIZENWSE);
- return c;
-}
-
-const Cursor& southResizeCursor()
-{
- static Cursor c = loadSharedCursor(0, IDC_SIZENS);
- return c;
-}
-
-const Cursor& southEastResizeCursor()
-{
- static Cursor c = loadSharedCursor(0, IDC_SIZENWSE);
- return c;
-}
-
-const Cursor& southWestResizeCursor()
-{
- static Cursor c = loadSharedCursor(0, IDC_SIZENESW);
- return c;
-}
-
-const Cursor& westResizeCursor()
-{
- static Cursor c = loadSharedCursor(0, IDC_SIZEWE);
- return c;
-}
-
-const Cursor& northSouthResizeCursor()
-{
- static Cursor c = loadSharedCursor(0, IDC_SIZENS);
- return c;
-}
-
-const Cursor& eastWestResizeCursor()
-{
- static Cursor c = loadSharedCursor(0, IDC_SIZEWE);
- return c;
-}
-
-const Cursor& northEastSouthWestResizeCursor()
-{
- static Cursor c = loadSharedCursor(0, IDC_SIZENESW);
- return c;
-}
-
-const Cursor& northWestSouthEastResizeCursor()
-{
- static Cursor c = loadSharedCursor(0, IDC_SIZENWSE);
- return c;
-}
-
-const Cursor& columnResizeCursor()
-{
- // FIXME: Windows does not have a standard column resize cursor <rdar://problem/5018591>
- static Cursor c = loadSharedCursor(0, IDC_SIZEWE);
- return c;
-}
-
-const Cursor& rowResizeCursor()
-{
- // FIXME: Windows does not have a standard row resize cursor <rdar://problem/5018591>
- static Cursor c = loadSharedCursor(0, IDC_SIZENS);
- return c;
-}
-
-const Cursor& middlePanningCursor()
-{
- static const Cursor c = loadCursorByName("panIcon", 7, 7);
- return c;
-}
-
-const Cursor& eastPanningCursor()
-{
- static const Cursor c = loadCursorByName("panEastCursor", 7, 7);
- return c;
-}
-
-const Cursor& northPanningCursor()
-{
- static const Cursor c = loadCursorByName("panNorthCursor", 7, 7);
- return c;
-}
-
-const Cursor& northEastPanningCursor()
-{
- static const Cursor c = loadCursorByName("panNorthEastCursor", 7, 7);
- return c;
-}
-
-const Cursor& northWestPanningCursor()
-{
- static const Cursor c = loadCursorByName("panNorthWestCursor", 7, 7);
- return c;
-}
-
-const Cursor& southPanningCursor()
-{
- static const Cursor c = loadCursorByName("panSouthCursor", 7, 7);
- return c;
-}
-
-const Cursor& southEastPanningCursor()
-{
- static const Cursor c = loadCursorByName("panSouthEastCursor", 7, 7);
- return c;
-}
-
-const Cursor& southWestPanningCursor()
-{
- static const Cursor c = loadCursorByName("panSouthWestCursor", 7, 7);
- return c;
-}
-
-const Cursor& westPanningCursor()
-{
- static const Cursor c = loadCursorByName("panWestCursor", 7, 7);
- return c;
-}
-
-const Cursor& moveCursor()
-{
- static Cursor c = loadSharedCursor(0, IDC_SIZEALL);
- return c;
-}
-
-const Cursor& verticalTextCursor()
-{
- static const Cursor c = loadCursorByName("verticalTextCursor", 7, 7);
- return c;
-}
-
-const Cursor& cellCursor()
-{
- return pointerCursor();
-}
-
-const Cursor& contextMenuCursor()
-{
- return pointerCursor();
-}
-
-const Cursor& aliasCursor()
-{
- return pointerCursor();
-}
-
-const Cursor& progressCursor()
-{
- static Cursor c = loadSharedCursor(0, IDC_APPSTARTING);
- return c;
-}
-
-const Cursor& noDropCursor()
-{
- static Cursor c = loadSharedCursor(0, IDC_NO);
- return c;
-}
-
-const Cursor& copyCursor()
-{
- return pointerCursor();
-}
-
-const Cursor& noneCursor()
-{
- return pointerCursor();
-}
-
-const Cursor& notAllowedCursor()
-{
- static Cursor c = loadSharedCursor(0, IDC_NO);
- return c;
-}
-
-const Cursor& zoomInCursor()
-{
- static const Cursor c = loadCursorByName("zoomInCursor", 7, 7);
- return c;
-}
-
-const Cursor& zoomOutCursor()
-{
- static const Cursor c = loadCursorByName("zoomOutCursor", 7, 7);
- return c;
-}
-
-const Cursor& grabCursor()
-{
- return pointerCursor();
-}
-
-const Cursor& grabbingCursor()
-{
- return pointerCursor();
-}
-
-}
diff --git a/WebCore/platform/win/DragDataWin.cpp b/WebCore/platform/win/DragDataWin.cpp
deleted file mode 100644
index 30487b8..0000000
--- a/WebCore/platform/win/DragDataWin.cpp
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "DragData.h"
-
-#include "ClipboardWin.h"
-#include "ClipboardUtilitiesWin.h"
-#include "ClipboardAccessPolicy.h"
-#include "DocumentFragment.h"
-#include "PlatformString.h"
-#include "Markup.h"
-#include "TextEncoding.h"
-#include <objidl.h>
-#include <shlwapi.h>
-#include <wininet.h>
-
-namespace WebCore {
-
-PassRefPtr<Clipboard> DragData::createClipboard(ClipboardAccessPolicy policy) const
-{
- return ClipboardWin::create(true, m_platformDragData, policy);
-}
-
-bool DragData::containsURL() const
-{
- return SUCCEEDED(m_platformDragData->QueryGetData(urlWFormat()))
- || SUCCEEDED(m_platformDragData->QueryGetData(urlFormat()))
- || SUCCEEDED(m_platformDragData->QueryGetData(filenameWFormat()))
- || SUCCEEDED(m_platformDragData->QueryGetData(filenameFormat()));
-}
-
-String DragData::asURL(String* title) const
-{
- bool success;
- return getURL(m_platformDragData, success, title);
-}
-
-bool DragData::containsFiles() const
-{
- return SUCCEEDED(m_platformDragData->QueryGetData(cfHDropFormat()));
-}
-
-void DragData::asFilenames(Vector<String>& result) const
-{
- WCHAR filename[MAX_PATH];
-
- STGMEDIUM medium;
- if (FAILED(m_platformDragData->GetData(cfHDropFormat(), &medium)))
- return;
-
- HDROP hdrop = (HDROP)GlobalLock(medium.hGlobal);
-
- if (!hdrop)
- return;
-
- const unsigned numFiles = DragQueryFileW(hdrop, 0xFFFFFFFF, 0, 0);
- for (unsigned i = 0; i < numFiles; i++) {
- if (!DragQueryFileW(hdrop, 0, filename, ARRAYSIZE(filename)))
- continue;
- result.append((UChar*)filename);
- }
-
- // Free up memory from drag
- DragFinish(hdrop);
-
- GlobalUnlock(medium.hGlobal);
-}
-
-bool DragData::containsPlainText() const
-{
- return SUCCEEDED(m_platformDragData->QueryGetData(plainTextWFormat()))
- || SUCCEEDED(m_platformDragData->QueryGetData(plainTextFormat()));
-}
-
-String DragData::asPlainText() const
-{
- bool success;
- return getPlainText(m_platformDragData, success);
-}
-
-bool DragData::containsColor() const
-{
- return false;
-}
-
-bool DragData::canSmartReplace() const
-{
- return SUCCEEDED(m_platformDragData->QueryGetData(smartPasteFormat()));
-}
-
-bool DragData::containsCompatibleContent() const
-{
- return containsPlainText() || containsURL()
- || containsHTML(m_platformDragData)
- || containsFilenames(m_platformDragData)
- || containsColor();
-}
-
-PassRefPtr<DocumentFragment> DragData::asFragment(Document* doc) const
-{
- /*
- * Order is richest format first. On OSX this is:
- * * Web Archive
- * * Filenames
- * * HTML
- * * RTF
- * * TIFF
- * * PICT
- */
-
- if (containsFilenames(m_platformDragData))
- if (PassRefPtr<DocumentFragment> fragment = fragmentFromFilenames(doc, m_platformDragData))
- return fragment;
-
- if (containsHTML(m_platformDragData))
- if (PassRefPtr<DocumentFragment> fragment = fragmentFromHTML(doc, m_platformDragData))
- return fragment;
-
- return 0;
-}
-
-Color DragData::asColor() const
-{
- return Color();
-}
-
-}
-
diff --git a/WebCore/platform/win/DragImageCGWin.cpp b/WebCore/platform/win/DragImageCGWin.cpp
deleted file mode 100644
index 7788572..0000000
--- a/WebCore/platform/win/DragImageCGWin.cpp
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "DragImage.h"
-
-#include "CachedImage.h"
-#include "GraphicsContext.h"
-#include "Image.h"
-#include "RetainPtr.h"
-
-#include <CoreGraphics/CoreGraphics.h>
-
-#include <windows.h>
-
-namespace WebCore {
-
-HBITMAP allocImage(HDC dc, IntSize size, CGContextRef *targetRef)
-{
- HBITMAP hbmp;
- BITMAPINFO bmpInfo = {0};
- bmpInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- bmpInfo.bmiHeader.biWidth = size.width();
- bmpInfo.bmiHeader.biHeight = size.height();
- bmpInfo.bmiHeader.biPlanes = 1;
- bmpInfo.bmiHeader.biBitCount = 32;
- bmpInfo.bmiHeader.biCompression = BI_RGB;
- LPVOID bits;
- hbmp = CreateDIBSection(dc, &bmpInfo, DIB_RGB_COLORS, &bits, 0, 0);
-
- if (!targetRef)
- return hbmp;
-
- CGColorSpaceRef deviceRGB = CGColorSpaceCreateDeviceRGB();
- CGContextRef bitmapContext = CGBitmapContextCreate(bits, bmpInfo.bmiHeader.biWidth, bmpInfo.bmiHeader.biHeight, 8,
- bmpInfo.bmiHeader.biWidth * 4, deviceRGB,
- kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipFirst);
- CGColorSpaceRelease(deviceRGB);
- if (!bitmapContext) {
- DeleteObject(hbmp);
- return 0;
- }
-
- *targetRef = bitmapContext;
- return hbmp;
-}
-
-static CGContextRef createCgContextFromBitmap(HBITMAP bitmap)
-{
- BITMAP info;
- GetObject(bitmap, sizeof(info), &info);
- ASSERT(info.bmBitsPixel == 32);
-
- CGColorSpaceRef deviceRGB = CGColorSpaceCreateDeviceRGB();
- CGContextRef bitmapContext = CGBitmapContextCreate(info.bmBits, info.bmWidth, info.bmHeight, 8,
- info.bmWidthBytes, deviceRGB, kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipFirst);
- CGColorSpaceRelease(deviceRGB);
- return bitmapContext;
-}
-
-DragImageRef scaleDragImage(DragImageRef image, FloatSize scale)
-{
- // FIXME: due to the way drag images are done on windows we need
- // to preprocess the alpha channel <rdar://problem/5015946>
-
- if (!image)
- return 0;
- CGContextRef targetContext;
- CGContextRef srcContext;
- CGImageRef srcImage;
- IntSize srcSize = dragImageSize(image);
- IntSize dstSize(static_cast<int>(srcSize.width() * scale.width()), static_cast<int>(srcSize.height() * scale.height()));
- HBITMAP hbmp = 0;
- HDC dc = GetDC(0);
- HDC dstDC = CreateCompatibleDC(dc);
- if (!dstDC)
- goto exit;
-
- hbmp = allocImage(dstDC, dstSize, &targetContext);
- if (!hbmp)
- goto exit;
-
- srcContext = createCgContextFromBitmap(image);
- srcImage = CGBitmapContextCreateImage(srcContext);
- CGRect rect;
- rect.origin.x = 0;
- rect.origin.y = 0;
- rect.size = dstSize;
- CGContextDrawImage(targetContext, rect, srcImage);
- CGImageRelease(srcImage);
- CGContextRelease(srcContext);
- CGContextRelease(targetContext);
- ::DeleteObject(image);
- image = 0;
-
-exit:
- if (!hbmp)
- hbmp = image;
- if (dstDC)
- DeleteDC(dstDC);
- ReleaseDC(0, dc);
- return hbmp;
-}
-
-DragImageRef createDragImageFromImage(Image* img)
-{
- HBITMAP hbmp = 0;
- HDC dc = GetDC(0);
- HDC workingDC = CreateCompatibleDC(dc);
- CGContextRef drawContext = 0;
- if (!workingDC)
- goto exit;
-
- hbmp = allocImage(workingDC, img->size(), &drawContext);
-
- if (!hbmp)
- goto exit;
-
- if (!drawContext) {
- ::DeleteObject(hbmp);
- hbmp = 0;
- }
-
- CGImageRef srcImage = img->getCGImageRef();
- CGRect rect;
- rect.size = img->size();
- rect.origin.x = 0;
- rect.origin.y = -rect.size.height;
- static const CGFloat white [] = {1.0, 1.0, 1.0, 1.0};
- CGContextScaleCTM(drawContext, 1, -1);
- CGContextSetFillColor(drawContext, white);
- CGContextFillRect(drawContext, rect);
- CGContextSetBlendMode(drawContext, kCGBlendModeNormal);
- CGContextDrawImage(drawContext, rect, srcImage);
- CGContextRelease(drawContext);
-
-exit:
- if (workingDC)
- DeleteDC(workingDC);
- ReleaseDC(0, dc);
- return hbmp;
-}
-
-}
diff --git a/WebCore/platform/win/DragImageCairoWin.cpp b/WebCore/platform/win/DragImageCairoWin.cpp
deleted file mode 100644
index 5fff64f..0000000
--- a/WebCore/platform/win/DragImageCairoWin.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "DragImage.h"
-
-#include "CachedImage.h"
-#include "GraphicsContext.h"
-#include "Image.h"
-#include "NotImplemented.h"
-#include "RetainPtr.h"
-
-#include <windows.h>
-
-namespace WebCore {
-
-DragImageRef scaleDragImage(DragImageRef image, FloatSize scale)
-{
- notImplemented();
-
- return image;
-}
-
-DragImageRef createDragImageFromImage(Image* img)
-{
- notImplemented();
-
- return 0;
-}
-
-}
diff --git a/WebCore/platform/win/DragImageWin.cpp b/WebCore/platform/win/DragImageWin.cpp
deleted file mode 100644
index 46146b3..0000000
--- a/WebCore/platform/win/DragImageWin.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "DragImage.h"
-
-#include "CachedImage.h"
-#include "GraphicsContext.h"
-#include "Image.h"
-#include "RetainPtr.h"
-
-#include <windows.h>
-
-namespace WebCore {
-
-IntSize dragImageSize(DragImageRef image)
-{
- if (!image)
- return IntSize();
- BITMAP b;
- GetObject(image, sizeof(BITMAP), &b);
- return IntSize(b.bmWidth, b.bmHeight);
-}
-
-void deleteDragImage(DragImageRef image)
-{
- if (image)
- ::DeleteObject(image);
-}
-
-DragImageRef dissolveDragImageToFraction(DragImageRef image, float)
-{
- //We don't do this on windows as the dragimage is blended by the OS
- return image;
-}
-
-DragImageRef createDragImageIconForCachedImage(CachedImage*)
-{
- //FIXME: Provide icon for image type <rdar://problem/5015949>
- return 0;
-}
-
-}
diff --git a/WebCore/platform/win/EditorWin.cpp b/WebCore/platform/win/EditorWin.cpp
deleted file mode 100644
index 813eb78..0000000
--- a/WebCore/platform/win/EditorWin.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Editor.h"
-#include "EditorClient.h"
-
-#include "ClipboardWin.h"
-#include "Document.h"
-#include "Element.h"
-#include "htmlediting.h"
-#include "NotImplemented.h"
-#include "TextIterator.h"
-#include "visible_units.h"
-
-#include <windows.h>
-
-namespace WebCore {
-
-PassRefPtr<Clipboard> Editor::newGeneralClipboard(ClipboardAccessPolicy policy)
-{
- COMPtr<IDataObject> clipboardData;
- if (!SUCCEEDED(OleGetClipboard(&clipboardData)))
- clipboardData = 0;
-
- return ClipboardWin::create(false, clipboardData.get(), policy);
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/win/EventLoopWin.cpp b/WebCore/platform/win/EventLoopWin.cpp
deleted file mode 100644
index aae107d..0000000
--- a/WebCore/platform/win/EventLoopWin.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "EventLoop.h"
-
-namespace WebCore {
-
-void EventLoop::cycle()
-{
- MSG msg;
- if (!GetMessage(&msg, 0, 0, 0)) {
- m_ended = true;
- return;
- }
-
- TranslateMessage(&msg);
- DispatchMessage(&msg);
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/win/FileChooserWin.cpp b/WebCore/platform/win/FileChooserWin.cpp
deleted file mode 100644
index 7d07b5d..0000000
--- a/WebCore/platform/win/FileChooserWin.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FileChooser.h"
-
-#include "LocalizedStrings.h"
-#include "StringTruncator.h"
-#include <shlwapi.h>
-#include <tchar.h>
-#include <windows.h>
-
-namespace WebCore {
-
-String FileChooser::basenameForWidth(const Font& font, int width) const
-{
- if (width <= 0)
- return String();
-
- String string;
- if (m_filenames.isEmpty())
- string = fileButtonNoFileSelectedLabel();
- else if (m_filenames.size() == 1) {
- String tmpFilename = m_filenames[0];
- LPTSTR basename = PathFindFileName(tmpFilename.charactersWithNullTermination());
- string = String(basename);
- } else
- return StringTruncator::rightTruncate(String::number(m_filenames.size()) + " files", width, font, false);
-
- return StringTruncator::centerTruncate(string, width, font, false);
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/win/FileSystemWin.cpp b/WebCore/platform/win/FileSystemWin.cpp
deleted file mode 100644
index 5671462..0000000
--- a/WebCore/platform/win/FileSystemWin.cpp
+++ /dev/null
@@ -1,307 +0,0 @@
-/*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2008 Collabora, Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FileSystem.h"
-
-#include "CString.h"
-#include "NotImplemented.h"
-#include "PlatformString.h"
-
-#include <windows.h>
-#include <winbase.h>
-#include <shlobj.h>
-#include <shlwapi.h>
-
-namespace WebCore {
-
-static bool statFile(String path, struct _stat64& st)
-{
- ASSERT_ARG(path, !path.isNull());
- return !_wstat64(path.charactersWithNullTermination(), &st) && (st.st_mode & _S_IFMT) == _S_IFREG;
-}
-
-bool getFileSize(const String& path, long long& result)
-{
- struct _stat64 sb;
- if (!statFile(path, sb))
- return false;
- result = sb.st_size;
- return true;
-}
-
-bool getFileModificationTime(const String& path, time_t& result)
-{
- struct _stat64 st;
- if (!statFile(path, st))
- return false;
- result = st.st_mtime;
- return true;
-}
-
-bool fileExists(const String& path)
-{
- struct _stat64 st;
- return statFile(path, st);
-}
-
-bool deleteFile(const String& path)
-{
- String filename = path;
- return !!DeleteFileW(filename.charactersWithNullTermination());
-}
-
-bool deleteEmptyDirectory(const String& path)
-{
- String filename = path;
- return !!RemoveDirectoryW(filename.charactersWithNullTermination());
-}
-
-String pathByAppendingComponent(const String& path, const String& component)
-{
- Vector<UChar> buffer(MAX_PATH);
-
- if (path.length() + 1 > buffer.size())
- return String();
-
- memcpy(buffer.data(), path.characters(), path.length() * sizeof(UChar));
- buffer[path.length()] = '\0';
-
- String componentCopy = component;
- if (!PathAppendW(buffer.data(), componentCopy.charactersWithNullTermination()))
- return String();
-
- buffer.resize(wcslen(buffer.data()));
-
- return String::adopt(buffer);
-}
-
-CString fileSystemRepresentation(const String&)
-{
- return "";
-}
-
-bool makeAllDirectories(const String& path)
-{
- String fullPath = path;
- if (SHCreateDirectoryEx(0, fullPath.charactersWithNullTermination(), 0) != ERROR_SUCCESS) {
- DWORD error = GetLastError();
- if (error != ERROR_FILE_EXISTS && error != ERROR_ALREADY_EXISTS) {
- LOG_ERROR("Failed to create path %s", path.ascii().data());
- return false;
- }
- }
- return true;
-}
-
-String homeDirectoryPath()
-{
- notImplemented();
- return "";
-}
-
-String pathGetFileName(const String& path)
-{
- return String(::PathFindFileName(String(path).charactersWithNullTermination()));
-}
-
-String directoryName(const String& path)
-{
- notImplemented();
- return String();
-}
-
-static String bundleName()
-{
- static bool initialized;
- static String name = "WebKit";
-
- if (!initialized) {
- initialized = true;
-
- if (CFBundleRef bundle = CFBundleGetMainBundle())
- if (CFTypeRef bundleExecutable = CFBundleGetValueForInfoDictionaryKey(bundle, kCFBundleExecutableKey))
- if (CFGetTypeID(bundleExecutable) == CFStringGetTypeID())
- name = reinterpret_cast<CFStringRef>(bundleExecutable);
- }
-
- return name;
-}
-
-static String storageDirectory(DWORD pathIdentifier)
-{
- Vector<UChar> buffer(MAX_PATH);
- if (FAILED(SHGetFolderPathW(0, pathIdentifier | CSIDL_FLAG_CREATE, 0, 0, buffer.data())))
- return String();
- buffer.resize(wcslen(buffer.data()));
- String directory = String::adopt(buffer);
-
- static const String companyNameDirectory = "Apple Computer\\";
- directory = pathByAppendingComponent(directory, companyNameDirectory + bundleName());
- if (!makeAllDirectories(directory))
- return String();
-
- return directory;
-}
-
-static String cachedStorageDirectory(DWORD pathIdentifier)
-{
- static HashMap<DWORD, String> directories;
-
- HashMap<DWORD, String>::iterator it = directories.find(pathIdentifier);
- if (it != directories.end())
- return it->second;
-
- String directory = storageDirectory(pathIdentifier);
- directories.add(pathIdentifier, directory);
-
- return directory;
-}
-
-CString openTemporaryFile(const char*, PlatformFileHandle& handle)
-{
- handle = INVALID_HANDLE_VALUE;
-
- char tempPath[MAX_PATH];
- int tempPathLength = ::GetTempPathA(_countof(tempPath), tempPath);
- if (tempPathLength <= 0 || tempPathLength > _countof(tempPath))
- return 0;
-
- HCRYPTPROV hCryptProv = 0;
- if (!CryptAcquireContext(&hCryptProv, 0, 0, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT))
- return 0;
-
- char proposedPath[MAX_PATH];
- while (1) {
- char tempFile[] = "XXXXXXXX.tmp"; // Use 8.3 style name (more characters aren't helpful due to 8.3 short file names)
- const int randomPartLength = 8;
- if (!CryptGenRandom(hCryptProv, randomPartLength, reinterpret_cast<BYTE*>(tempFile)))
- break;
-
- // Limit to valid filesystem characters, also excluding others that could be problematic, like punctuation.
- // don't include both upper and lowercase since Windows file systems are typically not case sensitive.
- const char validChars[] = "0123456789abcdefghijklmnopqrstuvwxyz";
- for (int i = 0; i < randomPartLength; ++i)
- tempFile[i] = validChars[tempFile[i] % (sizeof(validChars) - 1)];
-
- ASSERT(strlen(tempFile) == sizeof(tempFile) - 1);
-
- if (!PathCombineA(proposedPath, tempPath, tempFile))
- break;
-
- // use CREATE_NEW to avoid overwriting an existing file with the same name
- handle = CreateFileA(proposedPath, GENERIC_READ | GENERIC_WRITE, 0, 0, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0);
- if (!isHandleValid(handle) && GetLastError() == ERROR_ALREADY_EXISTS)
- continue;
-
- break;
- }
-
- CryptReleaseContext(hCryptProv, 0);
-
- if (!isHandleValid(handle))
- return 0;
-
- return proposedPath;
-}
-
-void closeFile(PlatformFileHandle& handle)
-{
- if (isHandleValid(handle)) {
- ::CloseHandle(handle);
- handle = invalidPlatformFileHandle;
- }
-}
-
-int writeToFile(PlatformFileHandle handle, const char* data, int length)
-{
- if (!isHandleValid(handle))
- return -1;
-
- DWORD bytesWritten;
- bool success = WriteFile(handle, data, length, &bytesWritten, 0);
-
- if (!success)
- return -1;
- return static_cast<int>(bytesWritten);
-}
-
-bool unloadModule(PlatformModule module)
-{
- return ::FreeLibrary(module);
-}
-
-String localUserSpecificStorageDirectory()
-{
- return cachedStorageDirectory(CSIDL_LOCAL_APPDATA);
-}
-
-String roamingUserSpecificStorageDirectory()
-{
- return cachedStorageDirectory(CSIDL_APPDATA);
-}
-
-bool safeCreateFile(const String& path, CFDataRef data)
-{
- // Create a temporary file.
- WCHAR tempDirPath[MAX_PATH];
- if (!GetTempPathW(ARRAYSIZE(tempDirPath), tempDirPath))
- return false;
-
- WCHAR tempPath[MAX_PATH];
- if (!GetTempFileNameW(tempDirPath, L"WEBKIT", 0, tempPath))
- return false;
-
- HANDLE tempFileHandle = CreateFileW(tempPath, GENERIC_READ | GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
- if (tempFileHandle == INVALID_HANDLE_VALUE)
- return false;
-
- // Write the data to this temp file.
- DWORD written;
- if (!WriteFile(tempFileHandle, CFDataGetBytePtr(data), static_cast<DWORD>(CFDataGetLength(data)), &written, 0))
- return false;
-
- CloseHandle(tempFileHandle);
-
- // Copy the temp file to the destination file.
- String destination = path;
- if (!MoveFileExW(tempPath, destination.charactersWithNullTermination(), MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED))
- return false;
-
- return true;
-}
-
-Vector<String> listDirectory(const String& path, const String& filter)
-{
- Vector<String> entries;
- notImplemented();
- return entries;
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/win/GDIObjectCounter.cpp b/WebCore/platform/win/GDIObjectCounter.cpp
deleted file mode 100644
index 3cc5bcb..0000000
--- a/WebCore/platform/win/GDIObjectCounter.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#ifndef NDEBUG
-
-#include "GDIObjectCounter.h"
-
-#include "CString.h"
-#include "Logging.h"
-
-#include <windows.h>
-
-namespace WebCore {
-
-GDIObjectCounter::GDIObjectCounter(const String& identifier)
-{
- init(identifier);
-}
-
-GDIObjectCounter::GDIObjectCounter(const String& className, void* instance)
-{
- init(String::format("%s (%p)", className.latin1().data(), instance));
-}
-
-void GDIObjectCounter::init(const String& identifier)
-{
- m_identifier = identifier;
- m_startCount = currentGDIObjectsInUse();
- m_endCount = 0;
-}
-
-GDIObjectCounter::~GDIObjectCounter()
-{
- m_endCount = currentGDIObjectsInUse();
- int leaked = m_endCount - m_startCount;
- if (leaked != 0)
- LOG(PlatformLeaks, "%s: leaked %d GDI object%s!", m_identifier.latin1().data(), leaked, leaked == 1 ? "" : "s");
-}
-
-unsigned GDIObjectCounter::currentGDIObjectsInUse()
-{
- return ::GetGuiResources(::GetCurrentProcess(), GR_GDIOBJECTS);
-}
-
-} // namespace WebCore
-
-#endif // !defined(NDEBUG)
diff --git a/WebCore/platform/win/GDIObjectCounter.h b/WebCore/platform/win/GDIObjectCounter.h
deleted file mode 100644
index 9b9bd12..0000000
--- a/WebCore/platform/win/GDIObjectCounter.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GDIObjectCounter_h
-#define GDIObjectCounter_h
-
-#ifdef NDEBUG
-#define LOCAL_GDI_COUNTER(num, identifier) ((void)0)
-#else
-#define LOCAL_GDI_COUNTER(num, identifier) GDIObjectCounter counter##num(identifier)
-#endif
-
-#ifndef NDEBUG
-
-#include "PlatformString.h"
-
-namespace WebCore {
-
- class GDIObjectCounter {
- public:
- GDIObjectCounter(const String& identifier);
- GDIObjectCounter(const String& className, void* instance);
- ~GDIObjectCounter();
-
- static unsigned currentGDIObjectsInUse();
-
- private:
- void init(const String& identifier);
- String m_identifier;
- unsigned m_startCount;
- unsigned m_endCount;
- };
-
-} // namespace WebCore
-
-#endif // !defined(NDEBUG)
-
-#endif // !defined(GDIObjectCounter_h)
diff --git a/WebCore/platform/win/KeyEventWin.cpp b/WebCore/platform/win/KeyEventWin.cpp
deleted file mode 100644
index 99dfe44..0000000
--- a/WebCore/platform/win/KeyEventWin.cpp
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "PlatformKeyboardEvent.h"
-
-#include <windows.h>
-#include <wtf/ASCIICType.h>
-
-using namespace WTF;
-
-namespace WebCore {
-
-static const unsigned short HIGH_BIT_MASK_SHORT = 0x8000;
-
-// FIXME: This is incomplete. We could change this to mirror
-// more like what Firefox does, and generate these switch statements
-// at build time.
-static String keyIdentifierForWindowsKeyCode(unsigned short keyCode)
-{
- switch (keyCode) {
- case VK_MENU:
- return "Alt";
- case VK_CONTROL:
- return "Control";
- case VK_SHIFT:
- return "Shift";
- case VK_CAPITAL:
- return "CapsLock";
- case VK_LWIN:
- case VK_RWIN:
- return "Win";
- case VK_CLEAR:
- return "Clear";
- case VK_DOWN:
- return "Down";
- // "End"
- case VK_END:
- return "End";
- // "Enter"
- case VK_RETURN:
- return "Enter";
- case VK_EXECUTE:
- return "Execute";
- case VK_F1:
- return "F1";
- case VK_F2:
- return "F2";
- case VK_F3:
- return "F3";
- case VK_F4:
- return "F4";
- case VK_F5:
- return "F5";
- case VK_F6:
- return "F6";
- case VK_F7:
- return "F7";
- case VK_F8:
- return "F8";
- case VK_F9:
- return "F9";
- case VK_F10:
- return "F11";
- case VK_F12:
- return "F12";
- case VK_F13:
- return "F13";
- case VK_F14:
- return "F14";
- case VK_F15:
- return "F15";
- case VK_F16:
- return "F16";
- case VK_F17:
- return "F17";
- case VK_F18:
- return "F18";
- case VK_F19:
- return "F19";
- case VK_F20:
- return "F20";
- case VK_F21:
- return "F21";
- case VK_F22:
- return "F22";
- case VK_F23:
- return "F23";
- case VK_F24:
- return "F24";
- case VK_HELP:
- return "Help";
- case VK_HOME:
- return "Home";
- case VK_INSERT:
- return "Insert";
- case VK_LEFT:
- return "Left";
- case VK_NEXT:
- return "PageDown";
- case VK_PRIOR:
- return "PageUp";
- case VK_PAUSE:
- return "Pause";
- case VK_SNAPSHOT:
- return "PrintScreen";
- case VK_RIGHT:
- return "Right";
- case VK_SCROLL:
- return "Scroll";
- case VK_SELECT:
- return "Select";
- case VK_UP:
- return "Up";
- // Standard says that DEL becomes U+007F.
- case VK_DELETE:
- return "U+007F";
- default:
- return String::format("U+%04X", toASCIIUpper(keyCode));
- }
-}
-
-static bool isKeypadEvent(WPARAM code, LPARAM keyData, PlatformKeyboardEvent::Type type)
-{
- if (type != PlatformKeyboardEvent::RawKeyDown && type != PlatformKeyboardEvent::KeyUp)
- return false;
-
- switch (code) {
- case VK_NUMLOCK:
- case VK_NUMPAD0:
- case VK_NUMPAD1:
- case VK_NUMPAD2:
- case VK_NUMPAD3:
- case VK_NUMPAD4:
- case VK_NUMPAD5:
- case VK_NUMPAD6:
- case VK_NUMPAD7:
- case VK_NUMPAD8:
- case VK_NUMPAD9:
- case VK_MULTIPLY:
- case VK_ADD:
- case VK_SEPARATOR:
- case VK_SUBTRACT:
- case VK_DECIMAL:
- case VK_DIVIDE:
- return true;
- case VK_RETURN:
- return HIWORD(keyData) & KF_EXTENDED;
- case VK_INSERT:
- case VK_DELETE:
- case VK_PRIOR:
- case VK_NEXT:
- case VK_END:
- case VK_HOME:
- case VK_LEFT:
- case VK_UP:
- case VK_RIGHT:
- case VK_DOWN:
- return !(HIWORD(keyData) & KF_EXTENDED);
- default:
- return false;
- }
-}
-
-static inline String singleCharacterString(UChar c) { return String(&c, 1); }
-
-PlatformKeyboardEvent::PlatformKeyboardEvent(HWND, WPARAM code, LPARAM keyData, Type type, bool systemKey)
- : m_type(type)
- , m_text((type == Char) ? singleCharacterString(code) : String())
- , m_unmodifiedText((type == Char) ? singleCharacterString(code) : String())
- , m_keyIdentifier((type == Char) ? String() : keyIdentifierForWindowsKeyCode(code))
- , m_autoRepeat(HIWORD(keyData) & KF_REPEAT)
- , m_windowsVirtualKeyCode((type == RawKeyDown || type == KeyUp) ? code : 0)
- , m_nativeVirtualKeyCode(m_windowsVirtualKeyCode)
- , m_isKeypad(isKeypadEvent(code, keyData, type))
- , m_shiftKey(GetKeyState(VK_SHIFT) & HIGH_BIT_MASK_SHORT)
- , m_ctrlKey(GetKeyState(VK_CONTROL) & HIGH_BIT_MASK_SHORT)
- , m_altKey(GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT)
- , m_metaKey(false)
- , m_isSystemKey(systemKey)
-{
-}
-
-void PlatformKeyboardEvent::disambiguateKeyDownEvent(Type, bool)
-{
- // No KeyDown events on Windows to disambiguate.
- ASSERT_NOT_REACHED();
-}
-
-bool PlatformKeyboardEvent::currentCapsLockState()
-{
- return GetKeyState(VK_CAPITAL) & 1;
-}
-
-}
diff --git a/WebCore/platform/win/Language.cpp b/WebCore/platform/win/Language.cpp
deleted file mode 100644
index 787c5a3..0000000
--- a/WebCore/platform/win/Language.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Language.h"
-
-#include "CString.h"
-#include "PlatformString.h"
-
-namespace WebCore {
-
-static String localeInfo(LCTYPE localeType, const String& fallback)
-{
- LANGID langID = GetUserDefaultUILanguage();
- int localeChars = GetLocaleInfo(langID, localeType, 0, 0);
- if (!localeChars)
- return fallback;
- Vector<WCHAR> localeNameBuf(localeChars);
- localeChars = GetLocaleInfo(langID, localeType, localeNameBuf.data(), localeChars);
- if (!localeChars)
- return fallback;
- String localeName = String::adopt(localeNameBuf);
- if (localeName.isEmpty())
- return fallback;
-
- return localeName;
-}
-
-String defaultLanguage()
-{
- static String computedDefaultLanguage;
- if (!computedDefaultLanguage.isEmpty())
- return computedDefaultLanguage;
-
- String languageName = localeInfo(LOCALE_SISO639LANGNAME, "en");
- String countryName = localeInfo(LOCALE_SISO3166CTRYNAME, String());
-
- if (countryName.isEmpty())
- computedDefaultLanguage = languageName;
- else
- computedDefaultLanguage = String::format("%s-%s", languageName.latin1().data(), countryName.latin1().data());
-
- return computedDefaultLanguage;
-}
-
-}
diff --git a/WebCore/platform/win/MIMETypeRegistryWin.cpp b/WebCore/platform/win/MIMETypeRegistryWin.cpp
deleted file mode 100644
index 06c6f36..0000000
--- a/WebCore/platform/win/MIMETypeRegistryWin.cpp
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "MIMETypeRegistry.h"
-
-#include <shlwapi.h>
-#include <wtf/HashMap.h>
-
-namespace WebCore
-{
-
-String getMIMETypeForUTI(const String & uti)
-{
- String mimeType;
- // FIXME: This is an ugly hack: public.type -> image/type mimetype
- if (int dotLocation = uti.reverseFind('.')) {
- mimeType = String("image/")+uti.substring(dotLocation + 1);
- }
- return mimeType;
-}
-
-static String mimeTypeForExtension(const String& extension)
-{
- String ext = "." + extension;
- WCHAR contentTypeStr[256];
- DWORD contentTypeStrLen = sizeof(contentTypeStr);
- DWORD keyType;
-
- HRESULT result = SHGetValue(HKEY_CLASSES_ROOT, ext.charactersWithNullTermination(), L"Content Type", &keyType, (LPVOID)contentTypeStr, &contentTypeStrLen);
-
- if (result == ERROR_SUCCESS && keyType == REG_SZ)
- return String(contentTypeStr, contentTypeStrLen / sizeof(contentTypeStr[0]) - 1);
-
- return String();
-}
-
-String MIMETypeRegistry::getPreferredExtensionForMIMEType(const String& type)
-{
- String mimeType;
-
- int semiColonPos = type.find(';');
- if (semiColonPos < 0)
- mimeType = type;
- else
- mimeType = type.substring(0, semiColonPos);
-
- String path = "MIME\\Database\\Content Type\\" + type;
- WCHAR extStr[MAX_PATH];
- DWORD extStrLen = sizeof(extStr);
- DWORD keyType;
-
- HRESULT result = SHGetValueW(HKEY_CLASSES_ROOT, path.charactersWithNullTermination(), L"Extension", &keyType, (LPVOID)extStr, &extStrLen);
-
- if (result == ERROR_SUCCESS && keyType == REG_SZ)
- return String(extStr + 1, extStrLen / sizeof(extStr[0]) - 2);
-
- return String();
-}
-
-String MIMETypeRegistry::getMIMETypeForExtension(const String &ext)
-{
- if (ext.isEmpty())
- return String();
-
- static HashMap<String, String> mimetypeMap;
- if (mimetypeMap.isEmpty()) {
- //fill with initial values
- mimetypeMap.add("txt", "text/plain");
- mimetypeMap.add("pdf", "application/pdf");
- mimetypeMap.add("ps", "application/postscript");
- mimetypeMap.add("html", "text/html");
- mimetypeMap.add("htm", "text/html");
- mimetypeMap.add("xml", "text/xml");
- mimetypeMap.add("xsl", "text/xsl");
- mimetypeMap.add("js", "application/x-javascript");
- mimetypeMap.add("xhtml", "application/xhtml+xml");
- mimetypeMap.add("rss", "application/rss+xml");
- mimetypeMap.add("webarchive", "application/x-webarchive");
- mimetypeMap.add("svg", "image/svg+xml");
- mimetypeMap.add("svgz", "image/svg+xml");
- mimetypeMap.add("jpg", "image/jpeg");
- mimetypeMap.add("jpeg", "image/jpeg");
- mimetypeMap.add("png", "image/png");
- mimetypeMap.add("tif", "image/tiff");
- mimetypeMap.add("tiff", "image/tiff");
- mimetypeMap.add("ico", "image/ico");
- mimetypeMap.add("cur", "image/ico");
- mimetypeMap.add("bmp", "image/bmp");
- }
- String result = mimetypeMap.get(ext);
- if (result.isEmpty()) {
- result = mimeTypeForExtension(ext);
- if (!result.isEmpty())
- mimetypeMap.add(ext, result);
- }
- return result;
-}
-
-}
diff --git a/WebCore/platform/win/PasteboardWin.cpp b/WebCore/platform/win/PasteboardWin.cpp
deleted file mode 100644
index 506cc7b..0000000
--- a/WebCore/platform/win/PasteboardWin.cpp
+++ /dev/null
@@ -1,327 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Pasteboard.h"
-
-#include "CString.h"
-#include "ClipboardUtilitiesWin.h"
-#include "Document.h"
-#include "DocumentFragment.h"
-#include "Element.h"
-#include "Frame.h"
-#include "HitTestResult.h"
-#include "Image.h"
-#include "KURL.h"
-#include "NotImplemented.h"
-#include "Page.h"
-#include "Range.h"
-#include "RenderImage.h"
-#include "TextEncoding.h"
-#include "markup.h"
-
-namespace WebCore {
-
-static UINT HTMLClipboardFormat = 0;
-static UINT BookmarkClipboardFormat = 0;
-static UINT WebSmartPasteFormat = 0;
-
-static LRESULT CALLBACK PasteboardOwnerWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
- LRESULT lresult = 0;
- LONG_PTR longPtr = GetWindowLongPtr(hWnd, 0);
-
- switch(message) {
- case WM_RENDERFORMAT:
- // This message comes when SetClipboardData was sent a null data handle
- // and now it's come time to put the data on the clipboard.
- break;
- case WM_RENDERALLFORMATS:
- // This message comes when SetClipboardData was sent a null data handle
- // and now this application is about to quit, so it must put data on
- // the clipboard before it exits.
- break;
- case WM_DRAWCLIPBOARD:
- break;
- case WM_DESTROY:
- break;
- case WM_CHANGECBCHAIN:
- break;
- default:
- lresult = DefWindowProc(hWnd, message, wParam, lParam);
- break;
- }
- return lresult;
-}
-
-Pasteboard* Pasteboard::generalPasteboard()
-{
- static Pasteboard* pasteboard = new Pasteboard;
- return pasteboard;
-}
-
-Pasteboard::Pasteboard()
-{
- // make a dummy HWND to be the Windows clipboard's owner
- WNDCLASSEX wcex = {0};
- wcex.cbSize = sizeof(WNDCLASSEX);
- wcex.lpfnWndProc = PasteboardOwnerWndProc;
- wcex.hInstance = Page::instanceHandle();
- wcex.lpszClassName = L"PasteboardOwnerWindowClass";
- ::RegisterClassEx(&wcex);
-
- m_owner = ::CreateWindow(L"PasteboardOwnerWindowClass", L"PasteboardOwnerWindow", 0, 0, 0, 0, 0,
- HWND_MESSAGE, 0, 0, 0);
-
- HTMLClipboardFormat = ::RegisterClipboardFormat(L"HTML Format");
- BookmarkClipboardFormat = ::RegisterClipboardFormat(L"UniformResourceLocatorW");
- WebSmartPasteFormat = ::RegisterClipboardFormat(L"WebKit Smart Paste Format");
-}
-
-void Pasteboard::clear()
-{
- if (::OpenClipboard(m_owner)) {
- ::EmptyClipboard();
- ::CloseClipboard();
- }
-}
-
-void Pasteboard::writeSelection(Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame)
-{
- clear();
-
- // Put CF_HTML format on the pasteboard
- if (::OpenClipboard(m_owner)) {
- ExceptionCode ec = 0;
- Vector<char> data;
- markupToCF_HTML(createMarkup(selectedRange, 0, AnnotateForInterchange),
- selectedRange->startContainer(ec)->document()->url().string(), data);
- HGLOBAL cbData = createGlobalData(data);
- if (!::SetClipboardData(HTMLClipboardFormat, cbData))
- ::GlobalFree(cbData);
- ::CloseClipboard();
- }
-
- // Put plain string on the pasteboard. CF_UNICODETEXT covers CF_TEXT as well
- String str = frame->selectedText();
- replaceNewlinesWithWindowsStyleNewlines(str);
- replaceNBSPWithSpace(str);
- if (::OpenClipboard(m_owner)) {
- HGLOBAL cbData = createGlobalData(str);
- if (!::SetClipboardData(CF_UNICODETEXT, cbData))
- ::GlobalFree(cbData);
- ::CloseClipboard();
- }
-
- // enable smart-replacing later on by putting dummy data on the pasteboard
- if (canSmartCopyOrDelete) {
- if (::OpenClipboard(m_owner)) {
- ::SetClipboardData(WebSmartPasteFormat, NULL);
- ::CloseClipboard();
- }
-
- }
-}
-
-void Pasteboard::writeURL(const KURL& url, const String& titleStr, Frame* frame)
-{
- ASSERT(!url.isEmpty());
-
- clear();
-
- String title(titleStr);
- if (title.isEmpty()) {
- title = url.lastPathComponent();
- if (title.isEmpty())
- title = url.host();
- }
-
- // write to clipboard in format com.apple.safari.bookmarkdata to be able to paste into the bookmarks view with appropriate title
- if (::OpenClipboard(m_owner)) {
- HGLOBAL cbData = createGlobalData(url, title);
- if (!::SetClipboardData(BookmarkClipboardFormat, cbData))
- ::GlobalFree(cbData);
- ::CloseClipboard();
- }
-
- // write to clipboard in format CF_HTML to be able to paste into contenteditable areas as a link
- if (::OpenClipboard(m_owner)) {
- Vector<char> data;
- markupToCF_HTML(urlToMarkup(url, title), "", data);
- HGLOBAL cbData = createGlobalData(data);
- if (!::SetClipboardData(HTMLClipboardFormat, cbData))
- ::GlobalFree(cbData);
- ::CloseClipboard();
- }
-
- // bare-bones CF_UNICODETEXT support
- if (::OpenClipboard(m_owner)) {
- HGLOBAL cbData = createGlobalData(url.string());
- if (!::SetClipboardData(CF_UNICODETEXT, cbData))
- ::GlobalFree(cbData);
- ::CloseClipboard();
- }
-}
-
-void Pasteboard::writeImage(Node* node, const KURL&, const String&)
-{
- ASSERT(node && node->renderer() && node->renderer()->isImage());
- RenderImage* renderer = static_cast<RenderImage*>(node->renderer());
- CachedImage* cachedImage = static_cast<CachedImage*>(renderer->cachedImage());
- ASSERT(cachedImage);
- Image* image = cachedImage->image();
- ASSERT(image);
-
- clear();
-
- HDC dc = GetDC(0);
- HDC compatibleDC = CreateCompatibleDC(0);
- HDC sourceDC = CreateCompatibleDC(0);
- HBITMAP resultBitmap = CreateCompatibleBitmap(dc, image->width(), image->height());
- HBITMAP oldBitmap = (HBITMAP)SelectObject(compatibleDC, resultBitmap);
-
- BITMAPINFO bmInfo = {0};
- bmInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- bmInfo.bmiHeader.biWidth = image->width();
- bmInfo.bmiHeader.biHeight = image->height();
- bmInfo.bmiHeader.biPlanes = 1;
- bmInfo.bmiHeader.biBitCount = 32;
- bmInfo.bmiHeader.biCompression = BI_RGB;
- HBITMAP coreBitmap = CreateDIBSection(dc, &bmInfo, DIB_RGB_COLORS, 0, 0, 0);
- HBITMAP oldSource = (HBITMAP)SelectObject(sourceDC, coreBitmap);
- image->getHBITMAP(coreBitmap);
-
- BLENDFUNCTION bf = {AC_SRC_OVER, 0, 255, AC_SRC_ALPHA};
- AlphaBlend(compatibleDC, 0, 0, image->width(), image->height(),
- sourceDC, 0, 0, image->width(), image->height(), bf);
-
- SelectObject(compatibleDC, oldBitmap);
- SelectObject(sourceDC, oldSource);
-
- DeleteObject(oldBitmap);
- DeleteObject(oldSource);
- DeleteObject(coreBitmap);
- ReleaseDC(0, dc);
- DeleteDC(compatibleDC);
- DeleteDC(sourceDC);
-
- if (::OpenClipboard(m_owner)) {
- ::SetClipboardData(CF_BITMAP, resultBitmap);
- ::CloseClipboard();
- }
-}
-
-bool Pasteboard::canSmartReplace()
-{
- return ::IsClipboardFormatAvailable(WebSmartPasteFormat);
-}
-
-String Pasteboard::plainText(Frame* frame)
-{
- if (::IsClipboardFormatAvailable(CF_UNICODETEXT) && ::OpenClipboard(m_owner)) {
- HANDLE cbData = ::GetClipboardData(CF_UNICODETEXT);
- if (cbData) {
- UChar* buffer = (UChar*)::GlobalLock(cbData);
- String fromClipboard(buffer);
- ::GlobalUnlock(cbData);
- ::CloseClipboard();
- return fromClipboard;
- } else
- ::CloseClipboard();
- }
-
- if (::IsClipboardFormatAvailable(CF_TEXT) && ::OpenClipboard(m_owner)) {
- HANDLE cbData = ::GetClipboardData(CF_TEXT);
- if (cbData) {
- char* buffer = (char*)::GlobalLock(cbData);
- String fromClipboard(buffer);
- ::GlobalUnlock(cbData);
- ::CloseClipboard();
- return fromClipboard;
- } else
- ::CloseClipboard();
- }
-
- return String();
-}
-
-PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefPtr<Range> context, bool allowPlainText, bool& chosePlainText)
-{
- chosePlainText = false;
-
- if (::IsClipboardFormatAvailable(HTMLClipboardFormat) && ::OpenClipboard(m_owner)) {
- // get data off of clipboard
- HANDLE cbData = ::GetClipboardData(HTMLClipboardFormat);
- if (cbData) {
- SIZE_T dataSize = ::GlobalSize(cbData);
- String cf_html(UTF8Encoding().decode((char*)::GlobalLock(cbData), dataSize));
- ::GlobalUnlock(cbData);
- ::CloseClipboard();
-
- PassRefPtr<DocumentFragment> fragment = fragmentFromCF_HTML(frame->document(), cf_html);
- if (fragment)
- return fragment;
- } else
- ::CloseClipboard();
- }
-
- if (allowPlainText && ::IsClipboardFormatAvailable(CF_UNICODETEXT)) {
- chosePlainText = true;
- if (::OpenClipboard(m_owner)) {
- HANDLE cbData = ::GetClipboardData(CF_UNICODETEXT);
- if (cbData) {
- UChar* buffer = (UChar*)GlobalLock(cbData);
- String str(buffer);
- ::GlobalUnlock( cbData );
- ::CloseClipboard();
- RefPtr<DocumentFragment> fragment = createFragmentFromText(context.get(), str);
- if (fragment)
- return fragment.release();
- } else
- ::CloseClipboard();
- }
- }
-
- if (allowPlainText && ::IsClipboardFormatAvailable(CF_TEXT)) {
- chosePlainText = true;
- if (::OpenClipboard(m_owner)) {
- HANDLE cbData = ::GetClipboardData(CF_TEXT);
- if (cbData) {
- char* buffer = (char*)GlobalLock(cbData);
- String str(buffer);
- ::GlobalUnlock( cbData );
- ::CloseClipboard();
- RefPtr<DocumentFragment> fragment = createFragmentFromText(context.get(), str);
- if (fragment)
- return fragment.release();
- } else
- ::CloseClipboard();
- }
- }
-
- return 0;
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/win/PlatformMouseEventWin.cpp b/WebCore/platform/win/PlatformMouseEventWin.cpp
deleted file mode 100644
index 7110b39..0000000
--- a/WebCore/platform/win/PlatformMouseEventWin.cpp
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "PlatformMouseEvent.h"
-
-#include <wtf/Assertions.h>
-#include <windows.h>
-#include <windowsx.h>
-
-namespace WebCore {
-
-#define HIGH_BIT_MASK_SHORT 0x8000
-
-static IntPoint positionForEvent(HWND hWnd, LPARAM lParam)
-{
- POINT point = {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)};
- return point;
-}
-
-static IntPoint globalPositionForEvent(HWND hWnd, LPARAM lParam)
-{
- POINT point = {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)};
- ClientToScreen(hWnd, &point);
- return point;
-}
-
-static MouseEventType messageToEventType(UINT message)
-{
- switch (message) {
- case WM_LBUTTONDBLCLK:
- case WM_RBUTTONDBLCLK:
- case WM_MBUTTONDBLCLK:
- //MSDN docs say double click is sent on mouse down
- case WM_LBUTTONDOWN:
- case WM_RBUTTONDOWN:
- case WM_MBUTTONDOWN:
- return MouseEventPressed;
-
- case WM_LBUTTONUP:
- case WM_RBUTTONUP:
- case WM_MBUTTONUP:
- return MouseEventReleased;
-
- case WM_MOUSELEAVE:
- case WM_MOUSEMOVE:
- return MouseEventMoved;
-
- default:
- ASSERT_NOT_REACHED();
- //Move is relatively harmless
- return MouseEventMoved;
- }
-}
-PlatformMouseEvent::PlatformMouseEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, bool activatedWebView)
- : m_position(positionForEvent(hWnd, lParam))
- , m_globalPosition(globalPositionForEvent(hWnd, lParam))
- , m_clickCount(0)
- , m_shiftKey(wParam & MK_SHIFT)
- , m_ctrlKey(wParam & MK_CONTROL)
- , m_altKey(GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT)
- , m_metaKey(m_altKey) // FIXME: We'll have to test other browsers
- , m_activatedWebView(activatedWebView)
- , m_eventType(messageToEventType(message))
- , m_modifierFlags(wParam)
-{
- m_timestamp = ::GetTickCount()*0.001; // GetTickCount returns milliseconds
-
- switch (message) {
- case WM_LBUTTONDOWN:
- case WM_LBUTTONUP:
- case WM_LBUTTONDBLCLK:
- m_button = LeftButton;
- break;
- case WM_RBUTTONDOWN:
- case WM_RBUTTONUP:
- case WM_RBUTTONDBLCLK:
- m_button = RightButton;
- break;
- case WM_MBUTTONDOWN:
- case WM_MBUTTONUP:
- case WM_MBUTTONDBLCLK:
- m_button = MiddleButton;
- break;
- case WM_MOUSEMOVE:
- case WM_MOUSELEAVE:
- if (wParam & MK_LBUTTON)
- m_button = LeftButton;
- else if (wParam & MK_MBUTTON)
- m_button = MiddleButton;
- else if (wParam & MK_RBUTTON)
- m_button = RightButton;
- else
- m_button = NoButton;
- break;
- default:
- ASSERT_NOT_REACHED();
- }
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/win/PlatformScreenWin.cpp b/WebCore/platform/win/PlatformScreenWin.cpp
deleted file mode 100644
index 56c8139..0000000
--- a/WebCore/platform/win/PlatformScreenWin.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "PlatformScreen.h"
-
-#include "IntRect.h"
-#include "FloatRect.h"
-#include "Frame.h"
-#include "FrameView.h"
-#include "Page.h"
-#include <windows.h>
-
-namespace WebCore {
-
-// Returns info for the default monitor if widget is NULL
-static MONITORINFOEX monitorInfoForWidget(Widget* widget)
-{
- HWND window = widget ? widget->root()->hostWindow()->platformWindow() : 0;
- HMONITOR monitor = MonitorFromWindow(window, MONITOR_DEFAULTTOPRIMARY);
-
- MONITORINFOEX monitorInfo;
- monitorInfo.cbSize = sizeof(MONITORINFOEX);
- GetMonitorInfo(monitor, &monitorInfo);
- return monitorInfo;
-}
-
-static DEVMODE deviceInfoForWidget(Widget* widget)
-{
- MONITORINFOEX monitorInfo = monitorInfoForWidget(widget);
-
- DEVMODE deviceInfo;
- deviceInfo.dmSize = sizeof(DEVMODE);
- deviceInfo.dmDriverExtra = 0;
- EnumDisplaySettings(monitorInfo.szDevice, ENUM_CURRENT_SETTINGS, &deviceInfo);
-
- return deviceInfo;
-}
-
-int screenDepth(Widget* widget)
-{
- DEVMODE deviceInfo = deviceInfoForWidget(widget);
- return deviceInfo.dmBitsPerPel;
-}
-
-int screenDepthPerComponent(Widget* widget)
-{
- // FIXME: Assumes RGB -- not sure if this is right.
- DEVMODE deviceInfo = deviceInfoForWidget(widget);
- return deviceInfo.dmBitsPerPel / 3;
-}
-
-bool screenIsMonochrome(Widget* widget)
-{
- DEVMODE deviceInfo = deviceInfoForWidget(widget);
- return deviceInfo.dmColor == DMCOLOR_MONOCHROME;
-}
-
-FloatRect screenRect(Widget* widget)
-{
- MONITORINFOEX monitorInfo = monitorInfoForWidget(widget);
- return monitorInfo.rcMonitor;
-}
-
-FloatRect screenAvailableRect(Widget* widget)
-{
- MONITORINFOEX monitorInfo = monitorInfoForWidget(widget);
- return monitorInfo.rcWork;
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/win/PlatformScrollBar.h b/WebCore/platform/win/PlatformScrollBar.h
deleted file mode 100644
index c84616a..0000000
--- a/WebCore/platform/win/PlatformScrollBar.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef PlatformScrollbar_h
-#define PlatformScrollbar_h
-
-#include "Scrollbar.h"
-#include "Timer.h"
-#include <wtf/PassRefPtr.h>
-
-typedef struct HDC__* HDC;
-
-namespace WebCore {
-
-class PlatformScrollbar : public Scrollbar {
-public:
- static PassRefPtr<PlatformScrollbar> create(ScrollbarClient* client, ScrollbarOrientation orientation, ScrollbarControlSize size)
- {
- return adoptRef(new PlatformScrollbar(client, orientation, size));
- }
-
- PlatformScrollbar(ScrollbarClient*, ScrollbarOrientation, ScrollbarControlSize, ScrollbarTheme* = 0);
-};
-
-}
-
-#endif // PlatformScrollbar_h
-
diff --git a/WebCore/platform/win/PlatformScrollBarWin.cpp b/WebCore/platform/win/PlatformScrollBarWin.cpp
deleted file mode 100644
index aa5333b..0000000
--- a/WebCore/platform/win/PlatformScrollBarWin.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2008 Brent Fulgham
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "PlatformScrollBar.h"
-
-#include "FrameView.h"
-#include "ScrollbarClient.h"
-#include "ScrollbarTheme.h"
-
-namespace WebCore {
-
-PlatformScrollbar::PlatformScrollbar(ScrollbarClient* client, ScrollbarOrientation orientation, ScrollbarControlSize size,
- ScrollbarTheme* theme)
- : Scrollbar(client, orientation, size, theme)
-{
-}
-
-}
-
diff --git a/WebCore/platform/win/PopupMenuWin.cpp b/WebCore/platform/win/PopupMenuWin.cpp
deleted file mode 100644
index 64b8a59..0000000
--- a/WebCore/platform/win/PopupMenuWin.cpp
+++ /dev/null
@@ -1,834 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "PopupMenu.h"
-
-#include "Document.h"
-#include "FloatRect.h"
-#include "FontSelector.h"
-#include "Frame.h"
-#include "FrameView.h"
-#include "GraphicsContext.h"
-#include "HTMLNames.h"
-#include "Page.h"
-#include "PlatformMouseEvent.h"
-#include "PlatformScreen.h"
-#include "RenderTheme.h"
-#include "RenderView.h"
-#include "Scrollbar.h"
-#include "ScrollbarTheme.h"
-#include "SimpleFontData.h"
-#include <tchar.h>
-#include <windows.h>
-
-using std::min;
-
-namespace WebCore {
-
-using namespace HTMLNames;
-
-// Default Window animation duration in milliseconds
-static const int defaultAnimationDuration = 200;
-// Maximum height of a popup window
-static const int maxPopupHeight = 320;
-
-static const int popupWindowAlphaPercent = 95;
-
-const int optionSpacingMiddle = 1;
-const int popupWindowBorderWidth = 1;
-
-static LPCTSTR kPopupWindowClassName = _T("PopupWindowClass");
-static ATOM registerPopup();
-static LRESULT CALLBACK PopupWndProc(HWND, UINT, WPARAM, LPARAM);
-
-// FIXME: Remove this as soon as practical.
-static inline bool isASCIIPrintable(unsigned c)
-{
- return c >= 0x20 && c <= 0x7E;
-}
-
-PopupMenu::PopupMenu(PopupMenuClient* client)
- : m_popupClient(client)
- , m_scrollbar(0)
- , m_popup(0)
- , m_DC(0)
- , m_bmp(0)
- , m_wasClicked(false)
- , m_itemHeight(0)
- , m_scrollOffset(0)
- , m_wheelDelta(0)
- , m_focusedIndex(0)
- , m_scrollbarCapturingMouse(false)
-{
-}
-
-PopupMenu::~PopupMenu()
-{
- if (m_bmp)
- ::DeleteObject(m_bmp);
- if (m_DC)
- ::DeleteObject(m_DC);
- if (m_popup)
- ::DestroyWindow(m_popup);
-}
-
-void PopupMenu::show(const IntRect& r, FrameView* v, int index)
-{
- calculatePositionAndSize(r, v);
- if (clientRect().isEmpty())
- return;
-
- if (!m_popup) {
- registerPopup();
-
- DWORD exStyle = WS_EX_LAYERED | WS_EX_LTRREADING;
-
- // Even though we already know our size and location at this point, we pass (0,0,0,0) as our size/location here.
- // We need to wait until after the call to ::SetWindowLongPtr to set our size so that in our WM_SIZE handler we can get access to the PopupMenu object
- m_popup = ::CreateWindowEx(exStyle, kPopupWindowClassName, _T("PopupMenu"),
- WS_POPUP | WS_BORDER,
- 0, 0, 0, 0,
- v->hostWindow()->platformWindow(), 0, 0, 0);
-
- if (!m_popup)
- return;
-
- ::SetWindowLongPtr(m_popup, 0, (LONG_PTR)this);
- ::SetLayeredWindowAttributes(m_popup, 0, (255 * popupWindowAlphaPercent) / 100, LWA_ALPHA);
- }
-
- if (!m_scrollbar)
- if (visibleItems() < client()->listSize()) {
- // We need a scroll bar
- m_scrollbar = client()->createScrollbar(this, VerticalScrollbar, SmallScrollbar);
- }
-
- ::SetWindowPos(m_popup, HWND_TOP, m_windowRect.x(), m_windowRect.y(), m_windowRect.width(), m_windowRect.height(), 0);
-
- // Determine whether we should animate our popups
- // Note: Must use 'BOOL' and 'FALSE' instead of 'bool' and 'false' to avoid stack corruption with SystemParametersInfo
- BOOL shouldAnimate = FALSE;
-#ifdef CAN_ANIMATE_TRANSPARENT_WINDOWS_SMOOTHLY
- ::SystemParametersInfo(SPI_GETCOMBOBOXANIMATION, 0, &shouldAnimate, 0);
-#endif
-
- if (shouldAnimate) {
- RECT viewRect = {0};
- ::GetWindowRect(v->hostWindow()->platformWindow(), &viewRect);
-
- if (!::IsRectEmpty(&viewRect)) {
- // Popups should slide into view away from the <select> box
- // NOTE: This may have to change for Vista
- DWORD slideDirection = (m_windowRect.y() < viewRect.top + v->contentsToWindow(r.location()).y()) ? AW_VER_NEGATIVE : AW_VER_POSITIVE;
-
- ::AnimateWindow(m_popup, defaultAnimationDuration, AW_SLIDE | slideDirection | AW_ACTIVATE);
- }
- } else
- ::ShowWindow(m_popup, SW_SHOWNORMAL);
- ::SetCapture(m_popup);
-
- if (client()) {
- int index = client()->selectedIndex();
- if (index >= 0)
- setFocusedIndex(index);
- }
-}
-
-void PopupMenu::hide()
-{
- ::ShowWindow(m_popup, SW_HIDE);
-}
-
-const int endOfLinePadding = 2;
-void PopupMenu::calculatePositionAndSize(const IntRect& r, FrameView* v)
-{
- // r is in absolute document coordinates, but we want to be in screen coordinates
-
- // First, move to WebView coordinates
- IntRect rScreenCoords(v->contentsToWindow(r.location()), r.size());
-
- // Then, translate to screen coordinates
- POINT location(rScreenCoords.location());
- if (!::ClientToScreen(v->hostWindow()->platformWindow(), &location))
- return;
-
- rScreenCoords.setLocation(location);
-
- // First, determine the popup's height
- int itemCount = client()->listSize();
- m_itemHeight = client()->menuStyle().font().height() + optionSpacingMiddle;
- int naturalHeight = m_itemHeight * itemCount;
- int popupHeight = min(maxPopupHeight, naturalHeight);
- // The popup should show an integral number of items (i.e. no partial items should be visible)
- popupHeight -= popupHeight % m_itemHeight;
-
- // Next determine its width
- int popupWidth = 0;
- for (int i = 0; i < itemCount; ++i) {
- String text = client()->itemText(i);
- if (text.isEmpty())
- continue;
-
- Font itemFont = client()->menuStyle().font();
- if (client()->itemIsLabel(i)) {
- FontDescription d = itemFont.fontDescription();
- d.setWeight(d.bolderWeight());
- itemFont = Font(d, itemFont.letterSpacing(), itemFont.wordSpacing());
- itemFont.update(m_popupClient->fontSelector());
- }
-
- popupWidth = max(popupWidth, itemFont.width(TextRun(text.characters(), text.length())));
- }
-
- if (naturalHeight > maxPopupHeight)
- // We need room for a scrollbar
- popupWidth += ScrollbarTheme::nativeTheme()->scrollbarThickness(SmallScrollbar);
-
- // Add padding to align the popup text with the <select> text
- // Note: We can't add paddingRight() because that value includes the width
- // of the dropdown button, so we must use our own endOfLinePadding constant.
- popupWidth += max(0, endOfLinePadding - client()->clientInsetRight()) + max(0, client()->clientPaddingLeft() - client()->clientInsetLeft());
-
- // Leave room for the border
- popupWidth += 2 * popupWindowBorderWidth;
- popupHeight += 2 * popupWindowBorderWidth;
-
- // The popup should be at least as wide as the control on the page
- popupWidth = max(rScreenCoords.width() - client()->clientInsetLeft() - client()->clientInsetRight(), popupWidth);
-
- // Always left-align items in the popup. This matches popup menus on the mac.
- int popupX = rScreenCoords.x() + client()->clientInsetLeft();
-
- IntRect popupRect(popupX, rScreenCoords.bottom(), popupWidth, popupHeight);
-
- // The popup needs to stay within the bounds of the screen and not overlap any toolbars
- FloatRect screen = screenAvailableRect(v);
-
- // Check that we don't go off the screen vertically
- if (popupRect.bottom() > screen.height()) {
- // The popup will go off the screen, so try placing it above the client
- if (rScreenCoords.y() - popupRect.height() < 0) {
- // The popup won't fit above, either, so place it whereever's bigger and resize it to fit
- if ((rScreenCoords.y() + rScreenCoords.height() / 2) < (screen.height() / 2)) {
- // Below is bigger
- popupRect.setHeight(screen.height() - popupRect.y());
- } else {
- // Above is bigger
- popupRect.setY(0);
- popupRect.setHeight(rScreenCoords.y());
- }
- } else {
- // The popup fits above, so reposition it
- popupRect.setY(rScreenCoords.y() - popupRect.height());
- }
- }
-
- // Check that we don't go off the screen horizontally
- if (popupRect.x() < screen.x()) {
- popupRect.setWidth(popupRect.width() - (screen.x() - popupRect.x()));
- popupRect.setX(screen.x());
- }
- m_windowRect = popupRect;
- return;
-}
-
-bool PopupMenu::setFocusedIndex(int i, bool hotTracking)
-{
- if (i < 0 || i >= client()->listSize() || i == focusedIndex())
- return false;
-
- if (!client()->itemIsEnabled(i))
- return false;
-
- invalidateItem(focusedIndex());
- invalidateItem(i);
-
- m_focusedIndex = i;
-
- if (!hotTracking)
- client()->setTextFromItem(i);
-
- if (!scrollToRevealSelection())
- ::UpdateWindow(m_popup);
-
- return true;
-}
-
-int PopupMenu::visibleItems() const
-{
- return clientRect().height() / m_itemHeight;
-}
-
-int PopupMenu::listIndexAtPoint(const IntPoint& point) const
-{
- return m_scrollOffset + point.y() / m_itemHeight;
-}
-
-int PopupMenu::focusedIndex() const
-{
- return m_focusedIndex;
-}
-
-void PopupMenu::focusFirst()
-{
- if (!client())
- return;
-
- int size = client()->listSize();
-
- for (int i = 0; i < size; ++i)
- if (client()->itemIsEnabled(i)) {
- setFocusedIndex(i);
- break;
- }
-}
-
-void PopupMenu::focusLast()
-{
- if (!client())
- return;
-
- int size = client()->listSize();
-
- for (int i = size - 1; i > 0; --i)
- if (client()->itemIsEnabled(i)) {
- setFocusedIndex(i);
- break;
- }
-}
-
-bool PopupMenu::down(unsigned lines)
-{
- if (!client())
- return false;
-
- int size = client()->listSize();
-
- int lastSelectableIndex, selectedListIndex;
- lastSelectableIndex = selectedListIndex = focusedIndex();
- for (int i = selectedListIndex + 1; i >= 0 && i < size; ++i)
- if (client()->itemIsEnabled(i)) {
- lastSelectableIndex = i;
- if (i >= selectedListIndex + (int)lines)
- break;
- }
-
- return setFocusedIndex(lastSelectableIndex);
-}
-
-bool PopupMenu::up(unsigned lines)
-{
- if (!client())
- return false;
-
- int size = client()->listSize();
-
- int lastSelectableIndex, selectedListIndex;
- lastSelectableIndex = selectedListIndex = focusedIndex();
- for (int i = selectedListIndex - 1; i >= 0 && i < size; --i)
- if (client()->itemIsEnabled(i)) {
- lastSelectableIndex = i;
- if (i <= selectedListIndex - (int)lines)
- break;
- }
-
- return setFocusedIndex(lastSelectableIndex);
-}
-
-void PopupMenu::invalidateItem(int index)
-{
- if (!m_popup)
- return;
-
- IntRect damageRect(clientRect());
- damageRect.setY(m_itemHeight * (index - m_scrollOffset));
- damageRect.setHeight(m_itemHeight);
- if (m_scrollbar)
- damageRect.setWidth(damageRect.width() - m_scrollbar->frameRect().width());
-
- RECT r = damageRect;
- ::InvalidateRect(m_popup, &r, TRUE);
-}
-
-IntRect PopupMenu::clientRect() const
-{
- IntRect clientRect = m_windowRect;
- clientRect.inflate(-popupWindowBorderWidth);
- clientRect.setLocation(IntPoint(0, 0));
- return clientRect;
-}
-
-void PopupMenu::incrementWheelDelta(int delta)
-{
- m_wheelDelta += delta;
-}
-
-void PopupMenu::reduceWheelDelta(int delta)
-{
- ASSERT(delta >= 0);
- ASSERT(delta <= abs(m_wheelDelta));
-
- if (m_wheelDelta > 0)
- m_wheelDelta -= delta;
- else if (m_wheelDelta < 0)
- m_wheelDelta += delta;
- else
- return;
-}
-
-bool PopupMenu::scrollToRevealSelection()
-{
- if (!m_scrollbar)
- return false;
-
- int index = focusedIndex();
-
- if (index < m_scrollOffset) {
- m_scrollbar->setValue(index);
- return true;
- }
-
- if (index >= m_scrollOffset + visibleItems()) {
- m_scrollbar->setValue(index - visibleItems() + 1);
- return true;
- }
-
- return false;
-}
-
-void PopupMenu::updateFromElement()
-{
- if (!m_popup)
- return;
-
- m_focusedIndex = client()->selectedIndex();
-
- ::InvalidateRect(m_popup, 0, TRUE);
- if (!scrollToRevealSelection())
- ::UpdateWindow(m_popup);
-}
-
-bool PopupMenu::itemWritingDirectionIsNatural()
-{
- return true;
-}
-
-const int separatorPadding = 4;
-const int separatorHeight = 1;
-void PopupMenu::paint(const IntRect& damageRect, HDC hdc)
-{
- if (!m_popup)
- return;
-
- if (!m_DC) {
- m_DC = ::CreateCompatibleDC(::GetDC(m_popup));
- if (!m_DC)
- return;
- }
-
- if (m_bmp) {
- bool keepBitmap = false;
- BITMAP bitmap;
- if (GetObject(m_bmp, sizeof(bitmap), &bitmap))
- keepBitmap = bitmap.bmWidth == clientRect().width()
- && bitmap.bmHeight == clientRect().height();
- if (!keepBitmap) {
- DeleteObject(m_bmp);
- m_bmp = 0;
- }
- }
- if (!m_bmp) {
- BITMAPINFO bitmapInfo;
- bitmapInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- bitmapInfo.bmiHeader.biWidth = clientRect().width();
- bitmapInfo.bmiHeader.biHeight = -clientRect().height();
- bitmapInfo.bmiHeader.biPlanes = 1;
- bitmapInfo.bmiHeader.biBitCount = 32;
- bitmapInfo.bmiHeader.biCompression = BI_RGB;
- bitmapInfo.bmiHeader.biSizeImage = 0;
- bitmapInfo.bmiHeader.biXPelsPerMeter = 0;
- bitmapInfo.bmiHeader.biYPelsPerMeter = 0;
- bitmapInfo.bmiHeader.biClrUsed = 0;
- bitmapInfo.bmiHeader.biClrImportant = 0;
-
- void* pixels = 0;
- m_bmp = ::CreateDIBSection(m_DC, &bitmapInfo, DIB_RGB_COLORS, &pixels, 0, 0);
- if (!m_bmp)
- return;
-
- ::SelectObject(m_DC, m_bmp);
- }
-
- GraphicsContext context(m_DC);
-
- int itemCount = client()->listSize();
-
- // listRect is the damageRect translated into the coordinates of the entire menu list (which is itemCount * m_itemHeight pixels tall)
- IntRect listRect = damageRect;
- listRect.move(IntSize(0, m_scrollOffset * m_itemHeight));
-
- for (int y = listRect.y(); y < listRect.bottom(); y += m_itemHeight) {
- int index = y / m_itemHeight;
-
- Color optionBackgroundColor, optionTextColor;
- PopupMenuStyle itemStyle = client()->itemStyle(index);
- if (index == focusedIndex()) {
- optionBackgroundColor = theme()->activeListBoxSelectionBackgroundColor();
- optionTextColor = theme()->activeListBoxSelectionForegroundColor();
- } else {
- optionBackgroundColor = itemStyle.backgroundColor();
- optionTextColor = itemStyle.foregroundColor();
- }
-
- // itemRect is in client coordinates
- IntRect itemRect(0, (index - m_scrollOffset) * m_itemHeight, damageRect.width(), m_itemHeight);
-
- // Draw the background for this menu item
- if (itemStyle.isVisible())
- context.fillRect(itemRect, optionBackgroundColor);
-
- if (client()->itemIsSeparator(index)) {
- IntRect separatorRect(itemRect.x() + separatorPadding, itemRect.y() + (itemRect.height() - separatorHeight) / 2, itemRect.width() - 2 * separatorPadding, separatorHeight);
- context.fillRect(separatorRect, optionTextColor);
- continue;
- }
-
- String itemText = client()->itemText(index);
-
- unsigned length = itemText.length();
- const UChar* string = itemText.characters();
- TextRun textRun(string, length, false, 0, 0, itemText.defaultWritingDirection() == WTF::Unicode::RightToLeft);
-
- context.setFillColor(optionTextColor);
-
- Font itemFont = client()->menuStyle().font();
- if (client()->itemIsLabel(index)) {
- FontDescription d = itemFont.fontDescription();
- d.setWeight(d.bolderWeight());
- itemFont = Font(d, itemFont.letterSpacing(), itemFont.wordSpacing());
- itemFont.update(m_popupClient->fontSelector());
- }
- context.setFont(itemFont);
-
- // Draw the item text
- if (itemStyle.isVisible()) {
- int textX = max(0, client()->clientPaddingLeft() - client()->clientInsetLeft());
- int textY = itemRect.y() + itemFont.ascent() + (itemRect.height() - itemFont.height()) / 2;
- context.drawBidiText(textRun, IntPoint(textX, textY));
- }
- }
-
- if (m_scrollbar)
- m_scrollbar->paint(&context, damageRect);
-
- if (!hdc)
- hdc = ::GetDC(m_popup);
-
- ::BitBlt(hdc, damageRect.x(), damageRect.y(), damageRect.width(), damageRect.height(), m_DC, damageRect.x(), damageRect.y(), SRCCOPY);
-}
-
-void PopupMenu::valueChanged(Scrollbar* scrollBar)
-{
- ASSERT(m_scrollbar);
-
- if (!m_popup)
- return;
-
- int offset = scrollBar->value();
-
- if (m_scrollOffset == offset)
- return;
-
- int scrolledLines = m_scrollOffset - offset;
- m_scrollOffset = offset;
-
- UINT flags = SW_INVALIDATE;
-
-#ifdef CAN_SET_SMOOTH_SCROLLING_DURATION
- BOOL shouldSmoothScroll = FALSE;
- ::SystemParametersInfo(SPI_GETLISTBOXSMOOTHSCROLLING, 0, &shouldSmoothScroll, 0);
- if (shouldSmoothScroll)
- flags |= MAKEWORD(SW_SMOOTHSCROLL, smoothScrollAnimationDuration);
-#endif
-
- IntRect listRect = clientRect();
- if (m_scrollbar)
- listRect.setWidth(listRect.width() - m_scrollbar->frameRect().width());
- RECT r = listRect;
- ::ScrollWindowEx(m_popup, 0, scrolledLines * m_itemHeight, &r, 0, 0, 0, flags);
- if (m_scrollbar) {
- r = m_scrollbar->frameRect();
- ::InvalidateRect(m_popup, &r, TRUE);
- }
- ::UpdateWindow(m_popup);
-}
-
-void PopupMenu::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect& rect)
-{
- IntRect scrollRect = rect;
- scrollRect.move(scrollbar->x(), scrollbar->y());
- RECT r = scrollRect;
- ::InvalidateRect(m_popup, &r, false);
-}
-
-static ATOM registerPopup()
-{
- static bool haveRegisteredWindowClass = false;
-
- if (haveRegisteredWindowClass)
- return true;
-
- WNDCLASSEX wcex;
-
- wcex.cbSize = sizeof(WNDCLASSEX);
-
- wcex.style = 0;
- wcex.lpfnWndProc = PopupWndProc;
- wcex.cbClsExtra = 0;
- wcex.cbWndExtra = sizeof(PopupMenu*); // For the PopupMenu pointer
- wcex.hInstance = Page::instanceHandle();
- wcex.hIcon = 0;
- wcex.hCursor = LoadCursor(0, IDC_ARROW);
- wcex.hbrBackground = 0;
- wcex.lpszMenuName = 0;
- wcex.lpszClassName = kPopupWindowClassName;
- wcex.hIconSm = 0;
-
- haveRegisteredWindowClass = true;
-
- return ::RegisterClassEx(&wcex);
-}
-
-const int smoothScrollAnimationDuration = 5000;
-static LRESULT CALLBACK PopupWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
- LRESULT lResult = 0;
- LONG_PTR longPtr = GetWindowLongPtr(hWnd, 0);
- PopupMenu* popup = reinterpret_cast<PopupMenu*>(longPtr);
-
- switch (message) {
- case WM_SIZE:
- if (popup && popup->scrollbar()) {
- IntSize size(LOWORD(lParam), HIWORD(lParam));
- popup->scrollbar()->setFrameRect(IntRect(size.width() - popup->scrollbar()->width(), 0, popup->scrollbar()->width(), size.height()));
-
- int visibleItems = popup->visibleItems();
- popup->scrollbar()->setEnabled(visibleItems < popup->client()->listSize());
- popup->scrollbar()->setSteps(1, max(1, visibleItems - 1));
- popup->scrollbar()->setProportion(visibleItems, popup->client()->listSize());
- }
- break;
- case WM_ACTIVATE:
- if (popup && popup->client() && wParam == WA_INACTIVE)
- popup->client()->hidePopup();
- break;
- case WM_KILLFOCUS:
- if (popup && popup->client() && (HWND)wParam != popup->popupHandle())
- // Focus is going elsewhere, so hide
- popup->client()->hidePopup();
- break;
- case WM_KEYDOWN:
- if (popup && popup->client()) {
- lResult = 0;
- switch (LOWORD(wParam)) {
- case VK_DOWN:
- case VK_RIGHT:
- popup->down();
- break;
- case VK_UP:
- case VK_LEFT:
- popup->up();
- break;
- case VK_HOME:
- popup->focusFirst();
- break;
- case VK_END:
- popup->focusLast();
- break;
- case VK_PRIOR:
- if (popup->focusedIndex() != popup->scrollOffset()) {
- // Set the selection to the first visible item
- int firstVisibleItem = popup->scrollOffset();
- popup->up(popup->focusedIndex() - firstVisibleItem);
- } else
- // The first visible item is selected, so move the selection back one page
- popup->up(popup->visibleItems());
- break;
- case VK_NEXT:
- if (popup) {
- int lastVisibleItem = popup->scrollOffset() + popup->visibleItems() - 1;
- if (popup->focusedIndex() != lastVisibleItem) {
- // Set the selection to the last visible item
- popup->down(lastVisibleItem - popup->focusedIndex());
- } else
- // The last visible item is selected, so move the selection forward one page
- popup->down(popup->visibleItems());
- }
- break;
- case VK_TAB:
- ::SendMessage(popup->client()->hostWindow()->platformWindow(), message, wParam, lParam);
- popup->client()->hidePopup();
- break;
- default:
- if (isASCIIPrintable(wParam))
- // Send the keydown to the WebView so it can be used for type-to-select.
- ::PostMessage(popup->client()->hostWindow()->platformWindow(), message, wParam, lParam);
- else
- lResult = 1;
- break;
- }
- }
- break;
- case WM_CHAR:
- if (popup && popup->client()) {
- lResult = 0;
- int index;
- switch (wParam) {
- case 0x0D: // Enter/Return
- popup->client()->hidePopup();
- index = popup->focusedIndex();
- ASSERT(index >= 0);
- popup->client()->valueChanged(index);
- break;
- case 0x1B: // Escape
- popup->client()->hidePopup();
- break;
- case 0x09: // TAB
- case 0x08: // Backspace
- case 0x0A: // Linefeed
- default: // Character
- lResult = 1;
- break;
- }
- }
- break;
- case WM_MOUSEMOVE:
- if (popup) {
- IntPoint mousePoint(MAKEPOINTS(lParam));
- if (popup->scrollbar()) {
- IntRect scrollBarRect = popup->scrollbar()->frameRect();
- if (popup->scrollbarCapturingMouse() || scrollBarRect.contains(mousePoint)) {
- // Put the point into coordinates relative to the scroll bar
- mousePoint.move(-scrollBarRect.x(), -scrollBarRect.y());
- PlatformMouseEvent event(hWnd, message, wParam, MAKELPARAM(mousePoint.x(), mousePoint.y()));
- popup->scrollbar()->mouseMoved(event);
- break;
- }
- }
-
- BOOL shouldHotTrack = FALSE;
- ::SystemParametersInfo(SPI_GETHOTTRACKING, 0, &shouldHotTrack, 0);
-
- RECT bounds;
- GetClientRect(popup->popupHandle(), &bounds);
- if ((shouldHotTrack || wParam & MK_LBUTTON) && ::PtInRect(&bounds, mousePoint))
- popup->setFocusedIndex(popup->listIndexAtPoint(mousePoint), true);
-
- // Release capture if the left button isn't down, and the mousePoint is outside the popup window.
- // This way, the WebView will get future mouse events in the rest of the window.
- if (!(wParam & MK_LBUTTON) && !::PtInRect(&bounds, mousePoint)) {
- ::ReleaseCapture();
- break;
- }
- }
- break;
- case WM_LBUTTONDOWN:
- if (popup) {
- ::SetCapture(popup->popupHandle());
- IntPoint mousePoint(MAKEPOINTS(lParam));
- if (popup->scrollbar()) {
- IntRect scrollBarRect = popup->scrollbar()->frameRect();
- if (scrollBarRect.contains(mousePoint)) {
- // Put the point into coordinates relative to the scroll bar
- mousePoint.move(-scrollBarRect.x(), -scrollBarRect.y());
- PlatformMouseEvent event(hWnd, message, wParam, MAKELPARAM(mousePoint.x(), mousePoint.y()));
- popup->scrollbar()->mouseDown(event);
- popup->setScrollbarCapturingMouse(true);
- break;
- }
- }
-
- popup->setFocusedIndex(popup->listIndexAtPoint(mousePoint), true);
- }
- break;
- case WM_LBUTTONUP:
- if (popup) {
- IntPoint mousePoint(MAKEPOINTS(lParam));
- if (popup->scrollbar()) {
- ::ReleaseCapture();
- IntRect scrollBarRect = popup->scrollbar()->frameRect();
- if (popup->scrollbarCapturingMouse() || scrollBarRect.contains(mousePoint)) {
- popup->setScrollbarCapturingMouse(false);
- // Put the point into coordinates relative to the scroll bar
- mousePoint.move(-scrollBarRect.x(), -scrollBarRect.y());
- PlatformMouseEvent event(hWnd, message, wParam, MAKELPARAM(mousePoint.x(), mousePoint.y()));
- popup->scrollbar()->mouseUp();
- // FIXME: This is a hack to work around Scrollbar not invalidating correctly when it doesn't have a parent widget
- RECT r = scrollBarRect;
- ::InvalidateRect(popup->popupHandle(), &r, TRUE);
- break;
- }
- }
- // Only release capture and hide the popup if the mouse is inside the popup window.
- RECT bounds;
- GetClientRect(popup->popupHandle(), &bounds);
- if (popup->client() && ::PtInRect(&bounds, mousePoint)) {
- ::ReleaseCapture();
- popup->client()->hidePopup();
- int index = popup->focusedIndex();
- if (index >= 0)
- popup->client()->valueChanged(index);
- }
- }
- break;
- case WM_MOUSEWHEEL:
- if (popup && popup->scrollbar()) {
- int i = 0;
- for (popup->incrementWheelDelta(GET_WHEEL_DELTA_WPARAM(wParam)); abs(popup->wheelDelta()) >= WHEEL_DELTA; popup->reduceWheelDelta(WHEEL_DELTA))
- if (popup->wheelDelta() > 0)
- ++i;
- else
- --i;
-
- popup->scrollbar()->scroll(i > 0 ? ScrollUp : ScrollDown, ScrollByLine, abs(i));
- }
- break;
- case WM_PAINT:
- if (popup) {
- PAINTSTRUCT paintInfo;
- ::BeginPaint(popup->popupHandle(), &paintInfo);
- popup->paint(paintInfo.rcPaint, paintInfo.hdc);
- ::EndPaint(popup->popupHandle(), &paintInfo);
- lResult = 0;
- }
- break;
- case WM_PRINTCLIENT:
- if (popup)
- popup->paint(popup->clientRect(), (HDC)wParam);
- break;
- default:
- lResult = DefWindowProc(hWnd, message, wParam, lParam);
- }
-
- return lResult;
-}
-
-}
diff --git a/WebCore/platform/win/ScrollbarThemeSafari.cpp b/WebCore/platform/win/ScrollbarThemeSafari.cpp
deleted file mode 100644
index 06a6533..0000000
--- a/WebCore/platform/win/ScrollbarThemeSafari.cpp
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ScrollbarThemeSafari.h"
-
-#if USE(SAFARI_THEME)
-
-#include "GraphicsContext.h"
-#include "IntRect.h"
-#include "Page.h"
-#include "PlatformMouseEvent.h"
-#include "Scrollbar.h"
-#include "ScrollbarClient.h"
-#include "ScrollbarThemeWin.h"
-#include "Settings.h"
-#include "SoftLinking.h"
-
-#include <CoreGraphics/CoreGraphics.h>
-
-// If you have an empty placeholder SafariThemeConstants.h, then include SafariTheme.h
-// This is a workaround until a version of WebKitSupportLibrary is released with an updated SafariThemeConstants.h
-#include <SafariTheme/SafariThemeConstants.h>
-#ifndef SafariThemeConstants_h
-#include <SafariTheme/SafariTheme.h>
-#endif
-
-// FIXME: There are repainting problems due to Aqua scroll bar buttons' visual overflow.
-
-using namespace std;
-
-namespace WebCore {
-
-using namespace SafariTheme;
-
-ScrollbarTheme* ScrollbarTheme::nativeTheme()
-{
- static ScrollbarThemeSafari safariTheme;
- static ScrollbarThemeWin windowsTheme;
- if (Settings::shouldPaintNativeControls())
- return &windowsTheme;
- return &safariTheme;
-}
-
-// FIXME: Get these numbers from CoreUI.
-static int cScrollbarThickness[] = { 15, 11 };
-static int cRealButtonLength[] = { 28, 21 };
-static int cButtonInset[] = { 14, 11 };
-static int cButtonHitInset[] = { 3, 2 };
-// cRealButtonLength - cButtonInset
-static int cButtonLength[] = { 14, 10 };
-static int cThumbMinLength[] = { 26, 20 };
-
-#if !defined(NDEBUG) && defined(USE_DEBUG_SAFARI_THEME)
-SOFT_LINK_DEBUG_LIBRARY(SafariTheme)
-#else
-SOFT_LINK_LIBRARY(SafariTheme)
-#endif
-
-SOFT_LINK(SafariTheme, paintThemePart, void, __stdcall,
- (ThemePart part, CGContextRef context, const CGRect& rect, NSControlSize size, ThemeControlState state),
- (part, context, rect, size, state))
-
-static ScrollbarControlState scrollbarControlStateFromThemeState(ThemeControlState state)
-{
- ScrollbarControlState s = 0;
- if (state & ActiveState)
- s |= ActiveScrollbarState;
- if (state & EnabledState)
- s |= EnabledScrollbarState;
- if (state & PressedState)
- s |= PressedScrollbarState;
- return s;
-}
-
-ScrollbarThemeSafari::~ScrollbarThemeSafari()
-{
-}
-
-int ScrollbarThemeSafari::scrollbarThickness(ScrollbarControlSize controlSize)
-{
- return cScrollbarThickness[controlSize];
-}
-
-bool ScrollbarThemeSafari::hasButtons(Scrollbar* scrollbar)
-{
- return scrollbar->enabled() && (scrollbar->orientation() == HorizontalScrollbar ?
- scrollbar->width() :
- scrollbar->height()) >= 2 * (cRealButtonLength[scrollbar->controlSize()] - cButtonHitInset[scrollbar->controlSize()]);
-}
-
-bool ScrollbarThemeSafari::hasThumb(Scrollbar* scrollbar)
-{
- return scrollbar->enabled() && (scrollbar->orientation() == HorizontalScrollbar ?
- scrollbar->width() :
- scrollbar->height()) >= 2 * cButtonInset[scrollbar->controlSize()] + cThumbMinLength[scrollbar->controlSize()] + 1;
-}
-
-static IntRect buttonRepaintRect(const IntRect& buttonRect, ScrollbarOrientation orientation, ScrollbarControlSize controlSize, bool start)
-{
- IntRect paintRect(buttonRect);
- if (orientation == HorizontalScrollbar) {
- paintRect.setWidth(cRealButtonLength[controlSize]);
- if (!start)
- paintRect.setX(buttonRect.x() - (cRealButtonLength[controlSize] - buttonRect.width()));
- } else {
- paintRect.setHeight(cRealButtonLength[controlSize]);
- if (!start)
- paintRect.setY(buttonRect.y() - (cRealButtonLength[controlSize] - buttonRect.height()));
- }
-
- return paintRect;
-}
-
-IntRect ScrollbarThemeSafari::backButtonRect(Scrollbar* scrollbar, ScrollbarPart part, bool painting)
-{
- IntRect result;
-
- // Windows just has single arrows.
- if (part == BackButtonEndPart)
- return result;
-
- int thickness = scrollbarThickness(scrollbar->controlSize());
- if (scrollbar->orientation() == HorizontalScrollbar)
- result = IntRect(scrollbar->x(), scrollbar->y(), cButtonLength[scrollbar->controlSize()], thickness);
- else
- result = IntRect(scrollbar->x(), scrollbar->y(), thickness, cButtonLength[scrollbar->controlSize()]);
- if (painting)
- return buttonRepaintRect(result, scrollbar->orientation(), scrollbar->controlSize(), true);
- return result;
-}
-
-IntRect ScrollbarThemeSafari::forwardButtonRect(Scrollbar* scrollbar, ScrollbarPart part, bool painting)
-{
- IntRect result;
-
- // Windows just has single arrows.
- if (part == ForwardButtonStartPart)
- return result;
-
- int thickness = scrollbarThickness(scrollbar->controlSize());
- if (scrollbar->orientation() == HorizontalScrollbar)
- result = IntRect(scrollbar->x() + scrollbar->width() - cButtonLength[scrollbar->controlSize()], scrollbar->y(), cButtonLength[scrollbar->controlSize()], thickness);
- else
- result = IntRect(scrollbar->x(), scrollbar->y() + scrollbar->height() - cButtonLength[scrollbar->controlSize()], thickness, cButtonLength[scrollbar->controlSize()]);
- if (painting)
- return buttonRepaintRect(result, scrollbar->orientation(), scrollbar->controlSize(), false);
- return result;
-}
-
-static IntRect trackRepaintRect(const IntRect& trackRect, ScrollbarOrientation orientation, ScrollbarControlSize controlSize)
-{
- IntRect paintRect(trackRect);
- if (orientation == HorizontalScrollbar)
- paintRect.inflateX(cButtonLength[controlSize]);
- else
- paintRect.inflateY(cButtonLength[controlSize]);
-
- return paintRect;
-}
-
-IntRect ScrollbarThemeSafari::trackRect(Scrollbar* scrollbar, bool painting)
-{
- if (painting || !hasButtons(scrollbar))
- return scrollbar->frameRect();
-
- IntRect result;
- int thickness = scrollbarThickness(scrollbar->controlSize());
- if (scrollbar->orientation() == HorizontalScrollbar)
- return IntRect(scrollbar->x() + cButtonLength[scrollbar->controlSize()], scrollbar->y(), scrollbar->width() - 2 * cButtonLength[scrollbar->controlSize()], thickness);
- return IntRect(scrollbar->x(), scrollbar->y() + cButtonLength[scrollbar->controlSize()], thickness, scrollbar->height() - 2 * cButtonLength[scrollbar->controlSize()]);
-}
-
-int ScrollbarThemeSafari::minimumThumbLength(Scrollbar* scrollbar)
-{
- return cThumbMinLength[scrollbar->controlSize()];
-}
-
-bool ScrollbarThemeSafari::shouldCenterOnThumb(Scrollbar*, const PlatformMouseEvent& evt)
-{
- return evt.shiftKey() && evt.button() == LeftButton;
-}
-
-void ScrollbarThemeSafari::paintTrackBackground(GraphicsContext* graphicsContext, Scrollbar* scrollbar, const IntRect& trackRect)
-{
- if (!SafariThemeLibrary())
- return;
- NSControlSize size = scrollbar->controlSize() == SmallScrollbar ? NSSmallControlSize : NSRegularControlSize;
- ThemeControlState state = 0;
- if (scrollbar->client()->isActive())
- state |= ActiveState;
- if (hasButtons(scrollbar))
- state |= EnabledState;
- paintThemePart(scrollbar->orientation() == VerticalScrollbar ? VScrollTrackPart : HScrollTrackPart, graphicsContext->platformContext(), trackRect, size, state);
-}
-
-void ScrollbarThemeSafari::paintButton(GraphicsContext* graphicsContext, Scrollbar* scrollbar, const IntRect& buttonRect, ScrollbarPart part)
-{
- if (!SafariThemeLibrary())
- return;
- NSControlSize size = scrollbar->controlSize() == SmallScrollbar ? NSSmallControlSize : NSRegularControlSize;
- ThemeControlState state = 0;
- if (scrollbar->client()->isActive())
- state |= ActiveState;
- if (hasButtons(scrollbar))
- state |= EnabledState;
- if (scrollbar->pressedPart() == part)
- state |= PressedState;
- if (part == BackButtonStartPart)
- paintThemePart(scrollbar->orientation() == VerticalScrollbar ? ScrollUpArrowPart : ScrollLeftArrowPart, graphicsContext->platformContext(),
- buttonRect, size, state);
- else if (part == ForwardButtonEndPart)
- paintThemePart(scrollbar->orientation() == VerticalScrollbar ? ScrollDownArrowPart : ScrollRightArrowPart, graphicsContext->platformContext(),
- buttonRect, size, state);
-}
-
-void ScrollbarThemeSafari::paintThumb(GraphicsContext* graphicsContext, Scrollbar* scrollbar, const IntRect& thumbRect)
-{
- if (!SafariThemeLibrary())
- return;
- NSControlSize size = scrollbar->controlSize() == SmallScrollbar ? NSSmallControlSize : NSRegularControlSize;
- ThemeControlState state = 0;
- if (scrollbar->client()->isActive())
- state |= ActiveState;
- if (hasThumb(scrollbar))
- state |= EnabledState;
- if (scrollbar->pressedPart() == ThumbPart)
- state |= PressedState;
- paintThemePart(scrollbar->orientation() == VerticalScrollbar ? VScrollThumbPart : HScrollThumbPart, graphicsContext->platformContext(),
- thumbRect, size, state);
-}
-
-}
-
-#endif
diff --git a/WebCore/platform/win/ScrollbarThemeSafari.h b/WebCore/platform/win/ScrollbarThemeSafari.h
deleted file mode 100644
index f039379..0000000
--- a/WebCore/platform/win/ScrollbarThemeSafari.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ScrollbarThemeSafari_h
-#define ScrollbarThemeSafari_h
-
-#if USE(SAFARI_THEME)
-
-#include "ScrollbarThemeComposite.h"
-
-namespace WebCore {
-
-class ScrollbarThemeSafari : public ScrollbarThemeComposite {
-public:
- virtual ~ScrollbarThemeSafari();
-
- virtual int scrollbarThickness(ScrollbarControlSize = RegularScrollbar);
-
- virtual bool supportsControlTints() const { return true; }
-
-protected:
- virtual bool hasButtons(Scrollbar*);
- virtual bool hasThumb(Scrollbar*);
-
- virtual IntRect backButtonRect(Scrollbar*, ScrollbarPart, bool painting = false);
- virtual IntRect forwardButtonRect(Scrollbar*, ScrollbarPart, bool painting = false);
- virtual IntRect trackRect(Scrollbar*, bool painting = false);
-
- virtual int minimumThumbLength(Scrollbar*);
-
- virtual bool shouldCenterOnThumb(Scrollbar*, const PlatformMouseEvent&);
-
- virtual void paintTrackBackground(GraphicsContext*, Scrollbar*, const IntRect&);
- virtual void paintButton(GraphicsContext*, Scrollbar*, const IntRect&, ScrollbarPart);
- virtual void paintThumb(GraphicsContext*, Scrollbar*, const IntRect&);
-};
-
-}
-#endif
-
-#endif
diff --git a/WebCore/platform/win/ScrollbarThemeWin.cpp b/WebCore/platform/win/ScrollbarThemeWin.cpp
deleted file mode 100644
index e13d893..0000000
--- a/WebCore/platform/win/ScrollbarThemeWin.cpp
+++ /dev/null
@@ -1,363 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ScrollbarThemeWin.h"
-
-#include "GraphicsContext.h"
-#include "PlatformMouseEvent.h"
-#include "Scrollbar.h"
-#include "SoftLinking.h"
-
-// Generic state constants
-#define TS_NORMAL 1
-#define TS_HOVER 2
-#define TS_ACTIVE 3
-#define TS_DISABLED 4
-
-#define SP_BUTTON 1
-#define SP_THUMBHOR 2
-#define SP_THUMBVERT 3
-#define SP_TRACKSTARTHOR 4
-#define SP_TRACKENDHOR 5
-#define SP_TRACKSTARTVERT 6
-#define SP_TRACKENDVERT 7
-#define SP_GRIPPERHOR 8
-#define SP_GRIPPERVERT 9
-
-#define TS_UP_BUTTON 0
-#define TS_DOWN_BUTTON 4
-#define TS_LEFT_BUTTON 8
-#define TS_RIGHT_BUTTON 12
-#define TS_UP_BUTTON_HOVER 17
-#define TS_DOWN_BUTTON_HOVER 18
-#define TS_LEFT_BUTTON_HOVER 19
-#define TS_RIGHT_BUTTON_HOVER 20
-
-using namespace std;
-
-namespace WebCore {
-
-static HANDLE scrollbarTheme;
-static bool haveTheme;
-static bool runningVista;
-
-// FIXME: Refactor the soft-linking code so that it can be shared with RenderThemeWin
-SOFT_LINK_LIBRARY(uxtheme)
-SOFT_LINK(uxtheme, OpenThemeData, HANDLE, WINAPI, (HWND hwnd, LPCWSTR pszClassList), (hwnd, pszClassList))
-SOFT_LINK(uxtheme, CloseThemeData, HRESULT, WINAPI, (HANDLE hTheme), (hTheme))
-SOFT_LINK(uxtheme, DrawThemeBackground, HRESULT, WINAPI, (HANDLE hTheme, HDC hdc, int iPartId, int iStateId, const RECT* pRect, const RECT* pClipRect), (hTheme, hdc, iPartId, iStateId, pRect, pClipRect))
-SOFT_LINK(uxtheme, IsThemeActive, BOOL, WINAPI, (), ())
-SOFT_LINK(uxtheme, IsThemeBackgroundPartiallyTransparent, BOOL, WINAPI, (HANDLE hTheme, int iPartId, int iStateId), (hTheme, iPartId, iStateId))
-
-static bool isRunningOnVistaOrLater()
-{
- static bool os = false;
- static bool initialized = false;
- if (!initialized) {
- OSVERSIONINFOEX vi = {sizeof(vi), 0};
- GetVersionEx((OSVERSIONINFO*)&vi);
-
- // NOTE: This does not work under a debugger - Vista shims Visual Studio,
- // making it believe it is xpsp2, which is inherited by debugged applications
- os = vi.dwMajorVersion >= 6;
- initialized = true;
- }
- return os;
-}
-
-static void checkAndInitScrollbarTheme()
-{
- if (uxthemeLibrary() && !scrollbarTheme)
- scrollbarTheme = OpenThemeData(0, L"Scrollbar");
- haveTheme = scrollbarTheme && IsThemeActive();
-}
-
-#if !USE(SAFARI_THEME)
-ScrollbarTheme* ScrollbarTheme::nativeTheme()
-{
- static ScrollbarThemeWin winTheme;
- return &winTheme;
-}
-#endif
-
-ScrollbarThemeWin::ScrollbarThemeWin()
-{
- static bool initialized;
- if (!initialized) {
- initialized = true;
- checkAndInitScrollbarTheme();
- runningVista = isRunningOnVistaOrLater();
- }
-}
-
-ScrollbarThemeWin::~ScrollbarThemeWin()
-{
-}
-
-int ScrollbarThemeWin::scrollbarThickness(ScrollbarControlSize)
-{
- static int thickness;
- if (!thickness)
- thickness = ::GetSystemMetrics(SM_CXVSCROLL);
- return thickness;
-}
-
-void ScrollbarThemeWin::themeChanged()
-{
- if (haveTheme)
- CloseThemeData(scrollbarTheme);
-}
-
-bool ScrollbarThemeWin::invalidateOnMouseEnterExit()
-{
- return runningVista;
-}
-
-bool ScrollbarThemeWin::hasThumb(Scrollbar* scrollbar)
-{
- return thumbLength(scrollbar) > 0;
-}
-
-IntRect ScrollbarThemeWin::backButtonRect(Scrollbar* scrollbar, ScrollbarPart part, bool)
-{
- // Windows just has single arrows.
- if (part == BackButtonEndPart)
- return IntRect();
-
- // Our desired rect is essentially 17x17.
-
- // Our actual rect will shrink to half the available space when
- // we have < 34 pixels left. This allows the scrollbar
- // to scale down and function even at tiny sizes.
- int thickness = scrollbarThickness();
- if (scrollbar->orientation() == HorizontalScrollbar)
- return IntRect(scrollbar->x(), scrollbar->y(),
- scrollbar->width() < 2 * thickness ? scrollbar->width() / 2 : thickness, thickness);
- return IntRect(scrollbar->x(), scrollbar->y(),
- thickness, scrollbar->height() < 2 * thickness ? scrollbar->height() / 2 : thickness);
-}
-
-IntRect ScrollbarThemeWin::forwardButtonRect(Scrollbar* scrollbar, ScrollbarPart part, bool)
-{
- // Windows just has single arrows.
- if (part == ForwardButtonStartPart)
- return IntRect();
-
- // Our desired rect is essentially 17x17.
-
- // Our actual rect will shrink to half the available space when
- // we have < 34 pixels left. This allows the scrollbar
- // to scale down and function even at tiny sizes.
- int thickness = scrollbarThickness();
- if (scrollbar->orientation() == HorizontalScrollbar) {
- int w = scrollbar->width() < 2 * thickness ? scrollbar->width() / 2 : thickness;
- return IntRect(scrollbar->x() + scrollbar->width() - w, scrollbar->y(), w, thickness);
- }
-
- int h = scrollbar->height() < 2 * thickness ? scrollbar->height() / 2 : thickness;
- return IntRect(scrollbar->x(), scrollbar->y() + scrollbar->height() - h, thickness, h);
-}
-
-IntRect ScrollbarThemeWin::trackRect(Scrollbar* scrollbar, bool)
-{
- int thickness = scrollbarThickness();
- if (scrollbar->orientation() == HorizontalScrollbar) {
- if (scrollbar->width() < 2 * thickness)
- return IntRect();
- return IntRect(scrollbar->x() + thickness, scrollbar->y(), scrollbar->width() - 2 * thickness, thickness);
- }
- if (scrollbar->height() < 2 * thickness)
- return IntRect();
- return IntRect(scrollbar->x(), scrollbar->y() + thickness, thickness, scrollbar->height() - 2 * thickness);
-}
-
-void ScrollbarThemeWin::paintTrackBackground(GraphicsContext* context, Scrollbar* scrollbar, const IntRect& rect)
-{
- // Just assume a forward track part. We only paint the track as a single piece when there is no thumb.
- if (!hasThumb(scrollbar))
- paintTrackPiece(context, scrollbar, rect, ForwardTrackPart);
-}
-
-void ScrollbarThemeWin::paintTrackPiece(GraphicsContext* context, Scrollbar* scrollbar, const IntRect& rect, ScrollbarPart partType)
-{
- checkAndInitScrollbarTheme();
-
- bool start = partType == BackTrackPart;
- int part;
- if (scrollbar->orientation() == HorizontalScrollbar)
- part = start ? SP_TRACKSTARTHOR : SP_TRACKENDHOR;
- else
- part = start ? SP_TRACKSTARTVERT : SP_TRACKENDVERT;
-
- int state;
- if (!scrollbar->enabled())
- state = TS_DISABLED;
- else if ((scrollbar->hoveredPart() == BackTrackPart && start) ||
- (scrollbar->hoveredPart() == ForwardTrackPart && !start))
- state = (scrollbar->pressedPart() == scrollbar->hoveredPart() ? TS_ACTIVE : TS_HOVER);
- else
- state = TS_NORMAL;
-
- bool alphaBlend = false;
- if (scrollbarTheme)
- alphaBlend = IsThemeBackgroundPartiallyTransparent(scrollbarTheme, part, state);
- HDC hdc = context->getWindowsContext(rect, alphaBlend);
- RECT themeRect(rect);
- if (scrollbarTheme)
- DrawThemeBackground(scrollbarTheme, hdc, part, state, &themeRect, 0);
- else {
- DWORD color3DFace = ::GetSysColor(COLOR_3DFACE);
- DWORD colorScrollbar = ::GetSysColor(COLOR_SCROLLBAR);
- DWORD colorWindow = ::GetSysColor(COLOR_WINDOW);
- if ((color3DFace != colorScrollbar) && (colorWindow != colorScrollbar))
- ::FillRect(hdc, &themeRect, HBRUSH(COLOR_SCROLLBAR+1));
- else {
- static WORD patternBits[8] = { 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55 };
- HBITMAP patternBitmap = ::CreateBitmap(8, 8, 1, 1, patternBits);
- HBRUSH brush = ::CreatePatternBrush(patternBitmap);
- SaveDC(hdc);
- ::SetTextColor(hdc, ::GetSysColor(COLOR_3DHILIGHT));
- ::SetBkColor(hdc, ::GetSysColor(COLOR_3DFACE));
- ::SetBrushOrgEx(hdc, rect.x(), rect.y(), NULL);
- ::SelectObject(hdc, brush);
- ::FillRect(hdc, &themeRect, brush);
- ::RestoreDC(hdc, -1);
- ::DeleteObject(brush);
- ::DeleteObject(patternBitmap);
- }
- }
- context->releaseWindowsContext(hdc, rect, alphaBlend);
-}
-
-void ScrollbarThemeWin::paintButton(GraphicsContext* context, Scrollbar* scrollbar, const IntRect& rect, ScrollbarPart part)
-{
- checkAndInitScrollbarTheme();
-
- bool start = (part == BackButtonStartPart);
- int xpState = 0;
- int classicState = 0;
- if (scrollbar->orientation() == HorizontalScrollbar)
- xpState = start ? TS_LEFT_BUTTON : TS_RIGHT_BUTTON;
- else
- xpState = start ? TS_UP_BUTTON : TS_DOWN_BUTTON;
- classicState = xpState / 4;
-
- if (!scrollbar->enabled()) {
- xpState += TS_DISABLED;
- classicState |= DFCS_INACTIVE;
- } else if ((scrollbar->hoveredPart() == BackButtonStartPart && start) ||
- (scrollbar->hoveredPart() == ForwardButtonEndPart && !start)) {
- if (scrollbar->pressedPart() == scrollbar->hoveredPart()) {
- xpState += TS_ACTIVE;
- classicState |= DFCS_PUSHED | DFCS_FLAT;
- } else
- xpState += TS_HOVER;
- } else {
- if (scrollbar->hoveredPart() == NoPart || !runningVista)
- xpState += TS_NORMAL;
- else {
- if (scrollbar->orientation() == HorizontalScrollbar)
- xpState = start ? TS_LEFT_BUTTON_HOVER : TS_RIGHT_BUTTON_HOVER;
- else
- xpState = start ? TS_UP_BUTTON_HOVER : TS_DOWN_BUTTON_HOVER;
- }
- }
-
- bool alphaBlend = false;
- if (scrollbarTheme)
- alphaBlend = IsThemeBackgroundPartiallyTransparent(scrollbarTheme, SP_BUTTON, xpState);
- HDC hdc = context->getWindowsContext(rect, alphaBlend);
-
- RECT themeRect(rect);
- if (scrollbarTheme)
- DrawThemeBackground(scrollbarTheme, hdc, SP_BUTTON, xpState, &themeRect, 0);
- else
- ::DrawFrameControl(hdc, &themeRect, DFC_SCROLL, classicState);
- context->releaseWindowsContext(hdc, rect, alphaBlend);
-}
-
-static IntRect gripperRect(int thickness, const IntRect& thumbRect)
-{
- // Center in the thumb.
- int gripperThickness = thickness / 2;
- return IntRect(thumbRect.x() + (thumbRect.width() - gripperThickness) / 2,
- thumbRect.y() + (thumbRect.height() - gripperThickness) / 2,
- gripperThickness, gripperThickness);
-}
-
-static void paintGripper(Scrollbar* scrollbar, HDC hdc, const IntRect& rect)
-{
- if (!scrollbarTheme)
- return; // Classic look has no gripper.
-
- int state;
- if (!scrollbar->enabled())
- state = TS_DISABLED;
- else if (scrollbar->pressedPart() == ThumbPart)
- state = TS_ACTIVE; // Thumb always stays active once pressed.
- else if (scrollbar->hoveredPart() == ThumbPart)
- state = TS_HOVER;
- else
- state = TS_NORMAL;
-
- RECT themeRect(rect);
- DrawThemeBackground(scrollbarTheme, hdc, scrollbar->orientation() == HorizontalScrollbar ? SP_GRIPPERHOR : SP_GRIPPERVERT, state, &themeRect, 0);
-}
-
-void ScrollbarThemeWin::paintThumb(GraphicsContext* context, Scrollbar* scrollbar, const IntRect& rect)
-{
- checkAndInitScrollbarTheme();
-
- int state;
- if (!scrollbar->enabled())
- state = TS_DISABLED;
- else if (scrollbar->pressedPart() == ThumbPart)
- state = TS_ACTIVE; // Thumb always stays active once pressed.
- else if (scrollbar->hoveredPart() == ThumbPart)
- state = TS_HOVER;
- else
- state = TS_NORMAL;
-
- bool alphaBlend = false;
- if (scrollbarTheme)
- alphaBlend = IsThemeBackgroundPartiallyTransparent(scrollbarTheme, scrollbar->orientation() == HorizontalScrollbar ? SP_THUMBHOR : SP_THUMBVERT, state);
- HDC hdc = context->getWindowsContext(rect, alphaBlend);
- RECT themeRect(rect);
- if (scrollbarTheme) {
- DrawThemeBackground(scrollbarTheme, hdc, scrollbar->orientation() == HorizontalScrollbar ? SP_THUMBHOR : SP_THUMBVERT, state, &themeRect, 0);
- paintGripper(scrollbar, hdc, gripperRect(scrollbarThickness(), rect));
- } else
- ::DrawEdge(hdc, &themeRect, EDGE_RAISED, BF_RECT | BF_MIDDLE);
- context->releaseWindowsContext(hdc, rect, alphaBlend);
-}
-
-bool ScrollbarThemeWin::shouldCenterOnThumb(Scrollbar*, const PlatformMouseEvent& evt)
-{
- return evt.shiftKey() && evt.button() == LeftButton;
-}
-
-}
-
diff --git a/WebCore/platform/win/ScrollbarThemeWin.h b/WebCore/platform/win/ScrollbarThemeWin.h
deleted file mode 100644
index 92e2523..0000000
--- a/WebCore/platform/win/ScrollbarThemeWin.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ScrollbarThemeWin_h
-#define ScrollbarThemeWin_h
-
-#include "ScrollbarThemeComposite.h"
-
-namespace WebCore {
-
-class ScrollbarThemeWin : public ScrollbarThemeComposite {
-public:
- ScrollbarThemeWin();
- virtual ~ScrollbarThemeWin();
-
- virtual int scrollbarThickness(ScrollbarControlSize = RegularScrollbar);
-
- virtual void themeChanged();
-
- virtual bool invalidateOnMouseEnterExit();
-
-protected:
- virtual bool hasButtons(Scrollbar*) { return true; }
- virtual bool hasThumb(Scrollbar*);
-
- virtual IntRect backButtonRect(Scrollbar*, ScrollbarPart, bool painting = false);
- virtual IntRect forwardButtonRect(Scrollbar*, ScrollbarPart, bool painting = false);
- virtual IntRect trackRect(Scrollbar*, bool painting = false);
-
- virtual bool shouldCenterOnThumb(Scrollbar*, const PlatformMouseEvent&);
-
- virtual void paintTrackBackground(GraphicsContext*, Scrollbar*, const IntRect&);
- virtual void paintTrackPiece(GraphicsContext*, Scrollbar*, const IntRect&, ScrollbarPart);
- virtual void paintButton(GraphicsContext*, Scrollbar*, const IntRect&, ScrollbarPart);
- virtual void paintThumb(GraphicsContext*, Scrollbar*, const IntRect&);
-};
-
-}
-#endif
diff --git a/WebCore/platform/win/SearchPopupMenuWin.cpp b/WebCore/platform/win/SearchPopupMenuWin.cpp
deleted file mode 100644
index f2709bb..0000000
--- a/WebCore/platform/win/SearchPopupMenuWin.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-#include "SearchPopupMenu.h"
-
-#include "AtomicString.h"
-#include <wtf/RetainPtr.h>
-
-namespace WebCore {
-
-SearchPopupMenu::SearchPopupMenu(PopupMenuClient* client)
- : PopupMenu(client)
-{
-}
-
-bool SearchPopupMenu::enabled()
-{
- return true;
-}
-
-static RetainPtr<CFStringRef> autosaveKey(const String& name)
-{
- String key = "com.apple.WebKit.searchField:" + name;
- return RetainPtr<CFStringRef>(AdoptCF, key.createCFString());
-}
-
-void SearchPopupMenu::saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems)
-{
- if (name.isEmpty())
- return;
-
- RetainPtr<CFMutableArrayRef> items;
-
- size_t size = searchItems.size();
- if (size) {
- items.adoptCF(CFArrayCreateMutable(0, size, &kCFTypeArrayCallBacks));
- for (size_t i = 0; i < size; ++i) {
- RetainPtr<CFStringRef> item(AdoptCF, searchItems[i].createCFString());
- CFArrayAppendValue(items.get(), item.get());
- }
- }
-
- CFPreferencesSetAppValue(autosaveKey(name).get(), items.get(), kCFPreferencesCurrentApplication);
- CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
-}
-
-void SearchPopupMenu::loadRecentSearches(const AtomicString& name, Vector<String>& searchItems)
-{
- if (name.isEmpty())
- return;
-
- searchItems.clear();
- RetainPtr<CFArrayRef> items(AdoptCF, reinterpret_cast<CFArrayRef>(CFPreferencesCopyAppValue(autosaveKey(name).get(), kCFPreferencesCurrentApplication)));
-
- if (!items || CFGetTypeID(items.get()) != CFArrayGetTypeID())
- return;
-
- size_t size = CFArrayGetCount(items.get());
- for (size_t i = 0; i < size; ++i) {
- CFStringRef item = (CFStringRef)CFArrayGetValueAtIndex(items.get(), i);
- if (CFGetTypeID(item) == CFStringGetTypeID())
- searchItems.append(item);
- }
-}
-
-}
diff --git a/WebCore/platform/win/SharedBufferWin.cpp b/WebCore/platform/win/SharedBufferWin.cpp
deleted file mode 100644
index ce93402..0000000
--- a/WebCore/platform/win/SharedBufferWin.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "SharedBuffer.h"
-
-namespace WebCore {
-
-PassRefPtr<SharedBuffer> SharedBuffer::createWithContentsOfFile(const String& filePath)
-{
- if (filePath.isEmpty())
- return 0;
-
- String nullifiedPath = filePath;
- FILE* fileDescriptor = 0;
- if (_wfopen_s(&fileDescriptor, nullifiedPath.charactersWithNullTermination(), TEXT("r+b")) || !fileDescriptor) {
- LOG_ERROR("Failed to open file %s to create shared buffer", filePath.ascii().data());
- return 0;
- }
-
- RefPtr<SharedBuffer> result;
-
- // Stat the file to get its size
- struct _stat64 fileStat;
- if (_fstat64(_fileno(fileDescriptor), &fileStat))
- goto exit;
-
- result = SharedBuffer::create();
- result->m_buffer.resize(fileStat.st_size);
- if (result->m_buffer.size() != fileStat.st_size) {
- result = 0;
- goto exit;
- }
-
- if (fread(result->m_buffer.data(), 1, fileStat.st_size, fileDescriptor) != fileStat.st_size)
- LOG_ERROR("Failed to fully read contents of file %s - errno(%i)", filePath.ascii().data(), errno);
-
-exit:
- fclose(fileDescriptor);
- return result.release();
-}
-
-}; // namespace WebCore
diff --git a/WebCore/platform/win/SharedTimerWin.cpp b/WebCore/platform/win/SharedTimerWin.cpp
deleted file mode 100644
index b611659..0000000
--- a/WebCore/platform/win/SharedTimerWin.cpp
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "SharedTimer.h"
-
-#include "Page.h"
-#include "SystemTime.h"
-#include "Widget.h"
-#include <wtf/Assertions.h>
-
-// Note: wx headers set defines that affect the configuration of windows.h
-// so we must include the wx header first to get unicode versions of functions,
-// etc.
-#if PLATFORM(WX)
-#include <wx/wx.h>
-#endif
-
-#include <windows.h>
-#include <mmsystem.h>
-
-// These aren't in winuser.h with the MSVS 2003 Platform SDK,
-// so use default values in that case.
-#ifndef USER_TIMER_MINIMUM
-#define USER_TIMER_MINIMUM 0x0000000A
-#endif
-
-#ifndef USER_TIMER_MAXIMUM
-#define USER_TIMER_MAXIMUM 0x7FFFFFFF
-#endif
-
-#ifndef QS_RAWINPUT
-#define QS_RAWINPUT 0x0400
-#endif
-
-#if PLATFORM(WIN)
-#include "PluginView.h"
-#endif
-
-namespace WebCore {
-
-static UINT timerID;
-static void (*sharedTimerFiredFunction)();
-
-static HWND timerWindowHandle = 0;
-static UINT timerFiredMessage = 0;
-static HANDLE timerQueue;
-static HANDLE timer;
-static Mutex timerMutex;
-static bool highResTimerActive;
-static bool processingCustomTimerMessage = false;
-static LONG pendingTimers;
-
-const LPCWSTR kTimerWindowClassName = L"TimerWindowClass";
-const int timerResolution = 1; // To improve timer resolution, we call timeBeginPeriod/timeEndPeriod with this value to increase timer resolution to 1ms.
-const int highResolutionThresholdMsec = 16; // Only activate high-res timer for sub-16ms timers (Windows can fire timers at 16ms intervals without changing the system resolution).
-const int stopHighResTimerInMsec = 300; // Stop high-res timer after 0.3 seconds to lessen power consumption (we don't use a smaller time since oscillating between high and low resolution breaks timer accuracy on XP).
-
-enum {
- sharedTimerID = 1000,
- endHighResTimerID = 1001,
-};
-
-LRESULT CALLBACK TimerWindowWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
-#if PLATFORM(WIN)
- // Windows Media Player has a modal message loop that will deliver messages
- // to us at inappropriate times and we will crash if we handle them when
- // they are delivered. We repost all messages so that we will get to handle
- // them once the modal loop exits.
- if (PluginView::isCallingPlugin()) {
- PostMessage(hWnd, message, wParam, lParam);
- return 0;
- }
-#endif
-
- if (message == timerFiredMessage) {
- InterlockedExchange(&pendingTimers, 0);
- processingCustomTimerMessage = true;
- sharedTimerFiredFunction();
- processingCustomTimerMessage = false;
- } else if (message == WM_TIMER) {
- if (wParam == sharedTimerID) {
- KillTimer(timerWindowHandle, sharedTimerID);
- sharedTimerFiredFunction();
- } else if (wParam == endHighResTimerID) {
- KillTimer(timerWindowHandle, endHighResTimerID);
- highResTimerActive = false;
- timeEndPeriod(timerResolution);
- }
- } else
- return DefWindowProc(hWnd, message, wParam, lParam);
-
- return 0;
-}
-
-static void initializeOffScreenTimerWindow()
-{
- if (timerWindowHandle)
- return;
-
- WNDCLASSEX wcex;
- memset(&wcex, 0, sizeof(WNDCLASSEX));
- wcex.cbSize = sizeof(WNDCLASSEX);
- wcex.lpfnWndProc = TimerWindowWndProc;
- wcex.hInstance = Page::instanceHandle();
- wcex.lpszClassName = kTimerWindowClassName;
- RegisterClassEx(&wcex);
-
- timerWindowHandle = CreateWindow(kTimerWindowClassName, 0, 0,
- CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, HWND_MESSAGE, 0, Page::instanceHandle(), 0);
- timerFiredMessage = RegisterWindowMessage(L"com.apple.WebKit.TimerFired");
-}
-
-void setSharedTimerFiredFunction(void (*f)())
-{
- sharedTimerFiredFunction = f;
-}
-
-static void clearTimer()
-{
- MutexLocker locker(timerMutex);
- if (timerQueue && timer)
- DeleteTimerQueueTimer(timerQueue, timer, 0);
- timer = 0;
-}
-
-static void NTAPI queueTimerProc(PVOID, BOOLEAN)
-{
- clearTimer();
- if (InterlockedIncrement(&pendingTimers) == 1)
- PostMessage(timerWindowHandle, timerFiredMessage, 0, 0);
-}
-
-void setSharedTimerFireTime(double fireTime)
-{
- ASSERT(sharedTimerFiredFunction);
-
- double interval = fireTime - currentTime();
- unsigned intervalInMS;
- if (interval < 0)
- intervalInMS = 0;
- else {
- interval *= 1000;
- if (interval > USER_TIMER_MAXIMUM)
- intervalInMS = USER_TIMER_MAXIMUM;
- else
- intervalInMS = (unsigned)interval;
- }
-
- if (interval < highResolutionThresholdMsec) {
- if (!highResTimerActive) {
- highResTimerActive = true;
- timeBeginPeriod(timerResolution);
- }
- SetTimer(timerWindowHandle, endHighResTimerID, stopHighResTimerInMsec, 0);
- }
-
- initializeOffScreenTimerWindow();
- bool timerSet = false;
- DWORD queueStatus = LOWORD(GetQueueStatus(QS_PAINT | QS_MOUSEBUTTON | QS_KEY | QS_RAWINPUT));
-
- // Win32 has a tri-level queue with application messages > user input > WM_PAINT/WM_TIMER.
-
- // If the queue doesn't contains input events, we use a higher priorty timer event posting mechanism.
- if (!(queueStatus & (QS_MOUSEBUTTON | QS_KEY | QS_RAWINPUT))) {
- if (intervalInMS < USER_TIMER_MINIMUM && !processingCustomTimerMessage && !(queueStatus & QS_PAINT)) {
- // Call PostMessage immediately if the timer is already expired, unless a paint is pending.
- // (we prioritize paints over timers)
- if (InterlockedIncrement(&pendingTimers) == 1)
- PostMessage(timerWindowHandle, timerFiredMessage, 0, 0);
- timerSet = true;
- } else {
- // Otherwise, delay the PostMessage via a CreateTimerQueueTimer
- if (!timerQueue)
- timerQueue = CreateTimerQueue();
- MutexLocker locker(timerMutex);
- if (timer)
- timerSet = ChangeTimerQueueTimer(timerQueue, timer, intervalInMS, 0);
- else
- timerSet = CreateTimerQueueTimer(&timer, timerQueue, queueTimerProc, 0, intervalInMS, 0, WT_EXECUTEINTIMERTHREAD | WT_EXECUTEONLYONCE);
- }
- }
-
- if (timerSet) {
- if (timerID) {
- KillTimer(timerWindowHandle, timerID);
- timerID = 0;
- }
- } else
- timerID = SetTimer(timerWindowHandle, sharedTimerID, intervalInMS, 0);
-}
-
-void stopSharedTimer()
-{
- clearTimer();
- if (timerID) {
- KillTimer(timerWindowHandle, timerID);
- timerID = 0;
- }
-}
-
-}
diff --git a/WebCore/platform/win/SoftLinking.h b/WebCore/platform/win/SoftLinking.h
deleted file mode 100644
index 761cb7a..0000000
--- a/WebCore/platform/win/SoftLinking.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef SoftLinking_h
-#define SoftLinking_h
-
-#include <windows.h>
-#include <wtf/Assertions.h>
-
-#define SOFT_LINK_LIBRARY_HELPER(lib, suffix) \
- static HMODULE lib##Library() \
- { \
- static HMODULE library = LoadLibraryW(L###lib suffix); \
- ASSERT(library); \
- return library; \
- }
-
-#define SOFT_LINK_LIBRARY(lib) SOFT_LINK_LIBRARY_HELPER(lib, L".dll")
-#define SOFT_LINK_DEBUG_LIBRARY(lib) SOFT_LINK_LIBRARY_HELPER(lib, L"_debug.dll")
-
-#define SOFT_LINK(library, functionName, resultType, callingConvention, parameterDeclarations, parameterNames) \
- static resultType callingConvention init##functionName parameterDeclarations; \
- static resultType (callingConvention*softLink##functionName) parameterDeclarations = init##functionName; \
- \
- static resultType callingConvention init##functionName parameterDeclarations \
- { \
- softLink##functionName = (resultType (callingConvention*) parameterDeclarations) GetProcAddress(library##Library(), #functionName); \
- ASSERT(softLink##functionName); \
- return softLink##functionName parameterNames; \
- }\
- \
- inline resultType functionName parameterDeclarations \
- {\
- return softLink##functionName parameterNames; \
- }
-
-#endif // SoftLinking_h
diff --git a/WebCore/platform/win/SoundWin.cpp b/WebCore/platform/win/SoundWin.cpp
deleted file mode 100644
index 443e7d9..0000000
--- a/WebCore/platform/win/SoundWin.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Sound.h"
-
-#include <Windows.h>
-
-namespace WebCore {
-
-void systemBeep() { MessageBeep(static_cast<UINT>(-1)); }
-
-} // namespace WebCore
-
diff --git a/WebCore/platform/win/SystemTimeWin.cpp b/WebCore/platform/win/SystemTimeWin.cpp
deleted file mode 100644
index 473e8de..0000000
--- a/WebCore/platform/win/SystemTimeWin.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "SystemTime.h"
-
-#include <DateMath.h>
-#include <windows.h>
-
-#if COMPILER(MINGW)
-#include <float.h>
-#define FLOAT_MAX FLT_MAX
-#endif
-
-namespace WebCore {
-
-double currentTime()
-{
- // Call through to our high-resolution JSC time code, since calls like GetSystemTimeAsFileTime and ftime are only accurate within 15ms.
- // This resolution can be improved with timeBeginPeriod/timeEndPeriod on Vista, but these calls don't
- // improve the resolution of date/time getters (GetSystemTimeAsFileTime, ftime, etc.) on XP.
- return JSC::getCurrentUTCTimeWithMicroseconds() * 0.001;
-}
-
-float userIdleTime()
-{
- LASTINPUTINFO lastInputInfo = {0};
- lastInputInfo.cbSize = sizeof(LASTINPUTINFO);
- if (::GetLastInputInfo(&lastInputInfo))
- return (GetTickCount() - lastInputInfo.dwTime) * 0.001; // ::GetTickCount returns ms of uptime valid for up to 49.7 days.
- return FLT_MAX; // return an arbitrarily high userIdleTime so that releasing pages from the page cache isn't postponed.
-}
-
-}
diff --git a/WebCore/platform/win/TemporaryLinkStubs.cpp b/WebCore/platform/win/TemporaryLinkStubs.cpp
deleted file mode 100644
index 80c8df0..0000000
--- a/WebCore/platform/win/TemporaryLinkStubs.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "NotImplemented.h"
-#include "SSLKeyGenerator.h"
-
-namespace WebCore {
-
-// <keygen>
-String signedPublicKeyAndChallengeString(unsigned, const String&, const KURL&) { notImplemented(); return String(); }
-void getSupportedKeySizes(Vector<String>&) { notImplemented(); }
-
-} // namespace WebCore
diff --git a/WebCore/platform/win/WCDataObject.cpp b/WebCore/platform/win/WCDataObject.cpp
deleted file mode 100644
index 5201bfa..0000000
--- a/WebCore/platform/win/WCDataObject.cpp
+++ /dev/null
@@ -1,381 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "WCDataObject.h"
-
-#include "PlatformString.h"
-
-namespace WebCore {
-
-class WCEnumFormatEtc : public IEnumFORMATETC
-{
-public:
- WCEnumFormatEtc(const Vector<FORMATETC>& formats);
- WCEnumFormatEtc(const Vector<FORMATETC*>& formats);
-
- //IUnknown members
- STDMETHOD(QueryInterface)(REFIID, void**);
- STDMETHOD_(ULONG, AddRef)(void);
- STDMETHOD_(ULONG, Release)(void);
-
- //IEnumFORMATETC members
- STDMETHOD(Next)(ULONG, LPFORMATETC, ULONG*);
- STDMETHOD(Skip)(ULONG);
- STDMETHOD(Reset)(void);
- STDMETHOD(Clone)(IEnumFORMATETC**);
-
-private:
- long m_ref;
- Vector<FORMATETC> m_formats;
- size_t m_current;
-};
-
-
-
-WCEnumFormatEtc::WCEnumFormatEtc(const Vector<FORMATETC>& formats)
-: m_ref(1)
-, m_current(0)
-{
- for(size_t i = 0; i < formats.size(); ++i)
- m_formats.append(formats[i]);
-}
-
-WCEnumFormatEtc::WCEnumFormatEtc(const Vector<FORMATETC*>& formats)
-: m_ref(1)
-, m_current(0)
-{
- for(size_t i = 0; i < formats.size(); ++i)
- m_formats.append(*formats[i]);
-}
-
-STDMETHODIMP WCEnumFormatEtc::QueryInterface(REFIID riid, void** ppvObject)
-{
- *ppvObject = 0;
- if (IsEqualIID(riid, IID_IUnknown) ||
- IsEqualIID(riid, IID_IEnumFORMATETC)) {
- *ppvObject = this;
- AddRef();
- return S_OK;
- }
-
- return E_NOINTERFACE;
-}
-
-STDMETHODIMP_(ULONG) WCEnumFormatEtc::AddRef(void)
-{
- return InterlockedIncrement(&m_ref);
-}
-
-STDMETHODIMP_(ULONG) WCEnumFormatEtc::Release(void)
-{
- long c = InterlockedDecrement(&m_ref);
- if (c == 0)
- delete this;
- return c;
-}
-
-STDMETHODIMP WCEnumFormatEtc::Next(ULONG celt, LPFORMATETC lpFormatEtc, ULONG* pceltFetched)
-{
- if(pceltFetched != 0)
- *pceltFetched=0;
-
- ULONG cReturn = celt;
-
- if(celt <= 0 || lpFormatEtc == 0 || m_current >= m_formats.size())
- return S_FALSE;
-
- if(pceltFetched == 0 && celt != 1) // pceltFetched can be 0 only for 1 item request
- return S_FALSE;
-
- while (m_current < m_formats.size() && cReturn > 0) {
- *lpFormatEtc++ = m_formats[m_current++];
- --cReturn;
- }
- if (pceltFetched != 0)
- *pceltFetched = celt - cReturn;
-
- return (cReturn == 0) ? S_OK : S_FALSE;
-}
-
-STDMETHODIMP WCEnumFormatEtc::Skip(ULONG celt)
-{
- if((m_current + int(celt)) >= m_formats.size())
- return S_FALSE;
- m_current += celt;
- return S_OK;
-}
-
-STDMETHODIMP WCEnumFormatEtc::Reset(void)
-{
- m_current = 0;
- return S_OK;
-}
-
-STDMETHODIMP WCEnumFormatEtc::Clone(IEnumFORMATETC** ppCloneEnumFormatEtc)
-{
- if(!ppCloneEnumFormatEtc)
- return E_POINTER;
-
- WCEnumFormatEtc *newEnum = new WCEnumFormatEtc(m_formats);
- if(!newEnum)
- return E_OUTOFMEMORY;
-
- newEnum->AddRef();
- newEnum->m_current = m_current;
- *ppCloneEnumFormatEtc = newEnum;
- return S_OK;
-}
-
-
-
-//////////////////////////////////////////////////////////////////////////
-
-HRESULT WCDataObject::createInstance(WCDataObject** result)
-{
- if (!result)
- return E_POINTER;
- *result = new WCDataObject();
- return S_OK;
-}
-
-WCDataObject::WCDataObject()
-: m_ref(1)
-{
-}
-
-WCDataObject::~WCDataObject()
-{
- for(size_t i = 0; i < m_medium.size(); ++i) {
- ReleaseStgMedium(m_medium[i]);
- delete m_medium[i];
- }
- WTF::deleteAllValues(m_formats);
-}
-
-STDMETHODIMP WCDataObject::QueryInterface(REFIID riid,void** ppvObject)
-{
- *ppvObject = 0;
- if (IID_IUnknown==riid || IID_IDataObject==riid)
- *ppvObject=this;
- if (*ppvObject) {
- AddRef();
- return S_OK;
- }
- return E_NOINTERFACE;
-}
-
-STDMETHODIMP_(ULONG) WCDataObject::AddRef( void)
-{
- return InterlockedIncrement(&m_ref);
-}
-
-STDMETHODIMP_(ULONG) WCDataObject::Release( void)
-{
- long c = InterlockedDecrement(&m_ref);
- if (c == 0)
- delete this;
- return c;
-}
-
-STDMETHODIMP WCDataObject::GetData(FORMATETC* pformatetcIn, STGMEDIUM* pmedium)
-{
- if(!pformatetcIn || !pmedium)
- return E_POINTER;
- pmedium->hGlobal = 0;
-
- for(size_t i=0; i < m_formats.size(); ++i) {
- if(/*pformatetcIn->tymed & m_formats[i]->tymed &&*/ // tymed can be 0 (TYMED_NULL) - but it can have a medium that contains an pUnkForRelease
- pformatetcIn->lindex == m_formats[i]->lindex &&
- pformatetcIn->dwAspect == m_formats[i]->dwAspect &&
- pformatetcIn->cfFormat == m_formats[i]->cfFormat) {
- CopyMedium(pmedium, m_medium[i], m_formats[i]);
- return S_OK;
- }
- }
- return DV_E_FORMATETC;
-}
-
-STDMETHODIMP WCDataObject::GetDataHere(FORMATETC*, STGMEDIUM*)
-{
- return E_NOTIMPL;
-}
-
-STDMETHODIMP WCDataObject::QueryGetData(FORMATETC* pformatetc)
-{
- if(!pformatetc)
- return E_POINTER;
-
- if (!(DVASPECT_CONTENT & pformatetc->dwAspect))
- return (DV_E_DVASPECT);
- HRESULT hr = DV_E_TYMED;
- for(size_t i = 0; i < m_formats.size(); ++i) {
- if(pformatetc->tymed & m_formats[i]->tymed) {
- if(pformatetc->cfFormat == m_formats[i]->cfFormat)
- return S_OK;
- else
- hr = DV_E_CLIPFORMAT;
- }
- else
- hr = DV_E_TYMED;
- }
- return hr;
-}
-
-STDMETHODIMP WCDataObject::GetCanonicalFormatEtc(FORMATETC*, FORMATETC*)
-{
- return DATA_S_SAMEFORMATETC;
-}
-
-STDMETHODIMP WCDataObject::SetData(FORMATETC* pformatetc, STGMEDIUM* pmedium, BOOL fRelease)
-{
- if(!pformatetc || !pmedium)
- return E_POINTER;
-
- FORMATETC* fetc=new FORMATETC;
- if (!fetc)
- return E_OUTOFMEMORY;
-
- STGMEDIUM* pStgMed = new STGMEDIUM;
-
- if(!pStgMed) {
- delete fetc;
- return E_OUTOFMEMORY;
- }
-
- ZeroMemory(fetc,sizeof(FORMATETC));
- ZeroMemory(pStgMed,sizeof(STGMEDIUM));
-
- *fetc = *pformatetc;
- m_formats.append(fetc);
-
- if(fRelease)
- *pStgMed = *pmedium;
- else
- CopyMedium(pStgMed, pmedium, pformatetc);
- m_medium.append(pStgMed);
-
- return S_OK;
-}
-
-void WCDataObject::CopyMedium(STGMEDIUM* pMedDest, STGMEDIUM* pMedSrc, FORMATETC* pFmtSrc)
-{
- switch(pMedSrc->tymed)
- {
- case TYMED_HGLOBAL:
- pMedDest->hGlobal = (HGLOBAL)OleDuplicateData(pMedSrc->hGlobal,pFmtSrc->cfFormat, 0);
- break;
- case TYMED_GDI:
- pMedDest->hBitmap = (HBITMAP)OleDuplicateData(pMedSrc->hBitmap,pFmtSrc->cfFormat, 0);
- break;
- case TYMED_MFPICT:
- pMedDest->hMetaFilePict = (HMETAFILEPICT)OleDuplicateData(pMedSrc->hMetaFilePict,pFmtSrc->cfFormat, 0);
- break;
- case TYMED_ENHMF:
- pMedDest->hEnhMetaFile = (HENHMETAFILE)OleDuplicateData(pMedSrc->hEnhMetaFile,pFmtSrc->cfFormat, 0);
- break;
- case TYMED_FILE:
- pMedSrc->lpszFileName = (LPOLESTR)OleDuplicateData(pMedSrc->lpszFileName,pFmtSrc->cfFormat, 0);
- break;
- case TYMED_ISTREAM:
- pMedDest->pstm = pMedSrc->pstm;
- pMedSrc->pstm->AddRef();
- break;
- case TYMED_ISTORAGE:
- pMedDest->pstg = pMedSrc->pstg;
- pMedSrc->pstg->AddRef();
- break;
- default:
- break;
- }
- pMedDest->tymed = pMedSrc->tymed;
- pMedDest->pUnkForRelease = 0;
- if(pMedSrc->pUnkForRelease != 0) {
- pMedDest->pUnkForRelease = pMedSrc->pUnkForRelease;
- pMedSrc->pUnkForRelease->AddRef();
- }
-}
-STDMETHODIMP WCDataObject::EnumFormatEtc(DWORD dwDirection, IEnumFORMATETC** ppenumFormatEtc)
-{
- if(!ppenumFormatEtc)
- return E_POINTER;
-
- *ppenumFormatEtc=0;
- switch (dwDirection)
- {
- case DATADIR_GET:
- *ppenumFormatEtc= new WCEnumFormatEtc(m_formats);
- if(!(*ppenumFormatEtc))
- return E_OUTOFMEMORY;
- break;
-
- case DATADIR_SET:
- default:
- return E_NOTIMPL;
- break;
- }
-
- return S_OK;
-}
-
-STDMETHODIMP WCDataObject::DAdvise(FORMATETC*, DWORD, IAdviseSink*,DWORD*)
-{
- return OLE_E_ADVISENOTSUPPORTED;
-}
-
-STDMETHODIMP WCDataObject::DUnadvise(DWORD)
-{
- return E_NOTIMPL;
-}
-
-HRESULT STDMETHODCALLTYPE WCDataObject::EnumDAdvise(IEnumSTATDATA**)
-{
- return OLE_E_ADVISENOTSUPPORTED;
-}
-
-void WCDataObject::clearData(CLIPFORMAT format)
-{
- size_t ptr = 0;
- while (ptr < m_formats.size()) {
- if (m_formats[ptr]->cfFormat == format) {
- FORMATETC* current = m_formats[ptr];
- m_formats[ptr] = m_formats[m_formats.size() - 1];
- m_formats[m_formats.size() - 1] = 0;
- m_formats.removeLast();
- delete current;
- STGMEDIUM* medium = m_medium[ptr];
- m_medium[ptr] = m_medium[m_medium.size() - 1];
- m_medium[m_medium.size() - 1] = 0;
- m_medium.removeLast();
- ReleaseStgMedium(medium);
- delete medium;
- continue;
- }
- ptr++;
- }
-}
-
-
-}
diff --git a/WebCore/platform/win/WCDataObject.h b/WebCore/platform/win/WCDataObject.h
deleted file mode 100644
index bdfb013..0000000
--- a/WebCore/platform/win/WCDataObject.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef WCDataObject_h
-#define WCDataObject_h
-
-#include <wtf/Vector.h>
-#include <ShlObj.h>
-#include <objidl.h>
-
-namespace WebCore {
-
-class String;
-
-class WCDataObject : public IDataObject {
-public:
- void CopyMedium(STGMEDIUM* pMedDest, STGMEDIUM* pMedSrc, FORMATETC* pFmtSrc);
-
- //IUnknown
- virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject);
- virtual ULONG STDMETHODCALLTYPE AddRef(void);
- virtual ULONG STDMETHODCALLTYPE Release(void);
-
- //IDataObject
- virtual HRESULT STDMETHODCALLTYPE GetData(FORMATETC* pformatIn, STGMEDIUM* pmedium);
- virtual HRESULT STDMETHODCALLTYPE GetDataHere(FORMATETC* pformat, STGMEDIUM* pmedium);
- virtual HRESULT STDMETHODCALLTYPE QueryGetData(FORMATETC* pformat);
- virtual HRESULT STDMETHODCALLTYPE GetCanonicalFormatEtc(FORMATETC* pformatectIn,FORMATETC* pformatOut);
- virtual HRESULT STDMETHODCALLTYPE SetData(FORMATETC* pformat, STGMEDIUM*pmedium, BOOL release);
- virtual HRESULT STDMETHODCALLTYPE EnumFormatEtc(DWORD dwDirection, IEnumFORMATETC** ppenumFormatEtc);
- virtual HRESULT STDMETHODCALLTYPE DAdvise(FORMATETC*, DWORD, IAdviseSink*, DWORD*);
- virtual HRESULT STDMETHODCALLTYPE DUnadvise(DWORD);
- virtual HRESULT STDMETHODCALLTYPE EnumDAdvise(IEnumSTATDATA**);
-
- void clearData(CLIPFORMAT);
-
- static HRESULT createInstance(WCDataObject**);
-private:
- WCDataObject();
- virtual ~WCDataObject();
- long m_ref;
- Vector<FORMATETC*> m_formats;
- Vector<STGMEDIUM*> m_medium;
-};
-
-}
-
-#endif //!WCDataObject_h
diff --git a/WebCore/platform/win/WebCoreTextRenderer.cpp b/WebCore/platform/win/WebCoreTextRenderer.cpp
deleted file mode 100644
index 75ce003..0000000
--- a/WebCore/platform/win/WebCoreTextRenderer.cpp
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "config.h"
-#include "WebCoreTextRenderer.h"
-
-#include "Font.h"
-#include "FontDescription.h"
-#include "GraphicsContext.h"
-#include "StringTruncator.h"
-#include <wtf/unicode/Unicode.h>
-
-namespace WebCore {
-
-static bool shouldUseFontSmoothing = true;
-
-static bool isOneLeftToRightRun(const TextRun& run)
-{
- for (int i = 0; i < run.length(); i++) {
- WTF::Unicode::Direction direction = WTF::Unicode::direction(run[i]);
- if (direction == WTF::Unicode::RightToLeft || direction > WTF::Unicode::OtherNeutral)
- return false;
- }
- return true;
-}
-
-static void doDrawTextAtPoint(GraphicsContext& context, const String& text, const IntPoint& point, const Font& font, const Color& color, int underlinedIndex)
-{
- TextRun run(text.characters(), text.length());
-
- context.setFillColor(color);
- if (isOneLeftToRightRun(run))
- font.drawText(&context, run, point);
- else {
- context.setFont(font);
- context.drawBidiText(run, point);
- }
-
- if (underlinedIndex >= 0) {
- ASSERT(underlinedIndex < static_cast<int>(text.length()));
-
- int beforeWidth;
- if (underlinedIndex > 0) {
- TextRun beforeRun(text.characters(), underlinedIndex);
- beforeWidth = font.width(beforeRun);
- } else
- beforeWidth = 0;
-
- TextRun underlinedRun(text.characters() + underlinedIndex, 1);
- int underlinedWidth = font.width(underlinedRun);
-
- IntPoint underlinePoint(point);
- underlinePoint.move(beforeWidth, 1);
-
- context.setStrokeColor(color);
- context.drawLineForText(underlinePoint, underlinedWidth, false);
- }
-}
-
-void WebCoreDrawTextAtPoint(GraphicsContext& context, const String& text, const IntPoint& point, const Font& font, const Color& color, int underlinedIndex)
-{
- context.save();
-
- doDrawTextAtPoint(context, text, point, font, color, underlinedIndex);
-
- context.restore();
-}
-
-void WebCoreDrawDoubledTextAtPoint(GraphicsContext& context, const String& text, const IntPoint& point, const Font& font, const Color& topColor, const Color& bottomColor, int underlinedIndex)
-{
- context.save();
-
- IntPoint textPos = point;
-
- doDrawTextAtPoint(context, text, textPos, font, bottomColor, underlinedIndex);
- textPos.move(0, -1);
- doDrawTextAtPoint(context, text, textPos, font, topColor, underlinedIndex);
-
- context.restore();
-}
-
-float WebCoreTextFloatWidth(const String& text, const Font& font)
-{
- return StringTruncator::width(text, font, false);
-}
-
-void WebCoreSetShouldUseFontSmoothing(bool smooth)
-{
- shouldUseFontSmoothing = smooth;
-}
-
-bool WebCoreShouldUseFontSmoothing()
-{
- return shouldUseFontSmoothing;
-}
-
-void WebCoreSetAlwaysUsesComplexTextCodePath(bool complex)
-{
- Font::setCodePath(complex ? Font::Complex : Font::Auto);
-}
-
-bool WebCoreAlwaysUsesComplexTextCodePath()
-{
- return Font::codePath() == Font::Complex;
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/win/WebCoreTextRenderer.h b/WebCore/platform/win/WebCoreTextRenderer.h
deleted file mode 100644
index 7b72946..0000000
--- a/WebCore/platform/win/WebCoreTextRenderer.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-namespace WebCore {
-
- class Color;
- class Font;
- class GraphicsContext;
- class IntPoint;
- class String;
-
- void WebCoreDrawTextAtPoint(GraphicsContext&, const String&, const IntPoint&, const Font&, const Color&, int underlinedIndex = -1);
- void WebCoreDrawDoubledTextAtPoint(GraphicsContext&, const String&, const IntPoint&, const Font&, const Color& topColor, const Color& bottomColor, int underlinedIndex = -1);
- float WebCoreTextFloatWidth(const String&, const Font&);
-
- void WebCoreSetShouldUseFontSmoothing(bool);
- bool WebCoreShouldUseFontSmoothing();
-
- void WebCoreSetAlwaysUsesComplexTextCodePath(bool);
- bool WebCoreAlwaysUsesComplexTextCodePath();
-
-} // namespace WebCore
diff --git a/WebCore/platform/win/WheelEventWin.cpp b/WebCore/platform/win/WheelEventWin.cpp
deleted file mode 100644
index d272ba7..0000000
--- a/WebCore/platform/win/WheelEventWin.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "PlatformWheelEvent.h"
-
-#include <windows.h>
-#include <windowsx.h>
-
-namespace WebCore {
-
-#define HIGH_BIT_MASK_SHORT 0x8000
-#define SPI_GETWHEELSCROLLCHARS 0x006C
-
-static IntPoint positionForEvent(HWND hWnd, LPARAM lParam)
-{
- POINT point = {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)};
- ScreenToClient(hWnd, &point);
- return point;
-}
-
-static IntPoint globalPositionForEvent(HWND hWnd, LPARAM lParam)
-{
- POINT point = {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)};
- return point;
-}
-
-int PlatformWheelEvent::horizontalLineMultiplier() const
-{
- static ULONG scrollChars;
- if (!scrollChars && !SystemParametersInfo(SPI_GETWHEELSCROLLCHARS, 0, &scrollChars, 0))
- scrollChars = cLineMultiplier;
- return scrollChars;
-}
-
-int PlatformWheelEvent::verticalLineMultiplier() const
-{
- static ULONG scrollLines;
- if (!scrollLines && !SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &scrollLines, 0))
- scrollLines = cLineMultiplier;
- return scrollLines;
-}
-
-PlatformWheelEvent::PlatformWheelEvent(HWND hWnd, WPARAM wParam, LPARAM lParam, bool isHorizontal)
- : m_position(positionForEvent(hWnd, lParam))
- , m_globalPosition(globalPositionForEvent(hWnd, lParam))
- , m_isAccepted(false)
- , m_shiftKey(wParam & MK_SHIFT)
- , m_ctrlKey(wParam & MK_CONTROL)
- , m_altKey(GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT)
- , m_metaKey(m_altKey) // FIXME: We'll have to test other browsers
-{
- static ULONG scrollLines, scrollChars;
- float delta = GET_WHEEL_DELTA_WPARAM(wParam) / (float)WHEEL_DELTA;
- if (isHorizontal) {
- // Windows sends a positive delta for scrolling right, while AppKit
- // sends a negative delta. EventHandler expects the AppKit values,
- // so we have to negate our horizontal delta to match.
- m_deltaX = -delta * horizontalLineMultiplier();
- m_deltaY = 0;
- m_granularity = ScrollByLineWheelEvent;
- } else {
- m_deltaX = 0;
- m_deltaY = delta;
- int verticalMultiplier = verticalLineMultiplier();
- // A multiplier of -1 is used to mean that vertical wheel scrolling should be done by page.
- m_granularity = (verticalMultiplier == -1) ? ScrollByPageWheelEvent : ScrollByLineWheelEvent;
- if (m_granularity == ScrollByLineWheelEvent)
- m_deltaY *= verticalMultiplier;
- }
-}
-
-}
diff --git a/WebCore/platform/win/WidgetWin.cpp b/WebCore/platform/win/WidgetWin.cpp
deleted file mode 100644
index 93dbf42..0000000
--- a/WebCore/platform/win/WidgetWin.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Widget.h"
-
-#include "Cursor.h"
-#include "Document.h"
-#include "Element.h"
-#include "GraphicsContext.h"
-#include "FrameWin.h"
-#include "IntRect.h"
-#include "FrameView.h"
-#include <winsock2.h>
-#include <windows.h>
-
-namespace WebCore {
-
-Widget::Widget(PlatformWidget widget)
-{
- init(widget);
-}
-
-Widget::~Widget()
-{
- ASSERT(!parent());
-}
-
-void Widget::show()
-{
-}
-
-void Widget::hide()
-{
-}
-
-HCURSOR lastSetCursor = 0;
-bool ignoreNextSetCursor = false;
-
-void Widget::setCursor(const Cursor& cursor)
-{
- // This is set by PluginViewWin so it can ignore set setCursor call made by
- // EventHandler.cpp.
- if (ignoreNextSetCursor) {
- ignoreNextSetCursor = false;
- return;
- }
-
- if (HCURSOR c = cursor.impl()->nativeCursor()) {
- lastSetCursor = c;
- SetCursor(c);
- }
-}
-
-void Widget::paint(GraphicsContext*, const IntRect&)
-{
-}
-
-void Widget::setFocus()
-{
-}
-
-void Widget::setIsSelected(bool)
-{
-}
-
-IntRect Widget::frameRect() const
-{
- return m_frame;
-}
-
-void Widget::setFrameRect(const IntRect& rect)
-{
- m_frame = rect;
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/win/WindowMessageBroadcaster.cpp b/WebCore/platform/win/WindowMessageBroadcaster.cpp
deleted file mode 100644
index 7088995..0000000
--- a/WebCore/platform/win/WindowMessageBroadcaster.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "WindowMessageBroadcaster.h"
-
-#include "WindowMessageListener.h"
-
-namespace WebCore {
-
-typedef HashMap<HWND, WindowMessageBroadcaster*> InstanceMap;
-
-static InstanceMap& instancesMap()
-{
- static InstanceMap instances;
- return instances;
-}
-
-void WindowMessageBroadcaster::addListener(HWND hwnd, WindowMessageListener* listener)
-{
- WindowMessageBroadcaster* broadcaster = instancesMap().get(hwnd);
- if (!broadcaster) {
- broadcaster = new WindowMessageBroadcaster(hwnd);
- instancesMap().add(hwnd, broadcaster);
- }
-
- broadcaster->addListener(listener);
-}
-
-void WindowMessageBroadcaster::removeListener(HWND hwnd, WindowMessageListener* listener)
-{
- WindowMessageBroadcaster* broadcaster = instancesMap().get(hwnd);
- if (!broadcaster)
- return;
-
- broadcaster->removeListener(listener);
-}
-
-WindowMessageBroadcaster::WindowMessageBroadcaster(HWND hwnd)
- : m_subclassedWindow(hwnd)
- , m_originalWndProc(0)
-{
- ASSERT_ARG(hwnd, IsWindow(hwnd));
-}
-
-WindowMessageBroadcaster::~WindowMessageBroadcaster()
-{
-}
-
-void WindowMessageBroadcaster::addListener(WindowMessageListener* listener)
-{
- if (m_listeners.isEmpty()) {
- ASSERT(!m_originalWndProc);
-#pragma warning(disable: 4244 4312)
- m_originalWndProc = reinterpret_cast<WNDPROC>(SetWindowLongPtr(m_subclassedWindow, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(SubclassedWndProc)));
- }
-
- m_listeners.add(listener);
-}
-
-void WindowMessageBroadcaster::removeListener(WindowMessageListener* listener)
-{
- ListenerSet::iterator found = m_listeners.find(listener);
- if (found == m_listeners.end())
- return;
-
- m_listeners.remove(found);
-
- if (m_listeners.isEmpty())
- destroy();
-}
-
-void WindowMessageBroadcaster::destroy()
-{
- m_listeners.clear();
- unsubclassWindow();
- instancesMap().remove(m_subclassedWindow);
- delete this;
-}
-
-void WindowMessageBroadcaster::unsubclassWindow()
-{
- SetWindowLongPtr(m_subclassedWindow, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(m_originalWndProc));
- m_originalWndProc = 0;
-}
-
-LRESULT CALLBACK WindowMessageBroadcaster::SubclassedWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
- WindowMessageBroadcaster* broadcaster = instancesMap().get(hwnd);
- ASSERT(broadcaster);
-
- ListenerSet::const_iterator end = broadcaster->listeners().end();
- for (ListenerSet::const_iterator it = broadcaster->listeners().begin(); it != end; ++it)
- (*it)->windowReceivedMessage(hwnd, message, wParam, lParam);
-
- WNDPROC originalWndProc = broadcaster->originalWndProc();
-
- // This will delete broadcaster.
- if (message == WM_DESTROY)
- broadcaster->destroy();
-
- return CallWindowProc(originalWndProc, hwnd, message, wParam, lParam);
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/win/WindowMessageBroadcaster.h b/WebCore/platform/win/WindowMessageBroadcaster.h
deleted file mode 100644
index 734f4b1..0000000
--- a/WebCore/platform/win/WindowMessageBroadcaster.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef WindowMessageBroadcaster_h
-#define WindowMessageBroadcaster_h
-
-#include <wtf/HashMap.h>
-#include <wtf/HashSet.h>
-#include <wtf/Noncopyable.h>
-
-namespace WebCore {
-
- class WindowMessageListener;
-
- class WindowMessageBroadcaster : Noncopyable {
- public:
- static void addListener(HWND, WindowMessageListener*);
- static void removeListener(HWND, WindowMessageListener*);
-
- private:
- typedef HashSet<WindowMessageListener*> ListenerSet;
-
- static LRESULT CALLBACK SubclassedWndProc(HWND, UINT, WPARAM, LPARAM);
-
- WindowMessageBroadcaster(HWND);
- ~WindowMessageBroadcaster();
-
- void addListener(WindowMessageListener*);
- void removeListener(WindowMessageListener*);
- const ListenerSet& listeners() const { return m_listeners; }
-
- void destroy();
- void unsubclassWindow();
-
- WNDPROC originalWndProc() const { return m_originalWndProc; }
-
- HWND m_subclassedWindow;
- WNDPROC m_originalWndProc;
- ListenerSet m_listeners;
- };
-
-} // namespace WebCore
-
-#endif // WindowMessageBroadcaster_h
diff --git a/WebCore/platform/win/WindowMessageListener.h b/WebCore/platform/win/WindowMessageListener.h
deleted file mode 100644
index b99cb35..0000000
--- a/WebCore/platform/win/WindowMessageListener.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef WindowMessageListener_h
-#define WindowMessageListener_h
-
-typedef struct HWND__* HWND;
-typedef long LPARAM;
-typedef unsigned UINT;
-typedef unsigned WPARAM;
-
-namespace WebCore {
-
- class WindowMessageListener {
- public:
- virtual void windowReceivedMessage(HWND, UINT message, WPARAM, LPARAM) = 0;
- };
-
-} // namespace WebCore
-
-#endif // WindowMessageListener_h
diff --git a/WebCore/platform/wx/ClipboardWx.cpp b/WebCore/platform/wx/ClipboardWx.cpp
deleted file mode 100644
index 461cc66..0000000
--- a/WebCore/platform/wx/ClipboardWx.cpp
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ClipboardWx.h"
-#include "HashTable.h"
-#include "IntPoint.h"
-#include "NotImplemented.h"
-#include "Pasteboard.h"
-#include "PlatformString.h"
-#include "StringHash.h"
-
-
-namespace WebCore {
-
-ClipboardWx::ClipboardWx(ClipboardAccessPolicy policy, bool forDragging)
- : Clipboard(policy, forDragging)
-{
-}
-
-void ClipboardWx::clearData(const String& type)
-{
- notImplemented();
-}
-
-void ClipboardWx::clearAllData()
-{
- Pasteboard::generalPasteboard()->clear();
-}
-
-String ClipboardWx::getData(const String& type, bool& success) const
-{
- notImplemented();
- return "";
-}
-
-bool ClipboardWx::setData(const String& type, const String& data)
-{
- notImplemented();
- return false;
-}
-
-// extensions beyond IE's API
-HashSet<String> ClipboardWx::types() const
-{
- notImplemented();
- HashSet<String> result;
- return result;
-}
-
-IntPoint ClipboardWx::dragLocation() const
-{
- notImplemented();
- return IntPoint(0,0);
-}
-
-CachedImage* ClipboardWx::dragImage() const
-{
- notImplemented();
- return 0;
-}
-
-void ClipboardWx::setDragImage(CachedImage*, const IntPoint&)
-{
- notImplemented();
-}
-
-Node* ClipboardWx::dragImageElement()
-{
- notImplemented();
- return 0;
-}
-
-void ClipboardWx::setDragImageElement(Node*, const IntPoint&)
-{
- notImplemented();
-}
-
-DragImageRef ClipboardWx::createDragImage(IntPoint& dragLoc) const
-{
- notImplemented();
- return 0;
-}
-
-void ClipboardWx::declareAndWriteDragImage(Element*, const KURL&, const String&, Frame*)
-{
- notImplemented();
-}
-
-void ClipboardWx::writeURL(const KURL& url, const String& string, Frame* frame)
-{
- Pasteboard::generalPasteboard()->writeURL(url, string, frame);
-}
-
-void ClipboardWx::writeRange(Range*, Frame*)
-{
- notImplemented();
-}
-
-bool ClipboardWx::hasData()
-{
- notImplemented();
- return false;
-}
-
-}
diff --git a/WebCore/platform/wx/ClipboardWx.h b/WebCore/platform/wx/ClipboardWx.h
deleted file mode 100644
index db5f7a8..0000000
--- a/WebCore/platform/wx/ClipboardWx.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ClipboardWx_h
-#define ClipboardWx_h
-
-#include "Clipboard.h"
-
-namespace WebCore {
-
- class CachedImage;
-
- // State available during IE's events for drag and drop and copy/paste
- class ClipboardWx : public Clipboard {
- public:
- static PassRefPtr<ClipboardWx> create(ClipboardAccessPolicy policy, bool forDragging)
- {
- return adoptRef(new ClipboardWx(policy, forDragging));
- }
-
- void clearData(const String& type);
- void clearAllData();
- String getData(const String& type, bool& success) const;
- bool setData(const String& type, const String& data);
-
- // extensions beyond IE's API
- HashSet<String> types() const;
-
- IntPoint dragLocation() const;
- CachedImage* dragImage() const;
- void setDragImage(CachedImage*, const IntPoint&);
- Node* dragImageElement();
- void setDragImageElement(Node*, const IntPoint&);
-
- virtual DragImageRef createDragImage(IntPoint& dragLoc) const;
- virtual void declareAndWriteDragImage(Element*, const KURL&, const String& title, Frame*);
- virtual void writeURL(const KURL&, const String&, Frame*);
- virtual void writeRange(Range*, Frame*);
-
- virtual bool hasData();
-
- private:
- ClipboardWx(ClipboardAccessPolicy, bool forDragging);
- };
-}
-
-#endif // ClipboardWx_h
diff --git a/WebCore/platform/wx/CursorWx.cpp b/WebCore/platform/wx/CursorWx.cpp
deleted file mode 100644
index 7175b01..0000000
--- a/WebCore/platform/wx/CursorWx.cpp
+++ /dev/null
@@ -1,301 +0,0 @@
-/*
- * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Cursor.h"
-#include "Image.h"
-
-#include <wx/defs.h>
-#include <wx/cursor.h>
-#include <wx/image.h>
-
-namespace WebCore {
-
-Cursor::Cursor(const Cursor& other)
- : m_impl(other.m_impl)
-{
-}
-
-Cursor::Cursor(Image* image, const IntPoint&)
-{
- m_impl = 0;
- // FIXME: figure out why the below code causes a crash
- //m_impl = new wxCursor( image->getWxBitmap()->ConvertToImage() );
-}
-
-Cursor::~Cursor()
-{
-}
-
-Cursor& Cursor::operator=(const Cursor& other)
-{
- m_impl = other.m_impl;
- return *this;
-}
-
-Cursor::Cursor(wxCursor* c)
- : m_impl(c)
-{
-}
-
-const Cursor& pointerCursor()
-{
- static Cursor c = new wxCursor(wxCURSOR_ARROW);
- return c;
-}
-
-const Cursor& crossCursor()
-{
- static Cursor c = new wxCursor(wxCURSOR_CROSS);
- return c;
-}
-
-const Cursor& handCursor()
-{
- static Cursor c = new wxCursor(wxCURSOR_HAND);
- return c;
-}
-
-const Cursor& iBeamCursor()
-{
- static Cursor c = new wxCursor(wxCURSOR_IBEAM);
- return c;
-}
-
-const Cursor& waitCursor()
-{
- static Cursor c = new wxCursor(wxCURSOR_WAIT);
- return c;
-}
-
-const Cursor& helpCursor()
-{
- static Cursor c = new wxCursor(wxCURSOR_QUESTION_ARROW);
- return c;
-}
-
-const Cursor& eastResizeCursor()
-{
- static Cursor c = new wxCursor(wxCURSOR_SIZEWE);
- return c;
-}
-
-const Cursor& northResizeCursor()
-{
- static Cursor c = new wxCursor(wxCURSOR_SIZENS);
- return c;
-}
-
-const Cursor& northEastResizeCursor()
-{
- static Cursor c = new wxCursor(wxCURSOR_SIZENESW);
- return c;
-}
-
-const Cursor& northWestResizeCursor()
-{
- static Cursor c = new wxCursor(wxCURSOR_SIZENWSE);
- return c;
-}
-
-const Cursor& southResizeCursor()
-{
- static Cursor c = northResizeCursor();
- return c;
-}
-
-const Cursor& southEastResizeCursor()
-{
- static Cursor c = northWestResizeCursor();
- return c;
-}
-
-const Cursor& southWestResizeCursor()
-{
- static Cursor c = northEastResizeCursor();
- return c;
-}
-
-const Cursor& westResizeCursor()
-{
- static Cursor c = eastResizeCursor();
- return c;
-}
-
-const Cursor& northSouthResizeCursor()
-{
- static Cursor c = northResizeCursor();
- return c;
-}
-
-const Cursor& eastWestResizeCursor()
-{
- static Cursor c = eastResizeCursor();
- return c;
-}
-
-const Cursor& northEastSouthWestResizeCursor()
-{
- static Cursor c = northEastResizeCursor();
- return c;
-}
-
-const Cursor& northWestSouthEastResizeCursor()
-{
- static Cursor c = northWestResizeCursor();
- return c;
-}
-
-const Cursor& columnResizeCursor()
-{
- // FIXME: Windows does not have a standard column resize cursor
- static Cursor c = new wxCursor(wxCURSOR_SIZING);
- return c;
-}
-
-const Cursor& rowResizeCursor()
-{
- // FIXME: Windows does not have a standard row resize cursor
- static Cursor c = new wxCursor(wxCURSOR_SIZING);
- return c;
-}
-
-const Cursor& middlePanningCursor()
-{
- return moveCursor();
-}
-
-const Cursor& eastPanningCursor()
-{
- return eastResizeCursor();
-}
-
-const Cursor& northPanningCursor()
-{
- return northResizeCursor();
-}
-
-const Cursor& northEastPanningCursor()
-{
- return northEastResizeCursor();
-}
-
-const Cursor& northWestPanningCursor()
-{
- return northWestResizeCursor();
-}
-
-const Cursor& southPanningCursor()
-{
- return southResizeCursor();
-}
-
-const Cursor& southEastPanningCursor()
-{
- return southEastResizeCursor();
-}
-
-const Cursor& southWestPanningCursor()
-{
- return southWestResizeCursor();
-}
-
-const Cursor& westPanningCursor()
-{
- return westResizeCursor();
-}
-
-const Cursor& verticalTextCursor()
-{
- return iBeamCursor();
-}
-
-const Cursor& cellCursor()
-{
- return pointerCursor();
-}
-
-const Cursor& contextMenuCursor()
-{
- return handCursor();
-}
-
-const Cursor& noDropCursor()
-{
- return pointerCursor();
-}
-
-const Cursor& progressCursor()
-{
- return waitCursor();
-}
-
-const Cursor& aliasCursor()
-{
- return pointerCursor();
-}
-
-const Cursor& copyCursor()
-{
- return pointerCursor();
-}
-
-const Cursor& noneCursor()
-{
- // TODO: Determine if we can find a better cursor for this.
- return pointerCursor();
-}
-
-const Cursor& notAllowedCursor()
-{
- static Cursor c = new wxCursor(wxCURSOR_NO_ENTRY);
- return c;
-}
-
-const Cursor& zoomInCursor()
-{
- static Cursor c = new wxCursor(wxCURSOR_MAGNIFIER);
- return c;
-}
-
-const Cursor& zoomOutCursor()
-{
- // TODO: Find a way to implement in/out magnifiers in wx.
- return zoomInCursor();
-}
-
-const Cursor& grabCursor()
-{
- // TODO: Determine if we can find a better cursor for this.
- return pointerCursor();
-}
-
-const Cursor& grabbingCursor()
-{
- // TODO: Determine if we can find a better cursor for this.
- return pointerCursor();
-}
-
-}
diff --git a/WebCore/platform/wx/DragDataWx.cpp b/WebCore/platform/wx/DragDataWx.cpp
deleted file mode 100644
index 97ea38c..0000000
--- a/WebCore/platform/wx/DragDataWx.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "DragData.h"
-
-#include "Clipboard.h"
-#include "Document.h"
-#include "DocumentFragment.h"
-
-namespace WebCore {
-
-bool DragData::canSmartReplace() const
-{
- return false;
-}
-
-bool DragData::containsColor() const
-{
- return false;
-}
-
-bool DragData::containsFiles() const
-{
- return false;
-}
-
-void DragData::asFilenames(Vector<String>& result) const
-{
-}
-
-bool DragData::containsPlainText() const
-{
- return false;
-}
-
-String DragData::asPlainText() const
-{
- return String();
-}
-
-Color DragData::asColor() const
-{
- return Color();
-}
-
-PassRefPtr<Clipboard> DragData::createClipboard(ClipboardAccessPolicy) const
-{
- return 0;
-}
-
-bool DragData::containsCompatibleContent() const
-{
- return false;
-}
-
-bool DragData::containsURL() const
-{
- return false;
-}
-
-String DragData::asURL(String* title) const
-{
- return String();
-}
-
-
-PassRefPtr<DocumentFragment> DragData::asFragment(Document*) const
-{
- return 0;
-}
-
-}
-
diff --git a/WebCore/platform/wx/DragImageWx.cpp b/WebCore/platform/wx/DragImageWx.cpp
deleted file mode 100644
index df2dcee..0000000
--- a/WebCore/platform/wx/DragImageWx.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "DragImage.h"
-#include "CachedImage.h"
-#include "FloatSize.h"
-#include "Image.h"
-
-namespace WebCore {
-
-IntSize dragImageSize(DragImageRef)
-{
- return IntSize(0, 0);
-}
-
-void deleteDragImage(DragImageRef)
-{
-}
-
-DragImageRef scaleDragImage(DragImageRef image, FloatSize)
-{
- return image;
-}
-
-DragImageRef dissolveDragImageToFraction(DragImageRef image, float)
-{
- return image;
-}
-
-DragImageRef createDragImageFromImage(Image*)
-{
- return 0;
-}
-
-DragImageRef createDragImageIconForCachedImage(CachedImage*)
-{
- return 0;
-}
-
-}
diff --git a/WebCore/platform/wx/EventLoopWx.cpp b/WebCore/platform/wx/EventLoopWx.cpp
deleted file mode 100644
index 99090ca..0000000
--- a/WebCore/platform/wx/EventLoopWx.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2008 Kevin Ollivier <kevino@theolliviers.com> All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "EventLoop.h"
-
-#include <wx/defs.h>
-#include <wx/app.h>
-
-namespace WebCore {
-
-void EventLoop::cycle()
-{
- if (wxTheApp) {
- if (wxTheApp->IsMainLoopRunning())
- wxTheApp->Dispatch();
- else
- m_ended = true;
- }
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/wx/FileSystemWx.cpp b/WebCore/platform/wx/FileSystemWx.cpp
deleted file mode 100644
index 7de425e..0000000
--- a/WebCore/platform/wx/FileSystemWx.cpp
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright (C) 2007 Kevin Ollivier
- * Copyright (C) 2008 Collabora, Ltd.
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "FileSystem.h"
-
-#include "CString.h"
-#include "NotImplemented.h"
-#include "PlatformString.h"
-
-#include <wx/wx.h>
-#include <wx/filename.h>
-
-namespace WebCore {
-
-bool fileExists(const String& path)
-{
- notImplemented();
- return true;
-}
-
-bool deleteFile(const String& path)
-{
- notImplemented();
- return false;
-}
-
-bool deleteEmptyDirectory(const String& path)
-{
- notImplemented();
- return false;
-}
-
-bool getFileSize(const String& path, long long& resultSize)
-{
- notImplemented();
- return false;
-}
-
-bool getFileModificationTime(const String&, time_t&)
-{
- notImplemented();
- return false;
-}
-
-bool makeAllDirectories(const String& path)
-{
- notImplemented();
- return false;
-}
-
-String pathByAppendingComponent(const String& path, const String& component)
-{
- notImplemented();
- return String();
-}
-
-String homeDirectoryPath()
-{
- notImplemented();
- return String();
-}
-
-String pathGetFileName(const String& path)
-{
- return wxFileName(path).GetFullName();
-}
-
-String directoryName(const String& path)
-{
- notImplemented();
- return String();
-}
-
-CString openTemporaryFile(const char* prefix, PlatformFileHandle& handle)
-{
- notImplemented();
- handle = invalidPlatformFileHandle;
- return CString();
-}
-
-void closeFile(PlatformFileHandle&)
-{
- notImplemented();
-}
-
-int writeToFile(PlatformFileHandle, const char* data, int length)
-{
- notImplemented();
- return 0;
-}
-
-bool unloadModule(PlatformModule)
-{
- notImplemented();
- return false;
-}
-
-Vector<String> listDirectory(const String& path, const String& filter)
-{
- Vector<String> entries;
- notImplemented();
- return entries;
-}
-
-}
diff --git a/WebCore/platform/wx/KeyEventWin.cpp b/WebCore/platform/wx/KeyEventWin.cpp
deleted file mode 100644
index f8f0155..0000000
--- a/WebCore/platform/wx/KeyEventWin.cpp
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "PlatformKeyboardEvent.h"
-#include <windows.h>
-
-#define REPEAT_COUNT_MASK 0x0000FFFF
-#define NEW_RELEASE_STATE_MASK 0x80000000
-#define PREVIOUS_DOWN_STATE_MASK 0x40000000
-#define ALT_KEY_DOWN_MASK 0x20000000
-
-#define HIGH_BIT_MASK_SHORT 0x8000
-
-namespace WebCore {
-
-// FIXME: This is incomplete. We should change this to mirror
-// more like what Firefox does, and generate these switch statements
-// at build time.
-static String keyIdentifierForWindowsKeyCode(short keyCode)
-{
- switch (keyCode) {
- case VK_MENU:
- return "Alt";
- case VK_CLEAR:
- return "Clear";
- case VK_DOWN:
- return "Down";
- // "End"
- case VK_END:
- return "End";
- // "Enter"
- case VK_RETURN:
- return "Enter";
- case VK_EXECUTE:
- return "Execute";
- case VK_F1:
- return "F1";
- case VK_F2:
- return "F2";
- case VK_F3:
- return "F3";
- case VK_F4:
- return "F4";
- case VK_F5:
- return "F5";
- case VK_F6:
- return "F6";
- case VK_F7:
- return "F7";
- case VK_F8:
- return "F8";
- case VK_F9:
- return "F9";
- case VK_F10:
- return "F11";
- case VK_F12:
- return "F12";
- case VK_F13:
- return "F13";
- case VK_F14:
- return "F14";
- case VK_F15:
- return "F15";
- case VK_F16:
- return "F16";
- case VK_F17:
- return "F17";
- case VK_F18:
- return "F18";
- case VK_F19:
- return "F19";
- case VK_F20:
- return "F20";
- case VK_F21:
- return "F21";
- case VK_F22:
- return "F22";
- case VK_F23:
- return "F23";
- case VK_F24:
- return "F24";
- case VK_HELP:
- return "Help";
- case VK_HOME:
- return "Home";
- case VK_INSERT:
- return "Insert";
- case VK_LEFT:
- return "Left";
- case VK_NEXT:
- return "PageDown";
- case VK_PRIOR:
- return "PageUp";
- case VK_PAUSE:
- return "Pause";
- case VK_SNAPSHOT:
- return "PrintScreen";
- case VK_RIGHT:
- return "Right";
- case VK_SCROLL:
- return "Scroll";
- case VK_SELECT:
- return "Select";
- case VK_UP:
- return "Up";
- // Standard says that DEL becomes U+007F.
- case VK_DELETE:
- return "U+007F";
- default:
- return String::sprintf("U+%04X", toupper(keyCode));
- }
-}
-
-static String singleCharacterString(UChar c) { return String(&c, 1); }
-
-PlatformKeyboardEvent::PlatformKeyboardEvent(HWND hWnd, WPARAM wParam, LPARAM lParam)
- : m_text(singleCharacterString(wParam))
- , m_unmodifiedText(singleCharacterString(wParam))
- , m_keyIdentifier(keyIdentifierForWindowsKeyCode(wParam))
- , m_isKeyUp((lParam & NEW_RELEASE_STATE_MASK))
- , m_autoRepeat(lParam & REPEAT_COUNT_MASK)
- , m_WindowsKeyCode(wParam)
- , m_isKeypad(false) // FIXME
- , m_shiftKey(GetAsyncKeyState(VK_SHIFT) & HIGH_BIT_MASK_SHORT)
- , m_ctrlKey(GetAsyncKeyState(VK_CONTROL) & HIGH_BIT_MASK_SHORT)
- , m_altKey(lParam & ALT_KEY_DOWN_MASK)
- , m_metaKey(lParam & ALT_KEY_DOWN_MASK) // FIXME: Is this right?
- , m_isModifierKeyPress(false)
-{
- if (!m_shiftKey)
- m_text = String(singleCharacterString(tolower(wParam)));
-}
-
-}
diff --git a/WebCore/platform/wx/KeyboardCodes.h b/WebCore/platform/wx/KeyboardCodes.h
deleted file mode 100644
index 86ee48c..0000000
--- a/WebCore/platform/wx/KeyboardCodes.h
+++ /dev/null
@@ -1,544 +0,0 @@
-/*
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef KeyboardCodes_h
-#define KeyboardCodes_h
-
-namespace WebCore {
-
-// VK_LBUTTON (01) Left mouse button
-// VK_RBUTTON (02) Right mouse button
-// VK_CANCEL (03) Control-break processing
-// VK_MBUTTON (04) Middle mouse button (three-button mouse)
-// VK_XBUTTON1 (05)
-// VK_XBUTTON2 (06)
-
-// VK_BACK (08) BACKSPACE key
-const int VK_BACK = 0x08;
-
-// VK_TAB (09) TAB key
-const int VK_TAB = 0x09;
-
-// VK_CLEAR (0C) CLEAR key
-const int VK_CLEAR = 0x0C;
-
-// VK_RETURN (0D)
-const int VK_RETURN = 0x0D;
-
-// VK_SHIFT (10) SHIFT key
-const int VK_SHIFT = 0x10;
-
-// VK_CONTROL (11) CTRL key
-const int VK_CONTROL = 0x11;
-
-// VK_MENU (12) ALT key
-const int VK_MENU = 0x12;
-
-// VK_PAUSE (13) PAUSE key
-const int VK_PAUSE = 0x13;
-
-// VK_CAPITAL (14) CAPS LOCK key
-const int VK_CAPITAL = 0x14;
-
-// VK_KANA (15) Input Method Editor (IME) Kana mode
-const int VK_KANA = 0x15;
-
-// VK_HANGUEL (15) IME Hanguel mode (maintained for compatibility; use VK_HANGUL)
-// VK_HANGUL (15) IME Hangul mode
-const int VK_HANGUL = 0x15;
-
-// VK_JUNJA (17) IME Junja mode
-const int VK_JUNJA = 0x17;
-
-// VK_FINAL (18) IME final mode
-const int VK_FINAL = 0x18;
-
-// VK_HANJA (19) IME Hanja mode
-const int VK_HANJA = 0x19;
-
-// VK_KANJI (19) IME Kanji mode
-const int VK_KANJI = 0x19;
-
-// VK_ESCAPE (1B) ESC key
-const int VK_ESCAPE = 0x1B;
-
-// VK_CONVERT (1C) IME convert
-const int VK_CONVERT = 0x1C;
-
-// VK_NONCONVERT (1D) IME nonconvert
-const int VK_NONCONVERT = 0x1D;
-
-// VK_ACCEPT (1E) IME accept
-const int VK_ACCEPT = 0x1E;
-
-// VK_MODECHANGE (1F) IME mode change request
-const int VK_MODECHANGE = 0x1F;
-
-// VK_SPACE (20) SPACEBAR
-const int VK_SPACE = 0x20;
-
-// VK_PRIOR (21) PAGE UP key
-const int VK_PRIOR = 0x21;
-
-// VK_NEXT (22) PAGE DOWN key
-const int VK_NEXT = 0x22;
-
-// VK_END (23) END key
-const int VK_END = 0x23;
-
-// VK_HOME (24) HOME key
-const int VK_HOME = 0x24;
-
-// VK_LEFT (25) LEFT ARROW key
-const int VK_LEFT = 0x25;
-
-// VK_UP (26) UP ARROW key
-const int VK_UP = 0x26;
-
-// VK_RIGHT (27) RIGHT ARROW key
-const int VK_RIGHT = 0x27;
-
-// VK_DOWN (28) DOWN ARROW key
-const int VK_DOWN = 0x28;
-
-// VK_SELECT (29) SELECT key
-const int VK_SELECT = 0x29;
-
-// VK_PRINT (2A) PRINT key
-const int VK_PRINT = 0x2A;
-
-// VK_EXECUTE (2B) EXECUTE key
-const int VK_EXECUTE = 0x2B;
-
-// VK_SNAPSHOT (2C) PRINT SCREEN key
-const int VK_SNAPSHOT = 0x2C;
-
-// VK_INSERT (2D) INS key
-const int VK_INSERT = 0x2D;
-
-// VK_DELETE (2E) DEL key
-const int VK_DELETE = 0x2E;
-
-// VK_HELP (2F) HELP key
-const int VK_HELP = 0x2F;
-
-// (30) 0 key
-const int VK_0 = 0x30;
-
-// (31) 1 key
-const int VK_1 = 0x31;
-
-// (32) 2 key
-const int VK_2 = 0x32;
-
-// (33) 3 key
-const int VK_3 = 0x33;
-
-// (34) 4 key
-const int VK_4 = 0x34;
-
-// (35) 5 key;
-
-const int VK_5 = 0x35;
-
-// (36) 6 key
-const int VK_6 = 0x36;
-
-// (37) 7 key
-const int VK_7 = 0x37;
-
-// (38) 8 key
-const int VK_8 = 0x38;
-
-// (39) 9 key
-const int VK_9 = 0x39;
-
-// (41) A key
-const int VK_A = 0x41;
-
-// (42) B key
-const int VK_B = 0x42;
-
-// (43) C key
-const int VK_C = 0x43;
-
-// (44) D key
-const int VK_D = 0x44;
-
-// (45) E key
-const int VK_E = 0x45;
-
-// (46) F key
-const int VK_F = 0x46;
-
-// (47) G key
-const int VK_G = 0x47;
-
-// (48) H key
-const int VK_H = 0x48;
-
-// (49) I key
-const int VK_I = 0x49;
-
-// (4A) J key
-const int VK_J = 0x4A;
-
-// (4B) K key
-const int VK_K = 0x4B;
-
-// (4C) L key
-const int VK_L = 0x4C;
-
-// (4D) M key
-const int VK_M = 0x4D;
-
-// (4E) N key
-const int VK_N = 0x4E;
-
-// (4F) O key
-const int VK_O = 0x4F;
-
-// (50) P key
-const int VK_P = 0x50;
-
-// (51) Q key
-const int VK_Q = 0x51;
-
-// (52) R key
-const int VK_R = 0x52;
-
-// (53) S key
-const int VK_S = 0x53;
-
-// (54) T key
-const int VK_T = 0x54;
-
-// (55) U key
-const int VK_U = 0x55;
-
-// (56) V key
-const int VK_V = 0x56;
-
-// (57) W key
-const int VK_W = 0x57;
-
-// (58) X key
-const int VK_X = 0x58;
-
-// (59) Y key
-const int VK_Y = 0x59;
-
-// (5A) Z key
-const int VK_Z = 0x5A;
-
-// VK_LWIN (5B) Left Windows key (Microsoft Natural keyboard)
-const int VK_LWIN = 0x5B;
-
-// VK_RWIN (5C) Right Windows key (Natural keyboard)
-const int VK_RWIN = 0x5C;
-
-// VK_APPS (5D) Applications key (Natural keyboard)
-const int VK_APPS = 0x5D;
-
-// VK_SLEEP (5F) Computer Sleep key
-const int VK_SLEEP = 0x5F;
-
-// VK_NUMPAD0 (60) Numeric keypad 0 key
-const int VK_NUMPAD0 = 0x60;
-
-// VK_NUMPAD1 (61) Numeric keypad 1 key
-const int VK_NUMPAD1 = 0x61;
-
-// VK_NUMPAD2 (62) Numeric keypad 2 key
-const int VK_NUMPAD2 = 0x62;
-
-// VK_NUMPAD3 (63) Numeric keypad 3 key
-const int VK_NUMPAD3 = 0x63;
-
-// VK_NUMPAD4 (64) Numeric keypad 4 key
-const int VK_NUMPAD4 = 0x64;
-
-// VK_NUMPAD5 (65) Numeric keypad 5 key
-const int VK_NUMPAD5 = 0x65;
-
-// VK_NUMPAD6 (66) Numeric keypad 6 key
-const int VK_NUMPAD6 = 0x66;
-
-// VK_NUMPAD7 (67) Numeric keypad 7 key
-const int VK_NUMPAD7 = 0x67;
-
-// VK_NUMPAD8 (68) Numeric keypad 8 key
-const int VK_NUMPAD8 = 0x68;
-
-// VK_NUMPAD9 (69) Numeric keypad 9 key
-const int VK_NUMPAD9 = 0x69;
-
-// VK_MULTIPLY (6A) Multiply key
-const int VK_MULTIPLY = 0x6A;
-
-// VK_ADD (6B) Add key
-const int VK_ADD = 0x6B;
-
-// VK_SEPARATOR (6C) Separator key
-const int VK_SEPARATOR = 0x6C;
-
-// VK_SUBTRACT (6D) Subtract key
-const int VK_SUBTRACT = 0x6D;
-
-// VK_DECIMAL (6E) Decimal key
-const int VK_DECIMAL = 0x6E;
-
-// VK_DIVIDE (6F) Divide key
-const int VK_DIVIDE = 0x6F;
-
-// VK_F1 (70) F1 key
-const int VK_F1 = 0x70;
-
-// VK_F2 (71) F2 key
-const int VK_F2 = 0x71;
-
-// VK_F3 (72) F3 key
-const int VK_F3 = 0x72;
-
-// VK_F4 (73) F4 key
-const int VK_F4 = 0x73;
-
-// VK_F5 (74) F5 key
-const int VK_F5 = 0x74;
-
-// VK_F6 (75) F6 key
-const int VK_F6 = 0x75;
-
-// VK_F7 (76) F7 key
-const int VK_F7 = 0x76;
-
-// VK_F8 (77) F8 key
-const int VK_F8 = 0x77;
-
-// VK_F9 (78) F9 key
-const int VK_F9 = 0x78;
-
-// VK_F10 (79) F10 key
-const int VK_F10 = 0x79;
-
-// VK_F11 (7A) F11 key
-const int VK_F11 = 0x7A;
-
-// VK_F12 (7B) F12 key
-const int VK_F12 = 0x7B;
-
-// VK_F13 (7C) F13 key
-const int VK_F13 = 0x7C;
-
-// VK_F14 (7D) F14 key
-const int VK_F14 = 0x7D;
-
-// VK_F15 (7E) F15 key
-const int VK_F15 = 0x7E;
-
-// VK_F16 (7F) F16 key
-const int VK_F16 = 0x7F;
-
-// VK_F17 (80H) F17 key
-const int VK_F17 = 0x80;
-
-// VK_F18 (81H) F18 key
-const int VK_F18 = 0x81;
-
-// VK_F19 (82H) F19 key
-const int VK_F19 = 0x82;
-
-// VK_F20 (83H) F20 key
-const int VK_F20 = 0x83;
-
-// VK_F21 (84H) F21 key
-const int VK_F21 = 0x84;
-
-// VK_F22 (85H) F22 key
-const int VK_F22 = 0x85;
-
-// VK_F23 (86H) F23 key
-const int VK_F23 = 0x86;
-
-// VK_F24 (87H) F24 key
-const int VK_F24 = 0x87;
-
-// VK_NUMLOCK (90) NUM LOCK key
-const int VK_NUMLOCK = 0x90;
-
-// VK_SCROLL (91) SCROLL LOCK key
-const int VK_SCROLL = 0x91;
-
-// VK_LSHIFT (A0) Left SHIFT key
-const int VK_LSHIFT = 0xA0;
-
-// VK_RSHIFT (A1) Right SHIFT key
-const int VK_RSHIFT = 0xA1;
-
-// VK_LCONTROL (A2) Left CONTROL key
-const int VK_LCONTROL = 0xA2;
-
-// VK_RCONTROL (A3) Right CONTROL key
-const int VK_RCONTROL = 0xA3;
-
-// VK_LMENU (A4) Left MENU key
-const int VK_LMENU = 0xA4;
-
-// VK_RMENU (A5) Right MENU key
-const int VK_RMENU = 0xA5;
-
-// VK_BROWSER_BACK (A6) Windows 2000/XP: Browser Back key
-const int VK_BROWSER_BACK = 0xA6;
-
-// VK_BROWSER_FORWARD (A7) Windows 2000/XP: Browser Forward key
-const int VK_BROWSER_FORWARD = 0xA7;
-
-// VK_BROWSER_REFRESH (A8) Windows 2000/XP: Browser Refresh key
-const int VK_BROWSER_REFRESH = 0xA8;
-
-// VK_BROWSER_STOP (A9) Windows 2000/XP: Browser Stop key
-const int VK_BROWSER_STOP = 0xA9;
-
-// VK_BROWSER_SEARCH (AA) Windows 2000/XP: Browser Search key
-const int VK_BROWSER_SEARCH = 0xAA;
-
-// VK_BROWSER_FAVORITES (AB) Windows 2000/XP: Browser Favorites key
-const int VK_BROWSER_FAVORITES = 0xAB;
-
-// VK_BROWSER_HOME (AC) Windows 2000/XP: Browser Start and Home key
-const int VK_BROWSER_HOME = 0xAC;
-
-// VK_VOLUME_MUTE (AD) Windows 2000/XP: Volume Mute key
-const int VK_VOLUME_MUTE = 0xAD;
-
-// VK_VOLUME_DOWN (AE) Windows 2000/XP: Volume Down key
-const int VK_VOLUME_DOWN = 0xAE;
-
-// VK_VOLUME_UP (AF) Windows 2000/XP: Volume Up key
-const int VK_VOLUME_UP = 0xAF;
-
-// VK_MEDIA_NEXT_TRACK (B0) Windows 2000/XP: Next Track key
-const int VK_MEDIA_NEXT_TRACK = 0xB0;
-
-// VK_MEDIA_PREV_TRACK (B1) Windows 2000/XP: Previous Track key
-const int VK_MEDIA_PREV_TRACK = 0xB1;
-
-// VK_MEDIA_STOP (B2) Windows 2000/XP: Stop Media key
-const int VK_MEDIA_STOP = 0xB2;
-
-// VK_MEDIA_PLAY_PAUSE (B3) Windows 2000/XP: Play/Pause Media key
-const int VK_MEDIA_PLAY_PAUSE = 0xB3;
-
-// VK_LAUNCH_MAIL (B4) Windows 2000/XP: Start Mail key
-const int VK_MEDIA_LAUNCH_MAIL = 0xB4;
-
-// VK_LAUNCH_MEDIA_SELECT (B5) Windows 2000/XP: Select Media key
-const int VK_MEDIA_LAUNCH_MEDIA_SELECT = 0xB5;
-
-// VK_LAUNCH_APP1 (B6) Windows 2000/XP: Start Application 1 key
-const int VK_MEDIA_LAUNCH_APP1 = 0xB6;
-
-// VK_LAUNCH_APP2 (B7) Windows 2000/XP: Start Application 2 key
-const int VK_MEDIA_LAUNCH_APP2 = 0xB7;
-
-// VK_OEM_1 (BA) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ';:' key
-const int VK_OEM_1 = 0xBA;
-
-// VK_OEM_PLUS (BB) Windows 2000/XP: For any country/region, the '+' key
-const int VK_OEM_PLUS = 0xBB;
-
-// VK_OEM_COMMA (BC) Windows 2000/XP: For any country/region, the ',' key
-const int VK_OEM_COMMA = 0xBC;
-
-// VK_OEM_MINUS (BD) Windows 2000/XP: For any country/region, the '-' key
-const int VK_OEM_MINUS = 0xBD;
-
-// VK_OEM_PERIOD (BE) Windows 2000/XP: For any country/region, the '.' key
-const int VK_OEM_PERIOD = 0xBE;
-
-// VK_OEM_2 (BF) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '/?' key
-const int VK_OEM_2 = 0xBF;
-
-// VK_OEM_3 (C0) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '`~' key
-const int VK_OEM_3 = 0xC0;
-
-// VK_OEM_4 (DB) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '[{' key
-const int VK_OEM_4 = 0xDB;
-
-// VK_OEM_5 (DC) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '\|' key
-const int VK_OEM_5 = 0xDC;
-
-// VK_OEM_6 (DD) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ']}' key
-const int VK_OEM_6 = 0xDD;
-
-// VK_OEM_7 (DE) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the 'single-quote/double-quote' key
-const int VK_OEM_7 = 0xDE;
-
-// VK_OEM_8 (DF) Used for miscellaneous characters; it can vary by keyboard.
-const int VK_OEM_8 = 0xDF;
-
-// VK_OEM_102 (E2) Windows 2000/XP: Either the angle bracket key or the backslash key on the RT 102-key keyboard
-const int VK_OEM_102 = 0xE2;
-
-// VK_PROCESSKEY (E5) Windows 95/98/Me, Windows NT 4.0, Windows 2000/XP: IME PROCESS key
-const int VK_PROCESSKEY = 0xE5;
-
-// VK_PACKET (E7) Windows 2000/XP: Used to pass Unicode characters as if they were keystrokes. The VK_PACKET key is the low word of a 32-bit Virtual Key value used for non-keyboard input methods. For more information, see Remark in KEYBDINPUT,SendInput, WM_KEYDOWN, and WM_KEYUP
-const int VK_PACKET = 0xE7;
-
-// VK_ATTN (F6) Attn key
-const int VK_ATTN = 0xF6;
-
-// VK_CRSEL (F7) CrSel key
-const int VK_CRSEL = 0xF7;
-
-// VK_EXSEL (F8) ExSel key
-const int VK_EXSEL = 0xF8;
-
-// VK_EREOF (F9) Erase EOF key
-const int VK_EREOF = 0xF9;
-
-// VK_PLAY (FA) Play key
-const int VK_PLAY = 0xFA;
-
-// VK_ZOOM (FB) Zoom key
-const int VK_ZOOM = 0xFB;
-
-// VK_NONAME (FC) Reserved for future use
-const int VK_NONAME = 0xFC;
-
-// VK_PA1 (FD) PA1 key
-const int VK_PA1 = 0xFD;
-
-// VK_OEM_CLEAR (FE) Clear key
-const int VK_OEM_CLEAR = 0xFE;
-
-const int VK_UNKNOWN = 0;
-
-}
-
-#endif
diff --git a/WebCore/platform/wx/KeyboardEventWx.cpp b/WebCore/platform/wx/KeyboardEventWx.cpp
deleted file mode 100644
index 8be87ac..0000000
--- a/WebCore/platform/wx/KeyboardEventWx.cpp
+++ /dev/null
@@ -1,372 +0,0 @@
-/*
- * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "PlatformKeyboardEvent.h"
-
-#include "KeyboardCodes.h"
-#include "NotImplemented.h"
-
-#include <wx/defs.h>
-#include <wx/event.h>
-
-namespace WebCore {
-
-static String keyIdentifierForWxKeyCode(int keyCode)
-{
- switch (keyCode) {
- case WXK_MENU:
- case WXK_ALT:
- return "Alt";
- case WXK_CLEAR:
- return "Clear";
- case WXK_DOWN:
- return "Down";
- case WXK_END:
- return "End";
- case WXK_RETURN:
- return "Enter";
- case WXK_EXECUTE:
- return "Execute";
- case WXK_F1:
- return "F1";
- case WXK_F2:
- return "F2";
- case WXK_F3:
- return "F3";
- case WXK_F4:
- return "F4";
- case WXK_F5:
- return "F5";
- case WXK_F6:
- return "F6";
- case WXK_F7:
- return "F7";
- case WXK_F8:
- return "F8";
- case WXK_F9:
- return "F9";
- case WXK_F10:
- return "F10";
- case WXK_F11:
- return "F11";
- case WXK_F12:
- return "F12";
- case WXK_F13:
- return "F13";
- case WXK_F14:
- return "F14";
- case WXK_F15:
- return "F15";
- case WXK_F16:
- return "F16";
- case WXK_F17:
- return "F17";
- case WXK_F18:
- return "F18";
- case WXK_F19:
- return "F19";
- case WXK_F20:
- return "F20";
- case WXK_F21:
- return "F21";
- case WXK_F22:
- return "F22";
- case WXK_F23:
- return "F23";
- case WXK_F24:
- return "F24";
- case WXK_HELP:
- return "Help";
- case WXK_HOME:
- return "Home";
- case WXK_INSERT:
- return "Insert";
- case WXK_LEFT:
- return "Left";
- case WXK_PAGEDOWN:
- return "PageDown";
- case WXK_PAGEUP:
- return "PageUp";
- case WXK_PAUSE:
- return "Pause";
- case WXK_PRINT:
- return "PrintScreen";
- case WXK_RIGHT:
- return "Right";
- case WXK_SELECT:
- return "Select";
- case WXK_UP:
- return "Up";
- // Standard says that DEL becomes U+007F.
- case WXK_DELETE:
- return "U+007F";
- default:
- return String::format("U+%04X", toupper(keyCode));
- }
-}
-
-static int windowsKeyCodeForKeyEvent(unsigned int keycode)
-{
- switch (keycode) {
- /* FIXME: Need to supply a bool in this func, to determine wheter the event comes from the keypad
- */
- case WXK_NUMPAD0:
- return VK_NUMPAD0;// (60) Numeric keypad 0 key
- case WXK_NUMPAD1:
- return VK_NUMPAD1;// (61) Numeric keypad 1 key
- case WXK_NUMPAD2:
- return VK_NUMPAD2; // (62) Numeric keypad 2 key
- case WXK_NUMPAD3:
- return VK_NUMPAD3; // (63) Numeric keypad 3 key
- case WXK_NUMPAD4:
- return VK_NUMPAD4; // (64) Numeric keypad 4 key
- case WXK_NUMPAD5:
- return VK_NUMPAD5; //(65) Numeric keypad 5 key
- case WXK_NUMPAD6:
- return VK_NUMPAD6; // (66) Numeric keypad 6 key
- case WXK_NUMPAD7:
- return VK_NUMPAD7; // (67) Numeric keypad 7 key
- case WXK_NUMPAD8:
- return VK_NUMPAD8; // (68) Numeric keypad 8 key
- case WXK_NUMPAD9:
- return VK_NUMPAD9; // (69) Numeric keypad 9 key
- case WXK_NUMPAD_MULTIPLY:
- return VK_MULTIPLY; // (6A) Multiply key
- case WXK_NUMPAD_ADD:
- return VK_ADD; // (6B) Add key
- case WXK_NUMPAD_SUBTRACT:
- return VK_SUBTRACT; // (6D) Subtract key
- case WXK_NUMPAD_DECIMAL:
- return VK_DECIMAL; // (6E) Decimal key
- case WXK_DIVIDE:
- return VK_DIVIDE; // (6F) Divide key
-
-
- case WXK_BACK:
- return VK_BACK; // (08) BACKSPACE key
- case WXK_TAB:
- return VK_TAB; // (09) TAB key
- case WXK_CLEAR:
- return VK_CLEAR; // (0C) CLEAR key
- case WXK_RETURN:
- return VK_RETURN; //(0D) Return key
- case WXK_SHIFT:
- return VK_SHIFT; // (10) SHIFT key
- case WXK_CONTROL:
- return VK_CONTROL; // (11) CTRL key
- case WXK_MENU:
- case WXK_ALT:
- return VK_MENU; // (12) ALT key
-
- case WXK_PAUSE:
- return VK_PAUSE; // (13) PAUSE key
- case WXK_CAPITAL:
- return VK_CAPITAL; // (14) CAPS LOCK key
- /*
- case WXK_Kana_Lock:
- case WXK_Kana_Shift:
- return VK_KANA; // (15) Input Method Editor (IME) Kana mode
- case WXK_Hangul:
- return VK_HANGUL; // VK_HANGUL (15) IME Hangul mode
- // VK_JUNJA (17) IME Junja mode
- // VK_FINAL (18) IME final mode
- case WXK_Hangul_Hanja:
- return VK_HANJA; // (19) IME Hanja mode
- case WXK_Kanji:
- return VK_KANJI; // (19) IME Kanji mode
- */
- case WXK_ESCAPE:
- return VK_ESCAPE; // (1B) ESC key
- // VK_CONVERT (1C) IME convert
- // VK_NONCONVERT (1D) IME nonconvert
- // VK_ACCEPT (1E) IME accept
- // VK_MODECHANGE (1F) IME mode change request
- case WXK_SPACE:
- return VK_SPACE; // (20) SPACEBAR
- case WXK_PAGEUP:
- return VK_PRIOR; // (21) PAGE UP key
- case WXK_PAGEDOWN:
- return VK_NEXT; // (22) PAGE DOWN key
- case WXK_END:
- return VK_END; // (23) END key
- case WXK_HOME:
- return VK_HOME; // (24) HOME key
- case WXK_LEFT:
- return VK_LEFT; // (25) LEFT ARROW key
- case WXK_UP:
- return VK_UP; // (26) UP ARROW key
- case WXK_RIGHT:
- return VK_RIGHT; // (27) RIGHT ARROW key
- case WXK_DOWN:
- return VK_DOWN; // (28) DOWN ARROW key
- case WXK_SELECT:
- return VK_SELECT; // (29) SELECT key
- case WXK_PRINT:
- return VK_PRINT; // (2A) PRINT key
- case WXK_EXECUTE:
- return VK_EXECUTE;// (2B) EXECUTE key
- //dunno on this
- //case WXK_PrintScreen:
- // return VK_SNAPSHOT; // (2C) PRINT SCREEN key
- case WXK_INSERT:
- return VK_INSERT; // (2D) INS key
- case WXK_DELETE:
- return VK_DELETE; // (2E) DEL key
- case WXK_HELP:
- return VK_HELP; // (2F) HELP key
- case '0':
- return VK_0; // (30) 0) key
- case '1':
- return VK_1; // (31) 1 ! key
- case '2':
- return VK_2; // (32) 2 & key
- case '3':
- return VK_3; //case '3': case '#';
- case '4': // (34) 4 key '$';
- return VK_4;
- case '5':
- return VK_5; // (35) 5 key '%'
- case '6':
- return VK_6; // (36) 6 key '^'
- case '7':
- return VK_7; // (37) 7 key case '&'
- case '8':
- return VK_8; // (38) 8 key '*'
- case '9':
- return VK_9; // (39) 9 key '('
- case 'A':
- return VK_A; // (41) A key case 'a': case 'A': return 0x41;
- case 'B':
- return VK_B; // (42) B key case 'b': case 'B': return 0x42;
- case 'C':
- return VK_C; // (43) C key case 'c': case 'C': return 0x43;
- case 'D':
- return VK_D; // (44) D key case 'd': case 'D': return 0x44;
- case 'E':
- return VK_E; // (45) E key case 'e': case 'E': return 0x45;
- case 'F':
- return VK_F; // (46) F key case 'f': case 'F': return 0x46;
- case 'G':
- return VK_G; // (47) G key case 'g': case 'G': return 0x47;
- case 'H':
- return VK_H; // (48) H key case 'h': case 'H': return 0x48;
- case 'I':
- return VK_I; // (49) I key case 'i': case 'I': return 0x49;
- case 'J':
- return VK_J; // (4A) J key case 'j': case 'J': return 0x4A;
- case 'K':
- return VK_K; // (4B) K key case 'k': case 'K': return 0x4B;
- case 'L':
- return VK_L; // (4C) L key case 'l': case 'L': return 0x4C;
- case 'M':
- return VK_M; // (4D) M key case 'm': case 'M': return 0x4D;
- case 'N':
- return VK_N; // (4E) N key case 'n': case 'N': return 0x4E;
- case 'O':
- return VK_O; // (4F) O key case 'o': case 'O': return 0x4F;
- case 'P':
- return VK_P; // (50) P key case 'p': case 'P': return 0x50;
- case 'Q':
- return VK_Q; // (51) Q key case 'q': case 'Q': return 0x51;
- case 'R':
- return VK_R; // (52) R key case 'r': case 'R': return 0x52;
- case 'S':
- return VK_S; // (53) S key case 's': case 'S': return 0x53;
- case 'T':
- return VK_T; // (54) T key case 't': case 'T': return 0x54;
- case 'U':
- return VK_U; // (55) U key case 'u': case 'U': return 0x55;
- case 'V':
- return VK_V; // (56) V key case 'v': case 'V': return 0x56;
- case 'W':
- return VK_W; // (57) W key case 'w': case 'W': return 0x57;
- case 'X':
- return VK_X; // (58) X key case 'x': case 'X': return 0x58;
- case 'Y':
- return VK_Y; // (59) Y key case 'y': case 'Y': return 0x59;
- case 'Z':
- return VK_Z; // (5A) Z key case 'z': case 'Z': return 0x5A;
- case WXK_WINDOWS_LEFT:
- return VK_LWIN; // (5B) Left Windows key (Microsoft Natural keyboard)
-
- case WXK_NUMLOCK:
- return VK_NUMLOCK; // (90) NUM LOCK key
-
- case WXK_SCROLL:
- return VK_SCROLL; // (91) SCROLL LOCK key
-
- default:
- return 0;
- }
-}
-
-PlatformKeyboardEvent::PlatformKeyboardEvent(wxKeyEvent& event)
-{
- if (event.GetEventType() == wxEVT_KEY_UP)
- m_type = KeyUp;
- else if (event.GetEventType() == wxEVT_KEY_DOWN)
- m_type = KeyDown;
- else if (event.GetEventType() == wxEVT_CHAR)
- m_type = Char;
- else
- ASSERT_NOT_REACHED();
- if (m_type != Char)
- m_keyIdentifier = keyIdentifierForWxKeyCode(event.GetKeyCode());
- else {
- m_text = wxString(event.GetUnicodeKey());
- m_unmodifiedText = m_text;
- }
- m_autoRepeat = false; // FIXME: not correct.
- m_windowsVirtualKeyCode = windowsKeyCodeForKeyEvent(event.GetKeyCode());
- m_nativeVirtualKeyCode = event.GetKeyCode();
- m_isKeypad = (event.GetKeyCode() >= WXK_NUMPAD_SPACE) && (event.GetKeyCode() <= WXK_NUMPAD_DIVIDE);
- m_shiftKey = event.ShiftDown();
- m_ctrlKey = event.CmdDown();
- m_altKey = event.AltDown();
- m_metaKey = event.MetaDown();
-}
-
-void PlatformKeyboardEvent::disambiguateKeyDownEvent(Type type, bool)
-{
- // Can only change type from KeyDown to RawKeyDown or Char, as we lack information for other conversions.
- ASSERT(m_type == KeyDown);
- m_type = type;
- if (type == RawKeyDown) {
- m_text = String();
- m_unmodifiedText = String();
- } else {
- m_keyIdentifier = String();
- m_windowsVirtualKeyCode = 0;
- }
-}
-
-bool PlatformKeyboardEvent::currentCapsLockState()
-{
- return wxGetKeyState(WXK_CAPITAL);
-}
-
-}
-
diff --git a/WebCore/platform/wx/LocalizedStringsWx.cpp b/WebCore/platform/wx/LocalizedStringsWx.cpp
deleted file mode 100644
index a315181..0000000
--- a/WebCore/platform/wx/LocalizedStringsWx.cpp
+++ /dev/null
@@ -1,321 +0,0 @@
-/*
- * Copyright (C) 2007 Kevin Ollivier
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "LocalizedStrings.h"
-
-#include "PlatformString.h"
-
-namespace WebCore {
-
-String submitButtonDefaultLabel()
-{
- return String("Submit");
-}
-
-String inputElementAltText()
-{
- return String();
-}
-
-String resetButtonDefaultLabel()
-{
- return String("Reset");
-}
-
-String defaultLanguage()
-{
- return String("en");
-}
-
-String searchableIndexIntroduction()
-{
- return String("Searchable Index");
-}
-
-String fileButtonChooseFileLabel()
-{
- return String("Choose File");
-}
-
-String fileButtonNoFileSelectedLabel()
-{
- return String("No file selected");
-}
-
-String contextMenuItemTagOpenLinkInNewWindow()
-{
- return String();
-}
-
-String contextMenuItemTagDownloadLinkToDisk()
-{
- return String();
-}
-
-String contextMenuItemTagCopyLinkToClipboard()
-{
- return String();
-}
-
-String contextMenuItemTagOpenImageInNewWindow()
-{
- return String();
-}
-
-String contextMenuItemTagDownloadImageToDisk()
-{
- return String();
-}
-
-String contextMenuItemTagCopyImageToClipboard()
-{
- return String();
-}
-
-String contextMenuItemTagOpenFrameInNewWindow()
-{
- return String();
-}
-
-String contextMenuItemTagCopy()
-{
- return String();
-}
-
-String contextMenuItemTagGoBack()
-{
- return String();
-}
-
-String contextMenuItemTagGoForward()
-{
- return String();
-}
-
-String contextMenuItemTagStop()
-{
- return String();
-}
-
-String contextMenuItemTagReload()
-{
- return String();
-}
-
-String contextMenuItemTagCut()
-{
- return String();
-}
-
-String contextMenuItemTagPaste()
-{
- return String();
-}
-
-String contextMenuItemTagNoGuessesFound()
-{
- return String();
-}
-
-String contextMenuItemTagIgnoreSpelling()
-{
- return String();
-}
-
-String contextMenuItemTagLearnSpelling()
-{
- return String();
-}
-
-String contextMenuItemTagSearchWeb()
-{
- return String();
-}
-
-String contextMenuItemTagLookUpInDictionary()
-{
- return String();
-}
-
-String contextMenuItemTagOpenLink()
-{
- return String();
-}
-
-String contextMenuItemTagIgnoreGrammar()
-{
- return String();
-}
-
-String contextMenuItemTagSpellingMenu()
-{
- return String();
-}
-
-String contextMenuItemTagShowSpellingPanel(bool show)
-{
- return String();
-}
-
-String contextMenuItemTagCheckSpelling()
-{
- return String();
-}
-
-String contextMenuItemTagCheckSpellingWhileTyping()
-{
- return String();
-}
-
-String contextMenuItemTagCheckGrammarWithSpelling()
-{
- return String();
-}
-
-String contextMenuItemTagFontMenu()
-{
- return String();
-}
-
-String contextMenuItemTagBold()
-{
- return String();
-}
-
-String contextMenuItemTagItalic()
-{
- return String();
-}
-
-String contextMenuItemTagUnderline()
-{
- return String();
-}
-
-String contextMenuItemTagOutline()
-{
- return String();
-}
-
-String contextMenuItemTagWritingDirectionMenu()
-{
- return String();
-}
-
-String contextMenuItemTagDefaultDirection()
-{
- return String();
-}
-
-String contextMenuItemTagLeftToRight()
-{
- return String();
-}
-
-String contextMenuItemTagRightToLeft()
-{
- return String();
-}
-
-String searchMenuNoRecentSearchesText()
-{
- return String("No recent searches");
-}
-
-String searchMenuRecentSearchesText()
-{
- return String("Recent searches");
-}
-
-String searchMenuClearRecentSearchesText()
-{
- return String("Clear recent searches");
-}
-
-String contextMenuItemTagInspectElement()
-{
- return String("Inspect Element");
-}
-
-String multipleFileUploadText(unsigned numberOfFiles)
-{
- // FIXME: If this file gets localized, this should really be localized as one string with a wildcard for the number.
- return String::number(numberOfFiles) + String(" files");
-}
-
-String unknownFileSizeText()
-{
- return String("Unknown");
-}
-
-String imageTitle(const String& filename, const IntSize& size)
-{
- return String();
-}
-
-// accessibility related strings
-String AXButtonActionVerb()
-{
- return String();
-}
-
-String AXRadioButtonActionVerb()
-{
- return String();
-}
-
-String AXTextFieldActionVerb()
-{
- return String();
-}
-
-String AXCheckedCheckBoxActionVerb()
-{
- return String();
-}
-
-String AXUncheckedCheckBoxActionVerb()
-{
- return String();
-}
-
-String AXLinkActionVerb()
-{
- return String();
-}
-
-String AXDefinitionListTermText()
-{
- return String();
-}
-
-String AXDefinitionListDefinitionText()
-{
- return String();
-}
-
-} // namespace WebCore
diff --git a/WebCore/platform/wx/LoggingWx.cpp b/WebCore/platform/wx/LoggingWx.cpp
deleted file mode 100644
index 006712c..0000000
--- a/WebCore/platform/wx/LoggingWx.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Logging.h"
-
-namespace WebCore {
-
-void InitializeLoggingChannelsIfNecessary()
-{
- LogNotYetImplemented.state = WTFLogChannelOn;
-}
-
-}
diff --git a/WebCore/platform/wx/MimeTypeRegistryWx.cpp b/WebCore/platform/wx/MimeTypeRegistryWx.cpp
deleted file mode 100644
index c025d02..0000000
--- a/WebCore/platform/wx/MimeTypeRegistryWx.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2006 Zack Rusin <zack@kde.org>
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "MIMETypeRegistry.h"
-
-namespace WebCore {
-
-struct ExtensionMap {
- const char* extension;
- const char* mimeType;
-};
-static const ExtensionMap extensionMap [] = {
- { "bmp", "image/bmp" },
- { "css", "text/css" },
- { "gif", "image/gif" },
- { "html", "text/html" },
- { "ico", "image/x-icon" },
- { "jpeg", "image/jpeg" },
- { "jpg", "image/jpeg" },
- { "js", "application/x-javascript" },
- { "pdf", "application/pdf" },
- { "png", "image/png" },
- { "rss", "application/rss+xml" },
- { "svg", "image/svg+xml" },
- { "text", "text/plain" },
- { "txt", "text/plain" },
- { "xbm", "image/x-xbitmap" },
- { "xml", "text/xml" },
- { "xsl", "text/xsl" },
- { "xhtml", "application/xhtml+xml" },
- { 0, 0 }
-};
-
-String MIMETypeRegistry::getMIMETypeForExtension(const String &ext)
-{
- String s = ext.lower();
- const ExtensionMap *e = extensionMap;
- while (e->extension) {
- if (s == e->extension)
- return e->mimeType;
- ++e;
- }
- // unknown, let's just assume plain text
- return "text/plain";
-}
-
-}
diff --git a/WebCore/platform/wx/MouseEventWx.cpp b/WebCore/platform/wx/MouseEventWx.cpp
deleted file mode 100644
index c9468a9..0000000
--- a/WebCore/platform/wx/MouseEventWx.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "Assertions.h"
-#include "PlatformMouseEvent.h"
-#include "SystemTime.h"
-
-#include <wx/defs.h>
-#include <wx/event.h>
-
-namespace WebCore {
-
-PlatformMouseEvent::PlatformMouseEvent(const wxMouseEvent& event, const wxPoint& globalPoint)
- : m_position(event.GetPosition())
- , m_globalPosition(globalPoint)
- , m_shiftKey(event.ShiftDown())
- , m_ctrlKey(event.CmdDown())
- , m_altKey(event.AltDown())
- , m_metaKey(event.MetaDown()) // FIXME: We'll have to test other browsers
-{
- wxEventType type = event.GetEventType();
- m_eventType = MouseEventMoved;
-
- if (type == wxEVT_LEFT_DOWN || type == wxEVT_MIDDLE_DOWN || type == wxEVT_RIGHT_DOWN)
- m_eventType = MouseEventPressed;
-
- else if (type == wxEVT_LEFT_UP || type == wxEVT_MIDDLE_UP || type == wxEVT_RIGHT_UP ||
- type == wxEVT_LEFT_DCLICK || type == wxEVT_MIDDLE_DCLICK || type == wxEVT_RIGHT_DCLICK)
- m_eventType = MouseEventReleased;
-
- else if (type == wxEVT_MOTION)
- m_eventType = MouseEventMoved;
-
- if (event.LeftIsDown() || event.Button(wxMOUSE_BTN_LEFT))
- m_button = LeftButton;
- else if (event.RightIsDown() || event.Button(wxMOUSE_BTN_RIGHT))
- m_button = RightButton;
- else if (event.MiddleIsDown() || event.Button(wxMOUSE_BTN_MIDDLE))
- m_button = MiddleButton;
- else if (!m_eventType == MouseEventMoved)
- ASSERT_NOT_REACHED();
-
-
- if (m_eventType == MouseEventMoved)
- m_clickCount = 0;
- else
- m_clickCount = event.ButtonDClick() ? 2 : 1;
-
- m_timestamp = WebCore::currentTime();
-}
-
-}
diff --git a/WebCore/platform/wx/MouseWheelEventWx.cpp b/WebCore/platform/wx/MouseWheelEventWx.cpp
deleted file mode 100644
index 154a710..0000000
--- a/WebCore/platform/wx/MouseWheelEventWx.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "PlatformWheelEvent.h"
-
-#include <wx/defs.h>
-#include <wx/event.h>
-
-namespace WebCore {
-
-PlatformWheelEvent::PlatformWheelEvent(const wxMouseEvent& event, const wxPoint& globalPoint)
- : m_position(event.GetPosition())
- , m_globalPosition(globalPoint)
- , m_granularity(ScrollByLineWheelEvent)
- , m_shiftKey(event.ShiftDown())
- , m_ctrlKey(event.ControlDown())
- , m_altKey(event.AltDown())
- , m_metaKey(event.MetaDown()) // FIXME: We'll have to test other browsers
- , m_deltaX(0) // wx doesn't support horizontal mouse wheel scrolling
- , m_deltaY(event.GetWheelRotation() / event.GetWheelDelta())
- , m_isAccepted(false)
-{
- // FIXME: retrieve the user setting for the number of lines to scroll on each wheel event
- m_deltaY *= horizontalLineMultiplier();
-}
-
-}
diff --git a/WebCore/platform/wx/PasteboardWx.cpp b/WebCore/platform/wx/PasteboardWx.cpp
deleted file mode 100644
index 3b71e9a..0000000
--- a/WebCore/platform/wx/PasteboardWx.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "Pasteboard.h"
-#include "DocumentFragment.h"
-#include "Editor.h"
-#include "Frame.h"
-#include "KURL.h"
-#include "markup.h"
-#include "PlatformString.h"
-
-#include <wx/defs.h>
-#include <wx/dataobj.h>
-#include <wx/clipbrd.h>
-
-namespace WebCore {
-
-Pasteboard::Pasteboard()
-{
-}
-
-Pasteboard* Pasteboard::generalPasteboard()
-{
- static Pasteboard* pasteboard = new Pasteboard();
- return pasteboard;
-}
-
-void Pasteboard::writeSelection(Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame)
-{
- if (wxTheClipboard->Open())
- {
- String text = frame->selectedText();
- text.replace('\\', frame->backslashAsCurrencySymbol());
-
- wxTheClipboard->SetData( new wxTextDataObject(text) );
- wxTheClipboard->Close();
- }
-}
-
-bool Pasteboard::canSmartReplace()
-{
- return false;
-}
-
-String Pasteboard::plainText(Frame* frame)
-{
- return String();
-}
-
-PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefPtr<Range> context,
- bool allowPlainText, bool& chosePlainText)
-{
- return 0;
-}
-
-void Pasteboard::writeURL(const KURL& url, const String&, Frame*)
-{
- if (wxTheClipboard->Open())
- {
- wxTheClipboard->SetData( new wxTextDataObject( url.string() ) );
- wxTheClipboard->Close();
- }
-}
-
-void Pasteboard::clear()
-{
- wxTheClipboard->Clear();
-}
-
-void Pasteboard::writeImage(Node*, const KURL&, const String& title)
-{
-}
-
-}
diff --git a/WebCore/platform/wx/PopupMenuWx.cpp b/WebCore/platform/wx/PopupMenuWx.cpp
deleted file mode 100644
index 4563b77..0000000
--- a/WebCore/platform/wx/PopupMenuWx.cpp
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * This file is part of the popup menu implementation for <select> elements in WebCore.
- *
- * Copyright (C) 2008 Apple Computer, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "PopupMenu.h"
-
-#include "Frame.h"
-#include "FrameView.h"
-#include "NotImplemented.h"
-#include "PopupMenuClient.h"
-#include "PlatformString.h"
-
-#include <wx/defs.h>
-#if __WXMSW__
-#include <wx/msw/winundef.h>
-#endif
-#include <wx/event.h>
-#include <wx/menu.h>
-
-static int s_menuStartId = wxNewId();
-
-
-
-namespace WebCore {
-
-PopupMenu::PopupMenu(PopupMenuClient* client)
- : m_popupClient(client)
- , m_menu(NULL)
-{
-}
-
-PopupMenu::~PopupMenu()
-{
- delete m_menu;
-}
-
-void PopupMenu::show(const IntRect& r, FrameView* v, int index)
-{
- // just delete and recreate
- delete m_menu;
- ASSERT(client());
-
- wxWindow* nativeWin = v->platformWidget();
-
- if (nativeWin) {
- // construct the menu
- m_menu = new wxMenu();
- int size = client()->listSize();
- for (int i = 0; i < size; i++) {
- int id = s_menuStartId + i;
-
- if (client()->itemIsSeparator(i)) {
- m_menu->AppendSeparator();
- }
- else {
- // FIXME: appending a menu item with an empty label asserts in
- // wx. This needs to be fixed at wx level so that we can have
- // the concept of "no selection" in choice boxes, etc.
- if (!client()->itemText(i).isEmpty())
- m_menu->Append(s_menuStartId + i, client()->itemText(i));
- }
- }
- nativeWin->Connect(s_menuStartId, s_menuStartId + (size-1), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(PopupMenu::OnMenuItemSelected), NULL, this);
- nativeWin->PopupMenu(m_menu, r.x() - v->scrollX(), r.y() - v->scrollY());
- nativeWin->Disconnect(s_menuStartId, s_menuStartId + (size-1), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(PopupMenu::OnMenuItemSelected), NULL, this);
- }
-}
-
-void PopupMenu::OnMenuItemSelected(wxCommandEvent& event)
-{
- if (client()) {
- client()->valueChanged(event.GetId() - s_menuStartId);
- client()->hidePopup();
- }
- // TODO: Do we need to call Disconnect here? Do we have a ref to the native window still?
-}
-
-void PopupMenu::hide()
-{
- // we don't need to do anything here, the native control only exists during the time
- // show is called
-}
-
-void PopupMenu::updateFromElement()
-{
- client()->setTextFromItem(m_popupClient->selectedIndex());
-}
-
-bool PopupMenu::itemWritingDirectionIsNatural()
-{
- return false;
-}
-
-}
diff --git a/WebCore/platform/wx/RenderThemeWx.cpp b/WebCore/platform/wx/RenderThemeWx.cpp
deleted file mode 100644
index 05ebeb9..0000000
--- a/WebCore/platform/wx/RenderThemeWx.cpp
+++ /dev/null
@@ -1,382 +0,0 @@
-/*
- * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "RenderTheme.h"
-
-#include "Document.h"
-#include "FrameView.h"
-#include "GraphicsContext.h"
-#include "NotImplemented.h"
-#include "RenderView.h"
-
-#include "WebKit/wx/WebView.h"
-
-#include <wx/defs.h>
-#include <wx/renderer.h>
-#include <wx/dcclient.h>
-#include <wx/scrolwin.h>
-#include <wx/settings.h>
-
-namespace WebCore {
-
-class RenderThemeWx : public RenderTheme {
-public:
- RenderThemeWx() : RenderTheme() { }
-
- // A method asking if the theme's controls actually care about redrawing when hovered.
- virtual bool supportsHover(const RenderStyle*) const { return true; }
-
- virtual bool paintCheckbox(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
- {
- return paintButton(o, i, r);
- }
-
- virtual void setCheckboxSize(RenderStyle*) const;
-
- virtual bool paintRadio(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
- {
- return paintButton(o, i, r);
- }
-
- virtual void setRadioSize(RenderStyle*) const;
-
- virtual void adjustRepaintRect(const RenderObject*, IntRect&);
-
- virtual void adjustButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
- virtual bool paintButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
-
- virtual void adjustTextFieldStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
- virtual bool paintTextField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
-
- virtual int minimumMenuListSize(RenderStyle*) const;
-
- virtual void adjustMenuListStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
- virtual bool paintMenuList(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
-
- virtual void adjustMenuListButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
- virtual bool paintMenuListButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
-
- virtual bool isControlStyled(const RenderStyle*, const BorderData&,
- const FillLayer&, const Color&) const;
-
- virtual bool controlSupportsTints(const RenderObject*) const;
-
- virtual void systemFont(int propId, FontDescription&) const;
-
- virtual Color platformActiveSelectionBackgroundColor() const;
- virtual Color platformInactiveSelectionBackgroundColor() const;
-
- virtual Color platformActiveSelectionForegroundColor() const;
- virtual Color platformInactiveSelectionForegroundColor() const;
-
- virtual int popupInternalPaddingLeft(RenderStyle*) const;
- virtual int popupInternalPaddingRight(RenderStyle*) const;
- virtual int popupInternalPaddingTop(RenderStyle*) const;
- virtual int popupInternalPaddingBottom(RenderStyle*) const;
-
-private:
- void addIntrinsicMargins(RenderStyle*) const;
- void close();
-
- bool supportsFocus(ControlPart) const;
-};
-
-
-// Constants
-
-#define MINIMUM_MENU_LIST_SIZE 21
-#define POPUP_INTERNAL_PADDING_LEFT 6
-#define POPUP_INTERNAL_PADDING_TOP 2
-#define POPUP_INTERNAL_PADDING_BOTTOM 2
-
-#ifdef __WXMAC__
-#define POPUP_INTERNAL_PADDING_RIGHT 22
-#else
-#define POPUP_INTERNAL_PADDING_RIGHT 20
-#endif
-
-RenderTheme* theme()
-{
- static RenderThemeWx rt;
- return &rt;
-}
-
-bool RenderThemeWx::isControlStyled(const RenderStyle* style, const BorderData& border,
- const FillLayer& background, const Color& backgroundColor) const
-{
- if (style->appearance() == TextFieldPart || style->appearance() == TextAreaPart)
- return style->border() != border;
-
- return RenderTheme::isControlStyled(style, border, background, backgroundColor);
-}
-
-void RenderThemeWx::adjustRepaintRect(const RenderObject* o, IntRect& r)
-{
- switch (o->style()->appearance()) {
- case MenulistPart: {
- r.setWidth(r.width() + 100);
- break;
- }
- default:
- break;
- }
-}
-
-bool RenderThemeWx::controlSupportsTints(const RenderObject* o) const
-{
- if (!isEnabled(o))
- return false;
-
- // Checkboxes only have tint when checked.
- if (o->style()->appearance() == CheckboxPart)
- return isChecked(o);
-
- // For now assume other controls have tint if enabled.
- return true;
-}
-
-void RenderThemeWx::systemFont(int propId, FontDescription& fontDescription) const
-{
- // no-op
-}
-
-void RenderThemeWx::addIntrinsicMargins(RenderStyle* style) const
-{
- // Cut out the intrinsic margins completely if we end up using a small font size
- if (style->fontSize() < 11)
- return;
-
- // Intrinsic margin value.
- const int m = 2;
-
- // FIXME: Using width/height alone and not also dealing with min-width/max-width is flawed.
- if (style->width().isIntrinsicOrAuto()) {
- if (style->marginLeft().quirk())
- style->setMarginLeft(Length(m, Fixed));
-
- if (style->marginRight().quirk())
- style->setMarginRight(Length(m, Fixed));
- }
-
- if (style->height().isAuto()) {
- if (style->marginTop().quirk())
- style->setMarginTop(Length(m, Fixed));
-
- if (style->marginBottom().quirk())
- style->setMarginBottom(Length(m, Fixed));
- }
-}
-
-void RenderThemeWx::setCheckboxSize(RenderStyle* style) const
-{
- // If the width and height are both specified, then we have nothing to do.
- if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto())
- return;
-
- // FIXME: A hard-coded size of 13 is used. This is wrong but necessary for now. It matches Firefox.
- // At different DPI settings on Windows, querying the theme gives you a larger size that accounts for
- // the higher DPI. Until our entire engine honors a DPI setting other than 96, we can't rely on the theme's
- // metrics.
- if (style->width().isIntrinsicOrAuto())
- style->setWidth(Length(13, Fixed));
-
- if (style->height().isAuto())
- style->setHeight(Length(13, Fixed));
-}
-
-void RenderThemeWx::setRadioSize(RenderStyle* style) const
-{
- // This is the same as checkboxes.
- setCheckboxSize(style);
-}
-
-bool RenderThemeWx::supportsFocus(ControlPart part) const
-{
- switch (part) {
- case PushButtonPart:
- case ButtonPart:
- case TextFieldPart:
- return true;
- default: // No for all others...
- return false;
- }
-}
-
-void RenderThemeWx::adjustButtonStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
-{
- addIntrinsicMargins(style);
-}
-
-bool RenderThemeWx::paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
-{
- wxWindow* window = o->view()->frameView()->platformWidget();
- wxDC* dc = static_cast<wxDC*>(i.context->platformContext());
- int flags = 0;
-
- if (!isEnabled(o))
- flags |= wxCONTROL_DISABLED;
-
- ControlPart part = o->style()->appearance();
- if (supportsFocus(part) && isFocused(o))
- flags |= wxCONTROL_FOCUSED;
-
- if (isPressed(o))
- flags |= wxCONTROL_PRESSED;
-
- if (part == PushButtonPart || part == ButtonPart)
- wxRendererNative::Get().DrawPushButton(window, *dc, r, flags);
- else if(part == RadioPart) {
- if (isChecked(o))
- flags |= wxCONTROL_CHECKED;
- wxRenderer_DrawRadioButton(window, *dc, r, flags);
- }
- else if(part == CheckboxPart) {
- if (isChecked(o))
- flags |= wxCONTROL_CHECKED;
- wxRendererNative::Get().DrawCheckBox(window, *dc, r, flags);
- }
- return false;
-}
-
-void RenderThemeWx::adjustTextFieldStyle(CSSStyleSelector*, RenderStyle* style, Element*) const
-{
-
-}
-
-bool RenderThemeWx::paintTextField(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
-{
- wxWindow* window = o->view()->frameView()->platformWidget();
- wxDC* dc = static_cast<wxDC*>(i.context->platformContext());
- wxRenderer_DrawTextCtrl(window, *dc, r, 0);
- return false;
-}
-
-int RenderThemeWx::minimumMenuListSize(RenderStyle*) const
-{
- return MINIMUM_MENU_LIST_SIZE;
-}
-
-void RenderThemeWx::adjustMenuListStyle(CSSStyleSelector*, RenderStyle* style, Element*) const
-{
-}
-
-bool RenderThemeWx::paintMenuList(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
-{
- wxWindow* window = o->view()->frameView()->platformWidget();
- wxDC* dc = static_cast<wxDC*>(i.context->platformContext());
-
- int flags = 0;
- if (!isEnabled(o))
- flags |= wxCONTROL_DISABLED;
-
- if (supportsFocus(o->style()->appearance()) && isFocused(o))
- flags |= wxCONTROL_FOCUSED;
-
- if (isPressed(o))
- flags |= wxCONTROL_PRESSED;
-
- wxRenderer_DrawChoice(window, *dc, r, flags);
-
- return false;
-}
-
-void RenderThemeWx::adjustMenuListButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const
-{
- notImplemented();
-}
-
-bool RenderThemeWx::paintMenuListButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
-{
- wxWindow* window = o->view()->frameView()->platformWidget();
- wxDC* dc = static_cast<wxDC*>(i.context->platformContext());
-
- int flags = 0;
- if (!isEnabled(o))
- flags |= wxCONTROL_DISABLED;
-
- if (supportsFocus(o->style()->appearance()) && isFocused(o))
- flags |= wxCONTROL_FOCUSED;
-
- if (isPressed(o))
- flags |= wxCONTROL_PRESSED;
-
- wxRendererNative::Get().DrawComboBoxDropButton(window, *dc, r, flags);
-
- return false;
-}
-
-
-Color RenderThemeWx::platformActiveSelectionBackgroundColor() const
-{
- return wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT);
-}
-
-Color RenderThemeWx::platformInactiveSelectionBackgroundColor() const
-{
- return wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW);
-}
-
-Color RenderThemeWx::platformActiveSelectionForegroundColor() const
-{
- // FIXME: Get wx to return the correct value for each platform.
-#if __WXMAC__
- return Color();
-#else
- return Color(255, 255, 255);
-#endif
-}
-
-Color RenderThemeWx::platformInactiveSelectionForegroundColor() const
-{
-#if __WXMAC__
- return Color();
-#else
- return Color(255, 255, 255);
-#endif
-}
-
-int RenderThemeWx::popupInternalPaddingLeft(RenderStyle*) const
-{
- return POPUP_INTERNAL_PADDING_LEFT;
-}
-
-int RenderThemeWx::popupInternalPaddingRight(RenderStyle*) const
-{
- return POPUP_INTERNAL_PADDING_RIGHT;
-}
-
-int RenderThemeWx::popupInternalPaddingTop(RenderStyle*) const
-{
- return POPUP_INTERNAL_PADDING_TOP;
-}
-
-int RenderThemeWx::popupInternalPaddingBottom(RenderStyle*) const
-{
- return POPUP_INTERNAL_PADDING_BOTTOM;
-}
-
-}
-
diff --git a/WebCore/platform/wx/ScreenWx.cpp b/WebCore/platform/wx/ScreenWx.cpp
deleted file mode 100644
index 5def245..0000000
--- a/WebCore/platform/wx/ScreenWx.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "Screen.h"
-#include "IntRect.h"
-#include "FloatRect.h"
-#include "Widget.h"
-
-#include <wx/defs.h>
-#include <wx/display.h>
-#include <wx/gdicmn.h>
-
-namespace WebCore {
-
-FloatRect scaleScreenRectToWidget(FloatRect rect, Widget*)
-{
- return rect;
-}
-
-FloatRect scaleWidgetRectToScreen(FloatRect rect, Widget*)
-{
- return rect;
-}
-
-FloatRect screenRect(Widget* widget)
-{
-/*
- int displayNum;
- Widget* widget = widget->widget();
- displayNum = wxDisplay::GetFromWindow(widget->nativeWindow());
- if (displayNum != -1){
- wxDisplay thisDisplay(displayNum);
- return thisDisplay.GetGeometry();
- }
-*/
- return FloatRect();
-}
-
-int screenDepth(Widget* widget)
-{
- return wxDisplayDepth();
-}
-
-int screenDepthPerComponent(Widget*)
-{
- return wxDisplayDepth();
-}
-
-bool screenIsMonochrome(Widget* widget)
-{
- return wxColourDisplay();
-}
-
-FloatRect screenAvailableRect(Widget* widget)
-{
-/*
- Widget* widget = widget->widget();
- displayNum = wxDisplay::GetFromWindow(widget->nativeWindow());
- if (displayNum != -1){
- wxDisplay thisDisplay(displayNum);
- // FIXME: In 2.7 this method is gone?
- //return thisDisplay.GetClientArea();
- }
-*/
- return FloatRect();
-}
-
-float scaleFactor(Widget*)
-{
- return 1.0f;
-
-}
-
-}
diff --git a/WebCore/platform/wx/ScrollViewWx.cpp b/WebCore/platform/wx/ScrollViewWx.cpp
deleted file mode 100644
index 3822cba..0000000
--- a/WebCore/platform/wx/ScrollViewWx.cpp
+++ /dev/null
@@ -1,352 +0,0 @@
-/*
- * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "ScrollView.h"
-
-#include "FloatRect.h"
-#include "IntRect.h"
-#include "NotImplemented.h"
-#include "PlatformWheelEvent.h"
-#include "Scrollbar.h"
-
-#include <algorithm>
-#include <stdio.h>
-
-#include <wx/defs.h>
-#include <wx/scrolbar.h>
-#include <wx/scrolwin.h>
-#include <wx/event.h>
-
-using namespace std;
-
-namespace WebCore {
-
-class ScrollView::ScrollViewPrivate : public wxEvtHandler {
-
-public:
- ScrollViewPrivate(ScrollView* scrollView)
- : wxEvtHandler()
- , m_scrollView(scrollView)
- , vScrollbarMode(ScrollbarAuto)
- , hScrollbarMode(ScrollbarAuto)
- , viewStart(0, 0)
- {
- }
-
- void bindEvents(wxWindow* win)
- {
- // TODO: is there an easier way to Connect to a range of events? these are contiguous.
- win->Connect(wxEVT_SCROLLWIN_TOP, wxScrollWinEventHandler(ScrollViewPrivate::OnScrollWinEvents), NULL, this);
- win->Connect(wxEVT_SCROLLWIN_BOTTOM, wxScrollWinEventHandler(ScrollViewPrivate::OnScrollWinEvents), NULL, this);
- win->Connect(wxEVT_SCROLLWIN_LINEUP, wxScrollWinEventHandler(ScrollViewPrivate::OnScrollWinEvents), NULL, this);
- win->Connect(wxEVT_SCROLLWIN_LINEDOWN, wxScrollWinEventHandler(ScrollViewPrivate::OnScrollWinEvents), NULL, this);
- win->Connect(wxEVT_SCROLLWIN_PAGEUP, wxScrollWinEventHandler(ScrollViewPrivate::OnScrollWinEvents), NULL, this);
- win->Connect(wxEVT_SCROLLWIN_PAGEDOWN, wxScrollWinEventHandler(ScrollViewPrivate::OnScrollWinEvents), NULL, this);
- win->Connect(wxEVT_SCROLLWIN_THUMBTRACK, wxScrollWinEventHandler(ScrollViewPrivate::OnScrollWinEvents), NULL, this);
- win->Connect(wxEVT_SCROLLWIN_THUMBRELEASE, wxScrollWinEventHandler(ScrollViewPrivate::OnScrollWinEvents), NULL, this);
- }
-
- void OnScrollWinEvents(wxScrollWinEvent& e)
- {
- wxEventType scrollType(e.GetEventType());
- bool horiz = e.GetOrientation() == wxHORIZONTAL;
-
- wxPoint pos(viewStart);
-
- if (scrollType == wxEVT_SCROLLWIN_THUMBTRACK || scrollType == wxEVT_SCROLLWIN_THUMBRELEASE) {
- if (horiz)
- pos.x = e.GetPosition();
- else
- pos.y = e.GetPosition();
- }
- else if (scrollType == wxEVT_SCROLLWIN_LINEDOWN) {
- if (horiz)
- pos.x += cScrollbarPixelsPerLineStep;
- else
- pos.y += cScrollbarPixelsPerLineStep;
- }
- else if (scrollType == wxEVT_SCROLLWIN_LINEUP) {
- if (horiz)
- pos.x -= cScrollbarPixelsPerLineStep;
- else
- pos.y -= cScrollbarPixelsPerLineStep;
- }
- else if (scrollType == wxEVT_SCROLLWIN_PAGEUP) {
- if (horiz)
- pos.x -= m_scrollView->visibleWidth() - cAmountToKeepWhenPaging;
- else
- pos.y -= m_scrollView->visibleHeight() - cAmountToKeepWhenPaging;
- }
- else if (scrollType == wxEVT_SCROLLWIN_PAGEDOWN) {
- if (horiz)
- pos.x += m_scrollView->visibleWidth() - cAmountToKeepWhenPaging;
- else
- pos.y += m_scrollView->visibleHeight() - cAmountToKeepWhenPaging;
- }
- else
- return e.Skip();
-
- m_scrollView->setScrollPosition(IntPoint(pos.x, pos.y));
- }
-
- ScrollView* m_scrollView;
-
- ScrollbarMode vScrollbarMode;
- ScrollbarMode hScrollbarMode;
- wxPoint viewStart;
-};
-
-void ScrollView::platformInit()
-{
- m_data = new ScrollViewPrivate(this);
-}
-
-
-void ScrollView::platformDestroy()
-{
- delete m_data;
-}
-
-void ScrollView::setPlatformWidget(wxWindow* win)
-{
- Widget::setPlatformWidget(win);
- m_data->bindEvents(win);
-}
-
-void ScrollView::platformRepaintContentRectangle(const IntRect& updateRect, bool now)
-{
- // we need to convert coordinates to scrolled position
- wxRect contentsRect = updateRect;
- contentsRect.Offset(-scrollX(), -scrollY());
- wxWindow* win = platformWidget();
- if (win) {
- win->RefreshRect(contentsRect, true);
- if (now)
- win->Update();
- }
-}
-
-IntRect ScrollView::platformVisibleContentRect(bool includeScrollbars) const
-{
- wxWindow* win = platformWidget();
- if (!win)
- return IntRect();
-
- int width, height;
-
- if (includeScrollbars)
- win->GetSize(&width, &height);
- else
- win->GetClientSize(&width, &height);
-
- return IntRect(m_data->viewStart.x, m_data->viewStart.y, width, height);
-}
-
-IntSize ScrollView::platformContentsSize() const
-{
- int width = 0;
- int height = 0;
- if (platformWidget()) {
- platformWidget()->GetVirtualSize(&width, &height);
- ASSERT(width >= 0 && height >= 0);
- }
- return IntSize(width, height);
-}
-
-void ScrollView::platformSetScrollPosition(const IntPoint& scrollPoint)
-{
- wxWindow* win = platformWidget();
-
- wxPoint scrollOffset = m_data->viewStart;
- wxPoint orig(scrollOffset);
- wxPoint newScrollOffset(scrollPoint);
-
- wxRect vRect(win->GetVirtualSize());
- wxRect cRect(win->GetClientSize());
-
- // clamp to scroll area
- if (newScrollOffset.x < 0)
- newScrollOffset.x = 0;
- else if (newScrollOffset.x + cRect.width > vRect.width)
- newScrollOffset.x = max(0, vRect.width - cRect.width - 1);
-
- if (newScrollOffset.y < 0)
- newScrollOffset.y = 0;
- else if (newScrollOffset.y + cRect.height > vRect.height)
- newScrollOffset.y = max(0, vRect.height - cRect.height - 1);
-
- if (newScrollOffset == scrollOffset)
- return;
-
- m_data->viewStart = newScrollOffset;
-
- wxPoint delta(orig - newScrollOffset);
-
- if (canBlitOnScroll())
- win->ScrollWindow(delta.x, delta.y);
- else
- win->Refresh();
-
- adjustScrollbars();
-}
-
-bool ScrollView::platformScroll(ScrollDirection, ScrollGranularity)
-{
- notImplemented();
- return true;
-}
-
-void ScrollView::platformSetContentsSize()
-{
- wxWindow* win = platformWidget();
- if (!win)
- return;
-
- win->SetVirtualSize(m_contentsSize.width(), m_contentsSize.height());
- adjustScrollbars();
-}
-
-void ScrollView::adjustScrollbars(int x, int y, bool refresh)
-{
- wxWindow* win = platformWidget();
- if (!win)
- return;
-
- wxRect crect(win->GetClientRect()), vrect(win->GetVirtualSize());
-
- if (x == -1) x = m_data->viewStart.x;
- if (y == -1) y = m_data->viewStart.y;
-
- long style = win->GetWindowStyle();
-
- // by setting the wxALWAYS_SHOW_SB wxWindow flag before
- // each SetScrollbar call, we can control the scrollbars
- // visibility individually.
-
- // horizontal scrollbar
- switch (m_data->hScrollbarMode) {
- case ScrollbarAlwaysOff:
- win->SetWindowStyleFlag(style & ~wxALWAYS_SHOW_SB);
- win->SetScrollbar(wxHORIZONTAL, 0, 0, 0, refresh);
- break;
-
- case ScrollbarAuto:
- win->SetWindowStyleFlag(style & ~wxALWAYS_SHOW_SB);
- win->SetScrollbar(wxHORIZONTAL, x, crect.width, vrect.width, refresh);
- break;
-
- default: // ScrollbarAlwaysOn
- win->SetWindowStyleFlag(style | wxALWAYS_SHOW_SB);
- win->SetScrollbar(wxHORIZONTAL, x, crect.width, vrect.width, refresh);
- break;
- }
-
- // vertical scrollbar
- switch (m_data->vScrollbarMode) {
- case ScrollbarAlwaysOff:
- win->SetWindowStyleFlag(style & ~wxALWAYS_SHOW_SB);
- win->SetScrollbar(wxVERTICAL, 0, 0, 0, refresh);
- break;
-
- case ScrollbarAlwaysOn:
- win->SetWindowStyleFlag(style | wxALWAYS_SHOW_SB);
- win->SetScrollbar(wxVERTICAL, y, crect.height, vrect.height, refresh);
- break;
-
- default: // case ScrollbarAuto:
- win->SetWindowStyleFlag(style & ~wxALWAYS_SHOW_SB);
- win->SetScrollbar(wxVERTICAL, y, crect.height, vrect.height, refresh);
- }
-}
-
-void ScrollView::platformSetScrollbarModes()
-{
- bool needsAdjust = false;
-
- if (m_data->hScrollbarMode != horizontalScrollbarMode() ) {
- m_data->hScrollbarMode = horizontalScrollbarMode();
- needsAdjust = true;
- }
-
- if (m_data->vScrollbarMode != horizontalScrollbarMode() ) {
- m_data->vScrollbarMode = horizontalScrollbarMode();
- needsAdjust = true;
- }
-
- if (needsAdjust)
- adjustScrollbars();
-}
-
-void ScrollView::platformScrollbarModes(ScrollbarMode& horizontal, ScrollbarMode& vertical) const
-{
- horizontal = m_data->hScrollbarMode;
- vertical = m_data->vScrollbarMode;
-}
-
-// used for subframes support
-void ScrollView::platformAddChild(Widget* widget)
-{
- // NB: In all cases I'm aware of,
- // by the time this is called the ScrollView is already a child
- // of its parent Widget by wx port APIs, so I don't think
- // we need to do anything here.
-}
-
-void ScrollView::platformRemoveChild(Widget* widget)
-{
- if (platformWidget()) {
- platformWidget()->RemoveChild(widget->platformWidget());
- // FIXME: Is this the right place to do deletion? I see
- // detachFromParent2/3/4, initiated by FrameLoader::detachFromParent,
- // but I'm not sure if it's better to handle there or not.
- widget->platformWidget()->Destroy();
- }
-}
-
-IntRect ScrollView::platformContentsToScreen(const IntRect& rect) const
-{
- if (platformWidget()) {
- wxRect wxrect = rect;
- platformWidget()->ClientToScreen(&wxrect.x, &wxrect.y);
- return wxrect;
- }
- return IntRect();
-}
-
-IntPoint ScrollView::platformScreenToContents(const IntPoint& point) const
-{
- if (platformWidget()) {
- return platformWidget()->ScreenToClient(point);
- }
- return IntPoint();
-}
-
-bool ScrollView::platformIsOffscreen() const
-{
- return !platformWidget() || !platformWidget()->IsShownOnScreen();
-}
-
-}
diff --git a/WebCore/platform/wx/SharedTimerWx.cpp b/WebCore/platform/wx/SharedTimerWx.cpp
deleted file mode 100644
index 19747ce..0000000
--- a/WebCore/platform/wx/SharedTimerWx.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include "SharedTimer.h"
-#include "NotImplemented.h"
-#include "SystemTime.h"
-#include "Widget.h"
-
-#include <wtf/Assertions.h>
-#include <stdio.h>
-
-#include "wx/defs.h"
-#include "wx/timer.h"
-
-namespace WebCore {
-
-static void (*sharedTimerFiredFunction)();
-
-class WebKitTimer: public wxTimer
-{
- public:
- WebKitTimer();
- ~WebKitTimer();
- virtual void Notify();
-};
-
-WebKitTimer::WebKitTimer()
-{
- wxTimer::wxTimer();
-}
-
-WebKitTimer::~WebKitTimer()
-{
-}
-
-void WebKitTimer::Notify()
-{
- sharedTimerFiredFunction();
-}
-
-static WebKitTimer* wkTimer;
-
-void setSharedTimerFiredFunction(void (*f)())
-{
- sharedTimerFiredFunction = f;
-}
-
-void setSharedTimerFireTime(double fireTime)
-{
- ASSERT(sharedTimerFiredFunction);
-
- double interval = fireTime - currentTime();
-
- if (!wkTimer)
- wkTimer = new WebKitTimer();
-
- unsigned int intervalInMS = interval * 1000;
- if (interval < 0) {
-#ifndef NDEBUG
- // TODO: We may eventually want to assert here, to track
- // what calls are leading to this condition. It seems to happen
- // mostly with repeating timers.
- fprintf(stderr, "WARNING: setSharedTimerFireTime: fire time is < 0 ms\n");
-#endif
- intervalInMS = 0;
- }
-
- // FIXME: We should mimic the Windows port's behavior and add the timer fired
- // event to the event queue directly rather than making an artifical delay.
- // However, wx won't allow us to assign a simple callback function - we'd have
- // to create a fake wxEvtHandler-derived class with a timer event handler
- // function. Until there's a better way, this way is at least far less
- // hacky.
- if (intervalInMS < 10)
-#if __WXMSW__
- intervalInMS = 10;
-#else
- intervalInMS = 1;
-#endif
-
- wkTimer->Start(intervalInMS, wxTIMER_ONE_SHOT);
-}
-
-void stopSharedTimer()
-{
- if (wkTimer)
- wkTimer->Stop();
-}
-
-}
diff --git a/WebCore/platform/wx/SoundWx.cpp b/WebCore/platform/wx/SoundWx.cpp
deleted file mode 100644
index c8d0e53..0000000
--- a/WebCore/platform/wx/SoundWx.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2006 Kevin Ollivier <kevino@theolliviers.com>
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include <wx/defs.h>
-#include <wx/utils.h>
-
-#include "Sound.h"
-
-namespace WebCore {
-
-void systemBeep()
-{
- wxBell();
-}
-
-}
-
-// vim: ts=4 sw=4 et
diff --git a/WebCore/platform/wx/SystemTimeWx.cpp b/WebCore/platform/wx/SystemTimeWx.cpp
deleted file mode 100644
index 41e6ad7..0000000
--- a/WebCore/platform/wx/SystemTimeWx.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2007 Robin Dunn. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "SystemTime.h"
-
-#include <wx/datetime.h>
-
-namespace WebCore {
-
-double currentTime()
-{
- wxDateTime now = wxDateTime::UNow();
- return (double)now.GetTicks() + (double)(now.GetMillisecond() / 1000.0);
-}
-
-}
diff --git a/WebCore/platform/wx/TemporaryLinkStubs.cpp b/WebCore/platform/wx/TemporaryLinkStubs.cpp
deleted file mode 100755
index d8c6046..0000000
--- a/WebCore/platform/wx/TemporaryLinkStubs.cpp
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2008 Collabora, Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <float.h>
-
-#include "AffineTransform.h"
-#include "AXObjectCache.h"
-#include "BitmapImage.h"
-#include "CachedResource.h"
-#include "Clipboard.h"
-#include "ContextMenu.h"
-#include "ContextMenuItem.h"
-#include "CookieJar.h"
-#include "Cursor.h"
-#include "DNS.h"
-#include "DocumentFragment.h"
-#include "DocumentLoader.h"
-#include "DragController.h"
-#include "Editor.h"
-#include "EditCommand.h"
-#include "EventHandler.h"
-#include "FileChooser.h"
-#include "Font.h"
-#include "Frame.h"
-#include "FrameLoader.h"
-#include "FrameView.h"
-#include "Icon.h"
-#include "IconDatabase.h"
-#include "IconLoader.h"
-#include "IntPoint.h"
-#include "GraphicsContext.h"
-#include "History.h"
-#include "KURL.h"
-#include "Language.h"
-#include "loader.h"
-#include "Node.h"
-#include "NotImplemented.h"
-#include "Pasteboard.h"
-#include "Path.h"
-#include "PlatformMenuDescription.h"
-#include "PlatformMouseEvent.h"
-#include "PopupMenu.h"
-#include "RenderTheme.h"
-#include "ResourceHandle.h"
-#include "ResourceHandleInternal.h"
-#include "ResourceLoader.h"
-#include "Screen.h"
-#include "ScrollbarTheme.h"
-#include "SearchPopupMenu.h"
-#include "Scrollbar.h"
-#include "SharedBuffer.h"
-#include "SharedTimer.h"
-#include "TextBoundaries.h"
-#include "Widget.h"
-
-using namespace WebCore;
-
-Vector<char> loadResourceIntoArray(const char* resourceName)
-{
- Vector<char> resource;
- return resource;
-}
-
-int findNextSentenceFromIndex(UChar const*,int,int,bool) { notImplemented(); return 0; }
-void findSentenceBoundary(UChar const*,int,int,int*,int*) { notImplemented(); }
-
-int WebCore::findNextWordFromIndex(UChar const*,int,int,bool) { notImplemented(); return 0; }
-
-DragImageRef Frame::dragImageForSelection() { notImplemented(); return 0; }
-
-void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect, int thickness) { notImplemented(); }
-
-// cookies (we'll need a place to store these
-void WebCore::setCookies(Document* document, const KURL& url, const KURL& policyURL, const String& value) { notImplemented(); }
-String WebCore::cookies(const Document* document, const KURL& url) { notImplemented(); return String(); }
-bool WebCore::cookiesEnabled(const Document* document) { notImplemented(); return false; }
-
-/********************************************************/
-/* Completely empty stubs (mostly to allow DRT to run): */
-/********************************************************/
-static WebCore::Cursor localCursor;
-const WebCore::Cursor& WebCore::moveCursor() { return localCursor; }
-
-void WebCore::findWordBoundary(UChar const* str,int len,int position,int* start, int* end) { notImplemented(); *start=position; *end=position; }
-
-void Widget::setIsSelected(bool) { notImplemented(); }
-
-void GraphicsContext::setPlatformShadow(IntSize const&,int,Color const&) { notImplemented(); }
-void GraphicsContext::clearPlatformShadow() { notImplemented(); }
-void GraphicsContext::beginTransparencyLayer(float) { notImplemented(); }
-void GraphicsContext::endTransparencyLayer() { notImplemented(); }
-void GraphicsContext::clearRect(const FloatRect&) { notImplemented(); }
-void GraphicsContext::strokeRect(const FloatRect&, float) { notImplemented(); }
-void GraphicsContext::setLineCap(LineCap) { notImplemented(); }
-void GraphicsContext::setLineJoin(LineJoin) { notImplemented(); }
-void GraphicsContext::setMiterLimit(float) { notImplemented(); }
-void GraphicsContext::setAlpha(float) { notImplemented(); }
-
-Color WebCore::focusRingColor() { return 0xFF0000FF; }
-
-void Image::drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform, const FloatPoint& phase, CompositeOperator, const FloatRect& destRect) { notImplemented(); }
-
-ScrollbarTheme* ScrollbarTheme::nativeTheme() { notImplemented(); static ScrollbarTheme theme; return &theme; }
-
-String FileChooser::basenameForWidth(const Font&, int width) const { notImplemented(); return String(); }
-
-Icon::~Icon() { }
-PassRefPtr<Icon> Icon::createIconForFile(const String& filename) { notImplemented(); return 0; }
-PassRefPtr<Icon> Icon::createIconForFiles(const Vector<String>& filenames) { notImplemented(); return 0; }
-void Icon::paint(GraphicsContext*, const IntRect&) { notImplemented(); }
-
-ContextMenu::ContextMenu(const HitTestResult& result) : m_hitTestResult(result) { notImplemented(); }
-ContextMenu::~ContextMenu() { notImplemented(); }
-void ContextMenu::appendItem(ContextMenuItem&) { notImplemented(); }
-void ContextMenu::setPlatformDescription(PlatformMenuDescription) { notImplemented(); }
-
-ContextMenuItem::ContextMenuItem(PlatformMenuItemDescription) { notImplemented(); }
-ContextMenuItem::ContextMenuItem(ContextMenu*) { notImplemented(); }
-ContextMenuItem::ContextMenuItem(ContextMenuItemType type, ContextMenuAction action, const String& title, ContextMenu* subMenu) { notImplemented(); }
-ContextMenuItem::~ContextMenuItem() { notImplemented(); }
-PlatformMenuItemDescription ContextMenuItem::releasePlatformDescription() { notImplemented(); return m_platformDescription; }
-ContextMenuItemType ContextMenuItem::type() const { notImplemented(); return ActionType; }
-void ContextMenuItem::setType(ContextMenuItemType) { notImplemented(); }
-ContextMenuAction ContextMenuItem::action() const { notImplemented(); return ContextMenuItemTagNoAction; }
-void ContextMenuItem::setAction(ContextMenuAction) { notImplemented(); }
-String ContextMenuItem::title() const { notImplemented(); return String(); }
-void ContextMenuItem::setTitle(const String&) { notImplemented(); }
-//PlatformMenuDescription ContextMenuItem::platformSubMenu() const { notImplemented(); return 0; }
-void ContextMenuItem::setSubMenu(ContextMenu*) { notImplemented(); }
-void ContextMenuItem::setChecked(bool) { notImplemented(); }
-void ContextMenuItem::setEnabled(bool) { notImplemented(); }
-
-void Editor::showColorPanel() { notImplemented(); }
-void Editor::showFontPanel() { notImplemented(); }
-void Editor::showStylesPanel() { notImplemented(); }
-
-bool EventHandler::tabsToAllControls(KeyboardEvent* event) const { notImplemented(); return false; }
-bool EventHandler::passSubframeEventToSubframe(MouseEventWithHitTestResults&, Frame* subframe, HitTestResult*) { notImplemented(); return false; }
-bool EventHandler::passMouseDownEventToWidget(Widget*) { notImplemented(); return false; }
-bool EventHandler::passWheelEventToWidget(PlatformWheelEvent&, Widget*) { notImplemented(); return false; }
-
-void SearchPopupMenu::saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems) { notImplemented(); }
-void SearchPopupMenu::loadRecentSearches(const AtomicString& name, Vector<String>& searchItems) { notImplemented(); }
-SearchPopupMenu::SearchPopupMenu(PopupMenuClient* client) : PopupMenu(client) { notImplemented(); }
-bool SearchPopupMenu::enabled() { return true; }
-
-namespace WebCore {
-float userIdleTime() { notImplemented(); return FLT_MAX; } // return an arbitrarily high userIdleTime so that releasing pages from the page cache isn't postponed
-void getSupportedKeySizes(Vector<String>&) { notImplemented(); }
-String signedPublicKeyAndChallengeString(unsigned keySizeIndex, const String &challengeString, const KURL &url) { return String(); }
-const char* currentTextBreakLocaleID() { notImplemented(); return "en_us"; }
-
-String KURL::fileSystemPath() const { notImplemented(); return String(); }
-
-PassRefPtr<SharedBuffer> SharedBuffer::createWithContentsOfFile(const String&) { notImplemented(); return 0; }
-
-void prefetchDNS(const String& hostname) { notImplemented(); }
-
-}
diff --git a/WebCore/platform/wx/WidgetWx.cpp b/WebCore/platform/wx/WidgetWx.cpp
deleted file mode 100755
index 37097fe..0000000
--- a/WebCore/platform/wx/WidgetWx.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#include "config.h"
-#include "Widget.h"
-
-#include "Cursor.h"
-#include "GraphicsContext.h"
-#include "IntRect.h"
-
-#include <wx/defs.h>
-#include <wx/scrolwin.h>
-
-namespace WebCore {
-
-Widget::Widget(PlatformWidget widget)
-{
- init(widget);
-}
-
-Widget::~Widget()
-{
-}
-
-void Widget::setFocus()
-{
- if (platformWidget())
- platformWidget()->SetFocus();
-}
-
-void Widget::setCursor(const Cursor& cursor)
-{
- if (platformWidget() && cursor.impl())
- platformWidget()->SetCursor(*cursor.impl());
-}
-
-void Widget::show()
-{
- if (platformWidget())
- platformWidget()->Show();
-}
-
-void Widget::hide()
-{
- if (platformWidget())
- platformWidget()->Hide();
-}
-
-IntRect Widget::frameRect() const
-{
- if (platformWidget())
- return platformWidget()->GetRect();
- return m_frame;
-}
-
-void Widget::setFrameRect(const IntRect& rect)
-{
- if (platformWidget())
- platformWidget()->SetSize(rect);
- m_frame = rect;
-}
-
-void Widget::invalidateRect(const IntRect& r)
-{
- if (platformWidget())
- platformWidget()->RefreshRect(r);
-}
-
-void Widget::paint(GraphicsContext*,const IntRect& r)
-{
-}
-
-}
diff --git a/WebCore/platform/wx/wxcode/fontprops.cpp b/WebCore/platform/wx/wxcode/fontprops.cpp
deleted file mode 100644
index 56d21bd..0000000
--- a/WebCore/platform/wx/wxcode/fontprops.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-// this is a hacky way of doing it, but we don't
-// currently have info on which platform we're being
-// compiled for directly.
-#if __WXMAC__
-#include "mac/carbon/fontprops.cpp"
-#elif __WXMSW__
-#include "win/fontprops.cpp"
-#else
-#include "gtk/fontprops.cpp"
-#endif
diff --git a/WebCore/platform/wx/wxcode/fontprops.h b/WebCore/platform/wx/wxcode/fontprops.h
deleted file mode 100644
index e6f0b16..0000000
--- a/WebCore/platform/wx/wxcode/fontprops.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <wx/defs.h>
-#include <wx/font.h>
-
-void GetTextExtent( const wxFont& font, const wxString& str, wxCoord *width, wxCoord *height,
- wxCoord *descent = NULL, wxCoord *externalLeading = NULL );
-
-class wxFontProperties{
-
-public:
- wxFontProperties(wxFont* font);
- float GetAscent() { return m_ascent; }
- float GetDescent() { return m_descent; }
- float GetLineGap() { return m_lineGap; }
- float GetLineSpacing() { return m_lineSpacing; }
- float GetXHeight() { return m_xHeight; }
-
-private:
- float m_ascent;
- float m_descent;
- float m_lineGap;
- float m_lineSpacing;
- float m_xHeight;
-
-}; \ No newline at end of file
diff --git a/WebCore/platform/wx/wxcode/gtk/fontprops.cpp b/WebCore/platform/wx/wxcode/gtk/fontprops.cpp
deleted file mode 100644
index 369fcc5..0000000
--- a/WebCore/platform/wx/wxcode/gtk/fontprops.cpp
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <wx/defs.h>
-#include <wx/gdicmn.h>
-#include <wx/font.h>
-#include <wx/fontutil.h>
-#include "fontprops.h"
-
-#include <gdk/gdk.h>
-
-wxFontProperties::wxFontProperties(wxFont* font):
-m_ascent(0), m_descent(0), m_lineGap(0), m_lineSpacing(0), m_xHeight(0)
-{
- PangoContext* context = gdk_pango_context_get_for_screen( gdk_screen_get_default() );
- PangoLayout* layout = pango_layout_new(context);
- // and use it if it's valid
- if ( font && font->Ok() )
- {
- pango_layout_set_font_description
- (
- layout,
- font->GetNativeFontInfo()->description
- );
- }
-
- PangoFontMetrics* metrics = pango_context_get_metrics (context, font->GetNativeFontInfo()->description, NULL);
-
- int height = font->GetPixelSize().GetHeight();
-
- m_ascent = PANGO_PIXELS(pango_font_metrics_get_ascent(metrics));
- m_descent = PANGO_PIXELS(pango_font_metrics_get_descent(metrics));
-
- int h;
-
- const char* x = "x";
- pango_layout_set_text( layout, x, strlen(x) );
- pango_layout_get_pixel_size( layout, NULL, &h );
-
- m_xHeight = h;
- m_lineGap = (m_ascent + m_descent) / 4; // FIXME: How can we calculate this via Pango?
- m_lineSpacing = m_ascent + m_descent;
-
- pango_font_metrics_unref(metrics);
-}
-
-void GetTextExtent( const wxFont& font, const wxString& str, wxCoord *width, wxCoord *height,
- wxCoord *descent, wxCoord *externalLeading )
-{
- if ( width )
- *width = 0;
- if ( height )
- *height = 0;
- if ( descent )
- *descent = 0;
- if ( externalLeading )
- *externalLeading = 0;
-
- if (str.empty())
- return;
-
- PangoContext* context = gdk_pango_context_get_for_screen( gdk_screen_get_default() );
- PangoLayout* m_layout = pango_layout_new(context);
- // and use it if it's valid
- if ( font != wxNullFont )
- {
- pango_layout_set_font_description
- (
- m_layout,
- font.GetNativeFontInfo()->description
- );
- }
-
- // Set layout's text
- const wxCharBuffer dataUTF8 = wxConvUTF8.cWX2MB(str);
- if ( !dataUTF8 )
- {
- // hardly ideal, but what else can we do if conversion failed?
- return;
- }
-
- pango_layout_set_text( m_layout, dataUTF8, strlen(dataUTF8) );
-
- if (descent)
- {
- int h;
- pango_layout_get_pixel_size( m_layout, width, &h );
- PangoLayoutIter *iter = pango_layout_get_iter(m_layout);
- int baseline = pango_layout_iter_get_baseline(iter);
- pango_layout_iter_free(iter);
- *descent = h - PANGO_PIXELS(baseline);
-
- if (height)
- *height = (wxCoord) h;
- }
- else
- {
- pango_layout_get_pixel_size( m_layout, width, height );
- }
-
- // Reset old font description
- //if (font != wxNullFont)
- // pango_layout_set_font_description( m_layout, m_fontdesc );
-} \ No newline at end of file
diff --git a/WebCore/platform/wx/wxcode/gtk/non-kerned-drawing.cpp b/WebCore/platform/wx/wxcode/gtk/non-kerned-drawing.cpp
deleted file mode 100644
index b86a9bc..0000000
--- a/WebCore/platform/wx/wxcode/gtk/non-kerned-drawing.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2007 Kevin Watters, Kevin Ollivier. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "GlyphBuffer.h"
-#include "GraphicsContext.h"
-#include "SimpleFontData.h"
-
-#include <wx/defs.h>
-#include <wx/dcclient.h>
-#include <wx/gdicmn.h>
-#include <vector>
-
-namespace WebCore {
-
-void drawTextWithSpacing(GraphicsContext* graphicsContext, const SimpleFontData* font, const wxColour& color, const GlyphBuffer& glyphBuffer, int from, int numGlyphs, const FloatPoint& point)
-{
-#if USE(WXGC)
- wxGCDC* dc = static_cast<wxGCDC*>(graphicsContext->platformContext());
-#else
- wxDC* dc = graphicsContext->platformContext();
-#endif
-
- wxFont wxfont = font->getWxFont();
- if (wxfont.IsOk())
- dc->SetFont(wxfont);
- dc->SetTextForeground(color);
-
- // convert glyphs to wxString
- GlyphBufferGlyph* glyphs = const_cast<GlyphBufferGlyph*>(glyphBuffer.glyphs(from));
- int offset = point.x();
- wxString text = wxEmptyString;
- for (unsigned i = 0; i < numGlyphs; i++) {
- text = text.Append((wxChar)glyphs[i]);
- offset += glyphBuffer.advanceAt(from + i);
- }
-
- // the y point is actually the bottom point of the text, turn it into the top
- float height = font->ascent() - font->descent();
- wxCoord ypoint = (wxCoord) (point.y() - height);
-
- dc->DrawText(text, (wxCoord)point.x(), ypoint);
-}
-
-}
diff --git a/WebCore/platform/wx/wxcode/mac/carbon/fontprops.cpp b/WebCore/platform/wx/wxcode/mac/carbon/fontprops.cpp
deleted file mode 100644
index b649eb4..0000000
--- a/WebCore/platform/wx/wxcode/mac/carbon/fontprops.cpp
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <ApplicationServices/ApplicationServices.h>
-
-#include <wx/defs.h>
-#include <wx/gdicmn.h>
-#include "fontprops.h"
-
-const float smallCapsFontSizeMultiplier = 0.7f;
-const float contextDPI = 72.0f;
-static inline float scaleEmToUnits(float x, unsigned unitsPerEm) { return x * (contextDPI / (contextDPI * unitsPerEm)); }
-
-wxFontProperties::wxFontProperties(wxFont* font):
-m_ascent(0), m_descent(0), m_lineGap(0), m_lineSpacing(0), m_xHeight(0)
-{
- ATSFontRef fontRef;
- CGFontRef cgFont;
-
- fontRef = FMGetATSFontRefFromFont(font->MacGetATSUFontID());
-
- if (fontRef)
- cgFont = CGFontCreateWithPlatformFont((void*)&fontRef);
-
- if (cgFont) {
- int iAscent;
- int iDescent;
- int iLineGap;
- float unitsPerEm;
-#ifdef BUILDING_ON_TIGER
- wkGetFontMetrics(cgFont, &iAscent, &iDescent, &iLineGap, &unitsPerEm);
-#else
- iAscent = CGFontGetAscent(cgFont);
- iDescent = CGFontGetDescent(cgFont);
- iLineGap = CGFontGetLeading(cgFont);
- unitsPerEm = CGFontGetUnitsPerEm(cgFont);
-#endif
- float pointSize = font->GetPointSize();
- float fAscent = scaleEmToUnits(iAscent, unitsPerEm) * pointSize;
- float fDescent = -scaleEmToUnits(iDescent, unitsPerEm) * pointSize;
- float fLineGap = scaleEmToUnits(iLineGap, unitsPerEm) * pointSize;
-
- m_ascent = lroundf(fAscent);
- m_descent = lroundf(fDescent);
- m_lineGap = lroundf(fLineGap);
- wxCoord xHeight = 0;
- GetTextExtent(*font, wxT("x"), NULL, &xHeight, NULL, NULL);
- m_xHeight = lroundf(xHeight);
- m_lineSpacing = m_ascent + m_descent + m_lineGap;
-
- }
-
-}
-
-void GetTextExtent( const wxFont& font, const wxString& str, wxCoord *width, wxCoord *height,
- wxCoord *descent, wxCoord *externalLeading )
-{
- ATSUStyle* ATSUIStyle;
-
- if ( font.Ok() )
- {
- OSStatus status ;
-
- status = ATSUCreateAndCopyStyle( (ATSUStyle) font.MacGetATSUStyle() , (ATSUStyle*) &ATSUIStyle ) ;
-
- wxASSERT_MSG( status == noErr, wxT("couldn't create ATSU style") ) ;
-
- // we need the scale here ...
-
- Fixed atsuSize = IntToFixed( int( /*m_scaleY*/ 1 * font.MacGetFontSize()) ) ;
- //RGBColor atsuColor = MAC_WXCOLORREF( m_textForegroundColor.GetPixel() ) ;
- ATSUAttributeTag atsuTags[] =
- {
- kATSUSizeTag //,
- // kATSUColorTag ,
- } ;
- ByteCount atsuSizes[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] =
- {
- sizeof( Fixed ) //,
- // sizeof( RGBColor ) ,
- } ;
- ATSUAttributeValuePtr atsuValues[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] =
- {
- &atsuSize //,
- // &atsuColor ,
- } ;
-
- status = ::ATSUSetAttributes(
- (ATSUStyle)ATSUIStyle, sizeof(atsuTags) / sizeof(ATSUAttributeTag) ,
- atsuTags, atsuSizes, atsuValues);
-
- wxASSERT_MSG( status == noErr , wxT("couldn't modify ATSU style") ) ;
- }
-
- wxCHECK_RET( ATSUIStyle != NULL, wxT("GetTextExtent - no valid font set") ) ;
-
- OSStatus status = noErr ;
-
- ATSUTextLayout atsuLayout ;
- UniCharCount chars = str.length() ;
- UniChar* ubuf = NULL ;
-
-#if SIZEOF_WCHAR_T == 4
- wxMBConvUTF16 converter ;
-#if wxUSE_UNICODE
- size_t unicharlen = converter.WC2MB( NULL , str.wc_str() , 0 ) ;
- ubuf = (UniChar*) malloc( unicharlen + 2 ) ;
- converter.WC2MB( (char*) ubuf , str.wc_str(), unicharlen + 2 ) ;
-#else
- const wxWCharBuffer wchar = str.wc_str( wxConvLocal ) ;
- size_t unicharlen = converter.WC2MB( NULL , wchar.data() , 0 ) ;
- ubuf = (UniChar*) malloc( unicharlen + 2 ) ;
- converter.WC2MB( (char*) ubuf , wchar.data() , unicharlen + 2 ) ;
-#endif
- chars = unicharlen / 2 ;
-#else
-#if wxUSE_UNICODE
- ubuf = (UniChar*) str.wc_str() ;
-#else
- wxWCharBuffer wchar = str.wc_str( wxConvLocal ) ;
- chars = wxWcslen( wchar.data() ) ;
- ubuf = (UniChar*) wchar.data() ;
-#endif
-#endif
-
- status = ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) ubuf , 0 , chars , chars , 1 ,
- &chars , (ATSUStyle*) &ATSUIStyle , &atsuLayout ) ;
-
- wxASSERT_MSG( status == noErr , wxT("couldn't create the layout of the text") );
-
- ATSUTextMeasurement textBefore, textAfter ;
- ATSUTextMeasurement textAscent, textDescent ;
-
- status = ::ATSUGetUnjustifiedBounds( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd,
- &textBefore , &textAfter, &textAscent , &textDescent );
-
- if ( height )
- *height = FixedToInt(textAscent + textDescent) ;
- if ( descent )
- *descent = FixedToInt(textDescent) ;
- if ( externalLeading )
- *externalLeading = 0 ;
- if ( width )
- *width = FixedToInt(textAfter - textBefore) ;
-
-#if SIZEOF_WCHAR_T == 4
- free( ubuf ) ;
-#endif
-
- ::ATSUDisposeTextLayout(atsuLayout);
- ::ATSUDisposeStyle((ATSUStyle)ATSUIStyle);
-}
diff --git a/WebCore/platform/wx/wxcode/mac/carbon/non-kerned-drawing.cpp b/WebCore/platform/wx/wxcode/mac/carbon/non-kerned-drawing.cpp
deleted file mode 100644
index 126f7ec..0000000
--- a/WebCore/platform/wx/wxcode/mac/carbon/non-kerned-drawing.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2007 Kevin Watters, Kevin Ollivier. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "GlyphBuffer.h"
-#include "GraphicsContext.h"
-#include "SimpleFontData.h"
-
-#include <wx/defs.h>
-#include <wx/dcclient.h>
-#include <wx/gdicmn.h>
-#include <vector>
-
-namespace WebCore {
-
-void drawTextWithSpacing(GraphicsContext* graphicsContext, const SimpleFontData* font, const wxColour& color, const GlyphBuffer& glyphBuffer, int from, int numGlyphs, const FloatPoint& point)
-{
-#if USE(WXGC)
- wxGCDC* dc = static_cast<wxGCDC*>(graphicsContext->platformContext());
-#else
- wxDC* dc = graphicsContext->platformContext();
-#endif
-
- wxFont wxfont = font->getWxFont();
- if (wxfont.IsOk())
- dc->SetFont(wxfont);
- dc->SetTextForeground(color);
-
- // convert glyphs to wxString
- GlyphBufferGlyph* glyphs = const_cast<GlyphBufferGlyph*>(glyphBuffer.glyphs(from));
- int offset = point.x();
- wxString text = wxEmptyString;
- for (unsigned i = 0; i < numGlyphs; i++) {
- text = text.Append((wxChar)glyphs[i]);
- offset += glyphBuffer.advanceAt(from + i);
- }
-
- // NOTE: The wx API actually adds the ascent to the y value internally,
- // so we have to subtract it from the y point here so that the ascent
- // isn't added twice.
- dc->DrawText(text, (wxCoord)point.x(), int(point.y() - font->ascent()));
-}
-
-}
diff --git a/WebCore/platform/wx/wxcode/non-kerned-drawing.h b/WebCore/platform/wx/wxcode/non-kerned-drawing.h
deleted file mode 100644
index d005985..0000000
--- a/WebCore/platform/wx/wxcode/non-kerned-drawing.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2007 Kevin Watters, Kevin Ollivier. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "Font.h"
-#include "GlyphBuffer.h"
-
-#include <wx/defs.h>
-#include <wx/dcclient.h>
-
-namespace WebCore {
-
-extern void drawTextWithSpacing(GraphicsContext* graphicsContext, const SimpleFontData* font, const wxColour& color, const GlyphBuffer& glyphBuffer, int from, int numGlyphs, const FloatPoint& point);
-
-}
diff --git a/WebCore/platform/wx/wxcode/win/fontprops.cpp b/WebCore/platform/wx/wxcode/win/fontprops.cpp
deleted file mode 100644
index 1314691..0000000
--- a/WebCore/platform/wx/wxcode/win/fontprops.cpp
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright (C) 2007 Kevin Ollivier <kevino@theolliviers.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include <wx/defs.h>
-#include <wx/gdicmn.h>
-#include "fontprops.h"
-#include "math.h"
-#include "MathExtras.h"
-
-#include <wx/wx.h>
-#include "wx/msw/private.h"
-
-inline long my_round(double x)
-{
- return (long)(x < 0 ? x - 0.5 : x + 0.5);
-}
-
-wxFontProperties::wxFontProperties(wxFont* font):
-m_ascent(0), m_descent(0), m_lineGap(0), m_lineSpacing(0), m_xHeight(0)
-{
- HDC dc = GetDC(0);
- WXHFONT hFont = font->GetHFONT();
- ::SelectObject(dc, hFont);
- if (font){
-
- int height = font->GetPointSize();
-
- TEXTMETRIC tm;
- GetTextMetrics(dc, &tm);
- m_ascent = lroundf(tm.tmAscent);
- m_descent = lroundf(tm.tmDescent);
- m_xHeight = m_ascent * 0.56f; // Best guess for xHeight for non-Truetype fonts.
- m_lineGap = lroundf(tm.tmExternalLeading);
- m_lineSpacing = m_lineGap + m_ascent + m_descent;
- }
- RestoreDC(dc, -1);
- ReleaseDC(0, dc);
-}
-
-void GetTextExtent( const wxFont& font, const wxString& str, wxCoord *width, wxCoord *height,
- wxCoord *descent, wxCoord *externalLeading )
-{
- HDC dc = GetDC(0);
- WXHFONT hFont = font.GetHFONT();
- ::SelectObject(dc, hFont);
-
- HFONT hfontOld;
- if ( font != wxNullFont )
- {
- wxASSERT_MSG( font.Ok(), _T("invalid font in wxDC::GetTextExtent") );
-
- hfontOld = (HFONT)::SelectObject(dc, hFont);
- }
- else // don't change the font
- {
- hfontOld = 0;
- }
-
- SIZE sizeRect;
- const size_t len = str.length();
- if ( !::GetTextExtentPoint32(dc, str, len, &sizeRect) )
- {
- wxLogLastError(_T("GetTextExtentPoint32()"));
- }
-
-#if !defined(_WIN32_WCE) || (_WIN32_WCE >= 400)
- // the result computed by GetTextExtentPoint32() may be too small as it
- // accounts for under/overhang of the first/last character while we want
- // just the bounding rect for this string so adjust the width as needed
- // (using API not available in 2002 SDKs of WinCE)
- if ( len > 0 )
- {
- ABC width;
- const wxChar chFirst = *str.begin();
- if ( ::GetCharABCWidths(dc, chFirst, chFirst, &width) )
- {
- if ( width.abcA < 0 )
- sizeRect.cx -= width.abcA;
-
- if ( len > 1 )
- {
- const wxChar chLast = *str.rbegin();
- ::GetCharABCWidths(dc, chLast, chLast, &width);
- }
- //else: we already have the width of the last character
-
- if ( width.abcC < 0 )
- sizeRect.cx -= width.abcC;
- }
- //else: GetCharABCWidths() failed, not a TrueType font?
- }
-#endif // !defined(_WIN32_WCE) || (_WIN32_WCE >= 400)
-
- TEXTMETRIC tm;
- ::GetTextMetrics(dc, &tm);
-
- if (width)
- *width = sizeRect.cx;
- if (height)
- *height = sizeRect.cy;
- if (descent)
- *descent = tm.tmDescent;
- if (externalLeading)
- *externalLeading = tm.tmExternalLeading;
-
- if ( hfontOld )
- {
- ::SelectObject(dc, hfontOld);
- }
-
- ReleaseDC(0, dc);
-}
diff --git a/WebCore/platform/wx/wxcode/win/non-kerned-drawing.cpp b/WebCore/platform/wx/wxcode/win/non-kerned-drawing.cpp
deleted file mode 100644
index f05923a..0000000
--- a/WebCore/platform/wx/wxcode/win/non-kerned-drawing.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (C) 2007 Kevin Watters, Kevin Ollivier. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "GlyphBuffer.h"
-#include "GraphicsContext.h"
-#include "SimpleFontData.h"
-
-#include <wx/defs.h>
-#include <wx/dcclient.h>
-#include <wx/gdicmn.h>
-#include <vector>
-
-using namespace std;
-
-//-----------------------------------------------------------------------------
-// constants
-//-----------------------------------------------------------------------------
-
-const double RAD2DEG = 180.0 / M_PI;
-
-//-----------------------------------------------------------------------------
-// Local functions
-//-----------------------------------------------------------------------------
-
-static inline double dmin(double a, double b) { return a < b ? a : b; }
-static inline double dmax(double a, double b) { return a > b ? a : b; }
-
-static inline double DegToRad(double deg) { return (deg * M_PI) / 180.0; }
-static inline double RadToDeg(double deg) { return (deg * 180.0) / M_PI; }
-
-#include "wx/msw/private.h"
-
-// TODO remove this dependency (gdiplus needs the macros)
-
-#ifndef max
-#define max(a,b) (((a) > (b)) ? (a) : (b))
-#endif
-
-#ifndef min
-#define min(a,b) (((a) < (b)) ? (a) : (b))
-#endif
-
-#include "gdiplus.h"
-
-
-namespace WebCore {
-
-void drawTextWithSpacing(GraphicsContext* graphicsContext, const SimpleFontData* font, const wxColour& color, const GlyphBuffer& glyphBuffer, int from, int numGlyphs, const FloatPoint& point)
-{
-#if USE(WXGC)
- wxGCDC* dc = static_cast<wxGCDC*>(graphicsContext->platformContext());
-#else
- wxDC* dc = graphicsContext->platformContext();
-#endif
-
- // get the native HDC handle to draw using native APIs
- HDC hdc = 0;
-#if USE(WXGC)
- wxGraphicsContext* gc = dc->GetGraphicsContext();
- Gdiplus::Graphics* g;
- if (gc) {
- g = (Gdiplus::Graphics*)gc->GetNativeContext();
- hdc = g->GetHDC();
- }
-#else
- hdc = static_cast<HDC>(dc->GetHDC());
-#endif
-
- // ExtTextOut wants the offsets as an array of ints, so extract them
- // from the glyph buffer
- const GlyphBufferGlyph* glyphs = glyphBuffer.glyphs(from);
- const GlyphBufferAdvance* advances = glyphBuffer.advances(from);
-
- float y = point.y() - font->ascent();
- float x = point.x();
-
- int* spacing = new int[numGlyphs - from];
- for (unsigned i = 0; i < numGlyphs; ++i)
- spacing[i] = advances[i].width();
-
- ::SelectObject(hdc, GetHfontOf(font->getWxFont()));
-
- if (color.Ok())
- ::SetTextColor(hdc, color.GetPixel());
-
- // do not draw background behind characters
- ::SetBkMode(hdc, TRANSPARENT);
-
- // draw text with optional character widths array
- wxString string = wxString((wxChar*)(&glyphs[from]), numGlyphs);
- ::ExtTextOut(hdc, x, y, 0, NULL, string.c_str(), string.length(), spacing);
-
- ::SetBkMode(hdc, TRANSPARENT);
-
- #if USE(WXGC)
- g->ReleaseHDC(hdc);
- #endif
-
- delete [] spacing;
-}
-
-}