diff options
Diffstat (limited to 'WebCore/platform/chromium')
-rw-r--r-- | WebCore/platform/chromium/ChromiumBridge.h | 7 | ||||
-rw-r--r-- | WebCore/platform/chromium/ClipboardChromium.cpp | 4 | ||||
-rw-r--r-- | WebCore/platform/chromium/ClipboardChromium.h | 1 | ||||
-rw-r--r-- | WebCore/platform/chromium/KeyCodeConversionGtk.cpp | 5 | ||||
-rw-r--r-- | WebCore/platform/chromium/MimeTypeRegistryChromium.cpp | 5 | ||||
-rw-r--r-- | WebCore/platform/chromium/PopupMenuChromium.cpp | 144 | ||||
-rw-r--r-- | WebCore/platform/chromium/PopupMenuChromium.h | 30 | ||||
-rw-r--r-- | WebCore/platform/chromium/ScrollbarThemeChromium.cpp | 64 | ||||
-rw-r--r-- | WebCore/platform/chromium/ScrollbarThemeChromium.h | 34 | ||||
-rw-r--r-- | WebCore/platform/chromium/ScrollbarThemeChromiumLinux.cpp | 41 | ||||
-rw-r--r-- | WebCore/platform/chromium/ScrollbarThemeChromiumLinux.h | 51 | ||||
-rw-r--r-- | WebCore/platform/chromium/ScrollbarThemeChromiumWin.cpp | 95 | ||||
-rw-r--r-- | WebCore/platform/chromium/ScrollbarThemeChromiumWin.h | 56 | ||||
-rw-r--r-- | WebCore/platform/chromium/SuddenTerminationChromium.cpp (renamed from WebCore/platform/chromium/KeyboardCodes.h) | 88 |
14 files changed, 413 insertions, 212 deletions
diff --git a/WebCore/platform/chromium/ChromiumBridge.h b/WebCore/platform/chromium/ChromiumBridge.h index 3e5c404..75e9103 100644 --- a/WebCore/platform/chromium/ChromiumBridge.h +++ b/WebCore/platform/chromium/ChromiumBridge.h @@ -76,8 +76,8 @@ namespace WebCore { static void clipboardWriteImage(const NativeImageSkia*, const KURL&, const String&); // Cookies ------------------------------------------------------------ - static void setCookies(const KURL& url, const KURL& policyURL, const String& value); - static String cookies(const KURL& url, const KURL& policyURL); + static void setCookies(const KURL& url, const KURL& firstPartyForCookies, const String& value); + static String cookies(const KURL& url, const KURL& firstPartyForCookies); // DNS ---------------------------------------------------------------- static void prefetchDNS(const String& hostname); @@ -135,6 +135,9 @@ namespace WebCore { static void decrementStatsCounter(const char* name); static void incrementStatsCounter(const char* name); + // Sudden Termination + static void suddenTerminationChanged(bool enabled); + // SystemTime --------------------------------------------------------- static double currentTime(); diff --git a/WebCore/platform/chromium/ClipboardChromium.cpp b/WebCore/platform/chromium/ClipboardChromium.cpp index b28503d..8f9ac7f 100644 --- a/WebCore/platform/chromium/ClipboardChromium.cpp +++ b/WebCore/platform/chromium/ClipboardChromium.cpp @@ -35,8 +35,10 @@ #include "Element.h" #include "Frame.h" #include "HTMLNames.h" +#include "NamedAttrMap.h" #include "MIMETypeRegistry.h" #include "markup.h" +#include "NamedNodeMap.h" #include "PlatformString.h" #include "Range.h" #include "RenderImage.h" @@ -216,7 +218,7 @@ static String imageToMarkup(const String& url, Element* element) markup.append("\""); // Copy over attributes. If we are dragging an image, we expect things like // the id to be copied as well. - NamedAttrMap* attrs = element->attributes(); + NamedNodeMap* attrs = element->attributes(); unsigned length = attrs->length(); for (unsigned i = 0; i < length; ++i) { Attribute* attr = attrs->attributeItem(i); diff --git a/WebCore/platform/chromium/ClipboardChromium.h b/WebCore/platform/chromium/ClipboardChromium.h index 53699da..0a83fd4 100644 --- a/WebCore/platform/chromium/ClipboardChromium.h +++ b/WebCore/platform/chromium/ClipboardChromium.h @@ -82,7 +82,6 @@ namespace WebCore { void resetFromClipboard(); void setDragImage(CachedImage*, Node*, const IntPoint&); RefPtr<ChromiumDataObject> m_dataObject; - Frame* m_frame; }; } // namespace WebCore diff --git a/WebCore/platform/chromium/KeyCodeConversionGtk.cpp b/WebCore/platform/chromium/KeyCodeConversionGtk.cpp index a3efe44..4fc7f32 100644 --- a/WebCore/platform/chromium/KeyCodeConversionGtk.cpp +++ b/WebCore/platform/chromium/KeyCodeConversionGtk.cpp @@ -150,9 +150,10 @@ int windowsKeyCodeForKeyEvent(unsigned keycode) case GDK_Help: return VKEY_HELP; // (2F) HELP key case GDK_0: - case GDK_parenleft: + case GDK_parenright: return VKEY_0; // (30) 0) key case GDK_1: + case GDK_exclam: return VKEY_1; // (31) 1 ! key case GDK_2: case GDK_at: @@ -176,7 +177,7 @@ int windowsKeyCodeForKeyEvent(unsigned keycode) case GDK_asterisk: return VKEY_8; // (38) 8 key '*' case GDK_9: - case GDK_parenright: + case GDK_parenleft: return VKEY_9; // (39) 9 key '(' case GDK_a: case GDK_A: diff --git a/WebCore/platform/chromium/MimeTypeRegistryChromium.cpp b/WebCore/platform/chromium/MimeTypeRegistryChromium.cpp index 1aac5ec..0f371b1 100644 --- a/WebCore/platform/chromium/MimeTypeRegistryChromium.cpp +++ b/WebCore/platform/chromium/MimeTypeRegistryChromium.cpp @@ -127,6 +127,11 @@ bool MIMETypeRegistry::isJavaAppletMIMEType(const String& mimeType) || mimeType.startsWith("application/x-java-vm", false); } +String MIMETypeRegistry::getMediaMIMETypeForExtension(const String&) +{ + return String(); +} + static HashSet<String>& dummyHashSet() { ASSERT_NOT_REACHED(); diff --git a/WebCore/platform/chromium/PopupMenuChromium.cpp b/WebCore/platform/chromium/PopupMenuChromium.cpp index 53f565a..1be075d 100644 --- a/WebCore/platform/chromium/PopupMenuChromium.cpp +++ b/WebCore/platform/chromium/PopupMenuChromium.cpp @@ -136,32 +136,26 @@ public: // Returns whether the popup wants to process events for the passed key. bool isInterestedInEventForKey(int keyCode); + // Gets the height of a row. + int getRowHeight(int index); + + // Returns true if the selection can be changed to index. + // Disabled items, or labels cannot be selected. + bool isSelectableItem(int index); + + const Vector<PopupItem*>& items() const { return m_items; } + private: friend class PopupContainer; friend class RefCounted<PopupListBox>; - // A type of List Item - enum ListItemType { - TypeOption, - TypeGroup, - TypeSeparator - }; - - // A item (represented by <option> or <optgroup>) in the <select> widget. - struct ListItem { - ListItem(const String& label, ListItemType type) - : label(label.copy()), type(type), y(0) {} - String label; - ListItemType type; - int y; // y offset of this item, relative to the top of the popup. - }; - PopupListBox(PopupMenuClient* client, const PopupContainerSettings& settings) : m_settings(settings) , m_originalIndex(0) , m_selectedIndex(0) - , m_willAcceptOnAbandon(false) + , m_acceptedIndexOnAbandon(-1) , m_visibleRows(0) + , m_baseWidth(0) , m_popupClient(client) , m_repeatingChar(0) , m_lastCharTime(0) @@ -184,10 +178,6 @@ private: // the web page, and closes the popup. void acceptIndex(int index); - // Returns true if the selection can be changed to index. - // Disabled items, or labels cannot be selected. - bool isSelectableItem(int index); - // Clears the selection (so no row appears selected). void clearSelection(); @@ -198,8 +188,6 @@ private: // Invalidates the row at the given index. void invalidateRow(int index); - // Gets the height of a row. - int getRowHeight(int index); // Get the bounds of a row. IntRect getRowBounds(int index); @@ -235,11 +223,11 @@ private: // enter yet however. int m_selectedIndex; - // True if we should accept the selectedIndex as chosen, even if the popup - // is "abandoned". This is used for keyboard navigation, where we want the + // If >= 0, this is the index we should accept if the popup is "abandoned". + // This is used for keyboard navigation, where we want the // selection to change immediately, and is only used if the settings // acceptOnAbandon field is true. - bool m_willAcceptOnAbandon; + int m_acceptedIndexOnAbandon; // This is the number of rows visible in the popup. The maximum number visible at a time is // defined as being kMaxVisibleRows. For a scrolled popup, this can be thought of as the @@ -250,7 +238,7 @@ private: int m_baseWidth; // A list of the options contained within the <select> - Vector<ListItem*> m_items; + Vector<PopupItem*> m_items; // The <select> PopupMenuClient that opened us. PopupMenuClient* m_popupClient; @@ -310,7 +298,8 @@ PassRefPtr<PopupContainer> PopupContainer::create(PopupMenuClient* client, return adoptRef(new PopupContainer(client, settings)); } -PopupContainer::PopupContainer(PopupMenuClient* client, const PopupContainerSettings& settings) +PopupContainer::PopupContainer(PopupMenuClient* client, + const PopupContainerSettings& settings) : m_listBox(PopupListBox::create(client, settings)) , m_settings(settings) { @@ -319,7 +308,7 @@ PopupContainer::PopupContainer(PopupMenuClient* client, const PopupContainerSett PopupContainer::~PopupContainer() { - if (m_listBox) + if (m_listBox && m_listBox->parent()) removeChild(m_listBox.get()); } @@ -342,7 +331,7 @@ void PopupContainer::showPopup(FrameView* view) if (widgetRect.bottom() > static_cast<int>(screen.bottom())) widgetRect.move(0, -(widgetRect.height() + selectHeight)); - chromeClient->popupOpened(this, widgetRect, m_settings.focusOnShow); + chromeClient->popupOpened(this, widgetRect, m_settings.focusOnShow, false); } if (!m_listBox->parent()) @@ -357,6 +346,29 @@ void PopupContainer::showPopup(FrameView* view) invalidate(); } +void PopupContainer::showExternal(const IntRect& rect, FrameView* v, int index) +{ + if (!listBox()) + return; + + listBox()->setBaseWidth(rect.width()); + listBox()->updateFromElement(); + + if (listBox()->numItems() < 1) { + hidePopup(); + return; + } + + // Adjust the popup position to account for scrolling. + IntPoint location = v->contentsToWindow(rect.location()); + IntRect popupRect(location, rect.size()); + + // Get the ChromeClient and pass it the popup menu's listbox data. + ChromeClientChromium* client = static_cast<ChromeClientChromium*>( + v->frame()->page()->chrome()->client()); + client->popupOpened(this, popupRect, true, true); +} + void PopupContainer::hidePopup() { if (client()) @@ -485,6 +497,16 @@ int PopupContainer::selectedIndex() const return m_listBox->selectedIndex(); } +int PopupContainer::menuItemHeight() const +{ + return m_listBox->getRowHeight(0); +} + +const WTF::Vector<PopupItem*>& PopupContainer:: popupData() const +{ + return m_listBox->items(); +} + /////////////////////////////////////////////////////////////////////////////// // PopupListBox implementation @@ -628,7 +650,7 @@ bool PopupListBox::handleKeyEvent(const PlatformKeyboardEvent& event) // IE). We change the original index so we revert to that when the // popup is closed. if (m_settings.acceptOnAbandon) - m_willAcceptOnAbandon = true; + m_acceptedIndexOnAbandon = m_selectedIndex; setOriginalIndex(m_selectedIndex); if (m_settings.setTextOnIndexChange) @@ -797,7 +819,7 @@ void PopupListBox::paintRow(GraphicsContext* gc, const IntRect& rect, int rowInd Font PopupListBox::getRowFont(int rowIndex) { - Font itemFont = m_popupClient->itemStyle(rowIndex).font(); + Font itemFont = m_popupClient->menuStyle().font(); if (m_popupClient->itemIsLabel(rowIndex)) { // Bold-ify labels (ie, an <optgroup> heading). FontDescription d = itemFont.fontDescription(); @@ -818,8 +840,10 @@ void PopupListBox::abandon() m_popupClient->hidePopup(); - if (m_willAcceptOnAbandon) - m_popupClient->valueChanged(m_selectedIndex); + if (m_acceptedIndexOnAbandon >= 0) { + m_popupClient->valueChanged(m_acceptedIndexOnAbandon); + m_acceptedIndexOnAbandon = -1; + } } int PopupListBox::pointToRowIndex(const IntPoint& point) @@ -828,7 +852,7 @@ int PopupListBox::pointToRowIndex(const IntPoint& point) // FIXME: binary search if perf matters. for (int i = 0; i < numItems(); ++i) { - if (y < m_items[i]->y) + if (y < m_items[i]->yOffset) return i-1; } @@ -890,7 +914,7 @@ IntRect PopupListBox::getRowBounds(int index) if (index < 0) return IntRect(0, 0, visibleWidth(), getRowHeight(index)); - return IntRect(0, m_items[index]->y, visibleWidth(), getRowHeight(index)); + return IntRect(0, m_items[index]->yOffset, visibleWidth(), getRowHeight(index)); } void PopupListBox::invalidateRow(int index) @@ -921,7 +945,7 @@ void PopupListBox::scrollToRevealRow(int index) bool PopupListBox::isSelectableItem(int index) { - return m_items[index]->type == TypeOption && m_popupClient->itemIsEnabled(index); + return m_items[index]->type == PopupItem::TypeOption && m_popupClient->itemIsEnabled(index); } void PopupListBox::clearSelection() @@ -998,26 +1022,19 @@ void PopupListBox::adjustSelectedIndex(int delta) void PopupListBox::updateFromElement() { - // It happens when pressing a key to jump to an item, then use tab or - // mouse to get away from the select box. In that case, updateFromElement - // is called before abandon, which causes discarding of the select result. - if (m_willAcceptOnAbandon) { - m_popupClient->valueChanged(m_selectedIndex); - m_willAcceptOnAbandon = false; - } - clear(); int size = m_popupClient->listSize(); for (int i = 0; i < size; ++i) { - ListItemType type; + PopupItem::Type type; if (m_popupClient->itemIsSeparator(i)) - type = PopupListBox::TypeSeparator; + type = PopupItem::TypeSeparator; else if (m_popupClient->itemIsLabel(i)) - type = PopupListBox::TypeGroup; + type = PopupItem::TypeGroup; else - type = PopupListBox::TypeOption; - m_items.append(new ListItem(m_popupClient->itemText(i), type)); + type = PopupItem::TypeOption; + m_items.append(new PopupItem(m_popupClient->itemText(i), type)); + m_items[i]->enabled = isSelectableItem(i); } m_selectedIndex = m_popupClient->selectedIndex(); @@ -1036,7 +1053,7 @@ void PopupListBox::layout() Font itemFont = getRowFont(i); // Place the item vertically. - m_items[i]->y = y; + m_items[i]->yOffset = y; y += itemFont.height(); // Ensure the popup is wide enough to fit this item. @@ -1051,13 +1068,26 @@ void PopupListBox::layout() } int windowHeight = 0; + +#if PLATFORM(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 + // than the maximum window size. + m_visibleRows = numItems(); +#else m_visibleRows = min(numItems(), kMaxVisibleRows); +#endif + for (int i = 0; i < m_visibleRows; ++i) { int rowHeight = getRowHeight(i); +#if !PLATFORM(DARWIN) + // Only clip the window height for non-Mac platforms. if (windowHeight + rowHeight > kMaxHeight) { m_visibleRows = i; break; } +#endif windowHeight += rowHeight; } @@ -1088,7 +1118,7 @@ void PopupListBox::layout() void PopupListBox::clear() { - for (Vector<ListItem*>::iterator it = m_items.begin(); it != m_items.end(); ++it) + for (Vector<PopupItem*>::iterator it = m_items.begin(); it != m_items.end(); ++it) delete *it; m_items.clear(); } @@ -1115,11 +1145,19 @@ PopupMenu::~PopupMenu() hide(); } -void PopupMenu::show(const IntRect& r, FrameView* v, int index) +// The Mac Chromium implementation relies on external control (a Cocoa control) +// to display, handle the input tracking and menu item selection for the popup. +// Windows and Linux Chromium let our WebKit port handle the display, while +// another process manages the popup window and input handling. +void PopupMenu::show(const IntRect& r, FrameView* v, int index) { if (!p.popup) p.popup = PopupContainer::create(client(), dropDownSettings); +#if PLATFORM(DARWIN) + p.popup->showExternal(r, v, index); +#else p.popup->show(r, v, index); +#endif } void PopupMenu::hide() diff --git a/WebCore/platform/chromium/PopupMenuChromium.h b/WebCore/platform/chromium/PopupMenuChromium.h index cd13c22..23003b1 100644 --- a/WebCore/platform/chromium/PopupMenuChromium.h +++ b/WebCore/platform/chromium/PopupMenuChromium.h @@ -42,6 +42,23 @@ namespace WebCore { class FrameView; class PopupListBox; + // A container for the data for each menu item (e.g. represented by <option> + // or <optgroup> in a <select> widget) and is used by PopupListBox. + struct PopupItem { + enum Type { + TypeOption, + TypeGroup, + TypeSeparator + }; + + PopupItem(const String& label, Type type) + : label(label), type(type), yOffset(0) { } + String label; + Type type; + int yOffset; // y offset of this item, relative to the top of the popup. + bool enabled; + }; + // FIXME: Our FramelessScrollView classes should probably implement HostWindow! // The PopupContainer class holds a PopupListBox (see cpp file). Its sole purpose is to be @@ -94,9 +111,14 @@ namespace WebCore { // Show the popup void showPopup(FrameView*); + // Used on Mac Chromium for HTML select popup menus. + void showExternal(const IntRect&, FrameView*, int index); + // Show the popup in the specified rect for the specified frame. // Note: this code was somehow arbitrarily factored-out of the Popup class - // so WebViewImpl can create a PopupContainer. + // so WebViewImpl can create a PopupContainer. This method is used for + // displaying auto complete popup menus on Mac Chromium, and for all + // popups on other platforms. void show(const IntRect&, FrameView*, int index); // Hide the popup. Do not call this directly: use client->hidePopup(). @@ -114,6 +136,12 @@ namespace WebCore { // Refresh the popup values from the PopupMenuClient. void refresh(); + // The menu per-item data. + const WTF::Vector<PopupItem*>& popupData() const; + + // The height of a row in the menu. + int menuItemHeight() const; + private: friend class WTF::RefCounted<PopupContainer>; diff --git a/WebCore/platform/chromium/ScrollbarThemeChromium.cpp b/WebCore/platform/chromium/ScrollbarThemeChromium.cpp index 426a078..78fc088 100644 --- a/WebCore/platform/chromium/ScrollbarThemeChromium.cpp +++ b/WebCore/platform/chromium/ScrollbarThemeChromium.cpp @@ -40,24 +40,6 @@ namespace WebCore { -ScrollbarTheme* ScrollbarTheme::nativeTheme() -{ - static ScrollbarThemeChromium theme; - return &theme; -} - -ScrollbarThemeChromium::ScrollbarThemeChromium() -{ -} - -ScrollbarThemeChromium::~ScrollbarThemeChromium() -{ -} - -void ScrollbarThemeChromium::themeChanged() -{ -} - bool ScrollbarThemeChromium::hasThumb(Scrollbar* scrollbar) { // This method is just called as a paint-time optimization to see if @@ -93,20 +75,6 @@ IntRect ScrollbarThemeChromium::forwardButtonRect(Scrollbar* scrollbar, Scrollba return IntRect(x, y, size.width(), size.height()); } -IntRect ScrollbarThemeChromium::trackRect(Scrollbar* scrollbar, bool) -{ - IntSize bs = buttonSize(scrollbar); - int thickness = scrollbarThickness(scrollbar->controlSize()); - if (scrollbar->orientation() == HorizontalScrollbar) { - if (scrollbar->width() < 2 * thickness) - return IntRect(); - return IntRect(scrollbar->x() + bs.width(), scrollbar->y(), scrollbar->width() - 2 * bs.width(), thickness); - } - if (scrollbar->height() < 2 * thickness) - return IntRect(); - return IntRect(scrollbar->x(), scrollbar->y() + bs.height(), thickness, scrollbar->height() - 2 * bs.height()); -} - void ScrollbarThemeChromium::paintTrackBackground(GraphicsContext* context, Scrollbar* scrollbar, const IntRect& rect) { // Just assume a forward track part. We only paint the track as a single piece when there is no thumb. @@ -165,36 +133,4 @@ bool ScrollbarThemeChromium::shouldCenterOnThumb(Scrollbar*, const PlatformMouse return evt.shiftKey() && evt.button() == LeftButton; } -IntSize ScrollbarThemeChromium::buttonSize(Scrollbar* scrollbar) -{ -#if defined(__linux__) - // On Linux, we don't use buttons - return IntSize(0, 0); -#endif - - // Our desired rect is essentially thickness by thickness. - - // Our actual rect will shrink to half the available space when we have < 2 - // times thickness pixels left. This allows the scrollbar to scale down - // and function even at tiny sizes. - - int thickness = scrollbarThickness(scrollbar->controlSize()); - - // In layout test mode, we force the button "girth" (i.e., the length of - // the button along the axis of the scrollbar) to be a fixed size. - // FIXME: This is retarded! scrollbarThickness is already fixed in layout - // test mode so that should be enough to result in repeatable results, but - // preserving this hack avoids having to rebaseline pixel tests. - const int kLayoutTestModeGirth = 17; - int girth = ChromiumBridge::layoutTestMode() ? kLayoutTestModeGirth : thickness; - - if (scrollbar->orientation() == HorizontalScrollbar) { - int width = scrollbar->width() < 2 * girth ? scrollbar->width() / 2 : girth; - return IntSize(width, thickness); - } - - int height = scrollbar->height() < 2 * girth ? scrollbar->height() / 2 : girth; - return IntSize(thickness, height); -} - } // namespace WebCore diff --git a/WebCore/platform/chromium/ScrollbarThemeChromium.h b/WebCore/platform/chromium/ScrollbarThemeChromium.h index 87ffd44..71d4817 100644 --- a/WebCore/platform/chromium/ScrollbarThemeChromium.h +++ b/WebCore/platform/chromium/ScrollbarThemeChromium.h @@ -1,10 +1,10 @@ /* * Copyright (c) 2008, 2009, 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 @@ -37,22 +37,9 @@ namespace WebCore { class PlatformMouseEvent; - // This class contains the Chromium scrollbar implementations for Windows - // and Linux. All of the symbols here in must be defined somewhere in the - // code and we manage the platform specific parts by linking in different, - // platform specific, files. Methods that we shared across platforms are - // implemented in ScrollbarThemeChromium.cpp + // This class contains the scrollbar code which is shared between Chromium + // Windows and Linux. class ScrollbarThemeChromium : public ScrollbarThemeComposite { - public: - ScrollbarThemeChromium(); - virtual ~ScrollbarThemeChromium(); - - virtual int scrollbarThickness(ScrollbarControlSize = RegularScrollbar); - - virtual void themeChanged(); - - virtual bool invalidateOnMouseEnterExit(); - protected: virtual bool hasButtons(Scrollbar*) { return true; } virtual bool hasThumb(Scrollbar*); @@ -65,19 +52,10 @@ namespace WebCore { virtual bool shouldCenterOnThumb(Scrollbar*, const PlatformMouseEvent&); virtual void paintTrackBackground(GraphicsContext*, Scrollbar*, const IntRect&); - virtual void paintTrackPiece(GraphicsContext*, Scrollbar*, const IntRect&, ScrollbarPart); - virtual void paintButton(GraphicsContext*, Scrollbar*, const IntRect&, ScrollbarPart); - virtual void paintThumb(GraphicsContext*, Scrollbar*, const IntRect&); virtual void paintTickmarks(GraphicsContext*, Scrollbar*, const IntRect&); - private: - IntSize buttonSize(Scrollbar*); - - int getThemeState(Scrollbar*, ScrollbarPart) const; - int getThemeArrowState(Scrollbar*, ScrollbarPart) const; - int getClassicThemeState(Scrollbar*, ScrollbarPart) const; + virtual IntSize buttonSize(Scrollbar*) = 0; }; - } // namespace WebCore #endif diff --git a/WebCore/platform/chromium/ScrollbarThemeChromiumLinux.cpp b/WebCore/platform/chromium/ScrollbarThemeChromiumLinux.cpp index a99d778..6893dea 100644 --- a/WebCore/platform/chromium/ScrollbarThemeChromiumLinux.cpp +++ b/WebCore/platform/chromium/ScrollbarThemeChromiumLinux.cpp @@ -29,9 +29,8 @@ */ #include "config.h" -#include "ScrollbarThemeChromium.h" +#include "ScrollbarThemeChromiumLinux.h" -#include "NotImplemented.h" #include "PlatformContextSkia.h" #include "PlatformMouseEvent.h" #include "Scrollbar.h" @@ -39,14 +38,15 @@ namespace WebCore { -int ScrollbarThemeChromium::scrollbarThickness(ScrollbarControlSize controlSize) +ScrollbarTheme* ScrollbarTheme::nativeTheme() { - return 15; + static ScrollbarThemeChromiumLinux theme; + return &theme; } -bool ScrollbarThemeChromium::invalidateOnMouseEnterExit() +int ScrollbarThemeChromiumLinux::scrollbarThickness(ScrollbarControlSize controlSize) { - return false; + return 15; } static void drawVertLine(SkCanvas* canvas, int x, int y1, int y2, const SkPaint& paint) @@ -73,8 +73,16 @@ static void drawBox(SkCanvas* canvas, const IntRect& rect, const SkPaint& paint) drawVertLine(canvas, rect.x(), rect.y(), bottom, paint); } -void ScrollbarThemeChromium::paintTrackPiece(GraphicsContext* gc, Scrollbar* scrollbar, - const IntRect& rect, ScrollbarPart partType) +IntRect ScrollbarThemeChromium::trackRect(Scrollbar* scrollbar, bool) +{ + IntSize bs = buttonSize(scrollbar); + int thickness = scrollbarThickness(scrollbar->controlSize()); + if (scrollbar->orientation() == HorizontalScrollbar) + return IntRect(scrollbar->x() + bs.width(), scrollbar->y(), scrollbar->width(), thickness); + return IntRect(scrollbar->x(), scrollbar->y() + bs.height(), thickness, scrollbar->height()); +} + +void ScrollbarThemeChromiumLinux::paintTrackPiece(GraphicsContext* gc, Scrollbar* scrollbar, const IntRect& rect, ScrollbarPart partType) { SkCanvas* const canvas = gc->platformContext()->canvas(); SkPaint paint; @@ -88,13 +96,12 @@ void ScrollbarThemeChromium::paintTrackPiece(GraphicsContext* gc, Scrollbar* scr drawBox(canvas, rect, paint); } -void ScrollbarThemeChromium::paintButton(GraphicsContext* gc, Scrollbar* scrollbar, - const IntRect& rect, ScrollbarPart part) +void ScrollbarThemeChromiumLinux::paintButton(GraphicsContext* gc, Scrollbar* scrollbar, const IntRect& rect, ScrollbarPart part) { // We don't use buttons } -void ScrollbarThemeChromium::paintThumb(GraphicsContext* gc, Scrollbar* scrollbar, const IntRect& rect) +void ScrollbarThemeChromiumLinux::paintThumb(GraphicsContext* gc, Scrollbar* scrollbar, const IntRect& rect) { const bool hovered = scrollbar->hoveredPart() == ThumbPart; const int midx = rect.x() + rect.width() / 2; @@ -139,4 +146,16 @@ void ScrollbarThemeChromium::paintThumb(GraphicsContext* gc, Scrollbar* scrollba } } +IntSize ScrollbarThemeChromiumLinux::buttonSize(Scrollbar* scrollbar) +{ + // On Linux, we don't use buttons + return IntSize(0, 0); +} + +int ScrollbarThemeChromiumLinux::minimumThumbLength(Scrollbar* scrollbar) +{ + // This matches Firefox on Linux. + return 2 * scrollbarThickness(scrollbar->controlSize()); +} + } // namespace WebCore diff --git a/WebCore/platform/chromium/ScrollbarThemeChromiumLinux.h b/WebCore/platform/chromium/ScrollbarThemeChromiumLinux.h new file mode 100644 index 0000000..4e08b07 --- /dev/null +++ b/WebCore/platform/chromium/ScrollbarThemeChromiumLinux.h @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2009, 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 ScrollbarThemeChromiumLinux_h +#define ScrollbarThemeChromiumLinux_h + +#include "ScrollbarThemeChromium.h" + +namespace WebCore { + class ScrollbarThemeChromiumLinux : public ScrollbarThemeChromium { + public: + virtual int scrollbarThickness(ScrollbarControlSize); + + protected: + virtual void paintTrackPiece(GraphicsContext*, Scrollbar*, const IntRect&, ScrollbarPart); + virtual void paintButton(GraphicsContext*, Scrollbar*, const IntRect&, ScrollbarPart); + virtual void paintThumb(GraphicsContext*, Scrollbar*, const IntRect&); + + virtual IntSize buttonSize(Scrollbar*); + virtual int minimumThumbLength(Scrollbar*); + }; +} // namespace WebCore + +#endif diff --git a/WebCore/platform/chromium/ScrollbarThemeChromiumWin.cpp b/WebCore/platform/chromium/ScrollbarThemeChromiumWin.cpp index 0337f63..334b767 100644 --- a/WebCore/platform/chromium/ScrollbarThemeChromiumWin.cpp +++ b/WebCore/platform/chromium/ScrollbarThemeChromiumWin.cpp @@ -25,7 +25,7 @@ */ #include "config.h" -#include "ScrollbarThemeChromium.h" +#include "ScrollbarThemeChromiumWin.h" #include <windows.h> #include <vsstyle.h> @@ -39,12 +39,43 @@ namespace WebCore { +ScrollbarTheme* ScrollbarTheme::nativeTheme() +{ + static ScrollbarThemeChromiumWin theme; + return &theme; +} + // The scrollbar size in DumpRenderTree on the Mac - so we can match their // layout results. Entries are for regular, small, and mini scrollbars. // Metrics obtained using [NSScroller scrollerWidthForControlSize:] static const int kMacScrollbarSize[3] = { 15, 11, 15 }; -int ScrollbarThemeChromium::scrollbarThickness(ScrollbarControlSize controlSize) +// 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; + +IntRect ScrollbarThemeChromium::trackRect(Scrollbar* scrollbar, bool) +{ + IntSize bs = buttonSize(scrollbar); + // The buttons at the top and bottom of the scrollbar are square, so the + // thickness of the scrollbar is also their height. + int thickness = scrollbarThickness(scrollbar->controlSize()); + if (scrollbar->orientation() == HorizontalScrollbar) { + // Once the scrollbar becomes smaller than the natural size of the + // two buttons, the track disappears. + if (scrollbar->width() < 2 * thickness) + return IntRect(); + return IntRect(scrollbar->x() + bs.width(), scrollbar->y(), scrollbar->width() - 2 * bs.width(), thickness); + } + if (scrollbar->height() < 2 * thickness) + return IntRect(); + return IntRect(scrollbar->x(), scrollbar->y() + bs.height(), thickness, scrollbar->height() - 2 * bs.height()); +} + +int ScrollbarThemeChromiumWin::scrollbarThickness(ScrollbarControlSize controlSize) { static int thickness; if (!thickness) { @@ -55,12 +86,30 @@ int ScrollbarThemeChromium::scrollbarThickness(ScrollbarControlSize controlSize) return thickness; } -bool ScrollbarThemeChromium::invalidateOnMouseEnterExit() +bool ScrollbarThemeChromiumWin::invalidateOnMouseEnterExit() { return isVistaOrNewer(); } -void ScrollbarThemeChromium::paintTrackPiece(GraphicsContext* gc, Scrollbar* scrollbar, const IntRect& rect, ScrollbarPart partType) +bool ScrollbarThemeChromiumWin::shouldSnapBackToDragOrigin(Scrollbar* 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.pos()); + mousePosition.move(scrollbar->x(), scrollbar->y()); + + // We should snap iff the event is outside our calculated rect. + return !rect.contains(mousePosition); +} + +void ScrollbarThemeChromiumWin::paintTrackPiece(GraphicsContext* gc, Scrollbar* scrollbar, const IntRect& rect, ScrollbarPart partType) { bool horz = scrollbar->orientation() == HorizontalScrollbar; @@ -82,7 +131,7 @@ void ScrollbarThemeChromium::paintTrackPiece(GraphicsContext* gc, Scrollbar* scr alignRect); } -void ScrollbarThemeChromium::paintButton(GraphicsContext* gc, Scrollbar* scrollbar, const IntRect& rect, ScrollbarPart part) +void ScrollbarThemeChromiumWin::paintButton(GraphicsContext* gc, Scrollbar* scrollbar, const IntRect& rect, ScrollbarPart part) { bool horz = scrollbar->orientation() == HorizontalScrollbar; @@ -100,7 +149,7 @@ void ScrollbarThemeChromium::paintButton(GraphicsContext* gc, Scrollbar* scrollb rect); } -void ScrollbarThemeChromium::paintThumb(GraphicsContext* gc, Scrollbar* scrollbar, const IntRect& rect) +void ScrollbarThemeChromiumWin::paintThumb(GraphicsContext* gc, Scrollbar* scrollbar, const IntRect& rect) { bool horz = scrollbar->orientation() == HorizontalScrollbar; @@ -121,7 +170,7 @@ void ScrollbarThemeChromium::paintThumb(GraphicsContext* gc, Scrollbar* scrollba rect); } -int ScrollbarThemeChromium::getThemeState(Scrollbar* scrollbar, ScrollbarPart part) const +int ScrollbarThemeChromiumWin::getThemeState(Scrollbar* scrollbar, ScrollbarPart part) const { // When dragging the thumb, draw thumb pressed and other segments normal // regardless of where the cursor actually is. See also four places in @@ -140,7 +189,7 @@ int ScrollbarThemeChromium::getThemeState(Scrollbar* scrollbar, ScrollbarPart pa return (scrollbar->pressedPart() == part) ? SCRBS_PRESSED : SCRBS_NORMAL; } -int ScrollbarThemeChromium::getThemeArrowState(Scrollbar* scrollbar, ScrollbarPart part) const +int ScrollbarThemeChromiumWin::getThemeArrowState(Scrollbar* scrollbar, ScrollbarPart part) const { // We could take advantage of knowing the values in the state enum to write // some simpler code, but treating the state enum as a black box seems @@ -190,7 +239,7 @@ int ScrollbarThemeChromium::getThemeArrowState(Scrollbar* scrollbar, ScrollbarPa return (scrollbar->pressedPart() == part) ? ABS_DOWNPRESSED : ABS_DOWNNORMAL; } -int ScrollbarThemeChromium::getClassicThemeState(Scrollbar* scrollbar, ScrollbarPart part) const +int ScrollbarThemeChromiumWin::getClassicThemeState(Scrollbar* scrollbar, ScrollbarPart part) const { // When dragging the thumb, draw the buttons normal even when hovered. if (scrollbar->pressedPart() == ThumbPart) @@ -204,4 +253,32 @@ int ScrollbarThemeChromium::getClassicThemeState(Scrollbar* scrollbar, Scrollbar return (scrollbar->pressedPart() == part) ? (DFCS_PUSHED | DFCS_FLAT) : 0; } +IntSize ScrollbarThemeChromiumWin::buttonSize(Scrollbar* scrollbar) +{ + // Our desired rect is essentially thickness by thickness. + + // Our actual rect will shrink to half the available space when we have < 2 + // times thickness pixels left. This allows the scrollbar to scale down + // and function even at tiny sizes. + + int thickness = scrollbarThickness(scrollbar->controlSize()); + + // In layout test mode, we force the button "girth" (i.e., the length of + // the button along the axis of the scrollbar) to be a fixed size. + // FIXME: This is retarded! scrollbarThickness is already fixed in layout + // test mode so that should be enough to result in repeatable results, but + // preserving this hack avoids having to rebaseline pixel tests. + const int kLayoutTestModeGirth = 17; + int girth = ChromiumBridge::layoutTestMode() ? kLayoutTestModeGirth : thickness; + + if (scrollbar->orientation() == HorizontalScrollbar) { + int width = scrollbar->width() < 2 * girth ? scrollbar->width() / 2 : girth; + return IntSize(width, thickness); + } + + int height = scrollbar->height() < 2 * girth ? scrollbar->height() / 2 : girth; + return IntSize(thickness, height); +} + + } // namespace WebCore diff --git a/WebCore/platform/chromium/ScrollbarThemeChromiumWin.h b/WebCore/platform/chromium/ScrollbarThemeChromiumWin.h new file mode 100644 index 0000000..5b4d0ea --- /dev/null +++ b/WebCore/platform/chromium/ScrollbarThemeChromiumWin.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2009, 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 ScrollbarThemeChromiumWin_h +#define ScrollbarThemeChromiumWin_h + +#include "ScrollbarThemeChromium.h" + +namespace WebCore { + class ScrollbarThemeChromiumWin : public ScrollbarThemeChromium { + public: + virtual int scrollbarThickness(ScrollbarControlSize); + virtual bool invalidateOnMouseEnterExit(); + virtual bool shouldSnapBackToDragOrigin(Scrollbar*, const PlatformMouseEvent&); + + protected: + virtual void paintTrackPiece(GraphicsContext*, Scrollbar*, const IntRect&, ScrollbarPart); + virtual void paintButton(GraphicsContext*, Scrollbar*, const IntRect&, ScrollbarPart); + virtual void paintThumb(GraphicsContext*, Scrollbar*, const IntRect&); + virtual IntSize buttonSize(Scrollbar*); + + private: + int getThemeState(Scrollbar*, ScrollbarPart) const; + int getThemeArrowState(Scrollbar*, ScrollbarPart) const; + int getClassicThemeState(Scrollbar*, ScrollbarPart) const; + }; +} // namespace WebCore + +#endif diff --git a/WebCore/platform/chromium/KeyboardCodes.h b/WebCore/platform/chromium/SuddenTerminationChromium.cpp index 10eb0cd..54b8304 100644 --- a/WebCore/platform/chromium/KeyboardCodes.h +++ b/WebCore/platform/chromium/SuddenTerminationChromium.cpp @@ -1,40 +1,48 @@ -/* - * Copyright (c) 2008, 2009, 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 KeyboardCodes_h -#define KeyboardCodes_h - -#if PLATFORM(WIN_OS) -#include "KeyboardCodesWin.h" -#else -#include "KeyboardCodesPosix.h" -#endif - -#endif +/*
+ * Copyright (C) 2009 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 "SuddenTermination.h"
+
+#include "ChromiumBridge.h"
+
+namespace WebCore {
+
+void disableSuddenTermination()
+{
+ ChromiumBridge::suddenTerminationChanged(false);
+}
+
+void enableSuddenTermination()
+{
+ ChromiumBridge::suddenTerminationChanged(true);
+}
+
+} // namespace WebCore
|