WebCore: Remove PLATFORM(WIN) files we do not use.
No expected functionality change.
BUG=none
Review URL: https://codereview.chromium.org/13642009
git-svn-id: svn://svn.chromium.org/blink/trunk@147754 bbb929c8-8fbe-4397-9dbb-9b2b20218538
diff --git a/Source/WebCore/accessibility/win/AXObjectCacheWin.cpp b/Source/WebCore/accessibility/win/AXObjectCacheWin.cpp
deleted file mode 100644
index 8db73de..0000000
--- a/Source/WebCore/accessibility/win/AXObjectCacheWin.cpp
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright (C) 2008, 2009, 2010 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 "AXObjectCache.h"
-
-#include "AccessibilityObject.h"
-#include "Chrome.h"
-#include "Document.h"
-#include "Page.h"
-#include "RenderObject.h"
-
-using namespace std;
-
-namespace WebCore {
-
-void AXObjectCache::detachWrapper(AccessibilityObject* obj)
-{
- // On Windows, AccessibilityObjects are created when get_accChildCount is
- // called, but they are not wrapped until get_accChild is called, so this
- // object may not have a wrapper.
- if (AccessibilityObjectWrapper* wrapper = obj->wrapper())
- wrapper->detach();
-}
-
-void AXObjectCache::attachWrapper(AccessibilityObject*)
-{
- // On Windows, AccessibilityObjects are wrapped when the accessibility
- // software requests them via get_accChild.
-}
-
-void AXObjectCache::handleScrolledToAnchor(const Node* anchorNode)
-{
- // The anchor node may not be accessible. Post the notification for the
- // first accessible object.
- postPlatformNotification(AccessibilityObject::firstAccessibleObjectFromNode(anchorNode), AXScrolledToAnchor);
-}
-
-void AXObjectCache::postPlatformNotification(AccessibilityObject* obj, AXNotification notification)
-{
- if (!obj)
- return;
-
- Document* document = obj->document();
- if (!document)
- return;
-
- Page* page = document->page();
- if (!page || !page->chrome()->platformPageClient())
- return;
-
- DWORD msaaEvent;
- switch (notification) {
- case AXFocusedUIElementChanged:
- case AXActiveDescendantChanged:
- msaaEvent = EVENT_OBJECT_FOCUS;
- break;
-
- case AXScrolledToAnchor:
- msaaEvent = EVENT_SYSTEM_SCROLLINGSTART;
- break;
-
- case AXValueChanged:
- case AXMenuListValueChanged:
- msaaEvent = EVENT_OBJECT_VALUECHANGE;
- break;
-
- case AXMenuListItemSelected:
- msaaEvent = EVENT_OBJECT_SELECTION;
- break;
-
- default:
- return;
- }
-
- // Windows will end up calling get_accChild() on the root accessible
- // object for the WebView, passing the child ID that we specify below. We
- // negate the AXID so we know that the caller is passing the ID of an
- // element, not the index of a child element.
-
- ASSERT(obj->axObjectID() >= 1);
- ASSERT(obj->axObjectID() <= numeric_limits<LONG>::max());
-
- NotifyWinEvent(msaaEvent, page->chrome()->platformPageClient(), OBJID_CLIENT, -static_cast<LONG>(obj->axObjectID()));
-}
-
-void AXObjectCache::nodeTextChangePlatformNotification(AccessibilityObject*, AXTextChange, unsigned, const String&)
-{
-}
-
-void AXObjectCache::frameLoadingEventPlatformNotification(AccessibilityObject*, AXLoadingEvent)
-{
-}
-
-AXID AXObjectCache::platformGenerateAXID() const
-{
- static AXID lastUsedID = 0;
-
- // Generate a new ID. Windows accessibility relies on a positive AXID,
- // ranging from 1 to LONG_MAX.
- AXID objID = lastUsedID;
- do {
- ++objID;
- objID %= std::numeric_limits<LONG>::max();
- } while (objID == 0 || HashTraits<AXID>::isDeletedValue(objID) || m_idsInUse.contains(objID));
-
- ASSERT(objID >= 1 && objID <= std::numeric_limits<LONG>::max());
-
- lastUsedID = objID;
-
- return objID;
-}
-
-void AXObjectCache::handleFocusedUIElementChanged(Node*, Node* newFocusedNode)
-{
- if (!newFocusedNode)
- return;
-
- Page* page = newFocusedNode->document()->page();
- if (!page || !page->chrome()->platformPageClient())
- return;
-
- AccessibilityObject* focusedObject = focusedUIElementForPage(page);
- if (!focusedObject)
- return;
-
- ASSERT(!focusedObject->accessibilityIsIgnored());
-
- postPlatformNotification(focusedObject, AXFocusedUIElementChanged);
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/accessibility/win/AccessibilityObjectWin.cpp b/Source/WebCore/accessibility/win/AccessibilityObjectWin.cpp
deleted file mode 100644
index 44122ef..0000000
--- a/Source/WebCore/accessibility/win/AccessibilityObjectWin.cpp
+++ /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.
- */
-
-#include "config.h"
-#include "AccessibilityObject.h"
-
-#if HAVE(ACCESSIBILITY)
-
-namespace WebCore {
-
-bool AccessibilityObject::accessibilityIgnoreAttachment() const
-{
- return false;
-}
-
-AccessibilityObjectInclusion AccessibilityObject::accessibilityPlatformIncludesObject() const
-{
- if (isMenuListPopup() || isMenuListOption())
- return IncludeObject;
-
- return DefaultBehavior;
-}
-
-} // namespace WebCore
-
-#endif // HAVE(ACCESSIBILITY)
diff --git a/Source/WebCore/accessibility/win/AccessibilityObjectWrapperWin.h b/Source/WebCore/accessibility/win/AccessibilityObjectWrapperWin.h
deleted file mode 100644
index 779443c..0000000
--- a/Source/WebCore/accessibility/win/AccessibilityObjectWrapperWin.h
+++ /dev/null
@@ -1,54 +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 AccessibilityObjectWrapperWin_h
-#define AccessibilityObjectWrapperWin_h
-
-namespace WebCore {
-
- class AccessibilityObject;
-
- class AccessibilityObjectWrapper : public IUnknown {
- public:
- // IUnknown
- virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject) = 0;
- virtual ULONG STDMETHODCALLTYPE AddRef(void) = 0;
- virtual ULONG STDMETHODCALLTYPE Release(void) = 0;
-
- virtual void detach() = 0;
- bool attached() const { return m_object; }
- AccessibilityObject* accessibilityObject() const { return m_object; }
-
- protected:
- AccessibilityObjectWrapper(AccessibilityObject* obj) : m_object(obj) { }
- AccessibilityObjectWrapper() : m_object(0) { }
-
- AccessibilityObject* m_object;
- };
-
-} // namespace WebCore
-
-#endif // AccessibilityObjectWrapperWin_h
diff --git a/Source/WebCore/page/win/DragControllerWin.cpp b/Source/WebCore/page/win/DragControllerWin.cpp
deleted file mode 100644
index a7be6d8..0000000
--- a/Source/WebCore/page/win/DragControllerWin.cpp
+++ /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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "DragController.h"
-
-#include "DragData.h"
-#include "FrameSelection.h"
-#include "windows.h"
-#include <wtf/RefPtr.h>
-
-namespace WebCore {
-
-const int DragController::LinkDragBorderInset = 2;
-const int DragController::MaxOriginalImageArea = 1500 * 1500;
-const int DragController::DragIconRightInset = 7;
-const int DragController::DragIconBottomInset = 3;
-
-const float DragController::DragImageAlpha = 0.75f;
-
-DragOperation DragController::dragOperation(DragData* dragData)
-{
- //FIXME: to match the macos behaviour we should return DragOperationNone
- //if we are a modal window, we are the drag source, or the window is an attached sheet
- //If this can be determined from within WebCore operationForDrag can be pulled into
- //WebCore itself
- ASSERT(dragData);
- return dragData->containsURL(0) && !m_didInitiateDrag ? DragOperationCopy : DragOperationNone;
-}
-
-bool DragController::isCopyKeyDown(DragData*)
-{
- return ::GetAsyncKeyState(VK_CONTROL);
-}
-
-const IntSize& DragController::maxDragImageSize()
-{
- static const IntSize maxDragImageSize(200, 200);
-
- return maxDragImageSize;
-}
-
-void DragController::cleanupAfterSystemDrag()
-{
-}
-
-}
diff --git a/Source/WebCore/page/win/EventHandlerWin.cpp b/Source/WebCore/page/win/EventHandlerWin.cpp
deleted file mode 100644
index 04b988f..0000000
--- a/Source/WebCore/page/win/EventHandlerWin.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2007-2009 Torch Mobile, 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "EventHandler.h"
-
-#include "Cursor.h"
-#include "FloatPoint.h"
-#include "FocusController.h"
-#include "FrameView.h"
-#include "Frame.h"
-#include "FrameSelection.h"
-#include "HitTestRequest.h"
-#include "HitTestResult.h"
-#include "MouseEventWithHitTestResults.h"
-#include "Page.h"
-#include "PlatformKeyboardEvent.h"
-#include "PlatformWheelEvent.h"
-#include "Scrollbar.h"
-#include "WCDataObject.h"
-#include "NotImplemented.h"
-
-#if OS(WINCE)
-#include "Clipboard.h"
-#else
-#include "ClipboardWin.h"
-#endif
-
-namespace WebCore {
-
-#if ENABLE(DRAG_SUPPORT)
-const double EventHandler::TextDragDelay = 0.0;
-#endif
-
-bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe)
-{
- subframe->eventHandler()->handleMousePressEvent(mev.event());
- return true;
-}
-
-bool EventHandler::passMouseMoveEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe, HitTestResult* hoveredNode)
-{
-#if ENABLE(DRAG_SUPPORT)
- if (m_mouseDownMayStartDrag && !m_mouseDownWasInSubframe)
- return false;
-#endif
- subframe->eventHandler()->handleMouseMoveEvent(mev.event(), hoveredNode);
- return true;
-}
-
-bool EventHandler::passMouseReleaseEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe)
-{
- subframe->eventHandler()->handleMouseReleaseEvent(mev.event());
- return true;
-}
-
-bool EventHandler::passWheelEventToWidget(const PlatformWheelEvent& wheelEvent, Widget* widget)
-{
- if (!widget->isFrameView())
- return false;
-
- return toFrameView(widget)->frame()->eventHandler()->handleWheelEvent(wheelEvent);
-}
-
-bool EventHandler::tabsToAllFormControls(KeyboardEvent*) const
-{
- return true;
-}
-
-bool EventHandler::eventActivatedView(const PlatformMouseEvent& event) const
-{
- return event.didActivateWebView();
-}
-
-#if ENABLE(DRAG_SUPPORT)
-PassRefPtr<Clipboard> EventHandler::createDraggingClipboard() const
-{
-#if OS(WINCE)
- return 0;
-#else
- COMPtr<WCDataObject> dataObject;
- WCDataObject::createInstance(&dataObject);
- return ClipboardWin::create(Clipboard::DragAndDrop, dataObject.get(), ClipboardWritable, m_frame);
-#endif
-}
-#endif
-
-void EventHandler::focusDocumentView()
-{
- Page* page = m_frame->page();
- if (!page)
- return;
- page->focusController()->setFocusedFrame(m_frame);
-}
-
-bool EventHandler::passWidgetMouseDownEventToWidget(const MouseEventWithHitTestResults&)
-{
- notImplemented();
- return false;
-}
-
-unsigned EventHandler::accessKeyModifiers()
-{
- return PlatformEvent::AltKey;
-}
-
-}
diff --git a/Source/WebCore/page/win/FrameCGWin.cpp b/Source/WebCore/page/win/FrameCGWin.cpp
deleted file mode 100644
index b559882..0000000
--- a/Source/WebCore/page/win/FrameCGWin.cpp
+++ /dev/null
@@ -1,112 +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 "FrameWin.h"
-
-#include "BitmapInfo.h"
-#include "Frame.h"
-#include "FrameView.h"
-#include "GraphicsContextCG.h"
-#include "RenderObject.h"
-#include "Settings.h"
-#include <CoreGraphics/CoreGraphics.h>
-#include <windows.h>
-
-namespace WebCore {
-
-static void drawRectIntoContext(IntRect rect, FrameView* view, GraphicsContext* gc)
-{
- IntSize offset = view->scrollOffset();
- rect.move(-offset.width(), -offset.height());
- rect = view->convertToContainingWindow(rect);
-
- gc->concatCTM(AffineTransform().translate(-rect.x(), -rect.y()));
-
- view->paint(gc, rect);
-}
-
-static HBITMAP imageFromRect(const Frame* frame, IntRect& ir)
-{
- PaintBehavior oldPaintBehavior = frame->view()->paintBehavior();
- frame->view()->setPaintBehavior(oldPaintBehavior | PaintBehaviorFlattenCompositingLayers);
-
- void* bits;
- HDC hdc = CreateCompatibleDC(0);
- int w = ir.width();
- int h = ir.height();
- BitmapInfo bmp = BitmapInfo::create(IntSize(w, h));
-
- HBITMAP hbmp = CreateDIBSection(0, &bmp, DIB_RGB_COLORS, static_cast<void**>(&bits), 0, 0);
- HBITMAP hbmpOld = static_cast<HBITMAP>(SelectObject(hdc, hbmp));
- CGContextRef context = CGBitmapContextCreate(static_cast<void*>(bits), w, h,
- 8, w * sizeof(RGBQUAD), deviceRGBColorSpaceRef(), kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst);
- CGContextSaveGState(context);
-
- GraphicsContext gc(context);
-
- drawRectIntoContext(ir, frame->view(), &gc);
-
- CGContextRelease(context);
- SelectObject(hdc, hbmpOld);
- DeleteDC(hdc);
-
- frame->view()->setPaintBehavior(oldPaintBehavior);
-
- return hbmp;
-}
-
-HBITMAP imageFromSelection(Frame* frame, bool forceBlackText)
-{
- frame->document()->updateLayout();
-
- frame->view()->setPaintBehavior(PaintBehaviorSelectionOnly | (forceBlackText ? PaintBehaviorForceBlackText : 0));
- FloatRect fr = frame->selection()->bounds();
- IntRect ir(static_cast<int>(fr.x()), static_cast<int>(fr.y()),
- static_cast<int>(fr.width()), static_cast<int>(fr.height()));
- HBITMAP image = imageFromRect(frame, ir);
- frame->view()->setPaintBehavior(PaintBehaviorNormal);
- return image;
-}
-
-DragImageRef Frame::nodeImage(Node* node)
-{
- document()->updateLayout();
-
- RenderObject* renderer = node->renderer();
- if (!renderer)
- return 0;
-
- LayoutRect topLevelRect;
- IntRect paintingRect = pixelSnappedIntRect(renderer->paintingRootRect(topLevelRect));
-
- m_view->setNodeToDraw(node); // invoke special sub-tree drawing mode
- HBITMAP result = imageFromRect(this, paintingRect);
- m_view->setNodeToDraw(0);
-
- return result;
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/page/win/FrameWin.cpp b/Source/WebCore/page/win/FrameWin.cpp
deleted file mode 100644
index e425ed9..0000000
--- a/Source/WebCore/page/win/FrameWin.cpp
+++ /dev/null
@@ -1,57 +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 "FrameWin.h"
-
-#include "BridgeJSC.h"
-#include "Document.h"
-#include "FloatRect.h"
-#include "Frame.h"
-#include "PrintContext.h"
-#include "RenderView.h"
-#include "Settings.h"
-#include "TransformationMatrix.h"
-
-namespace WebCore {
-
-void computePageRectsForFrame(Frame* frame, const IntRect& printRect, float headerHeight, float footerHeight, float userScaleFactor, Vector<IntRect>& outPages, int& outPageHeight)
-{
- PrintContext printContext(frame);
- float pageHeight = 0;
- printContext.computePageRects(printRect, headerHeight, footerHeight, userScaleFactor, pageHeight);
- outPageHeight = static_cast<int>(pageHeight);
- outPages = printContext.pageRects();
-}
-
-DragImageRef Frame::dragImageForSelection()
-{
- if (selection()->isRange())
- return imageFromSelection(this, false);
-
- return 0;
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/page/win/FrameWin.h b/Source/WebCore/page/win/FrameWin.h
deleted file mode 100644
index cbfe33d..0000000
--- a/Source/WebCore/page/win/FrameWin.h
+++ /dev/null
@@ -1,44 +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 FrameWin_h
-#define FrameWin_h
-
-#include <wtf/Vector.h>
-
-// Forward declared so we don't need wingdi.h.
-typedef struct HBITMAP__* HBITMAP;
-
-namespace WebCore {
-
- class Frame;
- class IntRect;
-
- HBITMAP imageFromSelection(Frame* frame, bool forceWhiteText);
- void computePageRectsForFrame(Frame*, const IntRect& printRect, float headerHeight, float footerHeight, float userScaleFactor, Vector<IntRect>& outPages, int& outPageHeight);
-
-}
-
-#endif
diff --git a/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.cpp b/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.cpp
deleted file mode 100644
index 2a7a4b2..0000000
--- a/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- Copyright (C) 2012 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 "GraphicsSurface.h"
-
-#include "NotImplemented.h"
-
-#if USE(GRAPHICS_SURFACE)
-namespace WebCore {
-
-PassRefPtr<GraphicsSurface> GraphicsSurface::create(const IntSize& size, Flags flags, const GraphicsSurfaceToken& token)
-{
- return platformImport(size, flags, token);
-}
-
-PassRefPtr<GraphicsSurface> GraphicsSurface::create(const IntSize& size, GraphicsSurface::Flags flags, const PlatformGraphicsContext3D shareContext)
-{
- return platformCreate(size, flags, shareContext);
-}
-
-GraphicsSurfaceToken GraphicsSurface::exportToken()
-{
- return platformExport();
-}
-
-uint32_t GraphicsSurface::getTextureID()
-{
- return platformGetTextureID();
-}
-
-PassOwnPtr<GraphicsContext> GraphicsSurface::beginPaint(const IntRect& rect, LockOptions lockOptions)
-{
- int stride = 0;
- char* bits = platformLock(rect, &stride, lockOptions);
- OwnPtr<GraphicsContext> graphicsContext = platformBeginPaint(rect.size(), bits, stride);
- return graphicsContext.release();
-}
-
-void GraphicsSurface::copyToGLTexture(uint32_t target, uint32_t texture, const IntRect& targetRect, const IntPoint& offset)
-{
- platformCopyToGLTexture(target, texture, targetRect, offset);
-}
-
-void GraphicsSurface::copyFromTexture(uint32_t texture, const IntRect& sourceRect)
-{
- platformCopyFromTexture(texture, sourceRect);
-}
-
-void GraphicsSurface::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity)
-{
- platformPaintToTextureMapper(textureMapper, targetRect, transform, opacity);
-}
-
-uint32_t GraphicsSurface::frontBuffer()
-{
- return platformFrontBuffer();
-}
-
-uint32_t GraphicsSurface::swapBuffers()
-{
- return platformSwapBuffers();
-}
-
-IntSize GraphicsSurface::size() const
-{
- return platformSize();
-}
-
-GraphicsSurface::GraphicsSurface(const IntSize&, Flags flags)
- : m_flags(flags)
- , m_fbo(0)
- , m_private(0)
-{
-}
-
-GraphicsSurface::~GraphicsSurface()
-{
- platformDestroy();
-}
-
-}
-#endif
diff --git a/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.h b/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.h
deleted file mode 100644
index 701edd7..0000000
--- a/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- Copyright (C) 2012 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 GraphicsSurface_h
-#define GraphicsSurface_h
-
-#if USE(GRAPHICS_SURFACE)
-
-#include "GraphicsContext.h"
-#include "GraphicsContext3D.h"
-#include "GraphicsSurfaceToken.h"
-#include "IntRect.h"
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-
-#if OS(DARWIN)
-typedef struct __IOSurface* IOSurfaceRef;
-typedef IOSurfaceRef PlatformGraphicsSurface;
-#endif
-
-#if OS(LINUX)
-typedef uint32_t PlatformGraphicsSurface;
-#endif
-
-#if OS(WINDOWS)
-typedef HANDLE PlatformGraphicsSurface;
-#endif
-
-namespace WebCore {
-
-class BitmapTexture;
-class TextureMapper;
-struct GraphicsSurfacePrivate;
-
-class GraphicsSurface : public RefCounted<GraphicsSurface> {
-public:
- enum Flag {
- SupportsAlpha = 0x01,
- SupportsSoftwareWrite = 0x02,
- SupportsSoftwareRead = 0x04,
- SupportsTextureTarget = 0x08,
- SupportsTextureSource = 0x10,
- SupportsCopyToTexture = 0x20,
- SupportsCopyFromTexture = 0x40,
- SupportsSharing = 0x80,
- SupportsSingleBuffered = 0x100
- };
-
- enum LockOption {
- RetainPixels = 0x01,
- ReadOnly = 0x02
- };
-
- typedef int Flags;
- typedef int LockOptions;
-
- Flags flags() const { return m_flags; }
- IntSize size() const;
-
- static PassRefPtr<GraphicsSurface> create(const IntSize&, Flags, const PlatformGraphicsContext3D shareContext = 0);
- static PassRefPtr<GraphicsSurface> create(const IntSize&, Flags, const GraphicsSurfaceToken&);
- void copyToGLTexture(uint32_t target, uint32_t texture, const IntRect& targetRect, const IntPoint& sourceOffset);
- void copyFromTexture(uint32_t texture, const IntRect& sourceRect);
- void paintToTextureMapper(TextureMapper*, const FloatRect& targetRect, const TransformationMatrix&, float opacity);
- uint32_t frontBuffer();
- uint32_t swapBuffers();
- GraphicsSurfaceToken exportToken();
- uint32_t getTextureID();
- PassOwnPtr<GraphicsContext> beginPaint(const IntRect&, LockOptions);
- PassRefPtr<Image> createReadOnlyImage(const IntRect&);
- ~GraphicsSurface();
-
-protected:
- static PassRefPtr<GraphicsSurface> platformCreate(const IntSize&, Flags, const PlatformGraphicsContext3D);
- static PassRefPtr<GraphicsSurface> platformImport(const IntSize&, Flags, const GraphicsSurfaceToken&);
- GraphicsSurfaceToken platformExport();
- void platformDestroy();
-
- uint32_t platformGetTextureID();
- char* platformLock(const IntRect&, int* stride, LockOptions);
- void platformUnlock();
- void platformCopyToGLTexture(uint32_t target, uint32_t texture, const IntRect&, const IntPoint&);
- void platformCopyFromTexture(uint32_t texture, const IntRect& sourceRect);
- void platformPaintToTextureMapper(TextureMapper*, const FloatRect& targetRect, const TransformationMatrix&, float opacity);
- uint32_t platformFrontBuffer() const;
- uint32_t platformSwapBuffers();
- IntSize platformSize() const;
-
- PassOwnPtr<GraphicsContext> platformBeginPaint(const IntSize&, char* bits, int stride);
-
-protected:
- LockOptions m_lockOptions;
- Flags m_flags;
-
-private:
- GraphicsSurface(const IntSize&, Flags);
-
- uint32_t m_fbo;
- GraphicsSurfacePrivate* m_private;
-};
-
-}
-#endif // USE(GRAPHICS_SURFACE)
-
-#endif // GraphicsSurface_h
diff --git a/Source/WebCore/platform/graphics/surfaces/GraphicsSurfaceToken.h b/Source/WebCore/platform/graphics/surfaces/GraphicsSurfaceToken.h
deleted file mode 100644
index c97f368..0000000
--- a/Source/WebCore/platform/graphics/surfaces/GraphicsSurfaceToken.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- Copyright (C) 2012 Digia 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 GraphicsSurfaceToken_h
-#define GraphicsSurfaceToken_h
-
-#include "GraphicsContext.h"
-#include "IntRect.h"
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-
-#if USE(GRAPHICS_SURFACE)
-
-namespace WebCore {
-
-struct GraphicsSurfaceToken {
-
-#if OS(DARWIN)
- typedef mach_port_t BufferHandle;
-#elif OS(LINUX)
- typedef uint32_t BufferHandle;
-#elif OS(WINDOWS)
- typedef HANDLE BufferHandle;
-#endif
-
-#if HAVE(GLX)
- GraphicsSurfaceToken(uint32_t windowID = 0)
- : frontBufferHandle(windowID)
- { }
-
- bool operator!=(const GraphicsSurfaceToken &rhs) const
- {
- return frontBufferHandle != rhs.frontBufferHandle;
- }
-
- bool isValid() const
- {
- return frontBufferHandle;
- }
-
-#endif
-
-#if OS(DARWIN) || OS(WINDOWS)
- GraphicsSurfaceToken(BufferHandle frontBuffer = 0, BufferHandle backBuffer = 0)
- : frontBufferHandle(frontBuffer)
- , backBufferHandle(backBuffer)
- { }
-
- bool operator!=(const GraphicsSurfaceToken &rhs) const
- {
- return (frontBufferHandle != rhs.frontBufferHandle || backBufferHandle != rhs.backBufferHandle);
- }
-
- bool isValid() const
- {
- return frontBufferHandle && backBufferHandle;
- }
-
- BufferHandle backBufferHandle;
-#endif
-
- BufferHandle frontBufferHandle;
-};
-
-}
-#endif // USE(GRAPHICS_SURFACE)
-
-#endif // GraphicsSurfaceToken_h
diff --git a/Source/WebCore/platform/graphics/surfaces/egl/EGLConfigSelector.cpp b/Source/WebCore/platform/graphics/surfaces/egl/EGLConfigSelector.cpp
deleted file mode 100644
index b7658e3..0000000
--- a/Source/WebCore/platform/graphics/surfaces/egl/EGLConfigSelector.cpp
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright (C) 2012 Intel 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this 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. 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 INC. 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 "EGLConfigSelector.h"
-
-#if USE(EGL)
-
-#include "EGLHelper.h"
-
-namespace WebCore {
-
-EGLConfigSelector::EGLConfigSelector(GLPlatformSurface::SurfaceAttributes attributes)
- : m_pixmapFBConfig(0)
- , m_surfaceContextFBConfig(0)
- , m_attributes(attributes)
-{
- m_sharedDisplay = EGLHelper::eglDisplay();
-}
-
-EGLConfigSelector::~EGLConfigSelector()
-{
-}
-
-EGLConfig EGLConfigSelector::pixmapContextConfig()
-{
- if (!m_pixmapFBConfig)
- m_pixmapFBConfig = createConfig(EGL_PIXMAP_BIT);
-
- return m_pixmapFBConfig;
-}
-
-EGLConfig EGLConfigSelector::surfaceContextConfig()
-{
- if (!m_surfaceContextFBConfig)
- m_surfaceContextFBConfig = createConfig(EGL_WINDOW_BIT);
-
- return m_surfaceContextFBConfig;
-}
-
-EGLint EGLConfigSelector::nativeVisualId(const EGLConfig& config) const
-{
- if (m_sharedDisplay == EGL_NO_DISPLAY)
- return -1;
-
- EGLint eglValue = 0;
- eglGetConfigAttrib(m_sharedDisplay, config, EGL_NATIVE_VISUAL_ID, &eglValue);
-
- return eglValue;
-}
-
-GLPlatformSurface::SurfaceAttributes EGLConfigSelector::attributes() const
-{
- return m_attributes;
-}
-
-void EGLConfigSelector::reset()
-{
- m_surfaceContextFBConfig = 0;
- m_pixmapFBConfig = 0;
-}
-
-EGLConfig EGLConfigSelector::createConfig(EGLint expectedSurfaceType)
-{
- if (m_sharedDisplay == EGL_NO_DISPLAY)
- return 0;
-
- EGLint numConfigs;
-
- eglGetConfigs(m_sharedDisplay, 0, 0, &numConfigs);
-
- if (!numConfigs) {
- LOG_ERROR("Failed to retrieve number of EGL configs.");
- return 0;
- }
-
- EGLConfig configs[numConfigs];
- eglGetConfigs(m_sharedDisplay, configs, numConfigs, &numConfigs);
-
- if (!numConfigs) {
- LOG_ERROR("Failed to retrieve any EGL configs.");
- return 0;
- }
-
- EGLConfig config = 0;
- EGLint alpha, surface, red, green, blue, renderType;
- EGLint expectedAlpha = m_attributes & GLPlatformSurface::SupportAlpha ? 8 : 0;
- EGLint expectedRed = 8;
- EGLint expectedBlue = 8;
- EGLint expectedGreen = 8;
-#if USE(OPENGL_ES_2)
- EGLint expectedRenderType = EGL_OPENGL_ES2_BIT;
-#else
- EGLint expectedRenderType = EGL_OPENGL_BIT,
-#endif
-
- for (int i = 0; i < numConfigs; i++) {
- EGLConfig tempConfig = configs[i];
- eglGetConfigAttrib(m_sharedDisplay, tempConfig, EGL_RENDERABLE_TYPE, &renderType);
-
- if (!(renderType & expectedRenderType))
- continue;
-
- eglGetConfigAttrib(m_sharedDisplay, tempConfig, EGL_ALPHA_SIZE, &alpha);
-
- if (alpha != expectedAlpha)
- continue;
-
- eglGetConfigAttrib(m_sharedDisplay, tempConfig, EGL_RED_SIZE, &red);
-
- if (red != expectedRed)
- continue;
-
- eglGetConfigAttrib(m_sharedDisplay, tempConfig, EGL_GREEN_SIZE, &green);
-
- if (green != expectedGreen)
- continue;
-
- eglGetConfigAttrib(m_sharedDisplay, tempConfig, EGL_BLUE_SIZE, &blue);
-
- if (blue != expectedBlue)
- continue;
-
- eglGetConfigAttrib(m_sharedDisplay, tempConfig, EGL_SURFACE_TYPE, &surface);
-
- if (surface & expectedSurfaceType) {
- config = configs[i];
- break;
- }
- }
-
- if ((m_attributes & GLPlatformSurface::SupportAlpha) && !config) {
- LOG_ERROR("Failed to retrieve EGL Configuration with alpha. Trying to find one without alpha support.");
- m_attributes &= ~GLPlatformSurface::SupportAlpha;
- config = createConfig(expectedSurfaceType);
- }
-
- if (!config)
- LOG_ERROR("Failed to find a valid EGL Configuration.");
-
- return config;
-}
-
-}
-
-#endif
diff --git a/Source/WebCore/platform/graphics/surfaces/egl/EGLConfigSelector.h b/Source/WebCore/platform/graphics/surfaces/egl/EGLConfigSelector.h
deleted file mode 100644
index 52897e4..0000000
--- a/Source/WebCore/platform/graphics/surfaces/egl/EGLConfigSelector.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2012 Intel 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this 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. 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 INC. 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 EGLConfigSelector_h
-#define EGLConfigSelector_h
-
-#if USE(EGL)
-
-#include <opengl/GLDefs.h>
-#include <opengl/GLPlatformSurface.h>
-#include <wtf/Noncopyable.h>
-
-namespace WebCore {
-
-class EGLConfigSelector {
- WTF_MAKE_NONCOPYABLE(EGLConfigSelector);
-public:
- EGLConfigSelector(GLPlatformSurface::SurfaceAttributes);
- virtual ~EGLConfigSelector();
- virtual EGLConfig pixmapContextConfig();
- virtual EGLConfig surfaceContextConfig();
- EGLint nativeVisualId(const EGLConfig&) const;
- GLPlatformSurface::SurfaceAttributes attributes() const;
- void reset();
-
-private:
- EGLConfig createConfig(EGLint expectedSurfaceType);
-
-protected:
- EGLConfig m_pixmapFBConfig;
- EGLConfig m_surfaceContextFBConfig;
- unsigned m_attributes : 3;
- PlatformDisplay m_sharedDisplay;
-};
-
-}
-
-#endif
-
-#endif
diff --git a/Source/WebCore/platform/graphics/surfaces/egl/EGLContext.cpp b/Source/WebCore/platform/graphics/surfaces/egl/EGLContext.cpp
deleted file mode 100644
index c208dcc..0000000
--- a/Source/WebCore/platform/graphics/surfaces/egl/EGLContext.cpp
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright (C) 2012 Intel 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this 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. 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 INC. 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 "EGLContext.h"
-
-#if USE(EGL)
-
-#include <wtf/text/WTFString.h>
-
-namespace WebCore {
-
-static const EGLint contextAttributes[] = {
-#if USE(OPENGL_ES_2)
- EGL_CONTEXT_CLIENT_VERSION, 2,
-#endif
- EGL_NONE
-};
-
-static const EGLint contextRobustnessAttributes[] = {
-#if USE(OPENGL_ES_2)
- EGL_CONTEXT_CLIENT_VERSION, 2,
-#endif
- EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT,
- EGL_LOSE_CONTEXT_ON_RESET_EXT,
- EGL_NONE
-};
-
-static bool isRobustnessExtSupported(EGLDisplay display)
-{
- static bool didQueryForRobustnessExtension = false;
- static bool isRobustnessExtensionSupported = false;
-
- if (!didQueryForRobustnessExtension) {
- didQueryForRobustnessExtension = true;
- isRobustnessExtensionSupported = GLPlatformContext::supportsEGLExtension(display, "EGL_EXT_create_context_robustness");
- }
-
- return isRobustnessExtensionSupported;
-}
-
-EGLOffScreenContext::EGLOffScreenContext()
- : GLPlatformContext()
- , m_display(0)
-{
-}
-
-bool EGLOffScreenContext::initialize(GLPlatformSurface* surface, PlatformContext sharedContext)
-{
- if (!surface)
- return false;
-
- if (!eglBindAPI(eglAPIVersion)) {
- LOG_ERROR("Failed to set EGL API(%d).", eglGetError());
- return false;
- }
-
- m_display = surface->sharedDisplay();
- if (!m_display)
- return false;
-
- EGLConfig config = surface->configuration();
- if (!config)
- return false;
-
- if (isRobustnessExtSupported(m_display))
- m_contextHandle = eglCreateContext(m_display, config, sharedContext, contextRobustnessAttributes);
-
- if (m_contextHandle != EGL_NO_CONTEXT) {
- // The EGL_EXT_create_context_robustness spec requires that a context created with
- // EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT bit set must also support GL_EXT_robustness or
- // a version of OpenGL incorporating equivalent functionality.
- // The spec also defines similar requirements for attribute EGL_LOSE_CONTEXT_ON_RESET_EXT.
- if (platformMakeCurrent(surface) && (GLPlatformContext::supportsGLExtension("GL_EXT_robustness")))
- m_resetLostContext = true;
- else
- eglDestroyContext(m_display, m_contextHandle);
- }
-
- if (m_contextHandle == EGL_NO_CONTEXT)
- m_contextHandle = eglCreateContext(m_display, config, sharedContext, contextAttributes);
-
- if (m_contextHandle != EGL_NO_CONTEXT)
- return true;
-
- return false;
-}
-
-EGLOffScreenContext::~EGLOffScreenContext()
-{
-}
-
-bool EGLOffScreenContext::isCurrentContext() const
-{
- return m_contextHandle == eglGetCurrentContext();
-}
-
-bool EGLOffScreenContext::platformMakeCurrent(GLPlatformSurface* surface)
-{
- if (!eglMakeCurrent(m_display, surface->drawable(), surface->drawable(), m_contextHandle)) {
- LOG_ERROR("Failed to make context current(%d).", eglGetError());
-
- if (m_resetLostContext && eglGetError() == EGL_CONTEXT_LOST) {
- LOG_ERROR("Lost current context.");
- m_contextLost = true;
- }
-
- return false;
- }
-
- return true;
-}
-
-void EGLOffScreenContext::platformReleaseCurrent()
-{
- eglMakeCurrent(m_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
-}
-
-void EGLOffScreenContext::freeResources()
-{
- if (m_contextHandle == EGL_NO_CONTEXT)
- return;
-
- eglDestroyContext(m_display, m_contextHandle);
- m_contextHandle = EGL_NO_CONTEXT;
- m_display = 0;
-}
-
-void EGLOffScreenContext::destroy()
-{
- GLPlatformContext::destroy();
- freeResources();
-}
-
-}
-
-#endif
diff --git a/Source/WebCore/platform/graphics/surfaces/egl/EGLContext.h b/Source/WebCore/platform/graphics/surfaces/egl/EGLContext.h
deleted file mode 100644
index ec31913..0000000
--- a/Source/WebCore/platform/graphics/surfaces/egl/EGLContext.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2012 Intel 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this 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. 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 INC. 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 EGLContext_h
-#define EGLContext_h
-
-#if USE(EGL)
-
-#include "GLPlatformContext.h"
-
-namespace WebCore {
-
-class EGLOffScreenContext : public GLPlatformContext {
-
-public:
- EGLOffScreenContext();
- virtual ~EGLOffScreenContext();
- virtual bool initialize(GLPlatformSurface*, PlatformContext) OVERRIDE;
- virtual bool platformMakeCurrent(GLPlatformSurface*) OVERRIDE;
- virtual void platformReleaseCurrent() OVERRIDE;
- virtual void destroy() OVERRIDE;
- virtual bool isCurrentContext() const OVERRIDE;
-
-private:
- void freeResources();
- EGLDisplay m_display;
-};
-
-}
-
-#endif
-
-#endif
diff --git a/Source/WebCore/platform/graphics/surfaces/egl/EGLHelper.cpp b/Source/WebCore/platform/graphics/surfaces/egl/EGLHelper.cpp
deleted file mode 100644
index 65cfdf4..0000000
--- a/Source/WebCore/platform/graphics/surfaces/egl/EGLHelper.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2013 Intel 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this 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. 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 INC. 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 "EGLHelper.h"
-
-#if USE(EGL)
-
-namespace WebCore {
-
-struct EGLDisplayConnection {
-
- EGLDisplayConnection(NativeSharedDisplay* display = 0)
- {
- if (display)
- m_eglDisplay = eglGetDisplay(reinterpret_cast<EGLNativeDisplayType>(display));
- else
- m_eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
-
- if (m_eglDisplay == EGL_NO_DISPLAY) {
- LOG_ERROR("EGLDisplay Initialization failed.");
- return;
- }
-
- EGLBoolean success;
- success = eglInitialize(m_eglDisplay, 0, 0);
-
- if (success != EGL_TRUE) {
- LOG_ERROR("EGLInitialization failed.");
- terminate();
- return;
- }
-
- success = eglBindAPI(eglAPIVersion);
-
- if (success != EGL_TRUE) {
- LOG_ERROR("Failed to set EGL API(%d).", eglGetError());
- terminate();
- return;
- }
- }
-
- ~EGLDisplayConnection()
- {
- terminate();
- }
-
- EGLDisplay display() { return m_eglDisplay; }
-
-private:
- void terminate()
- {
- if (m_eglDisplay == EGL_NO_DISPLAY)
- return;
-
- eglTerminate(m_eglDisplay);
- m_eglDisplay = EGL_NO_DISPLAY;
- }
-
- EGLDisplay m_eglDisplay;
-};
-
-PlatformDisplay EGLHelper::eglDisplay()
-{
- // Display connection will only be broken at program shutdown.
-#if PLATFORM(X11)
- static EGLDisplayConnection displayConnection(NativeWrapper::nativeDisplay());
-#else
- static EGLDisplayConnection displayConnection;
-#endif
- return displayConnection.display();
-}
-
-}
-
-#endif
diff --git a/Source/WebCore/platform/graphics/surfaces/egl/EGLHelper.h b/Source/WebCore/platform/graphics/surfaces/egl/EGLHelper.h
deleted file mode 100644
index d5708a7..0000000
--- a/Source/WebCore/platform/graphics/surfaces/egl/EGLHelper.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2013 Intel 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this 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. 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 INC. 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 EGLHelper_h
-#define EGLHelper_h
-
-#if USE(EGL)
-
-#if PLATFORM(X11)
-#include <glx/X11Helper.h>
-#endif
-
-#include <opengl/GLDefs.h>
-
-namespace WebCore {
-
-#if PLATFORM(X11)
-typedef X11Helper NativeWrapper;
-typedef Display NativeSharedDisplay;
-#else
-typedef void NativeSharedDisplay;
-#endif
-
-class EGLHelper {
-public:
- static PlatformDisplay eglDisplay();
-};
-
-}
-
-#endif
-
-#endif
diff --git a/Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.cpp b/Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.cpp
deleted file mode 100644
index c4f7fcf..0000000
--- a/Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.cpp
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Copyright (C) 2012 Intel 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this 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. 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 INC. 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 "EGLSurface.h"
-
-#if USE(EGL) && USE(GRAPHICS_SURFACE)
-
-#include "EGLConfigSelector.h"
-#include "EGLHelper.h"
-#include "GLPlatformContext.h"
-
-#if PLATFORM(X11)
-#include "EGLXSurface.h"
-#endif
-
-namespace WebCore {
-
-PassOwnPtr<GLTransportSurface> EGLTransportSurface::createTransportSurface(const IntSize& size, SurfaceAttributes attributes)
-{
- OwnPtr<GLTransportSurface> surface;
-#if PLATFORM(X11)
- surface = adoptPtr(new EGLWindowTransportSurface(size, attributes));
-#endif
-
- if (surface)
- return surface.release();
-
- return nullptr;
-}
-
-EGLTransportSurface::EGLTransportSurface(const IntSize& size, SurfaceAttributes attributes)
- : GLTransportSurface(size, attributes)
-{
- m_sharedDisplay = EGLHelper::eglDisplay();
-
- if (m_sharedDisplay == EGL_NO_DISPLAY)
- return;
-
- m_configSelector = adoptPtr(new EGLConfigSelector(attributes));
-}
-
-GLPlatformSurface::SurfaceAttributes EGLTransportSurface::attributes() const
-{
- return m_configSelector->attributes();
-}
-
-EGLTransportSurface::~EGLTransportSurface()
-{
-}
-
-void EGLTransportSurface::destroy()
-{
- if (m_drawable == EGL_NO_SURFACE || m_sharedDisplay == EGL_NO_DISPLAY)
- return;
-
- GLTransportSurface::destroy();
-
- if (m_drawable) {
- eglDestroySurface(m_sharedDisplay, m_drawable);
- m_drawable = EGL_NO_SURFACE;
- }
-
- m_configSelector = nullptr;
-}
-
-PlatformSurfaceConfig EGLTransportSurface::configuration()
-{
- return m_configSelector->surfaceContextConfig();
-}
-
-PassOwnPtr<GLPlatformSurface> EGLOffScreenSurface::createOffScreenSurface(SurfaceAttributes attributes)
-{
- OwnPtr<GLPlatformSurface> surface;
-#if PLATFORM(X11)
- surface = adoptPtr(new EGLPixmapSurface(attributes));
-#endif
-
- if (surface)
- return surface.release();
-
- return nullptr;
-}
-
-EGLOffScreenSurface::EGLOffScreenSurface(SurfaceAttributes surfaceAttributes)
- : GLPlatformSurface(surfaceAttributes)
-{
- m_sharedDisplay = EGLHelper::eglDisplay();
-
- if (m_sharedDisplay == EGL_NO_DISPLAY)
- return;
-
- m_configSelector = adoptPtr(new EGLConfigSelector(surfaceAttributes));
-}
-
-EGLOffScreenSurface::~EGLOffScreenSurface()
-{
-}
-
-GLPlatformSurface::SurfaceAttributes EGLOffScreenSurface::attributes() const
-{
- return m_configSelector->attributes();
-}
-
-PlatformSurfaceConfig EGLOffScreenSurface::configuration()
-{
- return m_configSelector->pixmapContextConfig();
-}
-
-void EGLOffScreenSurface::destroy()
-{
- if (m_sharedDisplay == EGL_NO_DISPLAY || m_drawable == EGL_NO_SURFACE)
- return;
-
- if (m_drawable) {
- eglDestroySurface(m_sharedDisplay, m_drawable);
- m_drawable = EGL_NO_SURFACE;
- }
-
- m_configSelector = nullptr;
-}
-
-}
-
-#endif
diff --git a/Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.h b/Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.h
deleted file mode 100644
index 464f1bf..0000000
--- a/Source/WebCore/platform/graphics/surfaces/egl/EGLSurface.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2012 Intel 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this 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. 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 INC. 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 EGLSurface_h
-#define EGLSurface_h
-
-#if USE(EGL) && USE(GRAPHICS_SURFACE)
-
-#include "GLTransportSurface.h"
-
-#include <wtf/Noncopyable.h>
-#include <wtf/PassOwnPtr.h>
-
-namespace WebCore {
-
-class EGLConfigSelector;
-
-class EGLTransportSurface : public GLTransportSurface {
-public:
- static PassOwnPtr<GLTransportSurface> createTransportSurface(const IntSize&, SurfaceAttributes);
- virtual ~EGLTransportSurface();
- virtual PlatformSurfaceConfig configuration() OVERRIDE;
- virtual void destroy() OVERRIDE;
- virtual GLPlatformSurface::SurfaceAttributes attributes() const OVERRIDE;
-
-protected:
- EGLTransportSurface(const IntSize&, SurfaceAttributes);
- OwnPtr<EGLConfigSelector> m_configSelector;
-};
-
-class EGLOffScreenSurface : public GLPlatformSurface {
-public:
- static PassOwnPtr<GLPlatformSurface> createOffScreenSurface(SurfaceAttributes);
- virtual ~EGLOffScreenSurface();
- virtual PlatformSurfaceConfig configuration() OVERRIDE;
- virtual void destroy() OVERRIDE;
- virtual GLPlatformSurface::SurfaceAttributes attributes() const OVERRIDE;
-
-protected:
- EGLOffScreenSurface(SurfaceAttributes);
- OwnPtr<EGLConfigSelector> m_configSelector;
-};
-
-}
-
-#endif
-
-#endif
diff --git a/Source/WebCore/platform/graphics/surfaces/egl/EGLXSurface.cpp b/Source/WebCore/platform/graphics/surfaces/egl/EGLXSurface.cpp
deleted file mode 100644
index 1b2aeee..0000000
--- a/Source/WebCore/platform/graphics/surfaces/egl/EGLXSurface.cpp
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright (C) 2013 Intel 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this 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. 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 INC. 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 "EGLXSurface.h"
-
-#if PLATFORM(X11) && USE(EGL) && USE(GRAPHICS_SURFACE)
-
-#include "EGLConfigSelector.h"
-
-namespace WebCore {
-
-EGLWindowTransportSurface::EGLWindowTransportSurface(const IntSize& size, GLPlatformSurface::SurfaceAttributes attributes)
- : EGLTransportSurface(size, attributes)
-{
- if (!m_configSelector)
- return;
-
- if (!m_configSelector->surfaceContextConfig()) {
- destroy();
- return;
- }
-
- EGLint visualId = m_configSelector->nativeVisualId(m_configSelector->surfaceContextConfig());
-
- if (visualId == -1) {
- destroy();
- return;
- }
-
- NativeWrapper::createOffScreenWindow(&m_bufferHandle, visualId, m_configSelector->attributes() & GLPlatformSurface::SupportAlpha, size);
-
- if (!m_bufferHandle) {
- destroy();
- return;
- }
-
- m_drawable = eglCreateWindowSurface(m_sharedDisplay, m_configSelector->surfaceContextConfig(), static_cast<EGLNativeWindowType>(m_bufferHandle), 0);
-
- if (m_drawable == EGL_NO_SURFACE) {
- LOG_ERROR("Failed to create EGL surface(%d).", eglGetError());
- destroy();
- }
-}
-
-EGLWindowTransportSurface::~EGLWindowTransportSurface()
-{
-}
-
-void EGLWindowTransportSurface::swapBuffers()
-{
- if (!eglSwapBuffers(m_sharedDisplay, m_drawable))
- LOG_ERROR("Failed to SwapBuffers(%d).", eglGetError());
-}
-
-void EGLWindowTransportSurface::destroy()
-{
- EGLTransportSurface::destroy();
-
- if (m_bufferHandle) {
- NativeWrapper::destroyWindow(m_bufferHandle);
- m_bufferHandle = 0;
- }
-}
-
-EGLPixmapSurface::EGLPixmapSurface(GLPlatformSurface::SurfaceAttributes surfaceAttributes)
- : EGLOffScreenSurface(surfaceAttributes)
-{
- if (!m_configSelector)
- return;
-
- EGLConfig config = m_configSelector->pixmapContextConfig();
-
- if (!config) {
- destroy();
- return;
- }
-
- EGLint visualId = m_configSelector->nativeVisualId(config);
-
- if (visualId == -1) {
- destroy();
- return;
- }
-
- NativePixmap pixmap;
- NativeWrapper::createPixmap(&pixmap, visualId, m_configSelector->attributes() & GLPlatformSurface::SupportAlpha);
- m_bufferHandle = pixmap;
-
- if (!m_bufferHandle) {
- destroy();
- return;
- }
-
- m_drawable = eglCreatePixmapSurface(m_sharedDisplay, config, static_cast<EGLNativePixmapType>(m_bufferHandle), 0);
-
- if (m_drawable == EGL_NO_SURFACE) {
- LOG_ERROR("Failed to create EGL surface(%d).", eglGetError());
- destroy();
- }
-}
-
-EGLPixmapSurface::~EGLPixmapSurface()
-{
-}
-
-void EGLPixmapSurface::destroy()
-{
- EGLOffScreenSurface::destroy();
-
- if (m_bufferHandle) {
- NativeWrapper::destroyPixmap(m_bufferHandle);
- m_bufferHandle = 0;
- }
-}
-
-}
-
-#endif
diff --git a/Source/WebCore/platform/graphics/surfaces/egl/EGLXSurface.h b/Source/WebCore/platform/graphics/surfaces/egl/EGLXSurface.h
deleted file mode 100644
index 1f2c427..0000000
--- a/Source/WebCore/platform/graphics/surfaces/egl/EGLXSurface.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2013 Intel 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this 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. 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 INC. 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 EGLXSurface_h
-#define EGLXSurface_h
-
-#if PLATFORM(X11) && USE(EGL) && USE(GRAPHICS_SURFACE)
-
-#include "EGLSurface.h"
-#include <glx/X11Helper.h>
-
-namespace WebCore {
-
-typedef X11Helper NativeWrapper;
-typedef Pixmap NativePixmap;
-
-// Contents of the surface are backed by native window.
-class EGLWindowTransportSurface : public EGLTransportSurface {
-public:
- EGLWindowTransportSurface(const IntSize&, GLPlatformSurface::SurfaceAttributes);
- virtual ~EGLWindowTransportSurface();
- virtual void swapBuffers() OVERRIDE;
- virtual void destroy() OVERRIDE;
-};
-
-class EGLPixmapSurface : public EGLOffScreenSurface {
-public:
- EGLPixmapSurface(GLPlatformSurface::SurfaceAttributes);
- virtual ~EGLPixmapSurface();
- virtual void destroy() OVERRIDE;
-};
-
-}
-
-#endif
-
-#endif
diff --git a/Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp b/Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp
deleted file mode 100644
index 15ab255..0000000
--- a/Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp
+++ /dev/null
@@ -1,421 +0,0 @@
-/*
- Copyright (C) 2012 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 "GraphicsSurface.h"
-
-#if USE(GRAPHICS_SURFACE) && OS(DARWIN)
-#include "TextureMapperGL.h"
-#include <CFNumber.h>
-#include <CGLContext.h>
-#include <CGLCurrent.h>
-#include <CGLIOSurface.h>
-#include <IOSurface/IOSurface.h>
-#include <OpenGL/OpenGL.h>
-#include <OpenGL/gl.h>
-#include <mach/mach.h>
-
-namespace WebCore {
-
-static uint32_t createTexture(IOSurfaceRef handle)
-{
- GLuint texture = 0;
- GLuint format = GL_BGRA;
- GLuint type = GL_UNSIGNED_INT_8_8_8_8_REV;
- GLuint internalFormat = GL_RGBA;
- CGLContextObj context = CGLGetCurrentContext();
- if (!context)
- return 0;
-
- GLint prevTexture;
- glGetIntegerv(GL_TEXTURE_RECTANGLE_ARB, &prevTexture);
-
- glGenTextures(1, &texture);
- glBindTexture(GL_TEXTURE_RECTANGLE_ARB, texture);
- CGLError error = CGLTexImageIOSurface2D(context, GL_TEXTURE_RECTANGLE_ARB, internalFormat, IOSurfaceGetWidth(handle), IOSurfaceGetHeight(handle), format, type, handle, 0);
- if (error) {
- glDeleteTextures(1, &texture);
- texture = 0;
- }
-
- glBindTexture(GL_TEXTURE_RECTANGLE_ARB, prevTexture);
-
- return texture;
-}
-
-struct GraphicsSurfacePrivate {
-public:
- GraphicsSurfacePrivate(const GraphicsSurfaceToken& token, const IntSize& size)
- : m_context(0)
- , m_size(size)
- , m_token(token)
- , m_frontBufferTexture(0)
- , m_frontBufferReadTexture(0)
- , m_backBufferTexture(0)
- , m_backBufferReadTexture(0)
- , m_readFbo(0)
- , m_drawFbo(0)
- {
- m_frontBuffer = IOSurfaceLookupFromMachPort(m_token.frontBufferHandle);
- m_backBuffer = IOSurfaceLookupFromMachPort(m_token.backBufferHandle);
- }
-
- GraphicsSurfacePrivate(const PlatformGraphicsContext3D shareContext, const IntSize& size, GraphicsSurface::Flags flags)
- : m_context(0)
- , m_size(size)
- , m_frontBufferTexture(0)
- , m_frontBufferReadTexture(0)
- , m_backBufferTexture(0)
- , m_backBufferReadTexture(0)
- , m_readFbo(0)
- , m_drawFbo(0)
- {
- unsigned pixelFormat = 'BGRA';
- unsigned bytesPerElement = 4;
- int width = m_size.width();
- int height = m_size.height();
-
- unsigned long bytesPerRow = IOSurfaceAlignProperty(kIOSurfaceBytesPerRow, width * bytesPerElement);
- if (!bytesPerRow)
- return;
-
- unsigned long allocSize = IOSurfaceAlignProperty(kIOSurfaceAllocSize, height * bytesPerRow);
- if (!allocSize)
- return;
-
- const void *keys[6];
- const void *values[6];
- keys[0] = kIOSurfaceWidth;
- values[0] = CFNumberCreate(0, kCFNumberIntType, &width);
- keys[1] = kIOSurfaceHeight;
- values[1] = CFNumberCreate(0, kCFNumberIntType, &height);
- keys[2] = kIOSurfacePixelFormat;
- values[2] = CFNumberCreate(0, kCFNumberIntType, &pixelFormat);
- keys[3] = kIOSurfaceBytesPerElement;
- values[3] = CFNumberCreate(0, kCFNumberIntType, &bytesPerElement);
- keys[4] = kIOSurfaceBytesPerRow;
- values[4] = CFNumberCreate(0, kCFNumberLongType, &bytesPerRow);
- keys[5] = kIOSurfaceAllocSize;
- values[5] = CFNumberCreate(0, kCFNumberLongType, &allocSize);
-
- CFDictionaryRef dict = CFDictionaryCreate(0, keys, values, 6, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
- for (unsigned i = 0; i < 6; i++)
- CFRelease(values[i]);
-
- m_frontBuffer = IOSurfaceCreate(dict);
- m_backBuffer = IOSurfaceCreate(dict);
-
- if (!(flags & GraphicsSurface::SupportsSharing))
- return;
-
- m_token = GraphicsSurfaceToken(IOSurfaceCreateMachPort(m_frontBuffer), IOSurfaceCreateMachPort(m_backBuffer));
- }
-
- ~GraphicsSurfacePrivate()
- {
- if (m_frontBufferTexture)
- glDeleteTextures(1, &m_frontBufferTexture);
-
- if (m_frontBufferReadTexture)
- glDeleteTextures(1, &m_frontBufferReadTexture);
-
- if (m_backBufferTexture)
- glDeleteTextures(1, &m_backBufferTexture);
-
- if (m_backBufferReadTexture)
- glDeleteTextures(1, &m_backBufferReadTexture);
-
- if (m_frontBuffer)
- CFRelease(IOSurfaceRef(m_frontBuffer));
-
- if (m_backBuffer)
- CFRelease(IOSurfaceRef(m_backBuffer));
-
- if (m_readFbo)
- glDeleteFramebuffers(1, &m_readFbo);
-
- if (m_drawFbo)
- glDeleteFramebuffers(1, &m_drawFbo);
-
- if (m_context)
- CGLReleaseContext(m_context);
-
- if (m_token.frontBufferHandle)
- mach_port_deallocate(mach_task_self(), m_token.frontBufferHandle);
- if (m_token.backBufferHandle)
- mach_port_deallocate(mach_task_self(), m_token.backBufferHandle);
-
- }
-
- uint32_t swapBuffers()
- {
- std::swap(m_frontBuffer, m_backBuffer);
- std::swap(m_frontBufferTexture, m_backBufferTexture);
- std::swap(m_frontBufferReadTexture, m_backBufferReadTexture);
-
- return IOSurfaceGetID(m_frontBuffer);
- }
-
- void makeCurrent()
- {
- m_detachedContext = CGLGetCurrentContext();
-
- if (m_context)
- CGLSetCurrentContext(m_context);
- }
-
- void doneCurrent()
- {
- CGLSetCurrentContext(m_detachedContext);
- m_detachedContext = 0;
- }
-
- void copyFromTexture(uint32_t texture, const IntRect& sourceRect)
- {
- // FIXME: The following glFlush can possibly be replaced by using the GL_ARB_sync extension.
- glFlush(); // Make sure the texture has actually been completely written in the original context.
-
- makeCurrent();
-
- int x = sourceRect.x();
- int y = sourceRect.y();
- int width = sourceRect.width();
- int height = sourceRect.height();
-
- glPushAttrib(GL_ALL_ATTRIB_BITS);
- GLint previousFBO;
- glGetIntegerv(GL_FRAMEBUFFER_BINDING, &previousFBO);
-
- if (!m_drawFbo)
- glGenFramebuffers(1, &m_drawFbo);
-
- if (!m_readFbo)
- glGenFramebuffers(1, &m_readFbo);
-
- glBindFramebuffer(GL_READ_FRAMEBUFFER, m_readFbo);
- glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
-
- glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_drawFbo);
- glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_RECTANGLE_ARB, backBufferTextureID(), 0);
- glBlitFramebuffer(x, y, width, height, x, x+height, y+width, y, GL_COLOR_BUFFER_BIT, GL_LINEAR); // Flip the texture upside down.
-
- glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_RECTANGLE_ARB, 0, 0);
- glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
- glBindFramebuffer(GL_FRAMEBUFFER, previousFBO);
- glPopAttrib();
-
- // Flushing the gl command buffer is necessary to ensure the texture has correctly been bound to the IOSurface.
- glFlush();
-
- swapBuffers();
- doneCurrent();
- }
-
- GraphicsSurfaceToken token() const
- {
- return m_token;
- }
-
- uint32_t frontBufferTextureID()
- {
- if (!m_frontBufferReadTexture)
- m_frontBufferReadTexture = createTexture(m_frontBuffer);
-
- return m_frontBufferReadTexture;
- }
-
- uint32_t backBufferTextureID()
- {
- if (!m_backBufferTexture)
- m_backBufferTexture = createTexture(m_backBuffer);
-
- return m_backBufferTexture;
- }
-
- PlatformGraphicsSurface frontBuffer() const
- {
- return m_frontBuffer;
- }
-
- PlatformGraphicsSurface backBuffer() const
- {
- return m_backBuffer;
- }
-
- IntSize size() const
- {
- return m_size;
- }
-
-private:
- CGLContextObj m_context;
- IntSize m_size;
- CGLContextObj m_detachedContext;
- PlatformGraphicsSurface m_frontBuffer;
- PlatformGraphicsSurface m_backBuffer;
- uint32_t m_frontBufferTexture;
- uint32_t m_frontBufferReadTexture;
- uint32_t m_backBufferTexture;
- uint32_t m_backBufferReadTexture;
- uint32_t m_readFbo;
- uint32_t m_drawFbo;
- GraphicsSurfaceToken m_token;
-};
-
-GraphicsSurfaceToken GraphicsSurface::platformExport()
-{
- return m_private->token();
-}
-
-uint32_t GraphicsSurface::platformGetTextureID()
-{
- return m_private->frontBufferTextureID();
-}
-
-void GraphicsSurface::platformCopyToGLTexture(uint32_t target, uint32_t id, const IntRect& targetRect, const IntPoint& offset)
-{
- glPushAttrib(GL_ALL_ATTRIB_BITS);
- if (!m_fbo)
- glGenFramebuffers(1, &m_fbo);
- glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
- glBindTexture(target, id);
- glBindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo);
- glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_RECTANGLE_ARB, m_private->frontBufferTextureID(), 0);
- glCopyTexSubImage2D(target, 0, targetRect.x(), targetRect.y(), offset.x(), offset.y(), targetRect.width(), targetRect.height());
- glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_RECTANGLE_ARB, 0, 0);
- glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
- glPopAttrib();
-
- // According to IOSurface's documentation, glBindFramebuffer is the one triggering an update of the surface's cache.
- // If the web process starts rendering and unlocks the surface before this happens, we might copy contents
- // of the currently rendering frame on our texture instead of the previously completed frame.
- // Flush the command buffer to reduce the odds of this happening, this would not be necessary with double buffering.
- glFlush();
-}
-
-void GraphicsSurface::platformCopyFromTexture(uint32_t texture, const IntRect& sourceRect)
-{
- m_private->copyFromTexture(texture, sourceRect);
-}
-
-void GraphicsSurface::platformPaintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity)
-{
- IntSize size = m_private->size();
- FloatRect rectOnContents(FloatPoint::zero(), size);
- TransformationMatrix adjustedTransform = transform;
- adjustedTransform.multiply(TransformationMatrix::rectToRect(rectOnContents, targetRect));
- static_cast<TextureMapperGL*>(textureMapper)->drawTexture(m_private->frontBufferTextureID(), TextureMapperGL::ShouldBlend | TextureMapperGL::ShouldUseARBTextureRect, size, rectOnContents, adjustedTransform, opacity);
-}
-
-uint32_t GraphicsSurface::platformFrontBuffer() const
-{
- return IOSurfaceGetID(m_private->frontBuffer());
-}
-
-uint32_t GraphicsSurface::platformSwapBuffers()
-{
- return m_private->swapBuffers();
-}
-
-IntSize GraphicsSurface::platformSize() const
-{
- return m_private->size();
-}
-
-PassRefPtr<GraphicsSurface> GraphicsSurface::platformCreate(const IntSize& size, Flags flags, const PlatformGraphicsContext3D shareContext)
-{
- // We currently disable support for CopyToTexture on Mac, because this is used for single buffered Tiles.
- // The single buffered nature of this requires a call to glFlush, as described in platformCopyToTexture.
- // This call blocks the GPU for about 40ms, which makes smooth animations impossible.
- if (flags & SupportsCopyToTexture || flags & SupportsSingleBuffered)
- return PassRefPtr<GraphicsSurface>();
-
- RefPtr<GraphicsSurface> surface = adoptRef(new GraphicsSurface(size, flags));
- surface->m_private = new GraphicsSurfacePrivate(shareContext, size, flags);
-
- if (!surface->m_private->frontBuffer() || !surface->m_private->backBuffer())
- return PassRefPtr<GraphicsSurface>();
-
- return surface;
-}
-
-PassRefPtr<GraphicsSurface> GraphicsSurface::platformImport(const IntSize& size, Flags flags, const GraphicsSurfaceToken& token)
-{
- // We currently disable support for CopyToTexture on Mac, because this is used for single buffered Tiles.
- // The single buffered nature of this requires a call to glFlush, as described in platformCopyToTexture.
- // This call blocks the GPU for about 40ms, which makes smooth animations impossible.
- if (flags & SupportsCopyToTexture || flags & SupportsSingleBuffered)
- return PassRefPtr<GraphicsSurface>();
-
- RefPtr<GraphicsSurface> surface = adoptRef(new GraphicsSurface(size, flags));
- surface->m_private = new GraphicsSurfacePrivate(token, size);
-
- if (!surface->m_private->frontBuffer() || !surface->m_private->backBuffer())
- return PassRefPtr<GraphicsSurface>();
-
- return surface;
-}
-
-static int ioSurfaceLockOptions(int lockOptions)
-{
- int options = 0;
- if (lockOptions & GraphicsSurface::ReadOnly)
- options |= kIOSurfaceLockReadOnly;
- if (!(lockOptions & GraphicsSurface::RetainPixels))
- options |= kIOSurfaceLockAvoidSync;
-
- return options;
-}
-
-char* GraphicsSurface::platformLock(const IntRect& rect, int* outputStride, LockOptions lockOptions)
-{
- // Locking is only necessary for single buffered use.
- // In this case we only have a front buffer, so we only lock this one.
- m_lockOptions = lockOptions;
- IOReturn status = IOSurfaceLock(m_private->frontBuffer(), ioSurfaceLockOptions(m_lockOptions), 0);
- if (status == kIOReturnCannotLock) {
- m_lockOptions |= RetainPixels;
- IOSurfaceLock(m_private->frontBuffer(), ioSurfaceLockOptions(m_lockOptions), 0);
- }
-
- int stride = IOSurfaceGetBytesPerRow(m_private->frontBuffer());
- if (outputStride)
- *outputStride = stride;
-
- char* base = static_cast<char*>(IOSurfaceGetBaseAddress(m_private->frontBuffer()));
-
- return base + stride * rect.y() + rect.x() * 4;
-}
-
-void GraphicsSurface::platformUnlock()
-{
- IOSurfaceUnlock(m_private->frontBuffer(), ioSurfaceLockOptions(m_lockOptions), 0);
-}
-
-void GraphicsSurface::platformDestroy()
-{
- if (m_fbo)
- glDeleteFramebuffers(1, &m_fbo);
- if (m_private)
- delete m_private;
- m_private = 0;
-}
-
-}
-#endif
diff --git a/Source/WebCore/platform/graphics/surfaces/win/GraphicsSurfaceWin.cpp b/Source/WebCore/platform/graphics/surfaces/win/GraphicsSurfaceWin.cpp
deleted file mode 100644
index 6c88190..0000000
--- a/Source/WebCore/platform/graphics/surfaces/win/GraphicsSurfaceWin.cpp
+++ /dev/null
@@ -1,483 +0,0 @@
-/*
-
- Copyright (C) 2012 Zeno Albisser <zeno@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 "GraphicsSurface.h"
-
-#if USE(GRAPHICS_SURFACE)
-#include "TextureMapperGL.h"
-
-#define EGL_EGLEXT_PROTOTYPES // This must be defined before including egl.h and eglext.h.
-#include <EGL/egl.h>
-#include <EGL/eglext.h>
-
-namespace WebCore {
-
-#define STRINGIFY(...) #__VA_ARGS__
-
-static GLuint loadShader(GLenum type, const GLchar *shaderSrc)
-{
- GLuint shader;
- GLint compiled;
-
- shader = glCreateShader(type);
- if (!shader)
- return 0;
-
- glShaderSource(shader, 1, &shaderSrc, 0);
- glCompileShader(shader);
- glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled);
- if (!compiled) {
- glDeleteShader(shader);
- return 0;
- }
- return shader;
-}
-
-struct GraphicsSurfacePrivate {
-public:
- GraphicsSurfacePrivate(const IntSize& size, GraphicsSurfaceToken token)
- : m_token(token)
- , m_detachedContext(0)
- , m_detachedReadSurface(0)
- , m_detachedDrawSurface(0)
- , m_size(size)
- , m_eglDisplay(0)
- , m_eglContext(0)
- , m_eglConfig(0)
- , m_eglFrontBufferSurface(0)
- , m_eglBackBufferSurface(0)
- , m_initialFrontBufferShareHandle(token.frontBufferHandle)
- , m_frontBufferShareHandle(token.frontBufferHandle)
- , m_backBufferShareHandle(token.backBufferHandle)
- , m_frontBufferTexture(0)
- , m_shaderProgram(0)
- {
- initializeShaderProgram();
- }
-
-
- GraphicsSurfacePrivate(const PlatformGraphicsContext3D shareContext, const IntSize& size, GraphicsSurface::Flags flags)
- : m_detachedContext(0)
- , m_detachedReadSurface(0)
- , m_detachedDrawSurface(0)
- , m_size(size)
- , m_eglDisplay(0)
- , m_eglContext(0)
- , m_eglConfig(0)
- , m_eglFrontBufferSurface(0)
- , m_eglBackBufferSurface(0)
- , m_initialFrontBufferShareHandle(0)
- , m_frontBufferShareHandle(0)
- , m_backBufferShareHandle(0)
- , m_frontBufferTexture(0)
- , m_shaderProgram(0)
- {
- initializeShaderProgram();
-
- static PFNEGLQUERYSURFACEPOINTERANGLEPROC eglQuerySurfacePointerANGLE = 0;
- if (!eglQuerySurfacePointerANGLE) {
- eglQuerySurfacePointerANGLE = reinterpret_cast<PFNEGLQUERYSURFACEPOINTERANGLEPROC>(eglGetProcAddress("eglQuerySurfacePointerANGLE"));
- if (!eglQuerySurfacePointerANGLE)
- return;
- }
-
- if (!m_eglDisplay || !m_eglContext || !m_eglConfig) {
- m_eglDisplay = eglGetCurrentDisplay();
- EGLint contextAttributes[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
- m_eglContext = eglCreateContext(m_eglDisplay, m_eglConfig, eglShareContext, contextAttributes);
- }
-
- EGLint attributes[] = {
- EGL_WIDTH, size.width(),
- EGL_HEIGHT, size.height(),
- EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGB,
- EGL_TEXTURE_TARGET, EGL_TEXTURE_2D,
- EGL_NONE
- };
-
- m_eglFrontBufferSurface = eglCreatePbufferSurface(m_eglDisplay, m_eglConfig, attributes);
- m_eglBackBufferSurface = eglCreatePbufferSurface(m_eglDisplay, m_eglConfig, attributes);
- if (m_eglFrontBufferSurface == EGL_NO_SURFACE || m_eglBackBufferSurface == EGL_NO_SURFACE)
- return;
-
- eglQuerySurfacePointerANGLE(m_eglDisplay, m_eglFrontBufferSurface, EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE, &m_frontBufferShareHandle);
- eglQuerySurfacePointerANGLE(m_eglDisplay, m_eglBackBufferSurface, EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE, &m_backBufferShareHandle);
-
- m_initialFrontBufferShareHandle = m_frontBufferShareHandle;
-
- m_token = GraphicsSurfaceToken(m_frontBufferShareHandle, m_backBufferShareHandle);
- }
-
- ~GraphicsSurfacePrivate()
- {
- releaseFrontBufferTexture();
-
- if (m_eglBackBufferSurface)
- eglDestroySurface(m_eglDisplay, m_eglBackBufferSurface);
-
- if (m_shaderProgram)
- glDeleteProgram(m_shaderProgram);
- m_shaderProgram = 0;
-
- if (m_eglDisplay && m_eglContext)
- eglDestroyContext(m_eglDisplay, m_eglContext);
- }
-
- void copyFromTexture(uint32_t texture, const IntRect& sourceRect)
- {
- if (!makeCurrent())
- return;
- glBindFramebuffer(GL_FRAMEBUFFER, 0);
- drawTexture(texture);
- glFinish();
- doneCurrent();
- }
-
- bool makeCurrent()
- {
- m_detachedContext = eglGetCurrentContext();
- m_detachedReadSurface = eglGetCurrentSurface(EGL_READ);
- m_detachedDrawSurface = eglGetCurrentSurface(EGL_DRAW);
-
- return eglMakeCurrent(m_eglDisplay, m_eglBackBufferSurface, m_eglBackBufferSurface, m_eglContext);
- }
-
- bool doneCurrent()
- {
- if (!m_detachedContext || !m_detachedDrawSurface || !m_detachedReadSurface)
- return false;
-
- bool success = eglMakeCurrent(m_eglDisplay, m_detachedDrawSurface, m_detachedReadSurface, m_detachedContext);
- m_detachedContext = 0;
- m_detachedReadSurface = 0;
- m_detachedDrawSurface = 0;
- return success;
- }
-
- PlatformGraphicsSurface swapBuffers()
- {
- if (m_frontBufferTexture)
- releaseFrontBufferTexture();
- std::swap(m_eglFrontBufferSurface, m_eglBackBufferSurface);
- std::swap(m_frontBufferShareHandle, m_backBufferShareHandle);
-
- return m_frontBufferShareHandle;
- }
-
- GraphicsSurfaceToken token() const
- {
- return m_token;
- }
-
- uint32_t frontBufferTextureID()
- {
- if (!m_eglFrontBufferSurface) {
- m_eglFrontBufferSurface = createSurfaceFromShareHandle(m_size, m_frontBufferShareHandle);
-
- glGenTextures(1, &m_frontBufferTexture);
- glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, m_frontBufferTexture);
- eglBindTexImage(m_eglDisplay, m_eglFrontBufferSurface, EGL_BACK_BUFFER);
-
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- }
-
- return m_frontBufferTexture;
- }
-
- PlatformGraphicsSurface initialFrontBufferShareHandle() const
- {
- return m_initialFrontBufferShareHandle;
- }
-
- PlatformGraphicsSurface frontBufferShareHandle() const
- {
- return m_frontBufferShareHandle;
- }
-
- PlatformGraphicsSurface backBufferShareHandle() const
- {
- return m_backBufferShareHandle;
- }
-
- void releaseFrontBufferTexture()
- {
- if (m_frontBufferTexture) {
- eglReleaseTexImage(m_eglDisplay, m_eglFrontBufferSurface, EGL_BACK_BUFFER);
- glDeleteTextures(1, &m_frontBufferTexture);
- m_frontBufferTexture = 0;
- }
-
- if (m_eglFrontBufferSurface)
- eglDestroySurface(m_eglDisplay, m_eglFrontBufferSurface);
- m_eglFrontBufferSurface = 0;
- }
-
- IntSize size() const
- {
- return m_size;
- }
-
-protected:
- void initializeShaderProgram()
- {
- if (m_shaderProgram)
- return;
-
- GLchar vShaderStr[] =
- STRINGIFY(
- attribute highp vec2 vertex;
- attribute highp vec2 textureCoordinates;
- varying highp vec2 textureCoords;
- void main(void)
- {
- gl_Position = vec4(vertex, 0.0, 1.0);
- textureCoords = textureCoordinates;
- }
- );
-
- GLchar fShaderStr[] =
- STRINGIFY(
- varying highp vec2 textureCoords;
- uniform sampler2D texture;
- void main(void)
- {
- highp vec3 color = texture2D(texture, textureCoords).rgb;
- gl_FragColor = vec4(clamp(color, 0.0, 1.0), 1.0);
- }
- );
-
- GLuint vertexShader;
- GLuint fragmentShader;
- GLint linked;
-
- vertexShader = loadShader(GL_VERTEX_SHADER, vShaderStr);
- fragmentShader = loadShader(GL_FRAGMENT_SHADER, fShaderStr);
- if (!vertexShader || !fragmentShader)
- return;
-
- m_shaderProgram = glCreateProgram();
- if (!m_shaderProgram)
- return;
-
- glAttachShader(m_shaderProgram, vertexShader);
- glAttachShader(m_shaderProgram, fragmentShader);
-
- glLinkProgram(m_shaderProgram);
- glGetProgramiv(m_shaderProgram, GL_LINK_STATUS, &linked);
- if (!linked) {
- glDeleteProgram(m_shaderProgram);
- m_shaderProgram = 0;
- }
-
- m_vertexAttr = glGetAttribLocation(m_shaderProgram, "vertex");
- m_textureCoordinatesAttr = glGetAttribLocation(m_shaderProgram, "textureCoordinates");
- m_textureUniform = glGetAttribLocation(m_shaderProgram, "texture");
-
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- }
-
- EGLSurface createSurfaceFromShareHandle(const IntSize& size, HANDLE shareHandle)
- {
- if (!m_eglDisplay || !m_eglConfig)
- m_eglDisplay = eglGetCurrentDisplay();
-
- EGLint attributes[] = {
- EGL_WIDTH, size.width(),
- EGL_HEIGHT, size.height(),
- EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGB,
- EGL_TEXTURE_TARGET, EGL_TEXTURE_2D,
- EGL_NONE
- };
-
- EGLSurface surface = eglCreatePbufferFromClientBuffer(m_eglDisplay, EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE, reinterpret_cast<EGLClientBuffer>(shareHandle), m_eglConfig, attributes);
- ASSERT(surface);
-
- return surface;
- }
-
- void drawTexture(uint32_t texture)
- {
- glUseProgram(m_shaderProgram);
-
- glBindBuffer(GL_ARRAY_BUFFER, 0);
- glBindTexture(GL_TEXTURE_2D, texture);
-
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-
- GLfloat afVertices[] = {
- -1, -1,
- 1, -1,
- -1, 1,
- 1, 1
- };
- glVertexAttribPointer(m_vertexAttr, 2, GL_FLOAT, GL_FALSE, 0, afVertices);
-
- GLfloat aftextureCoordinates[] = {
- 0, 1,
- 1, 1,
- 0, 0,
- 1, 0
- };
- glVertexAttribPointer(m_textureCoordinatesAttr, 2, GL_FLOAT, GL_FALSE, 0, aftextureCoordinates);
-
- glUniform1i(m_textureUniform, 0);
-
- glEnableVertexAttribArray(m_vertexAttr);
- glEnableVertexAttribArray(m_textureCoordinatesAttr);
-
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
-
- glDisableVertexAttribArray(m_vertexAttr);
- glDisableVertexAttribArray(m_textureCoordinatesAttr);
-
- glBindTexture(GL_TEXTURE_2D, 0);
- }
-
-private:
- GraphicsSurfaceToken m_token;
- EGLContext m_detachedContext;
- EGLSurface m_detachedReadSurface;
- EGLSurface m_detachedDrawSurface;
- IntSize m_size;
- EGLDisplay m_eglDisplay;
- EGLContext m_eglContext;
- EGLConfig m_eglConfig;
- EGLSurface m_eglFrontBufferSurface;
- EGLSurface m_eglBackBufferSurface;
- PlatformGraphicsSurface m_initialFrontBufferShareHandle;
- PlatformGraphicsSurface m_frontBufferShareHandle;
- PlatformGraphicsSurface m_backBufferShareHandle;
- GLuint m_frontBufferTexture;
- GLint m_shaderProgram;
-
- GLuint m_vertexAttr;
- GLuint m_textureCoordinatesAttr;
- GLuint m_textureUniform;
-};
-
-GraphicsSurfaceToken GraphicsSurface::platformExport()
-{
- return m_private->token();
-}
-
-uint32_t GraphicsSurface::platformGetTextureID()
-{
- return m_private->frontBufferTextureID();
-}
-
-void GraphicsSurface::platformCopyToGLTexture(uint32_t target, uint32_t id, const IntRect& targetRect, const IntPoint& offset)
-{
- // Currently not implemented.
-}
-
-void GraphicsSurface::platformCopyFromTexture(uint32_t texture, const IntRect& sourceRect)
-{
- m_private->copyFromTexture(texture, sourceRect);
-}
-
-void GraphicsSurface::platformPaintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity)
-{
- IntSize size = m_private->size();
- FloatRect rectOnContents(FloatPoint::zero(), size);
- TransformationMatrix adjustedTransform = transform;
- adjustedTransform.multiply(TransformationMatrix::rectToRect(rectOnContents, targetRect));
- static_cast<TextureMapperGL*>(textureMapper)->drawTexture(platformGetTextureID(), 0, size, rectOnContents, adjustedTransform, opacity);
-}
-
-uint32_t GraphicsSurface::platformFrontBuffer() const
-{
- if (m_private->initialFrontBufferShareHandle() == m_private->frontBufferShareHandle())
- return 0;
- if (m_private->initialFrontBufferShareHandle() == m_private->backBufferShareHandle())
- return 1;
- return 0xFFFF;
-}
-
-uint32_t GraphicsSurface::platformSwapBuffers()
-{
- m_private->swapBuffers();
- return platformFrontBuffer();
-}
-
-IntSize GraphicsSurface::platformSize() const
-{
- return m_private->size();
-}
-
-PassRefPtr<GraphicsSurface> GraphicsSurface::platformCreate(const IntSize& size, Flags flags, const PlatformGraphicsContext3D shareContext)
-{
- // Single buffered GraphicsSurface is currently not supported.
- if (flags & SupportsCopyToTexture || flags & SupportsSingleBuffered)
- return PassRefPtr<GraphicsSurface>();
-
- RefPtr<GraphicsSurface> surface = adoptRef(new GraphicsSurface(size, flags));
- surface->m_private = new GraphicsSurfacePrivate(shareContext, size, flags);
-
- if (!surface->m_private->frontBufferShareHandle() || !surface->m_private->backBufferShareHandle())
- return PassRefPtr<GraphicsSurface>();
-
- return surface;
-}
-
-PassRefPtr<GraphicsSurface> GraphicsSurface::platformImport(const IntSize& size, Flags flags, const GraphicsSurfaceToken& token)
-{
- // Single buffered GraphicsSurface is currently not supported.
- if (flags & SupportsCopyToTexture || flags & SupportsSingleBuffered)
- return PassRefPtr<GraphicsSurface>();
-
- RefPtr<GraphicsSurface> surface = adoptRef(new GraphicsSurface(size, flags));
- surface->m_private = new GraphicsSurfacePrivate(size, token);
-
- if (!surface->m_private->frontBufferShareHandle() || !surface->m_private->backBufferShareHandle())
- return PassRefPtr<GraphicsSurface>();
-
- return surface;
-}
-
-char* GraphicsSurface::platformLock(const IntRect& rect, int* outputStride, LockOptions lockOptions)
-{
- // GraphicsSurface is currently only being used for WebGL, which does not require this locking mechanism.
- return 0;
-}
-
-void GraphicsSurface::platformUnlock()
-{
- // GraphicsSurface is currently only being used for WebGL, which does not require this locking mechanism.
-}
-
-void GraphicsSurface::platformDestroy()
-{
- delete m_private;
- m_private = 0;
-}
-
-}
-#endif
diff --git a/Source/WebCore/platform/graphics/win/DIBPixelData.cpp b/Source/WebCore/platform/graphics/win/DIBPixelData.cpp
deleted file mode 100644
index 5d19280..0000000
--- a/Source/WebCore/platform/graphics/win/DIBPixelData.cpp
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (C) 2011 Brent Fulgham <bfulgham@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 INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED 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 "DIBPixelData.h"
-
-namespace WebCore {
-
-static const WORD bitmapType = 0x4d42; // BMP format
-static const WORD bitmapPixelsPerMeter = 2834; // 72 dpi
-
-DIBPixelData::DIBPixelData(HBITMAP bitmap)
-{
- initialize(bitmap);
-}
-
-void DIBPixelData::initialize(HBITMAP bitmap)
-{
- BITMAP bmpInfo;
- GetObject(bitmap, sizeof(bmpInfo), &bmpInfo);
-
- m_bitmapBuffer = reinterpret_cast<UInt8*>(bmpInfo.bmBits);
- m_bitmapBufferLength = bmpInfo.bmWidthBytes * bmpInfo.bmHeight;
- m_size = IntSize(bmpInfo.bmWidth, bmpInfo.bmHeight);
- m_bytesPerRow = bmpInfo.bmWidthBytes;
- m_bitsPerPixel = bmpInfo.bmBitsPixel;
-}
-
-#ifndef NDEBUG
-void DIBPixelData::writeToFile(LPCWSTR filePath)
-{
- HANDLE hFile = ::CreateFile(filePath, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
- if (INVALID_HANDLE_VALUE == hFile)
- return;
-
- BITMAPFILEHEADER header;
- header.bfType = bitmapType;
- header.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
- header.bfReserved1 = 0;
- header.bfReserved2 = 0;
- header.bfSize = sizeof(BITMAPFILEHEADER);
-
- BITMAPINFOHEADER info;
- info.biSize = sizeof(BITMAPINFOHEADER);
- info.biWidth = m_size.width();
- info.biHeight = m_size.height();
- info.biPlanes = 1;
- info.biBitCount = m_bitsPerPixel;
- info.biCompression = BI_RGB;
- info.biSizeImage = bufferLength();
- info.biXPelsPerMeter = bitmapPixelsPerMeter;
- info.biYPelsPerMeter = bitmapPixelsPerMeter;
- info.biClrUsed = 0;
- info.biClrImportant = 0;
-
- DWORD bytesWritten = 0;
- ::WriteFile(hFile, &header, sizeof(header), &bytesWritten, 0);
- ::WriteFile(hFile, &info, sizeof(info), &bytesWritten, 0);
- ::WriteFile(hFile, buffer(), bufferLength(), &bytesWritten, 0);
-
- ::CloseHandle(hFile);
-}
-#endif
-
-void DIBPixelData::setRGBABitmapAlpha(HDC hdc, const IntRect& dstRect, unsigned char level)
-{
- HBITMAP bitmap = static_cast<HBITMAP>(GetCurrentObject(hdc, OBJ_BITMAP));
- DIBPixelData pixelData(bitmap);
- ASSERT(pixelData.bitsPerPixel() == 32);
-
- XFORM trans;
- GetWorldTransform(hdc, &trans);
- IntSize transformedPosition(trans.eDx, trans.eDy);
- IntRect drawRect(dstRect);
- drawRect.move(transformedPosition);
-
- int pixelDataWidth = pixelData.size().width();
- int pixelDataHeight = pixelData.size().height();
- IntRect bitmapRect(0, 0, pixelDataWidth, pixelDataHeight);
- drawRect.intersect(bitmapRect);
- if (drawRect.isEmpty())
- return;
-
- RGBQUAD* bytes = reinterpret_cast<RGBQUAD*>(pixelData.buffer());
- bytes += drawRect.y() * pixelDataWidth;
-
- size_t width = drawRect.width();
- size_t height = drawRect.height();
- int x = drawRect.x();
- for (size_t i = 0; i < height; i++) {
- RGBQUAD* p = bytes + x;
- for (size_t j = 0; j < width; j++) {
- p->rgbReserved = level;
- p++;
- }
- bytes += pixelDataWidth;
- }
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/win/DIBPixelData.h b/Source/WebCore/platform/graphics/win/DIBPixelData.h
deleted file mode 100644
index 379776e..0000000
--- a/Source/WebCore/platform/graphics/win/DIBPixelData.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2011 Brent Fulgham <bfulgham@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 INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED 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 DIBPixelData_h
-#define DIBPixelData_h
-
-#include "IntRect.h"
-#include "IntSize.h"
-#include <windows.h>
-
-typedef unsigned char UInt8;
-
-namespace WebCore {
-
-class DIBPixelData {
- public:
- DIBPixelData()
- : m_bitmapBuffer(0)
- , m_bitmapBufferLength(0)
- , m_bytesPerRow(0)
- , m_bitsPerPixel(0)
- {
- }
- DIBPixelData(HBITMAP);
-
- void initialize(HBITMAP);
-
-#ifndef NDEBUG
- void writeToFile(LPCWSTR);
-#endif
-
- UInt8* buffer() const { return m_bitmapBuffer; }
- unsigned bufferLength() const { return m_bitmapBufferLength; }
- const IntSize& size() const { return m_size; }
- unsigned bytesPerRow() const { return m_bytesPerRow; }
- unsigned short bitsPerPixel() const { return m_bitsPerPixel; }
- static void setRGBABitmapAlpha(HDC, const IntRect&, unsigned char);
-
- private:
- UInt8* m_bitmapBuffer;
- unsigned m_bitmapBufferLength;
- IntSize m_size;
- unsigned m_bytesPerRow;
- unsigned short m_bitsPerPixel;
-};
-
-} // namespace WebCore
-
-#endif // DIBPixelData_h
diff --git a/Source/WebCore/platform/graphics/win/FontCGWin.cpp b/Source/WebCore/platform/graphics/win/FontCGWin.cpp
deleted file mode 100644
index 170c9f0..0000000
--- a/Source/WebCore/platform/graphics/win/FontCGWin.cpp
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008, 2009 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;
-}
-
-void Font::drawGlyphs(GraphicsContext* graphicsContext, const SimpleFontData* font, const GlyphBuffer& glyphBuffer,
- int from, int numGlyphs, const FloatPoint& point) const
-{
- CGContextRef cgContext = graphicsContext->platformContext();
- bool shouldUseFontSmoothing = WebCoreShouldUseFontSmoothing();
-
- switch(fontDescription().fontSmoothing()) {
- case Antialiased: {
- graphicsContext->setShouldAntialias(true);
- shouldUseFontSmoothing = false;
- break;
- }
- case SubpixelAntialiased: {
- graphicsContext->setShouldAntialias(true);
- shouldUseFontSmoothing = true;
- break;
- }
- case NoSmoothing: {
- graphicsContext->setShouldAntialias(false);
- shouldUseFontSmoothing = false;
- break;
- }
- case AutoSmoothing: {
- // For the AutoSmooth case, don't do anything! Keep the default settings.
- break;
- }
- default:
- ASSERT_NOT_REACHED();
- }
-
- uint32_t oldFontSmoothingStyle = wkSetFontSmoothingStyle(cgContext, shouldUseFontSmoothing);
-
- 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, font->platformData().useGDI());
-
- FloatSize shadowOffset;
- float shadowBlur;
- Color shadowColor;
- ColorSpace shadowColorSpace;
- graphicsContext->getShadow(shadowOffset, shadowBlur, shadowColor, shadowColorSpace);
-
- bool hasSimpleShadow = graphicsContext->textDrawingMode() == TextModeFill && shadowColor.isValid() && !shadowBlur && (!graphicsContext->shadowsIgnoreTransforms() || graphicsContext->getCTM().isIdentityOrTranslationOrFlipped());
- 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, ColorSpaceDeviceRGB);
- float shadowTextX = point.x() + translation.width() + shadowOffset.width();
- // If shadows are ignoring transforms, then we haven't applied the Y coordinate flip yet, so down is negative.
- float shadowTextY = point.y() + translation.height() + shadowOffset.height() * (graphicsContext->shadowsIgnoreTransforms() ? -1 : 1);
- CGContextSetTextPosition(cgContext, shadowTextX, shadowTextY);
- CGContextShowGlyphsWithAdvances(cgContext, glyphBuffer.glyphs(from), static_cast<const CGSize*>(glyphBuffer.advances(from)), numGlyphs);
- if (font->syntheticBoldOffset()) {
- CGContextSetTextPosition(cgContext, point.x() + translation.width() + shadowOffset.width() + font->syntheticBoldOffset(), point.y() + translation.height() + shadowOffset.height());
- CGContextShowGlyphsWithAdvances(cgContext, glyphBuffer.glyphs(from), static_cast<const CGSize*>(glyphBuffer.advances(from)), numGlyphs);
- }
- graphicsContext->setFillColor(fillColor, ColorSpaceDeviceRGB);
- }
-
- CGContextSetTextPosition(cgContext, point.x() + translation.width(), point.y() + translation.height());
- CGContextShowGlyphsWithAdvances(cgContext, glyphBuffer.glyphs(from), static_cast<const CGSize*>(glyphBuffer.advances(from)), numGlyphs);
- if (font->syntheticBoldOffset()) {
- CGContextSetTextPosition(cgContext, point.x() + translation.width() + font->syntheticBoldOffset(), point.y() + translation.height());
- CGContextShowGlyphsWithAdvances(cgContext, glyphBuffer.glyphs(from), static_cast<const CGSize*>(glyphBuffer.advances(from)), numGlyphs);
- }
-
- if (hasSimpleShadow)
- graphicsContext->setShadow(shadowOffset, shadowBlur, shadowColor, ColorSpaceDeviceRGB);
-
- wkRestoreFontSmoothingStyle(cgContext, oldFontSmoothingStyle);
-}
-
-}
diff --git a/Source/WebCore/platform/graphics/win/FontCacheWin.cpp b/Source/WebCore/platform/graphics/win/FontCacheWin.cpp
deleted file mode 100644
index 5a35c29..0000000
--- a/Source/WebCore/platform/graphics/win/FontCacheWin.cpp
+++ /dev/null
@@ -1,581 +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 "HWndDC.h"
-#include "SimpleFontData.h"
-#include "UnicodeRange.h"
-#include <mlang.h>
-#include <windows.h>
-#include <wtf/StdLibExtras.h>
-#include <wtf/text/StringHash.h>
-
-using std::min;
-
-namespace WebCore
-{
-
-void FontCache::platformInit()
-{
-}
-
-IMLangFontLinkType* FontCache::getFontLinkInterface()
-{
- static IMultiLanguage *multiLanguage;
- if (!multiLanguage) {
- if (CoCreateInstance(CLSID_CMultiLanguage, 0, CLSCTX_ALL, IID_IMultiLanguage, (void**)&multiLanguage) != S_OK)
- return 0;
- }
-
- static IMLangFontLinkType* 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;
- IMLangFontLinkType* 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(IMLangFontLinkType* 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;
-}
-
-PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
-{
- UChar character = characters[0];
- RefPtr<SimpleFontData> fontData;
- HWndDC hdc(0);
- HFONT primaryFont = font.primaryFont()->fontDataForCharacter(character)->platformData().hfont();
- HGDIOBJ oldFont = SelectObject(hdc, primaryFont);
- HFONT hfont = 0;
-
- if (IMLangFontLinkType* 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, DoNotRetain);
- }
-
- SelectObject(hdc, oldFont);
- DeleteObject(hfont);
- }
-
- return fontData.release();
-}
-
-PassRefPtr<SimpleFontData> FontCache::getSimilarFontPlatformData(const Font& font)
-{
- return 0;
-}
-
-PassRefPtr<SimpleFontData> FontCache::fontDataFromDescriptionAndLogFont(const FontDescription& fontDescription, ShouldRetain shouldRetain, const LOGFONT& font, AtomicString& outFontFamilyName)
-{
- AtomicString familyName = String(font.lfFaceName, wcsnlen(font.lfFaceName, LF_FACESIZE));
- RefPtr<SimpleFontData> fontData = getCachedFontData(fontDescription, familyName, false, shouldRetain);
- if (fontData)
- outFontFamilyName = familyName;
- return fontData.release();
-}
-
-PassRefPtr<SimpleFontData> FontCache::getLastResortFallbackFont(const FontDescription& fontDescription, ShouldRetain shouldRetain)
-{
- DEFINE_STATIC_LOCAL(AtomicString, fallbackFontName, ());
- if (!fallbackFontName.isEmpty())
- return getCachedFontData(fontDescription, fallbackFontName, false, shouldRetain);
-
- // 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.
-
- // Search all typical Windows-installed full Unicode fonts.
- // Sorted by most to least glyphs according to http://en.wikipedia.org/wiki/Unicode_typefaces
- // Start with Times New Roman also since it is the default if the user doesn't change prefs.
- static AtomicString fallbackFonts[] = {
- AtomicString("Times New Roman", AtomicString::ConstructFromLiteral),
- AtomicString("Microsoft Sans Serif", AtomicString::ConstructFromLiteral),
- AtomicString("Tahoma", AtomicString::ConstructFromLiteral),
- AtomicString("Lucida Sans Unicode", AtomicString::ConstructFromLiteral),
- AtomicString("Arial", AtomicString::ConstructFromLiteral)
- };
- RefPtr<SimpleFontData> simpleFont;
- for (size_t i = 0; i < WTF_ARRAY_LENGTH(fallbackFonts); ++i) {
- if (simpleFont = getCachedFontData(fontDescription, fallbackFonts[i], false, shouldRetain)) {
- fallbackFontName = fallbackFonts[i];
- return simpleFont.release();
- }
- }
-
- // Fall back to the DEFAULT_GUI_FONT if no known Unicode fonts are available.
- if (HFONT defaultGUIFont = static_cast<HFONT>(GetStockObject(DEFAULT_GUI_FONT))) {
- LOGFONT defaultGUILogFont;
- GetObject(defaultGUIFont, sizeof(defaultGUILogFont), &defaultGUILogFont);
- if (simpleFont = fontDataFromDescriptionAndLogFont(fontDescription, shouldRetain, defaultGUILogFont, fallbackFontName))
- return simpleFont.release();
- }
-
- // Fall back to Non-client metrics fonts.
- NONCLIENTMETRICS nonClientMetrics = {0};
- nonClientMetrics.cbSize = sizeof(nonClientMetrics);
- if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(nonClientMetrics), &nonClientMetrics, 0)) {
- if (simpleFont = fontDataFromDescriptionAndLogFont(fontDescription, shouldRetain, nonClientMetrics.lfMessageFont, fallbackFontName))
- return simpleFont.release();
- if (simpleFont = fontDataFromDescriptionAndLogFont(fontDescription, shouldRetain, nonClientMetrics.lfMenuFont, fallbackFontName))
- return simpleFont.release();
- if (simpleFont = fontDataFromDescriptionAndLogFont(fontDescription, shouldRetain, nonClientMetrics.lfStatusFont, fallbackFontName))
- return simpleFont.release();
- if (simpleFont = fontDataFromDescriptionAndLogFont(fontDescription, shouldRetain, nonClientMetrics.lfCaptionFont, fallbackFontName))
- return simpleFont.release();
- if (simpleFont = fontDataFromDescriptionAndLogFont(fontDescription, shouldRetain, nonClientMetrics.lfSmCaptionFont, fallbackFontName))
- return simpleFont.release();
- }
-
- ASSERT_NOT_REACHED();
- return 0;
-}
-
-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, bool synthesizeItalic)
-{
- HWndDC hdc(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);
-
- 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;
- matchData.m_chosen.lfOutPrecision = OUT_TT_PRECIS;
- matchData.m_chosen.lfQuality = DEFAULT_QUALITY;
- matchData.m_chosen.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
-
- if (desiredItalic && !matchData.m_chosen.lfItalic && synthesizeItalic)
- matchData.m_chosen.lfItalic = 1;
-
- HFONT result = CreateFontIndirect(&matchData.m_chosen);
- if (!result)
- return 0;
-
- HWndDC dc(0);
- SaveDC(dc);
- SelectObject(dc, result);
- WCHAR actualName[LF_FACESIZE];
- GetTextFace(dc, LF_FACESIZE, actualName);
- RestoreDC(dc, -1);
-
- if (wcsicmp(matchData.m_chosen.lfFaceName, actualName)) {
- DeleteObject(result);
- result = 0;
- }
-
- return result;
-}
-
-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)
-{
- HWndDC hdc(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);
-}
-
-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), useGDI);
-
- 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 (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/Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp b/Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp
deleted file mode 100644
index ec426c1..0000000
--- a/Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (C) 2007, 2008, 2009, 2010 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 "FontPlatformData.h"
-#include "OpenTypeUtilities.h"
-#include "SharedBuffer.h"
-#include "WOFFFileFormat.h"
-#include <ApplicationServices/ApplicationServices.h>
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
-#include <wtf/RetainPtr.h>
-#include <wtf/text/Base64.h>
-
-namespace WebCore {
-
-using namespace std;
-
-FontCustomPlatformData::~FontCustomPlatformData()
-{
- if (m_fontReference)
- RemoveFontMemResourceEx(m_fontReference);
-}
-
-FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontOrientation, FontWidthVariant, FontRenderingMode renderingMode)
-{
- ASSERT(m_fontReference);
-
- LOGFONT& logFont = *static_cast<LOGFONT*>(malloc(sizeof(LOGFONT)));
- 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);
-
- RetainPtr<CGFontRef> cgFont(AdoptCF, CGFontCreateWithPlatformFont(&logFont));
- return FontPlatformData(hfont, cgFont.get(), size, bold, italic, renderingMode == AlternateRenderingMode);
-}
-
-// Creates a unique and unpredictable font name, in order to avoid collisions and to
-// not allow access from CSS.
-static String createUniqueFontName()
-{
- GUID fontUuid;
- CoCreateGuid(&fontUuid);
-
- String fontName = base64Encode(reinterpret_cast<char*>(&fontUuid), sizeof(fontUuid));
- ASSERT(fontName.length() < LF_FACESIZE);
- return fontName;
-}
-
-FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer)
-{
- ASSERT_ARG(buffer, buffer);
-
- RefPtr<SharedBuffer> sfntBuffer;
- if (isWOFF(buffer)) {
- Vector<char> sfnt;
- if (!convertWOFFToSfnt(buffer, sfnt))
- return 0;
-
- sfntBuffer = SharedBuffer::adoptVector(sfnt);
- buffer = sfntBuffer.get();
- }
-
- String fontName = createUniqueFontName();
- HANDLE fontReference;
- fontReference = renameAndActivateFont(buffer, fontName);
- if (!fontReference)
- return 0;
- return new FontCustomPlatformData(fontReference, fontName);
-}
-
-bool FontCustomPlatformData::supportsFormat(const String& format)
-{
- return equalIgnoringCase(format, "truetype") || equalIgnoringCase(format, "opentype") || equalIgnoringCase(format, "woff");
-}
-
-}
diff --git a/Source/WebCore/platform/graphics/win/FontCustomPlatformData.h b/Source/WebCore/platform/graphics/win/FontCustomPlatformData.h
deleted file mode 100644
index 188951b..0000000
--- a/Source/WebCore/platform/graphics/win/FontCustomPlatformData.h
+++ /dev/null
@@ -1,63 +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 "FontOrientation.h"
-#include "FontRenderingMode.h"
-#include "FontWidthVariant.h"
-#include <windows.h>
-#include <wtf/Forward.h>
-#include <wtf/Noncopyable.h>
-#include <wtf/text/WTFString.h>
-
-typedef struct CGFont* CGFontRef;
-
-namespace WebCore {
-
-class FontPlatformData;
-class SharedBuffer;
-
-struct FontCustomPlatformData {
- WTF_MAKE_NONCOPYABLE(FontCustomPlatformData);
-public:
- FontCustomPlatformData(HANDLE fontReference, const String& name)
- : m_fontReference(fontReference)
- , m_name(name)
- {
- }
-
- ~FontCustomPlatformData();
-
- FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontOrientation = Horizontal,
- FontWidthVariant = RegularWidth, FontRenderingMode = NormalRenderingMode);
-
- static bool supportsFormat(const String&);
-
- HANDLE m_fontReference;
- String m_name;
-};
-
-FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer*);
-
-}
-
-#endif
diff --git a/Source/WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp b/Source/WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp
deleted file mode 100644
index d8070eb..0000000
--- a/Source/WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp
+++ /dev/null
@@ -1,157 +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, 2009 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 <ApplicationServices/ApplicationServices.h>
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
-#include <wtf/HashMap.h>
-#include <wtf/RetainPtr.h>
-#include <wtf/Vector.h>
-#include <wtf/text/StringHash.h>
-#include <wtf/text/WTFString.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)
-{
- LOGFONT logfont;
- GetObject(font, sizeof(logfont), &logfont);
- m_cgFont.adoptCF(CGFontCreateWithPlatformFont(&logfont));
-}
-
-FontPlatformData::FontPlatformData(HFONT hfont, CGFontRef font, float size, bool bold, bool oblique, bool useGDI)
- : m_syntheticBold(bold)
- , m_syntheticOblique(oblique)
- , m_orientation(Horizontal)
- , m_size(size)
- , m_widthVariant(RegularWidth)
- , m_font(RefCountedGDIHandle<HFONT>::create(hfont))
- , m_cgFont(font)
- , m_isColorBitmapFont(false)
- , m_useGDI(useGDI)
-{
-}
-
-FontPlatformData::~FontPlatformData()
-{
-}
-
-void FontPlatformData::platformDataInit(const FontPlatformData& source)
-{
- m_font = source.m_font;
- m_cgFont = source.m_cgFont;
- m_useGDI = source.m_useGDI;
-}
-
-const FontPlatformData& FontPlatformData::platformDataAssign(const FontPlatformData& other)
-{
- m_font = other.m_font;
- m_cgFont = other.m_cgFont;
- m_useGDI = other.m_useGDI;
-
- return *this;
-}
-
-bool FontPlatformData::platformIsEqual(const FontPlatformData& other) const
-{
- return m_font == other.m_font
- && m_cgFont == other.m_cgFont
- && m_useGDI == other.m_useGDI;
-}
-
-}
diff --git a/Source/WebCore/platform/graphics/win/FontPlatformDataWin.cpp b/Source/WebCore/platform/graphics/win/FontPlatformDataWin.cpp
deleted file mode 100644
index c073a62..0000000
--- a/Source/WebCore/platform/graphics/win/FontPlatformDataWin.cpp
+++ /dev/null
@@ -1,96 +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 "HWndDC.h"
-#include "SharedBuffer.h"
-#include <wtf/HashMap.h>
-#include <wtf/RetainPtr.h>
-#include <wtf/Vector.h>
-#include <wtf/text/StringHash.h>
-#include <wtf/text/WTFString.h>
-
-using std::min;
-
-namespace WebCore {
-
-FontPlatformData::FontPlatformData(HFONT font, float size, bool bold, bool oblique, bool useGDI)
- : m_font(RefCountedGDIHandle<HFONT>::create(font))
- , m_size(size)
- , m_orientation(Horizontal)
- , m_widthVariant(RegularWidth)
- , m_isColorBitmapFont(false)
- , m_syntheticBold(bold)
- , m_syntheticOblique(oblique)
- , m_useGDI(useGDI)
-{
- HWndDC hdc(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);
-}
-
-PassRefPtr<SharedBuffer> FontPlatformData::openTypeTable(uint32_t table) const
-{
- HWndDC hdc(0);
- HGDIOBJ oldFont = SelectObject(hdc, hfont());
-
- DWORD size = GetFontData(hdc, table, 0, 0, 0);
- RefPtr<SharedBuffer> buffer;
- if (size != GDI_ERROR) {
- buffer = SharedBuffer::create(size);
- DWORD result = GetFontData(hdc, table, 0, (PVOID)buffer->data(), size);
- ASSERT(result == size);
- }
-
- SelectObject(hdc, oldFont);
- return buffer.release();
-}
-
-#ifndef NDEBUG
-String FontPlatformData::description() const
-{
- return String();
-}
-#endif
-
-}
diff --git a/Source/WebCore/platform/graphics/win/FontWin.cpp b/Source/WebCore/platform/graphics/win/FontWin.cpp
deleted file mode 100644
index b01862f..0000000
--- a/Source/WebCore/platform/graphics/win/FontWin.cpp
+++ /dev/null
@@ -1,148 +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 "Logging.h"
-#include "SimpleFontData.h"
-#include "TextRun.h"
-#include "UniscribeController.h"
-#include <wtf/MathExtras.h>
-
-using namespace std;
-
-namespace WebCore {
-
-bool Font::canReturnFallbackFontsForComplexText()
-{
- return true;
-}
-
-bool Font::canExpandAroundIdeographsInComplexText()
-{
- return false;
-}
-
-FloatRect Font::selectionRectForComplexText(const TextRun& run, const FloatPoint& 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);
-}
-
-float Font::getGlyphsAndAdvancesForComplexText(const TextRun& run, int from, int to, GlyphBuffer& glyphBuffer, ForTextEmphasisOrNot forTextEmphasis) const
-{
- if (forTextEmphasis) {
- // FIXME: Add forTextEmphasis paremeter to UniscribeController and use it.
- LOG_ERROR("Not implemented for text emphasis.");
- return 0;
- }
-
- UniscribeController controller(this, run);
- controller.advance(from);
- float beforeWidth = controller.runWidthSoFar();
- controller.advance(to, &glyphBuffer);
-
- if (glyphBuffer.isEmpty())
- return 0;
-
- float afterWidth = controller.runWidthSoFar();
-
- if (run.rtl()) {
- controller.advance(run.length());
- return controller.runWidthSoFar() - afterWidth;
- }
- return beforeWidth;
-}
-
-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() + getGlyphsAndAdvancesForComplexText(run, from, to, glyphBuffer);
-
- // We couldn't generate any glyphs for the run. Give up.
- if (glyphBuffer.isEmpty())
- return;
-
- // Draw the glyph buffer now at the starting point returned in startX.
- FloatPoint startPoint(startX, point.y());
- drawGlyphBuffer(context, run, glyphBuffer, startPoint);
-}
-
-void Font::drawEmphasisMarksForComplexText(GraphicsContext* context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, int from, int to) const
-{
- GlyphBuffer glyphBuffer;
- float initialAdvance = getGlyphsAndAdvancesForComplexText(run, from, to, glyphBuffer, ForTextEmphasis);
-
- if (glyphBuffer.isEmpty())
- return;
-
- drawEmphasisMarks(context, run, glyphBuffer, mark, FloatPoint(point.x() + initialAdvance, point.y()));
-}
-
-float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
-{
- UniscribeController controller(this, run, fallbackFonts);
- controller.advance(run.length());
- if (glyphOverflow) {
- glyphOverflow->top = max<int>(glyphOverflow->top, ceilf(-controller.minGlyphBoundingBoxY()) - (glyphOverflow->computeBounds ? 0 : fontMetrics().ascent()));
- glyphOverflow->bottom = max<int>(glyphOverflow->bottom, ceilf(controller.maxGlyphBoundingBoxY()) - (glyphOverflow->computeBounds ? 0 : fontMetrics().descent()));
- glyphOverflow->left = max<int>(0, ceilf(-controller.minGlyphBoundingBoxX()));
- glyphOverflow->right = max<int>(0, ceilf(controller.maxGlyphBoundingBoxX() - controller.runWidthSoFar()));
- }
- return controller.runWidthSoFar();
-}
-
-int Font::offsetForPositionForComplexText(const TextRun& run, float xFloat, bool includePartialGlyphs) const
-{
- // FIXME: This truncation is not a problem for HTML, but only affects SVG, which passes floating-point numbers
- // to Font::offsetForPosition(). Bug http://webkit.org/b/40673 tracks fixing this problem.
- int x = static_cast<int>(xFloat);
-
- UniscribeController controller(this, run);
- return controller.offsetForPosition(x, includePartialGlyphs);
-}
-
-}
diff --git a/Source/WebCore/platform/graphics/win/FullScreenController.cpp b/Source/WebCore/platform/graphics/win/FullScreenController.cpp
deleted file mode 100644
index def538e..0000000
--- a/Source/WebCore/platform/graphics/win/FullScreenController.cpp
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008, 2009, 2011 Apple Inc. All rights reserved.
- * Copyright (C) Research In Motion Limited 2009. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR 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(FULLSCREEN_API)
-
-#include "FullScreenController.h"
-
-#include "Element.h"
-#include "FullScreenControllerClient.h"
-#include "IntRect.h"
-#include "MediaPlayerPrivateFullscreenWindow.h"
-#include "Timer.h"
-#include "WebCoreInstanceHandle.h"
-#include <wtf/RefPtr.h>
-
-using namespace WebCore;
-
-static const int kFullScreenAnimationDuration = 500; // milliseconds
-
-class FullScreenController::Private : public MediaPlayerPrivateFullscreenClient {
-public:
- Private(FullScreenController* controller, FullScreenControllerClient* client)
- : m_controller(controller)
- , m_client(client)
- , m_originalHost(0)
- , m_isFullScreen(false)
- , m_isEnteringFullScreen(false)
- , m_isExitingFullScreen(false)
- {
- }
- virtual ~Private() { }
-
- virtual LRESULT fullscreenClientWndProc(HWND, UINT, WPARAM, LPARAM);
-
- FullScreenController* m_controller;
- FullScreenControllerClient* m_client;
- OwnPtr<MediaPlayerPrivateFullscreenWindow> m_fullScreenWindow;
- OwnPtr<MediaPlayerPrivateFullscreenWindow> m_backgroundWindow;
- IntRect m_fullScreenFrame;
- IntRect m_originalFrame;
- HWND m_originalHost;
- bool m_isFullScreen;
- bool m_isEnteringFullScreen;
- bool m_isExitingFullScreen;
-};
-
-LRESULT FullScreenController::Private::fullscreenClientWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- LRESULT lResult = 0;
-
- switch (msg) {
- case WM_MOVE:
- m_fullScreenFrame.setX(LOWORD(lParam));
- m_fullScreenFrame.setY(HIWORD(lParam));
- break;
- case WM_SIZE:
- m_fullScreenFrame.setWidth(LOWORD(lParam));
- m_fullScreenFrame.setHeight(HIWORD(lParam));
- if (m_client->fullScreenClientWindow())
- ::SetWindowPos(m_client->fullScreenClientWindow(), 0, 0, 0, m_fullScreenFrame.width(), m_fullScreenFrame.height(), SWP_NOREPOSITION | SWP_NOMOVE);
- break;
- case WM_ACTIVATE:
- // Because m_fullScreenWindow is a topmost window, we need to exit full screen explicitly when it's deactivated.
- if (!wParam && m_fullScreenWindow && (hwnd == m_fullScreenWindow->hwnd()))
- m_controller->exitFullScreen();
- break;
- case WM_KEYDOWN:
- if (wParam == VK_ESCAPE) {
- m_controller->exitFullScreen();
- break;
- }
- // Fall through.
- default:
- lResult = ::DefWindowProc(hwnd, msg, wParam, lParam);
- }
-
- return lResult;
-}
-
-FullScreenController::FullScreenController(FullScreenControllerClient* client)
- : m_private(adoptPtr(new FullScreenController::Private(this, client)))
-{
- ASSERT_ARG(client, client);
-}
-
-FullScreenController::~FullScreenController()
-{
-}
-
-bool FullScreenController::isFullScreen() const
-{
- return m_private->m_isFullScreen;
-}
-
-void FullScreenController::enterFullScreen()
-{
- if (m_private->m_isFullScreen || m_private->m_isEnteringFullScreen)
- return;
- m_private->m_isFullScreen = true;
- m_private->m_isEnteringFullScreen = true;
-
- m_private->m_originalHost = m_private->m_client->fullScreenClientParentWindow();
- RECT originalFrame = {0, 0, 0, 0};
- ::GetClientRect(m_private->m_client->fullScreenClientWindow(), &originalFrame);
- ::MapWindowPoints(m_private->m_client->fullScreenClientWindow(), m_private->m_originalHost, reinterpret_cast<LPPOINT>(&originalFrame), 2);
- m_private->m_originalFrame = originalFrame;
-
- ASSERT(!m_private->m_backgroundWindow);
- m_private->m_backgroundWindow = adoptPtr(new MediaPlayerPrivateFullscreenWindow(m_private.get()));
- m_private->m_backgroundWindow->createWindow(0);
- ::AnimateWindow(m_private->m_backgroundWindow->hwnd(), kFullScreenAnimationDuration, AW_BLEND | AW_ACTIVATE);
-
- m_private->m_client->fullScreenClientWillEnterFullScreen();
- ASSERT(!m_private->m_fullScreenWindow);
- m_private->m_fullScreenWindow = adoptPtr(new MediaPlayerPrivateFullscreenWindow(m_private.get()));
- ASSERT(m_private->m_fullScreenWindow);
- m_private->m_fullScreenWindow->createWindow(0);
-
- m_private->m_client->fullScreenClientSetParentWindow(m_private->m_fullScreenWindow->hwnd());
-
- IntRect viewFrame(IntPoint(), m_private->m_fullScreenFrame.size());
- ::SetWindowPos(m_private->m_fullScreenWindow->hwnd(), HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
- ::SetWindowPos(m_private->m_client->fullScreenClientWindow(), HWND_TOP, 0, 0, viewFrame.width(), viewFrame.height(), SWP_NOACTIVATE);
-
- m_private->m_client->fullScreenClientDidEnterFullScreen();
- m_private->m_client->fullScreenClientForceRepaint();
-}
-
-void FullScreenController::enterFullScreenRepaintCompleted()
-{
- if (!m_private->m_isEnteringFullScreen)
- return;
- m_private->m_isEnteringFullScreen = false;
-
- // Normally, when the background fullscreen window is animated in, the Windows taskbar will be hidden, but this doesn't always work for some reason.
- // Setting the real fullscreen window to be a topmost window will force the taskbar to be hidden when we call AnimateWindow() below if it wasn't before.
- ::SetWindowPos(m_private->m_fullScreenWindow->hwnd(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
- ::AnimateWindow(m_private->m_fullScreenWindow->hwnd(), kFullScreenAnimationDuration, AW_BLEND | AW_ACTIVATE);
-}
-
-void FullScreenController::exitFullScreen()
-{
- if (!m_private->m_isFullScreen || m_private->m_isExitingFullScreen)
- return;
- m_private->m_isFullScreen = false;
- m_private->m_isExitingFullScreen = true;
-
- ::AnimateWindow(m_private->m_fullScreenWindow->hwnd(), kFullScreenAnimationDuration, AW_HIDE | AW_BLEND);
-
- m_private->m_client->fullScreenClientWillExitFullScreen();
- m_private->m_client->fullScreenClientSetParentWindow(m_private->m_originalHost);
- m_private->m_fullScreenWindow = nullptr;
-
- ::SetWindowPos(m_private->m_client->fullScreenClientWindow(), 0, m_private->m_originalFrame.x(), m_private->m_originalFrame.y(), m_private->m_originalFrame.width(), m_private->m_originalFrame.height(), SWP_NOACTIVATE | SWP_NOZORDER);
-
- m_private->m_client->fullScreenClientDidExitFullScreen();
- m_private->m_client->fullScreenClientForceRepaint();
-}
-
-void FullScreenController::exitFullScreenRepaintCompleted()
-{
- if (!m_private->m_isExitingFullScreen)
- return;
- m_private->m_isExitingFullScreen = false;
-
- ASSERT(m_private->m_backgroundWindow);
- ::AnimateWindow(m_private->m_backgroundWindow->hwnd(), kFullScreenAnimationDuration, AW_HIDE | AW_BLEND);
- m_private->m_backgroundWindow = nullptr;
-}
-
-void FullScreenController::repaintCompleted()
-{
- if (m_private->m_isEnteringFullScreen)
- enterFullScreenRepaintCompleted();
- else if (m_private->m_isExitingFullScreen)
- exitFullScreenRepaintCompleted();
-}
-
-void FullScreenController::close()
-{
- if (!m_private->m_isFullScreen)
- return;
- m_private->m_isFullScreen = false;
-
- m_private->m_client->fullScreenClientWillExitFullScreen();
- m_private->m_client->fullScreenClientSetParentWindow(m_private->m_originalHost);
- m_private->m_fullScreenWindow = nullptr;
-
- m_private->m_client->fullScreenClientDidExitFullScreen();
- ::SetWindowPos(m_private->m_client->fullScreenClientWindow(), 0, m_private->m_originalFrame.x(), m_private->m_originalFrame.y(), m_private->m_originalFrame.width(), m_private->m_originalFrame.height(), SWP_NOACTIVATE | SWP_NOZORDER);
- ::RedrawWindow(m_private->m_client->fullScreenClientWindow(), 0, 0, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE | RDW_ALLCHILDREN);
- m_private->m_backgroundWindow = nullptr;
-}
-#endif
diff --git a/Source/WebCore/platform/graphics/win/FullScreenController.h b/Source/WebCore/platform/graphics/win/FullScreenController.h
deleted file mode 100644
index b6846d9..0000000
--- a/Source/WebCore/platform/graphics/win/FullScreenController.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2011 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 WebFullScreenController_h
-#define WebFullScreenController_h
-
-#if ENABLE(FULLSCREEN_API)
-
-#include <wtf/OwnPtr.h>
-
-namespace WebCore {
-
-class FullScreenControllerClient;
-
-class FullScreenController {
-public:
- FullScreenController(FullScreenControllerClient*);
- ~FullScreenController();
-
-public:
- void enterFullScreen();
- void exitFullScreen();
- void repaintCompleted();
-
- bool isFullScreen() const;
-
- void close();
-
-protected:
- void enterFullScreenRepaintCompleted();
- void exitFullScreenRepaintCompleted();
-
- class Private;
- friend class Private;
- OwnPtr<FullScreenController::Private> m_private;
-};
-
-}
-
-#endif
-
-#endif
diff --git a/Source/WebCore/platform/graphics/win/FullScreenControllerClient.h b/Source/WebCore/platform/graphics/win/FullScreenControllerClient.h
deleted file mode 100644
index 3acf9cf..0000000
--- a/Source/WebCore/platform/graphics/win/FullScreenControllerClient.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2011 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 FullScreenControllerClient_h
-#define FullScreenControllerClient_h
-
-#if ENABLE(FULLSCREEN_API)
-
-namespace WebCore {
-
-class FullScreenControllerClient {
-public:
- virtual HWND fullScreenClientWindow() const = 0;
- virtual HWND fullScreenClientParentWindow() const = 0;
- virtual void fullScreenClientSetParentWindow(HWND) = 0;
- virtual void fullScreenClientWillEnterFullScreen() = 0;
- virtual void fullScreenClientDidEnterFullScreen() = 0;
- virtual void fullScreenClientWillExitFullScreen() = 0;
- virtual void fullScreenClientDidExitFullScreen() = 0;
- virtual void fullScreenClientForceRepaint() = 0;
-protected:
- virtual ~FullScreenControllerClient() { }
-};
-
-}
-
-#endif
-
-#endif
diff --git a/Source/WebCore/platform/graphics/win/GDIExtras.cpp b/Source/WebCore/platform/graphics/win/GDIExtras.cpp
deleted file mode 100644
index 4bd95da..0000000
--- a/Source/WebCore/platform/graphics/win/GDIExtras.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.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 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 "GDIExtras.h"
-
-#include "SoftLinking.h"
-
-namespace WebCore {
-
-#if OS(WINCE)
-SOFT_LINK_LIBRARY(coredll)
-SOFT_LINK_OPTIONAL(coredll, AlphaBlend, BOOL, APIENTRY, (HDC hdcDest, int nXOriginDest, int nYOriginDest, int nWidthDest, int nHeightDest, HDC hdcSrc,
- int nXOriginSrc, int nYOriginSrc, int nWidthSrc, int nHeightSrc, BLENDFUNCTION blendFunction))
-
-AlphaBlendPointerType AlphaBlendPointer()
-{
- return AlphaBlendPtr();
-}
-#endif
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/win/GDIExtras.h b/Source/WebCore/platform/graphics/win/GDIExtras.h
deleted file mode 100644
index 0166124..0000000
--- a/Source/WebCore/platform/graphics/win/GDIExtras.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.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 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 GDIExtras_h
-#define GDIExtras_h
-
-#include <windows.h>
-
-namespace WebCore {
-
-typedef BOOL (APIENTRY *AlphaBlendPointerType) (HDC hdcDest, int nXOriginDest, int nYOriginDest, int nWidthDest, int nHeightDest, HDC hdcSrc,
- int nXOriginSrc, int nYOriginSrc, int nWidthSrc, int nHeightSrc, BLENDFUNCTION blendFunction);
-
-#if OS(WINCE)
-AlphaBlendPointerType AlphaBlendPointer();
-#endif
-
-inline bool hasAlphaBlendSupport()
-{
-#if OS(WINCE)
- return AlphaBlendPointer();
-#else
- return true;
-#endif
-}
-
-inline bool alphaBlendIfSupported(HDC hdcDest, int nXOriginDest, int nYOriginDest, int nWidthDest, int nHeightDest, HDC hdcSrc,
- int nXOriginSrc, int nYOriginSrc, int nWidthSrc, int nHeightSrc, BLENDFUNCTION blendFunction)
-{
-#if OS(WINCE)
- AlphaBlendPointerType alphaBlendPointer = AlphaBlendPointer();
- if (!alphaBlendPointer)
- return false;
-
- alphaBlendPointer(hdcDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, hdcSrc, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc, blendFunction);
-#else
- AlphaBlend(hdcDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, hdcSrc, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc, blendFunction);
-#endif
- return true;
-}
-
-} // namespace WebCore
-
-#endif // GDIExtras_h
diff --git a/Source/WebCore/platform/graphics/win/GlyphPageTreeNodeCGWin.cpp b/Source/WebCore/platform/graphics/win/GlyphPageTreeNodeCGWin.cpp
deleted file mode 100644
index c11fc1b..0000000
--- a/Source/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/Source/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp b/Source/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp
deleted file mode 100644
index 063f7cb..0000000
--- a/Source/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2010 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 "GraphicsContextCG.h"
-
-#include "AffineTransform.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));
-
- DIBPixelData pixelData(bitmap);
-
- // FIXME: We can get here because we asked for a bitmap that is too big
- // when we have a tiled layer and we're compositing. In that case
- // bmBitsPixel will be 0. This seems to be benign, so for now we will
- // exit gracefully and look at it later:
- // https://bugs.webkit.org/show_bug.cgi?id=52041
- // ASSERT(bitmapBits.bitsPerPixel() == 32);
- if (pixelData.bitsPerPixel() != 32)
- return 0;
-
- CGBitmapInfo bitmapInfo = kCGBitmapByteOrder32Little | (hasAlpha ? kCGImageAlphaPremultipliedFirst : kCGImageAlphaNoneSkipFirst);
- CGContextRef context = CGBitmapContextCreate(pixelData.buffer(), pixelData.size().width(), pixelData.size().height(), 8,
- pixelData.bytesPerRow(), deviceRGBColorSpaceRef(), bitmapInfo);
-
- // Flip coords
- CGContextTranslateCTM(context, 0, pixelData.size().height());
- 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_updatingControlTints(false),
- m_transparencyCount(0)
-{
- platformInit(hdc, hasAlpha);
-}
-
-void GraphicsContext::platformInit(HDC hdc, bool hasAlpha)
-{
- m_data = new GraphicsContextPlatformPrivate(CGContextWithHDC(hdc, hasAlpha));
- CGContextRelease(m_data->m_cgContext.get());
- 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(), ColorSpaceDeviceRGB);
- setPlatformStrokeColor(strokeColor(), ColorSpaceDeviceRGB);
- }
-}
-
-// FIXME: Is it possible to merge getWindowsContext and createWindowsBitmap into a single API
-// suitable for all clients?
-void GraphicsContext::releaseWindowsContext(HDC hdc, const IntRect& dstRect, bool supportAlphaBlend, bool mayCreateBitmap)
-{
- bool createdBitmap = mayCreateBitmap && (!m_data->m_hdc || isInTransparencyLayer());
- if (!createdBitmap) {
- m_data->restore();
- return;
- }
-
- if (dstRect.isEmpty())
- return;
-
- OwnPtr<HBITMAP> bitmap = adoptPtr(static_cast<HBITMAP>(GetCurrentObject(hdc, OBJ_BITMAP)));
-
- DIBPixelData pixelData(bitmap.get());
-
- ASSERT(pixelData.bitsPerPixel() == 32);
-
- CGContextRef bitmapContext = CGBitmapContextCreate(pixelData.buffer(), pixelData.size().width(), pixelData.size().height(), 8,
- pixelData.bytesPerRow(), deviceRGBColorSpaceRef(), kCGBitmapByteOrder32Little |
- (supportAlphaBlend ? kCGImageAlphaPremultipliedFirst : kCGImageAlphaNoneSkipFirst));
-
- CGImageRef image = CGBitmapContextCreateImage(bitmapContext);
- CGContextDrawImage(m_data->m_cgContext.get(), dstRect, image);
-
- // Delete all our junk.
- CGImageRelease(image);
- CGContextRelease(bitmapContext);
- ::DeleteDC(hdc);
-}
-
-void GraphicsContext::drawWindowsBitmap(WindowsBitmap* image, const IntPoint& point)
-{
- // FIXME: Creating CFData is non-optimal, but needed to avoid crashing when printing. Ideally we should
- // make a custom CGDataProvider that controls the WindowsBitmap lifetime. see <rdar://6394455>
- RetainPtr<CFDataRef> imageData(AdoptCF, CFDataCreate(kCFAllocatorDefault, image->buffer(), image->bufferLength()));
- RetainPtr<CGDataProviderRef> dataProvider(AdoptCF, CGDataProviderCreateWithCFData(imageData.get()));
- RetainPtr<CGImageRef> cgImage(AdoptCF, CGImageCreate(image->size().width(), image->size().height(), 8, 32, image->bytesPerRow(), deviceRGBColorSpaceRef(),
- kCGBitmapByteOrder32Little | kCGImageAlphaFirst, dataProvider.get(), 0, true, kCGRenderingIntentDefault));
- CGContextDrawImage(m_data->m_cgContext.get(), CGRectMake(point.x(), point.y(), image->size().width(), image->size().height()), cgImage.get());
-}
-
-void GraphicsContext::drawFocusRing(const Path& path, int width, int offset, const Color& color)
-{
- // FIXME: implement
-}
-
-// FIXME: This is nearly identical to the GraphicsContext::drawFocusRing function in GraphicsContextMac.mm.
-// The code could move to GraphicsContextCG.cpp and be shared.
-void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int width, int offset, const Color& color)
-{
- if (paintingDisabled())
- return;
-
- float radius = (width - 1) / 2.0f;
- offset += radius;
- CGColorRef colorRef = color.isValid() ? cachedCGColor(color, ColorSpaceDeviceRGB) : 0;
-
- CGMutablePathRef focusRingPath = CGPathCreateMutable();
- 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);
-
- 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::drawLineForDocumentMarker(const FloatPoint& point, float width, DocumentMarkerLineStyle style)
-{
- if (paintingDisabled())
- return;
-
- if (style != DocumentMarkerSpellingLineStyle && style != DocumentMarkerGrammarLineStyle)
- 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
- float widthMod = fmodf(width, patternWidth);
- if (patternWidth - widthMod > cMisspellingLinePatternGapWidth)
- width -= widthMod;
-
- // Draw the underline
- CGContextRef context = platformContext();
- CGContextSaveGState(context);
-
- const Color& patternColor = style == DocumentMarkerGrammarLineStyle ? 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, WTF_ARRAY_LENGTH(edge_dash_lengths));
- CGContextSetAlpha(context, upperOpacity);
- CGContextStrokeLineSegments(context, upperPoints, 2);
-
- // Middle line
- CGContextSetLineDash(context, middle_offset, middle_dash_lengths, WTF_ARRAY_LENGTH(middle_dash_lengths));
- CGContextSetAlpha(context, middleOpacity);
- CGContextStrokeLineSegments(context, middlePoints, 2);
-
- // Bottom line
- CGContextSetLineDash(context, edge_offset, edge_dash_lengths, WTF_ARRAY_LENGTH(edge_dash_lengths));
- CGContextSetAlpha(context, lowerOpacity);
- CGContextStrokeLineSegments(context, lowerPoints, 2);
-
- CGContextRestoreGState(context);
-}
-
-void GraphicsContextPlatformPrivate::flush()
-{
- CGContextFlush(m_cgContext.get());
-}
-
-}
diff --git a/Source/WebCore/platform/graphics/win/GraphicsContextWin.cpp b/Source/WebCore/platform/graphics/win/GraphicsContextWin.cpp
deleted file mode 100644
index bd7e8d8..0000000
--- a/Source/WebCore/platform/graphics/win/GraphicsContextWin.cpp
+++ /dev/null
@@ -1,204 +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 "BitmapInfo.h"
-#include "TransformationMatrix.h"
-#include "NotImplemented.h"
-#include "Path.h"
-#include <wtf/MathExtras.h>
-
-using namespace std;
-
-namespace WebCore {
-
-static void fillWithClearColor(HBITMAP bitmap)
-{
- BITMAP bmpInfo;
- GetObject(bitmap, sizeof(bmpInfo), &bmpInfo);
- int bufferSize = bmpInfo.bmWidthBytes * bmpInfo.bmHeight;
- memset(bmpInfo.bmBits, 0, bufferSize);
-}
-
-#if PLATFORM(WIN)
-void GraphicsContext::setShouldIncludeChildWindows(bool include)
-{
- m_data->m_shouldIncludeChildWindows = include;
-}
-
-bool GraphicsContext::shouldIncludeChildWindows() const
-{
- return m_data->m_shouldIncludeChildWindows;
-}
-
-GraphicsContext::WindowsBitmap::WindowsBitmap(HDC hdc, const IntSize& size)
- : m_hdc(0)
-{
- BitmapInfo bitmapInfo = BitmapInfo::create(size);
-
- void* storage = 0;
- m_bitmap = CreateDIBSection(0, &bitmapInfo, DIB_RGB_COLORS, &storage, 0, 0);
- if (!m_bitmap)
- return;
-
- m_hdc = CreateCompatibleDC(hdc);
- SelectObject(m_hdc, m_bitmap);
-
- m_pixelData.initialize(m_bitmap);
-
- ASSERT(storage == m_pixelData.buffer());
-
- SetGraphicsMode(m_hdc, GM_ADVANCED);
-}
-
-GraphicsContext::WindowsBitmap::~WindowsBitmap()
-{
- if (!m_bitmap)
- return;
-
- DeleteDC(m_hdc);
- DeleteObject(m_bitmap);
-}
-
-PassOwnPtr<GraphicsContext::WindowsBitmap> GraphicsContext::createWindowsBitmap(const IntSize& size)
-{
- return adoptPtr(new WindowsBitmap(m_data->m_hdc, size));
-}
-#endif
-
-HDC GraphicsContext::getWindowsContext(const IntRect& dstRect, bool supportAlphaBlend, bool mayCreateBitmap)
-{
- // FIXME: Should a bitmap be created also when a shadow is set?
- if (mayCreateBitmap && (!m_data->m_hdc || isInTransparencyLayer())) {
- if (dstRect.isEmpty())
- return 0;
-
- // Create a bitmap DC in which to draw.
- BitmapInfo bitmapInfo = BitmapInfo::create(dstRect.size());
-
- 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)
- fillWithClearColor(bitmap);
-
- // 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 = TransformationMatrix().translate(-dstRect.x(), -dstRect.y());
-
- ::SetWorldTransform(bitmapDC, &xform);
-
- return bitmapDC;
- }
-
- m_data->flush();
- m_data->save();
- return m_data->m_hdc;
-}
-
-#if PLATFORM(WIN)
-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.maxX(), clipRect.maxY());
-}
-
-void GraphicsContextPlatformPrivate::clip(const Path&)
-{
- notImplemented();
-}
-
-void GraphicsContextPlatformPrivate::scale(const FloatSize& size)
-{
- if (!m_hdc)
- return;
-
- XFORM xform = TransformationMatrix().scaleNonUniform(size.width(), size.height());
- ModifyWorldTransform(m_hdc, &xform, MWT_LEFTMULTIPLY);
-}
-
-static const double deg2rad = 0.017453292519943295769; // pi/180
-
-void GraphicsContextPlatformPrivate::rotate(float degreesAngle)
-{
- XFORM xform = TransformationMatrix().rotate(degreesAngle);
- ModifyWorldTransform(m_hdc, &xform, MWT_LEFTMULTIPLY);
-}
-
-void GraphicsContextPlatformPrivate::translate(float x , float y)
-{
- if (!m_hdc)
- return;
-
- XFORM xform = TransformationMatrix().translate(x, y);
- ModifyWorldTransform(m_hdc, &xform, MWT_LEFTMULTIPLY);
-}
-
-void GraphicsContextPlatformPrivate::concatCTM(const AffineTransform& transform)
-{
- if (!m_hdc)
- return;
-
- XFORM xform = transform.toTransformationMatrix();
- ModifyWorldTransform(m_hdc, &xform, MWT_LEFTMULTIPLY);
-}
-
-void GraphicsContextPlatformPrivate::setCTM(const AffineTransform& transform)
-{
- if (!m_hdc)
- return;
-
- XFORM xform = transform.toTransformationMatrix();
- SetWorldTransform(m_hdc, &xform);
-}
-#endif
-
-}
diff --git a/Source/WebCore/platform/graphics/win/IconWin.cpp b/Source/WebCore/platform/graphics/win/IconWin.cpp
deleted file mode 100644
index cb7ddb7..0000000
--- a/Source/WebCore/platform/graphics/win/IconWin.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
-* Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
-* Copyright (C) 2007-2009 Torch Mobile, 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 "Icon.h"
-
-#include "GraphicsContext.h"
-#include "LocalWindowsContext.h"
-#include <windows.h>
-#include <wtf/text/WTFString.h>
-
-#if OS(WINCE)
-// SHGFI_SHELLICONSIZE is not available on WINCE
-#define SHGFI_SHELLICONSIZE 0
-#endif
-
-namespace WebCore {
-
-static const int shell32MultipleFileIconIndex = 54;
-
-Icon::Icon(HICON icon)
- : m_hIcon(icon)
-{
- ASSERT(icon);
-}
-
-Icon::~Icon()
-{
- DestroyIcon(m_hIcon);
-}
-
-// FIXME: Move the code to ChromeClient::iconForFiles().
-PassRefPtr<Icon> Icon::createIconForFiles(const Vector<String>& filenames)
-{
- if (filenames.isEmpty())
- return 0;
-
- if (filenames.size() == 1) {
- SHFILEINFO sfi;
- memset(&sfi, 0, sizeof(sfi));
-
- String tmpFilename = filenames[0];
- if (!SHGetFileInfo(tmpFilename.charactersWithNullTermination(), 0, &sfi, sizeof(sfi), SHGFI_ICON | SHGFI_SHELLICONSIZE | SHGFI_SMALLICON))
- return 0;
-
- return adoptRef(new Icon(sfi.hIcon));
- }
-
-#if OS(WINCE)
- return 0;
-#else
- WCHAR buffer[MAX_PATH];
- UINT length = ::GetSystemDirectoryW(buffer, WTF_ARRAY_LENGTH(buffer));
- if (!length)
- return 0;
-
- if (wcscat_s(buffer, L"\\shell32.dll"))
- return 0;
-
- HICON hIcon;
- if (!::ExtractIconExW(buffer, shell32MultipleFileIconIndex, 0, &hIcon, 1))
- return 0;
- return adoptRef(new Icon(hIcon));
-#endif
-}
-
-void Icon::paint(GraphicsContext* context, const IntRect& r)
-{
- if (context->paintingDisabled())
- return;
-
-#if OS(WINCE)
- context->drawIcon(m_hIcon, r, DI_NORMAL);
-#else
- LocalWindowsContext windowContext(context, r);
- DrawIconEx(windowContext.hdc(), r.x(), r.y(), m_hIcon, r.width(), r.height(), 0, 0, DI_NORMAL);
-#endif
-}
-
-}
diff --git a/Source/WebCore/platform/graphics/win/ImageCGWin.cpp b/Source/WebCore/platform/graphics/win/ImageCGWin.cpp
deleted file mode 100644
index 8007511..0000000
--- a/Source/WebCore/platform/graphics/win/ImageCGWin.cpp
+++ /dev/null
@@ -1,108 +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 "BitmapInfo.h"
-#include "GraphicsContextCG.h"
-#include <ApplicationServices/ApplicationServices.h>
-#include <windows.h>
-#include <wtf/RetainPtr.h>
-#include <wtf/text/WTFString.h>
-
-namespace WebCore {
-
-PassRefPtr<BitmapImage> BitmapImage::create(HBITMAP hBitmap)
-{
- DIBSECTION dibSection;
- if (!GetObject(hBitmap, sizeof(DIBSECTION), &dibSection))
- return 0;
-
- ASSERT(dibSection.dsBm.bmBitsPixel == 32);
- if (dibSection.dsBm.bmBitsPixel != 32)
- return 0;
-
- ASSERT(dibSection.dsBm.bmBits);
- if (!dibSection.dsBm.bmBits)
- return 0;
-
- RetainPtr<CGContextRef> bitmapContext(AdoptCF, CGBitmapContextCreate(dibSection.dsBm.bmBits, dibSection.dsBm.bmWidth, dibSection.dsBm.bmHeight, 8,
- dibSection.dsBm.bmWidthBytes, deviceRGBColorSpaceRef(), kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst));
-
- // The BitmapImage takes ownership of this.
- CGImageRef cgImage = CGBitmapContextCreateImage(bitmapContext.get());
-
- return adoptRef(new BitmapImage(cgImage));
-}
-
-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;
-
- CGContextRef cgContext = CGBitmapContextCreate(bmpInfo.bmBits, bmpInfo.bmWidth, bmpInfo.bmHeight,
- 8, bmpInfo.bmWidthBytes, deviceRGBColorSpaceRef(), kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst);
-
- GraphicsContext gc(cgContext);
-
- IntSize imageSize = BitmapImage::size();
- if (size)
- drawFrameMatchingSourceSize(&gc, FloatRect(0.0f, 0.0f, bmpInfo.bmWidth, bmpInfo.bmHeight), IntSize(*size), ColorSpaceDeviceRGB, CompositeCopy);
- else
- draw(&gc, FloatRect(0.0f, 0.0f, bmpInfo.bmWidth, bmpInfo.bmHeight), FloatRect(0.0f, 0.0f, imageSize.width(), imageSize.height()), ColorSpaceDeviceRGB, CompositeCopy, BlendModeNormal);
-
- // Do cleanup
- CGContextRelease(cgContext);
-
- return true;
-}
-
-void BitmapImage::drawFrameMatchingSourceSize(GraphicsContext* ctxt, const FloatRect& dstRect, const IntSize& srcSize, ColorSpace styleColorSpace, CompositeOperator compositeOp)
-{
- size_t frames = frameCount();
- for (size_t i = 0; i < frames; ++i) {
- CGImageRef image = frameAtIndex(i);
- if (image && 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()), styleColorSpace, compositeOp, BlendModeNormal);
- 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()), styleColorSpace, compositeOp, BlendModeNormal);
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/win/ImageWin.cpp b/Source/WebCore/platform/graphics/win/ImageWin.cpp
deleted file mode 100644
index 03de163..0000000
--- a/Source/WebCore/platform/graphics/win/ImageWin.cpp
+++ /dev/null
@@ -1,54 +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::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/Source/WebCore/platform/graphics/win/IntPointWin.cpp b/Source/WebCore/platform/graphics/win/IntPointWin.cpp
deleted file mode 100644
index 73db199..0000000
--- a/Source/WebCore/platform/graphics/win/IntPointWin.cpp
+++ /dev/null
@@ -1,57 +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 "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/Source/WebCore/platform/graphics/win/IntRectWin.cpp b/Source/WebCore/platform/graphics/win/IntRectWin.cpp
deleted file mode 100644
index 6af6735..0000000
--- a/Source/WebCore/platform/graphics/win/IntRectWin.cpp
+++ /dev/null
@@ -1,45 +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 "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(), maxX(), maxY() };
- return rect;
-}
-
-}
diff --git a/Source/WebCore/platform/graphics/win/IntSizeWin.cpp b/Source/WebCore/platform/graphics/win/IntSizeWin.cpp
deleted file mode 100644
index 26e68da..0000000
--- a/Source/WebCore/platform/graphics/win/IntSizeWin.cpp
+++ /dev/null
@@ -1,45 +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 "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/Source/WebCore/platform/graphics/win/LocalWindowsContext.h b/Source/WebCore/platform/graphics/win/LocalWindowsContext.h
deleted file mode 100644
index 5951e49..0000000
--- a/Source/WebCore/platform/graphics/win/LocalWindowsContext.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2010 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 LocalWindowsContext_h
-#define LocalWindowsContext_h
-
-#include "config.h"
-#include "GraphicsContext.h"
-
-namespace WebCore {
-
-class LocalWindowsContext {
- WTF_MAKE_NONCOPYABLE(LocalWindowsContext);
-public:
- LocalWindowsContext(GraphicsContext* graphicsContext, const IntRect& rect, bool supportAlphaBlend = true, bool mayCreateBitmap = true)
- : m_graphicsContext(graphicsContext)
- , m_rect(rect)
- , m_supportAlphaBlend(supportAlphaBlend)
- , m_mayCreateBitmap(mayCreateBitmap)
- {
- m_hdc = m_graphicsContext->getWindowsContext(m_rect, m_supportAlphaBlend, m_mayCreateBitmap);
- }
-
- ~LocalWindowsContext()
- {
- m_graphicsContext->releaseWindowsContext(m_hdc, m_rect, m_supportAlphaBlend, m_mayCreateBitmap);
- }
-
- HDC hdc() const { return m_hdc; }
-
-private:
- GraphicsContext* m_graphicsContext;
- HDC m_hdc;
- IntRect m_rect;
- bool m_supportAlphaBlend;
- bool m_mayCreateBitmap;
-};
-
-} // namespace WebCore
-#endif // LocalWindowsContext_h
diff --git a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp b/Source/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp
deleted file mode 100644
index 6914aef..0000000
--- a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.cpp
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * Copyright (C) 2010 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. 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 INC. 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 "MediaPlayerPrivateFullscreenWindow.h"
-
-#include "IntRect.h"
-#include "WebCoreInstanceHandle.h"
-#include <windows.h>
-
-#if USE(ACCELERATED_COMPOSITING)
-#include "CACFLayerTreeHost.h"
-#include "PlatformCALayer.h"
-#endif
-
-namespace WebCore {
-
-MediaPlayerPrivateFullscreenWindow::MediaPlayerPrivateFullscreenWindow(MediaPlayerPrivateFullscreenClient* client)
- : m_client(client)
- , m_hwnd(0)
-{
-}
-
-MediaPlayerPrivateFullscreenWindow::~MediaPlayerPrivateFullscreenWindow()
-{
- if (!m_hwnd)
- return;
-
- ::DestroyWindow(m_hwnd);
- ASSERT(!m_hwnd);
-}
-
-void MediaPlayerPrivateFullscreenWindow::createWindow(HWND parentHwnd)
-{
- static ATOM windowAtom;
- static LPCWSTR windowClassName = L"MediaPlayerPrivateFullscreenWindowClass";
- if (!windowAtom) {
- WNDCLASSEX wcex = {0};
- wcex.cbSize = sizeof(WNDCLASSEX);
- wcex.style = CS_HREDRAW | CS_VREDRAW;
- wcex.lpfnWndProc = staticWndProc;
- wcex.hInstance = instanceHandle();
- wcex.lpszClassName = windowClassName;
- windowAtom = ::RegisterClassEx(&wcex);
- }
-
- ASSERT(!m_hwnd);
-
- MONITORINFO mi = {0};
- mi.cbSize = sizeof(MONITORINFO);
- if (!GetMonitorInfo(MonitorFromWindow(parentHwnd, MONITOR_DEFAULTTONEAREST), &mi))
- return;
-
- IntRect monitorRect = mi.rcMonitor;
-
- ::CreateWindowExW(WS_EX_TOOLWINDOW, windowClassName, L"", WS_POPUP,
- monitorRect.x(), monitorRect.y(), monitorRect.width(), monitorRect.height(),
- parentHwnd, 0, WebCore::instanceHandle(), this);
- ASSERT(IsWindow(m_hwnd));
-
-#if USE(ACCELERATED_COMPOSITING)
- if (m_layerTreeHost)
- m_layerTreeHost->setWindow(m_hwnd);
-#endif
-
- ::SetFocus(m_hwnd);
-}
-
-#if USE(ACCELERATED_COMPOSITING)
-void MediaPlayerPrivateFullscreenWindow::setRootChildLayer(PassRefPtr<PlatformCALayer> rootChild)
-{
- if (m_rootChild == rootChild)
- return;
-
- if (m_rootChild)
- m_rootChild->removeFromSuperlayer();
-
- m_rootChild = rootChild;
-
- if (!m_rootChild) {
- m_layerTreeHost = nullptr;
- return;
- }
-
- if (!m_layerTreeHost) {
- m_layerTreeHost = CACFLayerTreeHost::create();
- if (m_hwnd)
- m_layerTreeHost->setWindow(m_hwnd);
- }
-
- m_layerTreeHost->setRootChildLayer(m_rootChild.get());
- PlatformCALayer* rootLayer = m_rootChild->rootLayer();
- CGRect rootBounds = m_rootChild->rootLayer()->bounds();
- m_rootChild->setFrame(rootBounds);
- m_rootChild->setBackgroundColor(CGColorGetConstantColor(kCGColorBlack));
-#ifndef NDEBUG
- RetainPtr<CGColorRef> redColor(AdoptCF, CGColorCreateGenericRGB(1, 0, 0, 1));
- rootLayer->setBackgroundColor(redColor.get());
-#else
- rootLayer->setBackgroundColor(CGColorGetConstantColor(kCGColorBlack));
-#endif
-}
-#endif
-
-LRESULT MediaPlayerPrivateFullscreenWindow::staticWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
- LONG_PTR longPtr = GetWindowLongPtr(hWnd, GWLP_USERDATA);
-
- if (!longPtr && message == WM_CREATE) {
- LPCREATESTRUCT lpcs = reinterpret_cast<LPCREATESTRUCT>(lParam);
- longPtr = reinterpret_cast<LONG_PTR>(lpcs->lpCreateParams);
- ::SetWindowLongPtr(hWnd, GWLP_USERDATA, longPtr);
- }
-
- if (MediaPlayerPrivateFullscreenWindow* window = reinterpret_cast<MediaPlayerPrivateFullscreenWindow*>(longPtr))
- return window->wndProc(hWnd, message, wParam, lParam);
-
- return ::DefWindowProc(hWnd, message, wParam, lParam);
-}
-
-LRESULT MediaPlayerPrivateFullscreenWindow::wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
- LRESULT lResult = 0;
- switch (message) {
- case WM_CREATE:
- m_hwnd = hWnd;
- break;
- case WM_DESTROY:
- m_hwnd = 0;
-#if USE(ACCELERATED_COMPOSITING)
- if (m_layerTreeHost)
- m_layerTreeHost->setWindow(0);
-#endif
- break;
- case WM_WINDOWPOSCHANGED:
- {
- LPWINDOWPOS wp = reinterpret_cast<LPWINDOWPOS>(lParam);
- if (wp->flags & SWP_NOSIZE)
- break;
-#if USE(ACCELERATED_COMPOSITING)
- if (m_layerTreeHost) {
- m_layerTreeHost->resize();
- PlatformCALayer* rootLayer = m_rootChild->rootLayer();
- CGRect rootBounds = m_rootChild->rootLayer()->bounds();
- m_rootChild->setFrame(rootBounds);
- m_rootChild->setNeedsLayout();
- }
-#endif
- }
- break;
- case WM_PAINT:
-#if USE(ACCELERATED_COMPOSITING)
- if (m_layerTreeHost) {
- m_layerTreeHost->paint();
- ::ValidateRect(m_hwnd, 0);
- } else
-#endif
- {
- PAINTSTRUCT ps;
- HDC hdc = ::BeginPaint(m_hwnd, &ps);
- ::FillRect(hdc, &ps.rcPaint, (HBRUSH)::GetStockObject(BLACK_BRUSH));
- ::EndPaint(m_hwnd, &ps);
- }
- break;
- case WM_PRINTCLIENT:
- {
- RECT clientRect;
- HDC context = (HDC)wParam;
- ::GetClientRect(m_hwnd, &clientRect);
- ::FillRect(context, &clientRect, (HBRUSH)::GetStockObject(BLACK_BRUSH));
- }
- }
- if (m_client)
- lResult = m_client->fullscreenClientWndProc(hWnd, message, wParam, lParam);
-
- return lResult;
-}
-
-}
diff --git a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.h b/Source/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.h
deleted file mode 100644
index 2622fba..0000000
--- a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateFullscreenWindow.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2010 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. 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 INC. 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 MediaPlayerPrivateFullscreenWindow_h
-#define MediaPlayerPrivateFullscreenWindow_h
-
-#if OS(WINDOWS)
-#include "WindowsExtras.h"
-#endif
-#include <wtf/RefPtr.h>
-
-#if USE(ACCELERATED_COMPOSITING)
-#include "CACFLayerTreeHostClient.h"
-#endif
-
-namespace WebCore {
-
-#if USE(ACCELERATED_COMPOSITING)
-class CACFLayerTreeHost;
-class PlatformCALayer;
-#endif
-
-class MediaPlayerPrivateFullscreenClient {
-public:
- virtual LRESULT fullscreenClientWndProc(HWND, UINT message, WPARAM, LPARAM) = 0;
-protected:
- virtual ~MediaPlayerPrivateFullscreenClient() {}
-};
-
-class MediaPlayerPrivateFullscreenWindow {
-public:
- MediaPlayerPrivateFullscreenWindow(MediaPlayerPrivateFullscreenClient*);
- ~MediaPlayerPrivateFullscreenWindow();
-
- void createWindow(HWND ownerWindow);
-
- HWND hwnd() const { return m_hwnd; }
-
-#if USE(ACCELERATED_COMPOSITING)
- PlatformCALayer* rootChildLayer() const { return m_rootChild.get(); }
- void setRootChildLayer(PassRefPtr<PlatformCALayer>);
-#endif
-
-private:
- static LRESULT __stdcall staticWndProc(HWND, UINT message, WPARAM, LPARAM);
- LRESULT wndProc(HWND, UINT message, WPARAM, LPARAM);
-
- MediaPlayerPrivateFullscreenClient* m_client;
-#if USE(ACCELERATED_COMPOSITING)
- RefPtr<CACFLayerTreeHost> m_layerTreeHost;
- RefPtr<PlatformCALayer> m_rootChild;
-#endif
- HWND m_hwnd;
-};
-
-}
-
-#endif
diff --git a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp b/Source/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp
deleted file mode 100644
index df18473..0000000
--- a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp
+++ /dev/null
@@ -1,1268 +0,0 @@
-/*
- * Copyright (C) 2007, 2008, 2009, 2010, 2011 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 "MediaPlayerPrivateQuickTimeVisualContext.h"
-
-#include "Cookie.h"
-#include "CookieJar.h"
-#include "DocumentLoader.h"
-#include "Frame.h"
-#include "FrameView.h"
-#include "GraphicsContext.h"
-#include "KURL.h"
-#include "MediaPlayerPrivateTaskTimer.h"
-#include "Page.h"
-#include "QTCFDictionary.h"
-#include "QTDecompressionSession.h"
-#include "QTMovie.h"
-#include "QTMovieTask.h"
-#include "QTMovieVisualContext.h"
-#include "ScrollView.h"
-#include "Settings.h"
-#include "SoftLinking.h"
-#include "TimeRanges.h"
-#include "Timer.h"
-#include <AssertMacros.h>
-#include <CoreGraphics/CGAffineTransform.h>
-#include <CoreGraphics/CGContext.h>
-#include <QuartzCore/CATransform3D.h>
-#include <Wininet.h>
-#include <wtf/CurrentTime.h>
-#include <wtf/HashSet.h>
-#include <wtf/MainThread.h>
-#include <wtf/MathExtras.h>
-#include <wtf/StdLibExtras.h>
-#include <wtf/text/StringBuilder.h>
-#include <wtf/text/StringHash.h>
-
-#if USE(ACCELERATED_COMPOSITING)
-#include "PlatformCALayer.h"
-#include "WKCAImageQueue.h"
-#endif
-
-using namespace std;
-
-namespace WebCore {
-
-static CGImageRef CreateCGImageFromPixelBuffer(QTPixelBuffer buffer);
-static bool requiredDllsAvailable();
-
-SOFT_LINK_LIBRARY(Wininet)
-SOFT_LINK(Wininet, InternetSetCookieExW, DWORD, WINAPI, (LPCWSTR lpszUrl, LPCWSTR lpszCookieName, LPCWSTR lpszCookieData, DWORD dwFlags, DWORD_PTR dwReserved), (lpszUrl, lpszCookieName, lpszCookieData, dwFlags, dwReserved))
-
-// Interface declaration for MediaPlayerPrivateQuickTimeVisualContext's QTMovieClient aggregate
-class MediaPlayerPrivateQuickTimeVisualContext::MovieClient : public QTMovieClient {
-public:
- MovieClient(MediaPlayerPrivateQuickTimeVisualContext* parent) : m_parent(parent) {}
- virtual ~MovieClient() { m_parent = 0; }
- virtual void movieEnded(QTMovie*);
- virtual void movieLoadStateChanged(QTMovie*);
- virtual void movieTimeChanged(QTMovie*);
-private:
- MediaPlayerPrivateQuickTimeVisualContext* m_parent;
-};
-
-#if USE(ACCELERATED_COMPOSITING)
-class MediaPlayerPrivateQuickTimeVisualContext::LayerClient : public PlatformCALayerClient {
-public:
- LayerClient(MediaPlayerPrivateQuickTimeVisualContext* parent) : m_parent(parent) {}
- virtual ~LayerClient() { m_parent = 0; }
-
-private:
- virtual void platformCALayerLayoutSublayersOfLayer(PlatformCALayer*);
- virtual bool platformCALayerRespondsToLayoutChanges() const { return true; }
-
- virtual void platformCALayerAnimationStarted(CFTimeInterval beginTime) { }
- virtual GraphicsLayer::CompositingCoordinatesOrientation platformCALayerContentsOrientation() const { return GraphicsLayer::CompositingCoordinatesBottomUp; }
- virtual void platformCALayerPaintContents(GraphicsContext&, const IntRect& inClip) { }
- virtual bool platformCALayerShowDebugBorders() const { return false; }
- virtual bool platformCALayerShowRepaintCounter(PlatformCALayer*) const { return false; }
- virtual int platformCALayerIncrementRepaintCount() { return 0; }
-
- virtual bool platformCALayerContentsOpaque() const { return false; }
- virtual bool platformCALayerDrawsContent() const { return false; }
- virtual void platformCALayerLayerDidDisplay(PlatformLayer*) { }
- virtual void platformCALayerDidCreateTiles(const Vector<FloatRect>&) { }
- virtual float platformCALayerDeviceScaleFactor() { return 1; }
-
- MediaPlayerPrivateQuickTimeVisualContext* m_parent;
-};
-
-void MediaPlayerPrivateQuickTimeVisualContext::LayerClient::platformCALayerLayoutSublayersOfLayer(PlatformCALayer* layer)
-{
- ASSERT(m_parent);
- ASSERT(m_parent->m_transformLayer == layer);
-
- FloatSize parentSize = layer->bounds().size();
- FloatSize naturalSize = m_parent->naturalSize();
-
- // Calculate the ratio of these two sizes and use that ratio to scale the qtVideoLayer:
- FloatSize ratio(parentSize.width() / naturalSize.width(), parentSize.height() / naturalSize.height());
-
- int videoWidth = 0;
- int videoHeight = 0;
- m_parent->m_movie->getNaturalSize(videoWidth, videoHeight);
- FloatRect videoBounds(0, 0, videoWidth * ratio.width(), videoHeight * ratio.height());
- FloatPoint3D videoAnchor = m_parent->m_qtVideoLayer->anchorPoint();
-
- // Calculate the new position based on the parent's size:
- FloatPoint position(parentSize.width() * 0.5 - videoBounds.width() * (0.5 - videoAnchor.x()),
- parentSize.height() * 0.5 - videoBounds.height() * (0.5 - videoAnchor.y()));
-
- m_parent->m_qtVideoLayer->setBounds(videoBounds);
- m_parent->m_qtVideoLayer->setPosition(position);
-}
-#endif
-
-class MediaPlayerPrivateQuickTimeVisualContext::VisualContextClient : public QTMovieVisualContextClient {
-public:
- VisualContextClient(MediaPlayerPrivateQuickTimeVisualContext* parent) : m_parent(parent) {}
- virtual ~VisualContextClient() { m_parent = 0; }
- void imageAvailableForTime(const QTCVTimeStamp*);
- static void retrieveCurrentImageProc(void*);
-private:
- MediaPlayerPrivateQuickTimeVisualContext* m_parent;
-};
-
-PassOwnPtr<MediaPlayerPrivateInterface> MediaPlayerPrivateQuickTimeVisualContext::create(MediaPlayer* player)
-{
- return adoptPtr(new MediaPlayerPrivateQuickTimeVisualContext(player));
-}
-
-void MediaPlayerPrivateQuickTimeVisualContext::registerMediaEngine(MediaEngineRegistrar registrar)
-{
- if (isAvailable())
- registrar(create, getSupportedTypes, supportsType, 0, 0, 0);
-}
-
-MediaPlayerPrivateQuickTimeVisualContext::MediaPlayerPrivateQuickTimeVisualContext(MediaPlayer* player)
- : m_player(player)
- , m_seekTo(-1)
- , m_seekTimer(this, &MediaPlayerPrivateQuickTimeVisualContext::seekTimerFired)
- , m_visualContextTimer(this, &MediaPlayerPrivateQuickTimeVisualContext::visualContextTimerFired)
- , m_networkState(MediaPlayer::Empty)
- , m_readyState(MediaPlayer::HaveNothing)
- , m_enabledTrackCount(0)
- , m_totalTrackCount(0)
- , m_hasUnsupportedTracks(false)
- , m_startedPlaying(false)
- , m_isStreaming(false)
- , m_visible(false)
- , m_newFrameAvailable(false)
- , m_movieClient(adoptPtr(new MediaPlayerPrivateQuickTimeVisualContext::MovieClient(this)))
-#if USE(ACCELERATED_COMPOSITING)
- , m_layerClient(adoptPtr(new MediaPlayerPrivateQuickTimeVisualContext::LayerClient(this)))
- , m_movieTransform(CGAffineTransformIdentity)
-#endif
- , m_visualContextClient(adoptPtr(new MediaPlayerPrivateQuickTimeVisualContext::VisualContextClient(this)))
- , m_delayingLoad(false)
- , m_privateBrowsing(false)
- , m_preload(MediaPlayer::Auto)
- , m_maxTimeLoadedAtLastDidLoadingProgress(0)
-{
-}
-
-MediaPlayerPrivateQuickTimeVisualContext::~MediaPlayerPrivateQuickTimeVisualContext()
-{
- tearDownVideoRendering();
- cancelCallOnMainThread(&VisualContextClient::retrieveCurrentImageProc, this);
-}
-
-bool MediaPlayerPrivateQuickTimeVisualContext::supportsFullscreen() const
-{
-#if USE(ACCELERATED_COMPOSITING)
- Document* document = m_player->mediaPlayerClient()->mediaPlayerOwningDocument();
- if (document && document->settings())
- return document->settings()->acceleratedCompositingEnabled();
-#endif
- return false;
-}
-
-PlatformMedia MediaPlayerPrivateQuickTimeVisualContext::platformMedia() const
-{
- PlatformMedia p;
- p.type = PlatformMedia::QTMovieVisualContextType;
- p.media.qtMovieVisualContext = m_visualContext.get();
- return p;
-}
-#if USE(ACCELERATED_COMPOSITING)
-
-PlatformLayer* MediaPlayerPrivateQuickTimeVisualContext::platformLayer() const
-{
- return m_transformLayer ? m_transformLayer->platformLayer() : 0;
-}
-#endif
-
-String MediaPlayerPrivateQuickTimeVisualContext::rfc2616DateStringFromTime(CFAbsoluteTime time)
-{
- static const char* const dayStrings[] = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" };
- static const char* const monthStrings[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
- static const CFStringRef dateFormatString = CFSTR("%s, %02d %s %04d %02d:%02d:%02d GMT");
- static CFTimeZoneRef gmtTimeZone;
- if (!gmtTimeZone)
- gmtTimeZone = CFTimeZoneCopyDefault();
-
- CFGregorianDate dateValue = CFAbsoluteTimeGetGregorianDate(time, gmtTimeZone);
- if (!CFGregorianDateIsValid(dateValue, kCFGregorianAllUnits))
- return String();
-
- time = CFGregorianDateGetAbsoluteTime(dateValue, gmtTimeZone);
- SInt32 day = CFAbsoluteTimeGetDayOfWeek(time, 0);
-
- RetainPtr<CFStringRef> dateCFString(AdoptCF, CFStringCreateWithFormat(0, 0, dateFormatString, dayStrings[day - 1], dateValue.day,
- monthStrings[dateValue.month - 1], dateValue.year, dateValue.hour, dateValue.minute, (int)dateValue.second));
- return dateCFString.get();
-}
-
-static void addCookieParam(StringBuilder& cookieBuilder, const String& name, const String& value)
-{
- if (name.isEmpty())
- return;
-
- // If this isn't the first parameter added, terminate the previous one.
- if (cookieBuilder.length())
- cookieBuilder.append("; ");
-
- // Add parameter name, and value if there is one.
- cookieBuilder.append(name);
- if (!value.isEmpty()) {
- cookieBuilder.append('=');
- cookieBuilder.append(value);
- }
-}
-
-void MediaPlayerPrivateQuickTimeVisualContext::setUpCookiesForQuickTime(const String& url)
-{
- // WebCore loaded the page with the movie URL with CFNetwork but QuickTime will
- // use WinINet to download the movie, so we need to copy any cookies needed to
- // download the movie into WinInet before asking QuickTime to open it.
- Document* document = m_player->mediaPlayerClient()->mediaPlayerOwningDocument();
- Frame* frame = document ? document->frame() : 0;
- if (!frame || !frame->page() || !frame->page()->settings()->cookieEnabled())
- return;
-
- KURL movieURL = KURL(KURL(), url);
- Vector<Cookie> documentCookies;
- if (!getRawCookies(frame->document(), movieURL, documentCookies))
- return;
-
- for (size_t ndx = 0; ndx < documentCookies.size(); ndx++) {
- const Cookie& cookie = documentCookies[ndx];
-
- if (cookie.name.isEmpty())
- continue;
-
- // Build up the cookie string with as much information as we can get so WinINet
- // knows what to do with it.
- StringBuilder cookieBuilder;
- addCookieParam(cookieBuilder, cookie.name, cookie.value);
- addCookieParam(cookieBuilder, "path", cookie.path);
- if (cookie.expires)
- addCookieParam(cookieBuilder, "expires", rfc2616DateStringFromTime(cookie.expires));
- if (cookie.httpOnly)
- addCookieParam(cookieBuilder, "httpOnly", String());
- cookieBuilder.append(';');
-
- String cookieURL;
- if (!cookie.domain.isEmpty()) {
- StringBuilder urlBuilder;
-
- urlBuilder.append(movieURL.protocol());
- urlBuilder.append("://");
- if (cookie.domain[0] == '.')
- urlBuilder.append(cookie.domain.substring(1));
- else
- urlBuilder.append(cookie.domain);
- if (cookie.path.length() > 1)
- urlBuilder.append(cookie.path);
-
- cookieURL = urlBuilder.toString();
- } else
- cookieURL = movieURL;
-
- String string = cookieBuilder.toString();
- InternetSetCookieExW(cookieURL.charactersWithNullTermination(), 0, string.charactersWithNullTermination(), 0, 0);
- }
-}
-
-static void disableComponentsOnce()
-{
- static bool sComponentsDisabled = false;
- if (sComponentsDisabled)
- return;
- sComponentsDisabled = true;
-
- uint32_t componentsToDisable[][5] = {
- {'eat ', 'TEXT', 'text', 0, 0},
- {'eat ', 'TXT ', 'text', 0, 0},
- {'eat ', 'utxt', 'text', 0, 0},
- {'eat ', 'TEXT', 'tx3g', 0, 0},
- };
-
- for (size_t i = 0; i < WTF_ARRAY_LENGTH(componentsToDisable); ++i)
- QTMovie::disableComponent(componentsToDisable[i]);
-}
-
-void MediaPlayerPrivateQuickTimeVisualContext::resumeLoad()
-{
- m_delayingLoad = false;
-
- if (!m_movieURL.isEmpty())
- loadInternal(m_movieURL);
-}
-
-void MediaPlayerPrivateQuickTimeVisualContext::load(const String& url)
-{
- m_movieURL = url;
-
- if (m_preload == MediaPlayer::None) {
- m_delayingLoad = true;
- return;
- }
-
- loadInternal(url);
-}
-
-void MediaPlayerPrivateQuickTimeVisualContext::loadInternal(const String& url)
-{
- if (!QTMovie::initializeQuickTime()) {
- // FIXME: is this the right error to return?
- m_networkState = MediaPlayer::DecodeError;
- m_player->networkStateChanged();
- return;
- }
-
- disableComponentsOnce();
-
- // Initialize the task timer.
- MediaPlayerPrivateTaskTimer::initialize();
-
- if (m_networkState != MediaPlayer::Loading) {
- m_networkState = MediaPlayer::Loading;
- m_player->networkStateChanged();
- }
- if (m_readyState != MediaPlayer::HaveNothing) {
- m_readyState = MediaPlayer::HaveNothing;
- m_player->readyStateChanged();
- }
- cancelSeek();
-
- setUpCookiesForQuickTime(url);
-
- m_movie = adoptRef(new QTMovie(m_movieClient.get()));
-
- m_movie->load(url.characters(), url.length(), m_player->preservesPitch());
- m_movie->setVolume(m_player->volume());
-}
-
-void MediaPlayerPrivateQuickTimeVisualContext::prepareToPlay()
-{
- if (!m_movie || m_delayingLoad)
- resumeLoad();
-}
-
-void MediaPlayerPrivateQuickTimeVisualContext::play()
-{
- if (!m_movie)
- return;
- m_startedPlaying = true;
-
- m_movie->play();
- m_visualContextTimer.startRepeating(1.0 / 30);
-}
-
-void MediaPlayerPrivateQuickTimeVisualContext::pause()
-{
- if (!m_movie)
- return;
- m_startedPlaying = false;
-
- m_movie->pause();
- m_visualContextTimer.stop();
-}
-
-float MediaPlayerPrivateQuickTimeVisualContext::duration() const
-{
- if (!m_movie)
- return 0;
- return m_movie->duration();
-}
-
-float MediaPlayerPrivateQuickTimeVisualContext::currentTime() const
-{
- if (!m_movie)
- return 0;
- return m_movie->currentTime();
-}
-
-void MediaPlayerPrivateQuickTimeVisualContext::seek(float time)
-{
- cancelSeek();
-
- if (!m_movie)
- return;
-
- if (time > duration())
- time = duration();
-
- m_seekTo = time;
- if (maxTimeLoaded() >= m_seekTo)
- doSeek();
- else
- m_seekTimer.start(0, 0.5f);
-}
-
-void MediaPlayerPrivateQuickTimeVisualContext::doSeek()
-{
- float oldRate = m_movie->rate();
- if (oldRate)
- m_movie->setRate(0);
- m_movie->setCurrentTime(m_seekTo);
- float timeAfterSeek = currentTime();
- // restore playback only if not at end, othewise QTMovie will loop
- if (oldRate && timeAfterSeek < duration())
- m_movie->setRate(oldRate);
- cancelSeek();
-}
-
-void MediaPlayerPrivateQuickTimeVisualContext::cancelSeek()
-{
- m_seekTo = -1;
- m_seekTimer.stop();
-}
-
-void MediaPlayerPrivateQuickTimeVisualContext::seekTimerFired(Timer<MediaPlayerPrivateQuickTimeVisualContext>*)
-{
- if (!m_movie || !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();
- }
- }
-}
-
-bool MediaPlayerPrivateQuickTimeVisualContext::paused() const
-{
- if (!m_movie)
- return true;
- return (!m_movie->rate());
-}
-
-bool MediaPlayerPrivateQuickTimeVisualContext::seeking() const
-{
- if (!m_movie)
- return false;
- return m_seekTo >= 0;
-}
-
-IntSize MediaPlayerPrivateQuickTimeVisualContext::naturalSize() const
-{
- if (!m_movie)
- return IntSize();
- int width;
- int height;
- m_movie->getNaturalSize(width, height);
-#if USE(ACCELERATED_COMPOSITING)
- CGSize originalSize = {width, height};
- CGSize transformedSize = CGSizeApplyAffineTransform(originalSize, m_movieTransform);
- return IntSize(abs(transformedSize.width), abs(transformedSize.height));
-#else
- return IntSize(width, height);
-#endif
-}
-
-bool MediaPlayerPrivateQuickTimeVisualContext::hasVideo() const
-{
- if (!m_movie)
- return false;
- return m_movie->hasVideo();
-}
-
-bool MediaPlayerPrivateQuickTimeVisualContext::hasAudio() const
-{
- if (!m_movie)
- return false;
- return m_movie->hasAudio();
-}
-
-void MediaPlayerPrivateQuickTimeVisualContext::setVolume(float volume)
-{
- if (!m_movie)
- return;
- m_movie->setVolume(volume);
-}
-
-void MediaPlayerPrivateQuickTimeVisualContext::setRate(float rate)
-{
- if (!m_movie)
- return;
-
- // Do not call setRate(...) unless we have started playing; otherwise
- // QuickTime's VisualContext can get wedged waiting for a rate change
- // call which will never come.
- if (m_startedPlaying)
- m_movie->setRate(rate);
-}
-
-void MediaPlayerPrivateQuickTimeVisualContext::setPreservesPitch(bool preservesPitch)
-{
- if (!m_movie)
- return;
- m_movie->setPreservesPitch(preservesPitch);
-}
-
-bool MediaPlayerPrivateQuickTimeVisualContext::hasClosedCaptions() const
-{
- if (!m_movie)
- return false;
- return m_movie->hasClosedCaptions();
-}
-
-void MediaPlayerPrivateQuickTimeVisualContext::setClosedCaptionsVisible(bool visible)
-{
- if (!m_movie)
- return;
- m_movie->setClosedCaptionsVisible(visible);
-}
-
-PassRefPtr<TimeRanges> MediaPlayerPrivateQuickTimeVisualContext::buffered() const
-{
- RefPtr<TimeRanges> timeRanges = TimeRanges::create();
- float loaded = maxTimeLoaded();
- // rtsp streams are not buffered
- if (!m_isStreaming && loaded > 0)
- timeRanges->add(0, loaded);
- return timeRanges.release();
-}
-
-float MediaPlayerPrivateQuickTimeVisualContext::maxTimeSeekable() const
-{
- // infinite duration means live stream
- return !std::isfinite(duration()) ? 0 : maxTimeLoaded();
-}
-
-float MediaPlayerPrivateQuickTimeVisualContext::maxTimeLoaded() const
-{
- if (!m_movie)
- return 0;
- return m_movie->maxTimeLoaded();
-}
-
-bool MediaPlayerPrivateQuickTimeVisualContext::didLoadingProgress() const
-{
- if (!m_movie || !duration())
- return false;
- float currentMaxTimeLoaded = maxTimeLoaded();
- bool didLoadingProgress = currentMaxTimeLoaded != m_maxTimeLoadedAtLastDidLoadingProgress;
- m_maxTimeLoadedAtLastDidLoadingProgress = currentMaxTimeLoaded;
- return didLoadingProgress;
-}
-
-unsigned MediaPlayerPrivateQuickTimeVisualContext::totalBytes() const
-{
- if (!m_movie)
- return 0;
- return m_movie->dataSize();
-}
-
-void MediaPlayerPrivateQuickTimeVisualContext::cancelLoad()
-{
- if (m_networkState < MediaPlayer::Loading || m_networkState == MediaPlayer::Loaded)
- return;
-
- tearDownVideoRendering();
-
- // Cancel the load by destroying the movie.
- m_movie.clear();
-
- updateStates();
-}
-
-void MediaPlayerPrivateQuickTimeVisualContext::updateStates()
-{
- MediaPlayer::NetworkState oldNetworkState = m_networkState;
- MediaPlayer::ReadyState oldReadyState = m_readyState;
-
- long loadState = m_movie ? m_movie->loadState() : QTMovieLoadStateError;
-
- if (loadState >= QTMovieLoadStateLoaded && m_readyState < MediaPlayer::HaveMetadata) {
- m_movie->disableUnsupportedTracks(m_enabledTrackCount, m_totalTrackCount);
- if (m_player->inMediaDocument()) {
- if (!m_enabledTrackCount || m_enabledTrackCount != m_totalTrackCount) {
- // This is a type of media that we do not handle directly with a <video>
- // element, eg. QuickTime VR, a movie with a sprite track, etc. Tell the
- // MediaPlayerClient that we won't support it.
- sawUnsupportedTracks();
- return;
- }
- } else if (!m_enabledTrackCount)
- loadState = QTMovieLoadStateError;
- }
-
- // "Loaded" is reserved for fully buffered movies, never the case when streaming
- if (loadState >= QTMovieLoadStateComplete && !m_isStreaming) {
- m_networkState = MediaPlayer::Loaded;
- m_readyState = MediaPlayer::HaveEnoughData;
- } else if (loadState >= QTMovieLoadStatePlaythroughOK) {
- m_readyState = MediaPlayer::HaveEnoughData;
- } else if (loadState >= QTMovieLoadStatePlayable) {
- // FIXME: This might not work correctly in streaming case, <rdar://problem/5693967>
- m_readyState = currentTime() < maxTimeLoaded() ? MediaPlayer::HaveFutureData : MediaPlayer::HaveCurrentData;
- } else if (loadState >= QTMovieLoadStateLoaded) {
- m_readyState = MediaPlayer::HaveMetadata;
- } else if (loadState > QTMovieLoadStateError) {
- m_networkState = MediaPlayer::Loading;
- m_readyState = MediaPlayer::HaveNothing;
- } else {
- if (m_player->inMediaDocument()) {
- // Something went wrong in the loading of media within a standalone file.
- // This can occur with chained ref movies that eventually resolve to a
- // file we don't support.
- sawUnsupportedTracks();
- return;
- }
-
- float loaded = maxTimeLoaded();
- if (!loaded)
- m_readyState = MediaPlayer::HaveNothing;
-
- if (!m_enabledTrackCount)
- m_networkState = MediaPlayer::FormatError;
- else {
- // FIXME: We should differentiate between load/network errors and decode errors <rdar://problem/5605692>
- if (loaded > 0)
- m_networkState = MediaPlayer::DecodeError;
- else
- m_readyState = MediaPlayer::HaveNothing;
- }
- }
-
- if (isReadyForRendering() && !hasSetUpVideoRendering())
- setUpVideoRendering();
-
- if (seeking())
- m_readyState = MediaPlayer::HaveNothing;
-
- if (m_networkState != oldNetworkState)
- m_player->networkStateChanged();
- if (m_readyState != oldReadyState)
- m_player->readyStateChanged();
-}
-
-bool MediaPlayerPrivateQuickTimeVisualContext::isReadyForRendering() const
-{
- return m_readyState >= MediaPlayer::HaveMetadata && m_player->visible();
-}
-
-void MediaPlayerPrivateQuickTimeVisualContext::sawUnsupportedTracks()
-{
- m_movie->setDisabled(true);
- m_hasUnsupportedTracks = true;
- m_player->mediaPlayerClient()->mediaPlayerSawUnsupportedTracks(m_player);
-}
-
-void MediaPlayerPrivateQuickTimeVisualContext::didEnd()
-{
- if (m_hasUnsupportedTracks)
- return;
-
- m_startedPlaying = false;
-
- updateStates();
- m_player->timeChanged();
-}
-
-void MediaPlayerPrivateQuickTimeVisualContext::setSize(const IntSize& size)
-{
- if (m_hasUnsupportedTracks || !m_movie || m_size == size)
- return;
- m_size = size;
-}
-
-void MediaPlayerPrivateQuickTimeVisualContext::setVisible(bool visible)
-{
- if (m_hasUnsupportedTracks || !m_movie || m_visible == visible)
- return;
-
- m_visible = visible;
- if (m_visible) {
- if (isReadyForRendering())
- setUpVideoRendering();
- } else
- tearDownVideoRendering();
-}
-
-void MediaPlayerPrivateQuickTimeVisualContext::paint(GraphicsContext* p, const IntRect& r)
-{
- MediaRenderingMode currentMode = currentRenderingMode();
-
- if (currentMode == MediaRenderingNone)
- return;
-
- if (currentMode == MediaRenderingSoftwareRenderer && !m_visualContext)
- return;
-
- QTPixelBuffer buffer = m_visualContext->imageForTime(0);
- if (buffer.pixelBufferRef()) {
-#if USE(ACCELERATED_COMPOSITING)
- if (m_qtVideoLayer) {
- // We are probably being asked to render the video into a canvas, but
- // there's a good chance the QTPixelBuffer is not ARGB and thus can't be
- // drawn using CG. If so, fire up an ICMDecompressionSession and convert
- // the current frame into something which can be rendered by CG.
- if (!buffer.pixelFormatIs32ARGB() && !buffer.pixelFormatIs32BGRA()) {
- // The decompression session will only decompress a specific pixelFormat
- // at a specific width and height; if these differ, the session must be
- // recreated with the new parameters.
- if (!m_decompressionSession || !m_decompressionSession->canDecompress(buffer))
- m_decompressionSession = QTDecompressionSession::create(buffer.pixelFormatType(), buffer.width(), buffer.height());
- buffer = m_decompressionSession->decompress(buffer);
- }
- }
-#endif
- CGImageRef image = CreateCGImageFromPixelBuffer(buffer);
-
- CGContextRef context = p->platformContext();
- CGContextSaveGState(context);
- CGContextTranslateCTM(context, r.x(), r.y());
- CGContextTranslateCTM(context, 0, r.height());
- CGContextScaleCTM(context, 1, -1);
- CGContextDrawImage(context, CGRectMake(0, 0, r.width(), r.height()), image);
- CGContextRestoreGState(context);
-
- CGImageRelease(image);
- }
- paintCompleted(*p, r);
-}
-
-void MediaPlayerPrivateQuickTimeVisualContext::paintCompleted(GraphicsContext& context, const IntRect& rect)
-{
- m_newFrameAvailable = false;
-}
-
-void MediaPlayerPrivateQuickTimeVisualContext::VisualContextClient::retrieveCurrentImageProc(void* refcon)
-{
- static_cast<MediaPlayerPrivateQuickTimeVisualContext*>(refcon)->retrieveCurrentImage();
-}
-
-void MediaPlayerPrivateQuickTimeVisualContext::VisualContextClient::imageAvailableForTime(const QTCVTimeStamp* timeStamp)
-{
- // This call may come in on another thread, so marshall to the main thread first:
- callOnMainThread(&retrieveCurrentImageProc, m_parent);
-
- // callOnMainThread must be paired with cancelCallOnMainThread in the destructor,
- // in case this object is deleted before the main thread request is handled.
-}
-
-void MediaPlayerPrivateQuickTimeVisualContext::visualContextTimerFired(Timer<MediaPlayerPrivateQuickTimeVisualContext>*)
-{
- if (m_visualContext && m_visualContext->isImageAvailableForTime(0))
- retrieveCurrentImage();
-}
-
-static CFDictionaryRef QTCFDictionaryCreateWithDataCallback(CFAllocatorRef allocator, const UInt8* bytes, CFIndex length)
-{
- RetainPtr<CFDataRef> data(AdoptCF, CFDataCreateWithBytesNoCopy(allocator, bytes, length, kCFAllocatorNull));
- if (!data)
- return 0;
-
- return reinterpret_cast<CFDictionaryRef>(CFPropertyListCreateFromXMLData(allocator, data.get(), kCFPropertyListImmutable, 0));
-}
-
-static CGImageRef CreateCGImageFromPixelBuffer(QTPixelBuffer buffer)
-{
-#if USE(ACCELERATED_COMPOSITING)
- CGDataProviderRef provider = 0;
- CGColorSpaceRef colorSpace = 0;
- CGImageRef image = 0;
-
- size_t bitsPerComponent = 0;
- size_t bitsPerPixel = 0;
- CGImageAlphaInfo alphaInfo = kCGImageAlphaNone;
-
- if (buffer.pixelFormatIs32BGRA()) {
- bitsPerComponent = 8;
- bitsPerPixel = 32;
- alphaInfo = (CGImageAlphaInfo)(kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little);
- } else if (buffer.pixelFormatIs32ARGB()) {
- bitsPerComponent = 8;
- bitsPerPixel = 32;
- alphaInfo = (CGImageAlphaInfo)(kCGImageAlphaNoneSkipLast | kCGBitmapByteOrder32Big);
- } else {
- // All other pixel formats are currently unsupported:
- ASSERT_NOT_REACHED();
- }
-
- CGDataProviderDirectAccessCallbacks callbacks = {
- &QTPixelBuffer::dataProviderGetBytePointerCallback,
- &QTPixelBuffer::dataProviderReleaseBytePointerCallback,
- &QTPixelBuffer::dataProviderGetBytesAtPositionCallback,
- &QTPixelBuffer::dataProviderReleaseInfoCallback,
- };
-
- // Colorspace should be device, so that Quartz does not have to do an extra render.
- colorSpace = CGColorSpaceCreateDeviceRGB();
- require(colorSpace, Bail);
-
- provider = CGDataProviderCreateDirectAccess(buffer.pixelBufferRef(), buffer.dataSize(), &callbacks);
- require(provider, Bail);
-
- // CGDataProvider does not retain the buffer, but it will release it later, so do an extra retain here:
- QTPixelBuffer::retainCallback(buffer.pixelBufferRef());
-
- image = CGImageCreate(buffer.width(), buffer.height(), bitsPerComponent, bitsPerPixel, buffer.bytesPerRow(), colorSpace, alphaInfo, provider, 0, false, kCGRenderingIntentDefault);
-
-Bail:
- // Once the image is created we can release our reference to the provider and the colorspace, they are retained by the image
- if (provider)
- CGDataProviderRelease(provider);
- if (colorSpace)
- CGColorSpaceRelease(colorSpace);
-
- return image;
-#else
- return 0;
-#endif
-}
-
-
-void MediaPlayerPrivateQuickTimeVisualContext::retrieveCurrentImage()
-{
- if (!m_visualContext)
- return;
-
-#if USE(ACCELERATED_COMPOSITING)
- if (m_qtVideoLayer) {
-
- QTPixelBuffer buffer = m_visualContext->imageForTime(0);
- if (!buffer.pixelBufferRef())
- return;
-
- PlatformCALayer* layer = m_qtVideoLayer.get();
-
- if (!buffer.lockBaseAddress()) {
- if (requiredDllsAvailable()) {
- if (!m_imageQueue) {
- m_imageQueue = adoptPtr(new WKCAImageQueue(buffer.width(), buffer.height(), 30));
- m_imageQueue->setFlags(WKCAImageQueue::Fill, WKCAImageQueue::Fill);
- layer->setContents(m_imageQueue->get());
- }
-
- // Debug QuickTime links against a non-Debug version of CoreFoundation, so the
- // CFDictionary attached to the CVPixelBuffer cannot be directly passed on into the
- // CAImageQueue without being converted to a non-Debug CFDictionary. Additionally,
- // old versions of QuickTime used a non-AAS CoreFoundation, so the types are not
- // interchangable even in the release case.
- RetainPtr<CFDictionaryRef> attachments(AdoptCF, QTCFDictionaryCreateCopyWithDataCallback(kCFAllocatorDefault, buffer.attachments(), &QTCFDictionaryCreateWithDataCallback));
- CFTimeInterval imageTime = QTMovieVisualContext::currentHostTime();
-
- m_imageQueue->collect();
-
- uint64_t imageId = m_imageQueue->registerPixelBuffer(buffer.baseAddress(), buffer.dataSize(), buffer.bytesPerRow(), buffer.width(), buffer.height(), buffer.pixelFormatType(), attachments.get(), 0);
-
- if (m_imageQueue->insertImage(imageTime, WKCAImageQueue::Buffer, imageId, WKCAImageQueue::Opaque | WKCAImageQueue::Flush, &QTPixelBuffer::imageQueueReleaseCallback, buffer.pixelBufferRef())) {
- // Retain the buffer one extra time so it doesn't dissappear before CAImageQueue decides to release it:
- QTPixelBuffer::retainCallback(buffer.pixelBufferRef());
- }
-
- } else {
- CGImageRef image = CreateCGImageFromPixelBuffer(buffer);
- layer->setContents(image);
- CGImageRelease(image);
- }
-
- buffer.unlockBaseAddress();
- layer->setNeedsCommit();
- }
- } else
-#endif
- m_player->repaint();
-
- m_visualContext->task();
-}
-
-static HashSet<String> mimeTypeCache()
-{
- DEFINE_STATIC_LOCAL(HashSet<String>, typeCache, ());
- static bool typeListInitialized = false;
-
- if (!typeListInitialized) {
- unsigned count = QTMovie::countSupportedTypes();
- for (unsigned n = 0; n < count; n++) {
- const UChar* character;
- unsigned len;
- QTMovie::getSupportedType(n, character, len);
- if (len)
- typeCache.add(String(character, len));
- }
-
- typeListInitialized = true;
- }
-
- return typeCache;
-}
-
-static CFStringRef createVersionStringFromModuleName(LPCWSTR moduleName)
-{
- HMODULE module = GetModuleHandleW(moduleName);
- if (!module)
- return 0;
-
- wchar_t filePath[MAX_PATH] = {0};
- if (!GetModuleFileNameW(module, filePath, MAX_PATH))
- return 0;
-
- DWORD versionInfoSize = GetFileVersionInfoSizeW(filePath, 0);
- if (!versionInfoSize)
- return 0;
-
- CFStringRef versionString = 0;
- void* versionInfo = calloc(versionInfoSize, sizeof(char));
- if (GetFileVersionInfo(filePath, 0, versionInfoSize, versionInfo)) {
- VS_FIXEDFILEINFO* fileInfo = 0;
- UINT fileInfoLength = 0;
-
- if (VerQueryValueW(versionInfo, L"\\", reinterpret_cast<LPVOID*>(&fileInfo), &fileInfoLength)) {
- versionString = CFStringCreateWithFormat(kCFAllocatorDefault, 0, CFSTR("%d.%d.%d.%d"),
- HIWORD(fileInfo->dwFileVersionMS), LOWORD(fileInfo->dwFileVersionMS),
- HIWORD(fileInfo->dwFileVersionLS), LOWORD(fileInfo->dwFileVersionLS));
- }
- }
- free(versionInfo);
-
- return versionString;
-}
-
-static bool requiredDllsAvailable()
-{
- static bool s_prerequisitesChecked = false;
- static bool s_prerequisitesSatisfied;
- static const CFStringRef kMinQuartzCoreVersion = CFSTR("1.0.42.0");
- static const CFStringRef kMinCoreVideoVersion = CFSTR("1.0.1.0");
-
- if (s_prerequisitesChecked)
- return s_prerequisitesSatisfied;
- s_prerequisitesChecked = true;
- s_prerequisitesSatisfied = false;
-
- CFStringRef quartzCoreString = createVersionStringFromModuleName(L"QuartzCore");
- if (!quartzCoreString)
- quartzCoreString = createVersionStringFromModuleName(L"QuartzCore_debug");
-
- CFStringRef coreVideoString = createVersionStringFromModuleName(L"CoreVideo");
- if (!coreVideoString)
- coreVideoString = createVersionStringFromModuleName(L"CoreVideo_debug");
-
- s_prerequisitesSatisfied = (quartzCoreString && coreVideoString
- && CFStringCompare(quartzCoreString, kMinQuartzCoreVersion, kCFCompareNumerically) != kCFCompareLessThan
- && CFStringCompare(coreVideoString, kMinCoreVideoVersion, kCFCompareNumerically) != kCFCompareLessThan);
-
- if (quartzCoreString)
- CFRelease(quartzCoreString);
- if (coreVideoString)
- CFRelease(coreVideoString);
-
- return s_prerequisitesSatisfied;
-}
-
-void MediaPlayerPrivateQuickTimeVisualContext::getSupportedTypes(HashSet<String>& types)
-{
- types = mimeTypeCache();
-}
-
-bool MediaPlayerPrivateQuickTimeVisualContext::isAvailable()
-{
- return QTMovie::initializeQuickTime();
-}
-
-MediaPlayer::SupportsType MediaPlayerPrivateQuickTimeVisualContext::supportsType(const String& type, const String& codecs, const KURL&)
-{
- // only return "IsSupported" if there is no codecs parameter for now as there is no way to ask QT if it supports an
- // extended MIME type
- return mimeTypeCache().contains(type) ? (codecs.isEmpty() ? MediaPlayer::MayBeSupported : MediaPlayer::IsSupported) : MediaPlayer::IsNotSupported;
-}
-
-void MediaPlayerPrivateQuickTimeVisualContext::MovieClient::movieEnded(QTMovie* movie)
-{
- if (m_parent->m_hasUnsupportedTracks)
- return;
-
- m_parent->m_visualContextTimer.stop();
-
- ASSERT(m_parent->m_movie.get() == movie);
- m_parent->didEnd();
-}
-
-void MediaPlayerPrivateQuickTimeVisualContext::MovieClient::movieLoadStateChanged(QTMovie* movie)
-{
- if (m_parent->m_hasUnsupportedTracks)
- return;
-
- ASSERT(m_parent->m_movie.get() == movie);
- m_parent->updateStates();
-}
-
-void MediaPlayerPrivateQuickTimeVisualContext::MovieClient::movieTimeChanged(QTMovie* movie)
-{
- if (m_parent->m_hasUnsupportedTracks)
- return;
-
- ASSERT(m_parent->m_movie.get() == movie);
- m_parent->updateStates();
- m_parent->m_player->timeChanged();
-}
-
-bool MediaPlayerPrivateQuickTimeVisualContext::hasSingleSecurityOrigin() const
-{
- // We tell quicktime to disallow resources that come from different origins
- // so we all media is single origin.
- return true;
-}
-
-void MediaPlayerPrivateQuickTimeVisualContext::setPreload(MediaPlayer::Preload preload)
-{
- m_preload = preload;
- if (m_delayingLoad && m_preload != MediaPlayer::None)
- resumeLoad();
-}
-
-float MediaPlayerPrivateQuickTimeVisualContext::mediaTimeForTimeValue(float timeValue) const
-{
- long timeScale;
- if (m_readyState < MediaPlayer::HaveMetadata || !(timeScale = m_movie->timeScale()))
- return timeValue;
-
- long mediaTimeValue = lroundf(timeValue * timeScale);
- return static_cast<float>(mediaTimeValue) / timeScale;
-}
-
-MediaPlayerPrivateQuickTimeVisualContext::MediaRenderingMode MediaPlayerPrivateQuickTimeVisualContext::currentRenderingMode() const
-{
- if (!m_movie)
- return MediaRenderingNone;
-
-#if USE(ACCELERATED_COMPOSITING)
- if (m_qtVideoLayer)
- return MediaRenderingMovieLayer;
-#endif
-
- return m_visualContext ? MediaRenderingSoftwareRenderer : MediaRenderingNone;
-}
-
-MediaPlayerPrivateQuickTimeVisualContext::MediaRenderingMode MediaPlayerPrivateQuickTimeVisualContext::preferredRenderingMode() const
-{
- if (!m_player->frameView() || !m_movie)
- return MediaRenderingNone;
-
-#if USE(ACCELERATED_COMPOSITING)
- if (supportsAcceleratedRendering() && m_player->mediaPlayerClient()->mediaPlayerRenderingCanBeAccelerated(m_player))
- return MediaRenderingMovieLayer;
-#endif
-
- return MediaRenderingSoftwareRenderer;
-}
-
-void MediaPlayerPrivateQuickTimeVisualContext::setUpVideoRendering()
-{
- MediaRenderingMode currentMode = currentRenderingMode();
- MediaRenderingMode preferredMode = preferredRenderingMode();
-
-#if !USE(ACCELERATED_COMPOSITING)
- ASSERT(preferredMode != MediaRenderingMovieLayer);
-#endif
-
- if (currentMode == preferredMode && currentMode != MediaRenderingNone)
- return;
-
- if (currentMode != MediaRenderingNone)
- tearDownVideoRendering();
-
- if (preferredMode == MediaRenderingMovieLayer)
- createLayerForMovie();
-
-#if USE(ACCELERATED_COMPOSITING)
- if (currentMode == MediaRenderingMovieLayer || preferredMode == MediaRenderingMovieLayer)
- m_player->mediaPlayerClient()->mediaPlayerRenderingModeChanged(m_player);
-#endif
-
- QTPixelBuffer::Type contextType = requiredDllsAvailable() && preferredMode == MediaRenderingMovieLayer ? QTPixelBuffer::ConfigureForCAImageQueue : QTPixelBuffer::ConfigureForCGImage;
- m_visualContext = QTMovieVisualContext::create(m_visualContextClient.get(), contextType);
- m_visualContext->setMovie(m_movie.get());
-}
-
-void MediaPlayerPrivateQuickTimeVisualContext::tearDownVideoRendering()
-{
-#if USE(ACCELERATED_COMPOSITING)
- if (m_qtVideoLayer)
- destroyLayerForMovie();
-#endif
-
- m_visualContext = 0;
-}
-
-bool MediaPlayerPrivateQuickTimeVisualContext::hasSetUpVideoRendering() const
-{
-#if USE(ACCELERATED_COMPOSITING)
- return m_qtVideoLayer || (currentRenderingMode() != MediaRenderingMovieLayer && m_visualContext);
-#else
- return true;
-#endif
-}
-
-void MediaPlayerPrivateQuickTimeVisualContext::retrieveAndResetMovieTransform()
-{
-#if USE(ACCELERATED_COMPOSITING)
- // First things first, reset the total movie transform so that
- // we can bail out early:
- m_movieTransform = CGAffineTransformIdentity;
-
- if (!m_movie || !m_movie->hasVideo())
- return;
-
- // This trick will only work on movies with a single video track,
- // so bail out early if the video contains more than one (or zero)
- // video tracks.
- QTTrackArray videoTracks = m_movie->videoTracks();
- if (videoTracks.size() != 1)
- return;
-
- QTTrack* track = videoTracks[0].get();
- ASSERT(track);
-
- CGAffineTransform movieTransform = m_movie->getTransform();
- if (!CGAffineTransformEqualToTransform(movieTransform, CGAffineTransformIdentity))
- m_movie->resetTransform();
-
- CGAffineTransform trackTransform = track->getTransform();
- if (!CGAffineTransformEqualToTransform(trackTransform, CGAffineTransformIdentity))
- track->resetTransform();
-
- // Multiply the two transforms together, taking care to
- // do so in the correct order, track * movie = final:
- m_movieTransform = CGAffineTransformConcat(trackTransform, movieTransform);
-#endif
-}
-
-void MediaPlayerPrivateQuickTimeVisualContext::createLayerForMovie()
-{
-#if USE(ACCELERATED_COMPOSITING)
- ASSERT(supportsAcceleratedRendering());
-
- if (!m_movie || m_qtVideoLayer)
- return;
-
- // Create a PlatformCALayer which will transform the contents of the video layer
- // which is in m_qtVideoLayer.
- m_transformLayer = PlatformCALayer::create(PlatformCALayer::LayerTypeLayer, m_layerClient.get());
- if (!m_transformLayer)
- return;
-
- // Mark the layer as anchored in the top left.
- m_transformLayer->setAnchorPoint(FloatPoint3D());
-
- m_qtVideoLayer = PlatformCALayer::create(PlatformCALayer::LayerTypeLayer, 0);
- if (!m_qtVideoLayer)
- return;
-
- if (CGAffineTransformEqualToTransform(m_movieTransform, CGAffineTransformIdentity))
- retrieveAndResetMovieTransform();
- CGAffineTransform t = m_movieTransform;
-
- // Remove the translation portion of the transform, since we will always rotate about
- // the layer's center point. In our limited use-case (a single video track), this is
- // safe:
- t.tx = t.ty = 0;
- m_qtVideoLayer->setTransform(CATransform3DMakeAffineTransform(t));
-
-#ifndef NDEBUG
- m_qtVideoLayer->setName("Video layer");
-#endif
- m_transformLayer->appendSublayer(m_qtVideoLayer.get());
- m_transformLayer->setNeedsLayout();
- // The layer will get hooked up via RenderLayerBacking::updateGraphicsLayerConfiguration().
-#endif
-
- // Fill the newly created layer with image data, so we're not looking at
- // an empty layer until the next time a new image is available, which could
- // be a long time if we're paused.
- if (m_visualContext)
- retrieveCurrentImage();
-}
-
-void MediaPlayerPrivateQuickTimeVisualContext::destroyLayerForMovie()
-{
-#if USE(ACCELERATED_COMPOSITING)
- if (m_qtVideoLayer) {
- m_qtVideoLayer->removeFromSuperlayer();
- m_qtVideoLayer = 0;
- }
-
- if (m_transformLayer)
- m_transformLayer = 0;
-
- if (m_imageQueue)
- m_imageQueue = nullptr;
-#endif
-}
-
-#if USE(ACCELERATED_COMPOSITING)
-bool MediaPlayerPrivateQuickTimeVisualContext::supportsAcceleratedRendering() const
-{
- return isReadyForRendering();
-}
-
-void MediaPlayerPrivateQuickTimeVisualContext::acceleratedRenderingStateChanged()
-{
- // Set up or change the rendering path if necessary.
- setUpVideoRendering();
-}
-
-void MediaPlayerPrivateQuickTimeVisualContext::setPrivateBrowsingMode(bool privateBrowsing)
-{
- m_privateBrowsing = privateBrowsing;
- if (m_movie)
- m_movie->setPrivateBrowsingMode(m_privateBrowsing);
-}
-
-#endif
-
-
-}
-
-#endif
diff --git a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.h b/Source/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.h
deleted file mode 100644
index 66334f2..0000000
--- a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.h
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * Copyright (C) 2007, 2008, 2009, 2010, 2011 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 MediaPlayerPrivateQuickTimeVisualContext_h
-#define MediaPlayerPrivateQuickTimeVisualContext_h
-
-#if ENABLE(VIDEO)
-
-#include "MediaPlayerPrivate.h"
-#include "Timer.h"
-#include <CoreGraphics/CGAffineTransform.h>
-#include <wtf/Forward.h>
-#include <wtf/OwnPtr.h>
-#include <wtf/RetainPtr.h>
-
-#ifndef DRAW_FRAME_RATE
-#define DRAW_FRAME_RATE 0
-#endif
-
-typedef struct CGImage *CGImageRef;
-class QTMovie;
-class QTMovieVisualContext;
-class QTDecompressionSession;
-
-namespace WebCore {
-
-class GraphicsContext;
-class IntSize;
-class IntRect;
-
-#if USE(ACCELERATED_COMPOSITING)
-class PlatformCALayer;
-class WKCAImageQueue;
-#endif
-
-class MediaPlayerPrivateQuickTimeVisualContext : public MediaPlayerPrivateInterface {
-public:
- static void registerMediaEngine(MediaEngineRegistrar);
-
- ~MediaPlayerPrivateQuickTimeVisualContext();
-
-private:
- MediaPlayerPrivateQuickTimeVisualContext(MediaPlayer*);
-
- virtual bool supportsFullscreen() const;
- virtual PlatformMedia platformMedia() const;
-#if USE(ACCELERATED_COMPOSITING)
- virtual PlatformLayer* platformLayer() const;
-#endif
-
- IntSize naturalSize() const;
- bool hasVideo() const;
- bool hasAudio() const;
-
- void load(const String& url);
- void cancelLoad();
- void loadInternal(const String& url);
- void resumeLoad();
-
- void play();
- void pause();
- void prepareToPlay();
-
- bool paused() const;
- bool seeking() const;
-
- float duration() const;
- float currentTime() const;
- void seek(float time);
-
- void setRate(float);
- void setVolume(float);
- void setPreservesPitch(bool);
-
- MediaPlayer::NetworkState networkState() const { return m_networkState; }
- MediaPlayer::ReadyState readyState() const { return m_readyState; }
-
- PassRefPtr<TimeRanges> buffered() const;
- float maxTimeSeekable() const;
- bool didLoadingProgress() const;
- unsigned totalBytes() const;
-
- void setVisible(bool);
- void setSize(const IntSize&);
-
- void loadStateChanged();
- void didEnd();
-
- void paint(GraphicsContext*, const IntRect&);
- void paintCompleted(GraphicsContext&, const IntRect&);
-
- bool hasSingleSecurityOrigin() const;
-
- bool hasClosedCaptions() const;
- void setClosedCaptionsVisible(bool);
-
- void setPreload(MediaPlayer::Preload);
-
- void updateStates();
- void doSeek();
- void cancelSeek();
- void seekTimerFired(Timer<MediaPlayerPrivateQuickTimeVisualContext>*);
- float maxTimeLoaded() const;
- void sawUnsupportedTracks();
-
- // engine support
- static PassOwnPtr<MediaPlayerPrivateInterface> create(MediaPlayer*);
- static void getSupportedTypes(HashSet<String>& types);
- static MediaPlayer::SupportsType supportsType(const String& type, const String& codecs, const KURL&);
- static bool isAvailable();
-
-#if USE(ACCELERATED_COMPOSITING)
- virtual bool supportsAcceleratedRendering() const;
- virtual void acceleratedRenderingStateChanged();
-#endif
-
- enum MediaRenderingMode { MediaRenderingNone, MediaRenderingSoftwareRenderer, MediaRenderingMovieLayer };
- MediaRenderingMode currentRenderingMode() const;
- MediaRenderingMode preferredRenderingMode() const;
- bool isReadyForRendering() const;
-
- void setUpVideoRendering();
- void tearDownVideoRendering();
- bool hasSetUpVideoRendering() const;
-
- void createLayerForMovie();
- void destroyLayerForMovie();
-
- void setUpCookiesForQuickTime(const String& url);
- String rfc2616DateStringFromTime(CFAbsoluteTime);
-
- void visualContextTimerFired(Timer<MediaPlayerPrivateQuickTimeVisualContext>*);
- void retrieveCurrentImage();
-
- virtual void setPrivateBrowsingMode(bool);
-
- virtual String engineDescription() const { return "QuickTime"; }
-
- class MovieClient;
- friend class MovieClient;
- OwnPtr<MovieClient> m_movieClient;
-
-#if USE(ACCELERATED_COMPOSITING)
- class LayerClient;
- friend class LayerClient;
- OwnPtr<LayerClient> m_layerClient;
-#endif
-
- class VisualContextClient;
- friend class VisualContextClient;
- OwnPtr<VisualContextClient> m_visualContextClient;
-
- void retrieveAndResetMovieTransform();
-
- virtual float mediaTimeForTimeValue(float) const;
-
- MediaPlayer* m_player;
- RefPtr<QTMovie> m_movie;
-#if USE(ACCELERATED_COMPOSITING)
- RefPtr<PlatformCALayer> m_qtVideoLayer;
- RefPtr<PlatformCALayer> m_transformLayer;
- OwnPtr<WKCAImageQueue> m_imageQueue;
- OwnPtr<QTDecompressionSession> m_decompressionSession;
- CGAffineTransform m_movieTransform;
-#endif
- RefPtr<QTMovieVisualContext> m_visualContext;
- float m_seekTo;
- Timer<MediaPlayerPrivateQuickTimeVisualContext> m_seekTimer;
- Timer<MediaPlayerPrivateQuickTimeVisualContext> m_visualContextTimer;
- IntSize m_size;
- MediaPlayer::NetworkState m_networkState;
- MediaPlayer::ReadyState m_readyState;
- unsigned m_enabledTrackCount;
- unsigned m_totalTrackCount;
- bool m_hasUnsupportedTracks;
- bool m_startedPlaying;
- bool m_isStreaming;
- bool m_visible;
- bool m_newFrameAvailable;
- bool m_delayingLoad;
- String m_movieURL;
- bool m_privateBrowsing;
- MediaPlayer::Preload m_preload;
- mutable float m_maxTimeLoadedAtLastDidLoadingProgress;
-#if DRAW_FRAME_RATE
- double m_frameCountWhilePlaying;
- double m_timeStartedPlaying;
- double m_timeStoppedPlaying;
-#endif
-
-};
-
-}
-
-#endif
-#endif
diff --git a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateTaskTimer.cpp b/Source/WebCore/platform/graphics/win/MediaPlayerPrivateTaskTimer.cpp
deleted file mode 100644
index 770e73e..0000000
--- a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateTaskTimer.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2009 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 "MediaPlayerPrivateTaskTimer.h"
-
-#include "QTMovieTask.h"
-
-namespace WebCore {
-
-MediaPlayerPrivateTaskTimer* MediaPlayerPrivateTaskTimer::s_timer = 0;
-
-void MediaPlayerPrivateTaskTimer::initialize()
-{
- if (s_timer)
- return;
-
- s_timer = new MediaPlayerPrivateTaskTimer;
-
- QTMovieTask::sharedTask()->setTaskTimerFuncs(setDelay, stopTaskTimer);
-}
-
-void MediaPlayerPrivateTaskTimer::setDelay(double delayInSeconds)
-{
- ASSERT(s_timer);
-
- s_timer->startOneShot(delayInSeconds);
-}
-
-void MediaPlayerPrivateTaskTimer::stopTaskTimer()
-{
- ASSERT(s_timer);
-
- s_timer->stop();
-}
-
-void MediaPlayerPrivateTaskTimer::fired()
-{
- QTMovieTask::sharedTask()->fireTaskClients();
-}
-
-}
diff --git a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateTaskTimer.h b/Source/WebCore/platform/graphics/win/MediaPlayerPrivateTaskTimer.h
deleted file mode 100644
index 10f861e..0000000
--- a/Source/WebCore/platform/graphics/win/MediaPlayerPrivateTaskTimer.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2009 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.
- */
-
-#ifndef MediaPlayerPrivateTaskTimer_h
-#define MediaPlayerPrivateTaskTimer_h
-
-#include "Timer.h"
-
-namespace WebCore {
-
-class MediaPlayerPrivateTaskTimer : TimerBase {
-public:
- static void initialize();
-
-private:
- static void setDelay(double);
- static void stopTaskTimer();
-
- void fired();
-
- static MediaPlayerPrivateTaskTimer* s_timer;
-};
-
-}
-
-#endif
diff --git a/Source/WebCore/platform/graphics/win/QTCFDictionary.cpp b/Source/WebCore/platform/graphics/win/QTCFDictionary.cpp
deleted file mode 100644
index 3c72792..0000000
--- a/Source/WebCore/platform/graphics/win/QTCFDictionary.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2007, 2008, 2009, 2010 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 "QTCFDictionary.h"
-
-#include <CFData.h>
-#include <windows.h>
-
-CFDataRef QTCFPropertyListCreateXMLData(CFAllocatorRef allocator, CFPropertyListRef propertyList)
-{
-
- typedef CFDataRef (* pfnCFPropertyListCreateXMLData)(CFAllocatorRef allocator, CFPropertyListRef propertyList);
- static pfnCFPropertyListCreateXMLData pCFPropertyListCreateXMLData = 0;
- if (!pCFPropertyListCreateXMLData) {
- HMODULE qtcfDLL = LoadLibraryW(L"QTCF.dll");
- if (qtcfDLL)
- pCFPropertyListCreateXMLData = reinterpret_cast<pfnCFPropertyListCreateXMLData>(GetProcAddress(qtcfDLL, "QTCF_CFPropertyListCreateXMLData"));
- }
-
- if (pCFPropertyListCreateXMLData)
- return pCFPropertyListCreateXMLData(allocator, propertyList);
- return 0;
-}
-
-CFDictionaryRef QTCFDictionaryCreateCopyWithDataCallback(CFAllocatorRef allocator, CFDictionaryRef dictionary, QTCFDictonaryCreateFromDataCallback callback)
-{
- ASSERT(dictionary);
- ASSERT(callback);
-
- CFDataRef data = QTCFPropertyListCreateXMLData(kCFAllocatorDefault, dictionary);
- if (!data)
- return 0;
- CFDictionaryRef outputDictionary = callback(allocator, CFDataGetBytePtr(data), CFDataGetLength(data));
- CFRelease(data);
-
- return outputDictionary;
-}
diff --git a/Source/WebCore/platform/graphics/win/QTCFDictionary.h b/Source/WebCore/platform/graphics/win/QTCFDictionary.h
deleted file mode 100644
index ff34328..0000000
--- a/Source/WebCore/platform/graphics/win/QTCFDictionary.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2007, 2008, 2009, 2010 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 QTCFDictionary_h
-#define QTCFDictionary_h
-
-#ifdef QTMOVIEWIN_EXPORTS
-#define QTMOVIEWIN_API __declspec(dllexport)
-#else
-#define QTMOVIEWIN_API __declspec(dllimport)
-#endif
-
-#include <CoreFoundation/CFBase.h>
-
-typedef const struct __CFDictionary * CFDictionaryRef;
-typedef const struct __CFAllocator * CFAllocatorRef;
-
-typedef CFDictionaryRef (* QTCFDictonaryCreateFromDataCallback)(CFAllocatorRef, const UInt8*, CFIndex);
-
-QTMOVIEWIN_API CFDictionaryRef QTCFDictionaryCreateCopyWithDataCallback(CFAllocatorRef, CFDictionaryRef, QTCFDictonaryCreateFromDataCallback);
-
-#endif
diff --git a/Source/WebCore/platform/graphics/win/QTDecompressionSession.cpp b/Source/WebCore/platform/graphics/win/QTDecompressionSession.cpp
deleted file mode 100644
index eeb3ca7..0000000
--- a/Source/WebCore/platform/graphics/win/QTDecompressionSession.cpp
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Copyright (C) 2010 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 "QTDecompressionSession.h"
-
-#include <ImageCompression.h>
-#include <algorithm>
-
-class QTDecompressionSessionClient {
-public:
- static void trackingCallback(void *decompressionTrackingRefCon, OSStatus,
- ICMDecompressionTrackingFlags decompressionTrackingFlags, CVPixelBufferRef pixelBuffer,
- TimeValue64, TimeValue64, ICMValidTimeFlags, void *, void *)
- {
- QTDecompressionSession* session = static_cast<QTDecompressionSession*>(decompressionTrackingRefCon);
- ASSERT(session);
-
- if (decompressionTrackingFlags & kICMDecompressionTracking_FrameDecoded)
- session->m_latestFrame = QTPixelBuffer(pixelBuffer);
- }
-};
-
-PassOwnPtr<QTDecompressionSession> QTDecompressionSession::create(unsigned long pixelFormat, size_t width, size_t height)
-{
- return adoptPtr(new QTDecompressionSession(pixelFormat, width, height));
-}
-
-QTDecompressionSession::QTDecompressionSession(unsigned long pixelFormat, size_t width, size_t height)
- : m_session(0)
- , m_pixelFormat(pixelFormat)
- , m_width(width)
- , m_height(height)
-{
- initializeSession();
-}
-
-QTDecompressionSession::~QTDecompressionSession()
-{
- if (m_session)
- ICMDecompressionSessionRelease(m_session);
-}
-
-void QTDecompressionSession::initializeSession()
-{
- if (m_session)
- return;
-
- ICMPixelFormatInfo pixelFormatInfo = {sizeof(ICMPixelFormatInfo), 0};
- if (ICMGetPixelFormatInfo(m_pixelFormat, &pixelFormatInfo) != noErr) {
- // The ICM does not know anything about the pixelFormat contained in
- // the pixel buffer, so it won't be able to convert it to RGBA.
- return;
- }
-
- // The depth and cType fields of the ImageDescriptionHandle are filled
- // out according to the instructions in Technical Q&A QA1183:
- // http://developer.apple.com/library/mac/#qa/qa2001/qa1183.html
- bool isIndexed = pixelFormatInfo.formatFlags & kICMPixelFormatIsIndexed;
- bool isQD = pixelFormatInfo.formatFlags & kICMPixelFormatIsSupportedByQD;
- bool isMonochrome = pixelFormatInfo.formatFlags & kICMPixelFormatIsMonochrome;
- bool hasAlpha = pixelFormatInfo.formatFlags & kICMPixelFormatHasAlphaChannel;
-
- unsigned int depth = 24; // The default depth is 24.
- if (hasAlpha)
- depth = 32; // Any pixel format with alpha gets a depth of 32.
- else if (isMonochrome) {
- // Grayscale pixel formats get depths 33 through 40, depending
- // on their bits per pixel. Yes, this means that 16-bit grayscale
- // and 8-bit grayscale have the same pixel depth.
- depth = 32 + std::min<unsigned int>(8, pixelFormatInfo.bitsPerPixel[0]);
- } else if (isIndexed) {
- // Indexed pixel formats get a depth of 1 through 8, depending on
- // the their bits per pixel.
- depth = pixelFormatInfo.bitsPerPixel[0];
- }
-
- // If QuickDraw supports the given pixel format, the cType should be kRawCodecType.
- // Otherwise, use the pixel format code for the cType. We are assuming the pixel
- // buffer is uncompressed.
- unsigned long cType = isQD ? kRawCodecType : m_pixelFormat;
-
- ImageDescriptionHandle description = (ImageDescriptionHandle)NewHandleClear(sizeof(ImageDescription));
- (**description).idSize = sizeof(ImageDescription);
- (**description).cType = cType;
- (**description).version = 2;
- (**description).spatialQuality = codecLosslessQuality;
- (**description).width = m_width;
- (**description).height = m_height;
- (**description).hRes = 72 << 16; // 72 DPI as a fixed-point number
- (**description).vRes = 72 << 16; // 72 DPI as a fixed-point number
- (**description).frameCount = 1;
- (**description).depth = depth;
- (**description).clutID = -1;
-
- // Create the mandatory ICMDecompressionSessionOptions, but leave
- // all the default values.
- ICMDecompressionSessionOptionsRef options = 0;
- ICMDecompressionSessionOptionsCreate(kCFAllocatorDefault, &options);
-
- CFDictionaryRef pixelBufferAttributes = QTPixelBuffer::createPixelBufferAttributesDictionary(QTPixelBuffer::ConfigureForCGImage);
-
- ICMDecompressionTrackingCallbackRecord callback = {
- QTDecompressionSessionClient::trackingCallback,
- this,
- };
-
- ICMDecompressionSessionCreate(kCFAllocatorDefault,
- description,
- options,
- pixelBufferAttributes,
- &callback,
- &m_session);
-
- if (pixelBufferAttributes)
- CFRelease(pixelBufferAttributes);
-
- ICMDecompressionSessionOptionsRelease(options);
- DisposeHandle((Handle)description);
-}
-
-bool QTDecompressionSession::canDecompress(QTPixelBuffer inBuffer)
-{
- return m_session
- && inBuffer.pixelFormatType() == m_pixelFormat
- && inBuffer.width() == m_width
- && inBuffer.height() == m_height;
-}
-
-QTPixelBuffer QTDecompressionSession::decompress(QTPixelBuffer inBuffer)
-{
- if (!canDecompress(inBuffer))
- return QTPixelBuffer();
-
- inBuffer.lockBaseAddress();
- ICMDecompressionSessionDecodeFrame(m_session,
- static_cast<UInt8*>(inBuffer.baseAddress()),
- inBuffer.dataSize(),
- 0, // frameOptions
- 0, // frameTime
- 0); // sourceFrameRefCon
-
- // Because we passed in 0 for frameTime, the above function
- // is synchronous, and the client callback will have been
- // called before the function returns, and m_latestFrame
- // will contain the newly decompressed frame.
- return m_latestFrame;
-}
diff --git a/Source/WebCore/platform/graphics/win/QTDecompressionSession.h b/Source/WebCore/platform/graphics/win/QTDecompressionSession.h
deleted file mode 100644
index 98964b2..0000000
--- a/Source/WebCore/platform/graphics/win/QTDecompressionSession.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2010 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 QTDecompressionSession_h
-#define QTDecompressionSession_h
-
-#ifdef QTMOVIEWIN_EXPORTS
-#define QTMOVIEWIN_API __declspec(dllexport)
-#else
-#define QTMOVIEWIN_API __declspec(dllimport)
-#endif
-
-#include "QTPixelBuffer.h"
-
-#include <wtf/PassOwnPtr.h>
-
-class QTDecompressionSessionClient;
-typedef struct OpaqueICMDecompressionSession* ICMDecompressionSessionRef;
-
-class QTMOVIEWIN_API QTDecompressionSession {
-public:
- static PassOwnPtr<QTDecompressionSession> create(unsigned long pixelFormat, size_t width, size_t height);
- ~QTDecompressionSession();
-
- bool canDecompress(QTPixelBuffer);
-
- // The resulting QTPixelBuffer will be a CG compatable ARGB pixel buffer.
- QTPixelBuffer decompress(QTPixelBuffer);
-
-private:
- friend class QTDecompressionSessionClient;
- QTDecompressionSession(unsigned long pixelFormat, size_t width, size_t height);
- void initializeSession();
-
- unsigned long m_pixelFormat;
- size_t m_width;
- size_t m_height;
- QTPixelBuffer m_latestFrame;
- ICMDecompressionSessionRef m_session;
-};
-
-#endif
diff --git a/Source/WebCore/platform/graphics/win/QTMovie.cpp b/Source/WebCore/platform/graphics/win/QTMovie.cpp
deleted file mode 100644
index 7ce28e5..0000000
--- a/Source/WebCore/platform/graphics/win/QTMovie.cpp
+++ /dev/null
@@ -1,924 +0,0 @@
-/*
- * Copyright (C) 2007, 2008, 2009, 2010, 2011 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 "QTMovie.h"
-
-#include "QTMovieTask.h"
-#include "QTMovieWinTimer.h"
-#include <FixMath.h>
-#include <GXMath.h>
-#include <Movies.h>
-#include <QTML.h>
-#include <QuickTimeComponents.h>
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
-#include <wtf/Assertions.h>
-#include <wtf/MathExtras.h>
-#include <wtf/Noncopyable.h>
-#include <wtf/Vector.h>
-
-using namespace std;
-
-static const long minimumQuickTimeVersion = 0x07300000; // 7.3
-
-static const long closedCaptionTrackType = 'clcp';
-static const long subTitleTrackType = 'sbtl';
-static const long mpeg4ObjectDescriptionTrackType = 'odsm';
-static const long mpeg4SceneDescriptionTrackType = 'sdsm';
-static const long closedCaptionDisplayPropertyID = 'disp';
-
-// 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 CFMutableArrayRef gSupportedTypes = 0;
-static SInt32 quickTimeVersion = 0;
-
-class QTMoviePrivate : public QTMovieTaskClient {
- WTF_MAKE_NONCOPYABLE(QTMoviePrivate);
-public:
- QTMoviePrivate();
- ~QTMoviePrivate();
- void task();
- void startTask();
- void endTask();
-
- void createMovieController();
- void cacheMovieScale();
-
- QTMovie* m_movieWin;
- Movie m_movie;
- MovieController m_movieController;
- bool m_tasking;
- bool m_disabled;
- Vector<QTMovieClient*> m_clients;
- long m_loadState;
- bool m_ended;
- bool m_seeking;
- float m_lastMediaTime;
- double m_lastLoadStateCheckTime;
- int m_width;
- int m_height;
- bool m_visible;
- long m_loadError;
- float m_widthScaleFactor;
- float m_heightScaleFactor;
- CFURLRef m_currentURL;
- float m_timeToRestore;
- float m_rateToRestore;
- bool m_privateBrowsing;
-#if !ASSERT_DISABLED
- bool m_scaleCached;
-#endif
-};
-
-QTMoviePrivate::QTMoviePrivate()
- : m_movieWin(0)
- , m_movie(0)
- , m_movieController(0)
- , m_tasking(false)
- , 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_loadError(0)
- , m_widthScaleFactor(1)
- , m_heightScaleFactor(1)
- , m_currentURL(0)
- , m_timeToRestore(-1.0f)
- , m_rateToRestore(-1.0f)
- , m_disabled(false)
- , m_privateBrowsing(false)
-#if !ASSERT_DISABLED
- , m_scaleCached(false)
-#endif
-{
-}
-
-QTMoviePrivate::~QTMoviePrivate()
-{
- endTask();
- if (m_movieController)
- DisposeMovieController(m_movieController);
- if (m_movie)
- DisposeMovie(m_movie);
- if (m_currentURL)
- CFRelease(m_currentURL);
-}
-
-void QTMoviePrivate::startTask()
-{
- if (!m_tasking) {
- QTMovieTask::sharedTask()->addTaskClient(this);
- m_tasking = true;
- }
- QTMovieTask::sharedTask()->updateTaskTimer();
-}
-
-void QTMoviePrivate::endTask()
-{
- if (m_tasking) {
- QTMovieTask::sharedTask()->removeTaskClient(this);
- m_tasking = false;
- }
- QTMovieTask::sharedTask()->updateTaskTimer();
-}
-
-void QTMoviePrivate::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 QTMovieLoadStateComplete.
- // This is different from QTKit API and seems strange.
- long loadState = m_loadError ? QTMovieLoadStateError : 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
- bool shouldRestorePlaybackState = false;
- bool movieNewlyPlayable = loadState >= QTMovieLoadStateLoaded && m_loadState < QTMovieLoadStateLoaded;
- m_loadState = loadState;
- if (movieNewlyPlayable) {
- cacheMovieScale();
- shouldRestorePlaybackState = true;
- }
-
- if (!m_movieController && m_loadState >= QTMovieLoadStateLoaded)
- createMovieController();
-
- for (size_t i = 0; i < m_clients.size(); ++i)
- m_clients[i]->movieLoadStateChanged(m_movieWin);
-
- if (shouldRestorePlaybackState && m_timeToRestore != -1.0f) {
- m_movieWin->setCurrentTime(m_timeToRestore);
- m_timeToRestore = -1.0f;
- m_movieWin->setRate(m_rateToRestore);
- m_rateToRestore = -1.0f;
- }
-
- if (m_disabled) {
- endTask();
- return;
- }
- }
- m_lastLoadStateCheckTime = systemTime();
- }
-
- bool ended = !!IsMovieDone(m_movie);
- if (ended != m_ended) {
- m_ended = ended;
- if (ended) {
- for (size_t i = 0; i < m_clients.size(); ++i)
- m_clients[i]->movieEnded(m_movieWin);
- }
- }
-
- float time = m_movieWin->currentTime();
- if (time < m_lastMediaTime || time >= m_lastMediaTime + cNonContinuousTimeChange || m_seeking) {
- m_seeking = false;
- for (size_t i = 0; i < m_clients.size(); ++i)
- m_clients[i]->movieTimeChanged(m_movieWin);
- }
- m_lastMediaTime = time;
-
- if (m_loadError)
- endTask();
- else
- QTMovieTask::sharedTask()->updateTaskTimer();
-}
-
-void QTMoviePrivate::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;
-
- // Disable automatic looping.
- MCDoAction(m_movieController, mcActionSetLooping, 0);
-}
-
-void QTMoviePrivate::cacheMovieScale()
-{
- Rect naturalRect;
- Rect initialRect;
-
- GetMovieNaturalBoundsRect(m_movie, &naturalRect);
- GetMovieBox(m_movie, &initialRect);
-
- float naturalWidth = naturalRect.right - naturalRect.left;
- float naturalHeight = naturalRect.bottom - naturalRect.top;
-
- if (naturalWidth)
- m_widthScaleFactor = (initialRect.right - initialRect.left) / naturalWidth;
- if (naturalHeight)
- m_heightScaleFactor = (initialRect.bottom - initialRect.top) / naturalHeight;
-#if !ASSERT_DISABLED
- m_scaleCached = true;
-#endif
-}
-
-QTMovie::QTMovie(QTMovieClient* client)
- : m_private(new QTMoviePrivate())
-{
- m_private->m_movieWin = this;
- if (client)
- m_private->m_clients.append(client);
- initializeQuickTime();
-}
-
-QTMovie::~QTMovie()
-{
- delete m_private;
-}
-
-void QTMovie::disableComponent(uint32_t cd[5])
-{
- ComponentDescription nullDesc = {'null', 'base', kAppleManufacturer, 0, 0};
- Component nullComp = FindNextComponent(0, &nullDesc);
- Component disabledComp = 0;
-
- while (disabledComp = FindNextComponent(disabledComp, (ComponentDescription*)&cd[0]))
- CaptureComponent(disabledComp, nullComp);
-}
-
-void QTMovie::addClient(QTMovieClient* client)
-{
- if (client)
- m_private->m_clients.append(client);
-}
-
-void QTMovie::removeClient(QTMovieClient* client)
-{
- size_t indexOfClient = m_private->m_clients.find(client);
- if (indexOfClient != notFound)
- m_private->m_clients.remove(indexOfClient);
-}
-
-void QTMovie::play()
-{
- m_private->m_timeToRestore = -1.0f;
-
- 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 QTMovie::pause()
-{
- m_private->m_timeToRestore = -1.0f;
-
- if (m_private->m_movieController)
- MCDoAction(m_private->m_movieController, mcActionPlay, 0);
- else
- StopMovie(m_private->m_movie);
- QTMovieTask::sharedTask()->updateTaskTimer();
-}
-
-float QTMovie::rate() const
-{
- if (!m_private->m_movie)
- return 0;
- return FixedToFloat(GetMovieRate(m_private->m_movie));
-}
-
-void QTMovie::setRate(float rate)
-{
- if (!m_private->m_movie)
- return;
- m_private->m_timeToRestore = -1.0f;
-
- if (m_private->m_movieController)
- MCDoAction(m_private->m_movieController, mcActionPrerollAndPlay, (void *)FloatToFixed(rate));
- else
- SetMovieRate(m_private->m_movie, FloatToFixed(rate));
- QTMovieTask::sharedTask()->updateTaskTimer();
-}
-
-float QTMovie::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 QTMovie::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 QTMovie::setCurrentTime(float time) const
-{
- if (!m_private->m_movie)
- return;
-
- m_private->m_timeToRestore = -1.0f;
-
- m_private->m_seeking = true;
- TimeScale scale = GetMovieTimeScale(m_private->m_movie);
- if (m_private->m_movieController) {
- QTRestartAtTimeRecord restart = { lroundf(time * scale) , 0 };
- MCDoAction(m_private->m_movieController, mcActionRestartAtTime, (void *)&restart);
- } else
- SetMovieTimeValue(m_private->m_movie, TimeValue(lroundf(time * scale)));
- QTMovieTask::sharedTask()->updateTaskTimer();
-}
-
-void QTMovie::setVolume(float volume)
-{
- if (!m_private->m_movie)
- return;
- SetMovieVolume(m_private->m_movie, static_cast<short>(volume * 256));
-}
-
-void QTMovie::setPreservesPitch(bool preservesPitch)
-{
- if (!m_private->m_movie || !m_private->m_currentURL)
- return;
-
- OSErr error;
- bool prop = false;
-
- error = QTGetMovieProperty(m_private->m_movie, kQTPropertyClass_Audio, kQTAudioPropertyID_RateChangesPreservePitch,
- sizeof(kQTAudioPropertyID_RateChangesPreservePitch), static_cast<QTPropertyValuePtr>(&prop), 0);
-
- if (error || prop == preservesPitch)
- return;
-
- m_private->m_timeToRestore = currentTime();
- m_private->m_rateToRestore = rate();
- load(m_private->m_currentURL, preservesPitch);
-}
-
-unsigned QTMovie::dataSize() const
-{
- if (!m_private->m_movie)
- return 0;
- return GetMovieDataSize(m_private->m_movie, 0, GetMovieDuration(m_private->m_movie));
-}
-
-float QTMovie::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 QTMovie::loadState() const
-{
- return m_private->m_loadState;
-}
-
-void QTMovie::getNaturalSize(int& width, int& height)
-{
- Rect rect = { 0, };
-
- if (m_private->m_movie)
- GetMovieNaturalBoundsRect(m_private->m_movie, &rect);
- width = (rect.right - rect.left) * m_private->m_widthScaleFactor;
- height = (rect.bottom - rect.top) * m_private->m_heightScaleFactor;
-}
-
-void QTMovie::loadPath(const UChar* url, int len, bool preservesPitch)
-{
- CFStringRef urlStringRef = CFStringCreateWithCharacters(kCFAllocatorDefault, reinterpret_cast<const UniChar*>(url), len);
- CFURLRef cfURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, urlStringRef, kCFURLWindowsPathStyle, false);
-
- load(cfURL, preservesPitch);
-
- if (cfURL)
- CFRelease(cfURL);
- if (urlStringRef)
- CFRelease(urlStringRef);
-}
-
-void QTMovie::load(const UChar* url, int len, bool preservesPitch)
-{
- CFStringRef urlStringRef = CFStringCreateWithCharacters(kCFAllocatorDefault, reinterpret_cast<const UniChar*>(url), len);
- CFURLRef cfURL = CFURLCreateWithString(kCFAllocatorDefault, urlStringRef, 0);
-
- load(cfURL, preservesPitch);
-
- if (cfURL)
- CFRelease(cfURL);
- if (urlStringRef)
- CFRelease(urlStringRef);
-}
-
-void QTMovie::load(CFURLRef url, bool preservesPitch)
-{
- if (!url)
- return;
-
- if (m_private->m_movie) {
- m_private->endTask();
- 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;
- m_private->m_loadState = 0;
- }
-
- // Define a property array for NewMovieFromProperties.
- QTNewMoviePropertyElement movieProps[9];
- ItemCount moviePropCount = 0;
-
- bool boolTrue = true;
-
- // Disable streaming support for now.
- CFStringRef scheme = CFURLCopyScheme(url);
- bool isRTSP = CFStringHasPrefix(scheme, CFSTR("rtsp:"));
- CFRelease(scheme);
-
- if (isRTSP) {
- m_private->m_loadError = noMovieFound;
- goto end;
- }
-
- if (m_private->m_currentURL) {
- if (m_private->m_currentURL != url) {
- CFRelease(m_private->m_currentURL);
- m_private->m_currentURL = url;
- CFRetain(url);
- }
- } else {
- m_private->m_currentURL = url;
- CFRetain(url);
- }
-
- // Add the movie data location to the property array
- movieProps[moviePropCount].propClass = kQTPropertyClass_DataLocation;
- movieProps[moviePropCount].propID = kQTDataLocationPropertyID_CFURL;
- movieProps[moviePropCount].propValueSize = sizeof(m_private->m_currentURL);
- movieProps[moviePropCount].propValueAddress = &(m_private->m_currentURL);
- 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++;
-
- movieProps[moviePropCount].propClass = kQTPropertyClass_Audio;
- movieProps[moviePropCount].propID = kQTAudioPropertyID_RateChangesPreservePitch;
- movieProps[moviePropCount].propValueSize = sizeof(preservesPitch);
- movieProps[moviePropCount].propValueAddress = &preservesPitch;
- movieProps[moviePropCount].propStatus = 0;
- moviePropCount++;
-
- bool allowCaching = !m_private->m_privateBrowsing;
- movieProps[moviePropCount].propClass = kQTPropertyClass_MovieInstantiation;
- movieProps[moviePropCount].propID = 'pers';
- movieProps[moviePropCount].propValueSize = sizeof(allowCaching);
- movieProps[moviePropCount].propValueAddress = &allowCaching;
- movieProps[moviePropCount].propStatus = 0;
- moviePropCount++;
-
- ASSERT(moviePropCount <= WTF_ARRAY_LENGTH(movieProps));
- m_private->m_loadError = NewMovieFromProperties(moviePropCount, movieProps, 0, 0, &m_private->m_movie);
-
-end:
- m_private->startTask();
- // get the load fail callback quickly
- if (m_private->m_loadError)
- QTMovieTask::sharedTask()->updateTaskTimer(0);
- else {
- OSType mode = kQTApertureMode_CleanAperture;
-
- // Set the aperture mode property on a movie to signal that we want aspect ratio
- // and clean aperture dimensions. Don't worry about errors, we can't do anything if
- // the installed version of QT doesn't support it and it isn't serious enough to
- // warrant failing.
- QTSetMovieProperty(m_private->m_movie, kQTPropertyClass_Visual, kQTVisualPropertyID_ApertureMode, sizeof(mode), &mode);
- }
-}
-
-void QTMovie::disableUnsupportedTracks(unsigned& enabledTrackCount, unsigned& totalTrackCount)
-{
- if (!m_private->m_movie) {
- totalTrackCount = 0;
- 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(closedCaptionTrackType);
- allowedTrackTypes->add(subTitleTrackType);
- allowedTrackTypes->add(mpeg4ObjectDescriptionTrackType);
- allowedTrackTypes->add(mpeg4SceneDescriptionTrackType);
- allowedTrackTypes->add(TimeCodeMediaType);
- allowedTrackTypes->add(TimeCode64MediaType);
- }
-
- long trackCount = GetMovieTrackCount(m_private->m_movie);
- enabledTrackCount = trackCount;
- totalTrackCount = 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)) {
-
- // Different mpeg variants import as different track types so check for the "mpeg
- // characteristic" instead of hard coding the (current) list of mpeg media types.
- if (GetMovieIndTrackType(m_private->m_movie, 1, 'mpeg', movieTrackCharacteristic | movieTrackEnabledOnly))
- continue;
-
- 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;
- }
- }
-}
-
-bool QTMovie::isDisabled() const
-{
- return m_private->m_disabled;
-}
-
-void QTMovie::setDisabled(bool b)
-{
- m_private->m_disabled = b;
-}
-
-
-bool QTMovie::hasVideo() const
-{
- if (!m_private->m_movie)
- return false;
- return (GetMovieIndTrackType(m_private->m_movie, 1, VisualMediaCharacteristic, movieTrackCharacteristic | movieTrackEnabledOnly));
-}
-
-bool QTMovie::hasAudio() const
-{
- if (!m_private->m_movie)
- return false;
- return (GetMovieIndTrackType(m_private->m_movie, 1, AudioMediaCharacteristic, movieTrackCharacteristic | movieTrackEnabledOnly));
-}
-
-QTTrackArray QTMovie::videoTracks() const
-{
- QTTrackArray tracks;
- long trackIndex = 1;
-
- while (Track theTrack = GetMovieIndTrackType(m_private->m_movie, trackIndex++, VisualMediaCharacteristic, movieTrackCharacteristic | movieTrackEnabledOnly))
- tracks.append(QTTrack::create(theTrack));
-
- return tracks;
-}
-
-bool QTMovie::hasClosedCaptions() const
-{
- if (!m_private->m_movie)
- return false;
- return GetMovieIndTrackType(m_private->m_movie, 1, closedCaptionTrackType, movieTrackMediaType);
-}
-
-void QTMovie::setClosedCaptionsVisible(bool visible)
-{
- if (!m_private->m_movie)
- return;
-
- Track ccTrack = GetMovieIndTrackType(m_private->m_movie, 1, closedCaptionTrackType, movieTrackMediaType);
- if (!ccTrack)
- return;
-
- Boolean doDisplay = visible;
- QTSetTrackProperty(ccTrack, closedCaptionTrackType, closedCaptionDisplayPropertyID, sizeof(doDisplay), &doDisplay);
-}
-
-long QTMovie::timeScale() const
-{
- if (!m_private->m_movie)
- return 0;
-
- return GetMovieTimeScale(m_private->m_movie);
-}
-
-static void getMIMETypeCallBack(const char* type);
-
-static void initializeSupportedTypes()
-{
- if (gSupportedTypes)
- return;
-
- gSupportedTypes = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
- 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.
- CFArrayAppendValue(gSupportedTypes, CFSTR("video/quicktime"));
-
- wkGetQuickTimeMIMETypeList(getMIMETypeCallBack);
-}
-
-static void getMIMETypeCallBack(const char* type)
-{
- ASSERT(type);
- CFStringRef cfType = CFStringCreateWithCString(kCFAllocatorDefault, type, kCFStringEncodingMacRoman);
- if (!cfType)
- return;
-
- // Filter out all non-audio or -video MIME Types, and only add each type once:
- if (CFStringHasPrefix(cfType, CFSTR("audio/")) || CFStringHasPrefix(cfType, CFSTR("video/"))) {
- CFRange range = CFRangeMake(0, CFArrayGetCount(gSupportedTypes));
- if (!CFArrayContainsValue(gSupportedTypes, range, cfType))
- CFArrayAppendValue(gSupportedTypes, cfType);
- }
-
- CFRelease(cfType);
-}
-
-unsigned QTMovie::countSupportedTypes()
-{
- initializeSupportedTypes();
- return static_cast<unsigned>(CFArrayGetCount(gSupportedTypes));
-}
-
-void QTMovie::getSupportedType(unsigned index, const UChar*& str, unsigned& len)
-{
- initializeSupportedTypes();
- ASSERT(index < CFArrayGetCount(gSupportedTypes));
-
- // Allocate sufficient buffer to hold any MIME type
- static UniChar* staticBuffer = 0;
- if (!staticBuffer)
- staticBuffer = new UniChar[32];
-
- CFStringRef cfstr = (CFStringRef)CFArrayGetValueAtIndex(gSupportedTypes, index);
- len = CFStringGetLength(cfstr);
- CFRange range = { 0, len };
- CFStringGetCharacters(cfstr, range, staticBuffer);
- str = reinterpret_cast<const UChar*>(staticBuffer);
-
-}
-
-CGAffineTransform QTMovie::getTransform() const
-{
- ASSERT(m_private->m_movie);
- MatrixRecord m = {0};
- GetMovieMatrix(m_private->m_movie, &m);
-
- ASSERT(!m.matrix[0][2]);
- ASSERT(!m.matrix[1][2]);
- CGAffineTransform transform = CGAffineTransformMake(
- Fix2X(m.matrix[0][0]),
- Fix2X(m.matrix[0][1]),
- Fix2X(m.matrix[1][0]),
- Fix2X(m.matrix[1][1]),
- Fix2X(m.matrix[2][0]),
- Fix2X(m.matrix[2][1]));
- return transform;
-}
-
-void QTMovie::setTransform(CGAffineTransform t)
-{
- ASSERT(m_private->m_movie);
- MatrixRecord m = {{
- {X2Fix(t.a), X2Fix(t.b), 0},
- {X2Fix(t.c), X2Fix(t.d), 0},
- {X2Fix(t.tx), X2Fix(t.ty), fract1},
- }};
-
- SetMovieMatrix(m_private->m_movie, &m);
- m_private->cacheMovieScale();
-}
-
-void QTMovie::resetTransform()
-{
- ASSERT(m_private->m_movie);
- SetMovieMatrix(m_private->m_movie, 0);
- m_private->cacheMovieScale();
-}
-
-void QTMovie::setPrivateBrowsingMode(bool privateBrowsing)
-{
- m_private->m_privateBrowsing = privateBrowsing;
- if (m_private->m_movie) {
- bool allowCaching = !m_private->m_privateBrowsing;
- QTSetMovieProperty(m_private->m_movie, 'cach', 'pers', sizeof(allowCaching), &allowCaching);
- }
-}
-
-bool QTMovie::initializeQuickTime()
-{
- static bool initialized = false;
- static bool initializationSucceeded = false;
- if (!initialized) {
- initialized = true;
- // Initialize and check QuickTime version
- OSErr result = InitializeQTML(kInitializeQTMLEnableDoubleBufferedSurface);
- 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();
- initializationSucceeded = true;
- }
- return initializationSucceeded;
-}
-
-Movie QTMovie::getMovieHandle() const
-{
- return m_private->m_movie;
-}
-
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
-{
- switch (fdwReason) {
- case DLL_PROCESS_ATTACH:
- return TRUE;
- case DLL_PROCESS_DETACH:
- case DLL_THREAD_ATTACH:
- case DLL_THREAD_DETACH:
- return FALSE;
- }
- ASSERT_NOT_REACHED();
- return FALSE;
-}
diff --git a/Source/WebCore/platform/graphics/win/QTMovie.h b/Source/WebCore/platform/graphics/win/QTMovie.h
deleted file mode 100644
index 3ab0506..0000000
--- a/Source/WebCore/platform/graphics/win/QTMovie.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright (C) 2007, 2008, 2009, 2010 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 QTMovie_h
-#define QTMovie_h
-
-#include "QTTrack.h"
-#include <wtf/Vector.h>
-#include <wtf/unicode/Unicode.h>
-
-#ifdef QTMOVIEWIN_EXPORTS
-#define QTMOVIEWIN_API __declspec(dllexport)
-#else
-#define QTMOVIEWIN_API __declspec(dllimport)
-#endif
-
-class QTMovie;
-class QTMoviePrivate;
-typedef struct MovieType** Movie;
-typedef Vector<RefPtr<QTTrack>> QTTrackArray;
-
-class QTMovieClient {
-public:
- virtual void movieEnded(QTMovie*) = 0;
- virtual void movieLoadStateChanged(QTMovie*) = 0;
- virtual void movieTimeChanged(QTMovie*) = 0;
-};
-
-enum {
- QTMovieLoadStateError = -1L,
- QTMovieLoadStateLoaded = 2000L,
- QTMovieLoadStatePlayable = 10000L,
- QTMovieLoadStatePlaythroughOK = 20000L,
- QTMovieLoadStateComplete = 100000L
-};
-
-typedef const struct __CFURL * CFURLRef;
-
-class QTMOVIEWIN_API QTMovie : public RefCounted<QTMovie> {
-public:
- static bool initializeQuickTime();
- static void taskTimerFired();
-
- static void disableComponent(uint32_t[5]);
-
- QTMovie(QTMovieClient*);
- ~QTMovie();
-
- void addClient(QTMovieClient*);
- void removeClient(QTMovieClient*);
-
- void loadPath(const UChar* url, int len, bool preservesPitch);
- void load(const UChar* url, int len, bool preservesPitch);
- void load(CFURLRef, bool preservesPitch);
-
- 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);
- void setPreservesPitch(bool);
-
- unsigned dataSize() const;
-
- void getNaturalSize(int& width, int& height);
-
- void disableUnsupportedTracks(unsigned& enabledTrackCount, unsigned& totalTrackCount);
-
- bool isDisabled() const;
- void setDisabled(bool);
-
- bool hasVideo() const;
- bool hasAudio() const;
-
- QTTrackArray videoTracks() const;
-
- bool hasClosedCaptions() const;
- void setClosedCaptionsVisible(bool);
-
- static unsigned countSupportedTypes();
- static void getSupportedType(unsigned index, const UChar*& str, unsigned& len);
-
- CGAffineTransform getTransform() const;
- void setTransform(CGAffineTransform);
- void resetTransform();
-
- Movie getMovieHandle() const;
-
- long timeScale() const;
-
- void setPrivateBrowsingMode(bool);
-
-private:
- QTMoviePrivate* m_private;
- friend class QTMoviePrivate;
-};
-
-#endif
diff --git a/Source/WebCore/platform/graphics/win/QTMovieGWorld.cpp b/Source/WebCore/platform/graphics/win/QTMovieGWorld.cpp
deleted file mode 100644
index 4be1bbb..0000000
--- a/Source/WebCore/platform/graphics/win/QTMovieGWorld.cpp
+++ /dev/null
@@ -1,465 +0,0 @@
-/*
- * Copyright (C) 2007, 2008, 2009, 2010 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 "QTMovieGWorld.h"
-
-#include "QTMovieTask.h"
-#include <GXMath.h>
-#include <Movies.h>
-#include <QTML.h>
-#include <QuickTimeComponents.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
-
-static LPCWSTR fullscreenQTMovieGWorldPointerProp = L"fullscreenQTMovieGWorldPointer";
-
-// 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<QTMovieGWorldPrivate*>* gTaskList;
-static Vector<CFStringRef>* gSupportedTypes = 0;
-static SInt32 quickTimeVersion = 0;
-
-class QTMovieGWorldPrivate : public QTMovieClient {
-public:
- QTMovieGWorldPrivate(QTMovieGWorld* movieWin);
- virtual ~QTMovieGWorldPrivate();
-
- void registerDrawingCallback();
- void unregisterDrawingCallback();
- void drawingComplete();
- void updateGWorld();
- void createGWorld();
- void deleteGWorld();
- void clearGWorld();
- void updateMovieSize();
-
- void setSize(int, int);
-
- virtual void movieEnded(QTMovie*);
- virtual void movieLoadStateChanged(QTMovie*);
- virtual void movieTimeChanged(QTMovie*);
-
- QTMovieGWorld* m_movieWin;
- RefPtr<QTMovie> m_qtMovie;
- Movie m_movie;
- QTMovieGWorldClient* m_client;
- long m_loadState;
- int m_width;
- int m_height;
- bool m_visible;
- GWorldPtr m_gWorld;
- int m_gWorldWidth;
- int m_gWorldHeight;
- GWorldPtr m_savedGWorld;
- float m_widthScaleFactor;
- float m_heightScaleFactor;
-#if !ASSERT_DISABLED
- bool m_scaleCached;
-#endif
- WindowPtr m_fullscreenWindow;
- GWorldPtr m_fullscreenOrigGWorld;
- Rect m_fullscreenRect;
- QTMovieGWorldFullscreenClient* m_fullscreenClient;
- char* m_fullscreenRestoreState;
- bool m_disabled;
-};
-
-QTMovieGWorldPrivate::QTMovieGWorldPrivate(QTMovieGWorld* movieWin)
- : m_movieWin(movieWin)
- , m_movie(0)
- , m_client(0)
- , m_loadState(0)
- , m_width(0)
- , m_height(0)
- , m_visible(false)
- , m_gWorld(0)
- , m_gWorldWidth(0)
- , m_gWorldHeight(0)
- , m_savedGWorld(0)
- , m_widthScaleFactor(1)
- , m_heightScaleFactor(1)
-#if !ASSERT_DISABLED
- , m_scaleCached(false)
-#endif
- , m_fullscreenWindow(0)
- , m_fullscreenOrigGWorld(0)
- , m_fullscreenClient(0)
- , m_fullscreenRestoreState(0)
- , m_disabled(false)
- , m_qtMovie(0)
-{
- Rect rect = { 0, 0, 0, 0 };
- m_fullscreenRect = rect;
-}
-
-QTMovieGWorldPrivate::~QTMovieGWorldPrivate()
-{
- ASSERT(!m_fullscreenWindow);
-
- if (m_gWorld)
- deleteGWorld();
-}
-
-pascal OSErr movieDrawingCompleteProc(Movie movie, long data)
-{
- UppParam param;
- param.longValue = data;
- QTMovieGWorldPrivate* mp = static_cast<QTMovieGWorldPrivate*>(param.ptr);
- if (mp)
- mp->drawingComplete();
- return 0;
-}
-
-void QTMovieGWorldPrivate::registerDrawingCallback()
-{
- if (!gMovieDrawingCompleteUPP)
- gMovieDrawingCompleteUPP = NewMovieDrawingCompleteUPP(movieDrawingCompleteProc);
-
- UppParam param;
- param.ptr = this;
- SetMovieDrawingCompleteProc(m_movie, movieDrawingCallWhenChanged, gMovieDrawingCompleteUPP, param.longValue);
-}
-
-void QTMovieGWorldPrivate::unregisterDrawingCallback()
-{
- SetMovieDrawingCompleteProc(m_movie, movieDrawingCallWhenChanged, 0, 0);
-}
-
-void QTMovieGWorldPrivate::drawingComplete()
-{
- if (!m_gWorld || m_movieWin->m_private->m_disabled || m_loadState < QTMovieLoadStateLoaded)
- return;
- m_client->movieNewImageAvailable(m_movieWin);
-}
-
-void QTMovieGWorldPrivate::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 QTMovieGWorldPrivate::createGWorld()
-{
- ASSERT(!m_gWorld);
- if (!m_movie || m_loadState < QTMovieLoadStateLoaded)
- 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, 0, 0, 0);
- if (err)
- return;
- GetMovieGWorld(m_movie, &m_savedGWorld, 0);
- SetMovieGWorld(m_movie, m_gWorld, 0);
- bounds.right = m_width;
- bounds.bottom = m_height;
- SetMovieBox(m_movie, &bounds);
-}
-
-void QTMovieGWorldPrivate::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 QTMovieGWorldPrivate::setSize(int width, int height)
-{
- if (m_width == width && m_height == height)
- return;
- m_width = width;
- m_height = height;
-
- // Do not change movie box before reaching load state loaded as we grab
- // the initial size when task() sees that state for the first time, and
- // we need the initial size to be able to scale movie properly.
- if (!m_movie || m_loadState < QTMovieLoadStateLoaded)
- return;
-
-#if !ASSERT_DISABLED
- ASSERT(m_scaleCached);
-#endif
-
- updateMovieSize();
-}
-
-void QTMovieGWorldPrivate::updateMovieSize()
-{
- if (!m_movie || m_loadState < QTMovieLoadStateLoaded)
- return;
-
- Rect bounds;
- bounds.top = 0;
- bounds.left = 0;
- bounds.right = m_width;
- bounds.bottom = m_height;
- SetMovieBox(m_movie, &bounds);
- updateGWorld();
-}
-
-
-void QTMovieGWorldPrivate::deleteGWorld()
-{
- ASSERT(m_gWorld);
- if (m_movie)
- SetMovieGWorld(m_movie, m_savedGWorld, 0);
- m_savedGWorld = 0;
- DisposeGWorld(m_gWorld);
- m_gWorld = 0;
- m_gWorldWidth = 0;
- m_gWorldHeight = 0;
-}
-
-void QTMovieGWorldPrivate::movieEnded(QTMovie*)
-{
- // Do nothing
-}
-
-void QTMovieGWorldPrivate::movieLoadStateChanged(QTMovie* movie)
-{
- long loadState = GetMovieLoadState(movie->getMovieHandle());
- 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
- bool movieNewlyPlayable = loadState >= QTMovieLoadStateLoaded && m_loadState < QTMovieLoadStateLoaded;
- m_loadState = loadState;
-
- if (movieNewlyPlayable) {
- updateMovieSize();
- if (m_visible)
- clearGWorld();
- }
- }
-}
-
-void QTMovieGWorldPrivate::movieTimeChanged(QTMovie*)
-{
- // Do nothing
-}
-
-QTMovieGWorld::QTMovieGWorld(QTMovieGWorldClient* client)
- : m_private(new QTMovieGWorldPrivate(this))
-{
- m_private->m_client = client;
-}
-
-QTMovieGWorld::~QTMovieGWorld()
-{
- delete m_private;
-}
-
-void QTMovieGWorld::setSize(int width, int height)
-{
- m_private->setSize(width, height);
- QTMovieTask::sharedTask()->updateTaskTimer();
-}
-
-void QTMovieGWorld::setVisible(bool b)
-{
- m_private->m_visible = b;
- m_private->updateGWorld();
-}
-
-void QTMovieGWorld::getCurrentFrameInfo(void*& buffer, unsigned& bitsPerPixel, unsigned& rowBytes, unsigned& width, unsigned& height)
-{
- if (!m_private->m_gWorld) {
- buffer = 0;
- bitsPerPixel = 0;
- rowBytes = 0;
- width = 0;
- height = 0;
- return;
- }
- PixMapHandle offscreenPixMap = GetGWorldPixMap(m_private->m_gWorld);
- buffer = (*offscreenPixMap)->baseAddr;
- bitsPerPixel = (*offscreenPixMap)->pixelSize;
- rowBytes = (*offscreenPixMap)->rowBytes & 0x3FFF;
- width = m_private->m_width;
- height = m_private->m_height;
-}
-
-void QTMovieGWorld::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 QTMovieGWorld::setDisabled(bool b)
-{
- m_private->m_disabled = b;
-}
-
-bool QTMovieGWorld::isDisabled() const
-{
- return m_private->m_disabled;
-}
-
-LRESULT QTMovieGWorld::fullscreenWndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
- QTMovieGWorld* movie = static_cast<QTMovieGWorld*>(GetPropW(wnd, fullscreenQTMovieGWorldPointerProp));
-
- if (message == WM_DESTROY)
- RemovePropW(wnd, fullscreenQTMovieGWorldPointerProp);
-
- if (!movie)
- return DefWindowProc(wnd, message, wParam, lParam);
-
- return movie->m_private->m_fullscreenClient->fullscreenClientWndProc(wnd, message, wParam, lParam);
-}
-
-HWND QTMovieGWorld::enterFullscreen(QTMovieGWorldFullscreenClient* client)
-{
- m_private->m_fullscreenClient = client;
-
- BeginFullScreen(&m_private->m_fullscreenRestoreState, 0, 0, 0, &m_private->m_fullscreenWindow, 0, fullScreenAllowEvents);
- QTMLSetWindowWndProc(m_private->m_fullscreenWindow, fullscreenWndProc);
- CreatePortAssociation(GetPortNativeWindow(m_private->m_fullscreenWindow), 0, 0);
-
- GetMovieBox(m_private->m_movie, &m_private->m_fullscreenRect);
- GetMovieGWorld(m_private->m_movie, &m_private->m_fullscreenOrigGWorld, 0);
- SetMovieGWorld(m_private->m_movie, reinterpret_cast<CGrafPtr>(m_private->m_fullscreenWindow), GetGWorldDevice(reinterpret_cast<CGrafPtr>(m_private->m_fullscreenWindow)));
-
- // Set the size of the box to preserve aspect ratio
- Rect rect = m_private->m_fullscreenWindow->portRect;
-
- float movieRatio = static_cast<float>(m_private->m_width) / m_private->m_height;
- int windowWidth = rect.right - rect.left;
- int windowHeight = rect.bottom - rect.top;
- float windowRatio = static_cast<float>(windowWidth) / windowHeight;
- int actualWidth = (windowRatio > movieRatio) ? (windowHeight * movieRatio) : windowWidth;
- int actualHeight = (windowRatio < movieRatio) ? (windowWidth / movieRatio) : windowHeight;
- int offsetX = (windowWidth - actualWidth) / 2;
- int offsetY = (windowHeight - actualHeight) / 2;
-
- rect.left = offsetX;
- rect.right = offsetX + actualWidth;
- rect.top = offsetY;
- rect.bottom = offsetY + actualHeight;
-
- SetMovieBox(m_private->m_movie, &rect);
- ShowHideTaskBar(true);
-
- // Set the 'this' pointer on the HWND
- HWND wnd = static_cast<HWND>(GetPortNativeWindow(m_private->m_fullscreenWindow));
- SetPropW(wnd, fullscreenQTMovieGWorldPointerProp, static_cast<HANDLE>(this));
-
- return wnd;
-}
-
-void QTMovieGWorld::exitFullscreen()
-{
- if (!m_private->m_fullscreenWindow)
- return;
-
- HWND wnd = static_cast<HWND>(GetPortNativeWindow(m_private->m_fullscreenWindow));
- DestroyPortAssociation(reinterpret_cast<CGrafPtr>(m_private->m_fullscreenWindow));
- SetMovieGWorld(m_private->m_movie, m_private->m_fullscreenOrigGWorld, 0);
- EndFullScreen(m_private->m_fullscreenRestoreState, 0L);
- SetMovieBox(m_private->m_movie, &m_private->m_fullscreenRect);
- m_private->m_fullscreenWindow = 0;
-}
-
-void QTMovieGWorld::setMovie(PassRefPtr<QTMovie> movie)
-{
- if (m_private->m_qtMovie) {
- m_private->unregisterDrawingCallback();
- m_private->m_qtMovie->removeClient(m_private);
- m_private->m_qtMovie = 0;
- m_private->m_movie = 0;
- }
-
- m_private->m_qtMovie = movie;
-
- if (m_private->m_qtMovie) {
- m_private->m_qtMovie->addClient(m_private);
- m_private->m_movie = m_private->m_qtMovie->getMovieHandle();
- m_private->registerDrawingCallback();
- }
-}
-
-QTMovie* QTMovieGWorld::movie() const
-{
- return m_private->m_qtMovie.get();
-}
diff --git a/Source/WebCore/platform/graphics/win/QTMovieGWorld.h b/Source/WebCore/platform/graphics/win/QTMovieGWorld.h
deleted file mode 100644
index 4f34c2c..0000000
--- a/Source/WebCore/platform/graphics/win/QTMovieGWorld.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2007, 2008, 2009, 2010 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 QTMovieGWorld_h
-#define QTMovieGWorld_h
-
-
-#include "QTMovie.h"
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-#include <windows.h>
-
-#ifdef QTMOVIEWIN_EXPORTS
-#define QTMOVIEWIN_API __declspec(dllexport)
-#else
-#define QTMOVIEWIN_API __declspec(dllimport)
-#endif
-
-class QTMovieGWorld;
-class QTMovieGWorldPrivate;
-
-class QTMovieGWorldClient {
-public:
- virtual void movieNewImageAvailable(QTMovieGWorld*) = 0;
-};
-
-class QTMovieGWorldFullscreenClient {
-public:
- virtual LRESULT fullscreenClientWndProc(HWND, UINT message, WPARAM, LPARAM) = 0;
-};
-
-class QTMOVIEWIN_API QTMovieGWorld : public RefCounted<QTMovieGWorld> {
-public:
- QTMovieGWorld(QTMovieGWorldClient*);
- ~QTMovieGWorld();
-
- void getNaturalSize(int& width, int& height);
- void setSize(int width, int height);
-
- void setVisible(bool);
- void paint(HDC, int x, int y);
- void getCurrentFrameInfo(void*& buffer, unsigned& bitsPerPixel, unsigned& rowBytes, unsigned& width, unsigned& height);
-
- void setDisabled(bool);
- bool isDisabled() const;
-
- // Returns the full-screen window created
- HWND enterFullscreen(QTMovieGWorldFullscreenClient*);
- void exitFullscreen();
-
- void setMovie(PassRefPtr<QTMovie>);
- QTMovie* movie() const;
-
-private:
- static LRESULT fullscreenWndProc(HWND, UINT message, WPARAM, LPARAM);
-
- QTMovieGWorldPrivate* m_private;
- friend class QTMovieGWorldPrivate;
-};
-
-#endif
diff --git a/Source/WebCore/platform/graphics/win/QTMovieTask.cpp b/Source/WebCore/platform/graphics/win/QTMovieTask.cpp
deleted file mode 100644
index 8713588..0000000
--- a/Source/WebCore/platform/graphics/win/QTMovieTask.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (C) 2007, 2008, 2009, 2010 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 "QTMovieTask.h"
-
-// Put Movies.h first so build failures here point clearly to QuickTime
-#include <Movies.h>
-
-#include <wtf/HashSet.h>
-#include <wtf/StdLibExtras.h>
-#include <wtf/Vector.h>
-
-QTMovieTask::QTMovieTask()
- : m_setTaskTimerDelay(0)
- , m_stopTaskTimer(0)
-{
-}
-
-QTMovieTask::~QTMovieTask()
-{
-}
-
-QTMovieTask* QTMovieTask::sharedTask()
-{
- static QTMovieTask* s_sharedTask = new QTMovieTask;
- return s_sharedTask;
-}
-
-void QTMovieTask::updateTaskTimer(double maxInterval, double minInterval)
-{
- ASSERT(m_setTaskTimerDelay);
- if (!m_setTaskTimerDelay)
- return;
-
- ASSERT(m_stopTaskTimer);
- if (!m_taskList.size() && m_stopTaskTimer) {
- m_stopTaskTimer();
- return;
- }
-
- long intervalInMS;
- OSStatus status = QTGetTimeUntilNextTask(&intervalInMS, 1000);
- double interval = intervalInMS / 1000.0;
- if (interval < minInterval)
- interval = minInterval;
- if (interval > maxInterval)
- interval = maxInterval;
- m_setTaskTimerDelay(interval);
-}
-
-void QTMovieTask::fireTaskClients()
-{
- Vector<QTMovieTaskClient*> clients;
- copyToVector(m_taskList, clients);
- for (Vector<QTMovieTaskClient*>::iterator i = clients.begin(); i != clients.end(); ++i)
- (*i)->task();
-}
-
-void QTMovieTask::addTaskClient(QTMovieTaskClient* client)
-{
- ASSERT(client);
- if (!client)
- return;
-
- m_taskList.add(client);
-}
-
-void QTMovieTask::removeTaskClient(QTMovieTaskClient* client)
-{
- ASSERT(client);
- if (!client)
- return;
-
- m_taskList.remove(client);
-}
-
-void QTMovieTask::setTaskTimerFuncs(SetTaskTimerDelayFunc setTaskTimerDelay, StopTaskTimerFunc stopTaskTimer)
-{
- m_setTaskTimerDelay = setTaskTimerDelay;
- m_stopTaskTimer = stopTaskTimer;
-}
-
diff --git a/Source/WebCore/platform/graphics/win/QTMovieTask.h b/Source/WebCore/platform/graphics/win/QTMovieTask.h
deleted file mode 100644
index 93e2210..0000000
--- a/Source/WebCore/platform/graphics/win/QTMovieTask.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2007, 2008, 2009, 2010 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 QTMovieTask_h
-#define QTMovieTask_h
-
-#include <wtf/HashSet.h>
-
-#ifdef QTMOVIEWIN_EXPORTS
-#define QTMOVIEWIN_API __declspec(dllexport)
-#else
-#define QTMOVIEWIN_API __declspec(dllimport)
-#endif
-
-class QTMovieTaskClient {
-public:
- virtual void task() = 0;
-};
-
-typedef void (*SetTaskTimerDelayFunc)(double);
-typedef void (*StopTaskTimerFunc)();
-
-class QTMOVIEWIN_API QTMovieTask {
-public:
- static QTMovieTask* sharedTask();
-
- void addTaskClient(QTMovieTaskClient* client);
- void removeTaskClient(QTMovieTaskClient*);
- void fireTaskClients();
-
- void updateTaskTimer(double maxInterval = 1.0, double minInterval = 1.0 / 30);
- void setTaskTimerFuncs(SetTaskTimerDelayFunc setTaskTimerDelay, StopTaskTimerFunc stopTaskTimer);
-
-protected:
- QTMovieTask();
- ~QTMovieTask();
-
- SetTaskTimerDelayFunc m_setTaskTimerDelay;
- StopTaskTimerFunc m_stopTaskTimer;
- HashSet<QTMovieTaskClient*> m_taskList;
-
-private:
- QTMovieTask(const QTMovieTask&);
- QTMovieTask& operator=(const QTMovieTask&);
-};
-
-#endif
diff --git a/Source/WebCore/platform/graphics/win/QTMovieVisualContext.cpp b/Source/WebCore/platform/graphics/win/QTMovieVisualContext.cpp
deleted file mode 100644
index 485a9f2..0000000
--- a/Source/WebCore/platform/graphics/win/QTMovieVisualContext.cpp
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * Copyright (C) 2007, 2008, 2009, 2010 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 "QTMovieVisualContext.h"
-
-#include "QTMovieTask.h"
-#include <CVBase.h>
-#include <CVHostTime.h>
-#include <ImageCompression.h>
-#include <Movies.h>
-#include <windows.h>
-#include <wtf/PassOwnPtr.h>
-
-struct QTCVTimeStamp {
- CVTimeStamp t;
-};
-
-class QTMovieVisualContextPriv {
-public:
- QTMovieVisualContextPriv(QTMovieVisualContext* parent, QTMovieVisualContextClient* client, QTPixelBuffer::Type contextType);
- ~QTMovieVisualContextPriv();
-
- bool isImageAvailableForTime(const QTCVTimeStamp*) const;
- QTPixelBuffer imageForTime(const QTCVTimeStamp*);
- void task();
-
- QTVisualContextRef visualContextRef();
-
- void setMovie(PassRefPtr<QTMovie>);
- QTMovie* movie() const;
-
- static void imageAvailableCallback(QTVisualContextRef visualContext, const CVTimeStamp *timeStamp, void *refCon);
-
-private:
- QTMovieVisualContext* m_parent;
- QTMovieVisualContextClient* m_client;
- QTVisualContextRef m_visualContext;
- RefPtr<QTMovie> m_movie;
-
-};
-
-static CFDictionaryRef createPixelBufferOptionsDictionary(QTPixelBuffer::Type contextType)
-{
- const void* key = kQTVisualContextPixelBufferAttributesKey;
- const void* value = QTPixelBuffer::createPixelBufferAttributesDictionary(contextType);
- CFDictionaryRef pixelBufferOptions = CFDictionaryCreate(kCFAllocatorDefault, &key, &value, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
- CFRelease(value);
- return pixelBufferOptions;
-}
-
-static CFDictionaryRef pixelBufferCreationOptions(QTPixelBuffer::Type contextType)
-{
- if (contextType == QTPixelBuffer::ConfigureForCAImageQueue) {
- static CFDictionaryRef imageQueueOptions = createPixelBufferOptionsDictionary(contextType);
- return imageQueueOptions;
- }
-
- ASSERT(contextType == QTPixelBuffer::ConfigureForCGImage);
- static CFDictionaryRef cgImageOptions = createPixelBufferOptionsDictionary(contextType);
- return cgImageOptions;
-}
-
-QTMovieVisualContextPriv::QTMovieVisualContextPriv(QTMovieVisualContext* parent, QTMovieVisualContextClient* client, QTPixelBuffer::Type contextType)
- : m_parent(parent)
- , m_client(client)
- , m_visualContext(0)
-{
- typedef OSStatus ( __cdecl *pfnQTPixelBufferContextCreate)(CFAllocatorRef, CFDictionaryRef, QTVisualContextRef*);
- static pfnQTPixelBufferContextCreate pPixelBufferContextCreate = 0;
- if (!pPixelBufferContextCreate) {
- HMODULE qtmlDLL = ::LoadLibraryW(L"QTMLClient.dll");
- if (!qtmlDLL)
- return;
- pPixelBufferContextCreate = reinterpret_cast<pfnQTPixelBufferContextCreate>(GetProcAddress(qtmlDLL, "QTPixelBufferContextCreate"));
- if (!pPixelBufferContextCreate)
- return;
- }
-
- OSStatus status = pPixelBufferContextCreate(kCFAllocatorDefault, pixelBufferCreationOptions(contextType), &m_visualContext);
- if (status == noErr && m_visualContext)
- QTVisualContextSetImageAvailableCallback(m_visualContext, &QTMovieVisualContextPriv::imageAvailableCallback, static_cast<void*>(this));
-}
-
-QTMovieVisualContextPriv::~QTMovieVisualContextPriv()
-{
- if (m_visualContext)
- QTVisualContextSetImageAvailableCallback(m_visualContext, 0, 0);
-}
-
-bool QTMovieVisualContextPriv::isImageAvailableForTime(const QTCVTimeStamp* timeStamp) const
-{
- if (!m_visualContext)
- return false;
-
- return QTVisualContextIsNewImageAvailable(m_visualContext, reinterpret_cast<const CVTimeStamp*>(timeStamp));
-}
-
-QTPixelBuffer QTMovieVisualContextPriv::imageForTime(const QTCVTimeStamp* timeStamp)
-{
- QTPixelBuffer pixelBuffer;
- if (m_visualContext) {
- CVImageBufferRef newImage = 0;
- OSStatus status = QTVisualContextCopyImageForTime(m_visualContext, kCFAllocatorDefault, reinterpret_cast<const CVTimeStamp*>(timeStamp), &newImage);
- if (status == noErr)
- pixelBuffer.adopt(newImage);
- }
- return pixelBuffer;
-}
-
-void QTMovieVisualContextPriv::task()
-{
- if (m_visualContext)
- QTVisualContextTask(m_visualContext);
-}
-
-QTVisualContextRef QTMovieVisualContextPriv::visualContextRef()
-{
- return m_visualContext;
-}
-
-void QTMovieVisualContextPriv::setMovie(PassRefPtr<QTMovie> movie)
-{
- if (movie == m_movie)
- return;
-
- if (m_movie) {
- SetMovieVisualContext(m_movie->getMovieHandle(), 0);
- m_movie = 0;
- }
-
- if (movie)
- OSStatus status = SetMovieVisualContext(movie->getMovieHandle(), m_visualContext);
-
- m_movie = movie;
-}
-
-QTMovie* QTMovieVisualContextPriv::movie() const
-{
- return m_movie.get();
-}
-
-void QTMovieVisualContextPriv::imageAvailableCallback(QTVisualContextRef visualContext, const CVTimeStamp *timeStamp, void *refCon)
-{
- if (!refCon)
- return;
-
- QTMovieVisualContextPriv* vc = static_cast<QTMovieVisualContextPriv*>(refCon);
- if (!vc->m_client)
- return;
-
- vc->m_client->imageAvailableForTime(reinterpret_cast<const QTCVTimeStamp*>(timeStamp));
-}
-
-PassRefPtr<QTMovieVisualContext> QTMovieVisualContext::create(QTMovieVisualContextClient* client, QTPixelBuffer::Type contextType)
-{
- return adoptRef(new QTMovieVisualContext(client, contextType));
-}
-
-QTMovieVisualContext::QTMovieVisualContext(QTMovieVisualContextClient* client, QTPixelBuffer::Type contextType)
- : m_private(adoptPtr(new QTMovieVisualContextPriv(this, client, contextType)))
-{
-}
-
-QTMovieVisualContext::~QTMovieVisualContext()
-{
-}
-
-bool QTMovieVisualContext::isImageAvailableForTime(const QTCVTimeStamp* timeStamp) const
-{
- return m_private->isImageAvailableForTime(timeStamp);
-}
-
-QTPixelBuffer QTMovieVisualContext::imageForTime(const QTCVTimeStamp* timeStamp)
-{
- return m_private->imageForTime(timeStamp);
-}
-
-void QTMovieVisualContext::task()
-{
- m_private->task();
-}
-
-QTVisualContextRef QTMovieVisualContext::visualContextRef()
-{
- return m_private->visualContextRef();
-}
-
-void QTMovieVisualContext::setMovie(PassRefPtr<QTMovie> movie)
-{
- m_private->setMovie(movie);
-}
-
-QTMovie* QTMovieVisualContext::movie() const
-{
- return m_private->movie();
-}
-
-double QTMovieVisualContext::currentHostTime()
-{
- return CVGetCurrentHostTime() / CVGetHostClockFrequency();
-}
diff --git a/Source/WebCore/platform/graphics/win/QTMovieVisualContext.h b/Source/WebCore/platform/graphics/win/QTMovieVisualContext.h
deleted file mode 100644
index a813e3c..0000000
--- a/Source/WebCore/platform/graphics/win/QTMovieVisualContext.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2007, 2008, 2009, 2010 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 QTMovieVisualContext_h
-#define QTMovieVisualContext_h
-
-#ifdef QTMOVIEWIN_EXPORTS
-#define QTMOVIEWIN_API __declspec(dllexport)
-#else
-#define QTMOVIEWIN_API __declspec(dllimport)
-#endif
-
-#include "QTMovie.h"
-#include "QTMovieTask.h"
-#include "QTPixelBuffer.h"
-#include <wtf/OwnPtr.h>
-#include <wtf/RefCounted.h>
-
-typedef const struct __CFDictionary* CFDictionaryRef;
-typedef struct OpaqueQTVisualContext* QTVisualContextRef;
-
-// QTCVTimeStamp is a struct containing only a CVTimeStamp. This is to
-// work around the inability of CVTimeStamp to be forward declared, in
-// addition to it being declared in different header files when building
-// the QTMovieWin and WebCore projects.
-struct QTCVTimeStamp;
-
-class QTMovieVisualContextClient {
-public:
- virtual void imageAvailableForTime(const QTCVTimeStamp*) = 0;
-};
-
-class QTMOVIEWIN_API QTMovieVisualContext : public RefCounted<QTMovieVisualContext> {
-public:
- static PassRefPtr<QTMovieVisualContext> create(QTMovieVisualContextClient*, QTPixelBuffer::Type);
- ~QTMovieVisualContext();
-
- bool isImageAvailableForTime(const QTCVTimeStamp*) const;
- QTPixelBuffer imageForTime(const QTCVTimeStamp*);
- void task();
-
- QTVisualContextRef visualContextRef();
-
- void setMovie(PassRefPtr<QTMovie>);
- QTMovie* movie() const;
-
- static double currentHostTime();
-
-protected:
- QTMovieVisualContext(QTMovieVisualContextClient*, QTPixelBuffer::Type);
- void setupVisualContext();
-
- friend class QTMovieVisualContextPriv;
- OwnPtr<QTMovieVisualContextPriv> m_private;
-};
-
-#endif
diff --git a/Source/WebCore/platform/graphics/win/QTMovieWinTimer.cpp b/Source/WebCore/platform/graphics/win/QTMovieWinTimer.cpp
deleted file mode 100644
index f6103ea..0000000
--- a/Source/WebCore/platform/graphics/win/QTMovieWinTimer.cpp
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2009 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 if (message == WM_TIMER && wParam == timerID) {
- stopSharedTimer();
- sharedTimerFiredFunction();
- } 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;
-}
-
-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;
- }
-
- stopSharedTimer();
- initializeOffScreenTimerWindow();
-
- // 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)
- PostMessage(timerWindowHandle, timerFiredMessage, 0, 0);
- } else
- timerID = SetTimer(timerWindowHandle, timerFiredMessage, intervalInMS, 0);
-}
-
-void stopSharedTimer()
-{
- if (timerID) {
- KillTimer(timerWindowHandle, 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/Source/WebCore/platform/graphics/win/QTMovieWinTimer.h b/Source/WebCore/platform/graphics/win/QTMovieWinTimer.h
deleted file mode 100644
index 976b310..0000000
--- a/Source/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 QTMovieWinTimer_h
-#define QTMovieWinTimer_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/Source/WebCore/platform/graphics/win/QTPixelBuffer.cpp b/Source/WebCore/platform/graphics/win/QTPixelBuffer.cpp
deleted file mode 100644
index 44a1b0e..0000000
--- a/Source/WebCore/platform/graphics/win/QTPixelBuffer.cpp
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * Copyright (C) 2007, 2008, 2009, 2010 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 "QTPixelBuffer.h"
-
-#include <CFNumber.h>
-#include <CFString.h>
-#include <CGColorSpace.h>
-#include <CGImage.h>
-#include <CVPixelBuffer.h>
-#include <QuickDraw.h>
-#include <memory.h>
-
-static OSStatus SetNumberValue(CFMutableDictionaryRef inDict, CFStringRef inKey, SInt32 inValue)
-{
- CFNumberRef number;
-
- number = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &inValue);
- if (!number)
- return coreFoundationUnknownErr;
-
- CFDictionarySetValue(inDict, inKey, number);
- CFRelease(number);
-
- return noErr;
-}
-
-CFDictionaryRef QTPixelBuffer::createPixelBufferAttributesDictionary(QTPixelBuffer::Type contextType)
-{
- static const CFStringRef kDirect3DCompatibilityKey = CFSTR("Direct3DCompatibility");
-
- CFMutableDictionaryRef pixelBufferAttributes = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
- if (contextType == QTPixelBuffer::ConfigureForCAImageQueue) {
- // Ask for D3D compatible pixel buffers so no further work is needed.
- CFDictionarySetValue(pixelBufferAttributes, kDirect3DCompatibilityKey, kCFBooleanTrue);
- } else {
- // Use the k32BGRAPixelFormat, as QuartzCore will be able to use the pixels directly,
- // without needing an additional copy or rendering pass.
- SetNumberValue(pixelBufferAttributes, kCVPixelBufferPixelFormatTypeKey, k32BGRAPixelFormat);
-
- // Set kCVPixelBufferBytesPerRowAlignmentKey to 16 to ensure that each row of pixels
- // starts at a 16 byte aligned address for most efficient data reading.
- SetNumberValue(pixelBufferAttributes, kCVPixelBufferBytesPerRowAlignmentKey, 16);
- CFDictionarySetValue(pixelBufferAttributes, kCVPixelBufferCGImageCompatibilityKey, kCFBooleanTrue);
- }
- return pixelBufferAttributes;
-}
-
-QTPixelBuffer::QTPixelBuffer()
- : m_pixelBuffer(0)
-{
-}
-
-QTPixelBuffer::QTPixelBuffer(const QTPixelBuffer& p)
- : m_pixelBuffer(p.m_pixelBuffer)
-{
- CVPixelBufferRetain(m_pixelBuffer);
-}
-
-QTPixelBuffer::QTPixelBuffer(CVPixelBufferRef ref)
- : m_pixelBuffer(ref)
-{
- CVPixelBufferRetain(m_pixelBuffer);
-}
-
-QTPixelBuffer::~QTPixelBuffer()
-{
- clear();
-}
-
-QTPixelBuffer& QTPixelBuffer::operator=(const QTPixelBuffer& p)
-{
- set(p.m_pixelBuffer);
- return *this;
-}
-
-void QTPixelBuffer::set(CVPixelBufferRef ref)
-{
- CVPixelBufferRetain(ref);
- CVPixelBufferRelease(m_pixelBuffer);
- m_pixelBuffer = ref;
-}
-
-CVPixelBufferRef QTPixelBuffer::pixelBufferRef()
-{
- return m_pixelBuffer;
-}
-
-void QTPixelBuffer::adopt(CVPixelBufferRef ref)
-{
- if (ref == m_pixelBuffer)
- return;
- CVPixelBufferRelease(m_pixelBuffer);
- m_pixelBuffer = ref;
-}
-
-void QTPixelBuffer::clear()
-{
- CVPixelBufferRelease(m_pixelBuffer);
- m_pixelBuffer = 0;
-}
-
-CVReturn QTPixelBuffer::lockBaseAddress()
-{
- return CVPixelBufferLockBaseAddress(m_pixelBuffer, 0);
-}
-
-CVReturn QTPixelBuffer::unlockBaseAddress()
-{
- return CVPixelBufferUnlockBaseAddress(m_pixelBuffer, 0);
-}
-
-void* QTPixelBuffer::baseAddress()
-{
- return CVPixelBufferGetBaseAddress(m_pixelBuffer);
-}
-
-size_t QTPixelBuffer::width() const
-{
- return CVPixelBufferGetWidth(m_pixelBuffer);
-}
-
-size_t QTPixelBuffer::height() const
-{
- return CVPixelBufferGetHeight(m_pixelBuffer);
-}
-
-unsigned long QTPixelBuffer::pixelFormatType() const
-{
- return CVPixelBufferGetPixelFormatType(m_pixelBuffer);
-}
-
-bool QTPixelBuffer::pixelFormatIs32ARGB() const
-{
- return CVPixelBufferGetPixelFormatType(m_pixelBuffer) == k32ARGBPixelFormat;
-}
-
-bool QTPixelBuffer::pixelFormatIs32BGRA() const
-{
- return CVPixelBufferGetPixelFormatType(m_pixelBuffer) == k32BGRAPixelFormat;
-}
-
-size_t QTPixelBuffer::bytesPerRow() const
-{
- return CVPixelBufferGetBytesPerRow(m_pixelBuffer);
-}
-
-size_t QTPixelBuffer::dataSize() const
-{
- return CVPixelBufferGetDataSize(m_pixelBuffer);
-}
-
-bool QTPixelBuffer::isPlanar() const
-{
- return CVPixelBufferIsPlanar(m_pixelBuffer);
-}
-
-size_t QTPixelBuffer::planeCount() const
-{
- return CVPixelBufferGetPlaneCount(m_pixelBuffer);
-}
-
-size_t QTPixelBuffer::widthOfPlane(size_t plane) const
-{
- return CVPixelBufferGetWidthOfPlane(m_pixelBuffer, plane);
-}
-
-size_t QTPixelBuffer::heightOfPlane(size_t plane) const
-{
- return CVPixelBufferGetHeightOfPlane(m_pixelBuffer, plane);
-}
-
-void* QTPixelBuffer::baseAddressOfPlane(size_t plane) const
-{
- return CVPixelBufferGetBaseAddressOfPlane(m_pixelBuffer, plane);
-}
-
-size_t QTPixelBuffer::bytesPerRowOfPlane(size_t plane) const
-{
- return CVPixelBufferGetBytesPerRowOfPlane(m_pixelBuffer, plane);
-}
-
-void QTPixelBuffer::getExtendedPixels(size_t* left, size_t* right, size_t* top, size_t* bottom) const
-{
- return CVPixelBufferGetExtendedPixels(m_pixelBuffer, left, right, top, bottom);
-}
-
-CFDictionaryRef QTPixelBuffer::attachments() const
-{
- return CVBufferGetAttachments(m_pixelBuffer, kCVAttachmentMode_ShouldPropagate);
-}
-
-void QTPixelBuffer::retainCallback(void* refcon)
-{
- CVPixelBufferRetain(static_cast<CVPixelBufferRef>(refcon));
-}
-
-void QTPixelBuffer::releaseCallback(void* refcon)
-{
- CVPixelBufferRelease(static_cast<CVPixelBufferRef>(refcon));
-}
-
-void QTPixelBuffer::imageQueueReleaseCallback(unsigned int type, uint64_t id, void* refcon)
-{
- CVPixelBufferRelease(static_cast<CVPixelBufferRef>(refcon));
-}
-
-void QTPixelBuffer::dataProviderReleaseBytePointerCallback(void* refcon, const void* pointer)
-{
- CVPixelBufferUnlockBaseAddress(static_cast<CVPixelBufferRef>(refcon), 0);
-}
-
-const void* QTPixelBuffer::dataProviderGetBytePointerCallback(void* refcon)
-{
- CVPixelBufferLockBaseAddress(static_cast<CVPixelBufferRef>(refcon), 0);
- return CVPixelBufferGetBaseAddress(static_cast<CVPixelBufferRef>(refcon));
-}
-
-size_t QTPixelBuffer::dataProviderGetBytesAtPositionCallback(void* refcon, void* buffer, size_t position, size_t count)
-{
- char* data = (char*)CVPixelBufferGetBaseAddress(static_cast<CVPixelBufferRef>(refcon));
- size_t size = CVPixelBufferGetDataSize(static_cast<CVPixelBufferRef>(refcon));
- if (size - position < count)
- count = size - position;
-
- memcpy(buffer, data+position, count);
- return count;
-}
-
-void QTPixelBuffer::dataProviderReleaseInfoCallback(void* refcon)
-{
- CVPixelBufferRelease(static_cast<CVPixelBufferRef>(refcon));
-}
diff --git a/Source/WebCore/platform/graphics/win/QTPixelBuffer.h b/Source/WebCore/platform/graphics/win/QTPixelBuffer.h
deleted file mode 100644
index 13630da..0000000
--- a/Source/WebCore/platform/graphics/win/QTPixelBuffer.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) 2007, 2008, 2009, 2010 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 QTPixelBuffer_h
-#define QTPixelBuffer_h
-
-#ifdef QTMOVIEWIN_EXPORTS
-#define QTMOVIEWIN_API __declspec(dllexport)
-#else
-#define QTMOVIEWIN_API __declspec(dllimport)
-#endif
-
-#include <stdint.h>
-
-typedef struct __CVBuffer *CVBufferRef;
-typedef CVBufferRef CVPixelBufferRef;
-typedef struct CGImage* CGImageRef;
-typedef int32_t CVReturn;
-typedef const struct __CFDictionary * CFDictionaryRef;
-
-// QTPixelBuffer wraps QuickTime's implementation of CVPixelBuffer, so its functions are
-// safe to call within WebKit.
-class QTMOVIEWIN_API QTPixelBuffer {
-public:
- enum Type { ConfigureForCGImage, ConfigureForCAImageQueue };
- static CFDictionaryRef createPixelBufferAttributesDictionary(Type);
-
- QTPixelBuffer();
- QTPixelBuffer(const QTPixelBuffer&);
- QTPixelBuffer(CVPixelBufferRef);
- QTPixelBuffer& operator=(const QTPixelBuffer&);
- ~QTPixelBuffer();
-
- void set(CVPixelBufferRef);
- CVPixelBufferRef pixelBufferRef();
- void adopt(CVPixelBufferRef);
- void clear();
-
- CVReturn lockBaseAddress();
- CVReturn unlockBaseAddress();
- void* baseAddress();
-
- size_t width() const;
- size_t height() const;
- unsigned long pixelFormatType() const;
- bool pixelFormatIs32ARGB() const;
- bool pixelFormatIs32BGRA() const;
- size_t bytesPerRow() const;
- size_t dataSize() const;
-
- bool isPlanar() const;
- size_t planeCount() const;
- size_t widthOfPlane(size_t) const;
- size_t heightOfPlane(size_t) const;
- void* baseAddressOfPlane(size_t) const;
- size_t bytesPerRowOfPlane(size_t) const;
-
- void getExtendedPixels(size_t* left, size_t* right, size_t* top, size_t* bottom) const;
- CFDictionaryRef attachments() const;
-
- // Generic CFRetain/CFRelease callbacks
- static void releaseCallback(void* refcon);
- static void retainCallback(void* refcon);
-
- // CAImageQueue callbacks
- static void imageQueueReleaseCallback(unsigned int type, uint64_t id, void* refcon);
-
- // CGDataProvider callbacks
- static void dataProviderReleaseBytePointerCallback(void* refcon, const void* pointer);
- static const void* dataProviderGetBytePointerCallback(void* refcon);
- static size_t dataProviderGetBytesAtPositionCallback(void* refcon, void* buffer, size_t position, size_t count);
- static void dataProviderReleaseInfoCallback(void* refcon);
-
-private:
- CVPixelBufferRef m_pixelBuffer;
-};
-
-#endif
diff --git a/Source/WebCore/platform/graphics/win/QTTrack.cpp b/Source/WebCore/platform/graphics/win/QTTrack.cpp
deleted file mode 100644
index bf80a81..0000000
--- a/Source/WebCore/platform/graphics/win/QTTrack.cpp
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (C) 2007, 2008, 2009, 2010 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 "QTTrack.h"
-
-#include <Movies.h>
-#include <QTML.h>
-
-using namespace std;
-
-class QTTrackPrivate {
- WTF_MAKE_NONCOPYABLE(QTTrackPrivate);
-public:
- QTTrackPrivate();
- ~QTTrackPrivate();
-
- QTTrack* m_track;
- Track m_trackHandle;
-};
-
-QTTrackPrivate::QTTrackPrivate()
- : m_track(0)
- , m_trackHandle(0)
-{
-}
-
-QTTrackPrivate::~QTTrackPrivate()
-{
- m_trackHandle = 0;
-}
-
-PassRefPtr<QTTrack> QTTrack::create(Track trackHandle)
-{
- return adoptRef(new QTTrack(trackHandle));
-}
-
-QTTrack::QTTrack(Track trackHandle)
- : m_private(new QTTrackPrivate())
-{
- m_private->m_track = this;
- m_private->m_trackHandle = trackHandle;
-}
-
-QTTrack::~QTTrack()
-{
- delete m_private;
-}
-
-bool QTTrack::isEnabled() const
-{
- ASSERT(m_private->m_track);
- return GetTrackEnabled(m_private->m_trackHandle);
-}
-
-void QTTrack::setEnabled(bool enabled)
-{
- ASSERT(m_private->m_trackHandle);
- SetTrackEnabled(m_private->m_trackHandle, enabled);
-}
-
-CGAffineTransform QTTrack::getTransform() const
-{
- ASSERT(m_private->m_trackHandle);
- MatrixRecord m = {0};
- GetTrackMatrix(m_private->m_trackHandle, &m);
-
- ASSERT(!m.matrix[0][2]);
- ASSERT(!m.matrix[1][2]);
- CGAffineTransform transform = CGAffineTransformMake(
- Fix2X(m.matrix[0][0]),
- Fix2X(m.matrix[0][1]),
- Fix2X(m.matrix[1][0]),
- Fix2X(m.matrix[1][1]),
- Fix2X(m.matrix[2][0]),
- Fix2X(m.matrix[2][1]));
-
- return transform;
-}
-
-void QTTrack::setTransform(CGAffineTransform t)
-{
- ASSERT(m_private->m_trackHandle);
- MatrixRecord m = {{
- {X2Fix(t.a), X2Fix(t.b), 0},
- {X2Fix(t.c), X2Fix(t.d), 0},
- {X2Fix(t.tx), X2Fix(t.ty), fract1},
- }};
-
- SetTrackMatrix(m_private->m_trackHandle, &m);
-}
-
-void QTTrack::resetTransform()
-{
- ASSERT(m_private->m_trackHandle);
- SetTrackMatrix(m_private->m_trackHandle, 0);
-}
-
diff --git a/Source/WebCore/platform/graphics/win/QTTrack.h b/Source/WebCore/platform/graphics/win/QTTrack.h
deleted file mode 100644
index 516a4f2..0000000
--- a/Source/WebCore/platform/graphics/win/QTTrack.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2007, 2008, 2009, 2010 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 QTTrack_h
-#define QTTrack_h
-
-#include <windows.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-
-#include <CoreGraphics/CGAffineTransform.h>
-
-#ifdef QTMOVIEWIN_EXPORTS
-#define QTMOVIEWIN_API __declspec(dllexport)
-#else
-#define QTMOVIEWIN_API __declspec(dllimport)
-#endif
-
-class QTTrack;
-class QTTrackPrivate;
-typedef struct TrackType** Track;
-
-class QTMOVIEWIN_API QTTrack : public RefCounted<QTTrack> {
-public:
- static PassRefPtr<QTTrack> create(Track);
- ~QTTrack();
-
- CGAffineTransform getTransform() const;
- void setTransform(CGAffineTransform);
- void resetTransform();
-
- bool isEnabled() const;
- void setEnabled(bool);
-
- Track getTrackHandle() const;
-private:
- QTTrack(Track);
- QTTrackPrivate* m_private;
- friend class QTTrackPrivate;
-};
-
-#endif
diff --git a/Source/WebCore/platform/graphics/win/RefCountedGDIHandle.h b/Source/WebCore/platform/graphics/win/RefCountedGDIHandle.h
deleted file mode 100644
index 65f66f1..0000000
--- a/Source/WebCore/platform/graphics/win/RefCountedGDIHandle.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008, 2010 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 RefCountedGDIHandle_h
-#define RefCountedGDIHandle_h
-
-#include <windows.h>
-#include <wtf/HashFunctions.h>
-#include <wtf/OwnPtr.h>
-#include <wtf/RefCounted.h>
-
-namespace WebCore {
-
-template <typename T> class RefCountedGDIHandle : public RefCounted<RefCountedGDIHandle<T> > {
-public:
- static PassRefPtr<RefCountedGDIHandle> create(T handle)
- {
- return adoptRef(new RefCountedGDIHandle<T>(handle));
- }
-
- static PassRefPtr<RefCountedGDIHandle<T> > createDeleted()
- {
- return adoptRef(new RefCountedGDIHandle<T>(reinterpret_cast<T>(-1)));
- }
-
- ~RefCountedGDIHandle()
- {
- if (m_handle != reinterpret_cast<T>(-1))
- WTF::deleteOwnedPtr(m_handle);
- }
-
- T handle() const
- {
- return m_handle;
- }
-
- unsigned hash() const
- {
- return WTF::PtrHash<T>::hash(m_handle);
- }
-
-private:
- RefCountedGDIHandle(T handle)
- : m_handle(handle)
- {
- }
-
- T m_handle;
-};
-
-} // namespace WebCore
-
-#endif // RefCountedGDIHandle_h
diff --git a/Source/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp b/Source/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp
deleted file mode 100644
index 9965526..0000000
--- a/Source/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp
+++ /dev/null
@@ -1,143 +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 "FloatRect.h"
-#include "Font.h"
-#include "FontCache.h"
-#include "FontDescription.h"
-#include "HWndDC.h"
-#include <ApplicationServices/ApplicationServices.h>
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
-#include <mlang.h>
-#include <unicode/uchar.h>
-#include <unicode/unorm.h>
-#include <winsock2.h>
-#include <wtf/MathExtras.h>
-#include <wtf/RetainPtr.h>
-#include <wtf/text/WTFString.h>
-
-namespace WebCore {
-
-using namespace std;
-
-void SimpleFontData::platformInit()
-{
- m_syntheticBoldOffset = m_platformData.syntheticBold() ? 1.0f : 0.f;
- m_scriptCache = 0;
- m_scriptFontProperties = 0;
- m_isSystemFont = false;
-
- if (m_platformData.useGDI())
- return initGDIFont();
-
- CGFontRef font = m_platformData.cgFont();
- int iAscent = CGFontGetAscent(font);
- int iDescent = CGFontGetDescent(font);
- int iLineGap = CGFontGetLeading(font);
- unsigned unitsPerEm = CGFontGetUnitsPerEm(font);
- float pointSize = m_platformData.size();
- float fAscent = scaleEmToUnits(iAscent, unitsPerEm) * pointSize;
- float fDescent = -scaleEmToUnits(iDescent, unitsPerEm) * pointSize;
- float fLineGap = scaleEmToUnits(iLineGap, unitsPerEm) * pointSize;
-
- if (!isCustomFont()) {
- HWndDC dc(0);
- HGDIOBJ oldFont = SelectObject(dc, m_platformData.hfont());
- int faceLength = GetTextFace(dc, 0, 0);
- Vector<WCHAR> faceName(faceLength);
- GetTextFace(dc, faceLength, faceName.data());
- m_isSystemFont = !wcscmp(faceName.data(), L"Lucida Grande");
- SelectObject(dc, oldFont);
-
- fAscent = ascentConsideringMacAscentHack(faceName.data(), fAscent, fDescent);
- }
-
- m_fontMetrics.setAscent(fAscent);
- m_fontMetrics.setDescent(fDescent);
- m_fontMetrics.setLineGap(fLineGap);
- m_fontMetrics.setLineSpacing(lroundf(fAscent) + lroundf(fDescent) + lroundf(fLineGap));
-
- GlyphPage* glyphPageZero = GlyphPageTreeNode::getRootChild(this, 0)->page();
- Glyph xGlyph = glyphPageZero ? glyphPageZero->glyphDataForCharacter('x').glyph : 0;
- if (xGlyph) {
- // Measure the actual character "x", since it's possible for it to extend below the baseline, and we need the
- // reported x-height to only include the portion of the glyph that is above the baseline.
- CGRect xBox;
- CGFontGetGlyphBBoxes(font, &xGlyph, 1, &xBox);
- m_fontMetrics.setXHeight(scaleEmToUnits(CGRectGetMaxY(xBox), unitsPerEm) * pointSize);
- } else {
- int iXHeight = CGFontGetXHeight(font);
- m_fontMetrics.setXHeight(scaleEmToUnits(iXHeight, unitsPerEm) * pointSize);
- }
-
- m_fontMetrics.setUnitsPerEm(unitsPerEm);
-}
-
-FloatRect SimpleFontData::platformBoundsForGlyph(Glyph glyph) const
-{
- if (!platformData().size())
- return FloatRect();
-
- if (m_platformData.useGDI())
- return boundsForGDIGlyph(glyph);
-
- CGRect box;
- CGFontGetGlyphBBoxes(m_platformData.cgFont(), &glyph, 1, &box);
- float pointSize = m_platformData.size();
- CGFloat scale = pointSize / fontMetrics().unitsPerEm();
- FloatRect boundingBox = CGRectApplyAffineTransform(box, CGAffineTransformMakeScale(scale, -scale));
- if (m_syntheticBoldOffset)
- boundingBox.setWidth(boundingBox.width() + m_syntheticBoldOffset);
-
- return boundingBox;
-}
-
-float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
-{
- if (!platformData().size())
- return 0;
-
- if (m_platformData.useGDI())
- return widthForGDIGlyph(glyph);
-
- CGFontRef font = m_platformData.cgFont();
- float pointSize = m_platformData.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/Source/WebCore/platform/graphics/win/SimpleFontDataWin.cpp b/Source/WebCore/platform/graphics/win/SimpleFontDataWin.cpp
deleted file mode 100644
index 01d9fc7..0000000
--- a/Source/WebCore/platform/graphics/win/SimpleFontDataWin.cpp
+++ /dev/null
@@ -1,265 +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 "Font.h"
-#include "FontCache.h"
-#include "FloatRect.h"
-#include "FontDescription.h"
-#include "HWndDC.h"
-#include <mlang.h>
-#include <wtf/MathExtras.h>
-
-namespace WebCore {
-
-const float cSmallCapsFontSizeMultiplier = 0.7f;
-
-static bool g_shouldApplyMacAscentHack;
-
-void SimpleFontData::setShouldApplyMacAscentHack(bool b)
-{
- g_shouldApplyMacAscentHack = b;
-}
-
-bool SimpleFontData::shouldApplyMacAscentHack()
-{
- return g_shouldApplyMacAscentHack;
-}
-
-float SimpleFontData::ascentConsideringMacAscentHack(const WCHAR* faceName, float ascent, float descent)
-{
- if (!shouldApplyMacAscentHack())
- return ascent;
-
- // 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 (!wcscmp(faceName, L"Times") || !wcscmp(faceName, L"Helvetica") || !wcscmp(faceName, L"Courier"))
- ascent += floorf(((ascent + descent) * 0.15f) + 0.5f);
-
- return ascent;
-}
-
-void SimpleFontData::initGDIFont()
-{
- if (!m_platformData.size()) {
- m_fontMetrics.reset();
- m_avgCharWidth = 0;
- m_maxCharWidth = 0;
- return;
- }
-
- HWndDC hdc(0);
- HGDIOBJ oldFont = SelectObject(hdc, m_platformData.hfont());
- OUTLINETEXTMETRIC metrics;
- GetOutlineTextMetrics(hdc, sizeof(metrics), &metrics);
- TEXTMETRIC& textMetrics = metrics.otmTextMetrics;
- float ascent = textMetrics.tmAscent;
- float descent = textMetrics.tmDescent;
- float lineGap = textMetrics.tmExternalLeading;
- m_fontMetrics.setAscent(ascent);
- m_fontMetrics.setDescent(descent);
- m_fontMetrics.setLineGap(lineGap);
- m_fontMetrics.setLineSpacing(lroundf(ascent) + lroundf(descent) + lroundf(lineGap));
- m_avgCharWidth = textMetrics.tmAveCharWidth;
- m_maxCharWidth = textMetrics.tmMaxCharWidth;
- float xHeight = ascent * 0.56f; // Best guess for xHeight if no x glyph is present.
-#if !OS(WINCE)
- GLYPHMETRICS gm;
- static const MAT2 identity = { 0, 1, 0, 0, 0, 0, 0, 1 };
- DWORD len = GetGlyphOutline(hdc, 'x', GGO_METRICS, &gm, 0, 0, &identity);
- if (len != GDI_ERROR && gm.gmptGlyphOrigin.y > 0)
- xHeight = gm.gmptGlyphOrigin.y;
-#endif
- m_fontMetrics.setXHeight(xHeight);
- m_fontMetrics.setUnitsPerEm(metrics.otmEMSquare);
-
- SelectObject(hdc, oldFont);
-}
-
-void SimpleFontData::platformCharWidthInit()
-{
- // GDI Fonts init charwidths in initGDIFont.
- if (!m_platformData.useGDI()) {
- m_avgCharWidth = 0.f;
- m_maxCharWidth = 0.f;
- initCharWidths();
- }
-}
-
-void SimpleFontData::platformDestroy()
-{
-#if !OS(WINCE)
- ScriptFreeCache(&m_scriptCache);
- delete m_scriptFontProperties;
-#endif
-}
-
-PassRefPtr<SimpleFontData> SimpleFontData::platformCreateScaledFontData(const FontDescription& fontDescription, float scaleFactor) const
-{
- float scaledSize = scaleFactor * m_platformData.size();
- if (isCustomFont()) {
- FontPlatformData scaledFont(m_platformData);
- scaledFont.setSize(scaledSize);
- return SimpleFontData::create(scaledFont, true, false);
- }
-
- LOGFONT winfont;
- GetObject(m_platformData.hfont(), sizeof(LOGFONT), &winfont);
- winfont.lfHeight = -lroundf(scaledSize * (m_platformData.useGDI() ? 1 : 32));
- HFONT hfont = CreateFontIndirect(&winfont);
- return SimpleFontData::create(FontPlatformData(hfont, scaledSize, m_platformData.syntheticBold(), m_platformData.syntheticOblique(), m_platformData.useGDI()), isCustomFont(), false);
-}
-
-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?
- IMLangFontLinkType* langFontLink = fontCache()->getFontLinkInterface();
- if (!langFontLink)
- return false;
-
- HWndDC dc(0);
-
- DWORD acpCodePages;
- langFontLink->CodePageToCodePages(CP_ACP, &acpCodePages);
-
- DWORD fontCodePages;
- langFontLink->GetFontCodePages(dc, m_platformData.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;
- }
-
- return true;
-}
-
-void SimpleFontData::determinePitch()
-{
- if (isCustomFont()) {
- m_treatAsFixedPitch = false;
- return;
- }
-
- // TEXTMETRICS have this. Set m_treatAsFixedPitch based off that.
- HWndDC dc(0);
- SaveDC(dc);
- SelectObject(dc, m_platformData.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);
-}
-
-FloatRect SimpleFontData::boundsForGDIGlyph(Glyph glyph) const
-{
-#if OS(WINCE)
- return FloatRect();
-#else
- HWndDC hdc(0);
- SetGraphicsMode(hdc, GM_ADVANCED);
- HGDIOBJ oldFont = SelectObject(hdc, m_platformData.hfont());
-
- GLYPHMETRICS gdiMetrics;
- static const MAT2 identity = { 0, 1, 0, 0, 0, 0, 0, 1 };
- GetGlyphOutline(hdc, glyph, GGO_METRICS | GGO_GLYPH_INDEX, &gdiMetrics, 0, 0, &identity);
-
- SelectObject(hdc, oldFont);
-
- return FloatRect(gdiMetrics.gmptGlyphOrigin.x, -gdiMetrics.gmptGlyphOrigin.y,
- gdiMetrics.gmBlackBoxX + m_syntheticBoldOffset, gdiMetrics.gmBlackBoxY);
-#endif
-}
-
-float SimpleFontData::widthForGDIGlyph(Glyph glyph) const
-{
- HWndDC hdc(0);
-#if !OS(WINCE)
- SetGraphicsMode(hdc, GM_ADVANCED);
-#endif
- HGDIOBJ oldFont = SelectObject(hdc, m_platformData.hfont());
-
-#if OS(WINCE)
- WCHAR c = glyph;
- SIZE fontSize;
- GetTextExtentPoint32W(hdc, &c, 1, &fontSize);
- float result = fontSize.cx * m_platformData.size() / 72.f;
-#else
- GLYPHMETRICS gdiMetrics;
- static const MAT2 identity = { 0, 1, 0, 0, 0, 0, 0, 1 };
- GetGlyphOutline(hdc, glyph, GGO_METRICS | GGO_GLYPH_INDEX, &gdiMetrics, 0, 0, &identity);
- float result = gdiMetrics.gmCellIncX + m_syntheticBoldOffset;
-#endif
-
- SelectObject(hdc, oldFont);
-
- return result;
-}
-
-#if !OS(WINCE)
-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) {
- HWndDC dc(0);
- SaveDC(dc);
- SelectObject(dc, m_platformData.hfont());
- ScriptGetFontProperties(dc, scriptCache(), m_scriptFontProperties);
- RestoreDC(dc, -1);
- }
- }
- return m_scriptFontProperties;
-}
-#endif
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/win/TransformationMatrixWin.cpp b/Source/WebCore/platform/graphics/win/TransformationMatrixWin.cpp
deleted file mode 100644
index 47806a2..0000000
--- a/Source/WebCore/platform/graphics/win/TransformationMatrixWin.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2009 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 "TransformationMatrix.h"
-
-#include <windows.h>
-
-namespace WebCore {
-
-TransformationMatrix::operator XFORM() const
-{
- XFORM xform;
- xform.eM11 = a();
- xform.eM12 = b();
- xform.eM21 = c();
- xform.eM22 = d();
- xform.eDx = e();
- xform.eDy = f();
-
- return xform;
-}
-
-}
diff --git a/Source/WebCore/platform/graphics/win/UniscribeController.cpp b/Source/WebCore/platform/graphics/win/UniscribeController.cpp
deleted file mode 100644
index aacfb16..0000000
--- a/Source/WebCore/platform/graphics/win/UniscribeController.cpp
+++ /dev/null
@@ -1,418 +0,0 @@
-/*
- * Copyright (C) 2007, 2008, 2009, 2010 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. 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 INC. 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 "HWndDC.h"
-#include "SimpleFontData.h"
-#include "TextRun.h"
-#include <wtf/MathExtras.h>
-
-using namespace WTF;
-using namespace Unicode;
-using namespace std;
-
-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, HashSet<const SimpleFontData*>* fallbackFonts)
- : m_font(*font)
- , m_run(run)
- , m_fallbackFonts(fallbackFonts)
- , m_minGlyphBoundingBoxX(numeric_limits<float>::max())
- , m_maxGlyphBoundingBoxX(numeric_limits<float>::min())
- , m_minGlyphBoundingBoxY(numeric_limits<float>::max())
- , m_maxGlyphBoundingBoxY(numeric_limits<float>::min())
- , m_end(run.length())
- , m_currentCharacter(0)
- , m_runWidthSoFar(0)
- , m_padding(run.expansion())
- , m_computingOffsetPosition(false)
- , m_includePartialGlyphs(false)
- , m_offsetX(0)
- , m_offsetPosition(0)
-{
- 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 = m_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;
-
- int length = offset - m_currentCharacter;
- if (length <= 0)
- return;
-
- // Itemize the string.
- const UChar* cp = m_run.data16(m_currentCharacter);
- 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() && !(category(*curr) & (Mark_NonSpacing | Mark_Enclosing | Mark_SpacingCombining)) && (newC = 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 && (category(c) & (Mark_NonSpacing | Mark_Enclosing | Mark_SpacingCombining));
- nextFontData = m_font.glyphDataForCharacter(*curr, false, forceSmallCaps ? SmallCapsVariant : AutoVariant).fontData;
- if (m_font.isSmallCaps()) {
- nextIsSmallCaps = forceSmallCaps || (newC = toUpper(c)) != c;
- if (nextIsSmallCaps)
- smallCapsBuffer[index] = forceSmallCaps ? c : newC;
- }
-
- if (m_fallbackFonts && nextFontData != fontData && fontData != m_font.primaryFont())
- m_fallbackFonts->add(fontData);
-
- 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) {
- if (m_fallbackFonts && nextFontData != m_font.primaryFont())
- m_fallbackFonts->add(nextFontData);
-
- 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.
- HWndDC hdc(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);
- }
-
- 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 back to their corresponding characters.
- Vector<int> spaceCharacters(glyphs.size());
- spaceCharacters.fill(-1);
-
- const float cLogicalScale = fontData->platformData().useGDI() ? 1.0f : 32.0f;
- float spaceWidth = fontData->spaceWidth() - fontData->syntheticBoldOffset();
- unsigned logicalSpaceWidth = spaceWidth * cLogicalScale;
-
- for (int k = 0; k < len; k++) {
- UChar ch = *(str + k);
- bool treatAsSpace = Font::treatAsSpace(ch);
- bool treatAsZeroWidthSpace = Font::treatAsZeroWidthSpace(ch);
- if (treatAsSpace || treatAsZeroWidthSpace) {
- // Substitute in the space glyph at the appropriate place in the glyphs
- // array.
- glyphs[clusters[k]] = fontData->spaceGlyph();
- advances[clusters[k]] = treatAsSpace ? logicalSpaceWidth : 0;
- if (treatAsSpace)
- spaceCharacters[clusters[k]] = m_currentCharacter + k + item.iCharPos;
- }
- }
-
- // 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->syntheticBoldOffset();
-
- 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.
- int characterIndex = spaceCharacters[k];
- // characterIndex is left at the initial value of -1 for glyphs that do not map back to treated-as-space characters.
- if (characterIndex != -1) {
- // 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 {
- m_padding -= m_padPerSpace;
- advance += m_padPerSpace;
- }
- }
-
- // Account for word-spacing.
- if (characterIndex > 0 && !Font::treatAsSpace(*m_run.data16(characterIndex - 1)) && m_font.wordSpacing())
- advance += m_font.wordSpacing();
- }
- }
-
- 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);
- }
-
- FloatRect glyphBounds = fontData->boundsForGlyph(glyph);
- glyphBounds.move(m_glyphOrigin.x(), m_glyphOrigin.y());
- m_minGlyphBoundingBoxX = min(m_minGlyphBoundingBoxX, glyphBounds.x());
- m_maxGlyphBoundingBoxX = max(m_maxGlyphBoundingBoxX, glyphBounds.maxX());
- m_minGlyphBoundingBoxY = min(m_minGlyphBoundingBoxY, glyphBounds.y());
- m_maxGlyphBoundingBoxY = max(m_maxGlyphBoundingBoxY, glyphBounds.maxY());
- m_glyphOrigin.move(advance + offsetX, -offsetY);
-
- // 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)
-{
- HWndDC hdc;
- 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.setHWnd(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);
-
- if (FAILED(shapeResult))
- return false;
-
- glyphs.shrink(glyphCount);
- visualAttributes.shrink(glyphCount);
-
- return true;
-}
-
-}
diff --git a/Source/WebCore/platform/graphics/win/UniscribeController.h b/Source/WebCore/platform/graphics/win/UniscribeController.h
deleted file mode 100644
index d4feb0a..0000000
--- a/Source/WebCore/platform/graphics/win/UniscribeController.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2007, 2008, 2009, 2010 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. 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 INC. 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 <wtf/Vector.h>
-
-namespace WebCore {
-
-class UniscribeController {
-public:
- UniscribeController(const Font*, const TextRun&, HashSet<const SimpleFontData*>* fallbackFonts = 0);
-
- // 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; }
-
- float minGlyphBoundingBoxX() const { return m_minGlyphBoundingBoxX; }
- float maxGlyphBoundingBoxX() const { return m_maxGlyphBoundingBoxX; }
- float minGlyphBoundingBoxY() const { return m_minGlyphBoundingBoxY; }
- float maxGlyphBoundingBoxY() const { return m_maxGlyphBoundingBoxY; }
-
-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;
- HashSet<const SimpleFontData*>* m_fallbackFonts;
- FloatPoint m_glyphOrigin;
- float m_minGlyphBoundingBoxX;
- float m_maxGlyphBoundingBoxX;
- float m_minGlyphBoundingBoxY;
- float m_maxGlyphBoundingBoxY;
-
- 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/Source/WebCore/platform/graphics/win/WKCAImageQueue.cpp b/Source/WebCore/platform/graphics/win/WKCAImageQueue.cpp
deleted file mode 100644
index 2bf0259..0000000
--- a/Source/WebCore/platform/graphics/win/WKCAImageQueue.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (C) 2010 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. 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 INC. 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 "WKCAImageQueue.h"
-
-#if USE(ACCELERATED_COMPOSITING)
-
-#include <CoreFoundation/CoreFoundation.h>
-#include <WebKitSystemInterface/WebKitSystemInterface.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/RetainPtr.h>
-
-namespace WebCore {
-
-class WKCAImageQueuePrivate {
-public:
- RetainPtr<CAImageQueueRef> m_imageQueue;
-};
-
-static CAImageQueueRef WKCAImageQueueRetain(CAImageQueueRef iq)
-{
- if (iq)
- return (CAImageQueueRef)CFRetain(iq);
- return 0;
-}
-
-static void WKCAImageQueueRelease(CAImageQueueRef iq)
-{
- if (iq)
- CFRelease(iq);
-}
-
-WKCAImageQueue::WKCAImageQueue(uint32_t width, uint32_t height, uint32_t capacity)
- : m_private(adoptPtr(new WKCAImageQueuePrivate()))
-{
- m_private->m_imageQueue.adoptCF(wkCAImageQueueCreate(width, height, capacity));
-}
-
-WKCAImageQueue::WKCAImageQueue(const WKCAImageQueue& o)
- : m_private(adoptPtr(new WKCAImageQueuePrivate()))
-{
- m_private->m_imageQueue = o.m_private->m_imageQueue;
-}
-
-WKCAImageQueue::~WKCAImageQueue(void)
-{
-}
-
-WKCAImageQueue& WKCAImageQueue::operator=(const WKCAImageQueue& o)
-{
- m_private->m_imageQueue = o.m_private->m_imageQueue;
- return *this;
-}
-
-size_t WKCAImageQueue::collect()
-{
- return wkCAImageQueueCollect(m_private->m_imageQueue.get());
-}
-
-bool WKCAImageQueue::insertImage(double t, unsigned int type, uint64_t id, uint32_t flags, ReleaseCallback release, void* info)
-{
- return wkCAImageQueueInsertImage(m_private->m_imageQueue.get(), t, type, id, flags, release, info);
-}
-
-uint64_t WKCAImageQueue::registerPixelBuffer(void *data, size_t data_size, size_t rowbytes, size_t width, size_t height, uint32_t pixel_format, CFDictionaryRef attachments, uint32_t flags)
-{
- return wkCAImageQueueRegisterPixelBuffer(m_private->m_imageQueue.get(), data, data_size, rowbytes, width, height, pixel_format, attachments, flags);
-}
-
-void WKCAImageQueue::setFlags(uint32_t mask, uint32_t flags)
-{
- wkCAImageQueueSetFlags(m_private->m_imageQueue.get(), mask, flags);
-}
-
-CFTypeRef WKCAImageQueue::get()
-{
- return m_private->m_imageQueue.get();
-}
-
-}
-
-#endif
diff --git a/Source/WebCore/platform/graphics/win/WKCAImageQueue.h b/Source/WebCore/platform/graphics/win/WKCAImageQueue.h
deleted file mode 100644
index 3d25b48..0000000
--- a/Source/WebCore/platform/graphics/win/WKCAImageQueue.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (C) 2010 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. 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 INC. 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 WKCAImageQueue_h
-#define WKCAImageQueue_h
-
-#if USE(ACCELERATED_COMPOSITING)
-
-typedef const void * CFTypeRef;
-typedef const struct __CFDictionary * CFDictionaryRef;
-
-#include <stdint.h>
-#include <wtf/OwnPtr.h>
-
-namespace WebCore {
-
-class WKCAImageQueuePrivate;
-
-class WKCAImageQueue {
-public:
- enum Flags {
- Async = 1U << 0,
- Fill = 1U << 1,
- Protected = 1U << 2,
- UseCleanAperture = 1U << 3,
- UseAspectRatio = 1U << 4,
- LowQualityColor = 1U << 5,
- };
-
- enum ImageType {
- Nil = 1,
- Surface,
- Buffer,
- IOSurface,
- };
-
- enum ImageFlags {
- Opaque = 1U << 0,
- Flush = 1U << 1,
- WillFlush = 1U << 2,
- Flipped = 1U << 3,
- WaitGPU = 1U << 4,
- };
-
- typedef void (*ReleaseCallback)(unsigned int type, uint64_t id, void* info);
-
- WKCAImageQueue(uint32_t width, uint32_t height, uint32_t capacity);
- ~WKCAImageQueue(void);
-
- size_t collect();
-
- bool insertImage(double t, unsigned int type, uint64_t id, uint32_t flags, ReleaseCallback release, void* info);
- uint64_t registerPixelBuffer(void *data, size_t data_size, size_t rowbytes, size_t width, size_t height, uint32_t pixel_format, CFDictionaryRef attachments, uint32_t flags);
-
- uint32_t flags() const;
- void setFlags(uint32_t mask, uint32_t flags);
-
- CFTypeRef get();
-
-private:
- WKCAImageQueue(const WKCAImageQueue&);
- WKCAImageQueue& operator=(const WKCAImageQueue&);
- OwnPtr<WKCAImageQueuePrivate> m_private;
-};
-
-}
-
-#endif
-
-#endif
diff --git a/Source/WebCore/platform/text/win/TextBreakIteratorInternalICUWin.cpp b/Source/WebCore/platform/text/win/TextBreakIteratorInternalICUWin.cpp
deleted file mode 100644
index e417e17..0000000
--- a/Source/WebCore/platform/text/win/TextBreakIteratorInternalICUWin.cpp
+++ /dev/null
@@ -1,41 +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* currentSearchLocaleID()
-{
- // FIXME: Should use system locale.
- return "";
-}
-
-const char* currentTextBreakLocaleID()
-{
- // Using en_US_POSIX now so word selection in address field works as expected as before (double-clicking
- // in a URL selects a word delimited by periods rather than selecting the entire URL).
- // However, this is not entirely correct - we should honor the system locale in the normal case.
- // FIXME: <rdar://problem/6786703> Should use system locale for text breaking
- return "en_US_POSIX";
-}
-
-}
diff --git a/Source/WebCore/platform/text/win/TextCodecWin.cpp b/Source/WebCore/platform/text/win/TextCodecWin.cpp
deleted file mode 100644
index 879af76..0000000
--- a/Source/WebCore/platform/text/win/TextCodecWin.cpp
+++ /dev/null
@@ -1,309 +0,0 @@
-/*
- * Copyright (C) 2007-2009 Torch Mobile, Inc. All rights reserved.
- * Copyright (C) 2010-2012 Patrick Gansterer <paroga@paroga.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 library is distributed in the hope that i 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 "TextCodecWin.h"
-
-#include "COMPtr.h"
-#include <mlang.h>
-#include <windows.h>
-#include <wtf/HashMap.h>
-#include <wtf/HashSet.h>
-#include <wtf/text/CString.h>
-#include <wtf/text/StringHash.h>
-#include <wtf/text/WTFString.h>
-
-namespace WebCore {
-
-struct CharsetInfo {
- CString m_name;
- String m_friendlyName;
- UINT m_codePage;
- Vector<CString> m_aliases;
-};
-
-class LanguageManager {
-private:
- LanguageManager();
-
- friend LanguageManager& languageManager();
-};
-
-// Usage: a lookup table used to get CharsetInfo with code page ID.
-// Key: code page ID. Value: charset information.
-static HashMap<UINT, CString>& codePageCharsets()
-{
- static HashMap<UINT, CString> cc;
- return cc;
-}
-
-static HashMap<String, CharsetInfo>& knownCharsets()
-{
- static HashMap<String, CharsetInfo> kc;
- return kc;
-}
-
-// Usage: a map that stores charsets that are supported by system. Sorted by name.
-// Key: charset. Value: code page ID.
-typedef HashSet<String> CharsetSet;
-static CharsetSet& supportedCharsets()
-{
- static CharsetSet sl;
- return sl;
-}
-
-static LanguageManager& languageManager()
-{
- static LanguageManager lm;
- return lm;
-}
-
-LanguageManager::LanguageManager()
-{
- COMPtr<IMultiLanguage> multiLanguage;
- if (FAILED(::CoCreateInstance(CLSID_CMultiLanguage, 0, CLSCTX_INPROC_SERVER, IID_IMultiLanguage, reinterpret_cast<LPVOID*>(&multiLanguage))))
- return;
-
- COMPtr<IEnumCodePage> enumInterface;
- if (FAILED(multiLanguage->EnumCodePages(MIMECONTF_BROWSER, &enumInterface)))
- return;
-
- MIMECPINFO cpInfo;
- ULONG ccpInfo;
- while (SUCCEEDED(enumInterface->Next(1, &cpInfo, &ccpInfo)) && ccpInfo) {
- if (!IsValidCodePage(cpInfo.uiCodePage))
- continue;
-
- HashMap<UINT, CString>::iterator i = codePageCharsets().find(cpInfo.uiCodePage);
-
- CString name(String(cpInfo.wszWebCharset).latin1());
- if (i == codePageCharsets().end()) {
- CharsetInfo info;
- info.m_codePage = cpInfo.uiCodePage;
- knownCharsets().set(name.data(), info);
- i = codePageCharsets().set(cpInfo.uiCodePage, name).iterator;
- }
- if (i != codePageCharsets().end()) {
- HashMap<String, CharsetInfo>::iterator j = knownCharsets().find(String(i->value.data(), i->value.length()));
- ASSERT(j != knownCharsets().end());
- CharsetInfo& info = j->value;
- info.m_name = i->value.data();
- info.m_friendlyName = cpInfo.wszDescription;
- info.m_aliases.append(name);
- info.m_aliases.append(String(cpInfo.wszHeaderCharset).latin1());
- info.m_aliases.append(String(cpInfo.wszBodyCharset).latin1());
- String cpName = "cp" + String::number(cpInfo.uiCodePage);
- info.m_aliases.append(cpName.latin1());
- supportedCharsets().add(i->value.data());
- }
- }
-}
-
-static UINT getCodePage(const char* name)
-{
- // Explicitly use a "const" reference to fix the silly VS build error
- // saying "==" is not found for const_iterator and iterator
- const HashMap<String, CharsetInfo>& charsets = knownCharsets();
- HashMap<String, CharsetInfo>::const_iterator i = charsets.find(name);
- return i == charsets.end() ? CP_ACP : i->value.m_codePage;
-}
-
-static PassOwnPtr<TextCodec> newTextCodecWin(const TextEncoding& encoding, const void*)
-{
- return adoptPtr(new TextCodecWin(getCodePage(encoding.name())));
-}
-
-TextCodecWin::TextCodecWin(UINT codePage)
- : m_codePage(codePage)
-{
-}
-
-TextCodecWin::~TextCodecWin()
-{
-}
-
-void TextCodecWin::registerExtendedEncodingNames(EncodingNameRegistrar registrar)
-{
- languageManager();
- for (CharsetSet::iterator i = supportedCharsets().begin(); i != supportedCharsets().end(); ++i) {
- HashMap<String, CharsetInfo>::iterator j = knownCharsets().find(*i);
- if (j != knownCharsets().end()) {
- registrar(j->value.m_name.data(), j->value.m_name.data());
- for (Vector<CString>::const_iterator alias = j->value.m_aliases.begin(); alias != j->value.m_aliases.end(); ++alias)
- registrar(alias->data(), j->value.m_name.data());
- }
- }
-}
-
-void TextCodecWin::registerExtendedCodecs(TextCodecRegistrar registrar)
-{
- languageManager();
- for (CharsetSet::iterator i = supportedCharsets().begin(); i != supportedCharsets().end(); ++i) {
- HashMap<String, CharsetInfo>::iterator j = knownCharsets().find(*i);
- if (j != knownCharsets().end())
- registrar(j->value.m_name.data(), newTextCodecWin, 0);
- }
-}
-
-static DWORD getCodePageFlags(UINT codePage)
-{
- if (codePage == 42) // Symbol
- return 0;
-
- // Microsoft says the flag must be 0 for the following code pages
- if (codePage > 50000) {
- if ((codePage >= 50220 && codePage <= 50222)
- || codePage == 50225
- || codePage == 50227
- || codePage == 50229
- || codePage == 52936
- || codePage == 54936
- || (codePage >= 57002 && codePage <= 57001)
- || codePage == 65000 // UTF-7
- )
- return 0;
- }
-
- return MB_PRECOMPOSED | MB_ERR_INVALID_CHARS;
-}
-
-static inline const char* findFirstNonAsciiCharacter(const char* bytes, size_t length)
-{
- for (const char* bytesEnd = bytes + length; bytes < bytesEnd; ++bytes) {
- if (*bytes & 0x80)
- break;
- }
- return bytes;
-}
-
-static void decodeInternal(Vector<UChar, 8192>& result, UINT codePage, const char* bytes, size_t length, size_t* left)
-{
- *left = length;
- if (!bytes || !length)
- return;
-
- DWORD flags = getCodePageFlags(codePage);
-
- int testLength = length;
- int untestedLength = length;
- for (;;) {
- int resultLength = MultiByteToWideChar(codePage, flags, bytes, testLength, 0, 0);
-
- if (resultLength > 0) {
- int oldSize = result.size();
- result.resize(oldSize + resultLength);
-
- MultiByteToWideChar(codePage, flags, bytes, testLength, result.data() + oldSize, resultLength);
-
- if (testLength == untestedLength) {
- *left = length - testLength;
- break;
- }
- untestedLength -= testLength;
- length -= testLength;
- bytes += testLength;
- } else {
- untestedLength = testLength - 1;
- if (!untestedLength) {
- *left = length;
- break;
- }
- }
- testLength = (untestedLength + 1) / 2;
- }
-}
-
-String TextCodecWin::decode(const char* bytes, size_t length, bool flush, bool stopOnError, bool& sawError)
-{
- if (!m_decodeBuffer.isEmpty()) {
- m_decodeBuffer.append(bytes, length);
- bytes = m_decodeBuffer.data();
- length = m_decodeBuffer.size();
- }
-
- size_t left;
- Vector<UChar, 8192> result;
- for (;;) {
- decodeInternal(result, m_codePage, bytes, length, &left);
- if (!left)
- break;
-
- if (!flush && left < 16)
- break;
-
- result.append(L'?');
- sawError = true;
- if (stopOnError)
- return String::adopt(result);
-
- if (left == 1)
- break;
-
- bytes += length - left + 1;
- length = left - 1;
- }
- if (left && !flush) {
- if (m_decodeBuffer.isEmpty())
- m_decodeBuffer.append(bytes + length - left, left);
- else {
- memmove(m_decodeBuffer.data(), bytes + length - left, left);
- m_decodeBuffer.resize(left);
- }
- } else
- m_decodeBuffer.clear();
-
- return String::adopt(result);
-}
-
-CString TextCodecWin::encode(const UChar* characters, size_t length, UnencodableHandling)
-{
- if (!characters || !length)
- return CString();
-
- int resultLength = WideCharToMultiByte(m_codePage, WC_COMPOSITECHECK, characters, length, 0, 0, 0, 0);
-
- // FIXME: We need to implement UnencodableHandling: QuestionMarksForUnencodables, EntitiesForUnencodables, and URLEncodedEntitiesForUnencodables.
-
- if (resultLength <= 0)
- return "?";
-
- char* characterBuffer;
- CString result = CString::newUninitialized(resultLength, characterBuffer);
-
- WideCharToMultiByte(m_codePage, WC_COMPOSITECHECK, characters, length, characterBuffer, resultLength, 0, 0);
-
- return result;
-}
-
-void TextCodecWin::enumerateSupportedEncodings(EncodingReceiver& receiver)
-{
- languageManager();
- for (CharsetSet::iterator i = supportedCharsets().begin(); i != supportedCharsets().end(); ++i) {
- HashMap<String, CharsetInfo>::iterator j = knownCharsets().find(*i);
- if (j != knownCharsets().end() && !receiver.receive(j->value.m_name.data(), j->value.m_friendlyName.charactersWithNullTermination(), j->value.m_codePage))
- break;
- }
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/text/win/TextCodecWin.h b/Source/WebCore/platform/text/win/TextCodecWin.h
deleted file mode 100644
index b69aba7..0000000
--- a/Source/WebCore/platform/text/win/TextCodecWin.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2006 Alexey Proskuryakov <ap@nypop.com>
- * Copyright (C) 2007-2009 Torch Mobile, Inc.
- * Copyright (C) 2010-2012 Patrick Gansterer <paroga@paroga.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 TextCodecWin_h
-#define TextCodecWin_h
-
-#include "TextCodec.h"
-#include "TextEncoding.h"
-#include <windows.h>
-#include <wtf/Vector.h>
-#include <wtf/text/WTFString.h>
-
-namespace WebCore {
-
-class TextCodecWin : public TextCodec {
-public:
- static void registerExtendedEncodingNames(EncodingNameRegistrar);
- static void registerExtendedCodecs(TextCodecRegistrar);
-
- TextCodecWin(UINT codePage);
- virtual ~TextCodecWin();
-
- virtual String decode(const char*, size_t length, bool flush, bool stopOnError, bool& sawError);
- virtual CString encode(const UChar*, size_t length, UnencodableHandling);
-
- struct EncodingInfo {
- String m_encoding;
- String m_friendlyName;
- };
-
- struct EncodingReceiver {
- // Return false to stop enumerating.
- virtual bool receive(const char* encoding, const wchar_t* friendlyName, unsigned int codePage) = 0;
- };
-
- static void enumerateSupportedEncodings(EncodingReceiver&);
-
-private:
- UINT m_codePage;
- Vector<char> m_decodeBuffer;
-};
-
-} // namespace WebCore
-
-#endif // TextCodecWin_h
diff --git a/Source/WebCore/platform/win/BString.cpp b/Source/WebCore/platform/win/BString.cpp
deleted file mode 100644
index fe0fe46..0000000
--- a/Source/WebCore/platform/win/BString.cpp
+++ /dev/null
@@ -1,197 +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 "KURL.h"
-#include <windows.h>
-#include <wtf/text/AtomicString.h>
-#include <wtf/text/WTFString.h>
-
-#if USE(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());
-}
-
-#if USE(CF)
-BString::BString(CFStringRef cfstr)
- : m_bstr(0)
-{
- if (!cfstr)
- return;
-
- const UniChar* uniChars = CFStringGetCharactersPtr(cfstr);
- if (uniChars) {
- m_bstr = SysAllocStringLen((LPCWSTR)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)
-{
- SysFreeString(m_bstr);
- m_bstr = bstr;
-}
-
-void BString::clear()
-{
- SysFreeString(m_bstr);
- m_bstr = 0;
-}
-
-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 !wcscmp((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 !wcscmp((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 !wcscmp(a, (BSTR)b);
-}
-
-bool operator !=(BSTR a, const BString& b)
-{
- return !(a==b);
-}
-
-}
diff --git a/Source/WebCore/platform/win/BString.h b/Source/WebCore/platform/win/BString.h
deleted file mode 100644
index dc1c27d..0000000
--- a/Source/WebCore/platform/win/BString.h
+++ /dev/null
@@ -1,79 +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
-
-#include <wtf/Forward.h>
-
-#if USE(CF)
-typedef const struct __CFString * CFStringRef;
-#endif
-
-typedef wchar_t* BSTR;
-
-namespace WebCore {
-
- class KURL;
-
- class BString {
- public:
- BString();
- BString(const wchar_t*);
- BString(const wchar_t*, size_t length);
- BString(const String&);
- BString(const AtomicString&);
- BString(const KURL&);
-#if USE(CF)
- BString(CFStringRef);
-#endif
- ~BString();
-
- void adoptBSTR(BSTR);
- void clear();
-
- BString(const BString&);
- BString& operator=(const BString&);
- BString& operator=(const BSTR&);
-
- BSTR* operator&() { ASSERT(!m_bstr); return &m_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/Source/WebCore/platform/win/BitmapInfo.cpp b/Source/WebCore/platform/win/BitmapInfo.cpp
deleted file mode 100644
index 610a27e..0000000
--- a/Source/WebCore/platform/win/BitmapInfo.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2009 Apple Inc. All Rights Reserved.
- * Copyright (C) 2009 Brent Fulgham
- * Copyright (C) 2007-2009 Torch Mobile, Inc. All Rights Reserved.
- * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.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 INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED 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 "BitmapInfo.h"
-
-#include <wtf/Assertions.h>
-
-namespace WebCore {
-
-BitmapInfo bitmapInfoForSize(int width, int height, BitmapInfo::BitCount bitCount)
-{
- BitmapInfo bitmapInfo;
- bitmapInfo.bmiHeader.biWidth = width;
- bitmapInfo.bmiHeader.biHeight = height;
- bitmapInfo.bmiHeader.biPlanes = 1;
- bitmapInfo.bmiHeader.biBitCount = bitCount;
- bitmapInfo.bmiHeader.biCompression = BI_RGB;
-
- return bitmapInfo;
-}
-
-BitmapInfo::BitmapInfo()
-{
- memset(&bmiHeader, 0, sizeof(bmiHeader));
- bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
-}
-
-BitmapInfo BitmapInfo::create(const IntSize& size, BitCount bitCount)
-{
- return bitmapInfoForSize(size.width(), size.height(), bitCount);
-}
-
-BitmapInfo BitmapInfo::createBottomUp(const IntSize& size, BitCount bitCount)
-{
- return bitmapInfoForSize(size.width(), -size.height(), bitCount);
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/win/BitmapInfo.h b/Source/WebCore/platform/win/BitmapInfo.h
deleted file mode 100644
index caf1b31..0000000
--- a/Source/WebCore/platform/win/BitmapInfo.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2009 Apple Inc. All Rights Reserved.
- * Copyright (C) 2009 Brent Fulgham
- * Copyright (C) 2007-2009 Torch Mobile, Inc. All Rights Reserved.
- * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.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 INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED 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 BitmapInfo_h
-#define BitmapInfo_h
-
-#include "IntSize.h"
-#include <windows.h>
-
-namespace WebCore {
-
-struct BitmapInfo : public BITMAPINFO {
- enum BitCount {
- BitCount1 = 1,
- BitCount4 = 4,
- BitCount8 = 8,
- BitCount16 = 16,
- BitCount24 = 24,
- BitCount32 = 32
- };
-
- BitmapInfo();
- static BitmapInfo create(const IntSize&, BitCount bitCount = BitCount32);
- static BitmapInfo createBottomUp(const IntSize&, BitCount bitCount = BitCount32);
-
- bool is16bit() const { return bmiHeader.biBitCount == 16; }
- bool is32bit() const { return bmiHeader.biBitCount == 32; }
- unsigned width() const { return abs(bmiHeader.biWidth); }
- unsigned height() const { return abs(bmiHeader.biHeight); }
- IntSize size() const { return IntSize(width(), height()); }
- unsigned bytesPerLine() const { return (width() * bmiHeader.biBitCount + 7) / 8; }
- unsigned paddedBytesPerLine() const { return (bytesPerLine() + 3) & ~0x3; }
- unsigned paddedWidth() const { return paddedBytesPerLine() * 8 / bmiHeader.biBitCount; }
- unsigned numPixels() const { return paddedWidth() * height(); }
-};
-
-} // namespace WebCore
-
-#endif // BitmapInfo_h
diff --git a/Source/WebCore/platform/win/COMPtr.h b/Source/WebCore/platform/win/COMPtr.h
deleted file mode 100644
index c1a925d..0000000
--- a/Source/WebCore/platform/win/COMPtr.h
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- * Copyright (C) 2007, 2010 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
-
-#ifndef NOMINMAX
-#define NOMINMAX
-#endif
-
-#include <unknwn.h>
-#include <wtf/Assertions.h>
-#include <wtf/HashTraits.h>
-
-#if !OS(WINCE)
-#include <guiddef.h>
-#endif
-
-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; }
-
- void clear();
- T* leakRef();
-
- 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 void COMPtr<T>::clear()
-{
- if (T* ptr = m_ptr) {
- m_ptr = 0;
- ptr->Release();
- }
-}
-
-template<typename T> inline T* COMPtr<T>::leakRef()
-{
- T* ptr = m_ptr;
- m_ptr = 0;
- return 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) { new (&slot) COMPtr<P>(HashTableDeletedValue); }
- static bool isDeletedValue(const COMPtr<P>& value) { return value.isHashTableDeletedValue(); }
- };
-
- 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/Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp b/Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp
deleted file mode 100644
index 3b71067..0000000
--- a/Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp
+++ /dev/null
@@ -1,844 +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 "DocumentFragment.h"
-#include "KURL.h"
-#include "TextEncoding.h"
-#include "markup.h"
-#include <shlobj.h>
-#include <wininet.h> // for INTERNET_MAX_URL_LENGTH
-#include <wtf/StringExtras.h>
-#include <wtf/text/CString.h>
-#include <wtf/text/StringBuilder.h>
-#include <wtf/text/WTFString.h>
-
-#if !OS(WINCE)
-#include <shlwapi.h>
-#endif
-
-#if USE(CF)
-#include <CoreFoundation/CoreFoundation.h>
-#include <wtf/RetainPtr.h>
-#endif
-
-namespace WebCore {
-
-#if USE(CF)
-FORMATETC* cfHDropFormat()
-{
- static FORMATETC urlFormat = {CF_HDROP, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
- return &urlFormat;
-}
-
-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 = CFURLGetString(cfURL.get());
-
- // Work around <rdar://problem/6708300>, where CFURLCreateWithFileSystemPath makes URLs with "localhost".
- if (url.startsWith("file://localhost/"))
- url.remove(7, 9);
-
- return true;
-}
-#endif
-
-static bool getDataMapItem(const DragDataMap* dataObject, FORMATETC* format, String& item)
-{
- DragDataMap::const_iterator found = dataObject->find(format->cfFormat);
- if (found == dataObject->end())
- return false;
- item = found->value[0];
- return true;
-}
-
-static bool getWebLocData(IDataObject* dataObject, String& url, String* title)
-{
- bool succeeded = false;
-#if USE(CF)
- WCHAR filename[MAX_PATH];
- WCHAR urlBuffer[INTERNET_MAX_URL_LENGTH];
-
- STGMEDIUM medium;
- if (FAILED(dataObject->GetData(cfHDropFormat(), &medium)))
- return false;
-
- HDROP hdrop = static_cast<HDROP>(GlobalLock(medium.hGlobal));
-
- if (!hdrop)
- return false;
-
- if (!DragQueryFileW(hdrop, 0, filename, WTF_ARRAY_LENGTH(filename)))
- goto exit;
-
- if (_wcsicmp(PathFindExtensionW(filename), L".url"))
- goto exit;
-
- if (!GetPrivateProfileStringW(L"InternetShortcut", L"url", 0, urlBuffer, WTF_ARRAY_LENGTH(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);
-#endif
- return succeeded;
-}
-
-static bool getWebLocData(const DragDataMap* dataObject, String& url, String* title)
-{
-#if USE(CF)
- WCHAR filename[MAX_PATH];
- WCHAR urlBuffer[INTERNET_MAX_URL_LENGTH];
-
- if (!dataObject->contains(cfHDropFormat()->cfFormat))
- return false;
-
- wcscpy(filename, dataObject->get(cfHDropFormat()->cfFormat)[0].charactersWithNullTermination());
- if (_wcsicmp(PathFindExtensionW(filename), L".url"))
- return false;
-
- if (!GetPrivateProfileStringW(L"InternetShortcut", L"url", 0, urlBuffer, WTF_ARRAY_LENGTH(urlBuffer), filename))
- return false;
-
- if (title) {
- PathRemoveExtension(filename);
- *title = filename;
- }
-
- url = urlBuffer;
- return true;
-#else
- return false;
-#endif
-}
-
-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 = static_cast<PWSTR>(GlobalLock(cbData));
- _snwprintf(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 String getFullCFHTML(IDataObject* data)
-{
- STGMEDIUM store;
- if (SUCCEEDED(data->GetData(htmlFormat(), &store))) {
- // MS HTML Format parsing
- char* data = static_cast<char*>(GlobalLock(store.hGlobal));
- SIZE_T dataSize = ::GlobalSize(store.hGlobal);
- String cfhtml(UTF8Encoding().decode(data, dataSize));
- GlobalUnlock(store.hGlobal);
- ReleaseStgMedium(&store);
- return cfhtml;
- }
- return String();
-}
-
-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());
-}
-
-// Find the markup between "<!--StartFragment -->" and "<!--EndFragment -->", accounting for browser quirks.
-static String extractMarkupFromCFHTML(const String& cfhtml)
-{
- unsigned markupStart = cfhtml.find("<html", 0, false);
- unsigned tagStart = cfhtml.find("startfragment", markupStart, false);
- unsigned fragmentStart = cfhtml.find('>', tagStart) + 1;
- unsigned tagEnd = cfhtml.find("endfragment", fragmentStart, false);
- unsigned fragmentEnd = cfhtml.reverseFind('<', tagEnd);
- return cfhtml.substring(fragmentStart, fragmentEnd - fragmentStart).stripWhiteSpace();
-}
-
-// Documentation for the CF_HTML format is available at http://msdn.microsoft.com/workshop/networking/clipboard/htmlclipboard.asp
-void markupToCFHTML(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);
-
- unsigned headerBufferLength = startHTMLOffset + 1; // + 1 for '\0' terminator.
- char* headerBuffer = (char*)malloc(headerBufferLength);
- snprintf(headerBuffer, headerBufferLength, header, startHTMLOffset, endHTMLOffset, startFragmentOffset, endFragmentOffset);
- append(result, CString(headerBuffer));
- free(headerBuffer);
- 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
-}
-
-void replaceNewlinesWithWindowsStyleNewlines(String& str)
-{
- DEFINE_STATIC_LOCAL(String, windowsNewline, (ASCIILiteral("\r\n")));
- StringBuilder result;
- for (unsigned index = 0; index < str.length(); ++index) {
- if (str[index] != '\n' || (index > 0 && str[index - 1] == '\r'))
- result.append(str[index]);
- else
- result.append(windowsNewline);
- }
- str = result.toString();
-}
-
-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;
-}
-
-FORMATETC* fileDescriptorFormat()
-{
- static UINT cf = RegisterClipboardFormat(CFSTR_FILEDESCRIPTOR);
- static FORMATETC fileDescriptorFormat = { cf, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
- return &fileDescriptorFormat;
-}
-
-FORMATETC* fileContentFormatZero()
-{
- static UINT cf = RegisterClipboardFormat(CFSTR_FILECONTENTS);
- static FORMATETC fileContentFormat = { cf, 0, DVASPECT_CONTENT, 0, TYMED_HGLOBAL };
- return &fileContentFormat;
-}
-
-void getFileDescriptorData(IDataObject* dataObject, int& size, String& pathname)
-{
- STGMEDIUM store;
- size = 0;
- if (FAILED(dataObject->GetData(fileDescriptorFormat(), &store)))
- return;
-
- FILEGROUPDESCRIPTOR* fgd = static_cast<FILEGROUPDESCRIPTOR*>(GlobalLock(store.hGlobal));
- size = fgd->fgd[0].nFileSizeLow;
- pathname = fgd->fgd[0].cFileName;
-
- GlobalUnlock(store.hGlobal);
- ::ReleaseStgMedium(&store);
-}
-
-void getFileContentData(IDataObject* dataObject, int size, void* dataBlob)
-{
- STGMEDIUM store;
- if (FAILED(dataObject->GetData(fileContentFormatZero(), &store)))
- return;
- void* data = GlobalLock(store.hGlobal);
- ::CopyMemory(dataBlob, data, size);
-
- GlobalUnlock(store.hGlobal);
- ::ReleaseStgMedium(&store);
-}
-
-void setFileDescriptorData(IDataObject* dataObject, int size, const String& passedPathname)
-{
- String pathname = passedPathname;
-
- STGMEDIUM medium = { 0 };
- medium.tymed = TYMED_HGLOBAL;
-
- medium.hGlobal = ::GlobalAlloc(GPTR, sizeof(FILEGROUPDESCRIPTOR));
- if (!medium.hGlobal)
- return;
-
- FILEGROUPDESCRIPTOR* fgd = static_cast<FILEGROUPDESCRIPTOR*>(GlobalLock(medium.hGlobal));
- ::ZeroMemory(fgd, sizeof(FILEGROUPDESCRIPTOR));
- fgd->cItems = 1;
- fgd->fgd[0].dwFlags = FD_FILESIZE;
- fgd->fgd[0].nFileSizeLow = size;
-
- int maxSize = std::min<int>(pathname.length(), WTF_ARRAY_LENGTH(fgd->fgd[0].cFileName));
- CopyMemory(fgd->fgd[0].cFileName, pathname.charactersWithNullTermination(), maxSize * sizeof(UChar));
- GlobalUnlock(medium.hGlobal);
-
- dataObject->SetData(fileDescriptorFormat(), &medium, TRUE);
-}
-
-void setFileContentData(IDataObject* dataObject, int size, void* dataBlob)
-{
- STGMEDIUM medium = { 0 };
- medium.tymed = TYMED_HGLOBAL;
-
- medium.hGlobal = ::GlobalAlloc(GPTR, size);
- if (!medium.hGlobal)
- return;
- void* fileContents = GlobalLock(medium.hGlobal);
- ::CopyMemory(fileContents, dataBlob, size);
- GlobalUnlock(medium.hGlobal);
-
- dataObject->SetData(fileContentFormatZero(), &medium, TRUE);
-}
-
-String getURL(IDataObject* dataObject, DragData::FilenameConversionPolicy filenamePolicy, String* title)
-{
- STGMEDIUM store;
- String url;
- if (getWebLocData(dataObject, url, title))
- return url;
-
- if (SUCCEEDED(dataObject->GetData(urlWFormat(), &store))) {
- // URL using Unicode
- UChar* data = static_cast<UChar*>(GlobalLock(store.hGlobal));
- url = extractURL(String(data), title);
- GlobalUnlock(store.hGlobal);
- ReleaseStgMedium(&store);
- } else if (SUCCEEDED(dataObject->GetData(urlFormat(), &store))) {
- // URL using ASCII
- char* data = static_cast<char*>(GlobalLock(store.hGlobal));
- url = extractURL(String(data), title);
- GlobalUnlock(store.hGlobal);
- ReleaseStgMedium(&store);
- }
-#if USE(CF)
- else if (filenamePolicy == DragData::ConvertFilenames) {
- if (SUCCEEDED(dataObject->GetData(filenameWFormat(), &store))) {
- // file using unicode
- wchar_t* data = static_cast<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) && title)
- *title = url;
- }
- GlobalUnlock(store.hGlobal);
- ReleaseStgMedium(&store);
- } else if (SUCCEEDED(dataObject->GetData(filenameFormat(), &store))) {
- // filename using ascii
- char* data = static_cast<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) && title)
- *title = url;
- }
- GlobalUnlock(store.hGlobal);
- ReleaseStgMedium(&store);
- }
- }
-#endif
- return url;
-}
-
-String getURL(const DragDataMap* data, DragData::FilenameConversionPolicy filenamePolicy, String* title)
-{
- String url;
-
- if (getWebLocData(data, url, title))
- return url;
- if (getDataMapItem(data, urlWFormat(), url))
- return extractURL(url, title);
- if (getDataMapItem(data, urlFormat(), url))
- return extractURL(url, title);
-#if USE(CF)
- if (filenamePolicy != DragData::ConvertFilenames)
- return url;
-
- String stringData;
- if (!getDataMapItem(data, filenameWFormat(), stringData))
- getDataMapItem(data, filenameFormat(), stringData);
-
- if (stringData.isEmpty() || (!PathFileExists(stringData.charactersWithNullTermination()) && !PathIsUNC(stringData.charactersWithNullTermination())))
- return url;
- RetainPtr<CFStringRef> pathAsCFString(AdoptCF, CFStringCreateWithCharacters(kCFAllocatorDefault, (const UniChar *)stringData.charactersWithNullTermination(), wcslen(stringData.charactersWithNullTermination())));
- if (urlFromPath(pathAsCFString.get(), url) && title)
- *title = url;
-#endif
- return url;
-}
-
-String getPlainText(IDataObject* dataObject)
-{
- STGMEDIUM store;
- String text;
- if (SUCCEEDED(dataObject->GetData(plainTextWFormat(), &store))) {
- // Unicode text
- UChar* data = static_cast<UChar*>(GlobalLock(store.hGlobal));
- text = String(data);
- GlobalUnlock(store.hGlobal);
- ReleaseStgMedium(&store);
- } else if (SUCCEEDED(dataObject->GetData(plainTextFormat(), &store))) {
- // ASCII text
- char* data = static_cast<char*>(GlobalLock(store.hGlobal));
- text = String(data);
- GlobalUnlock(store.hGlobal);
- ReleaseStgMedium(&store);
- } else {
- // FIXME: Originally, we called getURL() here because dragging and dropping files doesn't
- // populate the drag with text data. Per https://bugs.webkit.org/show_bug.cgi?id=38826, this
- // is undesirable, so maybe this line can be removed.
- text = getURL(dataObject, DragData::DoNotConvertFilenames);
- }
- return text;
-}
-
-String getPlainText(const DragDataMap* data)
-{
- String text;
-
- if (getDataMapItem(data, plainTextWFormat(), text))
- return text;
- if (getDataMapItem(data, plainTextFormat(), text))
- return text;
- return getURL(data, DragData::DoNotConvertFilenames);
-}
-
-String getTextHTML(IDataObject* data)
-{
- STGMEDIUM store;
- String html;
- if (SUCCEEDED(data->GetData(texthtmlFormat(), &store))) {
- UChar* data = static_cast<UChar*>(GlobalLock(store.hGlobal));
- html = String(data);
- GlobalUnlock(store.hGlobal);
- ReleaseStgMedium(&store);
- }
- return html;
-}
-
-String getTextHTML(const DragDataMap* data)
-{
- String text;
- getDataMapItem(data, texthtmlFormat(), text);
- return text;
-}
-
-String getCFHTML(IDataObject* data)
-{
- String cfhtml = getFullCFHTML(data);
- if (!cfhtml.isEmpty())
- return extractMarkupFromCFHTML(cfhtml);
- return String();
-}
-
-String getCFHTML(const DragDataMap* dataMap)
-{
- String cfhtml;
- getDataMapItem(dataMap, htmlFormat(), cfhtml);
- return extractMarkupFromCFHTML(cfhtml);
-}
-
-PassRefPtr<DocumentFragment> fragmentFromFilenames(Document*, const IDataObject*)
-{
- // FIXME: We should be able to create fragments from files
- return 0;
-}
-
-PassRefPtr<DocumentFragment> fragmentFromFilenames(Document*, const DragDataMap*)
-{
- // 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;
-}
-
-bool containsFilenames(const DragDataMap*)
-{
- // 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> fragmentFromCFHTML(Document* doc, const String& cfhtml)
-{
- // obtain baseURL if present
- String srcURLStr("sourceURL:");
- String srcURL;
- unsigned lineStart = cfhtml.find(srcURLStr, 0, false);
- if (lineStart != -1) {
- unsigned srcEnd = cfhtml.find("\n", lineStart, false);
- unsigned srcStart = lineStart+srcURLStr.length();
- String rawSrcURL = cfhtml.substring(srcStart, srcEnd-srcStart);
- replaceNBSPWithSpace(rawSrcURL);
- srcURL = rawSrcURL.stripWhiteSpace();
- }
-
- String markup = extractMarkupFromCFHTML(cfhtml);
- return createFragmentFromMarkup(doc, markup, srcURL, DisallowScriptingAndPluginContent);
-}
-
-PassRefPtr<DocumentFragment> fragmentFromHTML(Document* doc, IDataObject* data)
-{
- if (!doc || !data)
- return 0;
-
- String cfhtml = getFullCFHTML(data);
- if (!cfhtml.isEmpty()) {
- if (RefPtr<DocumentFragment> fragment = fragmentFromCFHTML(doc, cfhtml))
- return fragment.release();
- }
-
- String html = getTextHTML(data);
- String srcURL;
- if (!html.isEmpty())
- return createFragmentFromMarkup(doc, html, srcURL, DisallowScriptingAndPluginContent);
-
- return 0;
-}
-
-PassRefPtr<DocumentFragment> fragmentFromHTML(Document* document, const DragDataMap* data)
-{
- if (!document || !data || data->isEmpty())
- return 0;
-
- String stringData;
- if (getDataMapItem(data, htmlFormat(), stringData)) {
- if (RefPtr<DocumentFragment> fragment = fragmentFromCFHTML(document, stringData))
- return fragment.release();
- }
-
- String srcURL;
- if (getDataMapItem(data, texthtmlFormat(), stringData))
- return createFragmentFromMarkup(document, stringData, srcURL, DisallowScriptingAndPluginContent);
-
- return 0;
-}
-
-bool containsHTML(IDataObject* data)
-{
- return SUCCEEDED(data->QueryGetData(texthtmlFormat())) || SUCCEEDED(data->QueryGetData(htmlFormat()));
-}
-
-bool containsHTML(const DragDataMap* data)
-{
- return data->contains(texthtmlFormat()->cfFormat) || data->contains(htmlFormat()->cfFormat);
-}
-
-typedef void (*GetStringFunction)(IDataObject*, FORMATETC*, Vector<String>&);
-typedef void (*SetStringFunction)(IDataObject*, FORMATETC*, const Vector<String>&);
-
-struct ClipboardDataItem {
- GetStringFunction getString;
- SetStringFunction setString;
- FORMATETC* format;
-
- ClipboardDataItem(FORMATETC* format, GetStringFunction getString, SetStringFunction setString): format(format), getString(getString), setString(setString) { }
-};
-
-typedef HashMap<UINT, ClipboardDataItem*> ClipboardFormatMap;
-
-// Getter functions.
-
-template<typename T> void getStringData(IDataObject* data, FORMATETC* format, Vector<String>& dataStrings)
-{
- STGMEDIUM store;
- if (FAILED(data->GetData(format, &store)))
- return;
- dataStrings.append(String(static_cast<T*>(GlobalLock(store.hGlobal)), ::GlobalSize(store.hGlobal) / sizeof(T)));
- GlobalUnlock(store.hGlobal);
- ReleaseStgMedium(&store);
-}
-
-void getUtf8Data(IDataObject* data, FORMATETC* format, Vector<String>& dataStrings)
-{
- STGMEDIUM store;
- if (FAILED(data->GetData(format, &store)))
- return;
- dataStrings.append(String(UTF8Encoding().decode(static_cast<char*>(GlobalLock(store.hGlobal)), GlobalSize(store.hGlobal))));
- GlobalUnlock(store.hGlobal);
- ReleaseStgMedium(&store);
-}
-
-#if USE(CF)
-void getCFData(IDataObject* data, FORMATETC* format, Vector<String>& dataStrings)
-{
- STGMEDIUM store;
- if (FAILED(data->GetData(format, &store)))
- return;
-
- HDROP hdrop = reinterpret_cast<HDROP>(GlobalLock(store.hGlobal));
- if (!hdrop)
- return;
-
- WCHAR filename[MAX_PATH];
- UINT fileCount = DragQueryFileW(hdrop, 0xFFFFFFFF, 0, 0);
- for (UINT i = 0; i < fileCount; i++) {
- if (!DragQueryFileW(hdrop, i, filename, WTF_ARRAY_LENGTH(filename)))
- continue;
- dataStrings.append(static_cast<UChar*>(filename));
- }
-
- GlobalUnlock(store.hGlobal);
- ReleaseStgMedium(&store);
-}
-#endif
-
-// Setter functions.
-
-void setUCharData(IDataObject* data, FORMATETC* format, const Vector<String>& dataStrings)
-{
- STGMEDIUM medium = {0};
- medium.tymed = TYMED_HGLOBAL;
-
- medium.hGlobal = createGlobalData(dataStrings.first());
- if (!medium.hGlobal)
- return;
- data->SetData(format, &medium, FALSE);
- ::GlobalFree(medium.hGlobal);
-}
-
-void setUtf8Data(IDataObject* data, FORMATETC* format, const Vector<String>& dataStrings)
-{
- STGMEDIUM medium = {0};
- medium.tymed = TYMED_HGLOBAL;
-
- CString charString = dataStrings.first().utf8();
- size_t stringLength = charString.length();
- medium.hGlobal = ::GlobalAlloc(GPTR, stringLength + 1);
- if (!medium.hGlobal)
- return;
- char* buffer = static_cast<char*>(GlobalLock(medium.hGlobal));
- memcpy(buffer, charString.data(), stringLength);
- buffer[stringLength] = 0;
- GlobalUnlock(medium.hGlobal);
- data->SetData(format, &medium, FALSE);
- ::GlobalFree(medium.hGlobal);
-}
-
-#if USE(CF)
-void setCFData(IDataObject* data, FORMATETC* format, const Vector<String>& dataStrings)
-{
- STGMEDIUM medium = {0};
- medium.tymed = TYMED_HGLOBAL;
-
- SIZE_T dropFilesSize = sizeof(DROPFILES) + (sizeof(WCHAR) * (dataStrings.first().length() + 2));
- medium.hGlobal = ::GlobalAlloc(GHND | GMEM_SHARE, dropFilesSize);
- if (!medium.hGlobal)
- return;
-
- DROPFILES* dropFiles = reinterpret_cast<DROPFILES *>(GlobalLock(medium.hGlobal));
- dropFiles->pFiles = sizeof(DROPFILES);
- dropFiles->fWide = TRUE;
- String filename = dataStrings.first();
- wcscpy(reinterpret_cast<LPWSTR>(dropFiles + 1), filename.charactersWithNullTermination());
- GlobalUnlock(medium.hGlobal);
- data->SetData(format, &medium, FALSE);
- ::GlobalFree(medium.hGlobal);
-}
-#endif
-
-static const ClipboardFormatMap& getClipboardMap()
-{
- static ClipboardFormatMap formatMap;
- if (formatMap.isEmpty()) {
- formatMap.add(htmlFormat()->cfFormat, new ClipboardDataItem(htmlFormat(), getUtf8Data, setUtf8Data));
- formatMap.add(texthtmlFormat()->cfFormat, new ClipboardDataItem(texthtmlFormat(), getStringData<UChar>, setUCharData));
- formatMap.add(plainTextFormat()->cfFormat, new ClipboardDataItem(plainTextFormat(), getStringData<char>, setUtf8Data));
- formatMap.add(plainTextWFormat()->cfFormat, new ClipboardDataItem(plainTextWFormat(), getStringData<UChar>, setUCharData));
-#if USE(CF)
- formatMap.add(cfHDropFormat()->cfFormat, new ClipboardDataItem(cfHDropFormat(), getCFData, setCFData));
-#endif
- formatMap.add(filenameFormat()->cfFormat, new ClipboardDataItem(filenameFormat(), getStringData<char>, setUtf8Data));
- formatMap.add(filenameWFormat()->cfFormat, new ClipboardDataItem(filenameWFormat(), getStringData<UChar>, setUCharData));
- formatMap.add(urlFormat()->cfFormat, new ClipboardDataItem(urlFormat(), getStringData<char>, setUtf8Data));
- formatMap.add(urlWFormat()->cfFormat, new ClipboardDataItem(urlWFormat(), getStringData<UChar>, setUCharData));
- }
- return formatMap;
-}
-
-void getClipboardData(IDataObject* dataObject, FORMATETC* format, Vector<String>& dataStrings)
-{
- const ClipboardFormatMap& formatMap = getClipboardMap();
- ClipboardFormatMap::const_iterator found = formatMap.find(format->cfFormat);
- if (found == formatMap.end())
- return;
- found->value->getString(dataObject, found->value->format, dataStrings);
-}
-
-void setClipboardData(IDataObject* dataObject, UINT format, const Vector<String>& dataStrings)
-{
- const ClipboardFormatMap& formatMap = getClipboardMap();
- ClipboardFormatMap::const_iterator found = formatMap.find(format);
- if (found == formatMap.end())
- return;
- found->value->setString(dataObject, found->value->format, dataStrings);
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/win/ClipboardUtilitiesWin.h b/Source/WebCore/platform/win/ClipboardUtilitiesWin.h
deleted file mode 100644
index e8d4755..0000000
--- a/Source/WebCore/platform/win/ClipboardUtilitiesWin.h
+++ /dev/null
@@ -1,88 +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>
-#include <wtf/Forward.h>
-
-namespace WebCore {
-
-class Document;
-class KURL;
-
-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();
-FORMATETC* fileDescriptorFormat();
-FORMATETC* fileContentFormatZero();
-
-void markupToCFHTML(const String& markup, const String& srcURL, Vector<char>& result);
-
-void replaceNewlinesWithWindowsStyleNewlines(String&);
-void replaceNBSPWithSpace(String&);
-
-bool containsFilenames(const IDataObject*);
-bool containsFilenames(const DragDataMap*);
-bool containsHTML(IDataObject*);
-bool containsHTML(const DragDataMap*);
-
-PassRefPtr<DocumentFragment> fragmentFromFilenames(Document*, const IDataObject*);
-PassRefPtr<DocumentFragment> fragmentFromFilenames(Document*, const DragDataMap*);
-PassRefPtr<DocumentFragment> fragmentFromHTML(Document*, IDataObject*);
-PassRefPtr<DocumentFragment> fragmentFromHTML(Document*, const DragDataMap*);
-PassRefPtr<DocumentFragment> fragmentFromCFHTML(Document*, const String& cfhtml);
-
-String getURL(IDataObject*, DragData::FilenameConversionPolicy, String* title = 0);
-String getURL(const DragDataMap*, DragData::FilenameConversionPolicy, String* title = 0);
-String getPlainText(IDataObject*);
-String getPlainText(const DragDataMap*);
-String getTextHTML(IDataObject*);
-String getTextHTML(const DragDataMap*);
-String getCFHTML(IDataObject*);
-String getCFHTML(const DragDataMap*);
-
-void getClipboardData(IDataObject*, FORMATETC* fetc, Vector<String>& dataStrings);
-void setClipboardData(IDataObject*, UINT format, const Vector<String>& dataStrings);
-void getFileDescriptorData(IDataObject*, int& size, String& pathname);
-void getFileContentData(IDataObject*, int size, void* dataBlob);
-void setFileDescriptorData(IDataObject*, int size, const String& pathname);
-void setFileContentData(IDataObject*, int size, void* dataBlob);
-
-} // namespace WebCore
-
-#endif // ClipboardUtilitiesWin_h
diff --git a/Source/WebCore/platform/win/ClipboardWin.cpp b/Source/WebCore/platform/win/ClipboardWin.cpp
deleted file mode 100644
index 317b103..0000000
--- a/Source/WebCore/platform/win/ClipboardWin.cpp
+++ /dev/null
@@ -1,814 +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 "CachedImage.h"
-#include "ClipboardUtilitiesWin.h"
-#include "Document.h"
-#include "DragData.h"
-#include "Editor.h"
-#include "Element.h"
-#include "EventHandler.h"
-#include "FileList.h"
-#include "Frame.h"
-#include "FrameLoader.h"
-#include "FrameView.h"
-#include "HTMLNames.h"
-#include "HTMLParserIdioms.h"
-#include "Image.h"
-#include "MIMETypeRegistry.h"
-#include "NotImplemented.h"
-#include "Page.h"
-#include "Pasteboard.h"
-#include "PlatformMouseEvent.h"
-#include "Range.h"
-#include "RenderImage.h"
-#include "ResourceResponse.h"
-#include "SharedBuffer.h"
-#include "WCDataObject.h"
-#include "markup.h"
-#include <shlwapi.h>
-#include <wininet.h>
-#include <wtf/RefPtr.h>
-#include <wtf/text/CString.h>
-#include <wtf/text/WTFString.h>
-#include <wtf/text/StringHash.h>
-
-using namespace std;
-
-namespace WebCore {
-
-using namespace HTMLNames;
-
-// 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, ClipboardDataTypeTextHTML };
-
-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;
- if (qType == "text/html")
- return ClipboardDataTypeTextHTML;
-
- return ClipboardDataTypeNone;
-}
-
-#if !OS(WINCE)
-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] || type & (GCT_LFNCHAR | GCT_SHORTCHAR))
- psz[writeTo++] = psz[readFrom];
-
- readFrom++;
- }
- psz[writeTo] = 0;
-}
-#endif
-
-static String filesystemPathFromUrlOrTitle(const String& url, const String& title, const UChar* extension, bool isLink)
-{
-#if OS(WINCE)
- notImplemented();
- return String();
-#else
- static const size_t fsPathMaxLengthExcludingNullTerminator = MAX_PATH - 1;
- bool usedURL = false;
- WCHAR fsPathBuffer[MAX_PATH];
- fsPathBuffer[0] = 0;
- int extensionLen = extension ? lstrlen(extension) : 0;
- int fsPathMaxLengthExcludingExtension = fsPathMaxLengthExcludingNullTerminator - extensionLen;
-
- if (!title.isEmpty()) {
- size_t len = min<size_t>(title.length(), fsPathMaxLengthExcludingExtension);
- CopyMemory(fsPathBuffer, title.characters(), len * sizeof(UChar));
- fsPathBuffer[len] = 0;
- pathRemoveBadFSCharacters(fsPathBuffer, len);
- }
-
- if (!lstrlen(fsPathBuffer)) {
- KURL kurl(ParsedURLString, url);
- usedURL = true;
- // The filename for any content based drag or file url 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.
- DWORD len = fsPathMaxLengthExcludingExtension;
- String lastComponent = kurl.lastPathComponent();
- if (kurl.isLocalFile() || (!isLink && !lastComponent.isEmpty())) {
- len = min<DWORD>(fsPathMaxLengthExcludingExtension, lastComponent.length());
- CopyMemory(fsPathBuffer, lastComponent.characters(), len * sizeof(UChar));
- } else {
- len = min<DWORD>(fsPathMaxLengthExcludingExtension, url.length());
- CopyMemory(fsPathBuffer, url.characters(), len * sizeof(UChar));
- }
- fsPathBuffer[len] = 0;
- pathRemoveBadFSCharacters(fsPathBuffer, len);
- }
-
- if (!extension)
- return String(static_cast<UChar*>(fsPathBuffer));
-
- if (!isLink && usedURL) {
- PathRenameExtension(fsPathBuffer, extension);
- return String(static_cast<UChar*>(fsPathBuffer));
- }
-
- return makeString(static_cast<const UChar*>(fsPathBuffer), extension);
-#endif
-}
-
-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 = decodeURLEscapeSequences(url.path());
- // windows does not enjoy a leading slash on paths
- if (localPath[0] == '/')
- localPath = localPath.substring(1);
- LPCWSTR localPathStr = localPath.charactersWithNullTermination();
- if (wcslen(localPathStr) + 1 < MAX_PATH)
- wcscpy_s(filePath, MAX_PATH, localPathStr);
- else
- return 0;
- } else {
-#if OS(WINCE)
- notImplemented();
- return 0;
-#else
- WCHAR tempPath[MAX_PATH];
- WCHAR extension[MAX_PATH];
- if (!::GetTempPath(WTF_ARRAY_LENGTH(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;
-#endif
- }
-
- 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 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();
-
- const String& preferredTitle = title.isEmpty() ? image->response().suggestedFilename() : title;
- String extension = image->image()->filenameExtension();
- if (extension.isEmpty()) {
- // Do not continue processing in the rare and unusual case where a decoded image is not able
- // to provide a filename extension. Something tricky (like a bait-n-switch) is going on
- return 0;
- }
- extension.insert(".", 0);
- fsPath = filesystemPathFromUrlOrTitle(url, preferredTitle, extension.charactersWithNullTermination(), false);
-
- if (fsPath.length() <= 0) {
- GlobalUnlock(memObj);
- GlobalFree(memObj);
- return 0;
- }
-
- int maxSize = min(fsPath.length(), WTF_ARRAY_LENGTH(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;
-
-#if USE(CF)
- // HDROP
- if (hDropContent) {
- medium.hGlobal = hDropContent;
- hr = dataObject->SetData(cfHDropFormat(), &medium, TRUE);
- }
-#endif
-
-exit:
- if (FAILED(hr)) {
- if (fileDescriptor)
- GlobalFree(fileDescriptor);
- if (fileContent)
- GlobalFree(fileContent);
- if (hDropContent)
- GlobalFree(hDropContent);
- }
- return hr;
-}
-
-PassRefPtr<Clipboard> Clipboard::create(ClipboardAccessPolicy policy, DragData* dragData, Frame* frame)
-{
- if (dragData->platformData())
- return ClipboardWin::create(DragAndDrop, dragData->platformData(), policy, frame);
- return ClipboardWin::create(DragAndDrop, dragData->dragDataMap(), policy, frame);
-}
-
-ClipboardWin::ClipboardWin(ClipboardType clipboardType, IDataObject* dataObject, ClipboardAccessPolicy policy, Frame* frame)
- : Clipboard(policy, clipboardType)
- , m_dataObject(dataObject)
- , m_writableDataObject(0)
- , m_frame(frame)
-{
-}
-
-ClipboardWin::ClipboardWin(ClipboardType clipboardType, WCDataObject* dataObject, ClipboardAccessPolicy policy, Frame* frame)
- : Clipboard(policy, clipboardType)
- , m_dataObject(dataObject)
- , m_writableDataObject(dataObject)
- , m_frame(frame)
-{
-}
-
-ClipboardWin::ClipboardWin(ClipboardType clipboardType, const DragDataMap& dataMap, ClipboardAccessPolicy policy, Frame* frame)
- : Clipboard(policy, clipboardType)
- , m_dataObject(0)
- , m_writableDataObject(0)
- , m_frame(frame)
- , m_dragDataMap(dataMap)
-{
-}
-
-ClipboardWin::~ClipboardWin()
-{
- if (m_dragImage)
- m_dragImage->removeClient(this);
-}
-
-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;
- markupToCFHTML(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(isForDragAndDrop());
- if (!canWriteData() || !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(isForDragAndDrop());
- if (!canWriteData())
- return;
-
- m_writableDataObject = 0;
- WCDataObject::createInstance(&m_writableDataObject);
- m_dataObject = m_writableDataObject;
-}
-
-String ClipboardWin::getData(const String& type) const
-{
- if (!canReadData() || (!m_dataObject && m_dragDataMap.isEmpty()))
- return "";
-
- ClipboardDataType dataType = clipboardTypeFromMIMEType(type);
- if (dataType == ClipboardDataTypeText)
- return m_dataObject ? getPlainText(m_dataObject.get()) : getPlainText(&m_dragDataMap);
- if (dataType == ClipboardDataTypeURL)
- return m_dataObject ? getURL(m_dataObject.get(), DragData::DoNotConvertFilenames) : getURL(&m_dragDataMap, DragData::DoNotConvertFilenames);
- else if (dataType == ClipboardDataTypeTextHTML) {
- String data = m_dataObject ? getTextHTML(m_dataObject.get()) : getTextHTML(&m_dragDataMap);
- if (!data.isEmpty())
- return data;
- return m_dataObject ? getCFHTML(m_dataObject.get()) : getCFHTML(&m_dragDataMap);
- }
-
- 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(isForDragAndDrop());
- if (!canWriteData() || !m_writableDataObject)
- return false;
-
- ClipboardDataType winType = clipboardTypeFromMIMEType(type);
-
- if (winType == ClipboardDataTypeURL)
- return WebCore::writeURL(m_writableDataObject.get(), KURL(ParsedURLString, 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(ListHashSet<String>& results, const 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
-ListHashSet<String> ClipboardWin::types() const
-{
- ListHashSet<String> results;
- if (!canReadTypes())
- return results;
-
- if (!m_dataObject && m_dragDataMap.isEmpty())
- return results;
-
- if (m_dataObject) {
- COMPtr<IEnumFORMATETC> itr;
-
- if (FAILED(m_dataObject->EnumFormatEtc(DATADIR_GET, &itr)))
- return results;
-
- if (!itr)
- return results;
-
- FORMATETC data;
-
- // IEnumFORMATETC::Next returns S_FALSE if there are no more items.
- while (itr->Next(1, &data, 0) == S_OK)
- addMimeTypesForFormat(results, data);
- } else {
- for (DragDataMap::const_iterator it = m_dragDataMap.begin(); it != m_dragDataMap.end(); ++it) {
- FORMATETC data;
- data.cfFormat = (*it).key;
- addMimeTypesForFormat(results, data);
- }
- }
-
- return results;
-}
-
-PassRefPtr<FileList> ClipboardWin::files() const
-{
-#if OS(WINCE)
- notImplemented();
- return 0;
-#else
- RefPtr<FileList> files = FileList::create();
- if (!canReadData())
- return files.release();
-
- if (!m_dataObject && m_dragDataMap.isEmpty())
- return files.release();
-
- if (m_dataObject) {
- STGMEDIUM medium;
- if (FAILED(m_dataObject->GetData(cfHDropFormat(), &medium)))
- return files.release();
-
- HDROP hdrop = reinterpret_cast<HDROP>(GlobalLock(medium.hGlobal));
- if (!hdrop)
- return files.release();
-
- WCHAR filename[MAX_PATH];
- UINT fileCount = DragQueryFileW(hdrop, 0xFFFFFFFF, 0, 0);
- for (UINT i = 0; i < fileCount; i++) {
- if (!DragQueryFileW(hdrop, i, filename, WTF_ARRAY_LENGTH(filename)))
- continue;
- files->append(File::create(reinterpret_cast<UChar*>(filename), File::AllContentTypes));
- }
-
- GlobalUnlock(medium.hGlobal);
- ReleaseStgMedium(&medium);
- return files.release();
- }
- if (!m_dragDataMap.contains(cfHDropFormat()->cfFormat))
- return files.release();
- Vector<String> filesVector = m_dragDataMap.get(cfHDropFormat()->cfFormat);
- for (Vector<String>::iterator it = filesVector.begin(); it != filesVector.end(); ++it)
- files->append(File::create(*it));
- return files.release();
-#endif
-}
-
-void ClipboardWin::setDragImage(CachedImage* image, Node *node, const IntPoint &loc)
-{
- if (!canSetDragImage())
- 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;
- if (m_dragImage) {
- result = createDragImageFromImage(m_dragImage->image());
- loc = m_dragLoc;
- } else if (m_dragImageElement) {
- Node* node = m_dragImageElement.get();
- result = node->document()->frame()->nodeImage(node);
- loc = m_dragLoc;
- }
- return result;
-}
-
-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 = toRenderImage(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->imageForRenderer(element->renderer()) || !cachedImage->isLoaded())
- return;
-
- SharedBuffer* imageBuffer = cachedImage->imageForRenderer(element->renderer())->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;
-
- KURL fullURL = frame->document()->completeURL(stripLeadingAndTrailingHTMLSpaces(imageURL));
- if (fullURL.isEmpty())
- return;
- STGMEDIUM medium = {0};
- medium.tymed = TYMED_HGLOBAL;
-
- // Put img tag on the clipboard referencing the image
- Vector<char> data;
- markupToCFHTML(createMarkup(element, IncludeNode, 0, ResolveAllURLs), "", 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);
-
- String url = kurl.string();
- ASSERT(url.containsOnlyASCII()); // KURL::string() is URL encoded.
-
- String fsPath = filesystemPathFromUrlOrTitle(url, titleStr, L".URL", true);
- String contentString("[InternetShortcut]\r\nURL=" + url + "\r\n");
- CString content = contentString.latin1();
-
- if (fsPath.length() <= 0)
- return;
-
- HGLOBAL urlFileDescriptor = GlobalAlloc(GPTR, sizeof(FILEGROUPDESCRIPTOR));
- if (!urlFileDescriptor)
- return;
-
- HGLOBAL urlFileContent = GlobalAlloc(GPTR, content.length());
- if (!urlFileContent) {
- GlobalFree(urlFileDescriptor);
- return;
- }
-
- FILEGROUPDESCRIPTOR* fgd = static_cast<FILEGROUPDESCRIPTOR*>(GlobalLock(urlFileDescriptor));
- ZeroMemory(fgd, sizeof(FILEGROUPDESCRIPTOR));
- fgd->cItems = 1;
- fgd->fgd[0].dwFlags = FD_FILESIZE;
- fgd->fgd[0].nFileSizeLow = content.length();
-
- unsigned maxSize = min(fsPath.length(), WTF_ARRAY_LENGTH(fgd->fgd[0].cFileName));
- CopyMemory(fgd->fgd[0].cFileName, fsPath.characters(), maxSize * sizeof(UChar));
- GlobalUnlock(urlFileDescriptor);
-
- char* fileContents = static_cast<char*>(GlobalLock(urlFileContent));
- CopyMemory(fileContents, content.data(), content.length());
- GlobalUnlock(urlFileContent);
-
- 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;
-
- Vector<char> data;
- markupToCFHTML(createMarkup(selectedRange, 0, AnnotateForInterchange),
- selectedRange->startContainer()->document()->url().string(), data);
- medium.hGlobal = createGlobalData(data);
- if (medium.hGlobal && FAILED(m_writableDataObject->SetData(htmlFormat(), &medium, TRUE)))
- ::GlobalFree(medium.hGlobal);
-
- String str = frame->editor()->selectedTextForClipboard();
- 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);
-}
-
-void ClipboardWin::writePlainText(const String& text)
-{
- if (!m_writableDataObject)
- return;
-
- STGMEDIUM medium = {0};
- medium.tymed = TYMED_HGLOBAL;
-
- String str = text;
- replaceNewlinesWithWindowsStyleNewlines(str);
- replaceNBSPWithSpace(str);
- medium.hGlobal = createGlobalData(str);
- if (medium.hGlobal && FAILED(m_writableDataObject->SetData(plainTextWFormat(), &medium, TRUE)))
- ::GlobalFree(medium.hGlobal);
-
- medium.hGlobal = 0;
-}
-
-bool ClipboardWin::hasData()
-{
- if (!m_dataObject && m_dragDataMap.isEmpty())
- return false;
-
- if (m_dataObject) {
- COMPtr<IEnumFORMATETC> itr;
- if (FAILED(m_dataObject->EnumFormatEtc(DATADIR_GET, &itr)))
- return false;
-
- if (!itr)
- return false;
-
- FORMATETC data;
-
- // IEnumFORMATETC::Next returns S_FALSE if there are no more items.
- if (itr->Next(1, &data, 0) == S_OK) {
- // There is at least one item in the IDataObject
- return true;
- }
-
- return false;
- }
- return !m_dragDataMap.isEmpty();
-}
-
-void ClipboardWin::setExternalDataObject(IDataObject *dataObject)
-{
- ASSERT(isForDragAndDrop());
-
- m_writableDataObject = 0;
- m_dataObject = dataObject;
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/win/ClipboardWin.h b/Source/WebCore/platform/win/ClipboardWin.h
deleted file mode 100644
index 114bd40..0000000
--- a/Source/WebCore/platform/win/ClipboardWin.h
+++ /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.
- */
-
-#ifndef ClipboardWin_h
-#define ClipboardWin_h
-
-#include "COMPtr.h"
-#include "CachedImageClient.h"
-#include "Clipboard.h"
-#include "DragData.h"
-
-struct IDataObject;
-
-namespace WebCore {
-
-class CachedImage;
-class Frame;
-class IntPoint;
-class WCDataObject;
-
-// State available during IE's events for drag and drop and copy/paste
-class ClipboardWin : public Clipboard, public CachedImageClient {
- WTF_MAKE_FAST_ALLOCATED;
-public:
- static PassRefPtr<ClipboardWin> create(ClipboardType clipboardType, IDataObject* dataObject, ClipboardAccessPolicy policy, Frame* frame)
- {
- return adoptRef(new ClipboardWin(clipboardType, dataObject, policy, frame));
- }
- static PassRefPtr<ClipboardWin> create(ClipboardType clipboardType, WCDataObject* dataObject, ClipboardAccessPolicy policy, Frame* frame)
- {
- return adoptRef(new ClipboardWin(clipboardType, dataObject, policy, frame));
- }
- static PassRefPtr<ClipboardWin> create(ClipboardType clipboardType, const DragDataMap& dataMap, ClipboardAccessPolicy policy, Frame* frame)
- {
- return adoptRef(new ClipboardWin(clipboardType, dataMap, policy, frame));
- }
- ~ClipboardWin();
-
- void clearData(const String& type);
- void clearAllData();
- String getData(const String& type) const;
- bool setData(const String& type, const String& data);
-
- // extensions beyond IE's API
- virtual ListHashSet<String> types() const;
- virtual PassRefPtr<FileList> files() 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 void writePlainText(const String&);
-
- virtual bool hasData();
-
- COMPtr<IDataObject> dataObject() { return m_dataObject; }
-
- void setExternalDataObject(IDataObject *dataObject);
-
-private:
- ClipboardWin(ClipboardType, IDataObject*, ClipboardAccessPolicy, Frame*);
- ClipboardWin(ClipboardType, WCDataObject*, ClipboardAccessPolicy, Frame*);
- ClipboardWin(ClipboardType, const DragDataMap&, ClipboardAccessPolicy, Frame*);
-
- void resetFromClipboard();
- void setDragImage(CachedImage*, Node*, const IntPoint&);
-
- COMPtr<IDataObject> m_dataObject;
- COMPtr<WCDataObject> m_writableDataObject;
- DragDataMap m_dragDataMap;
- Frame* m_frame;
-};
-
-} // namespace WebCore
-
-#endif // ClipboardWin_h
diff --git a/Source/WebCore/platform/win/ContextMenuItemWin.cpp b/Source/WebCore/platform/win/ContextMenuItemWin.cpp
deleted file mode 100644
index 4d7ba6b..0000000
--- a/Source/WebCore/platform/win/ContextMenuItemWin.cpp
+++ /dev/null
@@ -1,105 +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"
-
-#if OS(WINCE)
-#ifndef MFS_DISABLED
-#define MFS_DISABLED MF_GRAYED
-#endif
-#ifndef MIIM_FTYPE
-#define MIIM_FTYPE MIIM_TYPE
-#endif
-#ifndef MIIM_STRING
-#define MIIM_STRING 0
-#endif
-#endif
-
-namespace WebCore {
-
-ContextMenuItem::ContextMenuItem(const MENUITEMINFO& info)
-{
- if (info.fMask & MIIM_FTYPE)
- m_type = info.fType == MFT_SEPARATOR ? SeparatorType : ActionType;
- else
- m_type = SeparatorType;
-
- if (m_type == ActionType && info.fMask & MIIM_STRING)
- m_title = String(info.dwTypeData, info.cch);
-
- if ((info.fMask & MIIM_SUBMENU) && info.hSubMenu) {
- m_type = SubmenuType;
- ContextMenu::getContextMenuItems(info.hSubMenu, m_subMenuItems);
- }
-
- if (info.fMask & MIIM_ID)
- m_action = static_cast<ContextMenuAction>(info.wID);
- else
- m_action = ContextMenuItemTagNoAction;
-
- if (info.fMask & MIIM_STATE) {
- m_checked = info.fState & MFS_CHECKED;
- m_enabled = !(info.fState & MFS_DISABLED);
- } else {
- m_checked = false;
- m_enabled = false;
- }
-}
-
-// ContextMenuItem::platformContextMenuItem doesn't set the info.dwTypeData. This is
-// done to make the lifetime handling of the returned MENUITEMINFO easier on
-// callers. Callers can set dwTypeData themselves (and make their own decisions
-// about its lifetime) if they need it.
-MENUITEMINFO ContextMenuItem::platformContextMenuItem() const
-{
- MENUITEMINFO info = {0};
- info.cbSize = sizeof(MENUITEMINFO);
-
- if (m_type == SeparatorType) {
- info.fMask = MIIM_FTYPE;
- info.fType = MFT_SEPARATOR;
- return info;
- }
-
- info.fMask = MIIM_FTYPE | MIIM_ID | MIIM_STATE;
- info.fType = MFT_STRING;
-
- info.wID = m_action;
-
- if (m_type == SubmenuType) {
- info.fMask |= MIIM_SUBMENU;
- info.hSubMenu = ContextMenu::createPlatformContextMenuFromItems(m_subMenuItems);
- }
-
- info.fState |= m_enabled ? MFS_ENABLED : MFS_DISABLED;
- info.fState |= m_checked ? MFS_CHECKED : MFS_UNCHECKED;
-
- return info;
-}
-
-}
diff --git a/Source/WebCore/platform/win/ContextMenuWin.cpp b/Source/WebCore/platform/win/ContextMenuWin.cpp
deleted file mode 100644
index 5aca72b..0000000
--- a/Source/WebCore/platform/win/ContextMenuWin.cpp
+++ /dev/null
@@ -1,140 +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 "Document.h"
-#include "Frame.h"
-#include "FrameView.h"
-#include "Node.h"
-#include "NotImplemented.h"
-#include <windows.h>
-#include <wtf/Vector.h>
-#include <wtf/text/CString.h>
-
-#ifndef MIIM_FTYPE
-#define MIIM_FTYPE MIIM_TYPE
-#endif
-#ifndef MIIM_STRING
-#define MIIM_STRING MIIM_TYPE
-#endif
-
-namespace WebCore {
-
-ContextMenu::ContextMenu(HMENU menu)
-{
- getContextMenuItems(menu, m_items);
-}
-
-void ContextMenu::getContextMenuItems(HMENU menu, Vector<ContextMenuItem>& items)
-{
-#if OS(WINCE)
- notImplemented();
-#else
- int count = ::GetMenuItemCount(menu);
- if (count <= 0)
- return;
-
- for (int i = 0; i < count; ++i) {
- MENUITEMINFO info = {0};
- info.cbSize = sizeof(MENUITEMINFO);
- info.fMask = MIIM_FTYPE | MIIM_ID | MIIM_STRING | MIIM_STATE | MIIM_SUBMENU;
-
- if (!::GetMenuItemInfo(menu, i, TRUE, &info))
- continue;
-
- if (info.fType == MFT_SEPARATOR) {
- items.append(ContextMenuItem(SeparatorType, ContextMenuItemTagNoAction, String()));
- continue;
- }
-
- int menuStringLength = info.cch + 1;
- OwnArrayPtr<WCHAR> menuString = adoptArrayPtr(new WCHAR[menuStringLength]);
- info.dwTypeData = menuString.get();
- info.cch = menuStringLength;
-
- if (::GetMenuItemInfo(menu, i, TRUE, &info))
- items.append(ContextMenuItem(info));
- }
-#endif
-}
-
-HMENU ContextMenu::createPlatformContextMenuFromItems(const Vector<ContextMenuItem>& items)
-{
- HMENU menu = ::CreatePopupMenu();
-
- for (size_t i = 0; i < items.size(); ++i) {
- const ContextMenuItem& item = items[i];
-
- MENUITEMINFO menuItem = item.platformContextMenuItem();
-
-#if OS(WINCE)
- UINT flags = MF_BYPOSITION;
- UINT newItem = 0;
- LPCWSTR title = 0;
-
- if (item.type() == SeparatorType)
- flags |= MF_SEPARATOR;
- else {
- flags |= MF_STRING;
- flags |= item.checked() ? MF_CHECKED : MF_UNCHECKED;
- flags |= item.enabled() ? MF_ENABLED : MF_GRAYED;
-
- title = menuItem.dwTypeData;
- menuItem.dwTypeData = 0;
-
- if (menuItem.hSubMenu) {
- flags |= MF_POPUP;
- newItem = reinterpret_cast<UINT>(menuItem.hSubMenu);
- menuItem.hSubMenu = 0;
- } else
- newItem = menuItem.wID;
- }
-
- ::InsertMenuW(menu, i, flags, newItem, title);
-#else
- // ContextMenuItem::platformContextMenuItem doesn't set the title of the MENUITEMINFO to make the
- // lifetime handling easier for callers.
- String itemTitle = item.title();
- if (item.type() != SeparatorType) {
- menuItem.fMask |= MIIM_STRING;
- menuItem.cch = itemTitle.length();
- menuItem.dwTypeData = const_cast<LPWSTR>(itemTitle.charactersWithNullTermination());
- }
-
- ::InsertMenuItem(menu, i, TRUE, &menuItem);
-#endif
- }
-
- return menu;
-}
-
-HMENU ContextMenu::platformContextMenu() const
-{
- return createPlatformContextMenuFromItems(m_items);
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/win/CursorWin.cpp b/Source/WebCore/platform/win/CursorWin.cpp
deleted file mode 100644
index ce4d58f..0000000
--- a/Source/WebCore/platform/win/CursorWin.cpp
+++ /dev/null
@@ -1,291 +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 "BitmapInfo.h"
-#include "HWndDC.h"
-#include "Image.h"
-#include "IntPoint.h"
-#include "SystemInfo.h"
-
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
-
-#include <windows.h>
-
-#define ALPHA_CURSORS
-
-namespace WebCore {
-
-static PassRefPtr<SharedCursor> createSharedCursor(Image* img, const IntPoint& hotSpot)
-{
- RefPtr<SharedCursor> impl;
-
- IntPoint effectiveHotSpot = determineHotSpot(img, hotSpot);
- static bool doAlpha = windowsVersion() >= WindowsXP;
- BitmapInfo cursorImage = BitmapInfo::create(IntSize(img->width(), img->height()));
-
- HWndDC dc(0);
- HDC workingDC = CreateCompatibleDC(dc);
- if (doAlpha) {
- OwnPtr<HBITMAP> hCursor = adoptPtr(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 = adoptPtr(CreateBitmap(img->width(), img->height(), 1, 1, maskBits.data()));
-
- ICONINFO ii;
- ii.fIcon = FALSE;
- ii.xHotspot = effectiveHotSpot.x();
- ii.yHotspot = effectiveHotSpot.y();
- ii.hbmMask = hMask.get();
- ii.hbmColor = hCursor.get();
-
- 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 = adoptPtr(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 = adoptPtr(CreateBitmap(cursor.bmWidth, cursor.bmHeight, 1, 1, NULL));
- OwnPtr<HBITMAP> xorMask = adoptPtr(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 = effectiveHotSpot.x();
- icon.yHotspot = effectiveHotSpot.y();
- icon.hbmMask = andMask.get();
- icon.hbmColor = xorMask.get();
- impl = SharedCursor::create(CreateIconIndirect(&icon));
-
- DeleteDC(xorMaskDC);
- DeleteDC(andMaskDC);
- }
- DeleteDC(workingDC);
-
- return impl.release();
-}
-
-static PassRefPtr<SharedCursor> loadSharedCursor(HINSTANCE hInstance, LPCWSTR lpCursorName)
-{
- return SharedCursor::create(::LoadCursorW(hInstance, lpCursorName));
-}
-
-static PassRefPtr<SharedCursor> loadCursorByName(char* name, int x, int y)
-{
- IntPoint hotSpot(x, y);
- RefPtr<Image> cursorImage(Image::loadPlatformResource(name));
- if (cursorImage && !cursorImage->isNull())
- return createSharedCursor(cursorImage.get(), hotSpot);
- return loadSharedCursor(0, IDC_ARROW);
-}
-
-void Cursor::ensurePlatformCursor() const
-{
- if (m_platformCursor)
- return;
-
- switch (m_type) {
- case Cursor::Pointer:
- case Cursor::Cell:
- case Cursor::ContextMenu:
- case Cursor::Alias:
- case Cursor::Copy:
- case Cursor::None:
- case Cursor::Grab:
- case Cursor::Grabbing:
- m_platformCursor = loadSharedCursor(0, IDC_ARROW);
- break;
- case Cursor::Cross:
- m_platformCursor = loadSharedCursor(0, IDC_CROSS);
- break;
- case Cursor::Hand:
- m_platformCursor = loadSharedCursor(0, IDC_HAND);
- break;
- case Cursor::IBeam:
- m_platformCursor = loadSharedCursor(0, IDC_IBEAM);
- break;
- case Cursor::Wait:
- m_platformCursor = loadSharedCursor(0, IDC_WAIT);
- break;
- case Cursor::Help:
- m_platformCursor = loadSharedCursor(0, IDC_HELP);
- break;
- case Cursor::Move:
- m_platformCursor = loadSharedCursor(0, IDC_SIZEALL);
- break;
- case Cursor::MiddlePanning:
- m_platformCursor = loadCursorByName("panIcon", 8, 8);
- break;
- case Cursor::EastResize:
- m_platformCursor = loadSharedCursor(0, IDC_SIZEWE);
- break;
- case Cursor::EastPanning:
- m_platformCursor = loadCursorByName("panEastCursor", 7, 7);
- break;
- case Cursor::NorthResize:
- m_platformCursor = loadSharedCursor(0, IDC_SIZENS);
- break;
- case Cursor::NorthPanning:
- m_platformCursor = loadCursorByName("panNorthCursor", 7, 7);
- break;
- case Cursor::NorthEastResize:
- m_platformCursor = loadSharedCursor(0, IDC_SIZENESW);
- break;
- case Cursor::NorthEastPanning:
- m_platformCursor = loadCursorByName("panNorthEastCursor", 7, 7);
- break;
- case Cursor::NorthWestResize:
- m_platformCursor = loadSharedCursor(0, IDC_SIZENWSE);
- break;
- case Cursor::NorthWestPanning:
- m_platformCursor = loadCursorByName("panNorthWestCursor", 7, 7);
- break;
- case Cursor::SouthResize:
- m_platformCursor = loadSharedCursor(0, IDC_SIZENS);
- break;
- case Cursor::SouthPanning:
- m_platformCursor = loadCursorByName("panSouthCursor", 7, 7);
- break;
- case Cursor::SouthEastResize:
- m_platformCursor = loadSharedCursor(0, IDC_SIZENWSE);
- break;
- case Cursor::SouthEastPanning:
- m_platformCursor = loadCursorByName("panSouthEastCursor", 7, 7);
- break;
- case Cursor::SouthWestResize:
- m_platformCursor = loadSharedCursor(0, IDC_SIZENESW);
- break;
- case Cursor::SouthWestPanning:
- m_platformCursor = loadCursorByName("panSouthWestCursor", 7, 7);
- break;
- case Cursor::WestResize:
- m_platformCursor = loadSharedCursor(0, IDC_SIZEWE);
- break;
- case Cursor::NorthSouthResize:
- m_platformCursor = loadSharedCursor(0, IDC_SIZENS);
- break;
- case Cursor::EastWestResize:
- m_platformCursor = loadSharedCursor(0, IDC_SIZEWE);
- break;
- case Cursor::WestPanning:
- m_platformCursor = loadCursorByName("panWestCursor", 7, 7);
- break;
- case Cursor::NorthEastSouthWestResize:
- m_platformCursor = loadSharedCursor(0, IDC_SIZENESW);
- break;
- case Cursor::NorthWestSouthEastResize:
- m_platformCursor = loadSharedCursor(0, IDC_SIZENWSE);
- break;
- case Cursor::ColumnResize:
- // FIXME: Windows does not have a standard column resize cursor <rdar://problem/5018591>
- m_platformCursor = loadSharedCursor(0, IDC_SIZEWE);
- break;
- case Cursor::RowResize:
- // FIXME: Windows does not have a standard row resize cursor <rdar://problem/5018591>
- m_platformCursor = loadSharedCursor(0, IDC_SIZENS);
- break;
- case Cursor::VerticalText:
- m_platformCursor = loadCursorByName("verticalTextCursor", 7, 7);
- break;
- case Cursor::Progress:
- m_platformCursor = loadSharedCursor(0, IDC_APPSTARTING);
- break;
- case Cursor::NoDrop:
- case Cursor::NotAllowed:
- m_platformCursor = loadSharedCursor(0, IDC_NO);
- break;
- case Cursor::ZoomIn:
- m_platformCursor = loadCursorByName("zoomInCursor", 7, 7);
- break;
- case Cursor::ZoomOut:
- m_platformCursor = loadCursorByName("zoomOutCursor", 7, 7);
- break;
- case Cursor::Custom:
- m_platformCursor = createSharedCursor(m_image.get(), m_hotSpot);
- break;
- default:
- ASSERT_NOT_REACHED();
- m_platformCursor = loadSharedCursor(0, IDC_ARROW);
- break;
- }
-}
-
-SharedCursor::~SharedCursor()
-{
- DestroyIcon(m_nativeCursor);
-}
-
-Cursor::Cursor(const Cursor& other)
- : m_type(other.m_type)
- , m_image(other.m_image)
- , m_hotSpot(other.m_hotSpot)
- , m_platformCursor(other.m_platformCursor)
-{
-}
-
-Cursor& Cursor::operator=(const Cursor& other)
-{
- m_type = other.m_type;
- m_image = other.m_image;
- m_hotSpot = other.m_hotSpot;
- m_platformCursor = other.m_platformCursor;
- return *this;
-}
-
-Cursor::~Cursor()
-{
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/win/DefWndProcWindowClass.cpp b/Source/WebCore/platform/win/DefWndProcWindowClass.cpp
deleted file mode 100644
index b07a6de..0000000
--- a/Source/WebCore/platform/win/DefWndProcWindowClass.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2011 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. 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 INC. 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 "DefWndProcWindowClass.h"
-
-#include "WebCoreInstanceHandle.h"
-#include <windows.h>
-
-namespace WebCore {
-
-static const wchar_t className[] = L"DefWndProcWindowClass";
-
-static ATOM registerClass()
-{
- WNDCLASSW wndClass = {0};
- wndClass.lpszClassName = className;
- wndClass.lpfnWndProc = ::DefWindowProcW;
- wndClass.hInstance = instanceHandle();
-
- return ::RegisterClassW(&wndClass);
-}
-
-const wchar_t* defWndProcWindowClassName()
-{
- static ATOM atom = registerClass();
- return className;
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/win/DefWndProcWindowClass.h b/Source/WebCore/platform/win/DefWndProcWindowClass.h
deleted file mode 100644
index 346a332..0000000
--- a/Source/WebCore/platform/win/DefWndProcWindowClass.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2011 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. 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 INC. 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 DefWndProcWindowClass_h
-#define DefWndProcWindowClass_h
-
-namespace WebCore {
-
-// Returns the name of a window class that can be used to create a "dummy" window. The window just
-// passes all messages to ::DefWindowProcW. This is useful in situations where you need an HWND but
-// don't need it to have any special behavior.
-const wchar_t* defWndProcWindowClassName();
-
-} // namespace WebCore
-
-#endif // DefWndProcWindowClass_h
diff --git a/Source/WebCore/platform/win/DelayLoadedModulesEnumerator.cpp b/Source/WebCore/platform/win/DelayLoadedModulesEnumerator.cpp
deleted file mode 100644
index aa6df11..0000000
--- a/Source/WebCore/platform/win/DelayLoadedModulesEnumerator.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2011 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. 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 INC. 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 "DelayLoadedModulesEnumerator.h"
-
-#include "ImportedFunctionsEnumerator.h"
-#include <delayimp.h>
-
-// See <http://msdn.microsoft.com/en-us/magazine/cc301808.aspx> and
-// <http://msdn.microsoft.com/en-us/windows/hardware/gg463119> for more information about the PE
-// image format.
-
-namespace WebCore {
-
-DelayLoadedModulesEnumerator::DelayLoadedModulesEnumerator(const PEImage& image)
- : m_image(image)
-{
- if (m_image.isValid())
- m_descriptor = static_cast<const ImgDelayDescr*>(m_image.dataDirectoryEntryAddress(IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT));
- else
- m_descriptor = 0;
-}
-
-bool DelayLoadedModulesEnumerator::isAtEnd() const
-{
- return !m_descriptor || !m_descriptor->rvaHmod;
-}
-
-void DelayLoadedModulesEnumerator::next()
-{
- ASSERT(!isAtEnd());
- ++m_descriptor;
-}
-
-const char* DelayLoadedModulesEnumerator::currentModuleName() const
-{
- ASSERT(!isAtEnd());
- return static_cast<const char*>(convertPotentialRVAToAddress(m_descriptor->rvaDLLName));
-}
-
-ImportedFunctionsEnumerator DelayLoadedModulesEnumerator::functionsEnumerator() const
-{
- ASSERT(!isAtEnd());
-
- const IMAGE_THUNK_DATA* importNameTable = static_cast<const IMAGE_THUNK_DATA*>(convertPotentialRVAToAddress(m_descriptor->rvaINT));
- const IMAGE_THUNK_DATA* importAddressTable = static_cast<const IMAGE_THUNK_DATA*>(convertPotentialRVAToAddress(m_descriptor->rvaIAT));
-
- return ImportedFunctionsEnumerator(m_image, importNameTable, importAddressTable);
-}
-
-const void* DelayLoadedModulesEnumerator::convertPotentialRVAToAddress(DWORD potentialRVA) const
-{
- ASSERT(!isAtEnd());
-
- if (!(m_descriptor->grAttrs & dlattrRva)) {
- // m_image is a pre-VC7.0 image, so addresses stored in the ImageDelayDescr are non-relative.
- return reinterpret_cast<void*>(potentialRVA);
- }
-
- return m_image.convertRVAToAddress(potentialRVA);
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/win/DelayLoadedModulesEnumerator.h b/Source/WebCore/platform/win/DelayLoadedModulesEnumerator.h
deleted file mode 100644
index 477806c..0000000
--- a/Source/WebCore/platform/win/DelayLoadedModulesEnumerator.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2011 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. 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 INC. 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 DelayLoadedModulesEnumerator_h
-#define DelayLoadedModulesEnumerator_h
-
-#include "ImportedModulesEnumeratorBase.h"
-#include "PEImage.h"
-
-struct ImgDelayDescr;
-
-namespace WebCore {
-
-// Enumerates all delay-loaded modules imported by the given PEImage.
-class DelayLoadedModulesEnumerator : public ImportedModulesEnumeratorBase {
-public:
- explicit DelayLoadedModulesEnumerator(const PEImage&);
-
- virtual bool isAtEnd() const;
- virtual void next();
-
- virtual const char* currentModuleName() const;
- virtual ImportedFunctionsEnumerator functionsEnumerator() const;
-
-private:
- const void* convertPotentialRVAToAddress(DWORD) const;
-
- PEImage m_image;
- const ImgDelayDescr* m_descriptor;
-};
-
-} // namespace WebCore
-
-#endif // DelayLoadedModulesEnumerator_h
diff --git a/Source/WebCore/platform/win/DragDataWin.cpp b/Source/WebCore/platform/win/DragDataWin.cpp
deleted file mode 100644
index 1302597..0000000
--- a/Source/WebCore/platform/win/DragDataWin.cpp
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
- * Copyright (C) 2012 Baidu Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) 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 "COMPtr.h"
-#include "ClipboardUtilitiesWin.h"
-#include "Frame.h"
-#include "DocumentFragment.h"
-#include "Markup.h"
-#include "TextEncoding.h"
-#include <objidl.h>
-#include <shlwapi.h>
-#include <wininet.h>
-#include <wtf/Forward.h>
-#include <wtf/Hashmap.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefPtr.h>
-#include <wtf/text/WTFString.h>
-
-namespace WebCore {
-
-DragData::DragData(const DragDataMap& data, const IntPoint& clientPosition, const IntPoint& globalPosition,
- DragOperation sourceOperationMask, DragApplicationFlags flags)
- : m_clientPosition(clientPosition)
- , m_globalPosition(globalPosition)
- , m_platformDragData(0)
- , m_draggingSourceOperationMask(sourceOperationMask)
- , m_applicationFlags(flags)
- , m_dragDataMap(data)
-{
-}
-
-bool DragData::containsURL(Frame*, FilenameConversionPolicy filenamePolicy) const
-{
- if (m_platformDragData)
- return SUCCEEDED(m_platformDragData->QueryGetData(urlWFormat()))
- || SUCCEEDED(m_platformDragData->QueryGetData(urlFormat()))
- || (filenamePolicy == ConvertFilenames
- && (SUCCEEDED(m_platformDragData->QueryGetData(filenameWFormat()))
- || SUCCEEDED(m_platformDragData->QueryGetData(filenameFormat()))));
- return m_dragDataMap.contains(urlWFormat()->cfFormat) || m_dragDataMap.contains(urlFormat()->cfFormat)
- || (filenamePolicy == ConvertFilenames && (m_dragDataMap.contains(filenameWFormat()->cfFormat) || m_dragDataMap.contains(filenameFormat()->cfFormat)));
-}
-
-const DragDataMap& DragData::dragDataMap()
-{
- if (!m_dragDataMap.isEmpty() || !m_platformDragData)
- return m_dragDataMap;
- // Enumerate clipboard content and load it in the map.
- COMPtr<IEnumFORMATETC> itr;
-
- if (FAILED(m_platformDragData->EnumFormatEtc(DATADIR_GET, &itr)) || !itr)
- return m_dragDataMap;
-
- FORMATETC dataFormat;
- while (itr->Next(1, &dataFormat, 0) == S_OK) {
- Vector<String> dataStrings;
- getClipboardData(m_platformDragData, &dataFormat, dataStrings);
- if (!dataStrings.isEmpty())
- m_dragDataMap.set(dataFormat.cfFormat, dataStrings);
- }
- return m_dragDataMap;
-}
-
-void DragData::getDragFileDescriptorData(int& size, String& pathname)
-{
- size = 0;
- if (m_platformDragData)
- getFileDescriptorData(m_platformDragData, size, pathname);
-}
-
-void DragData::getDragFileContentData(int size, void* dataBlob)
-{
- if (m_platformDragData)
- getFileContentData(m_platformDragData, size, dataBlob);
-}
-
-String DragData::asURL(Frame*, FilenameConversionPolicy filenamePolicy, String* title) const
-{
- return (m_platformDragData) ? getURL(m_platformDragData, filenamePolicy, title) : getURL(&m_dragDataMap, filenamePolicy, title);
-}
-
-bool DragData::containsFiles() const
-{
-#if OS(WINCE)
- return false;
-#else
- return (m_platformDragData) ? SUCCEEDED(m_platformDragData->QueryGetData(cfHDropFormat())) : m_dragDataMap.contains(cfHDropFormat()->cfFormat);
-#endif
-}
-
-unsigned DragData::numberOfFiles() const
-{
-#if OS(WINCE)
- return 0;
-#else
- if (!m_platformDragData)
- return 0;
-
- STGMEDIUM medium;
- if (FAILED(m_platformDragData->GetData(cfHDropFormat(), &medium)))
- return 0;
-
- HDROP hdrop = static_cast<HDROP>(GlobalLock(medium.hGlobal));
-
- if (!hdrop)
- return 0;
-
- unsigned numFiles = DragQueryFileW(hdrop, 0xFFFFFFFF, 0, 0);
-
- DragFinish(hdrop);
- GlobalUnlock(medium.hGlobal);
-
- return numFiles;
-#endif
-}
-
-void DragData::asFilenames(Vector<String>& result) const
-{
-#if !OS(WINCE)
- if (m_platformDragData) {
- WCHAR filename[MAX_PATH];
-
- STGMEDIUM medium;
- if (FAILED(m_platformDragData->GetData(cfHDropFormat(), &medium)))
- return;
-
- HDROP hdrop = reinterpret_cast<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, i, filename, WTF_ARRAY_LENGTH(filename)))
- continue;
- result.append(static_cast<UChar*>(filename));
- }
-
- // Free up memory from drag
- DragFinish(hdrop);
-
- GlobalUnlock(medium.hGlobal);
- return;
- }
- result = m_dragDataMap.get(cfHDropFormat()->cfFormat);
-#endif
-}
-
-bool DragData::containsPlainText() const
-{
- if (m_platformDragData)
- return SUCCEEDED(m_platformDragData->QueryGetData(plainTextWFormat()))
- || SUCCEEDED(m_platformDragData->QueryGetData(plainTextFormat()));
- return m_dragDataMap.contains(plainTextWFormat()->cfFormat) || m_dragDataMap.contains(plainTextFormat()->cfFormat);
-}
-
-String DragData::asPlainText(Frame*) const
-{
- return (m_platformDragData) ? getPlainText(m_platformDragData) : getPlainText(&m_dragDataMap);
-}
-
-bool DragData::containsColor() const
-{
- return false;
-}
-
-bool DragData::canSmartReplace() const
-{
- if (m_platformDragData)
- return SUCCEEDED(m_platformDragData->QueryGetData(smartPasteFormat()));
- return m_dragDataMap.contains(smartPasteFormat()->cfFormat);
-}
-
-bool DragData::containsCompatibleContent() const
-{
- return containsPlainText() || containsURL(0)
- || ((m_platformDragData) ? (containsHTML(m_platformDragData) || containsFilenames(m_platformDragData))
- : (containsHTML(&m_dragDataMap) || containsFilenames(&m_dragDataMap)))
- || containsColor();
-}
-
-PassRefPtr<DocumentFragment> DragData::asFragment(Frame* frame, PassRefPtr<Range>, bool, bool&) const
-{
- /*
- * Order is richest format first. On OSX this is:
- * * Web Archive
- * * Filenames
- * * HTML
- * * RTF
- * * TIFF
- * * PICT
- */
-
- if (m_platformDragData) {
- if (containsFilenames(m_platformDragData)) {
- if (PassRefPtr<DocumentFragment> fragment = fragmentFromFilenames(frame->document(), m_platformDragData))
- return fragment;
- }
-
- if (containsHTML(m_platformDragData)) {
- if (PassRefPtr<DocumentFragment> fragment = fragmentFromHTML(frame->document(), m_platformDragData))
- return fragment;
- }
- } else {
- if (containsFilenames(&m_dragDataMap)) {
- if (PassRefPtr<DocumentFragment> fragment = fragmentFromFilenames(frame->document(), &m_dragDataMap))
- return fragment;
- }
-
- if (containsHTML(&m_dragDataMap)) {
- if (PassRefPtr<DocumentFragment> fragment = fragmentFromHTML(frame->document(), &m_dragDataMap))
- return fragment;
- }
- }
- return 0;
-}
-
-Color DragData::asColor() const
-{
- return Color();
-}
-
-}
diff --git a/Source/WebCore/platform/win/DragImageCGWin.cpp b/Source/WebCore/platform/win/DragImageCGWin.cpp
deleted file mode 100644
index 93025b7..0000000
--- a/Source/WebCore/platform/win/DragImageCGWin.cpp
+++ /dev/null
@@ -1,163 +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 "BitmapInfo.h"
-#include "CachedImage.h"
-#include "GraphicsContextCG.h"
-#include "HWndDC.h"
-#include "Image.h"
-
-#include <CoreGraphics/CoreGraphics.h>
-#include <wtf/RetainPtr.h>
-
-#include <windows.h>
-
-namespace WebCore {
-
-void deallocContext(CGContextRef target)
-{
- CGContextRelease(target);
-}
-
-HBITMAP allocImage(HDC dc, IntSize size, CGContextRef *targetRef)
-{
- BitmapInfo bmpInfo = BitmapInfo::create(size);
-
- LPVOID bits;
- HBITMAP hbmp = CreateDIBSection(dc, &bmpInfo, DIB_RGB_COLORS, &bits, 0, 0);
-
- if (!targetRef)
- return hbmp;
-
- CGContextRef bitmapContext = CGBitmapContextCreate(bits, bmpInfo.bmiHeader.biWidth, bmpInfo.bmiHeader.biHeight, 8,
- bmpInfo.bmiHeader.biWidth * 4, deviceRGBColorSpaceRef(),
- kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipFirst);
- 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);
-
- CGContextRef bitmapContext = CGBitmapContextCreate(info.bmBits, info.bmWidth, info.bmHeight, 8,
- info.bmWidthBytes, deviceRGBColorSpaceRef(), kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipFirst);
- 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;
- HWndDC dc(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);
- return hbmp;
-}
-
-DragImageRef createDragImageFromImage(Image* img, RespectImageOrientationEnum)
-{
- HBITMAP hbmp = 0;
- HWndDC dc(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);
- if (srcImage) {
- CGContextSetBlendMode(drawContext, kCGBlendModeNormal);
- CGContextDrawImage(drawContext, rect, srcImage);
- }
- CGContextRelease(drawContext);
-
-exit:
- if (workingDC)
- DeleteDC(workingDC);
- return hbmp;
-}
-
-}
diff --git a/Source/WebCore/platform/win/DragImageWin.cpp b/Source/WebCore/platform/win/DragImageWin.cpp
deleted file mode 100644
index 5d06e31..0000000
--- a/Source/WebCore/platform/win/DragImageWin.cpp
+++ /dev/null
@@ -1,232 +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 "Font.h"
-#include "FontCache.h"
-#include "FontDescription.h"
-#include "FontSelector.h"
-#include "Frame.h"
-#include "GraphicsContext.h"
-#include "HWndDC.h"
-#include "Image.h"
-#include "Settings.h"
-#include "StringTruncator.h"
-#include "TextRun.h"
-#include "WebCoreTextRenderer.h"
-#include <wtf/RetainPtr.h>
-
-#include <windows.h>
-
-namespace WebCore {
-
-HBITMAP allocImage(HDC, IntSize, PlatformGraphicsContext** targetRef);
-void deallocContext(PlatformGraphicsContext* target);
-
-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* image)
-{
- if (!image)
- return 0;
-
- String filename = image->response().suggestedFilename();
-
- SHFILEINFO shfi = {0};
- if (FAILED(SHGetFileInfo(static_cast<LPCWSTR>(filename.charactersWithNullTermination()), FILE_ATTRIBUTE_NORMAL,
- &shfi, sizeof(shfi), SHGFI_ICON | SHGFI_USEFILEATTRIBUTES)))
- return 0;
-
- ICONINFO iconInfo;
- if (!GetIconInfo(shfi.hIcon, &iconInfo)) {
- DestroyIcon(shfi.hIcon);
- return 0;
- }
-
- DestroyIcon(shfi.hIcon);
- DeleteObject(iconInfo.hbmMask);
-
- return iconInfo.hbmColor;
-}
-
-const float DragLabelBorderX = 4;
-// Keep border_y in synch with DragController::LinkDragBorderInset.
-const float DragLabelBorderY = 2;
-const float DragLabelRadius = 5;
-const float LabelBorderYOffset = 2;
-
-const float MinDragLabelWidthBeforeClip = 120;
-const float MaxDragLabelWidth = 200;
-const float MaxDragLabelStringWidth = (MaxDragLabelWidth - 2 * DragLabelBorderX);
-
-const float DragLinkLabelFontsize = 11;
-const float DragLinkUrlFontSize = 10;
-
-static Font dragLabelFont(int size, bool bold, FontRenderingMode renderingMode)
-{
- Font result;
-#if !OS(WINCE)
- NONCLIENTMETRICS metrics;
- metrics.cbSize = sizeof(metrics);
- SystemParametersInfo(SPI_GETNONCLIENTMETRICS, metrics.cbSize, &metrics, 0);
-
- FontDescription description;
- description.setWeight(bold ? FontWeightBold : FontWeightNormal);
-
- FontFamily family;
- family.setFamily(metrics.lfSmCaptionFont.lfFaceName);
- description.setFamily(family);
- description.setSpecifiedSize((float)size);
- description.setComputedSize((float)size);
- description.setRenderingMode(renderingMode);
- result = Font(description, 0, 0);
- result.update(0);
-#endif
- return result;
-}
-
-DragImageRef createDragImageForLink(KURL& url, const String& inLabel, Frame* frame)
-{
- // This is more or less an exact match for the Mac OS X code.
-
- const Font* labelFont;
- const Font* urlFont;
- FontCachePurgePreventer fontCachePurgePreventer;
-
- if (frame->settings() && frame->settings()->fontRenderingMode() == AlternateRenderingMode) {
- static const Font alternateRenderingModeLabelFont = dragLabelFont(DragLinkLabelFontsize, true, AlternateRenderingMode);
- static const Font alternateRenderingModeURLFont = dragLabelFont(DragLinkUrlFontSize, false, AlternateRenderingMode);
- labelFont = &alternateRenderingModeLabelFont;
- urlFont = &alternateRenderingModeURLFont;
- } else {
- static const Font normalRenderingModeLabelFont = dragLabelFont(DragLinkLabelFontsize, true, NormalRenderingMode);
- static const Font normalRenderingModeURLFont = dragLabelFont(DragLinkUrlFontSize, false, NormalRenderingMode);
- labelFont = &normalRenderingModeLabelFont;
- urlFont = &normalRenderingModeURLFont;
- }
-
- bool drawURLString = true;
- bool clipURLString = false;
- bool clipLabelString = false;
-
- String urlString = url.string();
- String label = inLabel;
- if (label.isEmpty()) {
- drawURLString = false;
- label = urlString;
- }
-
- // First step in drawing the link drag image width.
- TextRun labelRun(label.impl());
- TextRun urlRun(urlString.impl());
- IntSize labelSize(labelFont->width(labelRun), labelFont->fontMetrics().ascent() + labelFont->fontMetrics().descent());
-
- if (labelSize.width() > MaxDragLabelStringWidth) {
- labelSize.setWidth(MaxDragLabelStringWidth);
- clipLabelString = true;
- }
-
- IntSize urlStringSize;
- IntSize imageSize(labelSize.width() + DragLabelBorderX * 2, labelSize.height() + DragLabelBorderY * 2);
-
- if (drawURLString) {
- urlStringSize.setWidth(urlFont->width(urlRun));
- urlStringSize.setHeight(urlFont->fontMetrics().ascent() + urlFont->fontMetrics().descent());
- imageSize.setHeight(imageSize.height() + urlStringSize.height());
- if (urlStringSize.width() > MaxDragLabelStringWidth) {
- imageSize.setWidth(MaxDragLabelWidth);
- clipURLString = true;
- } else
- imageSize.setWidth(std::max(labelSize.width(), urlStringSize.width()) + DragLabelBorderX * 2);
- }
-
- // We now know how big the image needs to be, so we create and
- // fill the background
- HBITMAP image = 0;
- HWndDC dc(0);
- HDC workingDC = CreateCompatibleDC(dc);
- if (!workingDC)
- return 0;
-
- PlatformGraphicsContext* contextRef;
- image = allocImage(workingDC, imageSize, &contextRef);
- if (!image) {
- DeleteDC(workingDC);
- return 0;
- }
-
- SelectObject(workingDC, image);
- GraphicsContext context(contextRef);
- // On Mac alpha is {0.7, 0.7, 0.7, 0.8}, however we can't control alpha
- // for drag images on win, so we use 1
- static const Color backgroundColor(140, 140, 140);
- static const IntSize radii(DragLabelRadius, DragLabelRadius);
- IntRect rect(0, 0, imageSize.width(), imageSize.height());
- context.fillRoundedRect(rect, radii, radii, radii, radii, backgroundColor, ColorSpaceDeviceRGB);
-
- // Draw the text
- static const Color topColor(0, 0, 0, 255); // original alpha = 0.75
- static const Color bottomColor(255, 255, 255, 127); // original alpha = 0.5
- if (drawURLString) {
- if (clipURLString)
- urlString = StringTruncator::rightTruncate(urlString, imageSize.width() - (DragLabelBorderX * 2.0f), *urlFont, StringTruncator::EnableRoundingHacks);
- IntPoint textPos(DragLabelBorderX, imageSize.height() - (LabelBorderYOffset + urlFont->fontMetrics().descent()));
- WebCoreDrawDoubledTextAtPoint(context, urlString, textPos, *urlFont, topColor, bottomColor);
- }
-
- if (clipLabelString)
- label = StringTruncator::rightTruncate(label, imageSize.width() - (DragLabelBorderX * 2.0f), *labelFont, StringTruncator::EnableRoundingHacks);
-
- IntPoint textPos(DragLabelBorderX, DragLabelBorderY + labelFont->pixelSize());
- WebCoreDrawDoubledTextAtPoint(context, label, textPos, *labelFont, topColor, bottomColor);
-
- deallocContext(contextRef);
- DeleteDC(workingDC);
- return image;
-}
-
-}
diff --git a/Source/WebCore/platform/win/EditorWin.cpp b/Source/WebCore/platform/win/EditorWin.cpp
deleted file mode 100644
index 4838552..0000000
--- a/Source/WebCore/platform/win/EditorWin.cpp
+++ /dev/null
@@ -1,53 +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 "Frame.h"
-#include "htmlediting.h"
-#include "TextIterator.h"
-#include "VisibleUnits.h"
-
-#include <windows.h>
-
-namespace WebCore {
-
-PassRefPtr<Clipboard> Editor::newGeneralClipboard(ClipboardAccessPolicy policy, Frame* frame)
-{
- COMPtr<IDataObject> clipboardData;
-#if !OS(WINCE)
- if (!SUCCEEDED(OleGetClipboard(&clipboardData)))
- clipboardData = 0;
-#endif
-
- return ClipboardWin::create(Clipboard::CopyAndPaste, clipboardData.get(), policy, frame);
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/win/EventLoopWin.cpp b/Source/WebCore/platform/win/EventLoopWin.cpp
deleted file mode 100644
index ece320f..0000000
--- a/Source/WebCore/platform/win/EventLoopWin.cpp
+++ /dev/null
@@ -1,45 +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"
-
-#include <windows.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/Source/WebCore/platform/win/FileSystemWin.cpp b/Source/WebCore/platform/win/FileSystemWin.cpp
deleted file mode 100644
index 197d509..0000000
--- a/Source/WebCore/platform/win/FileSystemWin.cpp
+++ /dev/null
@@ -1,402 +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 "FileMetadata.h"
-#include "NotImplemented.h"
-#include "PathWalker.h"
-#include <wtf/CryptographicallyRandomNumber.h>
-#include <wtf/HashMap.h>
-#include <wtf/text/CString.h>
-#include <wtf/text/WTFString.h>
-
-#include <windows.h>
-#include <shlobj.h>
-#include <shlwapi.h>
-
-namespace WebCore {
-
-static const ULONGLONG kSecondsFromFileTimeToTimet = 11644473600;
-
-static bool getFindData(String path, WIN32_FIND_DATAW& findData)
-{
- HANDLE handle = FindFirstFileW(path.charactersWithNullTermination(), &findData);
- if (handle == INVALID_HANDLE_VALUE)
- return false;
- FindClose(handle);
- return true;
-}
-
-static bool getFileSizeFromFindData(const WIN32_FIND_DATAW& findData, long long& size)
-{
- ULARGE_INTEGER fileSize;
- fileSize.HighPart = findData.nFileSizeHigh;
- fileSize.LowPart = findData.nFileSizeLow;
-
- if (fileSize.QuadPart > static_cast<ULONGLONG>(std::numeric_limits<long long>::max()))
- return false;
-
- size = fileSize.QuadPart;
- return true;
-}
-
-static void getFileModificationTimeFromFindData(const WIN32_FIND_DATAW& findData, time_t& time)
-{
- ULARGE_INTEGER fileTime;
- fileTime.HighPart = findData.ftLastWriteTime.dwHighDateTime;
- fileTime.LowPart = findData.ftLastWriteTime.dwLowDateTime;
-
- // Information about converting time_t to FileTime is available at http://msdn.microsoft.com/en-us/library/ms724228%28v=vs.85%29.aspx
- time = fileTime.QuadPart / 10000000 - kSecondsFromFileTimeToTimet;
-}
-
-bool getFileSize(const String& path, long long& size)
-{
- WIN32_FIND_DATAW findData;
- if (!getFindData(path, findData))
- return false;
-
- return getFileSizeFromFindData(findData, size);
-}
-
-bool getFileModificationTime(const String& path, time_t& time)
-{
- WIN32_FIND_DATAW findData;
- if (!getFindData(path, findData))
- return false;
-
- getFileModificationTimeFromFindData(findData, time);
- return true;
-}
-
-bool getFileMetadata(const String& path, FileMetadata& metadata)
-{
- WIN32_FIND_DATAW findData;
- if (!getFindData(path, findData))
- return false;
-
- if (!getFileSizeFromFindData(findData, metadata.length))
- return false;
-
- time_t modificationTime;
- getFileModificationTimeFromFindData(findData, modificationTime);
- metadata.modificationTime = modificationTime;
-
- metadata.type = (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? FileMetadata::TypeDirectory : FileMetadata::TypeFile;
-
- return true;
-}
-
-bool fileExists(const String& path)
-{
- WIN32_FIND_DATAW findData;
- return getFindData(path, findData);
-}
-
-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);
-}
-
-#if !USE(CF)
-
-CString fileSystemRepresentation(const String& path)
-{
- const UChar* characters = path.characters();
- int size = WideCharToMultiByte(CP_ACP, 0, characters, path.length(), 0, 0, 0, 0) - 1;
-
- char* buffer;
- CString string = CString::newUninitialized(size, buffer);
-
- WideCharToMultiByte(CP_ACP, 0, characters, path.length(), buffer, size, 0, 0);
-
- return string;
-}
-
-#endif // !USE(CF)
-
-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)
-{
- String name = path.left(path.length() - pathGetFileName(path).length());
- if (name.characterStartingAt(name.length() - 1) == '\\') {
- // Remove any trailing "\".
- name.truncate(name.length() - 1);
- }
- return name;
-}
-
-static String bundleName()
-{
- DEFINE_STATIC_LOCAL(String, name, (ASCIILiteral("WebKit")));
-
-#if USE(CF)
- static bool initialized;
-
- if (!initialized) {
- initialized = true;
-
- if (CFBundleRef bundle = CFBundleGetMainBundle())
- if (CFTypeRef bundleExecutable = CFBundleGetValueForInfoDictionaryKey(bundle, kCFBundleExecutableKey))
- if (CFGetTypeID(bundleExecutable) == CFStringGetTypeID())
- name = reinterpret_cast<CFStringRef>(bundleExecutable);
- }
-#endif
-
- 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);
-
- DEFINE_STATIC_LOCAL(String, companyNameDirectory, (ASCIILiteral("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->value;
-
- String directory = storageDirectory(pathIdentifier);
- directories.add(pathIdentifier, directory);
-
- return directory;
-}
-
-String openTemporaryFile(const String&, PlatformFileHandle& handle)
-{
- handle = INVALID_HANDLE_VALUE;
-
- wchar_t tempPath[MAX_PATH];
- int tempPathLength = ::GetTempPathW(WTF_ARRAY_LENGTH(tempPath), tempPath);
- if (tempPathLength <= 0 || tempPathLength > WTF_ARRAY_LENGTH(tempPath))
- return String();
-
- String proposedPath;
- do {
- wchar_t tempFile[] = L"XXXXXXXX.tmp"; // Use 8.3 style name (more characters aren't helpful due to 8.3 short file names)
- const int randomPartLength = 8;
- cryptographicallyRandomValues(tempFile, randomPartLength * sizeof(wchar_t));
-
- // 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(wcslen(tempFile) == WTF_ARRAY_LENGTH(tempFile) - 1);
-
- proposedPath = pathByAppendingComponent(tempPath, tempFile);
- if (proposedPath.isEmpty())
- break;
-
- // use CREATE_NEW to avoid overwriting an existing file with the same name
- handle = ::CreateFileW(proposedPath.charactersWithNullTermination(), GENERIC_READ | GENERIC_WRITE, 0, 0, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0);
- } while (!isHandleValid(handle) && GetLastError() == ERROR_ALREADY_EXISTS);
-
- if (!isHandleValid(handle))
- return String();
-
- return proposedPath;
-}
-
-PlatformFileHandle openFile(const String& path, FileOpenMode mode)
-{
- DWORD desiredAccess = 0;
- DWORD creationDisposition = 0;
- switch (mode) {
- case OpenForRead:
- desiredAccess = GENERIC_READ;
- creationDisposition = OPEN_EXISTING;
- break;
- case OpenForWrite:
- desiredAccess = GENERIC_WRITE;
- creationDisposition = CREATE_ALWAYS;
- break;
- default:
- ASSERT_NOT_REACHED();
- }
-
- String destination = path;
- return CreateFile(destination.charactersWithNullTermination(), desiredAccess, 0, 0, creationDisposition, FILE_ATTRIBUTE_NORMAL, 0);
-}
-
-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);
-}
-
-#if USE(CF)
-
-bool safeCreateFile(const String& path, CFDataRef data)
-{
- // Create a temporary file.
- WCHAR tempDirPath[MAX_PATH];
- if (!GetTempPathW(WTF_ARRAY_LENGTH(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;
-}
-
-#endif // USE(CF)
-
-Vector<String> listDirectory(const String& directory, const String& filter)
-{
- Vector<String> entries;
-
- PathWalker walker(directory, filter);
- if (!walker.isValid())
- return entries;
-
- do {
- if (walker.data().dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- continue;
-
- entries.append(directory + "\\" + reinterpret_cast<const UChar*>(walker.data().cFileName));
- } while (walker.step());
-
- return entries;
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/win/GDIObjectCounter.cpp b/Source/WebCore/platform/win/GDIObjectCounter.cpp
deleted file mode 100644
index 9a5adc7..0000000
--- a/Source/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 "Logging.h"
-#include <wtf/text/CString.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/Source/WebCore/platform/win/GDIObjectCounter.h b/Source/WebCore/platform/win/GDIObjectCounter.h
deleted file mode 100644
index ea628c2..0000000
--- a/Source/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 <wtf/text/WTFString.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/Source/WebCore/platform/win/HWndDC.h b/Source/WebCore/platform/win/HWndDC.h
deleted file mode 100644
index 2eaecad..0000000
--- a/Source/WebCore/platform/win/HWndDC.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 2012 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 HWndDC_h
-#define HWndDC_h
-
-#include <windows.h>
-#include <wtf/NonCopyable.h>
-
-namespace WebCore {
-
-class HWndDC {
- WTF_MAKE_NONCOPYABLE(HWndDC);
-public:
- HWndDC()
- : m_hwnd(0)
- , m_hdc(0)
- {
- }
-
- explicit HWndDC(HWND hwnd)
- : m_hwnd(hwnd)
- , m_hdc(::GetDC(hwnd))
- {
- }
-
- HWndDC(HWND hwnd, HRGN hrgnClip, DWORD flags)
- : m_hwnd(hwnd)
- , m_hdc(::GetDCEx(hwnd, hrgnClip, flags))
- {
- }
-
- ~HWndDC()
- {
- clear();
- }
-
- HDC setHWnd(HWND hwnd)
- {
- clear();
- m_hwnd = hwnd;
- m_hdc = ::GetDC(hwnd);
- return m_hdc;
- }
-
- void clear()
- {
- if (!m_hdc)
- return;
- ::ReleaseDC(m_hwnd, m_hdc);
- m_hwnd = 0;
- m_hdc = 0;
- }
-
- operator HDC()
- {
- return m_hdc;
- }
-
-private:
- HWND m_hwnd;
- HDC m_hdc;
-};
-
-} // namespace WebCore
-
-#endif // HWndDC_h
diff --git a/Source/WebCore/platform/win/ImportedFunctionsEnumerator.cpp b/Source/WebCore/platform/win/ImportedFunctionsEnumerator.cpp
deleted file mode 100644
index f1100bb..0000000
--- a/Source/WebCore/platform/win/ImportedFunctionsEnumerator.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2011 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. 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 INC. 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 "ImportedFunctionsEnumerator.h"
-
-// See <http://msdn.microsoft.com/en-us/magazine/cc301808.aspx> and
-// <http://msdn.microsoft.com/en-us/windows/hardware/gg463119> for more information about the PE
-// image format.
-
-namespace WebCore {
-
-ImportedFunctionsEnumerator::ImportedFunctionsEnumerator(const PEImage& image, const IMAGE_THUNK_DATA* importNameTable, const IMAGE_THUNK_DATA* importAddressTable)
- : m_image(image)
- , m_nameTableEntry(importNameTable)
- , m_addressTableEntry(importAddressTable)
-{
- ASSERT(!importNameTable == !importAddressTable);
-}
-
-bool ImportedFunctionsEnumerator::isAtEnd() const
-{
- ASSERT(!m_nameTableEntry || !m_nameTableEntry->u1.AddressOfData == !m_addressTableEntry->u1.Function);
- return !m_nameTableEntry || !m_nameTableEntry->u1.AddressOfData;
-}
-
-void ImportedFunctionsEnumerator::next()
-{
- ASSERT(!isAtEnd());
- ++m_nameTableEntry;
- ++m_addressTableEntry;
-}
-
-const char* ImportedFunctionsEnumerator::currentFunctionName() const
-{
- ASSERT(m_nameTableEntry);
-
- // Ordinal imports have no name.
- if (IMAGE_SNAP_BY_ORDINAL(m_nameTableEntry->u1.Ordinal))
- return 0;
-
- const IMAGE_IMPORT_BY_NAME* importByName = static_cast<const IMAGE_IMPORT_BY_NAME*>(m_image.convertRVAToAddress(m_nameTableEntry->u1.AddressOfData));
- return reinterpret_cast<const char*>(importByName->Name);
-}
-
-const void* const* ImportedFunctionsEnumerator::addressOfCurrentFunctionPointer() const
-{
- ASSERT(m_addressTableEntry);
- COMPILE_ASSERT(sizeof(void*) == sizeof(m_addressTableEntry->u1.Function), FunctionAddressSizeMatchesPointerSize);
- return reinterpret_cast<const void* const*>(&m_addressTableEntry->u1.Function);
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/win/ImportedFunctionsEnumerator.h b/Source/WebCore/platform/win/ImportedFunctionsEnumerator.h
deleted file mode 100644
index e8e0a05..0000000
--- a/Source/WebCore/platform/win/ImportedFunctionsEnumerator.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2011 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. 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 INC. 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 ImportedFunctionsEnumerator_h
-#define ImportedFunctionsEnumerator_h
-
-#include "PEImage.h"
-
-namespace WebCore {
-
-// Enumerates the functions from a single module imported by the given PEImage.
-class ImportedFunctionsEnumerator {
-public:
- explicit ImportedFunctionsEnumerator(const PEImage&, const IMAGE_THUNK_DATA* importNameTable, const IMAGE_THUNK_DATA* importAddressTable);
-
- bool isAtEnd() const;
- void next();
-
- const char* currentFunctionName() const;
- const void* const* addressOfCurrentFunctionPointer() const;
-
-private:
- const DWORD& currentFunctionAddress() const;
-
- PEImage m_image;
-
- // These point to corresponding entries in the Import Name Table (INT) and Import Address Table
- // (IAT) for a particular module. The INT and IAT are parallel arrays that are terminated by an
- // all-0 entry.
- const IMAGE_THUNK_DATA* m_nameTableEntry;
- const IMAGE_THUNK_DATA* m_addressTableEntry;
-};
-
-} // namespace WebCore
-
-#endif // ImportedFunctionsEnumerator_h
diff --git a/Source/WebCore/platform/win/ImportedModulesEnumerator.cpp b/Source/WebCore/platform/win/ImportedModulesEnumerator.cpp
deleted file mode 100644
index 3543374..0000000
--- a/Source/WebCore/platform/win/ImportedModulesEnumerator.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2011 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. 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 INC. 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 "ImportedModulesEnumerator.h"
-
-#include "ImportedFunctionsEnumerator.h"
-
-// See <http://msdn.microsoft.com/en-us/magazine/cc301808.aspx> and
-// <http://msdn.microsoft.com/en-us/windows/hardware/gg463119> for more information about the PE
-// image format.
-
-namespace WebCore {
-
-ImportedModulesEnumerator::ImportedModulesEnumerator(const PEImage& image)
- : m_image(image)
-{
- if (m_image.isValid())
- m_descriptor = static_cast<const IMAGE_IMPORT_DESCRIPTOR*>(m_image.dataDirectoryEntryAddress(IMAGE_DIRECTORY_ENTRY_IMPORT));
- else
- m_descriptor = 0;
-}
-
-bool ImportedModulesEnumerator::isAtEnd() const
-{
- return !m_descriptor || !m_descriptor->Characteristics;
-}
-
-void ImportedModulesEnumerator::next()
-{
- ASSERT(!isAtEnd());
- ++m_descriptor;
-}
-
-const char* ImportedModulesEnumerator::currentModuleName() const
-{
- ASSERT(m_descriptor);
- return static_cast<const char*>(m_image.convertRVAToAddress(m_descriptor->Name));
-}
-
-ImportedFunctionsEnumerator ImportedModulesEnumerator::functionsEnumerator() const
-{
- ASSERT(m_descriptor);
-
- const IMAGE_THUNK_DATA* importNameTable = static_cast<const IMAGE_THUNK_DATA*>(m_image.convertRVAToAddress(m_descriptor->OriginalFirstThunk));
- const IMAGE_THUNK_DATA* importAddressTable = static_cast<const IMAGE_THUNK_DATA*>(m_image.convertRVAToAddress(m_descriptor->FirstThunk));
-
- return ImportedFunctionsEnumerator(m_image, importNameTable, importAddressTable);
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/win/ImportedModulesEnumerator.h b/Source/WebCore/platform/win/ImportedModulesEnumerator.h
deleted file mode 100644
index da7342f..0000000
--- a/Source/WebCore/platform/win/ImportedModulesEnumerator.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2011 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. 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 INC. 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 ImportedModulesEnumerator_h
-#define ImportedModulesEnumerator_h
-
-#include "ImportedModulesEnumeratorBase.h"
-#include "PEImage.h"
-
-namespace WebCore {
-
-// Enumerates all non-delay-loaded modules imported by the given PEImage.
-class ImportedModulesEnumerator : public ImportedModulesEnumeratorBase {
-public:
- explicit ImportedModulesEnumerator(const PEImage&);
-
- virtual bool isAtEnd() const;
- virtual void next();
-
- virtual const char* currentModuleName() const;
- virtual ImportedFunctionsEnumerator functionsEnumerator() const;
-
-private:
- PEImage m_image;
- const IMAGE_IMPORT_DESCRIPTOR* m_descriptor;
-};
-
-} // namespace WebCore
-
-#endif // ImportedModulesEnumerator_h
diff --git a/Source/WebCore/platform/win/ImportedModulesEnumeratorBase.h b/Source/WebCore/platform/win/ImportedModulesEnumeratorBase.h
deleted file mode 100644
index 9f7842b..0000000
--- a/Source/WebCore/platform/win/ImportedModulesEnumeratorBase.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2011 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. 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 INC. 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 ImportedModulesEnumeratorBase_h
-#define ImportedModulesEnumeratorBase_h
-
-namespace WebCore {
-
-class ImportedFunctionsEnumerator;
-
-class ImportedModulesEnumeratorBase {
-public:
- virtual bool isAtEnd() const = 0;
- virtual void next() = 0;
-
- virtual const char* currentModuleName() const = 0;
- virtual ImportedFunctionsEnumerator functionsEnumerator() const = 0;
-
-protected:
- virtual ~ImportedModulesEnumeratorBase() { }
-};
-
-} // namespace WebCore
-
-#endif // ImportedModulesEnumeratorBase_h
diff --git a/Source/WebCore/platform/win/KeyEventWin.cpp b/Source/WebCore/platform/win/KeyEventWin.cpp
deleted file mode 100644
index 03c8ea2..0000000
--- a/Source/WebCore/platform/win/KeyEventWin.cpp
+++ /dev/null
@@ -1,255 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2010 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>
-
-#ifndef MAPVK_VSC_TO_VK_EX
-#define MAPVK_VSC_TO_VK_EX 3
-#endif
-
-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, PlatformEvent::Type type)
-{
- if (type != PlatformEvent::RawKeyDown && type != PlatformEvent::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 int windowsKeycodeWithLocation(WPARAM keycode, LPARAM keyData)
-{
- if (keycode != VK_CONTROL && keycode != VK_MENU && keycode != VK_SHIFT)
- return keycode;
-
- // If we don't need to support Windows XP or older Windows,
- // it might be better to use MapVirtualKeyEx with scancode and
- // extended keycode (i.e. 0xe0 or 0xe1).
- if ((keyData >> 16) & KF_EXTENDED) {
- switch (keycode) {
- case VK_CONTROL:
- return VK_RCONTROL;
- case VK_SHIFT:
- return VK_RSHIFT;
- case VK_MENU:
- return VK_RMENU;
- default:
- break;
- }
- }
-
- int scancode = (keyData >> 16) & 0xFF;
- int regeneratedVirtualKeyCode = ::MapVirtualKey(scancode, MAPVK_VSC_TO_VK_EX);
- return regeneratedVirtualKeyCode ? regeneratedVirtualKeyCode : keycode;
-}
-
-static inline String singleCharacterString(UChar c)
-{
- return String(&c, 1);
-}
-
-PlatformKeyboardEvent::PlatformKeyboardEvent(HWND, WPARAM code, LPARAM keyData, Type type, bool systemKey)
- : PlatformEvent(type, GetKeyState(VK_SHIFT) & HIGH_BIT_MASK_SHORT, GetKeyState(VK_CONTROL) & HIGH_BIT_MASK_SHORT, GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT, false, ::GetTickCount() * 0.001)
- , m_text((type == PlatformEvent::Char) ? singleCharacterString(code) : String())
- , m_unmodifiedText((type == PlatformEvent::Char) ? singleCharacterString(code) : String())
- , m_keyIdentifier((type == PlatformEvent::Char) ? String() : keyIdentifierForWindowsKeyCode(code))
- , m_windowsVirtualKeyCode((type == RawKeyDown || type == KeyUp) ? windowsKeycodeWithLocation(code, keyData) : 0)
- , m_nativeVirtualKeyCode(m_windowsVirtualKeyCode)
- , m_macCharCode(0)
- , m_autoRepeat(HIWORD(keyData) & KF_REPEAT)
- , m_isKeypad(isKeypadEvent(code, keyData, type))
- , 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;
-}
-
-void PlatformKeyboardEvent::getCurrentModifierState(bool& shiftKey, bool& ctrlKey, bool& altKey, bool& metaKey)
-{
- shiftKey = GetKeyState(VK_SHIFT) & HIGH_BIT_MASK_SHORT;
- ctrlKey = GetKeyState(VK_CONTROL) & HIGH_BIT_MASK_SHORT;
- altKey = GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT;
- metaKey = false;
-}
-
-}
diff --git a/Source/WebCore/platform/win/LanguageWin.cpp b/Source/WebCore/platform/win/LanguageWin.cpp
deleted file mode 100644
index 006dc10..0000000
--- a/Source/WebCore/platform/win/LanguageWin.cpp
+++ /dev/null
@@ -1,77 +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 <windows.h>
-#include <wtf/Vector.h>
-#include <wtf/text/WTFString.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;
- UChar* localeNameBuf;
- String localeName = String::createUninitialized(localeChars, localeNameBuf);
- localeChars = GetLocaleInfo(langID, localeType, localeNameBuf, localeChars);
- if (!localeChars)
- return fallback;
- if (localeName.isEmpty())
- return fallback;
-
- localeName.truncate(localeName.length() - 1);
- return localeName;
-}
-
-static String platformLanguage()
-{
- 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 = languageName + '-' + countryName;
-
- return computedDefaultLanguage;
-}
-
-Vector<String> platformUserPreferredLanguages()
-{
- Vector<String> userPreferredLanguages;
- userPreferredLanguages.append(platformLanguage());
- return userPreferredLanguages;
-}
-
-}
diff --git a/Source/WebCore/platform/win/LocalizedStringsWin.cpp b/Source/WebCore/platform/win/LocalizedStringsWin.cpp
deleted file mode 100644
index cc2f5c2..0000000
--- a/Source/WebCore/platform/win/LocalizedStringsWin.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (C) 2011 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. 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 INC. 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 "LocalizedStrings.h"
-
-#include "WebCoreInstanceHandle.h"
-#include <windows.h>
-#include <wtf/Assertions.h>
-#include <wtf/MainThread.h>
-#include <wtf/StdLibExtras.h>
-#include <wtf/text/WTFString.h>
-
-#if USE(CF)
-#include <CoreFoundation/CFBundle.h>
-#include <wtf/RetainPtr.h>
-#endif
-
-namespace WebCore {
-
-#if USE(CF)
-
-static CFBundleRef createWebKitBundle()
-{
- if (CFBundleRef existingBundle = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.WebKit"))) {
- CFRetain(existingBundle);
- return existingBundle;
- }
-
- wchar_t dllPathBuffer[MAX_PATH];
- DWORD length = ::GetModuleFileNameW(instanceHandle(), dllPathBuffer, WTF_ARRAY_LENGTH(dllPathBuffer));
- ASSERT(length);
- ASSERT(length < WTF_ARRAY_LENGTH(dllPathBuffer));
-
- RetainPtr<CFStringRef> dllPath(AdoptCF, CFStringCreateWithCharactersNoCopy(0, reinterpret_cast<const UniChar*>(dllPathBuffer), length, kCFAllocatorNull));
- RetainPtr<CFURLRef> dllURL(AdoptCF, CFURLCreateWithFileSystemPath(0, dllPath.get(), kCFURLWindowsPathStyle, false));
- RetainPtr<CFURLRef> dllDirectoryURL(AdoptCF, CFURLCreateCopyDeletingLastPathComponent(0, dllURL.get()));
- RetainPtr<CFURLRef> resourcesDirectoryURL(AdoptCF, CFURLCreateCopyAppendingPathComponent(0, dllDirectoryURL.get(), CFSTR("WebKit.resources"), true));
-
- return CFBundleCreate(0, resourcesDirectoryURL.get());
-}
-
-static CFBundleRef webKitBundle()
-{
- static CFBundleRef bundle = createWebKitBundle();
- ASSERT(bundle);
- return bundle;
-}
-
-#endif // USE(CF)
-
-String localizedString(const char* key)
-{
- ASSERT(isMainThread());
-
-#if USE(CF)
- static CFStringRef notFound = CFSTR("localized string not found");
-
- RetainPtr<CFStringRef> keyString(AdoptCF, CFStringCreateWithCStringNoCopy(NULL, key, kCFStringEncodingUTF8, kCFAllocatorNull));
- RetainPtr<CFStringRef> result(AdoptCF, CFCopyLocalizedStringWithDefaultValue(keyString.get(), 0, webKitBundle(), notFound, 0));
- ASSERT_WITH_MESSAGE(result.get() != notFound, "could not find localizable string %s in bundle", key);
-
- return result.get();
-#else
- // FIXME: Implement localizedString() for !USE(CF).
- return String::fromUTF8(key, strlen(key));
-#endif
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/win/LoggingWin.cpp b/Source/WebCore/platform/win/LoggingWin.cpp
deleted file mode 100644
index 1d5fb00..0000000
--- a/Source/WebCore/platform/win/LoggingWin.cpp
+++ /dev/null
@@ -1,109 +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 "InitializeLogging.h"
-#include "Logging.h"
-
-#if !LOG_DISABLED
-
-#include <windows.h>
-#include <wtf/OwnArrayPtr.h>
-#include <wtf/text/WTFString.h>
-
-namespace WebCore {
-
-static inline void initializeWithUserDefault(WTFLogChannel& channel)
-{
- DWORD length = GetEnvironmentVariableA(channel.defaultName, 0, 0);
- if (!length)
- return;
-
- OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length]);
-
- if (!GetEnvironmentVariableA(channel.defaultName, buffer.get(), length))
- return;
-
- String variableValue(buffer.get());
-
- static const String& hexadecimalPrefix = *new String("0x");
- if (variableValue.length() < 3 || !variableValue.startsWith(hexadecimalPrefix, false)) {
- LOG_ERROR("Unable to parse hex value for %s (%s), logging is off", channel.defaultName, buffer.get());
- return;
- }
-
- String unprefixedValue = variableValue.substring(2);
-
- // Now parse the unprefixed string as a hexadecimal number.
- bool parsedSuccessfully = false;
- unsigned logLevel = unprefixedValue.toUIntStrict(&parsedSuccessfully, 16);
-
- if (!parsedSuccessfully) {
- LOG_ERROR("Unable to parse hex value for %s (%s), logging is off", channel.defaultName, buffer.get());
- return;
- }
-
- 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(LogLiveConnect);
- initializeWithUserDefault(LogIconDatabase);
- initializeWithUserDefault(LogSQLDatabase);
- initializeWithUserDefault(LogSpellingAndGrammar);
- initializeWithUserDefault(LogBackForward);
- initializeWithUserDefault(LogHistory);
- initializeWithUserDefault(LogPageCache);
- initializeWithUserDefault(LogPlatformLeaks);
- initializeWithUserDefault(LogResourceLoading);
- initializeWithUserDefault(LogNetwork);
- initializeWithUserDefault(LogFTP);
- initializeWithUserDefault(LogThreading);
- initializeWithUserDefault(LogStorageAPI);
- initializeWithUserDefault(LogMedia);
- initializeWithUserDefault(LogPlugins);
- initializeWithUserDefault(LogArchives);
- initializeWithUserDefault(LogProgress);
- initializeWithUserDefault(LogFileAPI);
-}
-
-} // namespace WebCore
-
-#endif // !LOG_DISABLED
diff --git a/Source/WebCore/platform/win/MIMETypeRegistryWin.cpp b/Source/WebCore/platform/win/MIMETypeRegistryWin.cpp
deleted file mode 100644
index ed7b425..0000000
--- a/Source/WebCore/platform/win/MIMETypeRegistryWin.cpp
+++ /dev/null
@@ -1,115 +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 "WindowsExtras.h"
-#include <wtf/Assertions.h>
-#include <wtf/HashMap.h>
-#include <wtf/MainThread.h>
-
-namespace WebCore {
-
-static String mimeTypeForExtension(const String& extension)
-{
- String ext = "." + extension;
- WCHAR contentTypeStr[256];
- DWORD contentTypeStrLen = sizeof(contentTypeStr);
- DWORD keyType;
-
- HRESULT result = getRegistryValue(HKEY_CLASSES_ROOT, ext.charactersWithNullTermination(), L"Content Type", &keyType, 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 path = "MIME\\Database\\Content Type\\" + type;
- WCHAR extStr[MAX_PATH];
- DWORD extStrLen = sizeof(extStr);
- DWORD keyType;
-
- HRESULT result = getRegistryValue(HKEY_CLASSES_ROOT, path.charactersWithNullTermination(), L"Extension", &keyType, 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)
-{
- ASSERT(isMainThread());
-
- 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");
- mimetypeMap.add("wml", "text/vnd.wap.wml");
- mimetypeMap.add("wmlc", "application/vnd.wap.wmlc");
- mimetypeMap.add("m4a", "audio/x-m4a");
- }
- String result = mimetypeMap.get(ext);
- if (result.isEmpty()) {
- result = mimeTypeForExtension(ext);
- if (!result.isEmpty())
- mimetypeMap.add(ext, result);
- }
- return result;
-}
-
-bool MIMETypeRegistry::isApplicationPluginMIMEType(const String&)
-{
- return false;
-}
-
-}
diff --git a/Source/WebCore/platform/win/PEImage.cpp b/Source/WebCore/platform/win/PEImage.cpp
deleted file mode 100644
index abea4fb..0000000
--- a/Source/WebCore/platform/win/PEImage.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2011 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. 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 INC. 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 "PEImage.h"
-
-// See <http://msdn.microsoft.com/en-us/magazine/cc301808.aspx> and
-// <http://msdn.microsoft.com/en-us/windows/hardware/gg463119> for more information about the PE
-// image format.
-
-namespace WebCore {
-
-PEImage::PEImage(HMODULE module)
- : m_module(module)
- , m_ntHeaders(0)
-{
- const IMAGE_DOS_HEADER* dosHeader = reinterpret_cast<const IMAGE_DOS_HEADER*>(m_module);
- if (dosHeader->e_magic != IMAGE_DOS_SIGNATURE)
- return;
-
- const IMAGE_NT_HEADERS* ntHeaders = static_cast<const IMAGE_NT_HEADERS*>(convertRVAToAddress(dosHeader->e_lfanew));
- if (ntHeaders->Signature != IMAGE_NT_SIGNATURE)
- return;
-
- if (ntHeaders->OptionalHeader.Magic != IMAGE_NT_OPTIONAL_HDR_MAGIC)
- return;
-
- m_ntHeaders = ntHeaders;
-}
-
-const void* PEImage::convertRVAToAddress(DWORD rva) const
-{
- return reinterpret_cast<unsigned char*>(m_module) + rva;
-}
-
-const void* PEImage::dataDirectoryEntryAddress(DWORD entryIndex) const
-{
- if (!isValid())
- return 0;
-
- if (m_ntHeaders->OptionalHeader.NumberOfRvaAndSizes <= entryIndex)
- return 0;
-
- const IMAGE_DATA_DIRECTORY& directory = m_ntHeaders->OptionalHeader.DataDirectory[entryIndex];
-
- if (!directory.Size)
- return 0;
-
- return convertRVAToAddress(directory.VirtualAddress);
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/win/PEImage.h b/Source/WebCore/platform/win/PEImage.h
deleted file mode 100644
index 50c534d..0000000
--- a/Source/WebCore/platform/win/PEImage.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2011 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. 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 INC. 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 PEImage_h
-#define PEImage_h
-
-#include <windows.h>
-
-namespace WebCore {
-
-class PEImage {
-public:
- explicit PEImage(HMODULE);
-
- bool isValid() const { return m_ntHeaders; }
-
- // A relative virtual address (RVA) is an address relative to the base of the image. This
- // function will convert an RVA to an non-relative address, which can then be dereferenced.
- const void* convertRVAToAddress(DWORD) const;
-
- // Returns the address of the data corresponding to the given entry in the image's
- // DataDirectory.
- const void* dataDirectoryEntryAddress(DWORD entryIndex) const;
-
-private:
- HMODULE m_module;
- const IMAGE_NT_HEADERS* m_ntHeaders;
-};
-
-} // namespace WebCore
-
-#endif // PEImage_h
diff --git a/Source/WebCore/platform/win/PasteboardWin.cpp b/Source/WebCore/platform/win/PasteboardWin.cpp
deleted file mode 100644
index 31ee75e..0000000
--- a/Source/WebCore/platform/win/PasteboardWin.cpp
+++ /dev/null
@@ -1,354 +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 "BitmapInfo.h"
-#include "CachedImage.h"
-#include "ClipboardUtilitiesWin.h"
-#include "Document.h"
-#include "DocumentFragment.h"
-#include "Element.h"
-#include "Frame.h"
-#include "HWndDC.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 "WebCoreInstanceHandle.h"
-#include "WindowsExtras.h"
-#include "markup.h"
-#include <wtf/text/CString.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;
-
- 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_DESTROY:
- break;
-#if !OS(WINCE)
- case WM_DRAWCLIPBOARD:
- break;
- case WM_CHANGECBCHAIN:
- break;
-#endif
- default:
- lresult = DefWindowProc(hWnd, message, wParam, lParam);
- break;
- }
- return lresult;
-}
-
-Pasteboard* Pasteboard::generalPasteboard()
-{
- static Pasteboard* pasteboard = new Pasteboard;
- return pasteboard;
-}
-
-Pasteboard::Pasteboard()
-{
- WNDCLASS wc;
- memset(&wc, 0, sizeof(WNDCLASS));
- wc.lpfnWndProc = PasteboardOwnerWndProc;
- wc.hInstance = WebCore::instanceHandle();
- wc.lpszClassName = L"PasteboardOwnerWindowClass";
- RegisterClass(&wc);
-
- 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, ShouldSerializeSelectedTextForClipboard shouldSerializeSelectedTextForClipboard)
-{
- clear();
-
- // Put CF_HTML format on the pasteboard
- if (::OpenClipboard(m_owner)) {
- Vector<char> data;
- markupToCFHTML(createMarkup(selectedRange, 0, AnnotateForInterchange),
- selectedRange->startContainer()->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 = shouldSerializeSelectedTextForClipboard == IncludeImageAltTextForClipboard ? frame->editor()->selectedTextForClipboard() : frame->editor()->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, 0);
- ::CloseClipboard();
- }
-
- }
-}
-
-void Pasteboard::writePlainText(const String& text, SmartReplaceOption smartReplaceOption)
-{
- clear();
-
- // Put plain string on the pasteboard. CF_UNICODETEXT covers CF_TEXT as well
- String str = text;
- replaceNewlinesWithWindowsStyleNewlines(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 (smartReplaceOption == CanSmartReplace) {
- if (::OpenClipboard(m_owner)) {
- ::SetClipboardData(WebSmartPasteFormat, 0);
- ::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;
- markupToCFHTML(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);
-
- if (!(node->renderer() && node->renderer()->isImage()))
- return;
-
- RenderImage* renderer = toRenderImage(node->renderer());
- CachedImage* cachedImage = renderer->cachedImage();
- if (!cachedImage || cachedImage->errorOccurred())
- return;
- Image* image = cachedImage->imageForRenderer(renderer);
- ASSERT(image);
-
- clear();
-
- HWndDC dc(0);
- HDC compatibleDC = CreateCompatibleDC(0);
- HDC sourceDC = CreateCompatibleDC(0);
- OwnPtr<HBITMAP> resultBitmap = adoptPtr(CreateCompatibleBitmap(dc, image->width(), image->height()));
- HGDIOBJ oldBitmap = SelectObject(compatibleDC, resultBitmap.get());
-
- BitmapInfo bmInfo = BitmapInfo::create(image->size());
-
- HBITMAP coreBitmap = CreateDIBSection(dc, &bmInfo, DIB_RGB_COLORS, 0, 0, 0);
- HGDIOBJ oldSource = SelectObject(sourceDC, coreBitmap);
- image->getHBITMAP(coreBitmap);
-
- BitBlt(compatibleDC, 0, 0, image->width(), image->height(), sourceDC, 0, 0, SRCCOPY);
-
- SelectObject(sourceDC, oldSource);
- DeleteObject(coreBitmap);
-
- SelectObject(compatibleDC, oldBitmap);
- DeleteDC(sourceDC);
- DeleteDC(compatibleDC);
-
- if (::OpenClipboard(m_owner)) {
- ::SetClipboardData(CF_BITMAP, resultBitmap.leakPtr());
- ::CloseClipboard();
- }
-}
-
-void Pasteboard::writeClipboard(Clipboard*)
-{
- notImplemented();
-}
-
-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 = static_cast<UChar*>(GlobalLock(cbData));
- String fromClipboard(buffer);
- GlobalUnlock(cbData);
- ::CloseClipboard();
- return fromClipboard;
- }
- ::CloseClipboard();
- }
-
- if (::IsClipboardFormatAvailable(CF_TEXT) && ::OpenClipboard(m_owner)) {
- HANDLE cbData = ::GetClipboardData(CF_TEXT);
- if (cbData) {
- char* buffer = static_cast<char*>(GlobalLock(cbData));
- String fromClipboard(buffer);
- GlobalUnlock(cbData);
- ::CloseClipboard();
- return fromClipboard;
- }
- ::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 cfhtml(UTF8Encoding().decode(static_cast<char*>(GlobalLock(cbData)), dataSize));
- GlobalUnlock(cbData);
- ::CloseClipboard();
-
- PassRefPtr<DocumentFragment> fragment = fragmentFromCFHTML(frame->document(), cfhtml);
- 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 = static_cast<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 = static_cast<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/Source/WebCore/platform/win/PathWalker.cpp b/Source/WebCore/platform/win/PathWalker.cpp
deleted file mode 100644
index e96ed69..0000000
--- a/Source/WebCore/platform/win/PathWalker.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2011 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. 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 INC. 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 "PathWalker.h"
-
-#include <wtf/text/WTFString.h>
-
-namespace WebCore {
-
-PathWalker::PathWalker(const String& directory, const String& pattern)
-{
- String path = directory + "\\" + pattern;
- m_handle = ::FindFirstFileW(path.charactersWithNullTermination(), &m_data);
-}
-
-PathWalker::~PathWalker()
-{
- if (!isValid())
- return;
- ::FindClose(m_handle);
-}
-
-bool PathWalker::step()
-{
- return ::FindNextFileW(m_handle, &m_data);
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/win/PathWalker.h b/Source/WebCore/platform/win/PathWalker.h
deleted file mode 100644
index 219c837..0000000
--- a/Source/WebCore/platform/win/PathWalker.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2011 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. 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 INC. 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 <Windows.h>
-#include <wtf/Noncopyable.h>
-
-namespace WTF {
- class String;
-}
-
-namespace WebCore {
-
-class PathWalker {
- WTF_MAKE_NONCOPYABLE(PathWalker);
-public:
- PathWalker(const WTF::String& directory, const WTF::String& pattern);
- ~PathWalker();
-
- bool isValid() const { return m_handle != INVALID_HANDLE_VALUE; }
- const WIN32_FIND_DATAW& data() const { return m_data; }
-
- bool step();
-
-private:
- HANDLE m_handle;
- WIN32_FIND_DATAW m_data;
-};
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/win/PlatformMouseEventWin.cpp b/Source/WebCore/platform/win/PlatformMouseEventWin.cpp
deleted file mode 100644
index afd638d..0000000
--- a/Source/WebCore/platform/win/PlatformMouseEventWin.cpp
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2007-2008 Torch Mobile 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) 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 <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 PlatformEvent::Type 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 PlatformEvent::MousePressed;
-
- case WM_LBUTTONUP:
- case WM_RBUTTONUP:
- case WM_MBUTTONUP:
- return PlatformEvent::MouseReleased;
-
-#if !OS(WINCE)
- case WM_MOUSELEAVE:
-#endif
- case WM_MOUSEMOVE:
- return PlatformEvent::MouseMoved;
-
- default:
- ASSERT_NOT_REACHED();
- //Move is relatively harmless
- return PlatformEvent::MouseMoved;
- }
-}
-
-PlatformMouseEvent::PlatformMouseEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, bool didActivateWebView)
- : PlatformEvent(messageToEventType(message), wParam & MK_SHIFT, wParam & MK_CONTROL, GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT, GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT, ::GetTickCount() * 0.001)
- , m_position(positionForEvent(hWnd, lParam))
- , m_globalPosition(globalPositionForEvent(hWnd, lParam))
- , m_clickCount(0)
- , m_didActivateWebView(didActivateWebView)
- , m_modifierFlags(wParam)
-{
- 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:
-#if !OS(WINCE)
- case WM_MOUSELEAVE:
-#endif
- 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/Source/WebCore/platform/win/PlatformScreenWin.cpp b/Source/WebCore/platform/win/PlatformScreenWin.cpp
deleted file mode 100644
index bb1bcb0..0000000
--- a/Source/WebCore/platform/win/PlatformScreenWin.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2009 Torch Mobile, 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) 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 "IntRect.h"
-#include "NotImplemented.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()->platformPageClient() : 0;
- HMONITOR monitor = MonitorFromWindow(window, MONITOR_DEFAULTTOPRIMARY);
-
- MONITORINFOEX monitorInfo;
- monitorInfo.cbSize = sizeof(MONITORINFOEX);
- GetMonitorInfo(monitor, &monitorInfo);
- return monitorInfo;
-}
-
-static DEVMODE deviceInfoForWidget(Widget* widget)
-{
- DEVMODE deviceInfo;
- deviceInfo.dmSize = sizeof(DEVMODE);
- deviceInfo.dmDriverExtra = 0;
-#if OS(WINCE)
- if (!EnumDisplaySettings(0, ENUM_CURRENT_SETTINGS, &deviceInfo))
- deviceInfo.dmBitsPerPel = 16;
-#else
- MONITORINFOEX monitorInfo = monitorInfoForWidget(widget);
- EnumDisplaySettings(monitorInfo.szDevice, ENUM_CURRENT_SETTINGS, &deviceInfo);
-#endif
-
- return deviceInfo;
-}
-
-int screenDepth(Widget* widget)
-{
- DEVMODE deviceInfo = deviceInfoForWidget(widget);
- if (deviceInfo.dmBitsPerPel == 32) {
- // Some video drivers return 32, but this function is supposed to ignore the alpha
- // component. See <http://webkit.org/b/42972>.
- return 24;
- }
- return deviceInfo.dmBitsPerPel;
-}
-
-int screenDepthPerComponent(Widget* widget)
-{
- // FIXME: Assumes RGB -- not sure if this is right.
- return screenDepth(widget) / 3;
-}
-
-bool screenIsMonochrome(Widget* widget)
-{
-#if OS(WINCE)
- // EnumDisplaySettings doesn't set dmColor in DEVMODE.
- return false;
-#else
- DEVMODE deviceInfo = deviceInfoForWidget(widget);
- return deviceInfo.dmColor == DMCOLOR_MONOCHROME;
-#endif
-}
-
-FloatRect screenRect(Widget* widget)
-{
- MONITORINFOEX monitorInfo = monitorInfoForWidget(widget);
- return monitorInfo.rcMonitor;
-}
-
-FloatRect screenAvailableRect(Widget* widget)
-{
- MONITORINFOEX monitorInfo = monitorInfoForWidget(widget);
- return monitorInfo.rcWork;
-}
-
-void screenColorProfile(ColorProfile&)
-{
- notImplemented();
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/win/PopupMenuWin.cpp b/Source/WebCore/platform/win/PopupMenuWin.cpp
deleted file mode 100644
index 280c485..0000000
--- a/Source/WebCore/platform/win/PopupMenuWin.cpp
+++ /dev/null
@@ -1,1088 +0,0 @@
-/*
- * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved.
- * Copyright (C) 2007-2009 Torch Mobile Inc.
- * Copyright (C) 2010 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 "PopupMenuWin.h"
-
-#include "BitmapInfo.h"
-#include "Document.h"
-#include "FloatRect.h"
-#include "FontSelector.h"
-#include "Frame.h"
-#include "FrameView.h"
-#include "GraphicsContext.h"
-#include "HTMLNames.h"
-#include "HWndDC.h"
-#include "HostWindow.h"
-#include "LengthFunctions.h"
-#include "Page.h"
-#include "PlatformMouseEvent.h"
-#include "PlatformScreen.h"
-#include "RenderMenuList.h"
-#include "RenderTheme.h"
-#include "RenderView.h"
-#include "Scrollbar.h"
-#include "ScrollbarTheme.h"
-#include "SimpleFontData.h"
-#include "TextRun.h"
-#include "WebCoreInstanceHandle.h"
-#include "WindowsExtras.h"
-
-#include <windows.h>
-#include <windowsx.h>
-#if OS(WINCE)
-#include <ResDefCE.h>
-#define MAKEPOINTS(l) (*((POINTS FAR *)&(l)))
-#endif
-
-#define HIGH_BIT_MASK_SHORT 0x8000
-
-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;
-
-const int optionSpacingMiddle = 1;
-const int popupWindowBorderWidth = 1;
-
-static LPCWSTR kPopupWindowClassName = L"PopupWindowClass";
-
-// This is used from within our custom message pump when we want to send a
-// message to the web view and not have our message stolen and sent to
-// the popup window.
-static const UINT WM_HOST_WINDOW_FIRST = WM_USER;
-static const UINT WM_HOST_WINDOW_CHAR = WM_USER + WM_CHAR;
-static const UINT WM_HOST_WINDOW_MOUSEMOVE = WM_USER + WM_MOUSEMOVE;
-
-// FIXME: Remove this as soon as practical.
-static inline bool isASCIIPrintable(unsigned c)
-{
- return c >= 0x20 && c <= 0x7E;
-}
-
-static void translatePoint(LPARAM& lParam, HWND from, HWND to)
-{
- POINT pt;
- pt.x = (short)GET_X_LPARAM(lParam);
- pt.y = (short)GET_Y_LPARAM(lParam);
- ::MapWindowPoints(from, to, &pt, 1);
- lParam = MAKELPARAM(pt.x, pt.y);
-}
-
-static FloatRect monitorFromHwnd(HWND hwnd)
-{
- HMONITOR monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTOPRIMARY);
- MONITORINFOEX monitorInfo;
- monitorInfo.cbSize = sizeof(MONITORINFOEX);
- GetMonitorInfo(monitor, &monitorInfo);
- return monitorInfo.rcWork;
-}
-
-PopupMenuWin::PopupMenuWin(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)
- , m_showPopup(false)
-{
-}
-
-PopupMenuWin::~PopupMenuWin()
-{
- if (m_bmp)
- ::DeleteObject(m_bmp);
- if (m_DC)
- ::DeleteDC(m_DC);
- if (m_popup)
- ::DestroyWindow(m_popup);
- if (m_scrollbar)
- m_scrollbar->setParent(0);
-}
-
-void PopupMenuWin::disconnectClient()
-{
- m_popupClient = 0;
-}
-
-LPCWSTR PopupMenuWin::popupClassName()
-{
- return kPopupWindowClassName;
-}
-
-void PopupMenuWin::show(const IntRect& r, FrameView* view, int index)
-{
- calculatePositionAndSize(r, view);
- if (clientRect().isEmpty())
- return;
-
- HWND hostWindow = view->hostWindow()->platformPageClient();
-
- if (!m_scrollbar && visibleItems() < client()->listSize()) {
- // We need a scroll bar
- m_scrollbar = client()->createScrollbar(this, VerticalScrollbar, SmallScrollbar);
- m_scrollbar->styleChanged();
- }
-
- // We need to reposition the popup window to its final coordinates.
- // Before calling this, the popup hwnd is currently the size of and at the location of the menu list client so it needs to be updated.
- ::MoveWindow(m_popup, m_windowRect.x(), m_windowRect.y(), m_windowRect.width(), m_windowRect.height(), false);
-
- // 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;
-#if !OS(WINCE)
- ::SystemParametersInfo(SPI_GETCOMBOBOXANIMATION, 0, &shouldAnimate, 0);
-
- if (shouldAnimate) {
- RECT viewRect = {0};
- ::GetWindowRect(hostWindow, &viewRect);
- if (!::IsRectEmpty(&viewRect))
- ::AnimateWindow(m_popup, defaultAnimationDuration, AW_BLEND);
- } else
-#endif
- ::ShowWindow(m_popup, SW_SHOWNOACTIVATE);
-
- if (client()) {
- int index = client()->selectedIndex();
- if (index >= 0)
- setFocusedIndex(index);
- }
-
- m_showPopup = true;
-
- // Protect the popup menu in case its owner is destroyed while we're running the message pump.
- RefPtr<PopupMenu> protect(this);
-
- ::SetCapture(hostWindow);
-
- MSG msg;
- HWND activeWindow;
-
- while (::GetMessage(&msg, 0, 0, 0)) {
- switch (msg.message) {
- case WM_HOST_WINDOW_MOUSEMOVE:
- case WM_HOST_WINDOW_CHAR:
- if (msg.hwnd == m_popup) {
- // This message should be sent to the host window.
- msg.hwnd = hostWindow;
- msg.message -= WM_HOST_WINDOW_FIRST;
- }
- break;
-
- // Steal mouse messages.
-#if !OS(WINCE)
- case WM_NCMOUSEMOVE:
- case WM_NCLBUTTONDOWN:
- case WM_NCLBUTTONUP:
- case WM_NCLBUTTONDBLCLK:
- case WM_NCRBUTTONDOWN:
- case WM_NCRBUTTONUP:
- case WM_NCRBUTTONDBLCLK:
- case WM_NCMBUTTONDOWN:
- case WM_NCMBUTTONUP:
- case WM_NCMBUTTONDBLCLK:
-#endif
- case WM_MOUSEWHEEL:
- msg.hwnd = m_popup;
- break;
-
- // These mouse messages use client coordinates so we need to convert them.
- case WM_MOUSEMOVE:
- case WM_LBUTTONDOWN:
- case WM_LBUTTONUP:
- case WM_LBUTTONDBLCLK:
- case WM_RBUTTONDOWN:
- case WM_RBUTTONUP:
- case WM_RBUTTONDBLCLK:
- case WM_MBUTTONDOWN:
- case WM_MBUTTONUP:
- case WM_MBUTTONDBLCLK: {
- // Translate the coordinate.
- translatePoint(msg.lParam, msg.hwnd, m_popup);
-
- msg.hwnd = m_popup;
- break;
- }
-
- // Steal all keyboard messages.
- case WM_KEYDOWN:
- case WM_KEYUP:
- case WM_CHAR:
- case WM_DEADCHAR:
- case WM_SYSKEYDOWN:
- case WM_SYSKEYUP:
- case WM_SYSCHAR:
- case WM_SYSDEADCHAR:
- msg.hwnd = m_popup;
- break;
- }
-
- ::TranslateMessage(&msg);
- ::DispatchMessage(&msg);
-
- if (!m_popupClient)
- break;
-
- if (!m_showPopup)
- break;
- activeWindow = ::GetActiveWindow();
- if (activeWindow != hostWindow && !::IsChild(activeWindow, hostWindow))
- break;
- if (::GetCapture() != hostWindow)
- break;
- }
-
- if (::GetCapture() == hostWindow)
- ::ReleaseCapture();
-
- // We're done, hide the popup if necessary.
- hide();
-}
-
-void PopupMenuWin::hide()
-{
- if (!m_showPopup)
- return;
-
- m_showPopup = false;
-
- ::ShowWindow(m_popup, SW_HIDE);
-
- if (client())
- client()->popupDidHide();
-
- // Post a WM_NULL message to wake up the message pump if necessary.
- ::PostMessage(m_popup, WM_NULL, 0, 0);
-}
-
-// The screen that the popup is placed on should be whichever one the popup menu button lies on.
-// We fake an hwnd (here we use the popup's hwnd) on top of the button which we can then use to determine the screen.
-// We can then proceed with our final position/size calculations.
-void PopupMenuWin::calculatePositionAndSize(const IntRect& r, FrameView* v)
-{
- // First get the screen coordinates of the popup menu client.
- HWND hostWindow = v->hostWindow()->platformPageClient();
- IntRect absoluteBounds = ((RenderMenuList*)m_popupClient)->absoluteBoundingBoxRect();
- IntRect absoluteScreenCoords(v->contentsToWindow(absoluteBounds.location()), absoluteBounds.size());
- POINT absoluteLocation(absoluteScreenCoords.location());
- if (!::ClientToScreen(v->hostWindow()->platformPageClient(), &absoluteLocation))
- return;
- absoluteScreenCoords.setLocation(absoluteLocation);
-
- // Now set the popup menu's location temporarily to these coordinates so we can determine which screen the popup should lie on.
- // We create or move m_popup as necessary.
- if (!m_popup) {
- registerClass();
- DWORD exStyle = WS_EX_LTRREADING;
- m_popup = ::CreateWindowExW(exStyle, kPopupWindowClassName, L"PopupMenu",
- WS_POPUP | WS_BORDER,
- absoluteScreenCoords.x(), absoluteScreenCoords.y(), absoluteScreenCoords.width(), absoluteScreenCoords.height(),
- hostWindow, 0, WebCore::instanceHandle(), this);
-
- if (!m_popup)
- return;
- } else
- ::MoveWindow(m_popup, absoluteScreenCoords.x(), absoluteScreenCoords.y(), absoluteScreenCoords.width(), absoluteScreenCoords.height(), false);
-
- FloatRect screen = monitorFromHwnd(m_popup);
-
- // Now we determine the actual location and measurements of the popup itself.
- // 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()->platformPageClient(), &location))
- return;
-
- rScreenCoords.setLocation(location);
-
- // First, determine the popup's height
- int itemCount = client()->listSize();
- m_itemHeight = client()->menuStyle().font().fontMetrics().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, static_cast<int>(ceilf(itemFont.width(TextRun(text.characters(), text.length())))));
- }
-
- if (naturalHeight > maxPopupHeight)
- // We need room for a scrollbar
- popupWidth += ScrollbarTheme::theme()->scrollbarThickness(SmallScrollbar);
-
- // Add padding to align the popup text with the <select> text
- popupWidth += max<int>(0, client()->clientPaddingRight() - client()->clientInsetRight()) + max<int>(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.maxY(), popupWidth, popupHeight);
-
- // Check that we don't go off the screen vertically
- if (popupRect.maxY() > 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() + popupRect.width() > screen.width() + screen.x())
- popupRect.setX(screen.x() + screen.width() - popupRect.width());
- if (popupRect.x() < screen.x())
- popupRect.setX(screen.x());
-
- m_windowRect = popupRect;
- return;
-}
-
-bool PopupMenuWin::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 PopupMenuWin::visibleItems() const
-{
- return clientRect().height() / m_itemHeight;
-}
-
-int PopupMenuWin::listIndexAtPoint(const IntPoint& point) const
-{
- return m_scrollOffset + point.y() / m_itemHeight;
-}
-
-int PopupMenuWin::focusedIndex() const
-{
- return m_focusedIndex;
-}
-
-void PopupMenuWin::focusFirst()
-{
- if (!client())
- return;
-
- int size = client()->listSize();
-
- for (int i = 0; i < size; ++i)
- if (client()->itemIsEnabled(i)) {
- setFocusedIndex(i);
- break;
- }
-}
-
-void PopupMenuWin::focusLast()
-{
- if (!client())
- return;
-
- int size = client()->listSize();
-
- for (int i = size - 1; i > 0; --i)
- if (client()->itemIsEnabled(i)) {
- setFocusedIndex(i);
- break;
- }
-}
-
-bool PopupMenuWin::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 PopupMenuWin::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 PopupMenuWin::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 PopupMenuWin::clientRect() const
-{
- IntRect clientRect = m_windowRect;
- clientRect.inflate(-popupWindowBorderWidth);
- clientRect.setLocation(IntPoint(0, 0));
- return clientRect;
-}
-
-void PopupMenuWin::incrementWheelDelta(int delta)
-{
- m_wheelDelta += delta;
-}
-
-void PopupMenuWin::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 PopupMenuWin::scrollToRevealSelection()
-{
- if (!m_scrollbar)
- return false;
-
- int index = focusedIndex();
-
- if (index < m_scrollOffset) {
- ScrollableArea::scrollToOffsetWithoutAnimation(VerticalScrollbar, index);
- return true;
- }
-
- if (index >= m_scrollOffset + visibleItems()) {
- ScrollableArea::scrollToOffsetWithoutAnimation(VerticalScrollbar, index - visibleItems() + 1);
- return true;
- }
-
- return false;
-}
-
-void PopupMenuWin::updateFromElement()
-{
- if (!m_popup)
- return;
-
- m_focusedIndex = client()->selectedIndex();
-
- ::InvalidateRect(m_popup, 0, TRUE);
- if (!scrollToRevealSelection())
- ::UpdateWindow(m_popup);
-}
-
-const int separatorPadding = 4;
-const int separatorHeight = 1;
-void PopupMenuWin::paint(const IntRect& damageRect, HDC hdc)
-{
- if (!m_popup)
- return;
-
- if (!m_DC) {
- m_DC = ::CreateCompatibleDC(HWndDC(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) {
-#if OS(WINCE)
- BitmapInfo bitmapInfo = BitmapInfo::createBottomUp(clientRect().size(), BitmapInfo::BitCount16);
-#else
- BitmapInfo bitmapInfo = BitmapInfo::createBottomUp(clientRect().size());
-#endif
- 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.maxY(); y += m_itemHeight) {
- int index = y / m_itemHeight;
-
- Color optionBackgroundColor, optionTextColor;
- PopupMenuStyle itemStyle = client()->itemStyle(index);
- if (index == focusedIndex()) {
- optionBackgroundColor = RenderTheme::defaultTheme()->activeListBoxSelectionBackgroundColor();
- optionTextColor = RenderTheme::defaultTheme()->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, ColorSpaceDeviceRGB);
-
- if (client()->itemIsSeparator(index)) {
- IntRect separatorRect(itemRect.x() + separatorPadding, itemRect.y() + (itemRect.height() - separatorHeight) / 2, itemRect.width() - 2 * separatorPadding, separatorHeight);
- context.fillRect(separatorRect, optionTextColor, ColorSpaceDeviceRGB);
- continue;
- }
-
- String itemText = client()->itemText(index);
-
- TextDirection direction = (itemText.defaultWritingDirection() == WTF::Unicode::RightToLeft) ? RTL : LTR;
- TextRun textRun(itemText, 0, 0, TextRun::AllowTrailingExpansion, direction);
-
- context.setFillColor(optionTextColor, ColorSpaceDeviceRGB);
-
- 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());
- }
-
- // Draw the item text
- if (itemStyle.isVisible()) {
- int textX = max<int>(0, client()->clientPaddingLeft() - client()->clientInsetLeft());
- if (RenderTheme::defaultTheme()->popupOptionSupportsTextIndent() && itemStyle.textDirection() == LTR)
- textX += minimumIntValueForLength(itemStyle.textIndent(), itemRect.width());
- int textY = itemRect.y() + itemFont.fontMetrics().ascent() + (itemRect.height() - itemFont.fontMetrics().height()) / 2;
- context.drawBidiText(itemFont, textRun, IntPoint(textX, textY));
- }
- }
-
- if (m_scrollbar)
- m_scrollbar->paint(&context, damageRect);
-
- HWndDC hWndDC;
- HDC localDC = hdc ? hdc : hWndDC.setHWnd(m_popup);
-
- ::BitBlt(localDC, damageRect.x(), damageRect.y(), damageRect.width(), damageRect.height(), m_DC, damageRect.x(), damageRect.y(), SRCCOPY);
-}
-
-int PopupMenuWin::scrollSize(ScrollbarOrientation orientation) const
-{
- return ((orientation == VerticalScrollbar) && m_scrollbar) ? (m_scrollbar->totalSize() - m_scrollbar->visibleSize()) : 0;
-}
-
-int PopupMenuWin::scrollPosition(Scrollbar*) const
-{
- return m_scrollOffset;
-}
-
-void PopupMenuWin::setScrollOffset(const IntPoint& offset)
-{
- scrollTo(offset.y());
-}
-
-void PopupMenuWin::scrollTo(int offset)
-{
- ASSERT(m_scrollbar);
-
- if (!m_popup)
- return;
-
- 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 PopupMenuWin::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect& rect)
-{
- IntRect scrollRect = rect;
- scrollRect.move(scrollbar->x(), scrollbar->y());
- RECT r = scrollRect;
- ::InvalidateRect(m_popup, &r, false);
-}
-
-int PopupMenuWin::visibleHeight() const
-{
- return m_scrollbar ? m_scrollbar->visibleSize() : m_windowRect.height();
-}
-
-int PopupMenuWin::visibleWidth() const
-{
- return m_windowRect.width();
-}
-
-IntSize PopupMenuWin::contentsSize() const
-{
- return m_windowRect.size();
-}
-
-bool PopupMenuWin::scrollbarsCanBeActive() const
-{
- return m_showPopup;
-}
-
-IntRect PopupMenuWin::scrollableAreaBoundingBox() const
-{
- return m_windowRect;
-}
-
-void PopupMenuWin::registerClass()
-{
- static bool haveRegisteredWindowClass = false;
-
- if (haveRegisteredWindowClass)
- return;
-
-#if OS(WINCE)
- WNDCLASS wcex;
-#else
- WNDCLASSEX wcex;
- wcex.cbSize = sizeof(WNDCLASSEX);
- wcex.hIconSm = 0;
- wcex.style = CS_DROPSHADOW;
-#endif
-
- wcex.lpfnWndProc = PopupMenuWndProc;
- wcex.cbClsExtra = 0;
- wcex.cbWndExtra = sizeof(PopupMenu*); // For the PopupMenu pointer
- wcex.hInstance = WebCore::instanceHandle();
- wcex.hIcon = 0;
- wcex.hCursor = LoadCursor(0, IDC_ARROW);
- wcex.hbrBackground = 0;
- wcex.lpszMenuName = 0;
- wcex.lpszClassName = kPopupWindowClassName;
-
- haveRegisteredWindowClass = true;
-
-#if OS(WINCE)
- RegisterClass(&wcex);
-#else
- RegisterClassEx(&wcex);
-#endif
-}
-
-
-LRESULT CALLBACK PopupMenuWin::PopupMenuWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
- if (PopupMenuWin* popup = static_cast<PopupMenuWin*>(getWindowPointer(hWnd, 0)))
- return popup->wndProc(hWnd, message, wParam, lParam);
-
- if (message == WM_CREATE) {
- LPCREATESTRUCT createStruct = reinterpret_cast<LPCREATESTRUCT>(lParam);
-
- // Associate the PopupMenu with the window.
- setWindowPointer(hWnd, 0, createStruct->lpCreateParams);
- return 0;
- }
-
- return ::DefWindowProc(hWnd, message, wParam, lParam);
-}
-
-const int smoothScrollAnimationDuration = 5000;
-
-LRESULT PopupMenuWin::wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
- LRESULT lResult = 0;
-
- switch (message) {
-#if !OS(WINCE)
- case WM_MOUSEACTIVATE:
- return MA_NOACTIVATE;
-#endif
- case WM_SIZE: {
- if (!scrollbar())
- break;
-
- IntSize size(LOWORD(lParam), HIWORD(lParam));
- scrollbar()->setFrameRect(IntRect(size.width() - scrollbar()->width(), 0, scrollbar()->width(), size.height()));
-
- int visibleItems = this->visibleItems();
- scrollbar()->setEnabled(visibleItems < client()->listSize());
- scrollbar()->setSteps(1, max(1, visibleItems - 1));
- scrollbar()->setProportion(visibleItems, client()->listSize());
-
- break;
- }
- case WM_SYSKEYDOWN:
- case WM_KEYDOWN: {
- if (!client())
- break;
-
- bool altKeyPressed = GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT;
- bool ctrlKeyPressed = GetKeyState(VK_CONTROL) & HIGH_BIT_MASK_SHORT;
-
- lResult = 0;
- switch (LOWORD(wParam)) {
- case VK_F4: {
- if (!altKeyPressed && !ctrlKeyPressed) {
- int index = focusedIndex();
- ASSERT(index >= 0);
- client()->valueChanged(index);
- hide();
- }
- break;
- }
- case VK_DOWN:
- if (altKeyPressed) {
- int index = focusedIndex();
- ASSERT(index >= 0);
- client()->valueChanged(index);
- hide();
- } else
- down();
- break;
- case VK_RIGHT:
- down();
- break;
- case VK_UP:
- if (altKeyPressed) {
- int index = focusedIndex();
- ASSERT(index >= 0);
- client()->valueChanged(index);
- hide();
- } else
- up();
- break;
- case VK_LEFT:
- up();
- break;
- case VK_HOME:
- focusFirst();
- break;
- case VK_END:
- focusLast();
- break;
- case VK_PRIOR:
- if (focusedIndex() != scrollOffset()) {
- // Set the selection to the first visible item
- int firstVisibleItem = scrollOffset();
- up(focusedIndex() - firstVisibleItem);
- } else {
- // The first visible item is selected, so move the selection back one page
- up(visibleItems());
- }
- break;
- case VK_NEXT: {
- int lastVisibleItem = scrollOffset() + visibleItems() - 1;
- if (focusedIndex() != lastVisibleItem) {
- // Set the selection to the last visible item
- down(lastVisibleItem - focusedIndex());
- } else {
- // The last visible item is selected, so move the selection forward one page
- down(visibleItems());
- }
- break;
- }
- case VK_TAB:
- ::SendMessage(client()->hostWindow()->platformPageClient(), message, wParam, lParam);
- hide();
- break;
- case VK_ESCAPE:
- hide();
- break;
- default:
- if (isASCIIPrintable(wParam))
- // Send the keydown to the WebView so it can be used for type-to-select.
- // Since we know that the virtual key is ASCII printable, it's OK to convert this to
- // a WM_CHAR message. (We don't want to call TranslateMessage because that will post a
- // WM_CHAR message that will be stolen and redirected to the popup HWND.
- ::PostMessage(m_popup, WM_HOST_WINDOW_CHAR, wParam, lParam);
- else
- lResult = 1;
- break;
- }
- break;
- }
- case WM_CHAR: {
- if (!client())
- break;
-
- lResult = 0;
- int index;
- switch (wParam) {
- case 0x0D: // Enter/Return
- hide();
- index = focusedIndex();
- ASSERT(index >= 0);
- client()->valueChanged(index);
- break;
- case 0x1B: // Escape
- hide();
- break;
- case 0x09: // TAB
- case 0x08: // Backspace
- case 0x0A: // Linefeed
- default: // Character
- lResult = 1;
- break;
- }
- break;
- }
- case WM_MOUSEMOVE: {
- IntPoint mousePoint(MAKEPOINTS(lParam));
- if (scrollbar()) {
- IntRect scrollBarRect = scrollbar()->frameRect();
- if (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()));
- scrollbar()->mouseMoved(event);
- break;
- }
- }
-
- BOOL shouldHotTrack = FALSE;
-#if !OS(WINCE)
- ::SystemParametersInfo(SPI_GETHOTTRACKING, 0, &shouldHotTrack, 0);
-#endif
-
- RECT bounds;
- GetClientRect(popupHandle(), &bounds);
- if (!::PtInRect(&bounds, mousePoint) && !(wParam & MK_LBUTTON) && client()) {
- // When the mouse is not inside the popup menu and the left button isn't down, just
- // repost the message to the web view.
-
- // Translate the coordinate.
- translatePoint(lParam, m_popup, client()->hostWindow()->platformPageClient());
-
- ::PostMessage(m_popup, WM_HOST_WINDOW_MOUSEMOVE, wParam, lParam);
- break;
- }
-
- if ((shouldHotTrack || wParam & MK_LBUTTON) && ::PtInRect(&bounds, mousePoint))
- setFocusedIndex(listIndexAtPoint(mousePoint), true);
-
- break;
- }
- case WM_LBUTTONDOWN: {
- IntPoint mousePoint(MAKEPOINTS(lParam));
- if (scrollbar()) {
- IntRect scrollBarRect = 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()));
- scrollbar()->mouseDown(event);
- setScrollbarCapturingMouse(true);
- break;
- }
- }
-
- // If the mouse is inside the window, update the focused index. Otherwise,
- // hide the popup.
- RECT bounds;
- GetClientRect(m_popup, &bounds);
- if (::PtInRect(&bounds, mousePoint))
- setFocusedIndex(listIndexAtPoint(mousePoint), true);
- else
- hide();
- break;
- }
- case WM_LBUTTONUP: {
- IntPoint mousePoint(MAKEPOINTS(lParam));
- if (scrollbar()) {
- IntRect scrollBarRect = scrollbar()->frameRect();
- if (scrollbarCapturingMouse() || scrollBarRect.contains(mousePoint)) {
- 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()));
- scrollbar()->mouseUp(event);
- // FIXME: This is a hack to work around Scrollbar not invalidating correctly when it doesn't have a parent widget
- RECT r = scrollBarRect;
- ::InvalidateRect(popupHandle(), &r, TRUE);
- break;
- }
- }
- // Only hide the popup if the mouse is inside the popup window.
- RECT bounds;
- GetClientRect(popupHandle(), &bounds);
- if (client() && ::PtInRect(&bounds, mousePoint)) {
- hide();
- int index = focusedIndex();
- if (index >= 0)
- client()->valueChanged(index);
- }
- break;
- }
-
- case WM_MOUSEWHEEL: {
- if (!scrollbar())
- break;
-
- int i = 0;
- for (incrementWheelDelta(GET_WHEEL_DELTA_WPARAM(wParam)); abs(wheelDelta()) >= WHEEL_DELTA; reduceWheelDelta(WHEEL_DELTA)) {
- if (wheelDelta() > 0)
- ++i;
- else
- --i;
- }
-
- ScrollableArea::scroll(i > 0 ? ScrollUp : ScrollDown, ScrollByLine, abs(i));
- break;
- }
-
- case WM_PAINT: {
- PAINTSTRUCT paintInfo;
- ::BeginPaint(popupHandle(), &paintInfo);
- paint(paintInfo.rcPaint, paintInfo.hdc);
- ::EndPaint(popupHandle(), &paintInfo);
- lResult = 0;
- break;
- }
-#if !OS(WINCE)
- case WM_PRINTCLIENT:
- paint(clientRect(), (HDC)wParam);
- break;
-#endif
- default:
- lResult = DefWindowProc(hWnd, message, wParam, lParam);
- }
-
- return lResult;
-}
-
-}
diff --git a/Source/WebCore/platform/win/PopupMenuWin.h b/Source/WebCore/platform/win/PopupMenuWin.h
deleted file mode 100644
index 85cab76..0000000
--- a/Source/WebCore/platform/win/PopupMenuWin.h
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
- * Copyright (C) 2010 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 PopupMenuWin_h
-#define PopupMenuWin_h
-
-#include "IntRect.h"
-#include "PopupMenu.h"
-#include "PopupMenuClient.h"
-#include "ScrollableArea.h"
-#include "Scrollbar.h"
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-
-typedef struct HWND__* HWND;
-typedef struct HDC__* HDC;
-typedef struct HBITMAP__* HBITMAP;
-
-namespace WebCore {
-
-class FrameView;
-class Scrollbar;
-
-class PopupMenuWin : public PopupMenu, private ScrollableArea {
-public:
- PopupMenuWin(PopupMenuClient*);
- ~PopupMenuWin();
-
- virtual void show(const IntRect&, FrameView*, int index);
- virtual void hide();
- virtual void updateFromElement();
- virtual void disconnectClient();
-
- static LPCWSTR popupClassName();
-
-private:
- PopupMenuClient* client() const { return m_popupClient; }
-
- 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; }
-
- 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; }
-
- // ScrollableArea
- virtual int scrollSize(ScrollbarOrientation) const OVERRIDE;
- virtual int scrollPosition(Scrollbar*) const OVERRIDE;
- virtual void setScrollOffset(const IntPoint&) OVERRIDE;
- virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&) OVERRIDE;
- virtual void invalidateScrollCornerRect(const IntRect&) OVERRIDE { }
- virtual bool isActive() const OVERRIDE { return true; }
- ScrollableArea* enclosingScrollableArea() const OVERRIDE { return 0; }
- virtual bool isScrollCornerVisible() const OVERRIDE { return false; }
- virtual IntRect scrollCornerRect() const OVERRIDE { return IntRect(); }
- virtual Scrollbar* verticalScrollbar() const OVERRIDE { return m_scrollbar.get(); }
- virtual int visibleHeight() const OVERRIDE;
- virtual int visibleWidth() const OVERRIDE;
- virtual IntSize contentsSize() const OVERRIDE;
- virtual bool scrollbarsCanBeActive() const OVERRIDE;
- virtual IntRect scrollableAreaBoundingBox() const OVERRIDE;
-
- // NOTE: This should only be called by the overriden setScrollOffset from ScrollableArea.
- void scrollTo(int offset);
-
- void calculatePositionAndSize(const IntRect&, FrameView*);
- void invalidateItem(int index);
-
- static LRESULT CALLBACK PopupMenuWndProc(HWND, UINT, WPARAM, LPARAM);
- LRESULT wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
- static void registerClass();
-
- PopupMenuClient* m_popupClient;
- 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;
- bool m_showPopup;
-};
-
-} // namespace WebCore
-
-#endif // PopupMenuWin_h
diff --git a/Source/WebCore/platform/win/RunLoopWin.cpp b/Source/WebCore/platform/win/RunLoopWin.cpp
deleted file mode 100644
index 17d6845..0000000
--- a/Source/WebCore/platform/win/RunLoopWin.cpp
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Copyright (C) 2010 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. 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 INC. 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 "RunLoop.h"
-
-#include "WindowsExtras.h"
-#include <wtf/CurrentTime.h>
-
-using namespace std;
-
-namespace WebCore {
-
-static const UINT PerformWorkMessage = WM_USER + 1;
-static const LPWSTR kRunLoopMessageWindowClassName = L"RunLoopMessageWindow";
-
-LRESULT CALLBACK RunLoop::RunLoopWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
- if (RunLoop* runLoop = static_cast<RunLoop*>(getWindowPointer(hWnd, 0)))
- return runLoop->wndProc(hWnd, message, wParam, lParam);
-
- if (message == WM_CREATE) {
- LPCREATESTRUCT createStruct = reinterpret_cast<LPCREATESTRUCT>(lParam);
-
- // Associate the RunLoop with the window.
- setWindowPointer(hWnd, 0, createStruct->lpCreateParams);
- return 0;
- }
-
- return ::DefWindowProc(hWnd, message, wParam, lParam);
-}
-
-LRESULT RunLoop::wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
- switch (message) {
- case PerformWorkMessage:
- performWork();
- return 0;
- case WM_TIMER:
- RunLoop::TimerBase::timerFired(this, wParam);
- return 0;
- }
-
- return ::DefWindowProc(hWnd, message, wParam, lParam);
-}
-
-void RunLoop::run()
-{
- MSG message;
- while (BOOL result = ::GetMessage(&message, 0, 0, 0)) {
- if (result == -1)
- break;
- ::TranslateMessage(&message);
- ::DispatchMessage(&message);
- }
-}
-
-void RunLoop::stop()
-{
- ::PostQuitMessage(0);
-}
-
-bool RunLoop::registerRunLoopMessageWindowClass()
-{
- // FIXME: This really only needs to be called once.
-
- WNDCLASS windowClass = { 0 };
- windowClass.lpfnWndProc = RunLoop::RunLoopWndProc;
- windowClass.cbWndExtra = sizeof(RunLoop*);
- windowClass.lpszClassName = kRunLoopMessageWindowClassName;
-
- return !!::RegisterClass(&windowClass);
-}
-
-RunLoop::RunLoop()
-{
- registerRunLoopMessageWindowClass();
-
- m_runLoopMessageWindow = ::CreateWindow(kRunLoopMessageWindowClassName, 0, 0,
- CW_USEDEFAULT, 0, CW_USEDEFAULT, 0,
- HWND_MESSAGE, 0, 0, this);
- ASSERT(::IsWindow(m_runLoopMessageWindow));
-}
-
-RunLoop::~RunLoop()
-{
- // FIXME: Tear down the work item queue here.
-}
-
-void RunLoop::wakeUp()
-{
- // FIXME: No need to wake up the run loop if we've already called dispatch
- // before the run loop has had the time to respond.
- ::PostMessage(m_runLoopMessageWindow, PerformWorkMessage, reinterpret_cast<WPARAM>(this), 0);
-}
-
-// RunLoop::Timer
-
-void RunLoop::TimerBase::timerFired(RunLoop* runLoop, uint64_t ID)
-{
- TimerMap::iterator it = runLoop->m_activeTimers.find(ID);
- if (it == runLoop->m_activeTimers.end()) {
- // The timer must have been stopped after the WM_TIMER message was posted to the message queue.
- return;
- }
-
- TimerBase* timer = it->value;
-
- if (!timer->m_isRepeating) {
- runLoop->m_activeTimers.remove(it);
- ::KillTimer(runLoop->m_runLoopMessageWindow, ID);
- }
-
- timer->fired();
-}
-
-static uint64_t generateTimerID()
-{
- static uint64_t uniqueTimerID = 1;
- return uniqueTimerID++;
-}
-
-RunLoop::TimerBase::TimerBase(RunLoop* runLoop)
- : m_runLoop(runLoop)
- , m_ID(generateTimerID())
- , m_isRepeating(false)
-{
-}
-
-RunLoop::TimerBase::~TimerBase()
-{
- stop();
-}
-
-void RunLoop::TimerBase::start(double nextFireInterval, bool repeat)
-{
- m_isRepeating = repeat;
- m_runLoop->m_activeTimers.set(m_ID, this);
- ::SetTimer(m_runLoop->m_runLoopMessageWindow, m_ID, nextFireInterval * 1000, 0);
-}
-
-void RunLoop::TimerBase::stop()
-{
- TimerMap::iterator it = m_runLoop->m_activeTimers.find(m_ID);
- if (it == m_runLoop->m_activeTimers.end())
- return;
-
- m_runLoop->m_activeTimers.remove(it);
- ::KillTimer(m_runLoop->m_runLoopMessageWindow, m_ID);
-}
-
-bool RunLoop::TimerBase::isActive() const
-{
- return m_runLoop->m_activeTimers.contains(m_ID);
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/win/SSLKeyGeneratorWin.cpp b/Source/WebCore/platform/win/SSLKeyGeneratorWin.cpp
deleted file mode 100644
index da68de7..0000000
--- a/Source/WebCore/platform/win/SSLKeyGeneratorWin.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (C) 2008-2009 Torch Mobile 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 "SSLKeyGenerator.h"
-
-#include <wtf/text/Base64.h>
-#include <wtf/text/CString.h>
-
-#include <windows.h>
-#include <wincrypt.h>
-
-namespace WebCore {
-
-void WebCore::getSupportedKeySizes(Vector<String>& v)
-{
- // FIXME: Strings should be localizable.
- v.append("High Grade");
- v.append("Medium Grade");
-}
-
-String WebCore::signedPublicKeyAndChallengeString(unsigned index, const String& challenge, const KURL& url)
-{
- String keyString;
-
- HCRYPTPROV hContext = 0;
- HCRYPTKEY hKey = 0;
- PCERT_PUBLIC_KEY_INFO pPubInfo = 0;
-
- // Try to delete it if it exists already
- CryptAcquireContextW(&hContext, L"keygen_container", MS_ENHANCED_PROV, PROV_RSA_FULL, CRYPT_DELETEKEYSET);
-
- do {
- if (!CryptAcquireContextW(&hContext, L"keygen_container", MS_ENHANCED_PROV, PROV_RSA_FULL, CRYPT_NEWKEYSET))
- break;
-
- DWORD dwPubInfoLength = 0;
- if (!CryptGenKey(hContext, AT_KEYEXCHANGE, 0, &hKey) || !CryptExportPublicKeyInfo(hContext, AT_KEYEXCHANGE, X509_ASN_ENCODING, 0, &dwPubInfoLength))
- break;
-
- // Use malloc instead of new, because malloc guarantees to return a pointer aligned for all data types.
- pPubInfo = reinterpret_cast<PCERT_PUBLIC_KEY_INFO>(fastMalloc(dwPubInfoLength));
-
- if (!CryptExportPublicKeyInfo(hContext, AT_KEYEXCHANGE, X509_ASN_ENCODING, pPubInfo, &dwPubInfoLength))
- break;
-
- CERT_KEYGEN_REQUEST_INFO requestInfo = { 0 };
- requestInfo.dwVersion = CERT_KEYGEN_REQUEST_V1;
- requestInfo.pwszChallengeString = L"";
- requestInfo.SubjectPublicKeyInfo = *pPubInfo;
-
- String localChallenge = challenge;
-
- // Windows API won't write to our buffer, although it's not declared with const.
- requestInfo.pwszChallengeString = const_cast<wchar_t*>(localChallenge.charactersWithNullTermination());
-
- CRYPT_ALGORITHM_IDENTIFIER signAlgo = { 0 };
- signAlgo.pszObjId = szOID_RSA_SHA1RSA;
-
- DWORD dwEncodedLength;
- if (!CryptSignAndEncodeCertificate(hContext, AT_KEYEXCHANGE, X509_ASN_ENCODING, X509_KEYGEN_REQUEST_TO_BE_SIGNED, &requestInfo, &signAlgo, 0, 0, &dwEncodedLength))
- break;
-
- Vector<char> binary(dwEncodedLength);
- if (!CryptSignAndEncodeCertificate(hContext, AT_KEYEXCHANGE, X509_ASN_ENCODING, X509_KEYGEN_REQUEST_TO_BE_SIGNED, &requestInfo, &signAlgo, 0, reinterpret_cast<LPBYTE>(binary.data()), &dwEncodedLength))
- break;
-
- keyString = base64Encode(binary);
- } while(0);
-
- if (pPubInfo)
- fastFree(pPubInfo);
-
- if (hKey)
- CryptDestroyKey(hKey);
-
- if (hContext)
- CryptReleaseContext(hContext, 0);
-
- return keyString;
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/win/ScrollbarThemeWin.cpp b/Source/WebCore/platform/win/ScrollbarThemeWin.cpp
deleted file mode 100644
index ed49f2b..0000000
--- a/Source/WebCore/platform/win/ScrollbarThemeWin.cpp
+++ /dev/null
@@ -1,393 +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 "LocalWindowsContext.h"
-#include "PlatformMouseEvent.h"
-#include "Scrollbar.h"
-#include "SoftLinking.h"
-#include "SystemInfo.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 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))
-
-// Constants used to figure the drag rect outside which we should snap the
-// scrollbar thumb back to its origin. These calculations are based on
-// observing the behavior of the MSVC8 main window scrollbar + some
-// guessing/extrapolation.
-static const int kOffEndMultiplier = 3;
-static const int kOffSideMultiplier = 8;
-
-static void checkAndInitScrollbarTheme()
-{
- if (uxthemeLibrary() && !scrollbarTheme && IsThemeActive())
- scrollbarTheme = OpenThemeData(0, L"Scrollbar");
-}
-
-#if !USE(SAFARI_THEME)
-ScrollbarTheme* ScrollbarTheme::nativeTheme()
-{
- static ScrollbarThemeWin winTheme;
- return &winTheme;
-}
-#endif
-
-ScrollbarThemeWin::ScrollbarThemeWin()
-{
- static bool initialized;
- if (!initialized) {
- initialized = true;
- checkAndInitScrollbarTheme();
- runningVista = (windowsVersion() >= WindowsVista);
- }
-}
-
-ScrollbarThemeWin::~ScrollbarThemeWin()
-{
-}
-
-int ScrollbarThemeWin::scrollbarThickness(ScrollbarControlSize)
-{
- static int thickness;
- if (!thickness)
- thickness = ::GetSystemMetrics(SM_CXVSCROLL);
- return thickness;
-}
-
-void ScrollbarThemeWin::themeChanged()
-{
- if (!scrollbarTheme)
- return;
-
- CloseThemeData(scrollbarTheme);
- scrollbarTheme = 0;
-}
-
-bool ScrollbarThemeWin::invalidateOnMouseEnterExit()
-{
- return runningVista;
-}
-
-bool ScrollbarThemeWin::hasThumb(ScrollbarThemeClient* scrollbar)
-{
- return thumbLength(scrollbar) > 0;
-}
-
-IntRect ScrollbarThemeWin::backButtonRect(ScrollbarThemeClient* 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(ScrollbarThemeClient* 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(ScrollbarThemeClient* 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);
-}
-
-bool ScrollbarThemeWin::shouldCenterOnThumb(ScrollbarThemeClient*, const PlatformMouseEvent& evt)
-{
- return evt.shiftKey() && evt.button() == LeftButton;
-}
-
-bool ScrollbarThemeWin::shouldSnapBackToDragOrigin(ScrollbarThemeClient* scrollbar, const PlatformMouseEvent& evt)
-{
- // Find the rect within which we shouldn't snap, by expanding the track rect
- // in both dimensions.
- IntRect rect = trackRect(scrollbar);
- const bool horz = scrollbar->orientation() == HorizontalScrollbar;
- const int thickness = scrollbarThickness(scrollbar->controlSize());
- rect.inflateX((horz ? kOffEndMultiplier : kOffSideMultiplier) * thickness);
- rect.inflateY((horz ? kOffSideMultiplier : kOffEndMultiplier) * thickness);
-
- // Convert the event to local coordinates.
- IntPoint mousePosition = scrollbar->convertFromContainingWindow(evt.position());
- mousePosition.move(scrollbar->x(), scrollbar->y());
-
- // We should snap iff the event is outside our calculated rect.
- return !rect.contains(mousePosition);
-}
-
-void ScrollbarThemeWin::paintTrackBackground(GraphicsContext* context, ScrollbarThemeClient* 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, ScrollbarThemeClient* 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);
-
- LocalWindowsContext windowsContext(context, rect, alphaBlend);
- RECT themeRect(rect);
-
- if (scrollbarTheme)
- DrawThemeBackground(scrollbarTheme, windowsContext.hdc(), part, state, &themeRect, 0);
- else {
- DWORD color3DFace = ::GetSysColor(COLOR_3DFACE);
- DWORD colorScrollbar = ::GetSysColor(COLOR_SCROLLBAR);
- DWORD colorWindow = ::GetSysColor(COLOR_WINDOW);
- HDC hdc = windowsContext.hdc();
- 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);
- }
- }
-
-#if !OS(WINCE)
- if (!alphaBlend && !context->isInTransparencyLayer())
- DIBPixelData::setRGBABitmapAlpha(windowsContext.hdc(), rect, 255);
-#endif
-}
-
-void ScrollbarThemeWin::paintButton(GraphicsContext* context, ScrollbarThemeClient* 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;
-#if !OS(WINCE)
- classicState |= DFCS_FLAT;
-#endif
- } 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);
-
- LocalWindowsContext windowsContext(context, rect, alphaBlend);
- RECT themeRect(rect);
- if (scrollbarTheme)
- DrawThemeBackground(scrollbarTheme, windowsContext.hdc(), SP_BUTTON, xpState, &themeRect, 0);
- else
- ::DrawFrameControl(windowsContext.hdc(), &themeRect, DFC_SCROLL, classicState);
-
-#if !OS(WINCE)
- if (!alphaBlend && !context->isInTransparencyLayer())
- DIBPixelData::setRGBABitmapAlpha(windowsContext.hdc(), rect, 255);
-#endif
-}
-
-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(ScrollbarThemeClient* 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, ScrollbarThemeClient* 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);
- LocalWindowsContext windowsContext(context, rect, alphaBlend);
- RECT themeRect(rect);
- if (scrollbarTheme) {
- DrawThemeBackground(scrollbarTheme, windowsContext.hdc(), scrollbar->orientation() == HorizontalScrollbar ? SP_THUMBHOR : SP_THUMBVERT, state, &themeRect, 0);
- paintGripper(scrollbar, windowsContext.hdc(), gripperRect(scrollbarThickness(), rect));
- } else
- ::DrawEdge(windowsContext.hdc(), &themeRect, EDGE_RAISED, BF_RECT | BF_MIDDLE);
-
-#if !OS(WINCE)
- if (!alphaBlend && !context->isInTransparencyLayer())
- DIBPixelData::setRGBABitmapAlpha(windowsContext.hdc(), rect, 255);
-#endif
-}
-
-}
-
diff --git a/Source/WebCore/platform/win/ScrollbarThemeWin.h b/Source/WebCore/platform/win/ScrollbarThemeWin.h
deleted file mode 100644
index 870240c..0000000
--- a/Source/WebCore/platform/win/ScrollbarThemeWin.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 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(ScrollbarThemeClient*) { return true; }
- virtual bool hasThumb(ScrollbarThemeClient*);
-
- virtual IntRect backButtonRect(ScrollbarThemeClient*, ScrollbarPart, bool painting = false);
- virtual IntRect forwardButtonRect(ScrollbarThemeClient*, ScrollbarPart, bool painting = false);
- virtual IntRect trackRect(ScrollbarThemeClient*, bool painting = false);
-
- virtual bool shouldCenterOnThumb(ScrollbarThemeClient*, const PlatformMouseEvent&);
- virtual bool shouldSnapBackToDragOrigin(ScrollbarThemeClient*, const PlatformMouseEvent&);
-
- virtual void paintTrackBackground(GraphicsContext*, ScrollbarThemeClient*, const IntRect&);
- virtual void paintTrackPiece(GraphicsContext*, ScrollbarThemeClient*, const IntRect&, ScrollbarPart);
- virtual void paintButton(GraphicsContext*, ScrollbarThemeClient*, const IntRect&, ScrollbarPart);
- virtual void paintThumb(GraphicsContext*, ScrollbarThemeClient*, const IntRect&);
-};
-
-}
-#endif
diff --git a/Source/WebCore/platform/win/SearchPopupMenuWin.cpp b/Source/WebCore/platform/win/SearchPopupMenuWin.cpp
deleted file mode 100644
index 0d251df..0000000
--- a/Source/WebCore/platform/win/SearchPopupMenuWin.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (C) 2006, 2007 Apple Inc.
- * Copyright (C) 2010 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 "SearchPopupMenuWin.h"
-
-#include <wtf/text/AtomicString.h>
-
-#if USE(CF)
-#include <wtf/RetainPtr.h>
-#endif
-
-namespace WebCore {
-
-SearchPopupMenuWin::SearchPopupMenuWin(PopupMenuClient* client)
- : m_popup(adoptRef(new PopupMenuWin(client)))
-{
-}
-
-PopupMenu* SearchPopupMenuWin::popupMenu()
-{
- return m_popup.get();
-}
-
-bool SearchPopupMenuWin::enabled()
-{
-#if USE(CF)
- return true;
-#else
- return false;
-#endif
-}
-
-#if USE(CF)
-static RetainPtr<CFStringRef> autosaveKey(const String& name)
-{
- return String("com.apple.WebKit.searchField:" + name).createCFString();
-}
-#endif
-
-void SearchPopupMenuWin::saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems)
-{
- if (name.isEmpty())
- return;
-
-#if USE(CF)
- RetainPtr<CFMutableArrayRef> items;
-
- size_t size = searchItems.size();
- if (size) {
- items.adoptCF(CFArrayCreateMutable(0, size, &kCFTypeArrayCallBacks));
- for (size_t i = 0; i < size; ++i)
- CFArrayAppendValue(items.get(), searchItems[i].createCFString().get());
- }
-
- CFPreferencesSetAppValue(autosaveKey(name).get(), items.get(), kCFPreferencesCurrentApplication);
- CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
-#endif
-}
-
-void SearchPopupMenuWin::loadRecentSearches(const AtomicString& name, Vector<String>& searchItems)
-{
- if (name.isEmpty())
- return;
-
-#if USE(CF)
- 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);
- }
-#endif
-}
-
-}
diff --git a/Source/WebCore/platform/win/SearchPopupMenuWin.h b/Source/WebCore/platform/win/SearchPopupMenuWin.h
deleted file mode 100644
index 299a133..0000000
--- a/Source/WebCore/platform/win/SearchPopupMenuWin.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2010 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 SearchPopupMenuWin_h
-#define SearchPopupMenuWin_h
-
-#include "PopupMenuWin.h"
-#include "SearchPopupMenu.h"
-
-namespace WebCore {
-
-class SearchPopupMenuWin : public SearchPopupMenu {
-public:
- SearchPopupMenuWin(PopupMenuClient*);
-
- virtual PopupMenu* popupMenu();
- virtual void saveRecentSearches(const AtomicString& name, const Vector<String>& searchItems);
- virtual void loadRecentSearches(const AtomicString& name, Vector<String>& searchItems);
- virtual bool enabled();
-
-private:
- RefPtr<PopupMenuWin> m_popup;
-};
-
-}
-
-#endif // SearchPopupMenuWin_h
diff --git a/Source/WebCore/platform/win/SharedBufferWin.cpp b/Source/WebCore/platform/win/SharedBufferWin.cpp
deleted file mode 100644
index 59a5a76..0000000
--- a/Source/WebCore/platform/win/SharedBufferWin.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
- * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.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 COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) 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 <wtf/text/CString.h>
-
-// INVALID_FILE_SIZE is not defined on WinCE.
-#ifndef INVALID_FILE_SIZE
-#define INVALID_FILE_SIZE 0xffffffff
-#endif
-
-namespace WebCore {
-
-PassRefPtr<SharedBuffer> SharedBuffer::createWithContentsOfFile(const String& filePath)
-{
- if (filePath.isEmpty())
- return 0;
-
- String nullifiedPath = filePath;
- HANDLE fileHandle = CreateFileW(nullifiedPath.charactersWithNullTermination(), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
- if (fileHandle == INVALID_HANDLE_VALUE) {
- LOG_ERROR("Failed to open file %s to create shared buffer, GetLastError() = %u", filePath.ascii().data(), GetLastError());
- return 0;
- }
-
- RefPtr<SharedBuffer> result;
- DWORD bytesToRead = GetFileSize(fileHandle, 0);
- DWORD lastError = GetLastError();
-
- if (bytesToRead != INVALID_FILE_SIZE || lastError == NO_ERROR) {
- Vector<char> buffer(bytesToRead);
- DWORD bytesRead;
- if (ReadFile(fileHandle, buffer.data(), bytesToRead, &bytesRead, 0) && bytesToRead == bytesRead)
- result = SharedBuffer::adoptVector(buffer);
- else
- LOG_ERROR("Failed to fully read contents of file %s, GetLastError() = %u", filePath.ascii().data(), GetLastError());
- } else
- LOG_ERROR("Failed to get filesize of file %s, GetLastError() = %u", filePath.ascii().data(), lastError);
-
- CloseHandle(fileHandle);
- return result.release();
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/win/SharedTimerWin.cpp b/Source/WebCore/platform/win/SharedTimerWin.cpp
deleted file mode 100644
index 77069bc..0000000
--- a/Source/WebCore/platform/win/SharedTimerWin.cpp
+++ /dev/null
@@ -1,237 +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 "Settings.h"
-#include "WebCoreInstanceHandle.h"
-#include "Widget.h"
-#include <wtf/Assertions.h>
-#include <wtf/CurrentTime.h>
-
-#include "WindowsExtras.h"
-#include <mmsystem.h>
-
-#if PLATFORM(WIN)
-#include "PluginView.h"
-#endif
-
-// 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
-
-namespace WebCore {
-
-static UINT timerID;
-static void (*sharedTimerFiredFunction)();
-
-static HANDLE timer;
-static HWND timerWindowHandle = 0;
-const LPCWSTR kTimerWindowClassName = L"TimerWindowClass";
-
-#if !OS(WINCE)
-static UINT timerFiredMessage = 0;
-static HANDLE timerQueue;
-static bool highResTimerActive;
-static bool processingCustomTimerMessage = false;
-static LONG pendingTimers;
-
-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).
-#endif
-
-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 == WM_TIMER) {
- if (wParam == sharedTimerID) {
- KillTimer(timerWindowHandle, sharedTimerID);
- sharedTimerFiredFunction();
- }
-#if !OS(WINCE)
- else if (wParam == endHighResTimerID) {
- KillTimer(timerWindowHandle, endHighResTimerID);
- highResTimerActive = false;
- timeEndPeriod(timerResolution);
- }
- } else if (message == timerFiredMessage) {
- InterlockedExchange(&pendingTimers, 0);
- processingCustomTimerMessage = true;
- sharedTimerFiredFunction();
- processingCustomTimerMessage = false;
-#endif
- } else
- return DefWindowProc(hWnd, message, wParam, lParam);
-
- return 0;
-}
-
-static void initializeOffScreenTimerWindow()
-{
- if (timerWindowHandle)
- return;
-
-#if OS(WINCE)
- WNDCLASS wcex;
- memset(&wcex, 0, sizeof(WNDCLASS));
-#else
- WNDCLASSEX wcex;
- memset(&wcex, 0, sizeof(WNDCLASSEX));
- wcex.cbSize = sizeof(WNDCLASSEX);
-#endif
-
- wcex.lpfnWndProc = TimerWindowWndProc;
- wcex.hInstance = WebCore::instanceHandle();
- wcex.lpszClassName = kTimerWindowClassName;
-#if OS(WINCE)
- RegisterClass(&wcex);
-#else
- RegisterClassEx(&wcex);
-#endif
-
- timerWindowHandle = CreateWindow(kTimerWindowClassName, 0, 0,
- CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, HWND_MESSAGE, 0, WebCore::instanceHandle(), 0);
-
-#if !OS(WINCE)
- timerFiredMessage = RegisterWindowMessage(L"com.apple.WebKit.TimerFired");
-#endif
-}
-
-void setSharedTimerFiredFunction(void (*f)())
-{
- sharedTimerFiredFunction = f;
-}
-
-#if !OS(WINCE)
-static void NTAPI queueTimerProc(PVOID, BOOLEAN)
-{
- if (InterlockedIncrement(&pendingTimers) == 1)
- PostMessage(timerWindowHandle, timerFiredMessage, 0, 0);
-}
-#endif
-
-void setSharedTimerFireInterval(double interval)
-{
- ASSERT(sharedTimerFiredFunction);
-
- unsigned intervalInMS;
- interval *= 1000;
- if (interval > USER_TIMER_MAXIMUM)
- intervalInMS = USER_TIMER_MAXIMUM;
- else
- intervalInMS = static_cast<unsigned>(interval);
-
- initializeOffScreenTimerWindow();
- bool timerSet = false;
-
-#if !OS(WINCE)
- if (Settings::shouldUseHighResolutionTimers()) {
- if (interval < highResolutionThresholdMsec) {
- if (!highResTimerActive) {
- highResTimerActive = true;
- timeBeginPeriod(timerResolution);
- }
- SetTimer(timerWindowHandle, endHighResTimerID, stopHighResTimerInMsec, 0);
- }
-
- 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();
- if (timer)
- DeleteTimerQueueTimer(timerQueue, timer, 0);
- timerSet = CreateTimerQueueTimer(&timer, timerQueue, queueTimerProc, 0, intervalInMS, 0, WT_EXECUTEINTIMERTHREAD | WT_EXECUTEONLYONCE);
- }
- }
- }
-#endif // !OS(WINCE)
-
- if (timerSet) {
- if (timerID) {
- KillTimer(timerWindowHandle, timerID);
- timerID = 0;
- }
- } else {
- timerID = SetTimer(timerWindowHandle, sharedTimerID, intervalInMS, 0);
- timer = 0;
- }
-}
-
-void stopSharedTimer()
-{
-#if !OS(WINCE)
- if (timerQueue && timer) {
- DeleteTimerQueueTimer(timerQueue, timer, 0);
- timer = 0;
- }
-#endif
-
- if (timerID) {
- KillTimer(timerWindowHandle, timerID);
- timerID = 0;
- }
-}
-
-}
diff --git a/Source/WebCore/platform/win/SoftLinking.h b/Source/WebCore/platform/win/SoftLinking.h
deleted file mode 100644
index cd5c2c1..0000000
--- a/Source/WebCore/platform/win/SoftLinking.h
+++ /dev/null
@@ -1,179 +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); \
- return library; \
- }
-
-#if OS(WINCE)
-#define SOFT_LINK_GETPROCADDRESS GetProcAddressA
-#else
-#define SOFT_LINK_GETPROCADDRESS GetProcAddress
-#endif
-
-#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 = reinterpret_cast<resultType (callingConvention*) parameterDeclarations>(SOFT_LINK_GETPROCADDRESS(library##Library(), #functionName)); \
- ASSERT(softLink##functionName); \
- return softLink##functionName parameterNames; \
- }\
- \
- inline resultType functionName parameterDeclarations \
- {\
- return softLink##functionName parameterNames; \
- }
-
-#define SOFT_LINK_OPTIONAL(library, functionName, resultType, callingConvention, parameterDeclarations) \
- typedef resultType (callingConvention *functionName##PtrType) parameterDeclarations; \
- static functionName##PtrType functionName##Ptr() \
- { \
- static functionName##PtrType ptr; \
- static bool initialized; \
- \
- if (initialized) \
- return ptr; \
- initialized = true; \
- \
- ptr = reinterpret_cast<functionName##PtrType>(SOFT_LINK_GETPROCADDRESS(library##Library(), #functionName)); \
- return ptr; \
- }\
-
-#define SOFT_LINK_LOADED_LIBRARY(library, functionName, resultType, callingConvention, parameterDeclarations) \
- typedef resultType (callingConvention *functionName##PtrType) parameterDeclarations; \
- static functionName##PtrType functionName##Ptr() \
- { \
- static functionName##PtrType ptr; \
- static bool initialized; \
- \
- if (initialized) \
- return ptr; \
- initialized = true; \
- \
- static HINSTANCE libraryInstance = ::GetModuleHandle(L#library); \
- \
- ptr = reinterpret_cast<functionName##PtrType>(SOFT_LINK_GETPROCADDRESS(libraryInstance, #functionName)); \
- return ptr; \
- }\
-
-/*
- In order to soft link against functions decorated with __declspec(dllimport), we prepend "softLink_" to the function names.
- If you use SOFT_LINK_DLL_IMPORT(), you will also need to #define the function name to account for this, e.g.:
-
- SOFT_LINK_DLL_IMPORT(myLibrary, myFunction, ...)
- #define myFunction softLink_myFunction
-*/
-#define SOFT_LINK_DLL_IMPORT(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 = reinterpret_cast<resultType (callingConvention*)parameterDeclarations>(SOFT_LINK_GETPROCADDRESS(library##Library(), #functionName)); \
- ASSERT(softLink##functionName); \
- return softLink##functionName parameterNames; \
- }\
- \
- inline resultType softLink_##functionName parameterDeclarations \
- {\
- return softLink##functionName parameterNames; \
- }
-
-#define SOFT_LINK_DLL_IMPORT_OPTIONAL(library, functionName, resultType, callingConvention, parameterDeclarations) \
- typedef resultType (callingConvention *functionName##PtrType) parameterDeclarations; \
- static functionName##PtrType functionName##Ptr() \
- { \
- static functionName##PtrType ptr; \
- static bool initialized; \
- \
- if (initialized) \
- return ptr; \
- initialized = true; \
- \
- ptr = reinterpret_cast<resultType(callingConvention*)parameterDeclarations>(SOFT_LINK_GETPROCADDRESS(library##Library(), #functionName)); \
- return ptr; \
- }\
-
-#define SOFT_LINK_DLL_IMPORT_OPTIONAL(library, functionName, resultType, callingConvention, parameterDeclarations) \
- typedef resultType (callingConvention *functionName##PtrType) parameterDeclarations; \
- static functionName##PtrType functionName##Ptr() \
- { \
- static functionName##PtrType ptr; \
- static bool initialized; \
- \
- if (initialized) \
- return ptr; \
- initialized = true; \
- \
- ptr = reinterpret_cast<resultType(callingConvention*)parameterDeclarations>(SOFT_LINK_GETPROCADDRESS(library##Library(), #functionName)); \
- return ptr; \
- }\
-
-/*
- Variables exported by a DLL need to be accessed through a function.
- If you use SOFT_LINK_VARIABLE_DLL_IMPORT(), you will also need to #define the variable name to account for this, e.g.:
-
- SOFT_LINK_VARIABLE_DLL_IMPORT(myLibrary, myVar, int)
- #define myVar get_myVar()
-*/
-#define SOFT_LINK_VARIABLE_DLL_IMPORT(library, variableName, variableType) \
- static variableType get_##variableName() \
- { \
- static variableType* ptr = reinterpret_cast<variableType*>(SOFT_LINK_GETPROCADDRESS(library##Library(), #variableName)); \
- ASSERT(ptr); \
- return *ptr; \
- }\
-
-/*
- Note that this will only work for variable types for which a return value of 0 can signal an error.
- */
-#define SOFT_LINK_VARIABLE_DLL_IMPORT_OPTIONAL(library, variableName, variableType) \
- static variableType get_##variableName() \
- { \
- static variableType* ptr = reinterpret_cast<variableType*>(SOFT_LINK_GETPROCADDRESS(library##Library(), #variableName)); \
- if (!ptr) \
- return 0; \
- return *ptr; \
- }\
-
-#endif // SoftLinking_h
diff --git a/Source/WebCore/platform/win/SoundWin.cpp b/Source/WebCore/platform/win/SoundWin.cpp
deleted file mode 100644
index 443e7d9..0000000
--- a/Source/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/Source/WebCore/platform/win/StructuredExceptionHandlerSupressor.h b/Source/WebCore/platform/win/StructuredExceptionHandlerSupressor.h
deleted file mode 100644
index 4f57b40..0000000
--- a/Source/WebCore/platform/win/StructuredExceptionHandlerSupressor.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2011 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. 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 INC. 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 StructuredExceptionHandlerSupressor_h
-#define StructuredExceptionHandlerSupressor_h
-
-namespace WebCore {
-
-#pragma warning(push)
-#pragma warning(disable: 4733) // Disable "not registered as safe handler" warning
-
-class StructuredExceptionHandlerSupressor {
- WTF_MAKE_NONCOPYABLE(StructuredExceptionHandlerSupressor);
-public:
- StructuredExceptionHandlerSupressor()
- {
- // Windows puts an __try/__except block around some calls, such as hooks.
- // The exception handler then ignores system exceptions like invalid addresses
- // and null pointers. This class can be used to remove this block and prevent
- // it from catching the exception. Typically this will cause the exception to crash
- // which is often desirable to allow crashlogs to be recorded for debugging purposed.
- // While this class is in scope we replace the Windows exception handler with 0xffffffff,
- // which indicates that the exception should not be handled.
- //
- // See http://www.microsoft.com/msj/0197/Exception/Exception.aspx
-
- // Windows doesn't like assigning to member variables, so we need to get the value into
- // a local variable and store it afterwards.
- void* registration;
-
- __asm mov eax, FS:[0]
- __asm mov [registration], eax
- __asm mov eax, 0xffffffff
- __asm mov FS:[0], eax
-
- m_savedExceptionRegistration = registration;
- }
-
- ~StructuredExceptionHandlerSupressor()
- {
- // Restore the exception handler
- __asm mov eax, [m_savedExceptionRegistration]
- __asm mov FS:[0], eax
- }
-
-private:
- void* m_savedExceptionRegistration;
-};
-
-#pragma warning(pop)
-
-} // namespace WebCore
-
-#endif // StructuredExceptionHandlerSupressor_h
diff --git a/Source/WebCore/platform/win/SystemTimeWin.cpp b/Source/WebCore/platform/win/SystemTimeWin.cpp
deleted file mode 100644
index 547decc..0000000
--- a/Source/WebCore/platform/win/SystemTimeWin.cpp
+++ /dev/null
@@ -1,46 +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 <limits>
-#include <windows.h>
-
-namespace WebCore {
-
-float userIdleTime()
-{
-#if !OS(WINCE)
- LASTINPUTINFO lastInputInfo;
- 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.
-#endif
- // Return an arbitrarily high userIdleTime so that releasing pages from the page cache isn't postponed.
- return std::numeric_limits<float>::max();
-}
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/win/TemporaryLinkStubs.cpp b/Source/WebCore/platform/win/TemporaryLinkStubs.cpp
deleted file mode 100644
index 856cea9..0000000
--- a/Source/WebCore/platform/win/TemporaryLinkStubs.cpp
+++ /dev/null
@@ -1,45 +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"
-#if !USE(CFNETWORK)
-#include "CookieStorage.h"
-#endif
-
-namespace WebCore {
-
-// <keygen>
-String signedPublicKeyAndChallengeString(unsigned, const String&, const KURL&) { notImplemented(); return String(); }
-void getSupportedKeySizes(Vector<String>&) { notImplemented(); }
-
-#if !USE(CFNETWORK)
-void startObservingCookieChanges(CookieChangeCallbackPtr) { notImplemented(); }
-void stopObservingCookieChanges() { notImplemented(); }
-#endif
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/win/WCDataObject.cpp b/Source/WebCore/platform/win/WCDataObject.cpp
deleted file mode 100644
index 4eee4b9..0000000
--- a/Source/WebCore/platform/win/WCDataObject.cpp
+++ /dev/null
@@ -1,396 +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 "ClipboardUtilitiesWin.h"
-#include "DragData.h"
-#include <wtf/text/WTFString.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;
-}
-
-HRESULT WCDataObject::createInstance(WCDataObject** result, const DragDataMap& dataMap)
-{
- if (!result)
- return E_POINTER;
- *result = new WCDataObject;
-
- for (DragDataMap::const_iterator it = dataMap.begin(); it != dataMap.end(); ++it)
- setClipboardData(*result, it->key, it->value);
- 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 (IsEqualIID(riid, IID_IUnknown) ||
- IsEqualIID(riid, IID_IDataObject)) {
- *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)
- {
-#if !OS(WINCE)
- 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;
-#endif
- 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/Source/WebCore/platform/win/WCDataObject.h b/Source/WebCore/platform/win/WCDataObject.h
deleted file mode 100644
index e5fa298..0000000
--- a/Source/WebCore/platform/win/WCDataObject.h
+++ /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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (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 "DragData.h"
-#include <ShlObj.h>
-#include <objidl.h>
-#include <wtf/Forward.h>
-#include <wtf/Vector.h>
-
-namespace WebCore {
-
-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**);
- static HRESULT createInstance(WCDataObject**, const DragDataMap&);
-private:
- WCDataObject();
- virtual ~WCDataObject();
- long m_ref;
- Vector<FORMATETC*> m_formats;
- Vector<STGMEDIUM*> m_medium;
-};
-
-}
-
-#endif //!WCDataObject_h
diff --git a/Source/WebCore/platform/win/WebCoreInstanceHandle.cpp b/Source/WebCore/platform/win/WebCoreInstanceHandle.cpp
deleted file mode 100644
index dd21b2d..0000000
--- a/Source/WebCore/platform/win/WebCoreInstanceHandle.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2010 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. 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 INC. 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 "WebCoreInstanceHandle.h"
-
-namespace WebCore {
-
-HINSTANCE s_instanceHandle;
-
-} // namespace WebCore
diff --git a/Source/WebCore/platform/win/WebCoreInstanceHandle.h b/Source/WebCore/platform/win/WebCoreInstanceHandle.h
deleted file mode 100644
index 9b6ce66..0000000
--- a/Source/WebCore/platform/win/WebCoreInstanceHandle.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2010 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. 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 INC. 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 WebCoreInstanceHandle_h
-#define WebCoreInstanceHandle_h
-
-typedef struct HINSTANCE__* HINSTANCE;
-
-namespace WebCore {
-
-// The global DLL or application instance used for all windows.
-extern HINSTANCE s_instanceHandle;
-
-inline void setInstanceHandle(HINSTANCE instanceHandle) { s_instanceHandle = instanceHandle; }
-inline HINSTANCE instanceHandle() { return s_instanceHandle; }
-
-}
-
-#endif // WebCoreInstanceHandle_h
diff --git a/Source/WebCore/platform/win/WebCoreTextRenderer.cpp b/Source/WebCore/platform/win/WebCoreTextRenderer.cpp
deleted file mode 100644
index 912c8d6..0000000
--- a/Source/WebCore/platform/win/WebCoreTextRenderer.cpp
+++ /dev/null
@@ -1,132 +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 "FontCache.h"
-#include "FontDescription.h"
-#include "GraphicsContext.h"
-#include "StringTruncator.h"
-#include "TextRun.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)
-{
- FontCachePurgePreventer fontCachePurgePreventer;
-
- TextRun run(text.characters(), text.length());
-
- context.setFillColor(color, ColorSpaceDeviceRGB);
- if (isOneLeftToRightRun(run))
- font.drawText(&context, run, point);
- else
- context.drawBidiText(font, run, point);
-
- if (underlinedIndex >= 0) {
- ASSERT_WITH_SECURITY_IMPLICATION(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, ColorSpaceDeviceRGB);
- 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)
-{
- FontCachePurgePreventer fontCachePurgePreventer;
-
- return StringTruncator::width(text, font, StringTruncator::EnableRoundingHacks);
-}
-
-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/Source/WebCore/platform/win/WebCoreTextRenderer.h b/Source/WebCore/platform/win/WebCoreTextRenderer.h
deleted file mode 100644
index 6deef4a..0000000
--- a/Source/WebCore/platform/win/WebCoreTextRenderer.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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (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 WebCoreTextRenderer_h
-#define WebCoreTextRenderer_h
-
-#include <wtf/Forward.h>
-
-namespace WebCore {
-
- class Color;
- class Font;
- class GraphicsContext;
- class IntPoint;
-
- 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
-
-#endif // WebCoreTextRenderer_h
diff --git a/Source/WebCore/platform/win/WheelEventWin.cpp b/Source/WebCore/platform/win/WheelEventWin.cpp
deleted file mode 100644
index 5224697..0000000
--- a/Source/WebCore/platform/win/WheelEventWin.cpp
+++ /dev/null
@@ -1,130 +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 "PlatformWheelEvent.h"
-
-#include "FloatPoint.h"
-#include "FloatSize.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;
-}
-
-static int horizontalScrollChars()
-{
- static ULONG scrollChars;
- if (!scrollChars && !SystemParametersInfo(SPI_GETWHEELSCROLLCHARS, 0, &scrollChars, 0))
- scrollChars = 1;
- return scrollChars;
-}
-
-static int verticalScrollLines()
-{
- static ULONG scrollLines;
- if (!scrollLines && !SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &scrollLines, 0))
- scrollLines = 3;
- return scrollLines;
-}
-
-PlatformWheelEvent::PlatformWheelEvent(HWND hWnd, const FloatSize& delta, const FloatPoint& location)
- : PlatformEvent(PlatformEvent::Wheel, false, false, false, false, ::GetTickCount() * 0.001)
- , m_directionInvertedFromDevice(false)
-{
- m_deltaX = delta.width();
- m_deltaY = delta.height();
-
- m_wheelTicksX = m_deltaX;
- m_wheelTicksY = m_deltaY;
-
- // Global Position is just x, y location of event
- POINT point = {location.x(), location.y()};
- m_globalPosition = point;
-
- // Position needs to be translated to our client
- ScreenToClient(hWnd, &point);
- m_position = point;
-}
-
-PlatformWheelEvent::PlatformWheelEvent(HWND hWnd, WPARAM wParam, LPARAM lParam, bool isMouseHWheel)
- : PlatformEvent(PlatformEvent::Wheel, wParam & MK_SHIFT, wParam & MK_CONTROL, GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT, GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT, ::GetTickCount() * 0.001)
- , m_position(positionForEvent(hWnd, lParam))
- , m_globalPosition(globalPositionForEvent(hWnd, lParam))
- , m_directionInvertedFromDevice(false)
-{
- // How many pixels should we scroll per line? Gecko uses the height of the
- // current line, which means scroll distance changes as you go through the
- // page or go to different pages. IE 7 is ~50 px/line, although the value
- // seems to vary slightly by page and zoom level. Since IE 7 has a
- // smoothing algorithm on scrolling, it can get away with slightly larger
- // scroll values without feeling jerky. Here we use 100 px per three lines
- // (the default scroll amount on Windows is three lines per wheel tick).
- static const float cScrollbarPixelsPerLine = 100.0f / 3.0f;
- float delta = GET_WHEEL_DELTA_WPARAM(wParam) / static_cast<float>(WHEEL_DELTA);
- if (isMouseHWheel) {
- // Windows is <-- -/+ -->, WebKit wants <-- +/- -->, so we negate
- // |delta| after saving the original value on the wheel tick member.
- m_wheelTicksX = delta;
- m_wheelTicksY = 0;
- delta = -delta;
- } else {
- // Even though we use shift + vertical wheel to scroll horizontally in
- // WebKit, we still note it as a vertical scroll on the wheel tick
- // member, so that the DOM event we later construct will match the real
- // hardware event better.
- m_wheelTicksX = 0;
- m_wheelTicksY = delta;
- }
- if (isMouseHWheel || shiftKey()) {
- m_deltaX = delta * static_cast<float>(horizontalScrollChars()) * cScrollbarPixelsPerLine;
- m_deltaY = 0;
- m_granularity = ScrollByPixelWheelEvent;
- } else {
- m_deltaX = 0;
- m_deltaY = delta;
- int verticalMultiplier = verticalScrollLines();
- m_granularity = (verticalMultiplier == WHEEL_PAGESCROLL) ? ScrollByPageWheelEvent : ScrollByPixelWheelEvent;
- if (m_granularity == ScrollByPixelWheelEvent)
- m_deltaY *= static_cast<float>(verticalMultiplier) * cScrollbarPixelsPerLine;
- }
-}
-
-}
diff --git a/Source/WebCore/platform/win/WidgetWin.cpp b/Source/WebCore/platform/win/WidgetWin.cpp
deleted file mode 100644
index 416260b..0000000
--- a/Source/WebCore/platform/win/WidgetWin.cpp
+++ /dev/null
@@ -1,101 +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 "Chrome.h"
-#include "Cursor.h"
-#include "Document.h"
-#include "Element.h"
-#include "FrameView.h"
-#include "FrameWin.h"
-#include "GraphicsContext.h"
-#include "IntRect.h"
-#include "Page.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()
-{
-}
-
-bool ignoreNextSetCursor = false;
-
-void Widget::setCursor(const Cursor& cursor)
-{
- // This is set by PluginViewWin so it can ignore the setCursor call made by
- // EventHandler.cpp.
- if (ignoreNextSetCursor) {
- ignoreNextSetCursor = false;
- return;
- }
-
- ScrollView* view = root();
- if (!view)
- return;
- view->hostWindow()->setCursor(cursor);
-}
-
-void Widget::paint(GraphicsContext*, const IntRect&)
-{
-}
-
-void Widget::setFocus(bool focused)
-{
-}
-
-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/Source/WebCore/platform/win/Win32Handle.h b/Source/WebCore/platform/win/Win32Handle.h
deleted file mode 100644
index cefdf42..0000000
--- a/Source/WebCore/platform/win/Win32Handle.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2011 Patrick Gansterer <paroga@paroga.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 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 Win32Handle_h
-#define Win32Handle_h
-
-#include <memory>
-#include <windows.h>
-#include <wtf/Noncopyable.h>
-
-namespace WebCore {
-
-class Win32Handle {
- WTF_MAKE_NONCOPYABLE(Win32Handle);
-public:
- Win32Handle() : m_handle(INVALID_HANDLE_VALUE) { }
- explicit Win32Handle(HANDLE handle) : m_handle(handle) { }
-
- ~Win32Handle() { clear(); }
-
- void clear()
- {
- if (!isValid())
- return;
- CloseHandle(m_handle);
- m_handle = INVALID_HANDLE_VALUE;
- }
-
- bool isValid() const { return m_handle != INVALID_HANDLE_VALUE; }
-
- HANDLE get() const { return m_handle; }
- HANDLE release() { HANDLE ret = m_handle; m_handle = INVALID_HANDLE_VALUE; return ret; }
-
- Win32Handle& operator=(HANDLE handle)
- {
- clear();
- m_handle = handle;
- }
-
-private:
- HANDLE m_handle;
-};
-
-} // namespace WebCore
-
-#endif // Win32Handle_h
diff --git a/Source/WebCore/platform/win/WindowMessageBroadcaster.cpp b/Source/WebCore/platform/win/WindowMessageBroadcaster.cpp
deleted file mode 100644
index 7088995..0000000
--- a/Source/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/Source/WebCore/platform/win/WindowMessageBroadcaster.h b/Source/WebCore/platform/win/WindowMessageBroadcaster.h
deleted file mode 100644
index d36c233..0000000
--- a/Source/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>
-
-namespace WebCore {
-
- class WindowMessageListener;
-
- class WindowMessageBroadcaster {
- WTF_MAKE_NONCOPYABLE(WindowMessageBroadcaster);
- 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/Source/WebCore/platform/win/WindowMessageListener.h b/Source/WebCore/platform/win/WindowMessageListener.h
deleted file mode 100644
index 1d410f2..0000000
--- a/Source/WebCore/platform/win/WindowMessageListener.h
+++ /dev/null
@@ -1,45 +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
-
-#if OS(WINDOWS)
-#include "WindowsExtras.h"
-#endif
-
-namespace WebCore {
-
- class WindowMessageListener {
- public:
- virtual void windowReceivedMessage(HWND, UINT message, WPARAM, LPARAM) = 0;
- };
-
-} // namespace WebCore
-
-#endif // WindowMessageListener_h
diff --git a/Source/WebCore/platform/win/WindowsExtras.h b/Source/WebCore/platform/win/WindowsExtras.h
deleted file mode 100644
index 283d9d9..0000000
--- a/Source/WebCore/platform/win/WindowsExtras.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2012 Patrick Gansterer <paroga@paroga.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 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 WindowsExtras_h
-#define WindowsExtras_h
-
-#include <windows.h>
-#include <objbase.h>
-#include <shlwapi.h>
-
-namespace WebCore {
-
-#ifndef HWND_MESSAGE
-const HWND HWND_MESSAGE = 0;
-#endif
-
-inline HRESULT getRegistryValue(HKEY hkey, LPCWSTR pszSubKey, LPCWSTR pszValue, LPDWORD pdwType, LPVOID pvData, LPDWORD pcbData)
-{
-#if OS(WINCE)
- HKEY key;
- if (::RegOpenKeyExW(hkey, pszSubKey, 0, 0, &key) != ERROR_SUCCESS)
- return ERROR_INVALID_NAME;
- HRESULT result = ::RegQueryValueExW(key, pszValue, 0, pdwType, static_cast<LPBYTE>(pvData), pcbData);
- ::RegCloseKey(key);
- return result;
-#else
- return ::SHGetValueW(hkey, pszSubKey, pszValue, pdwType, pvData, pcbData);
-#endif
-}
-
-inline void* getWindowPointer(HWND hWnd, int index)
-{
-#if OS(WINCE)
- return reinterpret_cast<void*>(::GetWindowLong(hWnd, index));
-#else
- return reinterpret_cast<void*>(::GetWindowLongPtr(hWnd, index));
-#endif
-}
-
-inline void* setWindowPointer(HWND hWnd, int index, void* value)
-{
-#if OS(WINCE)
- return reinterpret_cast<void*>(::SetWindowLong(hWnd, index, reinterpret_cast<LONG>(value)));
-#else
- return reinterpret_cast<void*>(::SetWindowLongPtr(hWnd, index, reinterpret_cast<LONG_PTR>(value)));
-#endif
-}
-
-} // namespace WebCore
-
-#endif // WindowsExtras_h
diff --git a/Source/WebCore/platform/win/WindowsTouch.h b/Source/WebCore/platform/win/WindowsTouch.h
deleted file mode 100644
index 9048103..0000000
--- a/Source/WebCore/platform/win/WindowsTouch.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (C) 2009 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 WindowsTouch_h
-#define WindowsTouch_h
-
-/*
- * The following constants are used to determine multitouch and gesture behavior
- * for Windows 7. For more information, see:
- * http://msdn.microsoft.com/en-us/library/dd562197(VS.85).aspx
- */
-
-// Value used in WebViewWndProc for Gestures
-#define WM_GESTURE 0x0119
-#define WM_GESTURENOTIFY 0x011A
-
-// Gesture Information Flags
-#define GF_BEGIN 0x00000001
-#define GF_INERTIA 0x00000002
-#define GF_END 0x00000004
-
-// Gesture IDs
-#define GID_BEGIN 1
-#define GID_END 2
-#define GID_ZOOM 3
-#define GID_PAN 4
-#define GID_ROTATE 5
-#define GID_TWOFINGERTAP 6
-#define GID_PRESSANDTAP 7
-#define GID_ROLLOVER GID_PRESSANDTAP
-
-// Zoom Gesture Confiration Flags
-#define GC_ZOOM 0x00000001
-
-// Pan Gesture Configuration Flags
-#define GC_PAN 0x00000001
-#define GC_PAN_WITH_SINGLE_FINGER_VERTICALLY 0x00000002
-#define GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY 0x00000004
-#define GC_PAN_WITH_GUTTER 0x00000008
-#define GC_PAN_WITH_INERTIA 0x00000010
-
-// Rotate Gesture Configuration Flags
-#define GC_ROTATE 0x00000001
-
-// Two finger tap configuration flags
-#define GC_TWOFINGERTAP 0x00000001
-
-// Press and tap Configuration Flags
-#define GC_PRESSANDTAP 0x00000001
-#define GC_ROLLOVER GC_PRESSANDTAP
-
-// GESTUREINFO struct definition
-typedef struct tagGESTUREINFO {
- UINT cbSize; // size, in bytes, of this structure (including variable length Args field)
- DWORD dwFlags; // see GF_* flags
- DWORD dwID; // gesture ID, see GID_* defines
- HWND hwndTarget; // handle to window targeted by this gesture
- POINTS ptsLocation; // current location of this gesture
- DWORD dwInstanceID; // internally used
- DWORD dwSequenceID; // internally used
- ULONGLONG ullArguments; // arguments for gestures whose arguments fit in 8 BYTES
- UINT cbExtraArgs; // size, in bytes, of extra arguments, if any, that accompany this gesture
-} GESTUREINFO, *PGESTUREINFO;
-typedef GESTUREINFO const * PCGESTUREINFO;
-
-// GESTURECONFIG struct defintion
-typedef struct tagGESTURECONFIG {
- DWORD dwID; // gesture ID
- DWORD dwWant; // settings related to gesture ID that are to be turned on
- DWORD dwBlock; // settings related to gesture ID that are to be turned off
-} GESTURECONFIG, *PGESTURECONFIG;
-
-/*
- * Gesture notification structure
- * - The WM_GESTURENOTIFY message lParam contains a pointer to this structure.
- * - The WM_GESTURENOTIFY message notifies a window that gesture recognition is
- * in progress and a gesture will be generated if one is recognized under the
- * current gesture settings.
- */
-typedef struct tagGESTURENOTIFYSTRUCT {
- UINT cbSize; // size, in bytes, of this structure
- DWORD dwFlags; // unused
- HWND hwndTarget; // handle to window targeted by the gesture
- POINTS ptsLocation; // starting location
- DWORD dwInstanceID; // internally used
-} GESTURENOTIFYSTRUCT, *PGESTURENOTIFYSTRUCT;
-
-DECLARE_HANDLE(HGESTUREINFO);
-
-#endif