From d0825bca7fe65beaee391d30da42e937db621564 Mon Sep 17 00:00:00 2001 From: Steve Block Date: Tue, 2 Feb 2010 14:57:50 +0000 Subject: Merge webkit.org at r54127 : Initial merge by git Change-Id: Ib661abb595522f50ea406f72d3a0ce17f7193c82 --- WebCore/platform/chromium/ChromiumBridge.h | 9 +++-- WebCore/platform/chromium/ChromiumDataObject.cpp | 3 ++ WebCore/platform/chromium/ChromiumDataObject.h | 2 + WebCore/platform/chromium/ClipboardChromium.cpp | 16 ++++++-- .../chromium/ClipboardUtilitiesChromium.cpp | 2 +- .../platform/chromium/ClipboardUtilitiesChromium.h | 2 +- WebCore/platform/chromium/DragDataChromium.cpp | 2 +- WebCore/platform/chromium/KeyCodeConversionGtk.cpp | 17 ++++++++ WebCore/platform/chromium/PasteboardChromium.cpp | 10 ++--- WebCore/platform/chromium/PlatformBridge.h | 47 ++++++++++++++++++++++ .../chromium/PlatformKeyboardEventChromium.cpp | 12 +++--- WebCore/platform/chromium/PopupMenuChromium.cpp | 35 ++++++++-------- .../platform/chromium/ScrollbarThemeChromiumMac.mm | 2 +- 13 files changed, 121 insertions(+), 38 deletions(-) create mode 100644 WebCore/platform/chromium/PlatformBridge.h (limited to 'WebCore/platform/chromium') diff --git a/WebCore/platform/chromium/ChromiumBridge.h b/WebCore/platform/chromium/ChromiumBridge.h index 3709f7c..92b4c13 100644 --- a/WebCore/platform/chromium/ChromiumBridge.h +++ b/WebCore/platform/chromium/ChromiumBridge.h @@ -43,7 +43,7 @@ typedef struct NPObject NPObject; typedef struct _NPP NPP_t; typedef NPP_t* NPP; -#if PLATFORM(WIN_OS) +#if OS(WINDOWS) typedef struct HFONT__* HFONT; #endif @@ -87,6 +87,7 @@ namespace WebCore { static String cookies(const KURL& url, const KURL& firstPartyForCookies); static bool rawCookies(const KURL& url, const KURL& firstPartyForCookies, Vector*); static void deleteCookie(const KURL& url, const String& cookieName); + static bool cookiesEnabled(const KURL& url, const KURL& firstPartyForCookies); // DNS ---------------------------------------------------------------- static void prefetchDNS(const String& hostname); @@ -105,10 +106,10 @@ namespace WebCore { static KURL filePathToURL(const String&); // Font --------------------------------------------------------------- -#if PLATFORM(WIN_OS) +#if OS(WINDOWS) static bool ensureFontLoaded(HFONT font); #endif -#if PLATFORM(LINUX) +#if OS(LINUX) static String getFontFamilyForCharacters(const UChar*, size_t numCharacters); #endif @@ -187,7 +188,7 @@ namespace WebCore { static double currentTime(); // Theming ------------------------------------------------------------ -#if PLATFORM(WIN_OS) +#if OS(WINDOWS) static void paintButton( GraphicsContext*, int part, int state, int classicState, const IntRect&); static void paintMenuList( diff --git a/WebCore/platform/chromium/ChromiumDataObject.cpp b/WebCore/platform/chromium/ChromiumDataObject.cpp index 683c2e6..df0849c 100644 --- a/WebCore/platform/chromium/ChromiumDataObject.cpp +++ b/WebCore/platform/chromium/ChromiumDataObject.cpp @@ -37,6 +37,7 @@ void ChromiumDataObject::clear() { url = KURL(); urlTitle = ""; + downloadURL = KURL(); fileExtension = ""; filenames.clear(); plainText = ""; @@ -50,6 +51,7 @@ void ChromiumDataObject::clear() bool ChromiumDataObject::hasData() const { return !url.isEmpty() + || !downloadURL.isEmpty() || !fileExtension.isEmpty() || !filenames.isEmpty() || !plainText.isEmpty() @@ -60,6 +62,7 @@ bool ChromiumDataObject::hasData() const ChromiumDataObject::ChromiumDataObject(const ChromiumDataObject& other) : url(other.url) , urlTitle(other.urlTitle) + , downloadURL(other.downloadURL) , fileExtension(other.fileExtension) , filenames(other.filenames) , plainText(other.plainText) diff --git a/WebCore/platform/chromium/ChromiumDataObject.h b/WebCore/platform/chromium/ChromiumDataObject.h index 3e8675e..15eb911 100644 --- a/WebCore/platform/chromium/ChromiumDataObject.h +++ b/WebCore/platform/chromium/ChromiumDataObject.h @@ -59,6 +59,8 @@ namespace WebCore { KURL url; String urlTitle; + KURL downloadURL; + String fileExtension; Vector filenames; diff --git a/WebCore/platform/chromium/ClipboardChromium.cpp b/WebCore/platform/chromium/ClipboardChromium.cpp index 1a2caa4..32f7d50 100644 --- a/WebCore/platform/chromium/ClipboardChromium.cpp +++ b/WebCore/platform/chromium/ClipboardChromium.cpp @@ -53,7 +53,7 @@ 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 }; +enum ClipboardDataType { ClipboardDataTypeNone, ClipboardDataTypeURL, ClipboardDataTypeText, ClipboardDataTypeDownloadURL }; static ClipboardDataType clipboardTypeFromMIMEType(const String& type) { @@ -64,6 +64,8 @@ static ClipboardDataType clipboardTypeFromMIMEType(const String& type) return ClipboardDataTypeText; if (cleanType == "url" || cleanType == "text/uri-list") return ClipboardDataTypeURL; + if (cleanType == "downloadurl") + return ClipboardDataTypeDownloadURL; return ClipboardDataTypeNone; } @@ -157,6 +159,14 @@ bool ClipboardChromium::setData(const String& type, const String& data) return true; } + if (winType == ClipboardDataTypeDownloadURL) { + KURL url = KURL(ParsedURLString, data); + if (url.isValid()) { + m_dataObject->downloadURL = url; + return true; + } + } + return false; } @@ -353,13 +363,13 @@ void ClipboardChromium::writeRange(Range* selectedRange, Frame* frame) m_dataObject->textHtml = createMarkup(selectedRange, 0, AnnotateForInterchange); -#if PLATFORM(DARWIN) +#if OS(DARWIN) m_dataObject->textHtml = String("") + m_dataObject->textHtml; #endif m_dataObject->htmlBaseUrl = frame->document()->url(); String str = frame->selectedText(); -#if PLATFORM(WIN_OS) +#if OS(WINDOWS) replaceNewlinesWithWindowsStyleNewlines(str); #endif replaceNBSPWithSpace(str); diff --git a/WebCore/platform/chromium/ClipboardUtilitiesChromium.cpp b/WebCore/platform/chromium/ClipboardUtilitiesChromium.cpp index 7efcb3c..5d9ed05 100644 --- a/WebCore/platform/chromium/ClipboardUtilitiesChromium.cpp +++ b/WebCore/platform/chromium/ClipboardUtilitiesChromium.cpp @@ -36,7 +36,7 @@ namespace WebCore { -#if PLATFORM(WIN_OS) +#if OS(WINDOWS) void replaceNewlinesWithWindowsStyleNewlines(String& str) { static const UChar Newline = '\n'; diff --git a/WebCore/platform/chromium/ClipboardUtilitiesChromium.h b/WebCore/platform/chromium/ClipboardUtilitiesChromium.h index c597089..23fd29c 100644 --- a/WebCore/platform/chromium/ClipboardUtilitiesChromium.h +++ b/WebCore/platform/chromium/ClipboardUtilitiesChromium.h @@ -33,7 +33,7 @@ namespace WebCore { class KURL; class String; -#if PLATFORM(WIN_OS) +#if OS(WINDOWS) void replaceNewlinesWithWindowsStyleNewlines(String&); #endif void replaceNBSPWithSpace(String&); diff --git a/WebCore/platform/chromium/DragDataChromium.cpp b/WebCore/platform/chromium/DragDataChromium.cpp index 133ba24..9b67fc0 100644 --- a/WebCore/platform/chromium/DragDataChromium.cpp +++ b/WebCore/platform/chromium/DragDataChromium.cpp @@ -147,7 +147,7 @@ PassRefPtr DragData::asFragment(Document* doc) const if (!m_platformDragData->textHtml.isEmpty()) { RefPtr fragment = createFragmentFromMarkup(doc, - m_platformDragData->textHtml, m_platformDragData->htmlBaseUrl); + m_platformDragData->textHtml, m_platformDragData->htmlBaseUrl, FragmentScriptingNotAllowed); return fragment.release(); } diff --git a/WebCore/platform/chromium/KeyCodeConversionGtk.cpp b/WebCore/platform/chromium/KeyCodeConversionGtk.cpp index e3d5f61..a709f3e 100644 --- a/WebCore/platform/chromium/KeyCodeConversionGtk.cpp +++ b/WebCore/platform/chromium/KeyCodeConversionGtk.cpp @@ -72,6 +72,23 @@ int windowsKeyCodeForKeyEvent(unsigned keycode) case GDK_KP_Divide: return VKEY_DIVIDE; // (6F) Divide key + case GDK_KP_Page_Up: + return VKEY_PRIOR; // (21) PAGE UP key + case GDK_KP_Page_Down: + return VKEY_NEXT; // (22) PAGE DOWN key + case GDK_KP_End: + return VKEY_END; // (23) END key + case GDK_KP_Home: + return VKEY_HOME; // (24) HOME key + case GDK_KP_Left: + return VKEY_LEFT; // (25) LEFT ARROW key + case GDK_KP_Up: + return VKEY_UP; // (26) UP ARROW key + case GDK_KP_Right: + return VKEY_RIGHT; // (27) RIGHT ARROW key + case GDK_KP_Down: + return VKEY_DOWN; // (28) DOWN ARROW key + case GDK_BackSpace: return VKEY_BACK; // (08) BACKSPACE key case GDK_ISO_Left_Tab: diff --git a/WebCore/platform/chromium/PasteboardChromium.cpp b/WebCore/platform/chromium/PasteboardChromium.cpp index ce06e55..3b3aea6 100644 --- a/WebCore/platform/chromium/PasteboardChromium.cpp +++ b/WebCore/platform/chromium/PasteboardChromium.cpp @@ -82,13 +82,13 @@ void Pasteboard::setSelectionMode(bool selectionMode) void Pasteboard::writeSelection(Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame) { String html = createMarkup(selectedRange, 0, AnnotateForInterchange); -#if PLATFORM(DARWIN) +#if OS(DARWIN) html = String("") + html; #endif ExceptionCode ec = 0; KURL url = selectedRange->startContainer(ec)->document()->url(); String plainText = frame->selectedText(); -#if PLATFORM(WIN_OS) +#if OS(WINDOWS) replaceNewlinesWithWindowsStyleNewlines(plainText); #endif replaceNBSPWithSpace(plainText); @@ -98,7 +98,7 @@ void Pasteboard::writeSelection(Range* selectedRange, bool canSmartCopyOrDelete, void Pasteboard::writePlainText(const String& text) { -#if PLATFORM(WIN_OS) +#if OS(WINDOWS) String plainText(text); replaceNewlinesWithWindowsStyleNewlines(plainText); ChromiumBridge::clipboardWritePlainText(plainText); @@ -170,14 +170,14 @@ PassRefPtr Pasteboard::documentFragment(Frame* frame, PassRefP String markup; KURL srcURL; ChromiumBridge::clipboardReadHTML(buffer, &markup, &srcURL); -#if PLATFORM(DARWIN) +#if OS(DARWIN) DEFINE_STATIC_LOCAL(const String, forceUtf8String, ("")); if (markup.startsWith(forceUtf8String)) markup = markup.substring(forceUtf8String.length()); #endif RefPtr fragment = - createFragmentFromMarkup(frame->document(), markup, srcURL); + createFragmentFromMarkup(frame->document(), markup, srcURL, FragmentScriptingNotAllowed); if (fragment) return fragment.release(); } diff --git a/WebCore/platform/chromium/PlatformBridge.h b/WebCore/platform/chromium/PlatformBridge.h new file mode 100644 index 0000000..ecb7b45 --- /dev/null +++ b/WebCore/platform/chromium/PlatformBridge.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2010 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 PlatformBridge_h +#define PlatformBridge_h + +#include "ChromiumBridge.h" + +namespace WebCore { + +// FIXME: A better name for ChromiumBridge is PlatformBridge. Android already +// uses PlatformBridge so the code that is shared among the Android and Chromium +// ports is gradually moving towards using PlatformBridge. Once the Android +// unforking is done, we will change the name of ChromiumBridge to PlatformBridge +// and merge the two classes into one that will be shared by both ports. +typedef ChromiumBridge PlatformBridge; + +} // namespace WebCore + +#endif // PlatformBridge_h diff --git a/WebCore/platform/chromium/PlatformKeyboardEventChromium.cpp b/WebCore/platform/chromium/PlatformKeyboardEventChromium.cpp index ae55afe..74643f7 100644 --- a/WebCore/platform/chromium/PlatformKeyboardEventChromium.cpp +++ b/WebCore/platform/chromium/PlatformKeyboardEventChromium.cpp @@ -27,9 +27,9 @@ #include "config.h" #include "PlatformKeyboardEvent.h" -#if PLATFORM(WIN_OS) +#if OS(WINDOWS) #include -#elif PLATFORM(DARWIN) +#elif OS(DARWIN) #import #else #include "NotImplemented.h" @@ -39,7 +39,7 @@ namespace WebCore { void PlatformKeyboardEvent::disambiguateKeyDownEvent(Type type, bool backwardCompatibilityMode) { -#if PLATFORM(WIN_OS) +#if OS(WINDOWS) // No KeyDown events on Windows to disambiguate. ASSERT_NOT_REACHED(); #else @@ -56,7 +56,7 @@ void PlatformKeyboardEvent::disambiguateKeyDownEvent(Type type, bool backwardCom } else { m_keyIdentifier = String(); m_windowsVirtualKeyCode = 0; -#if PLATFORM(DARWIN) +#if OS(DARWIN) if (m_text.length() == 1 && (m_text[0U] >= 0xF700 && m_text[0U] <= 0xF7FF)) { // According to NSEvents.h, OpenStep reserves the range 0xF700-0xF8FF for function keys. However, some actual private use characters // happen to be in this range, e.g. the Apple logo (Option+Shift+K). @@ -71,10 +71,10 @@ void PlatformKeyboardEvent::disambiguateKeyDownEvent(Type type, bool backwardCom bool PlatformKeyboardEvent::currentCapsLockState() { -#if PLATFORM(WIN_OS) +#if OS(WINDOWS) // FIXME: Does this even work inside the sandbox? return GetKeyState(VK_CAPITAL) & 1; -#elif PLATFORM(DARWIN) +#elif OS(DARWIN) return GetCurrentKeyModifiers() & alphaLock; #else notImplemented(); diff --git a/WebCore/platform/chromium/PopupMenuChromium.cpp b/WebCore/platform/chromium/PopupMenuChromium.cpp index 5abd364..cab7ced 100644 --- a/WebCore/platform/chromium/PopupMenuChromium.cpp +++ b/WebCore/platform/chromium/PopupMenuChromium.cpp @@ -32,6 +32,7 @@ #include "PopupMenuChromium.h" #include "CharacterNames.h" +#include "Chrome.h" #include "ChromeClientChromium.h" #include "Font.h" #include "FontSelector.h" @@ -610,17 +611,10 @@ bool PopupListBox::isInterestedInEventForKey(int keyCode) static bool isCharacterTypeEvent(const PlatformKeyboardEvent& event) { // Check whether the event is a character-typed event or not. - // In Windows, PlatformKeyboardEvent::Char (not RawKeyDown) type event - // is considered as character type event. In Mac OS, KeyDown (not - // KeyUp) is considered as character type event. -#if PLATFORM(WIN_OS) - if (event.type() == PlatformKeyboardEvent::Char) - return true; -#else - if (event.type() == PlatformKeyboardEvent::KeyDown) - return true; -#endif - return false; + // We use RawKeyDown/Char/KeyUp event scheme on all platforms, + // so PlatformKeyboardEvent::Char (not RawKeyDown) type event + // is considered as character type event. + return event.type() == PlatformKeyboardEvent::Char; } bool PopupListBox::handleKeyEvent(const PlatformKeyboardEvent& event) @@ -744,13 +738,18 @@ void PopupListBox::typeAheadFind(const PlatformKeyboardEvent& event) } } + // Compute a case-folded copy of the prefix string before beginning the search for + // a matching element. This code uses foldCase to work around the fact that + // String::startWith does not fold non-ASCII characters. This code can be changed + // to use startWith once that is fixed. + String prefixWithCaseFolded(prefix.foldCase()); int itemCount = numItems(); int index = (max(0, m_selectedIndex) + searchStartOffset) % itemCount; for (int i = 0; i < itemCount; i++, index = (index + 1) % itemCount) { if (!isSelectableItem(index)) continue; - if (stripLeadingWhiteSpace(m_items[index]->label).startsWith(prefix, false)) { + if (stripLeadingWhiteSpace(m_items[index]->label).foldCase().startsWith(prefixWithCaseFolded)) { selectIndex(index); return; } @@ -912,6 +911,10 @@ int PopupListBox::pointToRowIndex(const IntPoint& point) void PopupListBox::acceptIndex(int index) { + // Clear m_acceptedIndexOnAbandon once user accepts the selected index. + if (m_acceptedIndexOnAbandon >= 0) + m_acceptedIndexOnAbandon = -1; + if (index >= numItems()) return; @@ -1134,7 +1137,7 @@ void PopupListBox::layout() // Calculate scroll bar width. int windowHeight = 0; -#if PLATFORM(DARWIN) +#if OS(DARWIN) // Set the popup's window to contain all available items on Mac only, which // uses native controls that manage their own scrolling. This allows hit // testing to work when selecting items in popups that have more menu entries @@ -1146,7 +1149,7 @@ void PopupListBox::layout() for (int i = 0; i < m_visibleRows; ++i) { int rowHeight = getRowHeight(i); -#if !PLATFORM(DARWIN) +#if !OS(DARWIN) // Only clip the window height for non-Mac platforms. if (windowHeight + rowHeight > kMaxHeight) { m_visibleRows = i; @@ -1224,7 +1227,7 @@ void PopupMenu::show(const IntRect& r, FrameView* v, int index) { if (!p.popup) p.popup = PopupContainer::create(client(), dropDownSettings); -#if PLATFORM(DARWIN) +#if OS(DARWIN) p.popup->showExternal(r, v, index); #else p.popup->show(r, v, index); @@ -1234,7 +1237,7 @@ void PopupMenu::show(const IntRect& r, FrameView* v, int index) void PopupMenu::hide() { if (p.popup) - p.popup->hidePopup(); + p.popup->hide(); } void PopupMenu::updateFromElement() diff --git a/WebCore/platform/chromium/ScrollbarThemeChromiumMac.mm b/WebCore/platform/chromium/ScrollbarThemeChromiumMac.mm index b4ebaf6..e532d57 100644 --- a/WebCore/platform/chromium/ScrollbarThemeChromiumMac.mm +++ b/WebCore/platform/chromium/ScrollbarThemeChromiumMac.mm @@ -375,7 +375,7 @@ bool ScrollbarThemeChromiumMac::paint(Scrollbar* scrollbar, GraphicsContext* con trackInfo.min = 0; trackInfo.max = scrollbar->maximum(); trackInfo.value = scrollbar->currentPos(); - trackInfo.trackInfo.scrollbar.viewsize = scrollbar->pageStep(); + trackInfo.trackInfo.scrollbar.viewsize = scrollbar->visibleSize(); trackInfo.attributes = 0; if (scrollbar->orientation() == HorizontalScrollbar) trackInfo.attributes |= kThemeTrackHorizontal; -- cgit v1.1