diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-15 17:31:21 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-15 17:31:21 +0000 |
commit | bce89e6ed2c32bf287ebc1852770d7861f68bf3a (patch) | |
tree | 6bb5d8ba52e47532d0761627180ef6ecbbca4701 | |
parent | 6e66e46982f98d7351b2e2a804e71d76fbaa1053 (diff) | |
download | chromium_src-bce89e6ed2c32bf287ebc1852770d7861f68bf3a.zip chromium_src-bce89e6ed2c32bf287ebc1852770d7861f68bf3a.tar.gz chromium_src-bce89e6ed2c32bf287ebc1852770d7861f68bf3a.tar.bz2 |
Eliminate port/platform/win directory. Stop building a fork of BString, and
stop depending on COMPtr.h. I avoided BString by definining a bastard shim in
AccessibleBase.cpp. I did that because the one from WebCore's platform/win
would require #if !USE(JSC) to avoid UString issues. Eventually,
AccessibleBase.cpp is going to be rewritten to not use COM, so this issue will
go away.
R=dglazkov
Review URL: http://codereview.chromium.org/13808
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6986 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | webkit/SConscript.port | 3 | ||||
-rw-r--r-- | webkit/build/port/port.vcproj | 24 | ||||
-rw-r--r-- | webkit/glue/glue_accessibility.cc | 10 | ||||
-rw-r--r-- | webkit/glue/glue_accessibility.h | 2 | ||||
-rw-r--r-- | webkit/pending/AccessibleBase.cpp | 20 | ||||
-rw-r--r-- | webkit/port/platform/chromium/SoundChromiumWin.cpp (renamed from webkit/port/platform/win/SoundWin.cpp) | 1 | ||||
-rw-r--r-- | webkit/port/platform/win/BString.cpp | 194 | ||||
-rw-r--r-- | webkit/port/platform/win/BString.h | 81 | ||||
-rw-r--r-- | webkit/port/platform/win/COMPtr.h | 151 | ||||
-rw-r--r-- | webkit/port/platform/win/README | 2 |
10 files changed, 31 insertions, 457 deletions
diff --git a/webkit/SConscript.port b/webkit/SConscript.port index 3d7b5c4..832d5ab 100644 --- a/webkit/SConscript.port +++ b/webkit/SConscript.port @@ -115,8 +115,7 @@ if env['PLATFORM'] == 'win32': input_files.extend([ '$PORT_DIR/platform/chromium/FileSystemChromiumWin.cpp', '$PORT_DIR/platform/chromium/ScrollBarThemeChromiumWin.cpp', - '$PORT_DIR/platform/win/BString.cpp', - '$PORT_DIR/platform/win/SoundWin.cpp', + '$PORT_DIR/platform/chromium/SoundChromiumWin.cpp', '$PORT_DIR/platform/graphics/chromium/FontCacheChromiumWin.cpp', '$PORT_DIR/platform/graphics/chromium/FontPlatformDataChromiumWin.cpp', diff --git a/webkit/build/port/port.vcproj b/webkit/build/port/port.vcproj index 5e7eee0..5a9ead0 100644 --- a/webkit/build/port/port.vcproj +++ b/webkit/build/port/port.vcproj @@ -829,26 +829,6 @@ >
</File>
<Filter
- Name="win"
- >
- <File
- RelativePath="..\..\port\platform\win\BString.cpp"
- >
- </File>
- <File
- RelativePath="..\..\port\platform\win\BString.h"
- >
- </File>
- <File
- RelativePath="..\..\port\platform\win\COMPtr.h"
- >
- </File>
- <File
- RelativePath="..\..\port\platform\win\SoundWin.cpp"
- >
- </File>
- </Filter>
- <Filter
Name="chromium"
>
<File
@@ -976,6 +956,10 @@ >
</File>
<File
+ RelativePath="..\..\port\platform\chromium\SoundChromiumWin.cpp"
+ >
+ </File>
+ <File
RelativePath="..\..\port\platform\chromium\SSLKeyGeneratorChromium.cpp"
>
</File>
diff --git a/webkit/glue/glue_accessibility.cc b/webkit/glue/glue_accessibility.cc index ee3a3e1..2d0c8f4 100644 --- a/webkit/glue/glue_accessibility.cc +++ b/webkit/glue/glue_accessibility.cc @@ -9,7 +9,6 @@ #pragma warning(push, 0) #include "AccessibleDocument.h" #include "AXObjectCache.h" -#include "COMPtr.h" #include "Document.h" #include "Frame.h" #pragma warning(pop) @@ -17,16 +16,19 @@ #include "webkit/glue/glue_accessibility.h" -#include "chrome/browser/iaccessible_function_ids.h" +#include "base/ref_counted.h" #include "webkit/glue/webframe_impl.h" #include "webkit/glue/webview_impl.h" +// TODO: Remove this evil dependency on Chrome! +#include "chrome/browser/iaccessible_function_ids.h" + // struct GlueAccessibility::GlueAccessibilityRoot struct GlueAccessibility::GlueAccessibilityRoot { GlueAccessibilityRoot() {} // Root of the WebKit IAccessible tree. - COMPtr<AccessibleDocument> accessibility_root_; + scoped_refptr<AccessibleDocument> accessibility_root_; }; // class GlueAccessibility @@ -51,7 +53,7 @@ bool GlueAccessibility::GetAccessibilityInfo(WebView* view, } // Temporary storing for the currently active IAccessible. - COMPtr<IAccessible> active_iaccessible; + scoped_refptr<IAccessible> active_iaccessible; IntToIAccessibleMap::iterator it = int_to_iaccessible_map_.find(in_params.iaccessible_id); diff --git a/webkit/glue/glue_accessibility.h b/webkit/glue/glue_accessibility.h index e7343b6..1423e44e 100644 --- a/webkit/glue/glue_accessibility.h +++ b/webkit/glue/glue_accessibility.h @@ -14,7 +14,7 @@ class WebView; template <typename T> class COMPtr; -typedef stdext::hash_map<int, COMPtr<IAccessible> > IntToIAccessibleMap; +typedef stdext::hash_map<int, scoped_refptr<IAccessible> > IntToIAccessibleMap; typedef stdext::hash_map<IAccessible*, int> IAccessibleToIntMap; //////////////////////////////////////////////////////////////////////////////// diff --git a/webkit/pending/AccessibleBase.cpp b/webkit/pending/AccessibleBase.cpp index e123ae3..2bca2eb 100644 --- a/webkit/pending/AccessibleBase.cpp +++ b/webkit/pending/AccessibleBase.cpp @@ -29,7 +29,6 @@ #include <oleacc.h> #include "AccessibilityObject.h" #include "AXObjectCache.h" -#include "BString.h" #include "Element.h" #include "EventHandler.h" #include "FrameView.h" @@ -46,6 +45,25 @@ using namespace WebCore; +namespace { + +// TODO(darin): Eliminate use of COM in this file, and then this class can die. +class BString { +public: + BString(const String& s) + { + if (s.isNull()) + m_bstr = 0; + else + m_bstr = SysAllocStringLen(s.characters(), s.length()); + } + BSTR release() { BSTR s = m_bstr; m_bstr = 0; return s; } +private: + BSTR m_bstr; +}; + +} + AccessibleBase::AccessibleBase(AccessibilityObject* obj) : AccessibilityObjectWrapper(obj) { diff --git a/webkit/port/platform/win/SoundWin.cpp b/webkit/port/platform/chromium/SoundChromiumWin.cpp index 443e7d9..38c5995 100644 --- a/webkit/port/platform/win/SoundWin.cpp +++ b/webkit/port/platform/chromium/SoundChromiumWin.cpp @@ -33,4 +33,3 @@ namespace WebCore { void systemBeep() { MessageBeep(static_cast<UINT>(-1)); } } // namespace WebCore - diff --git a/webkit/port/platform/win/BString.cpp b/webkit/port/platform/win/BString.cpp deleted file mode 100644 index c049b1b..0000000 --- a/webkit/port/platform/win/BString.cpp +++ /dev/null @@ -1,194 +0,0 @@ -/* - * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "BString.h" - -#include "AtomicString.h" -#include "KURL.h" -#include "PlatformString.h" -#include <comdef.h> -#include <tchar.h> -#include <windows.h> - -#if PLATFORM(CF) -#include <CoreFoundation/CoreFoundation.h> -#endif - -using namespace KJS; - -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 PLATFORM(CF) -BString::BString(CFStringRef cfstr) - : m_bstr(0) -{ - if (!cfstr) - return; - - const UniChar* uniChars = CFStringGetCharactersPtr(cfstr); - if (uniChars) { - m_bstr = SysAllocStringLen((LPCTSTR)uniChars, CFStringGetLength(cfstr)); - return; - } - - CFIndex length = CFStringGetLength(cfstr); - m_bstr = SysAllocStringLen(0, length); - CFStringGetCharacters(cfstr, CFRangeMake(0, length), (UniChar*)m_bstr); - m_bstr[length] = 0; -} -#endif - -BString::~BString() -{ - SysFreeString(m_bstr); -} - -BString::BString(const BString& other) -{ - if (!other.m_bstr) - m_bstr = 0; - else - m_bstr = SysAllocString(other.m_bstr); -} - -void BString::adoptBSTR(BSTR bstr) -{ - if (m_bstr) - SysFreeString(m_bstr); - m_bstr = bstr; -} - -BString& BString::operator=(const BString& other) -{ - if (this != &other) - *this = other.m_bstr; - return *this; -} - -BString& BString::operator=(const BSTR& other) -{ - if (other != m_bstr) { - SysFreeString(m_bstr); - m_bstr = other ? SysAllocString(other) : 0; - } - - return *this; -} - -bool operator ==(const BString& a, const BString& b) -{ - if (SysStringLen((BSTR)a) != SysStringLen((BSTR)b)) - return false; - if (!(BSTR)a && !(BSTR)b) - return true; - if (!(BSTR)a || !(BSTR)b) - return false; - return !_tcscmp((BSTR)a, (BSTR)b); -} - -bool operator !=(const BString& a, const BString& b) -{ - return !(a==b); -} - -bool operator ==(const BString& a, BSTR b) -{ - if (SysStringLen((BSTR)a) != SysStringLen(b)) - return false; - if (!(BSTR)a && !b) - return true; - if (!(BSTR)a || !b) - return false; - return !_tcscmp((BSTR)a, b); -} - -bool operator !=(const BString& a, BSTR b) -{ - return !(a==b); -} - -bool operator ==(BSTR a, const BString& b) -{ - if (SysStringLen(a) != SysStringLen((BSTR)b)) - return false; - if (!a && !(BSTR)b) - return true; - if (!a || !(BSTR)b) - return false; - return !_tcscmp(a, (BSTR)b); -} - -bool operator !=(BSTR a, const BString& b) -{ - return !(a==b); -} - -} diff --git a/webkit/port/platform/win/BString.h b/webkit/port/platform/win/BString.h deleted file mode 100644 index 803a9b0..0000000 --- a/webkit/port/platform/win/BString.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef BString_h -#define BString_h - -#if PLATFORM(CF) -typedef const struct __CFString * CFStringRef; -#endif - -typedef wchar_t* BSTR; - -namespace KJS { - class UString; -} - -namespace WebCore { - - class AtomicString; - class KURL; - class String; - - class BString { - public: - BString(); - BString(const wchar_t*); - BString(const wchar_t*, size_t length); - BString(const String&); - BString(const AtomicString&); - BString(const KURL&); -#if PLATFORM(CF) - BString(CFStringRef); -#endif - ~BString(); - - void adoptBSTR(BSTR); - - BString(const BString&); - BString& operator=(const BString&); - BString& operator=(const BSTR&); - - operator BSTR() const { return m_bstr; } - - BSTR release() { BSTR result = m_bstr; m_bstr = 0; return result; } - - private: - BSTR m_bstr; - }; - - bool operator ==(const BString&, const BString&); - bool operator !=(const BString&, const BString&); - bool operator ==(const BString&, BSTR); - bool operator !=(const BString&, BSTR); - bool operator ==(BSTR, const BString&); - bool operator !=(BSTR, const BString&); - -} - -#endif diff --git a/webkit/port/platform/win/COMPtr.h b/webkit/port/platform/win/COMPtr.h deleted file mode 100644 index c06b3d2..0000000 --- a/webkit/port/platform/win/COMPtr.h +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (C) 2007 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef COMPtr_h -#define COMPtr_h - -#include <WTF/Assertions.h> - -typedef long HRESULT; - -enum AdoptCOMTag { AdoptCOM }; - -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() { if (m_ptr) m_ptr->Release(); } - - T *get() const { return m_ptr; } - - 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>&); - - HRESULT copyRefTo(T**); - void adoptRef(T*); - -private: - T* m_ptr; -}; - -template <typename T> inline HRESULT COMPtr<T>::copyRefTo(T** 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(); -} - -#endif diff --git a/webkit/port/platform/win/README b/webkit/port/platform/win/README deleted file mode 100644 index 7fe1b47..0000000 --- a/webkit/port/platform/win/README +++ /dev/null @@ -1,2 +0,0 @@ -This directory is temporary and must go away. It contains forks of some files -from WebCore/platform/win/. |