diff options
Diffstat (limited to 'Source/WebCore/platform/chromium')
-rw-r--r-- | Source/WebCore/platform/chromium/ClipboardChromium.cpp | 19 | ||||
-rw-r--r-- | Source/WebCore/platform/chromium/ClipboardChromium.h | 4 | ||||
-rw-r--r-- | Source/WebCore/platform/chromium/DataTransferItemChromium.cpp | 108 | ||||
-rw-r--r-- | Source/WebCore/platform/chromium/DataTransferItemChromium.h | 75 | ||||
-rw-r--r-- | Source/WebCore/platform/chromium/DataTransferItemsChromium.cpp | 111 | ||||
-rw-r--r-- | Source/WebCore/platform/chromium/DataTransferItemsChromium.h (renamed from Source/WebCore/platform/chromium/WindowsVersion.h) | 53 | ||||
-rw-r--r-- | Source/WebCore/platform/chromium/FileSystemChromium.cpp | 7 | ||||
-rw-r--r-- | Source/WebCore/platform/chromium/PasteboardPrivate.h | 1 | ||||
-rw-r--r-- | Source/WebCore/platform/chromium/ScrollbarThemeChromiumWin.cpp | 24 | ||||
-rw-r--r-- | Source/WebCore/platform/chromium/TraceEvent.h | 74 | ||||
-rw-r--r-- | Source/WebCore/platform/chromium/WindowsVersion.cpp | 52 |
11 files changed, 456 insertions, 72 deletions
diff --git a/Source/WebCore/platform/chromium/ClipboardChromium.cpp b/Source/WebCore/platform/chromium/ClipboardChromium.cpp index 7e58f03..6756313 100644 --- a/Source/WebCore/platform/chromium/ClipboardChromium.cpp +++ b/Source/WebCore/platform/chromium/ClipboardChromium.cpp @@ -31,6 +31,7 @@ #include "ChromiumDataObject.h" #include "ClipboardMimeTypes.h" #include "ClipboardUtilitiesChromium.h" +#include "DataTransferItemsChromium.h" #include "Document.h" #include "DragData.h" #include "Element.h" @@ -342,4 +343,22 @@ bool ClipboardChromium::hasData() return m_dataObject->hasData(); } +#if ENABLE(DATA_TRANSFER_ITEMS) +PassRefPtr<DataTransferItems> ClipboardChromium::items() +{ + RefPtr<DataTransferItemsChromium> items = DataTransferItemsChromium::create(this, m_frame->document()->scriptExecutionContext()); + + if (!m_dataObject) + return items; + + if (isForCopyAndPaste() && policy() == ClipboardReadable) { + // Iterate through the types and add them. + HashSet<String> types = m_dataObject->types(); + for (HashSet<String>::const_iterator it = types.begin(); it != types.end(); ++it) + items->addPasteboardItem(*it); + } + return items; +} +#endif + } // namespace WebCore diff --git a/Source/WebCore/platform/chromium/ClipboardChromium.h b/Source/WebCore/platform/chromium/ClipboardChromium.h index d30a1c4..61db0a5 100644 --- a/Source/WebCore/platform/chromium/ClipboardChromium.h +++ b/Source/WebCore/platform/chromium/ClipboardChromium.h @@ -80,6 +80,10 @@ namespace WebCore { virtual bool hasData(); +#if ENABLE(DATA_TRANSFER_ITEMS) + virtual PassRefPtr<DataTransferItems> items(); +#endif + private: ClipboardChromium(ClipboardType, PassRefPtr<ChromiumDataObject>, ClipboardAccessPolicy, Frame*); diff --git a/Source/WebCore/platform/chromium/DataTransferItemChromium.cpp b/Source/WebCore/platform/chromium/DataTransferItemChromium.cpp new file mode 100644 index 0000000..7857336 --- /dev/null +++ b/Source/WebCore/platform/chromium/DataTransferItemChromium.cpp @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2011 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "DataTransferItemChromium.h" + +#if ENABLE(DATA_TRANSFER_ITEMS) + +#include "Clipboard.h" +#include "ClipboardMimeTypes.h" +#include "PlatformBridge.h" +#include "StringCallback.h" + +namespace WebCore { + +PassRefPtr<DataTransferItemChromium> DataTransferItemChromium::createFromPasteboard(PassRefPtr<Clipboard> owner, ScriptExecutionContext* context, const String& type) +{ + if (type == mimeTypeTextPlain || type == mimeTypeTextHTML) + return adoptRef(new DataTransferItemChromium(owner, context, PasteboardSource, DataTransferItem::kindString, type, "")); + return adoptRef(new DataTransferItemChromium(owner, context, PasteboardSource, DataTransferItem::kindFile, type, "")); +} + +PassRefPtr<DataTransferItemChromium> DataTransferItemChromium::create(PassRefPtr<Clipboard> owner, + ScriptExecutionContext* context, + const String& data, + const String& type) +{ + return adoptRef(new DataTransferItemChromium(owner, context, InternalSource, DataTransferItem::kindString, type, data)); +} + +DataTransferItemChromium::DataTransferItemChromium(PassRefPtr<Clipboard> owner, ScriptExecutionContext* context, DataSource source, const String& kind, const String& type, const String& data) + : m_owner(owner) + , m_context(context) + , m_source(source) + , m_kind(kind) + , m_type(type) + , m_data(data) +{ +} + +String DataTransferItemChromium::kind() const +{ + if (m_owner->policy() == ClipboardNumb) + return String(); + return m_kind; +} + +String DataTransferItemChromium::type() const +{ + if (m_owner->policy() == ClipboardNumb) + return String(); + return m_type; +} + +void DataTransferItemChromium::getAsString(PassRefPtr<StringCallback> callback) +{ + if ((m_owner->policy() != ClipboardReadable && m_owner->policy() != ClipboardWritable) + || m_kind != kindString) + return; + if (m_source == InternalSource) { + callback->scheduleCallback(m_context, m_data); + return; + } + // This is ugly but there's no real alternative. + if (m_type == mimeTypeTextPlain) { + callback->scheduleCallback(m_context, PlatformBridge::clipboardReadPlainText(PasteboardPrivate::StandardBuffer)); + return; + } + if (m_type == mimeTypeTextHTML) { + String html; + KURL ignoredSourceURL; + PlatformBridge::clipboardReadHTML(PasteboardPrivate::StandardBuffer, &html, &ignoredSourceURL); + callback->scheduleCallback(m_context, html); + return; + } + ASSERT_NOT_REACHED(); +} + +} // namespace WebCore + +#endif // ENABLE(DATA_TRANSFER_ITEMS) diff --git a/Source/WebCore/platform/chromium/DataTransferItemChromium.h b/Source/WebCore/platform/chromium/DataTransferItemChromium.h new file mode 100644 index 0000000..77f74f2 --- /dev/null +++ b/Source/WebCore/platform/chromium/DataTransferItemChromium.h @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2011 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef DataTransferItemChromium_h +#define DataTransferItemChromium_h + +#if ENABLE(DATA_TRANSFER_ITEMS) + +#include "DataTransferItem.h" +#include <wtf/RefPtr.h> +#include <wtf/text/WTFString.h> + +namespace WebCore { + +class Clipboard; +class ScriptExecutionContext; + +class DataTransferItemChromium : public DataTransferItem { +public: + static PassRefPtr<DataTransferItemChromium> createFromPasteboard(PassRefPtr<Clipboard> owner, ScriptExecutionContext*, const String& type); + static PassRefPtr<DataTransferItemChromium> create(PassRefPtr<Clipboard> owner, ScriptExecutionContext*, const String& data, const String& type); + + virtual String kind() const; + virtual String type() const; + + virtual void getAsString(PassRefPtr<StringCallback>); + +private: + enum DataSource { + PasteboardSource, + InternalSource, + }; + + DataTransferItemChromium(PassRefPtr<Clipboard> owner, ScriptExecutionContext*, DataSource, const String& kind, const String& type, const String& data); + + const RefPtr<Clipboard> m_owner; + ScriptExecutionContext* m_context; + const DataSource m_source; + const String m_kind; + const String m_type; + const String m_data; +}; + +} // namespace WebCore + +#endif // ENABLE(DATA_TRANSFER_ITEMS) + +#endif // DataTransferItem_h diff --git a/Source/WebCore/platform/chromium/DataTransferItemsChromium.cpp b/Source/WebCore/platform/chromium/DataTransferItemsChromium.cpp new file mode 100644 index 0000000..418b8b5 --- /dev/null +++ b/Source/WebCore/platform/chromium/DataTransferItemsChromium.cpp @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2011 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: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "DataTransferItemsChromium.h" + +#if ENABLE(DATA_TRANSFER_ITEMS) + +#include "Clipboard.h" +#include "DataTransferItemChromium.h" +#include "ExceptionCode.h" + +namespace WebCore { + +PassRefPtr<DataTransferItemsChromium> DataTransferItemsChromium::create(PassRefPtr<Clipboard> owner, ScriptExecutionContext* context) +{ + return adoptRef(new DataTransferItemsChromium(owner, context)); +} + +DataTransferItemsChromium::DataTransferItemsChromium(PassRefPtr<Clipboard> owner, ScriptExecutionContext* context) + : m_owner(owner) + , m_context(context) +{ +} + +unsigned long DataTransferItemsChromium::length() const +{ + if (m_owner->policy() == ClipboardNumb) + return 0; + return m_items.size(); +} + +PassRefPtr<DataTransferItem> DataTransferItemsChromium::item(unsigned long index) const +{ + if (m_owner->policy() == ClipboardNumb || index >= length()) + return 0; + return m_items[index]; +} + +void DataTransferItemsChromium::deleteItem(unsigned long index, ExceptionCode& ec) +{ + if (m_owner->policy() != ClipboardWritable) { + ec = INVALID_STATE_ERR; + return; + } + + if (index >= length()) + return; + + m_items.remove(index); +} + +void DataTransferItemsChromium::clear() +{ + if (m_owner->policy() != ClipboardWritable) + return; + + m_items.clear(); +} + +void DataTransferItemsChromium::add(const String& data, const String& type, ExceptionCode& ec) +{ + if (m_owner->policy() != ClipboardWritable) + return; + + // Only one 'string' item with a given type is allowed in the collection. + for (size_t i = 0; i < m_items.size(); ++i) { + if (m_items[i]->type() == type && m_items[i]->kind() == DataTransferItem::kindString) { + ec = INVALID_STATE_ERR; + return; + } + } + + m_items.append(DataTransferItemChromium::create(m_owner, m_context, data, type)); +} + +void DataTransferItemsChromium::addPasteboardItem(const String& type) +{ + m_items.append(DataTransferItemChromium::createFromPasteboard(m_owner, m_context, type)); +} + +} // namespace WebCore + +#endif // ENABLE(DATA_TRANSFER_ITEMS) diff --git a/Source/WebCore/platform/chromium/WindowsVersion.h b/Source/WebCore/platform/chromium/DataTransferItemsChromium.h index 3b2010a..51c4fdb 100644 --- a/Source/WebCore/platform/chromium/WindowsVersion.h +++ b/Source/WebCore/platform/chromium/DataTransferItemsChromium.h @@ -1,10 +1,10 @@ /* - * Copyright (c) 2008, 2009, Google Inc. All rights reserved. - * + * Copyright (C) 2011 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: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above @@ -14,7 +14,7 @@ * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -28,13 +28,50 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef WindowsVersion_h -#define WindowsVersion_h +#ifndef DataTransferItemsChromium_h +#define DataTransferItemsChromium_h + +#if ENABLE(DATA_TRANSFER_ITEMS) + +#include "DataTransferItems.h" +#include <wtf/RefPtr.h> +#include <wtf/Vector.h> namespace WebCore { - bool isVistaOrNewer(); +class Clipboard; +class DataTransferItemChromium; +class ScriptExecutionContext; + +typedef int ExceptionCode; + +class DataTransferItemsChromium : public DataTransferItems { +public: + static PassRefPtr<DataTransferItemsChromium> create(PassRefPtr<Clipboard>, ScriptExecutionContext*); + + virtual unsigned long length() const; + virtual PassRefPtr<DataTransferItem> item(unsigned long index) const; + virtual void deleteItem(unsigned long index, ExceptionCode&); + virtual void clear(); + + virtual void add(const String& data, const String& type, ExceptionCode&); + +private: + friend class ClipboardChromium; + + DataTransferItemsChromium(PassRefPtr<Clipboard>, ScriptExecutionContext*); + + virtual void addPasteboardItem(const String& type); + + RefPtr<Clipboard> m_owner; + // Indirectly owned by our parent. + ScriptExecutionContext* m_context; + Vector<RefPtr<DataTransferItemChromium> > m_items; +}; } // namespace WebCore -#endif +#endif // ENABLE(DATA_TRANSFER_ITEMS) + +#endif // DataTransferItemsChromium_h + diff --git a/Source/WebCore/platform/chromium/FileSystemChromium.cpp b/Source/WebCore/platform/chromium/FileSystemChromium.cpp index faf5e92..5e03c5b 100644 --- a/Source/WebCore/platform/chromium/FileSystemChromium.cpp +++ b/Source/WebCore/platform/chromium/FileSystemChromium.cpp @@ -112,4 +112,11 @@ int writeToFile(PlatformFileHandle handle, const char* data, int length) return PlatformBridge::writeToFile(handle, data, length); } +Vector<String> listDirectory(const String& path, const String& filter) +{ + notImplemented(); + + return Vector<String>(); +} + } // namespace WebCore diff --git a/Source/WebCore/platform/chromium/PasteboardPrivate.h b/Source/WebCore/platform/chromium/PasteboardPrivate.h index 1de7fe3..5f167ba 100644 --- a/Source/WebCore/platform/chromium/PasteboardPrivate.h +++ b/Source/WebCore/platform/chromium/PasteboardPrivate.h @@ -36,6 +36,7 @@ namespace WebCore { class PasteboardPrivate { public: enum ClipboardFormat { + PlainTextFormat, HTMLFormat, BookmarkFormat, WebSmartPasteFormat, diff --git a/Source/WebCore/platform/chromium/ScrollbarThemeChromiumWin.cpp b/Source/WebCore/platform/chromium/ScrollbarThemeChromiumWin.cpp index 29e8b44..7229c51 100644 --- a/Source/WebCore/platform/chromium/ScrollbarThemeChromiumWin.cpp +++ b/Source/WebCore/platform/chromium/ScrollbarThemeChromiumWin.cpp @@ -35,7 +35,7 @@ #include "PlatformContextSkia.h" #include "PlatformMouseEvent.h" #include "Scrollbar.h" -#include "WindowsVersion.h" +#include "SystemInfo.h" namespace WebCore { @@ -70,7 +70,7 @@ int ScrollbarThemeChromiumWin::scrollbarThickness(ScrollbarControlSize controlSi bool ScrollbarThemeChromiumWin::invalidateOnMouseEnterExit() { - return isVistaOrNewer(); + return windowsVersion() >= WindowsVista; } bool ScrollbarThemeChromiumWin::shouldSnapBackToDragOrigin(Scrollbar* scrollbar, const PlatformMouseEvent& evt) @@ -160,12 +160,12 @@ int ScrollbarThemeChromiumWin::getThemeState(Scrollbar* scrollbar, ScrollbarPart if (scrollbar->pressedPart() == ThumbPart) { if (part == ThumbPart) return SCRBS_PRESSED; - return isVistaOrNewer() ? SCRBS_HOVER : SCRBS_NORMAL; + return (windowsVersion() < WindowsVista) ? SCRBS_NORMAL : SCRBS_HOVER; } if (!scrollbar->enabled()) return SCRBS_DISABLED; if (scrollbar->hoveredPart() != part || part == BackTrackPart || part == ForwardTrackPart) - return (scrollbar->hoveredPart() == NoPart || !isVistaOrNewer()) ? SCRBS_NORMAL : SCRBS_HOVER; + return (scrollbar->hoveredPart() == NoPart || (windowsVersion() < WindowsVista)) ? SCRBS_NORMAL : SCRBS_HOVER; if (scrollbar->pressedPart() == NoPart) return SCRBS_HOT; return (scrollbar->pressedPart() == part) ? SCRBS_PRESSED : SCRBS_NORMAL; @@ -179,43 +179,43 @@ int ScrollbarThemeChromiumWin::getThemeArrowState(Scrollbar* scrollbar, Scrollba if (part == BackButtonStartPart || part == ForwardButtonStartPart) { if (scrollbar->orientation() == HorizontalScrollbar) { if (scrollbar->pressedPart() == ThumbPart) - return !isVistaOrNewer() ? ABS_LEFTNORMAL : ABS_LEFTHOVER; + return (windowsVersion() < WindowsVista) ? ABS_LEFTNORMAL : ABS_LEFTHOVER; if (!scrollbar->enabled()) return ABS_LEFTDISABLED; if (scrollbar->hoveredPart() != part) - return ((scrollbar->hoveredPart() == NoPart) || !isVistaOrNewer()) ? ABS_LEFTNORMAL : ABS_LEFTHOVER; + return ((scrollbar->hoveredPart() == NoPart) || (windowsVersion() < WindowsVista)) ? ABS_LEFTNORMAL : ABS_LEFTHOVER; if (scrollbar->pressedPart() == NoPart) return ABS_LEFTHOT; return (scrollbar->pressedPart() == part) ? ABS_LEFTPRESSED : ABS_LEFTNORMAL; } if (scrollbar->pressedPart() == ThumbPart) - return !isVistaOrNewer() ? ABS_UPNORMAL : ABS_UPHOVER; + return (windowsVersion() < WindowsVista) ? ABS_UPNORMAL : ABS_UPHOVER; if (!scrollbar->enabled()) return ABS_UPDISABLED; if (scrollbar->hoveredPart() != part) - return ((scrollbar->hoveredPart() == NoPart) || !isVistaOrNewer()) ? ABS_UPNORMAL : ABS_UPHOVER; + return ((scrollbar->hoveredPart() == NoPart) || (windowsVersion() < WindowsVista)) ? ABS_UPNORMAL : ABS_UPHOVER; if (scrollbar->pressedPart() == NoPart) return ABS_UPHOT; return (scrollbar->pressedPart() == part) ? ABS_UPPRESSED : ABS_UPNORMAL; } if (scrollbar->orientation() == HorizontalScrollbar) { if (scrollbar->pressedPart() == ThumbPart) - return !isVistaOrNewer() ? ABS_RIGHTNORMAL : ABS_RIGHTHOVER; + return (windowsVersion() < WindowsVista) ? ABS_RIGHTNORMAL : ABS_RIGHTHOVER; if (!scrollbar->enabled()) return ABS_RIGHTDISABLED; if (scrollbar->hoveredPart() != part) - return ((scrollbar->hoveredPart() == NoPart) || !isVistaOrNewer()) ? ABS_RIGHTNORMAL : ABS_RIGHTHOVER; + return ((scrollbar->hoveredPart() == NoPart) || (windowsVersion() < WindowsVista)) ? ABS_RIGHTNORMAL : ABS_RIGHTHOVER; if (scrollbar->pressedPart() == NoPart) return ABS_RIGHTHOT; return (scrollbar->pressedPart() == part) ? ABS_RIGHTPRESSED : ABS_RIGHTNORMAL; } if (scrollbar->pressedPart() == ThumbPart) - return !isVistaOrNewer() ? ABS_DOWNNORMAL : ABS_DOWNHOVER; + return (windowsVersion() < WindowsVista) ? ABS_DOWNNORMAL : ABS_DOWNHOVER; if (!scrollbar->enabled()) return ABS_DOWNDISABLED; if (scrollbar->hoveredPart() != part) - return ((scrollbar->hoveredPart() == NoPart) || !isVistaOrNewer()) ? ABS_DOWNNORMAL : ABS_DOWNHOVER; + return ((scrollbar->hoveredPart() == NoPart) || (windowsVersion() < WindowsVista)) ? ABS_DOWNNORMAL : ABS_DOWNHOVER; if (scrollbar->pressedPart() == NoPart) return ABS_DOWNHOT; return (scrollbar->pressedPart() == part) ? ABS_DOWNPRESSED : ABS_DOWNNORMAL; diff --git a/Source/WebCore/platform/chromium/TraceEvent.h b/Source/WebCore/platform/chromium/TraceEvent.h new file mode 100644 index 0000000..9b92d58 --- /dev/null +++ b/Source/WebCore/platform/chromium/TraceEvent.h @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2011 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 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 TraceEvent_h +#define TraceEvent_h + +#include "PlatformBridge.h" + +// Implementation detail: trace event macros create temporary variables +// to keep instrumentation overhead low. These macros give each temporary +// variable a unique name based on the line number to prevent name collissions. +#define TRACE_EVENT_MAKE_UNIQUE_IDENTIFIER3(a, b) a##b +#define TRACE_EVENT_MAKE_UNIQUE_IDENTIFIER2(a, b) TRACE_EVENT_MAKE_UNIQUE_IDENTIFIER3(a, b) +#define TRACE_EVENT_MAKE_UNIQUE_IDENTIFIER(name_prefix) TRACE_EVENT_MAKE_UNIQUE_IDENTIFIER2(name_prefix, __LINE__) + +// Issues PlatformBridge::traceEventBegin and traceEventEnd calls for the enclosing scope +#define TRACE_EVENT(name, id, extra) WebCore::internal::ScopeTracer TRACE_EVENT_MAKE_UNIQUE_IDENTIFIER(__traceEventScope)(name, id, extra); + +namespace WebCore { + +namespace internal { + +// Used by TRACE_EVENT macro. Do not use directly. +class ScopeTracer { +public: + ScopeTracer(const char* name, void*, const char* extra); + ~ScopeTracer(); + +private: + const char* m_name; + void* m_id; + OwnPtr<char*> m_extra; +}; + +inline ScopeTracer::ScopeTracer(const char* name, void* id, const char* extra) + : m_name(name) + , m_id(id) +{ + PlatformBridge::traceEventBegin(name, id, extra); \ + if (extra) + m_extra = adoptPtr(strdup(extra)); +} + +inline ScopeTracer::~ScopeTracer() +{ + PlatformBridge::traceEventEnd(m_name, m_id, m_extra.get()); +} + +} // namespace internal + +} // namespace WebCore + +#endif diff --git a/Source/WebCore/platform/chromium/WindowsVersion.cpp b/Source/WebCore/platform/chromium/WindowsVersion.cpp deleted file mode 100644 index a9632cb..0000000 --- a/Source/WebCore/platform/chromium/WindowsVersion.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) 2008, Google Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#include "config.h" -#include "WindowsVersion.h" - -#include <windows.h> - -namespace WebCore { - -bool isVistaOrNewer() -{ - // Cache the result to avoid asking every time. - static bool haveResult = false; - static bool result = false; - if (!haveResult) { - OSVERSIONINFO versionInfo; - versionInfo.dwOSVersionInfoSize = sizeof(versionInfo); - GetVersionEx(&versionInfo); - - haveResult = true; - result = versionInfo.dwMajorVersion >= 6; - } - return result; -} - -} // namespace WebCore |