diff options
author | Shimeng (Simon) Wang <swang@google.com> | 2010-12-07 17:22:45 -0800 |
---|---|---|
committer | Shimeng (Simon) Wang <swang@google.com> | 2010-12-22 14:15:40 -0800 |
commit | 4576aa36e9a9671459299c7963ac95aa94beaea9 (patch) | |
tree | 3863574e050f168c0126ecb47c83319fab0972d8 /WebCore/platform | |
parent | 55323ac613cc31553107b68603cb627264d22bb0 (diff) | |
download | external_webkit-4576aa36e9a9671459299c7963ac95aa94beaea9.zip external_webkit-4576aa36e9a9671459299c7963ac95aa94beaea9.tar.gz external_webkit-4576aa36e9a9671459299c7963ac95aa94beaea9.tar.bz2 |
Merge WebKit at r73109: Initial merge by git.
Change-Id: I61f1a66d9642e3d8405d3ac6ccab2a53421c75d8
Diffstat (limited to 'WebCore/platform')
152 files changed, 1923 insertions, 912 deletions
diff --git a/WebCore/platform/ColorData.gperf b/WebCore/platform/ColorData.gperf index f83e793..2a72237 100644 --- a/WebCore/platform/ColorData.gperf +++ b/WebCore/platform/ColorData.gperf @@ -1,3 +1,9 @@ +%{ +#include "HashTools.h" +#include <string.h> + +namespace WebCore { +%} %struct-type struct NamedColor; %omit-struct-type @@ -160,3 +166,10 @@ white, 0xffffffff whitesmoke, 0xfff5f5f5 yellow, 0xffffff00 yellowgreen, 0xff9acd32 +%% +const struct NamedColor* findColor(register const char* str, register unsigned int len) +{ + return ColorDataHash::findColorImpl(str, len); +} + +} // namespace WebCore diff --git a/WebCore/platform/ContextMenu.h b/WebCore/platform/ContextMenu.h index a162fe4..5321ed6 100644 --- a/WebCore/platform/ContextMenu.h +++ b/WebCore/platform/ContextMenu.h @@ -88,6 +88,9 @@ namespace WebCore { PlatformMenuDescription m_platformDescription; #else PlatformMenuDescription m_platformDescription; +#if OS(WINCE) + unsigned m_itemCount; +#endif #endif }; diff --git a/WebCore/platform/HashTools.h b/WebCore/platform/HashTools.h new file mode 100644 index 0000000..4fb0904 --- /dev/null +++ b/WebCore/platform/HashTools.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2010 Andras Becsi <abecsi@inf.u-szeged.hu>, University of Szeged + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef HashTools_h +#define HashTools_h + +namespace WebCore { + +struct PubIDInfo { + enum eMode { + eQuirks, + eQuirks3, + eAlmostStandards + }; + + const char* name; + eMode mode_if_no_sysid; + eMode mode_if_sysid; +}; + +struct NamedColor { + const char* name; + unsigned ARGBValue; +}; + +struct Property { + const char* name; + int id; +}; + +struct Value { + const char* name; + int id; +}; + +const PubIDInfo* findDoctypeEntry(register const char* str, register unsigned int len); +const NamedColor* findColor(register const char* str, register unsigned int len); +const Property* findProperty(register const char* str, register unsigned int len); +const Value* findValue(register const char* str, register unsigned int len); + +} // namespace WebCore + +#endif // HashTools_h diff --git a/WebCore/platform/KURL.cpp b/WebCore/platform/KURL.cpp index 3ac5d86..60049df 100644 --- a/WebCore/platform/KURL.cpp +++ b/WebCore/platform/KURL.cpp @@ -1796,7 +1796,7 @@ bool portAllowed(const KURL& url) 6669, // Alternate IRC [Apple addition] invalidPortNumber, // Used to block all invalid port numbers }; - const unsigned short* const blockedPortListEnd = blockedPortList + sizeof(blockedPortList) / sizeof(blockedPortList[0]); + const unsigned short* const blockedPortListEnd = blockedPortList + WTF_ARRAY_LENGTH(blockedPortList); #ifndef NDEBUG // The port list must be sorted for binary_search to work. diff --git a/WebCore/platform/KURLGoogle.cpp b/WebCore/platform/KURLGoogle.cpp index 726bc57..6d63734 100644 --- a/WebCore/platform/KURLGoogle.cpp +++ b/WebCore/platform/KURLGoogle.cpp @@ -893,7 +893,7 @@ bool portAllowed(const KURL& url) 6669, // Alternate IRC [Apple addition] invalidPortNumber, // Used to block all invalid port numbers }; - const unsigned short* const blockedPortListEnd = blockedPortList + sizeof(blockedPortList) / sizeof(blockedPortList[0]); + const unsigned short* const blockedPortListEnd = blockedPortList + WTF_ARRAY_LENGTH(blockedPortList); #ifndef NDEBUG // The port list must be sorted for binary_search to work. diff --git a/WebCore/platform/LocalizedStrings.cpp b/WebCore/platform/LocalizedStrings.cpp index 021205a..8739c74 100644 --- a/WebCore/platform/LocalizedStrings.cpp +++ b/WebCore/platform/LocalizedStrings.cpp @@ -585,6 +585,31 @@ String validationMessageValueMissingText() return platformStrategies()->localizationStrategy()->validationMessageValueMissingText(); } +String validationMessageValueMissingForCheckboxText() +{ + return platformStrategies()->localizationStrategy()->validationMessageValueMissingText(); +} + +String validationMessageValueMissingForFileText() +{ + return platformStrategies()->localizationStrategy()->validationMessageValueMissingText(); +} + +String validationMessageValueMissingForMultipleFileText() +{ + return platformStrategies()->localizationStrategy()->validationMessageValueMissingText(); +} + +String validationMessageValueMissingForRadioText() +{ + return platformStrategies()->localizationStrategy()->validationMessageValueMissingText(); +} + +String validationMessageValueMissingForSelectText() +{ + return platformStrategies()->localizationStrategy()->validationMessageValueMissingText(); +} + String validationMessageTypeMismatchText() { return platformStrategies()->localizationStrategy()->validationMessageTypeMismatchText(); diff --git a/WebCore/platform/LocalizedStrings.h b/WebCore/platform/LocalizedStrings.h index d332e45..b168651 100644 --- a/WebCore/platform/LocalizedStrings.h +++ b/WebCore/platform/LocalizedStrings.h @@ -166,6 +166,11 @@ namespace WebCore { String localizedMediaTimeDescription(float); String validationMessageValueMissingText(); + String validationMessageValueMissingForCheckboxText(); + String validationMessageValueMissingForFileText(); + String validationMessageValueMissingForMultipleFileText(); + String validationMessageValueMissingForRadioText(); + String validationMessageValueMissingForSelectText(); String validationMessageTypeMismatchText(); String validationMessageTypeMismatchForEmailText(); String validationMessageTypeMismatchForMultipleEmailText(); diff --git a/WebCore/platform/MIMETypeRegistry.cpp b/WebCore/platform/MIMETypeRegistry.cpp index 9977fe7..0f4cc0e 100644 --- a/WebCore/platform/MIMETypeRegistry.cpp +++ b/WebCore/platform/MIMETypeRegistry.cpp @@ -143,7 +143,7 @@ static void initializeSupportedImageMIMETypes() "image/x-icon", // ico "image/x-xbitmap" // xbm }; - for (size_t i = 0; i < sizeof(types) / sizeof(types[0]); ++i) { + for (size_t i = 0; i < WTF_ARRAY_LENGTH(types); ++i) { supportedImageMIMETypes->add(types[i]); supportedImageResourceMIMETypes->add(types[i]); } @@ -211,7 +211,7 @@ static void initializeSupportedJavaScriptMIMETypes() "text/jscript", "text/livescript", }; - for (size_t i = 0; i < sizeof(types) / sizeof(types[0]); ++i) + for (size_t i = 0; i < WTF_ARRAY_LENGTH(types); ++i) supportedJavaScriptMIMETypes->add(types[i]); } @@ -246,7 +246,7 @@ static void initializeSupportedNonImageMimeTypes() COMPILE_ASSERT(sizeof(types) / sizeof(types[0]) <= 16, nonimage_mime_types_must_be_less_than_or_equal_to_16); - for (size_t i = 0; i < sizeof(types)/sizeof(types[0]); ++i) + for (size_t i = 0; i < WTF_ARRAY_LENGTH(types); ++i) supportedNonImageMIMETypes->add(types[i]); #if ENABLE(ARCHIVE) // ANDROID extension: disabled to reduce code size diff --git a/WebCore/platform/ScrollView.cpp b/WebCore/platform/ScrollView.cpp index 4a9d479..d6184e9 100644 --- a/WebCore/platform/ScrollView.cpp +++ b/WebCore/platform/ScrollView.cpp @@ -53,6 +53,7 @@ ScrollView::ScrollView() , m_drawPanScrollIcon(false) , m_useFixedLayout(false) , m_paintsEntireContents(false) + , m_delegatesScrolling(false) { platformInit(); } @@ -201,6 +202,11 @@ void ScrollView::setPaintsEntireContents(bool paintsEntireContents) m_paintsEntireContents = paintsEntireContents; } +void ScrollView::setDelegatesScrolling(bool delegatesScrolling) +{ + m_delegatesScrolling = delegatesScrolling; +} + #if !PLATFORM(GTK) IntRect ScrollView::visibleContentRect(bool includeScrollbars) const { @@ -302,9 +308,21 @@ int ScrollView::actualScrollY() const IntPoint ScrollView::maximumScrollPosition() const { - IntSize maximumOffset = contentsSize() - visibleContentRect().size(); + IntPoint maximumOffset(contentsWidth() - visibleWidth() - m_scrollOrigin.x(), contentsHeight() - visibleHeight() - m_scrollOrigin.y()); maximumOffset.clampNegativeToZero(); - return IntPoint(maximumOffset.width(), maximumOffset.height()); + return maximumOffset; +} + +IntPoint ScrollView::minimumScrollPosition() const +{ + return IntPoint(-m_scrollOrigin.x(), -m_scrollOrigin.y()); +} + +IntPoint ScrollView::adjustScrollPositionWithinRange(const IntPoint& scrollPoint) const +{ + IntPoint newScrollPosition = scrollPoint.shrunkTo(maximumScrollPosition()); + newScrollPosition = newScrollPosition.expandedTo(minimumScrollPosition()); + return newScrollPosition; } int ScrollView::scrollSize(ScrollbarOrientation orientation) const @@ -327,9 +345,9 @@ void ScrollView::valueChanged(Scrollbar* scrollbar) IntSize newOffset = m_scrollOffset; if (scrollbar) { if (scrollbar->orientation() == HorizontalScrollbar) - newOffset.setWidth(scrollbar->value()); + newOffset.setWidth(scrollbar->value() - m_scrollOrigin.x()); else if (scrollbar->orientation() == VerticalScrollbar) - newOffset.setHeight(scrollbar->value()); + newOffset.setHeight(scrollbar->value() - m_scrollOrigin.y()); } IntSize scrollDelta = newOffset - m_scrollOffset; @@ -372,8 +390,7 @@ void ScrollView::setScrollPosition(const IntPoint& scrollPoint) } #endif - IntPoint newScrollPosition = scrollPoint.shrunkTo(maximumScrollPosition()); - newScrollPosition.clampNegativeToZero(); + IntPoint newScrollPosition = adjustScrollPositionWithinRange(scrollPoint); if (newScrollPosition == scrollPosition()) return; @@ -464,11 +481,15 @@ void ScrollView::updateScrollbars(const IntSize& desiredOffset) newHasHorizontalScrollbar = false; if (hasHorizontalScrollbar != newHasHorizontalScrollbar) { + if (m_scrollOrigin.y() && !newHasHorizontalScrollbar) + m_scrollOrigin.setY(m_scrollOrigin.y() - m_horizontalScrollbar->height()); setHasHorizontalScrollbar(newHasHorizontalScrollbar); sendContentResizedNotification = true; } if (hasVerticalScrollbar != newHasVerticalScrollbar) { + if (m_scrollOrigin.x() && !newHasVerticalScrollbar) + m_scrollOrigin.setX(m_scrollOrigin.x() - m_verticalScrollbar->width()); setHasVerticalScrollbar(newHasVerticalScrollbar); sendContentResizedNotification = true; } @@ -494,10 +515,10 @@ void ScrollView::updateScrollbars(const IntSize& desiredOffset) return; m_inUpdateScrollbars = true; - IntSize maxScrollPosition(contentsWidth() - visibleWidth(), contentsHeight() - visibleHeight()); - IntSize scroll = desiredOffset.shrunkTo(maxScrollPosition); - scroll.clampNegativeToZero(); - + + IntPoint scrollPoint = adjustScrollPositionWithinRange(IntPoint(desiredOffset.width(), desiredOffset.height())); + IntSize scroll(scrollPoint.x(), scrollPoint.y()); + if (m_horizontalScrollbar) { int clientWidth = visibleWidth(); m_horizontalScrollbar->setEnabled(contentsWidth() > clientWidth); @@ -515,7 +536,7 @@ void ScrollView::updateScrollbars(const IntSize& desiredOffset) m_horizontalScrollbar->setSuppressInvalidation(true); m_horizontalScrollbar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep); m_horizontalScrollbar->setProportion(clientWidth, contentsWidth()); - m_horizontalScrollbar->setValue(scroll.width(), Scrollbar::NotFromScrollAnimator); + m_horizontalScrollbar->setValue(scroll.width() + m_scrollOrigin.x(), Scrollbar::NotFromScrollAnimator); if (m_scrollbarsSuppressed) m_horizontalScrollbar->setSuppressInvalidation(false); } @@ -537,7 +558,7 @@ void ScrollView::updateScrollbars(const IntSize& desiredOffset) m_verticalScrollbar->setSuppressInvalidation(true); m_verticalScrollbar->setSteps(Scrollbar::pixelsPerLineStep(), pageStep); m_verticalScrollbar->setProportion(clientHeight, contentsHeight()); - m_verticalScrollbar->setValue(scroll.height(), Scrollbar::NotFromScrollAnimator); + m_verticalScrollbar->setValue(scroll.height() + m_scrollOrigin.y(), Scrollbar::NotFromScrollAnimator); if (m_scrollbarsSuppressed) m_verticalScrollbar->setSuppressInvalidation(false); } @@ -1042,7 +1063,24 @@ void ScrollView::removePanScrollIcon() hostWindow()->invalidateContentsAndWindow(IntRect(m_panScrollIconPoint, IntSize(panIconSizeLength, panIconSizeLength)), true /*immediate*/); } -#if !PLATFORM(WX) && !PLATFORM(GTK) && !PLATFORM(QT) && !PLATFORM(EFL) +void ScrollView::setScrollOrigin(const IntPoint& origin, bool updatePosition) +{ + if (m_scrollOrigin == origin) + return; + + m_scrollOrigin = origin; + + if (platformWidget()) { + platformSetScrollOrigin(origin, updatePosition); + return; + } + + // Update if the scroll origin changes, since our position will be different if the content size did not change. + if (updatePosition) + updateScrollbars(scrollOffset()); +} + +#if !PLATFORM(WX) && !PLATFORM(GTK) && !PLATFORM(EFL) void ScrollView::platformInit() { @@ -1072,6 +1110,10 @@ void ScrollView::platformSetScrollbarsSuppressed(bool) { } +void ScrollView::platformSetScrollOrigin(const IntPoint&, bool updatePosition) +{ +} + #endif #if !PLATFORM(MAC) && !PLATFORM(WX) diff --git a/WebCore/platform/ScrollView.h b/WebCore/platform/ScrollView.h index d6b08b2..e9c7feb 100644 --- a/WebCore/platform/ScrollView.h +++ b/WebCore/platform/ScrollView.h @@ -104,14 +104,19 @@ public: virtual void setCanHaveScrollbars(bool); bool canHaveScrollbars() const { return horizontalScrollbarMode() != ScrollbarAlwaysOff || verticalScrollbarMode() != ScrollbarAlwaysOff; } - virtual bool delegatesScrolling() { return false; } - virtual bool avoidScrollbarCreation() { return false; } + virtual bool avoidScrollbarCreation() const { return false; } // By default you only receive paint events for the area that is visible. In the case of using a // tiled backing store, this function can be set, so that the view paints the entire contents. bool paintsEntireContents() const { return m_paintsEntireContents; } void setPaintsEntireContents(bool); + // By default programmatic scrolling is handled by WebCore and not by the UI application. + // In the case of using a tiled backing store, this mode can be set, so that the scroll requests + // are delegated to the UI application. + bool delegatesScrolling() const { return m_delegatesScrolling; } + void setDelegatesScrolling(bool); + // Overridden by FrameView to create custom CSS scrollbars if applicable. virtual PassRefPtr<Scrollbar> createScrollbar(ScrollbarOrientation); @@ -162,6 +167,9 @@ public: IntPoint scrollPosition() const { return visibleContentRect().location(); } IntSize scrollOffset() const { return visibleContentRect().location() - IntPoint(); } // Gets the scrolled position as an IntSize. Convenient for adding to other sizes. IntPoint maximumScrollPosition() const; // The maximum position we can be scrolled to. + IntPoint minimumScrollPosition() const; // The minimum position we can be scrolled to. + // Adjust the passed in scroll position to keep it between the minimum and maximum positions. + IntPoint adjustScrollPositionWithinRange(const IntPoint&) const; int scrollX() const { return scrollPosition().x(); } int scrollY() const { return scrollPosition().y(); } @@ -281,6 +289,9 @@ protected: // Scroll the content by invalidating everything. virtual void scrollContentsSlowPath(const IntRect& updateRect); + void setScrollOrigin(const IntPoint&, bool updatePosition); + IntPoint scrollOrigin() { return m_scrollOrigin; } + private: RefPtr<Scrollbar> m_horizontalScrollbar; RefPtr<Scrollbar> m_verticalScrollbar; @@ -314,6 +325,20 @@ private: bool m_useFixedLayout; bool m_paintsEntireContents; + bool m_delegatesScrolling; + + // There are 8 possible combinations of writing mode and direction. Scroll origin will be non-zero in the x or y axis + // if there is any reversed direction or writing-mode. The combinations are: + // writing-mode / direction scrollOrigin.x() set scrollOrigin.y() set + // horizontal-tb / ltr NO NO + // horizontal-tb / rtl YES NO + // horizontal-bt / ltr NO YES + // horizontal-bt / rtl YES YES + // vertical-lr / ltr NO NO + // vertical-lr / rtl NO YES + // vertical-rl / ltr YES NO + // vertical-rl / rtl YES YES + IntPoint m_scrollOrigin; void init(); void destroy(); @@ -342,6 +367,8 @@ private: void platformSetScrollbarsSuppressed(bool repaintOnUnsuppress); void platformRepaintContentRectangle(const IntRect&, bool now); bool platformIsOffscreen() const; + + void platformSetScrollOrigin(const IntPoint&, bool updatePosition); #if PLATFORM(ANDROID) int platformActualWidth() const; diff --git a/WebCore/platform/UUID.cpp b/WebCore/platform/UUID.cpp index eb721e0..faad008 100644 --- a/WebCore/platform/UUID.cpp +++ b/WebCore/platform/UUID.cpp @@ -95,7 +95,7 @@ String createCanonicalUUIDString() return canonicalUuidStr; #elif OS(LINUX) && PLATFORM(CHROMIUM) unsigned randomData[4]; - for (size_t i = 0; i < sizeof(randomData) / sizeof(randomData[0]); ++i) + for (size_t i = 0; i < WTF_ARRAY_LENGTH(randomData); ++i) randomData[i] = static_cast<unsigned>(randomNumber() * (std::numeric_limits<unsigned>::max() + 1.0)); // Format as Version 4 UUID. diff --git a/WebCore/platform/android/LocalizedStringsAndroid.cpp b/WebCore/platform/android/LocalizedStringsAndroid.cpp index 9cb6242..18117f9 100644 --- a/WebCore/platform/android/LocalizedStringsAndroid.cpp +++ b/WebCore/platform/android/LocalizedStringsAndroid.cpp @@ -404,6 +404,36 @@ String validationMessageValueMissingText() return String(); } +String validationMessageValueMissingForCheckboxText() +{ + notImplemented(); + return validationMessageValueMissingText(); +} + +String validationMessageValueMissingForFileText() +{ + notImplemented(); + return validationMessageValueMissingText(); +} + +String validationMessageValueMissingForMultipleFileText() +{ + notImplemented(); + return validationMessageValueMissingText(); +} + +String validationMessageValueMissingForRadioText() +{ + notImplemented(); + return validationMessageValueMissingText(); +} + +String validationMessageValueMissingForSelectText() +{ + notImplemented(); + return validationMessageValueMissingText(); +} + String validationMessageTypeMismatchText() { notImplemented(); diff --git a/WebCore/platform/android/PlatformBridge.h b/WebCore/platform/android/PlatformBridge.h index 2d6451a..f518fe1 100644 --- a/WebCore/platform/android/PlatformBridge.h +++ b/WebCore/platform/android/PlatformBridge.h @@ -82,9 +82,13 @@ class NPObject; namespace WebCore { +<<<<<<< HEAD class Document; class FrameView; class Node; +======= +class ScrollView; +>>>>>>> webkit.org at r73109 class Widget; // An interface to the embedding layer, which has the ability to answer @@ -108,6 +112,7 @@ public: static bool cookiesEnabled(const Document*); // Plugin static NPObject* pluginScriptableObject(Widget*); +<<<<<<< HEAD // Popups static bool popupsAllowed(NPP); @@ -136,6 +141,10 @@ public: static void updateViewport(FrameView*); static void updateTextfield(FrameView*, Node*, bool changeToPassword, const WTF::String& text); +======= + + static void setScrollPosition(ScrollView*, int x, int y); +>>>>>>> webkit.org at r73109 // Language static String computeDefaultLanguage(); diff --git a/WebCore/platform/android/ScrollViewAndroid.cpp b/WebCore/platform/android/ScrollViewAndroid.cpp index fcd52d6..f54e5ea 100644 --- a/WebCore/platform/android/ScrollViewAndroid.cpp +++ b/WebCore/platform/android/ScrollViewAndroid.cpp @@ -100,7 +100,7 @@ void ScrollView::platformSetScrollPosition(const WebCore::IntPoint& pt) { if (parent()) // don't attempt to scroll subframes; they're fully visible return; - android::WebViewCore::getWebViewCore(this)->scrollTo(pt.x(), pt.y()); + PlatformBridge::setScrollPosition(this, pt.x(), pt.y()); } void ScrollView::platformSetScrollbarModes() diff --git a/WebCore/platform/audio/Cone.cpp b/WebCore/platform/audio/Cone.cpp index 91813ab..843b3cc 100644 --- a/WebCore/platform/audio/Cone.cpp +++ b/WebCore/platform/audio/Cone.cpp @@ -41,20 +41,20 @@ ConeEffect::ConeEffect() { } -double ConeEffect::gain(Vector3 sourcePosition, Vector3 sourceOrientation, Vector3 listenerPosition) +double ConeEffect::gain(FloatPoint3D sourcePosition, FloatPoint3D sourceOrientation, FloatPoint3D listenerPosition) { if (sourceOrientation.isZero() || ((m_innerAngle == 360.0) && (m_outerAngle == 360.0))) return 1.0; // no cone specified - unity gain // Normalized source-listener vector - Vector3 sourceToListener = listenerPosition - sourcePosition; + FloatPoint3D sourceToListener = listenerPosition - sourcePosition; sourceToListener.normalize(); - Vector3 normalizedSourceOrientation = sourceOrientation; + FloatPoint3D normalizedSourceOrientation = sourceOrientation; normalizedSourceOrientation.normalize(); // Angle between the source orientation vector and the source-listener vector - double dotProduct = dot(sourceToListener, normalizedSourceOrientation); + double dotProduct = sourceToListener.dot(normalizedSourceOrientation); double angle = 180.0 * acos(dotProduct) / M_PI; double absAngle = fabs(angle); diff --git a/WebCore/platform/audio/Cone.h b/WebCore/platform/audio/Cone.h index 9936f28..f566018 100644 --- a/WebCore/platform/audio/Cone.h +++ b/WebCore/platform/audio/Cone.h @@ -29,7 +29,7 @@ #ifndef Cone_h #define Cone_h -#include <wtf/Vector3.h> +#include "FloatPoint3D.h" namespace WebCore { @@ -40,7 +40,7 @@ public: ConeEffect(); // Returns scalar gain for the given source/listener positions/orientations - double gain(Vector3 sourcePosition, Vector3 sourceOrientation, Vector3 listenerPosition); + double gain(FloatPoint3D sourcePosition, FloatPoint3D sourceOrientation, FloatPoint3D listenerPosition); // Angles in degrees void setInnerAngle(double innerAngle) { m_innerAngle = innerAngle; } diff --git a/WebCore/platform/brew/LocalizedStringsBrew.cpp b/WebCore/platform/brew/LocalizedStringsBrew.cpp index b044623..08e2002 100644 --- a/WebCore/platform/brew/LocalizedStringsBrew.cpp +++ b/WebCore/platform/brew/LocalizedStringsBrew.cpp @@ -402,6 +402,36 @@ String validationMessageValueMissingText() return String(); } +String validationMessageValueMissingForCheckboxText() +{ + notImplemented(); + return validationMessageValueMissingText(); +} + +String validationMessageValueMissingForFileText() +{ + notImplemented(); + return validationMessageValueMissingText(); +} + +String validationMessageValueMissingForMultipleFileText() +{ + notImplemented(); + return validationMessageValueMissingText(); +} + +String validationMessageValueMissingForRadioText() +{ + notImplemented(); + return validationMessageValueMissingText(); +} + +String validationMessageValueMissingForSelectText() +{ + notImplemented(); + return validationMessageValueMissingText(); +} + String validationMessageTypeMismatchText() { notImplemented(); diff --git a/WebCore/platform/chromium/ChromiumBridge.h b/WebCore/platform/chromium/ChromiumBridge.h index fff7f69..8ca6434 100644 --- a/WebCore/platform/chromium/ChromiumBridge.h +++ b/WebCore/platform/chromium/ChromiumBridge.h @@ -31,6 +31,10 @@ #ifndef ChromiumBridge_h #define ChromiumBridge_h +#if ENABLE(WEB_AUDIO) +#include "AudioBus.h" +#endif + #include "FileSystem.h" #include "ImageSource.h" #include "LinkHash.h" @@ -212,6 +216,11 @@ namespace WebCore { // Resources ---------------------------------------------------------- static PassRefPtr<Image> loadPlatformImageResource(const char* name); +#if ENABLE(WEB_AUDIO) + static PassOwnPtr<AudioBus> loadPlatformAudioResource(const char* name, double sampleRate); + static PassOwnPtr<AudioBus> decodeAudioFileData(const char* data, size_t size, double sampleRate); +#endif + // Sandbox ------------------------------------------------------------ static bool sandboxEnabled(); diff --git a/WebCore/platform/efl/LocalizedStringsEfl.cpp b/WebCore/platform/efl/LocalizedStringsEfl.cpp index 2935983..85dcdcb 100644 --- a/WebCore/platform/efl/LocalizedStringsEfl.cpp +++ b/WebCore/platform/efl/LocalizedStringsEfl.cpp @@ -480,6 +480,36 @@ String validationMessageValueMissingText() return String::fromUTF8("value missing"); } +String validationMessageValueMissingForCheckboxText() +{ + notImplemented(); + return validationMessageValueMissingText(); +} + +String validationMessageValueMissingForFileText() +{ + notImplemented(); + return validationMessageValueMissingText(); +} + +String validationMessageValueMissingForMultipleFileText() +{ + notImplemented(); + return validationMessageValueMissingText(); +} + +String validationMessageValueMissingForRadioText() +{ + notImplemented(); + return validationMessageValueMissingText(); +} + +String validationMessageValueMissingForSelectText() +{ + notImplemented(); + return validationMessageValueMissingText(); +} + String missingPluginText() { return String::fromUTF8("missing plugin"); diff --git a/WebCore/platform/efl/RenderThemeEfl.cpp b/WebCore/platform/efl/RenderThemeEfl.cpp index 6076747..7cf635f 100644 --- a/WebCore/platform/efl/RenderThemeEfl.cpp +++ b/WebCore/platform/efl/RenderThemeEfl.cpp @@ -247,11 +247,10 @@ void RenderThemeEfl::applyEdjeStateFromForm(Evas_Object* o, ControlStates states "window-inactive", "indeterminate" }; - size_t i, last = sizeof(signals) / sizeof(signals[0]); edje_object_signal_emit(o, "reset", ""); - for (i = 0; i < last; i++) { + for (size_t i = 0; i < WTF_ARRAY_LENGTH(signals); ++i) { if (states & (1 << i)) edje_object_signal_emit(o, signals[i], ""); } diff --git a/WebCore/platform/graphics/ContextShadow.h b/WebCore/platform/graphics/ContextShadow.h index 2b779f7..fa778af 100644 --- a/WebCore/platform/graphics/ContextShadow.h +++ b/WebCore/platform/graphics/ContextShadow.h @@ -120,6 +120,9 @@ private: PlatformImage m_layerImage; PlatformContext m_layerContext; + // Used for reference when canvas scale(x,y) was called. + FloatRect m_unscaledLayerRect; + void blurLayerImage(unsigned char*, const IntSize& imageSize, int stride); void calculateLayerBoundingRect(const FloatRect& layerArea, const IntRect& clipRect); #if PLATFORM(CAIRO) diff --git a/WebCore/platform/graphics/FloatPoint3D.h b/WebCore/platform/graphics/FloatPoint3D.h index b6cbaa8..ba0ee9d 100644 --- a/WebCore/platform/graphics/FloatPoint3D.h +++ b/WebCore/platform/graphics/FloatPoint3D.h @@ -84,6 +84,11 @@ public: m_z *= sz; } + bool isZero() const + { + return !m_x && !m_y && !m_z; + } + void normalize(); float dot(const FloatPoint3D& a) const @@ -115,6 +120,8 @@ public: float lengthSquared() const { return this->dot(*this); } float length() const { return sqrtf(lengthSquared()); } + + float distanceTo(const FloatPoint3D& a) const; private: float m_x; @@ -160,6 +167,21 @@ inline float operator*(const FloatPoint3D& a, const FloatPoint3D& b) return a.dot(b); } +inline FloatPoint3D operator*(float k, const FloatPoint3D& v) +{ + return FloatPoint3D(k * v.x(), k * v.y(), k * v.z()); +} + +inline FloatPoint3D operator*(const FloatPoint3D& v, float k) +{ + return FloatPoint3D(k * v.x(), k * v.y(), k * v.z()); +} + +inline float FloatPoint3D::distanceTo(const FloatPoint3D& a) const +{ + return (*this - a).length(); +} + } // namespace WebCore #endif // FloatPoint3D_h diff --git a/WebCore/platform/graphics/GraphicsContext.h b/WebCore/platform/graphics/GraphicsContext.h index e8ba0e4..76e897e 100644 --- a/WebCore/platform/graphics/GraphicsContext.h +++ b/WebCore/platform/graphics/GraphicsContext.h @@ -135,7 +135,6 @@ namespace WebCore { class GraphicsContextPrivate; class ImageBuffer; class KURL; - class Path; class Pattern; class SharedGraphicsContext3D; class TextRun; @@ -204,6 +203,7 @@ namespace WebCore { #if PLATFORM(CG) void applyStrokePattern(); void applyFillPattern(); + void drawPath(const Path&); #endif #if PLATFORM(ANDROID) @@ -245,9 +245,8 @@ namespace WebCore { void drawEllipse(const IntRect&); void drawConvexPolygon(size_t numPoints, const FloatPoint*, bool shouldAntialias = false); - void drawPath(); - void fillPath(); - void strokePath(); + void fillPath(const Path&); + void strokePath(const Path&); // Arc drawing (used by border-radius in CSS) just supports stroking at the moment. void strokeArc(const IntRect&, int startAngle, int angleSpan); @@ -288,7 +287,7 @@ namespace WebCore { void addInnerRoundedRectClip(const IntRect&, int thickness); void clipOut(const IntRect&); void clipOutRoundedRect(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight); - void clipPath(WindRule); + void clipPath(const Path&, WindRule); void clipConvexPolygon(size_t numPoints, const FloatPoint*, bool antialias = true); void clipToImageBuffer(ImageBuffer*, const FloatRect&); @@ -323,7 +322,7 @@ namespace WebCore { void clearShadow(); void drawFocusRing(const Vector<IntRect>&, int width, int offset, const Color&); - void drawFocusRing(const Vector<Path>&, int width, int offset, const Color&); + void drawFocusRing(const Path&, int width, int offset, const Color&); void setLineCap(LineCap); void setLineDash(const DashArray&, float dashOffset); @@ -337,8 +336,10 @@ namespace WebCore { void setCompositeOperation(CompositeOperator); +#if PLATFORM(SKIA) || PLATFORM(WX) || PLATFORM(OPENVG) || OS(WINCE) void beginPath(); void addPath(const Path&); +#endif void clip(const Path&); @@ -428,7 +429,6 @@ namespace WebCore { #if PLATFORM(QT) bool inTransparencyLayer() const; - PlatformPath* currentPath(); void pushTransparencyLayerInternal(const QRect &rect, qreal opacity, QPixmap& alphaMask); void takeOwnershipOfPlatformContext(); static QPainter::CompositionMode toQtCompositionMode(CompositeOperator op); diff --git a/WebCore/platform/graphics/GraphicsContextPrivate.h b/WebCore/platform/graphics/GraphicsContextPrivate.h index 985cad9..696932e 100644 --- a/WebCore/platform/graphics/GraphicsContextPrivate.h +++ b/WebCore/platform/graphics/GraphicsContextPrivate.h @@ -29,7 +29,6 @@ #include "Gradient.h" #include "GraphicsContext.h" #include "Pattern.h" -#include "TransformationMatrix.h" namespace WebCore { @@ -79,8 +78,6 @@ namespace WebCore { bool shadowsIgnoreTransforms; #if PLATFORM(CAIRO) float globalAlpha; -#elif PLATFORM(QT) - TransformationMatrix pathTransform; #endif }; diff --git a/WebCore/platform/graphics/GraphicsTypes.cpp b/WebCore/platform/graphics/GraphicsTypes.cpp index 761bf40..dd52ba9 100644 --- a/WebCore/platform/graphics/GraphicsTypes.cpp +++ b/WebCore/platform/graphics/GraphicsTypes.cpp @@ -47,7 +47,7 @@ static const char* const compositeOperatorNames[] = { "highlight", "lighter" }; -const int numCompositeOperatorNames = sizeof(compositeOperatorNames) / sizeof(compositeOperatorNames[0]); +const int numCompositeOperatorNames = WTF_ARRAY_LENGTH(compositeOperatorNames); bool parseCompositeOperator(const String& s, CompositeOperator& op) { diff --git a/WebCore/platform/graphics/MediaPlayer.cpp b/WebCore/platform/graphics/MediaPlayer.cpp index dc743bf..c9deb4c 100644 --- a/WebCore/platform/graphics/MediaPlayer.cpp +++ b/WebCore/platform/graphics/MediaPlayer.cpp @@ -274,6 +274,7 @@ MediaPlayer::MediaPlayer(MediaPlayerClient* client) MediaPlayer::~MediaPlayer() { + m_mediaPlayerClient = 0; } void MediaPlayer::load(const String& url, const ContentType& contentType) diff --git a/WebCore/platform/graphics/Path.h b/WebCore/platform/graphics/Path.h index 86ba831..ba25dc2 100644 --- a/WebCore/platform/graphics/Path.h +++ b/WebCore/platform/graphics/Path.h @@ -28,7 +28,6 @@ #ifndef Path_h #define Path_h -#include <algorithm> #include <wtf/FastAllocBase.h> #include <wtf/Forward.h> @@ -109,8 +108,6 @@ namespace WebCore { Path(const Path&); Path& operator=(const Path&); - void swap(Path& other) { std::swap(m_path, other.m_path); } - bool contains(const FloatPoint&, WindRule rule = RULE_NONZERO) const; bool strokeContains(StrokeStyleApplier*, const FloatPoint&) const; FloatRect boundingRect() const; diff --git a/WebCore/platform/graphics/SimpleFontData.h b/WebCore/platform/graphics/SimpleFontData.h index 432a164..ea053cd 100644 --- a/WebCore/platform/graphics/SimpleFontData.h +++ b/WebCore/platform/graphics/SimpleFontData.h @@ -106,6 +106,7 @@ public: #endif Glyph spaceGlyph() const { return m_spaceGlyph; } + bool isZeroWidthSpaceGlyph(Glyph glyph) const { return glyph == m_zeroWidthSpaceGlyph && glyph; } virtual const SimpleFontData* fontDataForCharacter(UChar32) const; virtual bool containsCharacters(const UChar*, int length) const; @@ -267,7 +268,7 @@ private: #if !PLATFORM(QT) ALWAYS_INLINE FloatRect SimpleFontData::boundsForGlyph(Glyph glyph) const { - if (glyph == m_zeroWidthSpaceGlyph && glyph) + if (isZeroWidthSpaceGlyph(glyph)) return FloatRect(); FloatRect bounds; @@ -286,7 +287,7 @@ ALWAYS_INLINE FloatRect SimpleFontData::boundsForGlyph(Glyph glyph) const ALWAYS_INLINE float SimpleFontData::widthForGlyph(Glyph glyph) const { - if (glyph == m_zeroWidthSpaceGlyph && glyph) + if (isZeroWidthSpaceGlyph(glyph)) return 0; float width = m_glyphToWidthMap.metricsForGlyph(glyph); diff --git a/WebCore/platform/graphics/TextRun.h b/WebCore/platform/graphics/TextRun.h index 79b6cb3..dce5535 100644 --- a/WebCore/platform/graphics/TextRun.h +++ b/WebCore/platform/graphics/TextRun.h @@ -117,7 +117,10 @@ private: const UChar* m_characters; int m_len; - int m_xpos; + // m_xpos is the x position relative to the left start of the text line, not relative to the left + // start of the containing block. In the case of right alignment or center alignment, left start of + // the text line is not the same as left start of the containing block. + int m_xpos; int m_padding; #if ENABLE(SVG) float m_horizontalGlyphStretch; diff --git a/WebCore/platform/graphics/WOFFFileFormat.cpp b/WebCore/platform/graphics/WOFFFileFormat.cpp index 5391f30..b1400ba 100644 --- a/WebCore/platform/graphics/WOFFFileFormat.cpp +++ b/WebCore/platform/graphics/WOFFFileFormat.cpp @@ -36,11 +36,11 @@ #endif #if PLATFORM(BREWMP) -#include <AEEStdLib.h> -#define htonl(x) HTONL(x) -#define htons(x) HTONS(x) -#define ntohl(x) NTOHL(x) -#define ntohs(x) NTOHS(x) +#include <AEEstd.h> +#define htonl(x) std_htonl(x) +#define htons(x) std_htons(x) +#define ntohl(x) std_ntohl(x) +#define ntohs(x) std_ntohs(x) #endif #if PLATFORM(WIN) diff --git a/WebCore/platform/graphics/cairo/ContextShadowCairo.cpp b/WebCore/platform/graphics/cairo/ContextShadowCairo.cpp index 8299b6a..699edf7 100644 --- a/WebCore/platform/graphics/cairo/ContextShadowCairo.cpp +++ b/WebCore/platform/graphics/cairo/ContextShadowCairo.cpp @@ -84,6 +84,8 @@ static cairo_surface_t* getScratchBuffer(const IntSize& size) PlatformContext ContextShadow::beginShadowLayer(PlatformContext context, const FloatRect& layerArea) { + m_unscaledLayerRect = layerArea; + double x1, x2, y1, y2; cairo_clip_extents(context, &x1, &y1, &x2, &y2); calculateLayerBoundingRect(layerArea, IntRect(x1, y1, x2 - x1, y2 - y1)); @@ -120,7 +122,19 @@ void ContextShadow::endShadowLayer(cairo_t* cr) cairo_save(cr); setSourceRGBAFromColor(cr, m_color); - cairo_mask_surface(cr, m_layerImage, m_layerRect.x(), m_layerRect.y()); + + cairo_matrix_t transform; + cairo_get_matrix(cr, &transform); + double x = m_layerRect.x(); + double y = m_layerRect.y(); + + double xScale = sqrt(transform.xx * transform.xx + transform.yx * transform.yx); + double yScale = sqrt(transform.xy * transform.xy + transform.yy * transform.yy); + if (xScale != 1 || yScale != 1) { + x = m_unscaledLayerRect.x() + m_offset.width() / transform.xx - m_blurDistance; + y = m_unscaledLayerRect.y() + m_offset.height() / transform.yy - m_blurDistance; + } + cairo_mask_surface(cr, m_layerImage, x, y); cairo_restore(cr); // Schedule a purge of the scratch buffer. We do not need to destroy the surface. diff --git a/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp b/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp index 755adff..9c2ff82 100644 --- a/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp +++ b/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp @@ -531,44 +531,26 @@ void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* poin cairo_set_fill_rule(cr, savedFillRule); } -void GraphicsContext::fillPath() +void GraphicsContext::fillPath(const Path& path) { if (paintingDisabled()) return; cairo_t* cr = m_data->cr; - - setPathOnCairoContext(cr, m_data->m_pendingPath.context()); + setPathOnCairoContext(cr, path.platformPath()->context()); fillCurrentCairoPath(this, m_common, cr); } -void GraphicsContext::strokePath() +void GraphicsContext::strokePath(const Path& path) { if (paintingDisabled()) return; cairo_t* cr = m_data->cr; - setPathOnCairoContext(cr, m_data->m_pendingPath.context()); + setPathOnCairoContext(cr, path.platformPath()->context()); strokeCurrentCairoPath(this, m_common, cr); } -void GraphicsContext::drawPath() -{ - if (paintingDisabled()) - return; - - cairo_t* cr = m_data->cr; - - setPathOnCairoContext(cr, m_data->m_pendingPath.context()); - - cairo_set_fill_rule(cr, fillRule() == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING); - drawPathShadow(this, m_common, FillAndStroke); - - setPlatformFill(this, cr, m_common); - setPlatformStroke(this, cr, m_common); - cairo_new_path(cr); -} - void GraphicsContext::fillRect(const FloatRect& rect) { if (paintingDisabled()) @@ -607,17 +589,18 @@ void GraphicsContext::clip(const FloatRect& rect) m_data->clip(rect); } -void GraphicsContext::clipPath(WindRule clipRule) +void GraphicsContext::clipPath(const Path& path, WindRule clipRule) { if (paintingDisabled()) return; cairo_t* cr = m_data->cr; + setPathOnCairoContext(cr, path.platformPath()->context()); cairo_set_fill_rule(cr, clipRule == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING); cairo_clip(cr); } -void GraphicsContext::drawFocusRing(const Vector<Path>& paths, int width, int offset, const Color& color) +void GraphicsContext::drawFocusRing(const Path& path, int width, int offset, const Color& color) { // FIXME: implement } @@ -994,25 +977,6 @@ void GraphicsContext::setCompositeOperation(CompositeOperator op) cairo_set_operator(m_data->cr, toCairoOperator(op)); } -void GraphicsContext::beginPath() -{ - if (paintingDisabled()) - return; - - cairo_new_path(m_data->m_pendingPath.context()); -} - -void GraphicsContext::addPath(const Path& path) -{ - if (paintingDisabled()) - return; - - cairo_matrix_t currentMatrix; - cairo_get_matrix(m_data->cr, ¤tMatrix); - cairo_set_matrix(m_data->m_pendingPath.context(), ¤tMatrix); - appendWebCorePathToCairoContext(m_data->m_pendingPath.context(), path); -} - void GraphicsContext::clip(const Path& path) { if (paintingDisabled()) diff --git a/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h b/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h index 527cb72..494b40d 100644 --- a/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h +++ b/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h @@ -27,7 +27,6 @@ #include "GraphicsContext.h" -#include "CairoPath.h" #include "ContextShadow.h" #include <cairo.h> #include <math.h> @@ -97,7 +96,6 @@ public: cairo_t* cr; Vector<float> layers; - CairoPath m_pendingPath; ContextShadow shadow; Vector<ContextShadow> shadowStack; diff --git a/WebCore/platform/graphics/cg/GraphicsContextCG.cpp b/WebCore/platform/graphics/cg/GraphicsContextCG.cpp index 8d72b85..2eb929e 100644 --- a/WebCore/platform/graphics/cg/GraphicsContextCG.cpp +++ b/WebCore/platform/graphics/cg/GraphicsContextCG.cpp @@ -299,21 +299,12 @@ void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2) // This method is only used to draw the little circles used in lists. void GraphicsContext::drawEllipse(const IntRect& rect) { - // FIXME: CG added CGContextAddEllipseinRect in Tiger, so we should be able to quite easily draw an ellipse. - // This code can only handle circles, not ellipses. But khtml only - // uses it for circles. - ASSERT(rect.width() == rect.height()); - if (paintingDisabled()) return; - CGContextRef context = platformContext(); - CGContextBeginPath(context); - float r = (float)rect.width() / 2; - CGContextAddArc(context, rect.x() + r, rect.y() + r, r, 0.0f, 2.0f * piFloat, 0); - CGContextClosePath(context); - - drawPath(); + Path path; + path.addEllipse(rect); + drawPath(path); } @@ -405,21 +396,22 @@ void GraphicsContext::strokeArc(const IntRect& rect, int startAngle, int angleSp CGContextRestoreGState(context); } -static void addConvexPolygonToContext(CGContextRef context, size_t numPoints, const FloatPoint* points) +static void addConvexPolygonToPath(Path& path, size_t numberOfPoints, const FloatPoint* points) { - CGContextBeginPath(context); - CGContextMoveToPoint(context, points[0].x(), points[0].y()); - for (size_t i = 1; i < numPoints; i++) - CGContextAddLineToPoint(context, points[i].x(), points[i].y()); - CGContextClosePath(context); + ASSERT(numberOfPoints > 0); + + path.moveTo(points[0]); + for (size_t i = 1; i < numberOfPoints; ++i) + path.addLineTo(points[i]); + path.closeSubpath(); } -void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points, bool antialiased) +void GraphicsContext::drawConvexPolygon(size_t numberOfPoints, const FloatPoint* points, bool antialiased) { if (paintingDisabled()) return; - if (npoints <= 1) + if (numberOfPoints <= 1) return; CGContextRef context = platformContext(); @@ -427,28 +419,30 @@ void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points if (antialiased != shouldAntialias()) CGContextSetShouldAntialias(context, antialiased); - addConvexPolygonToContext(context, npoints, points); - drawPath(); + Path path; + addConvexPolygonToPath(path, numberOfPoints, points); + drawPath(path); if (antialiased != shouldAntialias()) CGContextSetShouldAntialias(context, shouldAntialias()); } -void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* points, bool antialias) +void GraphicsContext::clipConvexPolygon(size_t numberOfPoints, const FloatPoint* points, bool antialias) { if (paintingDisabled()) return; - if (numPoints <= 1) + if (numberOfPoints <= 1) return; CGContextRef context = platformContext(); if (antialias != shouldAntialias()) CGContextSetShouldAntialias(context, antialias); - - addConvexPolygonToContext(context, numPoints, points); - clipPath(RULE_NONZERO); + + Path path; + addConvexPolygonToPath(path, numberOfPoints, points); + clipPath(path, RULE_NONZERO); if (antialias != shouldAntialias()) CGContextSetShouldAntialias(context, shouldAntialias()); @@ -511,7 +505,7 @@ static inline bool calculateDrawingMode(const GraphicsContextState& state, CGPat return shouldFill || shouldStroke; } -void GraphicsContext::drawPath() +void GraphicsContext::drawPath(const Path& path) { if (paintingDisabled()) return; @@ -521,11 +515,15 @@ void GraphicsContext::drawPath() if (state.fillGradient || state.strokeGradient) { // We don't have any optimized way to fill & stroke a path using gradients - fillPath(); - strokePath(); + // FIXME: Be smarter about this. + fillPath(path); + strokePath(path); return; } + CGContextBeginPath(context); + CGContextAddPath(context, path.platformPath()); + if (state.fillPattern) applyFillPattern(); if (state.strokePattern) @@ -544,13 +542,16 @@ static inline void fillPathWithFillRule(CGContextRef context, WindRule fillRule) CGContextFillPath(context); } -void GraphicsContext::fillPath() +void GraphicsContext::fillPath(const Path& path) { if (paintingDisabled()) return; CGContextRef context = platformContext(); + CGContextBeginPath(context); + CGContextAddPath(context, path.platformPath()); + if (m_common->state.fillGradient) { CGContextSaveGState(context); if (fillRule() == RULE_EVENODD) @@ -568,13 +569,16 @@ void GraphicsContext::fillPath() fillPathWithFillRule(context, fillRule()); } -void GraphicsContext::strokePath() +void GraphicsContext::strokePath(const Path& path) { if (paintingDisabled()) return; CGContextRef context = platformContext(); + CGContextBeginPath(context); + CGContextAddPath(context, path.platformPath()); + if (m_common->state.strokeGradient) { CGContextSaveGState(context); CGContextReplacePathWithStrokedPath(context); @@ -643,8 +647,7 @@ void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLef Path path; path.addRoundedRect(rect, topLeft, topRight, bottomLeft, bottomRight); - addPath(path); - fillPath(); + fillPath(path); if (oldFillColor != color || oldColorSpace != colorSpace) setCGFillColor(context, oldFillColor, oldColorSpace); @@ -669,19 +672,23 @@ void GraphicsContext::clipOut(const IntRect& rect) CGContextEOClip(platformContext()); } -void GraphicsContext::clipPath(WindRule clipRule) +void GraphicsContext::clipPath(const Path& path, WindRule clipRule) { if (paintingDisabled()) return; + if (path.isEmpty()) + return; + CGContextRef context = platformContext(); - if (!CGContextIsPathEmpty(context)) { - if (clipRule == RULE_EVENODD) - CGContextEOClip(context); - else - CGContextClip(context); - } + CGContextBeginPath(platformContext()); + CGContextAddPath(platformContext(), path.platformPath()); + + if (clipRule == RULE_EVENODD) + CGContextEOClip(context); + else + CGContextClip(context); } void GraphicsContext::addInnerRoundedRectClip(const IntRect& rect, int thickness) @@ -863,16 +870,6 @@ void GraphicsContext::setLineJoin(LineJoin join) } } -void GraphicsContext::beginPath() -{ - CGContextBeginPath(platformContext()); -} - -void GraphicsContext::addPath(const Path& path) -{ - CGContextAddPath(platformContext(), path.platformPath()); -} - void GraphicsContext::clip(const Path& path) { if (paintingDisabled()) diff --git a/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp b/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp index 375a74b..7dab01f 100644 --- a/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp +++ b/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp @@ -41,6 +41,7 @@ #if PLATFORM(SKIA) #include "NativeImageSkia.h" #include "PlatformContextSkia.h" +#include "SkColorPriv.h" #include "skia/ext/platform_canvas.h" #elif PLATFORM(CG) #include <CoreGraphics/CGBitmapContext.h> @@ -68,8 +69,22 @@ ContentLayerChromium::SharedValues::SharedValues(GraphicsContext3D* context) " v_texCoord = a_texCoord; \n" "} \n"; +#if PLATFORM(SKIA) + // Color is in RGBA order. + char rgbaFragmentShaderString[] = + "precision mediump float; \n" + "varying vec2 v_texCoord; \n" + "uniform sampler2D s_texture; \n" + "uniform float alpha; \n" + "void main() \n" + "{ \n" + " vec4 texColor = texture2D(s_texture, v_texCoord); \n" + " gl_FragColor = texColor * alpha; \n" + "} \n"; +#endif + // Color is in BGRA order. - char fragmentShaderString[] = + char bgraFragmentShaderString[] = "precision mediump float; \n" "varying vec2 v_texCoord; \n" "uniform sampler2D s_texture; \n" @@ -80,6 +95,12 @@ ContentLayerChromium::SharedValues::SharedValues(GraphicsContext3D* context) " gl_FragColor = vec4(texColor.z, texColor.y, texColor.x, texColor.w) * alpha; \n" "} \n"; +#if PLATFORM(SKIA) + // Assuming the packing is either Skia default RGBA or Chromium default BGRA. + char* fragmentShaderString = SK_B32_SHIFT ? rgbaFragmentShaderString : bgraFragmentShaderString; +#else + char* fragmentShaderString = bgraFragmentShaderString; +#endif m_contentShaderProgram = createShaderProgram(m_context, vertexShaderString, fragmentShaderString); if (!m_contentShaderProgram) { LOG_ERROR("ContentLayerChromium: Failed to create shader program"); diff --git a/WebCore/platform/graphics/chromium/CrossProcessFontLoading.mm b/WebCore/platform/graphics/chromium/CrossProcessFontLoading.mm index a7ec03a..72e3369 100644 --- a/WebCore/platform/graphics/chromium/CrossProcessFontLoading.mm +++ b/WebCore/platform/graphics/chromium/CrossProcessFontLoading.mm @@ -181,11 +181,10 @@ MemoryActivatedFont::~MemoryActivatedFont() // that was picked in the end. The caller is responsible for calling // CFRelease() on this parameter when done with it. // * fontID - on output, the ID corresponding to nsFont. -void FontPlatformData::loadFont(NSFont* nsFont, float fontSize, NSFont*& outNSFont, CGFontRef& cgFont, ATSUFontID& fontID) +void FontPlatformData::loadFont(NSFont* nsFont, float fontSize, NSFont*& outNSFont, CGFontRef& cgFont) { outNSFont = nsFont; cgFont = CTFontCopyGraphicsFont(toCTFontRef(outNSFont), 0); - MemoryActivatedFont* memFont = 0; if (OutOfProcessFontLoadingEnabled() && outNSFont && cgFont && isLastResortFont(cgFont)) { // Release old CGFontRef since it points at the LastResort font which we don't want. CFRelease(cgFont); @@ -206,12 +205,6 @@ void FontPlatformData::loadFont(NSFont* nsFont, float fontSize, NSFont*& outNSFo cgFont = CTFontCopyGraphicsFont(toCTFontRef(outNSFont), 0); } } - - if (memFont) { - fontID = m_inMemoryFont->atsFontRef(); - } else { - fontID = CTFontGetPlatformFont(toCTFontRef(outNSFont), 0); - } } } // namespace WebCore diff --git a/WebCore/platform/graphics/chromium/FontCacheChromiumWin.cpp b/WebCore/platform/graphics/chromium/FontCacheChromiumWin.cpp index 384b1c5..347a3fb 100644 --- a/WebCore/platform/graphics/chromium/FontCacheChromiumWin.cpp +++ b/WebCore/platform/graphics/chromium/FontCacheChromiumWin.cpp @@ -211,9 +211,8 @@ static bool LookupAltName(const String& name, String& altName) static NameMap* fontNameMap = 0; if (!fontNameMap) { - size_t numElements = sizeof(namePairs) / sizeof(NamePair); fontNameMap = new NameMap; - for (size_t i = 0; i < numElements; ++i) + for (size_t i = 0; i < WTF_ARRAY_LENGTH(namePairs); ++i) fontNameMap->set(String(namePairs[i].name), &(namePairs[i].altNameCodepage)); } diff --git a/WebCore/platform/graphics/chromium/FontLinux.cpp b/WebCore/platform/graphics/chromium/FontLinux.cpp index 9fc7558..82b9df7 100644 --- a/WebCore/platform/graphics/chromium/FontLinux.cpp +++ b/WebCore/platform/graphics/chromium/FontLinux.cpp @@ -234,6 +234,7 @@ private: static bool isCodepointSpace(HB_UChar16 c) { return c == ' ' || c == '\t'; } const Font* const m_font; + const SimpleFontData* m_currentFontData; HB_ShaperItem m_item; uint16_t* m_glyphs16; // A vector of 16-bit glyph ids. SkScalar* m_xPositions; // A vector of x positions for each glyph. @@ -340,7 +341,6 @@ void TextRunWalker::setPadding(int padding) // amount to each space. The last space gets the smaller amount, if // any. unsigned numWordBreaks = 0; - bool isRTL = m_iterateBackwards; for (unsigned i = 0; i < m_item.stringLength; i++) { if (isWordBreak(i)) @@ -381,6 +381,7 @@ bool TextRunWalker::nextScriptRun() // (and the glyphs in each A, C and T section are backwards too) if (!hb_utf16_script_run_prev(&m_numCodePoints, &m_item.item, m_run.characters(), m_run.length(), &m_indexOfNextScriptRun)) return false; + m_currentFontData = m_font->glyphDataForCharacter(m_item.string[m_item.item.pos], false, false).fontData; } else { if (!hb_utf16_script_run_next(&m_numCodePoints, &m_item.item, m_run.characters(), m_run.length(), &m_indexOfNextScriptRun)) return false; @@ -392,11 +393,11 @@ bool TextRunWalker::nextScriptRun() // in the harfbuzz data structures to e.g. pick the correct script's shaper. // So we allow that to run first, then do a second pass over the range it // found and take the largest subregion that stays within a single font. - const FontData* glyphData = m_font->glyphDataForCharacter(m_item.string[m_item.item.pos], false, false).fontData; + m_currentFontData = m_font->glyphDataForCharacter(m_item.string[m_item.item.pos], false, false).fontData; unsigned endOfRun; for (endOfRun = 1; endOfRun < m_item.item.length; ++endOfRun) { - const FontData* nextGlyphData = m_font->glyphDataForCharacter(m_item.string[m_item.item.pos + endOfRun], false, false).fontData; - if (nextGlyphData != glyphData) + const SimpleFontData* nextFontData = m_font->glyphDataForCharacter(m_item.string[m_item.item.pos + endOfRun], false, false).fontData; + if (nextFontData != m_currentFontData) break; } m_item.item.length = endOfRun; @@ -518,13 +519,15 @@ void TextRunWalker::setGlyphXPositions(bool isRTL) // Glyphs are stored in logical order, but for layout purposes we // always go left to right. for (int i = m_item.num_glyphs - 1; i >= 0; --i) { - // Whitespace must be laid out in logical order, so when inserting - // spaces in RTL (but iterating in LTR order) we must insert spaces - // _before_ the next glyph. - if (i + 1 >= m_item.num_glyphs || m_item.attributes[i + 1].clusterStart) - position += m_letterSpacing; - - position += determineWordBreakSpacing(logClustersIndex); + if (!m_currentFontData->isZeroWidthSpaceGlyph(m_glyphs16[i])) { + // Whitespace must be laid out in logical order, so when inserting + // spaces in RTL (but iterating in LTR order) we must insert spaces + // _before_ the next glyph. + if (static_cast<unsigned>(i + 1) >= m_item.num_glyphs || m_item.attributes[i + 1].clusterStart) + position += m_letterSpacing; + + position += determineWordBreakSpacing(logClustersIndex); + } m_glyphs16[i] = m_item.glyphs[i]; double offsetX = truncateFixedPointToInteger(m_item.offsets[i].x); @@ -533,14 +536,18 @@ void TextRunWalker::setGlyphXPositions(bool isRTL) while (logClustersIndex > 0 && logClusters()[logClustersIndex] == i) logClustersIndex--; - position += truncateFixedPointToInteger(m_item.advances[i]); + if (!m_currentFontData->isZeroWidthSpaceGlyph(m_glyphs16[i])) + position += truncateFixedPointToInteger(m_item.advances[i]); } } else { - for (int i = 0; i < m_item.num_glyphs; ++i) { + for (size_t i = 0; i < m_item.num_glyphs; ++i) { m_glyphs16[i] = m_item.glyphs[i]; double offsetX = truncateFixedPointToInteger(m_item.offsets[i].x); m_xPositions[i] = m_offsetX + position + offsetX; + if (m_currentFontData->isZeroWidthSpaceGlyph(m_glyphs16[i])) + continue; + double advance = truncateFixedPointToInteger(m_item.advances[i]); advance += determineWordBreakSpacing(logClustersIndex); @@ -548,7 +555,7 @@ void TextRunWalker::setGlyphXPositions(bool isRTL) if (m_item.attributes[i].clusterStart) advance += m_letterSpacing; - while (logClustersIndex < m_item.item.length && logClusters()[logClustersIndex] == i) + while (static_cast<unsigned>(logClustersIndex) < m_item.item.length && logClusters()[logClustersIndex] == i) logClustersIndex++; position += advance; @@ -569,6 +576,8 @@ void TextRunWalker::normalizeSpacesAndMirrorChars(const UChar* source, bool rtl, U16_NEXT(source, nextPosition, length, character); if (Font::treatAsSpace(character)) character = ' '; + else if (Font::treatAsZeroWidthSpace(character)) + character = zeroWidthSpace; else if (rtl) character = u_charMirror(character); U16_APPEND(destination, position, length, character, error); @@ -592,7 +601,7 @@ const TextRun& TextRunWalker::getNormalizedTextRun(const TextRun& originalRun, O // 2) Convert spacing characters into plain spaces, as some fonts will provide glyphs // for characters like '\n' otherwise. // 3) Convert mirrored characters such as parenthesis for rtl text. - + // Convert to NFC form if the text has diacritical marks. icu::UnicodeString normalizedString; UErrorCode error = U_ZERO_ERROR; @@ -698,7 +707,7 @@ static int glyphIndexForXPositionInScriptRun(const TextRunWalker& walker, int x) for (glyphIndex = walker.length() - 1; glyphIndex >= 0; --glyphIndex) { // When iterating LTR over RTL text, we must include the whitespace // _before_ the glyph, so no + 1 here. - if (x < (walker.length() - glyphIndex) * letterSpacing + truncateFixedPointToInteger(advances[glyphIndex])) + if (x < (static_cast<int>(walker.length()) - glyphIndex) * letterSpacing + truncateFixedPointToInteger(advances[glyphIndex])) break; x -= truncateFixedPointToInteger(advances[glyphIndex]); } diff --git a/WebCore/platform/graphics/chromium/FontPlatformDataLinux.cpp b/WebCore/platform/graphics/chromium/FontPlatformDataLinux.cpp index 0da873b..3944775 100644 --- a/WebCore/platform/graphics/chromium/FontPlatformDataLinux.cpp +++ b/WebCore/platform/graphics/chromium/FontPlatformDataLinux.cpp @@ -130,7 +130,7 @@ String FontPlatformData::description() const void FontPlatformData::setupPaint(SkPaint* paint) const { - const float ts = m_textSize > 0 ? m_textSize : 12; + const float ts = m_textSize >= 0 ? m_textSize : 12; paint->setAntiAlias(m_style.useAntiAlias == FontRenderStyle::NoPreference ? isSkiaAntiAlias : m_style.useAntiAlias); switch (m_style.useHinting) { diff --git a/WebCore/platform/graphics/chromium/FontUtilsChromiumWin.cpp b/WebCore/platform/graphics/chromium/FontUtilsChromiumWin.cpp index e725c50..bea0572 100644 --- a/WebCore/platform/graphics/chromium/FontUtilsChromiumWin.cpp +++ b/WebCore/platform/graphics/chromium/FontUtilsChromiumWin.cpp @@ -150,14 +150,14 @@ void initializeScriptFontMap(ScriptToFontMap& scriptFontMap) {USCRIPT_MYANMAR, myanmarFonts}, }; - for (int i = 0; i < sizeof(fontMap) / sizeof(fontMap[0]); ++i) + for (size_t i = 0; i < WTF_ARRAY_LENGTH(fontMap); ++i) scriptFontMap[fontMap[i].script] = fontMap[i].family; // FIXME: Instead of scanning the hard-coded list, we have to // use EnumFont* to 'inspect' fonts to pick up fonts covering scripts // when it's possible (e.g. using OS/2 table). If we do that, this // had better be pulled out of here. - for (int i = 0; i < sizeof(scriptToFontFamilies) / sizeof(scriptToFontFamilies[0]); ++i) { + for (size_t i = 0; i < WTF_ARRAY_LENGTH(scriptToFontFamilies); ++i) { UScriptCode script = scriptToFontFamilies[i].script; scriptFontMap[script] = 0; const UChar** familyPtr = scriptToFontFamilies[i].families; diff --git a/WebCore/platform/graphics/chromium/SimpleFontDataChromiumWin.cpp b/WebCore/platform/graphics/chromium/SimpleFontDataChromiumWin.cpp index deebd31..bcef1fe 100644 --- a/WebCore/platform/graphics/chromium/SimpleFontDataChromiumWin.cpp +++ b/WebCore/platform/graphics/chromium/SimpleFontDataChromiumWin.cpp @@ -53,6 +53,18 @@ static inline float scaleEmToUnits(float x, int unitsPerEm) void SimpleFontData::platformInit() { + if (!m_platformData.size()) { + m_ascent = 0; + m_descent = 0; + m_lineGap = 0; + m_lineSpacing = 0; + m_avgCharWidth = 0; + m_maxCharWidth = 0; + m_xHeight = 0; + m_unitsPerEm = 0; + return; + } + HDC dc = GetDC(0); HGDIOBJ oldFont = SelectObject(dc, m_platformData.hfont()); @@ -155,6 +167,9 @@ FloatRect SimpleFontData::platformBoundsForGlyph(Glyph) const float SimpleFontData::platformWidthForGlyph(Glyph glyph) const { + if (!m_platformData.size()) + return 0; + HDC dc = GetDC(0); HGDIOBJ oldFont = SelectObject(dc, m_platformData.hfont()); diff --git a/WebCore/platform/graphics/chromium/SimpleFontDataLinux.cpp b/WebCore/platform/graphics/chromium/SimpleFontDataLinux.cpp index e7ff9ee..c5190fc 100644 --- a/WebCore/platform/graphics/chromium/SimpleFontDataLinux.cpp +++ b/WebCore/platform/graphics/chromium/SimpleFontDataLinux.cpp @@ -53,6 +53,18 @@ static const size_t maxVDMXTableSize = 1024 * 1024; // 1 MB void SimpleFontData::platformInit() { + if (!m_platformData.size()) { + m_ascent = 0; + m_descent = 0; + m_lineGap = 0; + m_lineSpacing = 0; + m_avgCharWidth = 0; + m_maxCharWidth = 0; + m_xHeight = 0; + m_unitsPerEm = 0; + return; + } + SkPaint paint; SkPaint::FontMetrics metrics; @@ -177,6 +189,9 @@ FloatRect SimpleFontData::platformBoundsForGlyph(Glyph) const float SimpleFontData::platformWidthForGlyph(Glyph glyph) const { + if (!m_platformData.size()) + return 0; + SkASSERT(sizeof(glyph) == 2); // compile-time assert SkPaint paint; diff --git a/WebCore/platform/graphics/cocoa/FontPlatformData.h b/WebCore/platform/graphics/cocoa/FontPlatformData.h index 7ab84f5..8cf08fb 100644 --- a/WebCore/platform/graphics/cocoa/FontPlatformData.h +++ b/WebCore/platform/graphics/cocoa/FontPlatformData.h @@ -63,7 +63,6 @@ class FontPlatformData { : m_syntheticBold(syntheticBold) , m_syntheticOblique(syntheticOblique) , m_orientation(orientation) - , m_atsuFontID(0) , m_size(size) , m_font(0) #ifdef BUILDING_ON_TIGER @@ -75,11 +74,10 @@ class FontPlatformData { FontPlatformData(NSFont *nsFont, float size, bool syntheticBold = false, bool syntheticOblique = false, FontOrientation = Horizontal); - FontPlatformData(CGFontRef cgFont, ATSUFontID fontID, float size, bool syntheticBold, bool syntheticOblique, FontOrientation orientation) + FontPlatformData(CGFontRef cgFont, float size, bool syntheticBold, bool syntheticOblique, FontOrientation orientation) : m_syntheticBold(syntheticBold) , m_syntheticOblique(syntheticOblique) , m_orientation(orientation) - , m_atsuFontID(fontID) , m_size(size) , m_font(0) , m_cgFont(cgFont) @@ -103,7 +101,6 @@ class FontPlatformData { bool m_syntheticOblique; FontOrientation m_orientation; - ATSUFontID m_atsuFontID; float m_size; unsigned hash() const @@ -118,7 +115,7 @@ class FontPlatformData { bool operator==(const FontPlatformData& other) const { return m_font == other.m_font && m_syntheticBold == other.m_syntheticBold && m_syntheticOblique == other.m_syntheticOblique && - m_cgFont == other.m_cgFont && m_size == other.m_size && m_atsuFontID == other.m_atsuFontID && m_orientation == other.m_orientation; + m_cgFont == other.m_cgFont && m_size == other.m_size && m_orientation == other.m_orientation; } NSFont *font() const { return m_font; } @@ -149,8 +146,7 @@ private: // * outNSFont - The font that was actually loaded, for the Chromium port this may be different than nsFont. // The caller is responsible for calling CFRelease() on this parameter when done with it. // * cgFont - CGFontRef representing the input font at the specified point size. - // * fontID - ID of loaded font. - void loadFont(NSFont* nsFont, float fontSize, NSFont*& outNSFont, CGFontRef& cgFont, ATSUFontID& fontID); + void loadFont(NSFont* nsFont, float fontSize, NSFont*& outNSFont, CGFontRef& cgFont); NSFont *m_font; diff --git a/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm b/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm index 52a88ed..8dacbe3 100644 --- a/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm +++ b/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm @@ -31,15 +31,13 @@ namespace WebCore { #if PLATFORM(MAC) -void FontPlatformData::loadFont(NSFont* nsFont, float, NSFont*& outNSFont, CGFontRef& cgFont, ATSUFontID& fontID) +void FontPlatformData::loadFont(NSFont* nsFont, float, NSFont*& outNSFont, CGFontRef& cgFont) { outNSFont = nsFont; #ifndef BUILDING_ON_TIGER cgFont = CTFontCopyGraphicsFont(toCTFontRef(nsFont), 0); - fontID = CTFontGetPlatformFont(toCTFontRef(nsFont), 0); #else cgFont = wkGetCGFontFromNSFont(nsFont); - fontID = wkGetNSFontATSUFontId(nsFont); #endif } #endif // PLATFORM(MAC) @@ -60,7 +58,7 @@ FontPlatformData::FontPlatformData(NSFont *nsFont, float size, bool syntheticBol ASSERT_ARG(nsFont, nsFont); CGFontRef cgFont = 0; - loadFont(nsFont, size, m_font, cgFont, m_atsuFontID); + loadFont(nsFont, size, m_font, cgFont); m_orientation = orientation; @@ -82,7 +80,6 @@ FontPlatformData::FontPlatformData(const FontPlatformData& f) m_syntheticOblique = f.m_syntheticOblique; m_size = f.m_size; m_cgFont = f.m_cgFont; - m_atsuFontID = f.m_atsuFontID; m_isColorBitmapFont = f.m_isColorBitmapFont; m_orientation = f.m_orientation; m_CTFont = f.m_CTFont; @@ -103,7 +100,6 @@ const FontPlatformData& FontPlatformData::operator=(const FontPlatformData& f) m_syntheticOblique = f.m_syntheticOblique; m_size = f.m_size; m_cgFont = f.m_cgFont; - m_atsuFontID = f.m_atsuFontID; if (m_font == f.m_font) return *this; if (f.m_font && f.m_font != reinterpret_cast<NSFont *>(-1)) @@ -136,7 +132,7 @@ void FontPlatformData::setFont(NSFont *font) CGFontRef cgFont = 0; NSFont* loadedFont = 0; - loadFont(m_font, m_size, loadedFont, cgFont, m_atsuFontID); + loadFont(m_font, m_size, loadedFont, cgFont); #if PLATFORM(CHROMIUM) && OS(DARWIN) // If loadFont replaced m_font with a fallback font, then release the diff --git a/WebCore/platform/graphics/filters/FEBlend.cpp b/WebCore/platform/graphics/filters/FEBlend.cpp index 03b95c3..89b44e0 100644 --- a/WebCore/platform/graphics/filters/FEBlend.cpp +++ b/WebCore/platform/graphics/filters/FEBlend.cpp @@ -35,15 +35,15 @@ typedef unsigned char (*BlendType)(unsigned char colorA, unsigned char colorB, u namespace WebCore { -FEBlend::FEBlend(BlendModeType mode) - : FilterEffect() +FEBlend::FEBlend(Filter* filter, BlendModeType mode) + : FilterEffect(filter) , m_mode(mode) { } -PassRefPtr<FEBlend> FEBlend::create(BlendModeType mode) +PassRefPtr<FEBlend> FEBlend::create(Filter* filter, BlendModeType mode) { - return adoptRef(new FEBlend(mode)); + return adoptRef(new FEBlend(filter, mode)); } BlendModeType FEBlend::blendMode() const @@ -86,19 +86,19 @@ static unsigned char lighten(unsigned char colorA, unsigned char colorB, unsigne return ((std::max((255 - alphaA) * colorB + colorA * 255, (255 - alphaB) * colorA + colorB * 255)) / 255); } -void FEBlend::apply(Filter* filter) +void FEBlend::apply() { FilterEffect* in = inputEffect(0); FilterEffect* in2 = inputEffect(1); - in->apply(filter); - in2->apply(filter); + in->apply(); + in2->apply(); if (!in->resultImage() || !in2->resultImage()) return; if (m_mode <= FEBLEND_MODE_UNKNOWN || m_mode > FEBLEND_MODE_LIGHTEN) return; - if (!effectContext(filter)) + if (!effectContext()) return; IntRect effectADrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect()); diff --git a/WebCore/platform/graphics/filters/FEBlend.h b/WebCore/platform/graphics/filters/FEBlend.h index a6569e2..4c59578 100644 --- a/WebCore/platform/graphics/filters/FEBlend.h +++ b/WebCore/platform/graphics/filters/FEBlend.h @@ -40,18 +40,18 @@ enum BlendModeType { class FEBlend : public FilterEffect { public: - static PassRefPtr<FEBlend> create(BlendModeType); + static PassRefPtr<FEBlend> create(Filter*, BlendModeType); BlendModeType blendMode() const; void setBlendMode(BlendModeType); - virtual void apply(Filter*); + virtual void apply(); virtual void dump(); virtual TextStream& externalRepresentation(TextStream&, int indention) const; private: - FEBlend(BlendModeType); + FEBlend(Filter*, BlendModeType); BlendModeType m_mode; }; diff --git a/WebCore/platform/graphics/filters/FEColorMatrix.cpp b/WebCore/platform/graphics/filters/FEColorMatrix.cpp index acf7d4a..1c99b1e 100644 --- a/WebCore/platform/graphics/filters/FEColorMatrix.cpp +++ b/WebCore/platform/graphics/filters/FEColorMatrix.cpp @@ -33,16 +33,16 @@ namespace WebCore { -FEColorMatrix::FEColorMatrix(ColorMatrixType type, const Vector<float>& values) - : FilterEffect() +FEColorMatrix::FEColorMatrix(Filter* filter, ColorMatrixType type, const Vector<float>& values) + : FilterEffect(filter) , m_type(type) , m_values(values) { } -PassRefPtr<FEColorMatrix> FEColorMatrix::create(ColorMatrixType type, const Vector<float>& values) +PassRefPtr<FEColorMatrix> FEColorMatrix::create(Filter* filter, ColorMatrixType type, const Vector<float>& values) { - return adoptRef(new FEColorMatrix(type, values)); + return adoptRef(new FEColorMatrix(filter, type, values)); } ColorMatrixType FEColorMatrix::type() const @@ -148,14 +148,14 @@ void effectType(ByteArray* pixelArray, const Vector<float>& values) } } -void FEColorMatrix::apply(Filter* filter) +void FEColorMatrix::apply() { FilterEffect* in = inputEffect(0); - in->apply(filter); + in->apply(); if (!in->resultImage()) return; - GraphicsContext* filterContext = effectContext(filter); + GraphicsContext* filterContext = effectContext(); if (!filterContext) return; diff --git a/WebCore/platform/graphics/filters/FEColorMatrix.h b/WebCore/platform/graphics/filters/FEColorMatrix.h index b898b17..a3ced7e 100644 --- a/WebCore/platform/graphics/filters/FEColorMatrix.h +++ b/WebCore/platform/graphics/filters/FEColorMatrix.h @@ -40,7 +40,7 @@ enum ColorMatrixType { class FEColorMatrix : public FilterEffect { public: - static PassRefPtr<FEColorMatrix> create(ColorMatrixType, const Vector<float>&); + static PassRefPtr<FEColorMatrix> create(Filter*, ColorMatrixType, const Vector<float>&); ColorMatrixType type() const; void setType(ColorMatrixType); @@ -48,13 +48,13 @@ public: const Vector<float>& values() const; void setValues(const Vector<float>&); - virtual void apply(Filter*); + virtual void apply(); virtual void dump(); virtual TextStream& externalRepresentation(TextStream&, int indention) const; private: - FEColorMatrix(ColorMatrixType, const Vector<float>&); + FEColorMatrix(Filter*, ColorMatrixType, const Vector<float>&); ColorMatrixType m_type; Vector<float> m_values; diff --git a/WebCore/platform/graphics/filters/FEComponentTransfer.cpp b/WebCore/platform/graphics/filters/FEComponentTransfer.cpp index 5cffac7..cfab50b 100644 --- a/WebCore/platform/graphics/filters/FEComponentTransfer.cpp +++ b/WebCore/platform/graphics/filters/FEComponentTransfer.cpp @@ -36,9 +36,9 @@ namespace WebCore { typedef void (*TransferType)(unsigned char*, const ComponentTransferFunction&); -FEComponentTransfer::FEComponentTransfer(const ComponentTransferFunction& redFunc, const ComponentTransferFunction& greenFunc, +FEComponentTransfer::FEComponentTransfer(Filter* filter, const ComponentTransferFunction& redFunc, const ComponentTransferFunction& greenFunc, const ComponentTransferFunction& blueFunc, const ComponentTransferFunction& alphaFunc) - : FilterEffect() + : FilterEffect(filter) , m_redFunc(redFunc) , m_greenFunc(greenFunc) , m_blueFunc(blueFunc) @@ -46,10 +46,10 @@ FEComponentTransfer::FEComponentTransfer(const ComponentTransferFunction& redFun { } -PassRefPtr<FEComponentTransfer> FEComponentTransfer::create(const ComponentTransferFunction& redFunc, +PassRefPtr<FEComponentTransfer> FEComponentTransfer::create(Filter* filter, const ComponentTransferFunction& redFunc, const ComponentTransferFunction& greenFunc, const ComponentTransferFunction& blueFunc, const ComponentTransferFunction& alphaFunc) { - return adoptRef(new FEComponentTransfer(redFunc, greenFunc, blueFunc, alphaFunc)); + return adoptRef(new FEComponentTransfer(filter, redFunc, greenFunc, blueFunc, alphaFunc)); } ComponentTransferFunction FEComponentTransfer::redFunction() const @@ -147,14 +147,14 @@ static void gamma(unsigned char* values, const ComponentTransferFunction& transf } } -void FEComponentTransfer::apply(Filter* filter) +void FEComponentTransfer::apply() { FilterEffect* in = inputEffect(0); - in->apply(filter); + in->apply(); if (!in->resultImage()) return; - if (!effectContext(filter)) + if (!effectContext()) return; unsigned char rValues[256], gValues[256], bValues[256], aValues[256]; diff --git a/WebCore/platform/graphics/filters/FEComponentTransfer.h b/WebCore/platform/graphics/filters/FEComponentTransfer.h index d3145d4..bbe3ebb 100644 --- a/WebCore/platform/graphics/filters/FEComponentTransfer.h +++ b/WebCore/platform/graphics/filters/FEComponentTransfer.h @@ -63,7 +63,7 @@ struct ComponentTransferFunction { class FEComponentTransfer : public FilterEffect { public: - static PassRefPtr<FEComponentTransfer> create(const ComponentTransferFunction& redFunc, const ComponentTransferFunction& greenFunc, + static PassRefPtr<FEComponentTransfer> create(Filter*, const ComponentTransferFunction& redFunc, const ComponentTransferFunction& greenFunc, const ComponentTransferFunction& blueFunc, const ComponentTransferFunction& alphaFunc); ComponentTransferFunction redFunction() const; @@ -78,13 +78,13 @@ public: ComponentTransferFunction alphaFunction() const; void setAlphaFunction(const ComponentTransferFunction&); - virtual void apply(Filter*); + virtual void apply(); virtual void dump(); virtual TextStream& externalRepresentation(TextStream&, int indention) const; private: - FEComponentTransfer(const ComponentTransferFunction& redFunc, const ComponentTransferFunction& greenFunc, + FEComponentTransfer(Filter*, const ComponentTransferFunction& redFunc, const ComponentTransferFunction& greenFunc, const ComponentTransferFunction& blueFunc, const ComponentTransferFunction& alphaFunc); ComponentTransferFunction m_redFunc; diff --git a/WebCore/platform/graphics/filters/FEComposite.cpp b/WebCore/platform/graphics/filters/FEComposite.cpp index aad71e3..d27321f 100644 --- a/WebCore/platform/graphics/filters/FEComposite.cpp +++ b/WebCore/platform/graphics/filters/FEComposite.cpp @@ -32,8 +32,8 @@ namespace WebCore { -FEComposite::FEComposite(const CompositeOperationType& type, float k1, float k2, float k3, float k4) - : FilterEffect() +FEComposite::FEComposite(Filter* filter, const CompositeOperationType& type, float k1, float k2, float k3, float k4) + : FilterEffect(filter) , m_type(type) , m_k1(k1) , m_k2(k2) @@ -42,9 +42,9 @@ FEComposite::FEComposite(const CompositeOperationType& type, float k1, float k2, { } -PassRefPtr<FEComposite> FEComposite::create(const CompositeOperationType& type, float k1, float k2, float k3, float k4) +PassRefPtr<FEComposite> FEComposite::create(Filter* filter, const CompositeOperationType& type, float k1, float k2, float k3, float k4) { - return adoptRef(new FEComposite(type, k1, k2, k3, k4)); + return adoptRef(new FEComposite(filter, type, k1, k2, k3, k4)); } CompositeOperationType FEComposite::operation() const @@ -114,7 +114,7 @@ inline void arithmetic(const ByteArray* srcPixelArrayA, ByteArray* srcPixelArray } } -void FEComposite::determineAbsolutePaintRect(Filter* filter) +void FEComposite::determineAbsolutePaintRect() { switch (m_type) { case FECOMPOSITE_OPERATOR_IN: @@ -130,21 +130,21 @@ void FEComposite::determineAbsolutePaintRect(Filter* filter) return; default: // Take the union of both input effects. - FilterEffect::determineAbsolutePaintRect(filter); + FilterEffect::determineAbsolutePaintRect(); return; } } -void FEComposite::apply(Filter* filter) +void FEComposite::apply() { FilterEffect* in = inputEffect(0); FilterEffect* in2 = inputEffect(1); - in->apply(filter); - in2->apply(filter); + in->apply(); + in2->apply(); if (!in->resultImage() || !in2->resultImage()) return; - GraphicsContext* filterContext = effectContext(filter); + GraphicsContext* filterContext = effectContext(); if (!filterContext) return; diff --git a/WebCore/platform/graphics/filters/FEComposite.h b/WebCore/platform/graphics/filters/FEComposite.h index ecdb037..b846902 100644 --- a/WebCore/platform/graphics/filters/FEComposite.h +++ b/WebCore/platform/graphics/filters/FEComposite.h @@ -42,7 +42,7 @@ enum CompositeOperationType { class FEComposite : public FilterEffect { public: - static PassRefPtr<FEComposite> create(const CompositeOperationType&, float, float, float, float); + static PassRefPtr<FEComposite> create(Filter*, const CompositeOperationType&, float, float, float, float); CompositeOperationType operation() const; void setOperation(CompositeOperationType); @@ -59,15 +59,15 @@ public: float k4() const; void setK4(float); - virtual void apply(Filter*); + virtual void apply(); virtual void dump(); - virtual void determineAbsolutePaintRect(Filter*); + virtual void determineAbsolutePaintRect(); virtual TextStream& externalRepresentation(TextStream&, int indention) const; private: - FEComposite(const CompositeOperationType&, float, float, float, float); + FEComposite(Filter*, const CompositeOperationType&, float, float, float, float); CompositeOperationType m_type; float m_k1; diff --git a/WebCore/platform/graphics/filters/FEConvolveMatrix.cpp b/WebCore/platform/graphics/filters/FEConvolveMatrix.cpp index d487a47..198d764 100644 --- a/WebCore/platform/graphics/filters/FEConvolveMatrix.cpp +++ b/WebCore/platform/graphics/filters/FEConvolveMatrix.cpp @@ -32,10 +32,10 @@ namespace WebCore { -FEConvolveMatrix::FEConvolveMatrix(const IntSize& kernelSize, +FEConvolveMatrix::FEConvolveMatrix(Filter* filter, const IntSize& kernelSize, float divisor, float bias, const IntPoint& targetOffset, EdgeModeType edgeMode, const FloatPoint& kernelUnitLength, bool preserveAlpha, const Vector<float>& kernelMatrix) - : FilterEffect() + : FilterEffect(filter) , m_kernelSize(kernelSize) , m_divisor(divisor) , m_bias(bias) @@ -47,11 +47,11 @@ FEConvolveMatrix::FEConvolveMatrix(const IntSize& kernelSize, { } -PassRefPtr<FEConvolveMatrix> FEConvolveMatrix::create(const IntSize& kernelSize, +PassRefPtr<FEConvolveMatrix> FEConvolveMatrix::create(Filter* filter, const IntSize& kernelSize, float divisor, float bias, const IntPoint& targetOffset, EdgeModeType edgeMode, const FloatPoint& kernelUnitLength, bool preserveAlpha, const Vector<float>& kernelMatrix) { - return adoptRef(new FEConvolveMatrix(kernelSize, divisor, bias, targetOffset, edgeMode, kernelUnitLength, + return adoptRef(new FEConvolveMatrix(filter, kernelSize, divisor, bias, targetOffset, edgeMode, kernelUnitLength, preserveAlpha, kernelMatrix)); } @@ -370,14 +370,14 @@ ALWAYS_INLINE void FEConvolveMatrix::setOuterPixels(PaintingData& paintingData, fastSetOuterPixels<false>(paintingData, x1, y1, x2, y2); } -void FEConvolveMatrix::apply(Filter* filter) +void FEConvolveMatrix::apply() { FilterEffect* in = inputEffect(0); - in->apply(filter); + in->apply(); if (!in->resultImage()) return; - if (!effectContext(filter)) + if (!effectContext()) return; IntRect imageRect(IntPoint(), resultImage()->size()); diff --git a/WebCore/platform/graphics/filters/FEConvolveMatrix.h b/WebCore/platform/graphics/filters/FEConvolveMatrix.h index 8d3439e..6811a1b 100644 --- a/WebCore/platform/graphics/filters/FEConvolveMatrix.h +++ b/WebCore/platform/graphics/filters/FEConvolveMatrix.h @@ -44,7 +44,7 @@ class CanvasPixelArray; class FEConvolveMatrix : public FilterEffect { public: - static PassRefPtr<FEConvolveMatrix> create(const IntSize&, + static PassRefPtr<FEConvolveMatrix> create(Filter*, const IntSize&, float, float, const IntPoint&, EdgeModeType, const FloatPoint&, bool, const Vector<float>&); @@ -72,15 +72,15 @@ public: bool preserveAlpha() const; void setPreserveAlpha(bool); - virtual void apply(Filter*); + virtual void apply(); virtual void dump(); - virtual void determineAbsolutePaintRect(Filter*) { setAbsolutePaintRect(maxEffectRect()); } + virtual void determineAbsolutePaintRect() { setAbsolutePaintRect(maxEffectRect()); } virtual TextStream& externalRepresentation(TextStream&, int indention) const; private: - FEConvolveMatrix(const IntSize&, float, float, + FEConvolveMatrix(Filter*, const IntSize&, float, float, const IntPoint&, EdgeModeType, const FloatPoint&, bool, const Vector<float>&); struct PaintingData { diff --git a/WebCore/platform/graphics/filters/FEDiffuseLighting.cpp b/WebCore/platform/graphics/filters/FEDiffuseLighting.cpp index 98b5adf..14d57f4 100644 --- a/WebCore/platform/graphics/filters/FEDiffuseLighting.cpp +++ b/WebCore/platform/graphics/filters/FEDiffuseLighting.cpp @@ -28,17 +28,17 @@ namespace WebCore { -FEDiffuseLighting::FEDiffuseLighting(const Color& lightingColor, float surfaceScale, +FEDiffuseLighting::FEDiffuseLighting(Filter* filter, const Color& lightingColor, float surfaceScale, float diffuseConstant, float kernelUnitLengthX, float kernelUnitLengthY, PassRefPtr<LightSource> lightSource) - : FELighting(DiffuseLighting, lightingColor, surfaceScale, diffuseConstant, 0, 0, kernelUnitLengthX, kernelUnitLengthY, lightSource) + : FELighting(filter, DiffuseLighting, lightingColor, surfaceScale, diffuseConstant, 0, 0, kernelUnitLengthX, kernelUnitLengthY, lightSource) { } -PassRefPtr<FEDiffuseLighting> FEDiffuseLighting::create(const Color& lightingColor, +PassRefPtr<FEDiffuseLighting> FEDiffuseLighting::create(Filter* filter, const Color& lightingColor, float surfaceScale, float diffuseConstant, float kernelUnitLengthX, float kernelUnitLengthY, PassRefPtr<LightSource> lightSource) { - return adoptRef(new FEDiffuseLighting(lightingColor, surfaceScale, diffuseConstant, kernelUnitLengthX, kernelUnitLengthY, lightSource)); + return adoptRef(new FEDiffuseLighting(filter, lightingColor, surfaceScale, diffuseConstant, kernelUnitLengthX, kernelUnitLengthY, lightSource)); } FEDiffuseLighting::~FEDiffuseLighting() diff --git a/WebCore/platform/graphics/filters/FEDiffuseLighting.h b/WebCore/platform/graphics/filters/FEDiffuseLighting.h index 5273144..b58b47a 100644 --- a/WebCore/platform/graphics/filters/FEDiffuseLighting.h +++ b/WebCore/platform/graphics/filters/FEDiffuseLighting.h @@ -31,7 +31,7 @@ class LightSource; class FEDiffuseLighting : public FELighting { public: - static PassRefPtr<FEDiffuseLighting> create(const Color&, float, float, + static PassRefPtr<FEDiffuseLighting> create(Filter*, const Color&, float, float, float, float, PassRefPtr<LightSource>); virtual ~FEDiffuseLighting(); @@ -58,7 +58,7 @@ public: virtual TextStream& externalRepresentation(TextStream&, int indention) const; private: - FEDiffuseLighting(const Color&, float, float, float, float, PassRefPtr<LightSource>); + FEDiffuseLighting(Filter*, const Color&, float, float, float, float, PassRefPtr<LightSource>); }; } // namespace WebCore diff --git a/WebCore/platform/graphics/filters/FEDisplacementMap.cpp b/WebCore/platform/graphics/filters/FEDisplacementMap.cpp index 4c62ca7..55321e6 100644 --- a/WebCore/platform/graphics/filters/FEDisplacementMap.cpp +++ b/WebCore/platform/graphics/filters/FEDisplacementMap.cpp @@ -32,18 +32,18 @@ namespace WebCore { -FEDisplacementMap::FEDisplacementMap(ChannelSelectorType xChannelSelector, ChannelSelectorType yChannelSelector, float scale) - : FilterEffect() +FEDisplacementMap::FEDisplacementMap(Filter* filter, ChannelSelectorType xChannelSelector, ChannelSelectorType yChannelSelector, float scale) + : FilterEffect(filter) , m_xChannelSelector(xChannelSelector) , m_yChannelSelector(yChannelSelector) , m_scale(scale) { } -PassRefPtr<FEDisplacementMap> FEDisplacementMap::create(ChannelSelectorType xChannelSelector, +PassRefPtr<FEDisplacementMap> FEDisplacementMap::create(Filter* filter, ChannelSelectorType xChannelSelector, ChannelSelectorType yChannelSelector, float scale) { - return adoptRef(new FEDisplacementMap(xChannelSelector, yChannelSelector, scale)); + return adoptRef(new FEDisplacementMap(filter, xChannelSelector, yChannelSelector, scale)); } ChannelSelectorType FEDisplacementMap::xChannelSelector() const @@ -76,19 +76,19 @@ void FEDisplacementMap::setScale(float scale) m_scale = scale; } -void FEDisplacementMap::apply(Filter* filter) +void FEDisplacementMap::apply() { FilterEffect* in = inputEffect(0); FilterEffect* in2 = inputEffect(1); - in->apply(filter); - in2->apply(filter); + in->apply(); + in2->apply(); if (!in->resultImage() || !in2->resultImage()) return; if (m_xChannelSelector == CHANNEL_UNKNOWN || m_yChannelSelector == CHANNEL_UNKNOWN) return; - if (!effectContext(filter)) + if (!effectContext()) return; IntRect effectADrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect()); @@ -105,6 +105,7 @@ void FEDisplacementMap::apply(Filter* filter) ASSERT(srcPixelArrayA->length() == srcPixelArrayB->length()); + Filter* filter = this->filter(); float scaleX = filter->applyHorizontalScale(m_scale / 255); float scaleY = filter->applyVerticalScale(m_scale / 255); float scaleAdjustmentX = filter->applyHorizontalScale(0.5f - 0.5f * m_scale); diff --git a/WebCore/platform/graphics/filters/FEDisplacementMap.h b/WebCore/platform/graphics/filters/FEDisplacementMap.h index c5b97a7..ffb8f0e 100644 --- a/WebCore/platform/graphics/filters/FEDisplacementMap.h +++ b/WebCore/platform/graphics/filters/FEDisplacementMap.h @@ -39,7 +39,7 @@ enum ChannelSelectorType { class FEDisplacementMap : public FilterEffect { public: - static PassRefPtr<FEDisplacementMap> create(ChannelSelectorType xChannelSelector, ChannelSelectorType yChannelSelector, float); + static PassRefPtr<FEDisplacementMap> create(Filter*, ChannelSelectorType xChannelSelector, ChannelSelectorType yChannelSelector, float); ChannelSelectorType xChannelSelector() const; void setXChannelSelector(const ChannelSelectorType); @@ -50,15 +50,15 @@ public: float scale() const; void setScale(float scale); - virtual void apply(Filter*); + virtual void apply(); virtual void dump(); - virtual void determineAbsolutePaintRect(Filter*) { setAbsolutePaintRect(maxEffectRect()); } + virtual void determineAbsolutePaintRect() { setAbsolutePaintRect(maxEffectRect()); } virtual TextStream& externalRepresentation(TextStream&, int indention) const; private: - FEDisplacementMap(ChannelSelectorType xChannelSelector, ChannelSelectorType yChannelSelector, float); + FEDisplacementMap(Filter*, ChannelSelectorType xChannelSelector, ChannelSelectorType yChannelSelector, float); ChannelSelectorType m_xChannelSelector; ChannelSelectorType m_yChannelSelector; diff --git a/WebCore/platform/graphics/filters/FEFlood.cpp b/WebCore/platform/graphics/filters/FEFlood.cpp index b51a422..bc6721b 100644 --- a/WebCore/platform/graphics/filters/FEFlood.cpp +++ b/WebCore/platform/graphics/filters/FEFlood.cpp @@ -30,16 +30,16 @@ namespace WebCore { -FEFlood::FEFlood(const Color& floodColor, float floodOpacity) - : FilterEffect() +FEFlood::FEFlood(Filter* filter, const Color& floodColor, float floodOpacity) + : FilterEffect(filter) , m_floodColor(floodColor) , m_floodOpacity(floodOpacity) { } -PassRefPtr<FEFlood> FEFlood::create(const Color& floodColor, float floodOpacity) +PassRefPtr<FEFlood> FEFlood::create(Filter* filter, const Color& floodColor, float floodOpacity) { - return adoptRef(new FEFlood(floodColor, floodOpacity)); + return adoptRef(new FEFlood(filter, floodColor, floodOpacity)); } Color FEFlood::floodColor() const @@ -62,9 +62,9 @@ void FEFlood::setFloodOpacity(float floodOpacity) m_floodOpacity = floodOpacity; } -void FEFlood::apply(Filter* filter) +void FEFlood::apply() { - GraphicsContext* filterContext = effectContext(filter); + GraphicsContext* filterContext = effectContext(); if (!filterContext) return; diff --git a/WebCore/platform/graphics/filters/FEFlood.h b/WebCore/platform/graphics/filters/FEFlood.h index e6a9574..2e8824f 100644 --- a/WebCore/platform/graphics/filters/FEFlood.h +++ b/WebCore/platform/graphics/filters/FEFlood.h @@ -31,7 +31,7 @@ namespace WebCore { class FEFlood : public FilterEffect { public: - static PassRefPtr<FEFlood> create(const Color&, float); + static PassRefPtr<FEFlood> create(Filter* filter, const Color&, float); Color floodColor() const; void setFloodColor(const Color &); @@ -39,15 +39,15 @@ public: float floodOpacity() const; void setFloodOpacity(float); - virtual void apply(Filter*); + virtual void apply(); virtual void dump(); - virtual void determineAbsolutePaintRect(Filter*) { setAbsolutePaintRect(maxEffectRect()); } + virtual void determineAbsolutePaintRect() { setAbsolutePaintRect(maxEffectRect()); } virtual TextStream& externalRepresentation(TextStream&, int indention) const; private: - FEFlood(const Color&, float); + FEFlood(Filter*, const Color&, float); Color m_floodColor; float m_floodOpacity; diff --git a/WebCore/platform/graphics/filters/FEGaussianBlur.cpp b/WebCore/platform/graphics/filters/FEGaussianBlur.cpp index bb70537..876e4b3 100644 --- a/WebCore/platform/graphics/filters/FEGaussianBlur.cpp +++ b/WebCore/platform/graphics/filters/FEGaussianBlur.cpp @@ -40,16 +40,16 @@ static const unsigned gMaxKernelSize = 1000; namespace WebCore { -FEGaussianBlur::FEGaussianBlur(float x, float y) - : FilterEffect() +FEGaussianBlur::FEGaussianBlur(Filter* filter, float x, float y) + : FilterEffect(filter) , m_stdX(x) , m_stdY(y) { } -PassRefPtr<FEGaussianBlur> FEGaussianBlur::create(float x, float y) +PassRefPtr<FEGaussianBlur> FEGaussianBlur::create(Filter* filter, float x, float y) { - return adoptRef(new FEGaussianBlur(x, y)); + return adoptRef(new FEGaussianBlur(filter, x, y)); } float FEGaussianBlur::stdDeviationX() const @@ -147,14 +147,14 @@ inline void calculateKernelSize(Filter* filter, unsigned& kernelSizeX, unsigned& kernelSizeY = gMaxKernelSize; } -void FEGaussianBlur::determineAbsolutePaintRect(Filter* filter) +void FEGaussianBlur::determineAbsolutePaintRect() { FloatRect absolutePaintRect = inputEffect(0)->absolutePaintRect(); absolutePaintRect.intersect(maxEffectRect()); unsigned kernelSizeX = 0; unsigned kernelSizeY = 0; - calculateKernelSize(filter, kernelSizeX, kernelSizeY, m_stdX, m_stdY); + calculateKernelSize(filter(), kernelSizeX, kernelSizeY, m_stdX, m_stdY); // We take the half kernel size and multiply it with three, because we run box blur three times. absolutePaintRect.inflateX(3 * kernelSizeX * 0.5f); @@ -162,14 +162,14 @@ void FEGaussianBlur::determineAbsolutePaintRect(Filter* filter) setAbsolutePaintRect(enclosingIntRect(absolutePaintRect)); } -void FEGaussianBlur::apply(Filter* filter) +void FEGaussianBlur::apply() { FilterEffect* in = inputEffect(0); - in->apply(filter); + in->apply(); if (!in->resultImage()) return; - if (!effectContext(filter)) + if (!effectContext()) return; setIsAlphaImage(in->isAlphaImage()); @@ -185,7 +185,7 @@ void FEGaussianBlur::apply(Filter* filter) unsigned kernelSizeX = 0; unsigned kernelSizeY = 0; - calculateKernelSize(filter, kernelSizeX, kernelSizeY, m_stdX, m_stdY); + calculateKernelSize(filter(), kernelSizeX, kernelSizeY, m_stdX, m_stdY); ByteArray* srcPixelArray = srcImageData->data()->data(); RefPtr<ImageData> tmpImageData = ImageData::create(imageRect.width(), imageRect.height()); diff --git a/WebCore/platform/graphics/filters/FEGaussianBlur.h b/WebCore/platform/graphics/filters/FEGaussianBlur.h index 50fc610..79f9a45 100644 --- a/WebCore/platform/graphics/filters/FEGaussianBlur.h +++ b/WebCore/platform/graphics/filters/FEGaussianBlur.h @@ -30,7 +30,7 @@ namespace WebCore { class FEGaussianBlur : public FilterEffect { public: - static PassRefPtr<FEGaussianBlur> create(float, float); + static PassRefPtr<FEGaussianBlur> create(Filter*, float, float); float stdDeviationX() const; void setStdDeviationX(float); @@ -40,15 +40,15 @@ public: static float calculateStdDeviation(float); - virtual void apply(Filter*); + virtual void apply(); virtual void dump(); - virtual void determineAbsolutePaintRect(Filter*); + virtual void determineAbsolutePaintRect(); virtual TextStream& externalRepresentation(TextStream&, int indention) const; private: - FEGaussianBlur(float, float); + FEGaussianBlur(Filter*, float, float); float m_stdX; float m_stdY; diff --git a/WebCore/platform/graphics/filters/FELighting.cpp b/WebCore/platform/graphics/filters/FELighting.cpp index 803b9c1..812920c 100644 --- a/WebCore/platform/graphics/filters/FELighting.cpp +++ b/WebCore/platform/graphics/filters/FELighting.cpp @@ -35,10 +35,10 @@ namespace WebCore { -FELighting::FELighting(LightingType lightingType, const Color& lightingColor, float surfaceScale, +FELighting::FELighting(Filter* filter, LightingType lightingType, const Color& lightingColor, float surfaceScale, float diffuseConstant, float specularConstant, float specularExponent, float kernelUnitLengthX, float kernelUnitLengthY, PassRefPtr<LightSource> lightSource) - : FilterEffect() + : FilterEffect(filter) , m_lightingType(lightingType) , m_lightSource(lightSource) , m_lightingColor(lightingColor) @@ -329,14 +329,14 @@ bool FELighting::drawLighting(ByteArray* pixels, int width, int height) return true; } -void FELighting::apply(Filter* filter) +void FELighting::apply() { FilterEffect* in = inputEffect(0); - in->apply(filter); + in->apply(); if (!in->resultImage()) return; - if (!effectContext(filter)) + if (!effectContext()) return; setIsAlphaImage(false); diff --git a/WebCore/platform/graphics/filters/FELighting.h b/WebCore/platform/graphics/filters/FELighting.h index c0f62ab..fa1c0aa 100644 --- a/WebCore/platform/graphics/filters/FELighting.h +++ b/WebCore/platform/graphics/filters/FELighting.h @@ -40,9 +40,9 @@ namespace WebCore { class FELighting : public FilterEffect { public: - virtual void apply(Filter*); + virtual void apply(); - virtual void determineAbsolutePaintRect(Filter*) { setAbsolutePaintRect(maxEffectRect()); } + virtual void determineAbsolutePaintRect() { setAbsolutePaintRect(maxEffectRect()); } protected: enum LightingType { @@ -69,7 +69,7 @@ protected: inline void bottomRight(int offset, IntPoint& normalVector); }; - FELighting(LightingType, const Color&, float, float, float, float, float, float, PassRefPtr<LightSource>); + FELighting(Filter*, LightingType, const Color&, float, float, float, float, float, float, PassRefPtr<LightSource>); bool drawLighting(ByteArray*, int, int); inline void inlineSetPixel(int offset, LightingData&, LightSource::PaintingData&, diff --git a/WebCore/platform/graphics/filters/FEMerge.cpp b/WebCore/platform/graphics/filters/FEMerge.cpp index b136af3..ca53a86 100644 --- a/WebCore/platform/graphics/filters/FEMerge.cpp +++ b/WebCore/platform/graphics/filters/FEMerge.cpp @@ -29,28 +29,28 @@ namespace WebCore { -FEMerge::FEMerge() - : FilterEffect() +FEMerge::FEMerge(Filter* filter) + : FilterEffect(filter) { } -PassRefPtr<FEMerge> FEMerge::create() +PassRefPtr<FEMerge> FEMerge::create(Filter* filter) { - return adoptRef(new FEMerge); + return adoptRef(new FEMerge(filter)); } -void FEMerge::apply(Filter* filter) +void FEMerge::apply() { unsigned size = numberOfEffectInputs(); ASSERT(size > 0); for (unsigned i = 0; i < size; ++i) { FilterEffect* in = inputEffect(i); - in->apply(filter); + in->apply(); if (!in->resultImage()) return; } - GraphicsContext* filterContext = effectContext(filter); + GraphicsContext* filterContext = effectContext(); if (!filterContext) return; diff --git a/WebCore/platform/graphics/filters/FEMerge.h b/WebCore/platform/graphics/filters/FEMerge.h index 46b882f..24d071e 100644 --- a/WebCore/platform/graphics/filters/FEMerge.h +++ b/WebCore/platform/graphics/filters/FEMerge.h @@ -31,15 +31,15 @@ namespace WebCore { class FEMerge : public FilterEffect { public: - static PassRefPtr<FEMerge> create(); + static PassRefPtr<FEMerge> create(Filter*); - virtual void apply(Filter*); + virtual void apply(); virtual void dump(); virtual TextStream& externalRepresentation(TextStream&, int indention) const; private: - FEMerge(); + FEMerge(Filter*); }; } // namespace WebCore diff --git a/WebCore/platform/graphics/filters/FEMorphology.cpp b/WebCore/platform/graphics/filters/FEMorphology.cpp index 0b67f9a..dd7659a 100644 --- a/WebCore/platform/graphics/filters/FEMorphology.cpp +++ b/WebCore/platform/graphics/filters/FEMorphology.cpp @@ -36,17 +36,17 @@ using std::max; namespace WebCore { -FEMorphology::FEMorphology(MorphologyOperatorType type, float radiusX, float radiusY) - : FilterEffect() +FEMorphology::FEMorphology(Filter* filter, MorphologyOperatorType type, float radiusX, float radiusY) + : FilterEffect(filter) , m_type(type) , m_radiusX(radiusX) , m_radiusY(radiusY) { } -PassRefPtr<FEMorphology> FEMorphology::create(MorphologyOperatorType type, float radiusX, float radiusY) +PassRefPtr<FEMorphology> FEMorphology::create(Filter* filter, MorphologyOperatorType type, float radiusX, float radiusY) { - return adoptRef(new FEMorphology(type, radiusX, radiusY)); + return adoptRef(new FEMorphology(filter, type, radiusX, radiusY)); } MorphologyOperatorType FEMorphology::morphologyOperator() const @@ -74,9 +74,10 @@ float FEMorphology::radiusY() const return m_radiusY; } -void FEMorphology::determineAbsolutePaintRect(Filter* filter) +void FEMorphology::determineAbsolutePaintRect() { FloatRect paintRect = inputEffect(0)->absolutePaintRect(); + Filter* filter = this->filter(); paintRect.inflateX(filter->applyHorizontalScale(m_radiusX)); paintRect.inflateY(filter->applyVerticalScale(m_radiusY)); paintRect.intersect(maxEffectRect()); @@ -88,20 +89,21 @@ void FEMorphology::setRadiusY(float radiusY) m_radiusY = radiusY; } -void FEMorphology::apply(Filter* filter) +void FEMorphology::apply() { FilterEffect* in = inputEffect(0); - in->apply(filter); + in->apply(); if (!in->resultImage()) return; - if (!effectContext(filter)) + if (!effectContext()) return; setIsAlphaImage(in->isAlphaImage()); if (m_radiusX <= 0 || m_radiusY <= 0) return; + Filter* filter = this->filter(); int radiusX = static_cast<int>(floorf(filter->applyHorizontalScale(m_radiusX))); int radiusY = static_cast<int>(floorf(filter->applyVerticalScale(m_radiusY))); diff --git a/WebCore/platform/graphics/filters/FEMorphology.h b/WebCore/platform/graphics/filters/FEMorphology.h index 913671d..683e7d0 100644 --- a/WebCore/platform/graphics/filters/FEMorphology.h +++ b/WebCore/platform/graphics/filters/FEMorphology.h @@ -36,7 +36,7 @@ enum MorphologyOperatorType { class FEMorphology : public FilterEffect { public: - static PassRefPtr<FEMorphology> create(MorphologyOperatorType, float radiusX, float radiusY); + static PassRefPtr<FEMorphology> create(Filter*, MorphologyOperatorType, float radiusX, float radiusY); MorphologyOperatorType morphologyOperator() const; void setMorphologyOperator(MorphologyOperatorType); @@ -46,15 +46,15 @@ public: float radiusY() const; void setRadiusY(float); - virtual void apply(Filter*); + virtual void apply(); virtual void dump(); - virtual void determineAbsolutePaintRect(Filter*); + virtual void determineAbsolutePaintRect(); virtual TextStream& externalRepresentation(TextStream&, int indention) const; private: - FEMorphology(MorphologyOperatorType, float radiusX, float radiusY); + FEMorphology(Filter*, MorphologyOperatorType, float radiusX, float radiusY); MorphologyOperatorType m_type; float m_radiusX; diff --git a/WebCore/platform/graphics/filters/FEOffset.cpp b/WebCore/platform/graphics/filters/FEOffset.cpp index 6ca56aa..b640054 100644 --- a/WebCore/platform/graphics/filters/FEOffset.cpp +++ b/WebCore/platform/graphics/filters/FEOffset.cpp @@ -31,16 +31,16 @@ namespace WebCore { -FEOffset::FEOffset(float dx, float dy) - : FilterEffect() +FEOffset::FEOffset(Filter* filter, float dx, float dy) + : FilterEffect(filter) , m_dx(dx) , m_dy(dy) { } -PassRefPtr<FEOffset> FEOffset::create(float dx, float dy) +PassRefPtr<FEOffset> FEOffset::create(Filter* filter, float dx, float dy) { - return adoptRef(new FEOffset(dx, dy)); + return adoptRef(new FEOffset(filter, dx, dy)); } float FEOffset::dx() const @@ -63,28 +63,30 @@ void FEOffset::setDy(float dy) m_dy = dy; } -void FEOffset::determineAbsolutePaintRect(Filter* filter) +void FEOffset::determineAbsolutePaintRect() { FloatRect paintRect = inputEffect(0)->absolutePaintRect(); + Filter* filter = this->filter(); paintRect.move(filter->applyHorizontalScale(m_dx), filter->applyVerticalScale(m_dy)); paintRect.intersect(maxEffectRect()); setAbsolutePaintRect(enclosingIntRect(paintRect)); } -void FEOffset::apply(Filter* filter) +void FEOffset::apply() { FilterEffect* in = inputEffect(0); - in->apply(filter); + in->apply(); if (!in->resultImage()) return; - GraphicsContext* filterContext = effectContext(filter); + GraphicsContext* filterContext = effectContext(); if (!filterContext) return; setIsAlphaImage(in->isAlphaImage()); FloatRect drawingRegion = drawingRegionOfInputImage(in->absolutePaintRect()); + Filter* filter = this->filter(); drawingRegion.move(filter->applyHorizontalScale(m_dx), filter->applyVerticalScale(m_dy)); filterContext->drawImageBuffer(in->resultImage(), ColorSpaceDeviceRGB, drawingRegion); } diff --git a/WebCore/platform/graphics/filters/FEOffset.h b/WebCore/platform/graphics/filters/FEOffset.h index 36575c5..5aa5c38 100644 --- a/WebCore/platform/graphics/filters/FEOffset.h +++ b/WebCore/platform/graphics/filters/FEOffset.h @@ -30,7 +30,7 @@ namespace WebCore { class FEOffset : public FilterEffect { public: - static PassRefPtr<FEOffset> create(float dx, float dy); + static PassRefPtr<FEOffset> create(Filter*, float dx, float dy); float dx() const; void setDx(float); @@ -38,15 +38,15 @@ public: float dy() const; void setDy(float); - virtual void apply(Filter*); + virtual void apply(); virtual void dump(); - virtual void determineAbsolutePaintRect(Filter*); + virtual void determineAbsolutePaintRect(); virtual TextStream& externalRepresentation(TextStream&, int indention) const; private: - FEOffset(float dx, float dy); + FEOffset(Filter*, float dx, float dy); float m_dx; float m_dy; diff --git a/WebCore/platform/graphics/filters/FESpecularLighting.cpp b/WebCore/platform/graphics/filters/FESpecularLighting.cpp index 2606600..d21dafd 100644 --- a/WebCore/platform/graphics/filters/FESpecularLighting.cpp +++ b/WebCore/platform/graphics/filters/FESpecularLighting.cpp @@ -28,18 +28,18 @@ namespace WebCore { -FESpecularLighting::FESpecularLighting(const Color& lightingColor, float surfaceScale, +FESpecularLighting::FESpecularLighting(Filter* filter, const Color& lightingColor, float surfaceScale, float specularConstant, float specularExponent, float kernelUnitLengthX, float kernelUnitLengthY, PassRefPtr<LightSource> lightSource) - : FELighting(SpecularLighting, lightingColor, surfaceScale, 0, specularConstant, specularExponent, kernelUnitLengthX, kernelUnitLengthY, lightSource) + : FELighting(filter, SpecularLighting, lightingColor, surfaceScale, 0, specularConstant, specularExponent, kernelUnitLengthX, kernelUnitLengthY, lightSource) { } -PassRefPtr<FESpecularLighting> FESpecularLighting::create(const Color& lightingColor, +PassRefPtr<FESpecularLighting> FESpecularLighting::create(Filter* filter, const Color& lightingColor, float surfaceScale, float specularConstant, float specularExponent, float kernelUnitLengthX, float kernelUnitLengthY, PassRefPtr<LightSource> lightSource) { - return adoptRef(new FESpecularLighting(lightingColor, surfaceScale, specularConstant, specularExponent, + return adoptRef(new FESpecularLighting(filter, lightingColor, surfaceScale, specularConstant, specularExponent, kernelUnitLengthX, kernelUnitLengthY, lightSource)); } diff --git a/WebCore/platform/graphics/filters/FESpecularLighting.h b/WebCore/platform/graphics/filters/FESpecularLighting.h index f6e7b66..b3ccfbc 100644 --- a/WebCore/platform/graphics/filters/FESpecularLighting.h +++ b/WebCore/platform/graphics/filters/FESpecularLighting.h @@ -29,7 +29,7 @@ namespace WebCore { class FESpecularLighting : public FELighting { public: - static PassRefPtr<FESpecularLighting> create(const Color&, float, float, + static PassRefPtr<FESpecularLighting> create(Filter*, const Color&, float, float, float, float, float, PassRefPtr<LightSource>); virtual ~FESpecularLighting(); @@ -59,7 +59,7 @@ public: virtual TextStream& externalRepresentation(TextStream&, int indention) const; private: - FESpecularLighting(const Color&, float, float, float, float, float, PassRefPtr<LightSource>); + FESpecularLighting(Filter*, const Color&, float, float, float, float, float, PassRefPtr<LightSource>); }; } // namespace WebCore diff --git a/WebCore/platform/graphics/filters/FETile.cpp b/WebCore/platform/graphics/filters/FETile.cpp index 57160ed..6b11401 100644 --- a/WebCore/platform/graphics/filters/FETile.cpp +++ b/WebCore/platform/graphics/filters/FETile.cpp @@ -31,26 +31,26 @@ namespace WebCore { -FETile::FETile() - : FilterEffect() +FETile::FETile(Filter* filter) + : FilterEffect(filter) { } -PassRefPtr<FETile> FETile::create() +PassRefPtr<FETile> FETile::create(Filter* filter) { - return adoptRef(new FETile); + return adoptRef(new FETile(filter)); } -void FETile::apply(Filter* filter) +void FETile::apply() { // FIXME: See bug 47315. This is a hack to work around a compile failure, but is incorrect behavior otherwise. #if ENABLE(SVG) FilterEffect* in = inputEffect(0); - in->apply(filter); + in->apply(); if (!in->resultImage()) return; - GraphicsContext* filterContext = effectContext(filter); + GraphicsContext* filterContext = effectContext(); if (!filterContext) return; @@ -62,6 +62,7 @@ void FETile::apply(Filter* filter) FloatPoint inMaxEffectLocation = tileRect.location(); FloatPoint maxEffectLocation = maxEffectRect().location(); if (in->filterEffectType() == FilterEffectTypeSourceInput) { + Filter* filter = this->filter(); tileRect = filter->filterRegion(); tileRect.scale(filter->filterResolution().width(), filter->filterResolution().height()); } diff --git a/WebCore/platform/graphics/filters/FETile.h b/WebCore/platform/graphics/filters/FETile.h index 5f21433..9b02b4c 100644 --- a/WebCore/platform/graphics/filters/FETile.h +++ b/WebCore/platform/graphics/filters/FETile.h @@ -30,19 +30,19 @@ namespace WebCore { class FETile : public FilterEffect { public: - static PassRefPtr<FETile> create(); + static PassRefPtr<FETile> create(Filter* filter); - virtual void apply(Filter*); + virtual void apply(); virtual void dump(); - virtual void determineAbsolutePaintRect(Filter*) { setAbsolutePaintRect(maxEffectRect()); } + virtual void determineAbsolutePaintRect() { setAbsolutePaintRect(maxEffectRect()); } virtual FilterEffectType filterEffectType() const { return FilterEffectTypeTile; } virtual TextStream& externalRepresentation(TextStream&, int indention) const; private: - FETile(); + FETile(Filter*); }; } // namespace WebCore diff --git a/WebCore/platform/graphics/filters/FETurbulence.cpp b/WebCore/platform/graphics/filters/FETurbulence.cpp index 9ad27cf..8914db7 100644 --- a/WebCore/platform/graphics/filters/FETurbulence.cpp +++ b/WebCore/platform/graphics/filters/FETurbulence.cpp @@ -47,8 +47,8 @@ static const int s_randAmplitude = 16807; // 7**5; primitive root of m static const int s_randQ = 127773; // m / a static const int s_randR = 2836; // m % a -FETurbulence::FETurbulence(TurbulanceType type, float baseFrequencyX, float baseFrequencyY, int numOctaves, float seed, bool stitchTiles) - : FilterEffect() +FETurbulence::FETurbulence(Filter* filter, TurbulanceType type, float baseFrequencyX, float baseFrequencyY, int numOctaves, float seed, bool stitchTiles) + : FilterEffect(filter) , m_type(type) , m_baseFrequencyX(baseFrequencyX) , m_baseFrequencyY(baseFrequencyY) @@ -58,9 +58,9 @@ FETurbulence::FETurbulence(TurbulanceType type, float baseFrequencyX, float base { } -PassRefPtr<FETurbulence> FETurbulence::create(TurbulanceType type, float baseFrequencyX, float baseFrequencyY, int numOctaves, float seed, bool stitchTiles) +PassRefPtr<FETurbulence> FETurbulence::create(Filter* filter, TurbulanceType type, float baseFrequencyX, float baseFrequencyY, int numOctaves, float seed, bool stitchTiles) { - return adoptRef(new FETurbulence(type, baseFrequencyX, baseFrequencyY, numOctaves, seed, stitchTiles)); + return adoptRef(new FETurbulence(filter, type, baseFrequencyX, baseFrequencyY, numOctaves, seed, stitchTiles)); } TurbulanceType FETurbulence::type() const @@ -318,9 +318,9 @@ unsigned char FETurbulence::calculateTurbulenceValueForPoint(PaintingData& paint return static_cast<unsigned char>(turbulenceFunctionResult * 255); } -void FETurbulence::apply(Filter* filter) +void FETurbulence::apply() { - if (!effectContext(filter)) + if (!effectContext()) return; IntRect imageRect(IntPoint(), resultImage()->size()); @@ -342,7 +342,7 @@ void FETurbulence::apply(Filter* filter) for (int x = 0; x < imageRect.width(); ++x) { point.setX(point.x() + 1); for (paintingData.channel = 0; paintingData.channel < 4; ++paintingData.channel, ++indexOfPixelChannel) - pixelArray->set(indexOfPixelChannel, calculateTurbulenceValueForPoint(paintingData, filter->mapAbsolutePointToLocalPoint(point))); + pixelArray->set(indexOfPixelChannel, calculateTurbulenceValueForPoint(paintingData, filter()->mapAbsolutePointToLocalPoint(point))); } } resultImage()->putUnmultipliedImageData(imageData.get(), imageRect, IntPoint()); diff --git a/WebCore/platform/graphics/filters/FETurbulence.h b/WebCore/platform/graphics/filters/FETurbulence.h index c15d7d1..1bad123 100644 --- a/WebCore/platform/graphics/filters/FETurbulence.h +++ b/WebCore/platform/graphics/filters/FETurbulence.h @@ -38,7 +38,7 @@ enum TurbulanceType { class FETurbulence : public FilterEffect { public: - static PassRefPtr<FETurbulence> create(TurbulanceType, float, float, int, float, bool); + static PassRefPtr<FETurbulence> create(Filter*, TurbulanceType, float, float, int, float, bool); TurbulanceType type() const; void setType(TurbulanceType); @@ -58,10 +58,10 @@ public: bool stitchTiles() const; void setStitchTiles(bool); - virtual void apply(Filter*); + virtual void apply(); virtual void dump(); - virtual void determineAbsolutePaintRect(Filter*) { setAbsolutePaintRect(maxEffectRect()); } + virtual void determineAbsolutePaintRect() { setAbsolutePaintRect(maxEffectRect()); } virtual TextStream& externalRepresentation(TextStream&, int indention) const; @@ -84,7 +84,7 @@ private: inline long random(); }; - FETurbulence(TurbulanceType, float, float, int, float, bool); + FETurbulence(Filter*, TurbulanceType, float, float, int, float, bool); inline void initPaint(PaintingData&); float noise2D(PaintingData&, const FloatPoint&); diff --git a/WebCore/platform/graphics/filters/FilterEffect.cpp b/WebCore/platform/graphics/filters/FilterEffect.cpp index ad351a5..c228731 100644 --- a/WebCore/platform/graphics/filters/FilterEffect.cpp +++ b/WebCore/platform/graphics/filters/FilterEffect.cpp @@ -26,20 +26,22 @@ namespace WebCore { -FilterEffect::FilterEffect() +FilterEffect::FilterEffect(Filter* filter) : m_alphaImage(false) + , m_filter(filter) , m_hasX(false) , m_hasY(false) , m_hasWidth(false) , m_hasHeight(false) { + ASSERT(m_filter); } FilterEffect::~FilterEffect() { } -void FilterEffect::determineAbsolutePaintRect(Filter*) +void FilterEffect::determineAbsolutePaintRect() { m_absolutePaintRect = IntRect(); unsigned size = m_inputEffects.size(); @@ -70,9 +72,9 @@ FilterEffect* FilterEffect::inputEffect(unsigned number) const return m_inputEffects.at(number).get(); } -GraphicsContext* FilterEffect::effectContext(Filter* filter) +GraphicsContext* FilterEffect::effectContext() { - determineAbsolutePaintRect(filter); + determineAbsolutePaintRect(); if (m_absolutePaintRect.isEmpty()) return 0; m_effectBuffer = ImageBuffer::create(m_absolutePaintRect.size(), ColorSpaceLinearRGB); diff --git a/WebCore/platform/graphics/filters/FilterEffect.h b/WebCore/platform/graphics/filters/FilterEffect.h index 25db57b..f9674e2 100644 --- a/WebCore/platform/graphics/filters/FilterEffect.h +++ b/WebCore/platform/graphics/filters/FilterEffect.h @@ -56,7 +56,7 @@ public: // Creates the ImageBuffer for the current filter primitive result in the size of the // repaintRect. Gives back the GraphicsContext of the own ImageBuffer. - GraphicsContext* effectContext(Filter*); + GraphicsContext* effectContext(); FilterEffectVector& inputEffects() { return m_inputEffects; } FilterEffect* inputEffect(unsigned) const; @@ -75,10 +75,10 @@ public: IntRect maxEffectRect() const { return m_maxEffectRect; } void setMaxEffectRect(const IntRect& maxEffectRect) { m_maxEffectRect = maxEffectRect; } - virtual void apply(Filter*) = 0; + virtual void apply() = 0; virtual void dump() = 0; - virtual void determineAbsolutePaintRect(Filter*); + virtual void determineAbsolutePaintRect(); virtual FilterEffectType filterEffectType() const { return FilterEffectTypeUnknown; } @@ -105,8 +105,10 @@ public: FloatRect effectBoundaries() const { return m_effectBoundaries; } void setEffectBoundaries(const FloatRect& effectBoundaries) { m_effectBoundaries = effectBoundaries; } + Filter* filter() { return m_filter; } + protected: - FilterEffect(); + FilterEffect(Filter*); private: OwnPtr<ImageBuffer> m_effectBuffer; @@ -119,6 +121,7 @@ private: // The maximum size of a filter primitive. In SVG this is the primitive subregion in absolute coordinate space. // The absolute paint rect should never be bigger than m_maxEffectRect. IntRect m_maxEffectRect; + Filter* m_filter; private: // The following member variables are SVG specific and will move to RenderSVGResourceFilterPrimitive. diff --git a/WebCore/platform/graphics/filters/SourceAlpha.cpp b/WebCore/platform/graphics/filters/SourceAlpha.cpp index 7dc56d9..a505b4b 100644 --- a/WebCore/platform/graphics/filters/SourceAlpha.cpp +++ b/WebCore/platform/graphics/filters/SourceAlpha.cpp @@ -31,9 +31,9 @@ namespace WebCore { -PassRefPtr<SourceAlpha> SourceAlpha::create() +PassRefPtr<SourceAlpha> SourceAlpha::create(Filter* filter) { - return adoptRef(new SourceAlpha); + return adoptRef(new SourceAlpha(filter)); } const AtomicString& SourceAlpha::effectName() @@ -42,16 +42,18 @@ const AtomicString& SourceAlpha::effectName() return s_effectName; } -void SourceAlpha::determineAbsolutePaintRect(Filter* filter) +void SourceAlpha::determineAbsolutePaintRect() { + Filter* filter = this->filter(); FloatRect paintRect = filter->sourceImageRect(); paintRect.scale(filter->filterResolution().width(), filter->filterResolution().height()); setAbsolutePaintRect(enclosingIntRect(paintRect)); } -void SourceAlpha::apply(Filter* filter) +void SourceAlpha::apply() { - GraphicsContext* filterContext = effectContext(filter); + GraphicsContext* filterContext = effectContext(); + Filter* filter = this->filter(); if (!filterContext || !filter->sourceImage()) return; diff --git a/WebCore/platform/graphics/filters/SourceAlpha.h b/WebCore/platform/graphics/filters/SourceAlpha.h index 83704e5..c6f95d3 100644 --- a/WebCore/platform/graphics/filters/SourceAlpha.h +++ b/WebCore/platform/graphics/filters/SourceAlpha.h @@ -30,21 +30,24 @@ namespace WebCore { class SourceAlpha : public FilterEffect { public: - static PassRefPtr<SourceAlpha> create(); + static PassRefPtr<SourceAlpha> create(Filter*); static const AtomicString& effectName(); - virtual void apply(Filter*); + virtual void apply(); virtual void dump(); - virtual void determineAbsolutePaintRect(Filter*); + virtual void determineAbsolutePaintRect(); virtual FilterEffectType filterEffectType() const { return FilterEffectTypeSourceInput; } virtual TextStream& externalRepresentation(TextStream&, int indention) const; private: - SourceAlpha() { } + SourceAlpha(Filter* filter) + : FilterEffect(filter) + { + } }; } //namespace WebCore diff --git a/WebCore/platform/graphics/filters/SourceGraphic.cpp b/WebCore/platform/graphics/filters/SourceGraphic.cpp index fbb711a..6aac367 100644 --- a/WebCore/platform/graphics/filters/SourceGraphic.cpp +++ b/WebCore/platform/graphics/filters/SourceGraphic.cpp @@ -30,9 +30,9 @@ namespace WebCore { -PassRefPtr<SourceGraphic> SourceGraphic::create() +PassRefPtr<SourceGraphic> SourceGraphic::create(Filter* filter) { - return adoptRef(new SourceGraphic); + return adoptRef(new SourceGraphic(filter)); } const AtomicString& SourceGraphic::effectName() @@ -41,16 +41,18 @@ const AtomicString& SourceGraphic::effectName() return s_effectName; } -void SourceGraphic::determineAbsolutePaintRect(Filter* filter) +void SourceGraphic::determineAbsolutePaintRect() { + Filter* filter = this->filter(); FloatRect paintRect = filter->sourceImageRect(); paintRect.scale(filter->filterResolution().width(), filter->filterResolution().height()); setAbsolutePaintRect(enclosingIntRect(paintRect)); } -void SourceGraphic::apply(Filter* filter) +void SourceGraphic::apply() { - GraphicsContext* filterContext = effectContext(filter); + GraphicsContext* filterContext = effectContext(); + Filter* filter = this->filter(); if (!filterContext || !filter->sourceImage()) return; diff --git a/WebCore/platform/graphics/filters/SourceGraphic.h b/WebCore/platform/graphics/filters/SourceGraphic.h index a13337d..fa47f12 100644 --- a/WebCore/platform/graphics/filters/SourceGraphic.h +++ b/WebCore/platform/graphics/filters/SourceGraphic.h @@ -31,21 +31,24 @@ namespace WebCore { class SourceGraphic : public FilterEffect { public: - static PassRefPtr<SourceGraphic> create(); + static PassRefPtr<SourceGraphic> create(Filter*); static const AtomicString& effectName(); - virtual void apply(Filter*); + virtual void apply(); virtual void dump(); - virtual void determineAbsolutePaintRect(Filter*); + virtual void determineAbsolutePaintRect(); virtual FilterEffectType filterEffectType() const { return FilterEffectTypeSourceInput; } virtual TextStream& externalRepresentation(TextStream&, int indention) const; private: - SourceGraphic() { } + SourceGraphic(Filter* filter) + : FilterEffect(filter) + { + } }; } //namespace WebCore diff --git a/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp b/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp index 394082d..c0756ee 100644 --- a/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp +++ b/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp @@ -228,7 +228,9 @@ bool FontPlatformData::operator==(const FontPlatformData& other) const return true; if (!m_pattern || !other.m_pattern) return false; - return FcPatternEqual(m_pattern.get(), other.m_pattern.get()); + return FcPatternEqual(m_pattern.get(), other.m_pattern.get()) + && m_scaledFont == other.m_scaledFont && m_size == other.m_size + && m_syntheticOblique == other.m_syntheticOblique && m_syntheticBold == other.m_syntheticBold; } #ifndef NDEBUG diff --git a/WebCore/platform/graphics/gpu/DrawingBuffer.cpp b/WebCore/platform/graphics/gpu/DrawingBuffer.cpp index d812e28..8cb6d0c 100644 --- a/WebCore/platform/graphics/gpu/DrawingBuffer.cpp +++ b/WebCore/platform/graphics/gpu/DrawingBuffer.cpp @@ -167,20 +167,29 @@ void DrawingBuffer::reset(const IntSize& newSize) m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO); // Initialize renderbuffers to 0. - unsigned char colorMask[] = {true, true, true, true}, depthMask = true, stencilMask = true; + float clearColor[] = {0, 0, 0, 0}, clearDepth = 0; + int clearStencil = 0; + unsigned char colorMask[] = {true, true, true, true}, depthMask = true; + unsigned int stencilMask = 0xffffffff; unsigned char isScissorEnabled = false; unsigned char isDitherEnabled = false; unsigned long clearMask = GraphicsContext3D::COLOR_BUFFER_BIT; + m_context->getFloatv(GraphicsContext3D::COLOR_CLEAR_VALUE, clearColor); + m_context->clearColor(0, 0, 0, 0); m_context->getBooleanv(GraphicsContext3D::COLOR_WRITEMASK, colorMask); m_context->colorMask(true, true, true, true); if (attributes.depth) { + m_context->getFloatv(GraphicsContext3D::DEPTH_CLEAR_VALUE, &clearDepth); + m_context->clearDepth(1); m_context->getBooleanv(GraphicsContext3D::DEPTH_WRITEMASK, &depthMask); m_context->depthMask(true); clearMask |= GraphicsContext3D::DEPTH_BUFFER_BIT; } if (attributes.stencil) { - m_context->getBooleanv(GraphicsContext3D::STENCIL_WRITEMASK, &stencilMask); - m_context->stencilMask(true); + m_context->getIntegerv(GraphicsContext3D::STENCIL_CLEAR_VALUE, &clearStencil); + m_context->clearStencil(0); + m_context->getIntegerv(GraphicsContext3D::STENCIL_WRITEMASK, reinterpret_cast<int*>(&stencilMask)); + m_context->stencilMaskSeparate(GraphicsContext3D::FRONT, 0xffffffff); clearMask |= GraphicsContext3D::STENCIL_BUFFER_BIT; } isScissorEnabled = m_context->isEnabled(GraphicsContext3D::SCISSOR_TEST); @@ -190,11 +199,16 @@ void DrawingBuffer::reset(const IntSize& newSize) m_context->clear(clearMask); + m_context->clearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]); m_context->colorMask(colorMask[0], colorMask[1], colorMask[2], colorMask[3]); - if (attributes.depth) + if (attributes.depth) { + m_context->clearDepth(clearDepth); m_context->depthMask(depthMask); - if (attributes.stencil) - m_context->stencilMask(stencilMask); + } + if (attributes.stencil) { + m_context->clearStencil(clearStencil); + m_context->stencilMaskSeparate(GraphicsContext3D::FRONT, stencilMask); + } if (isScissorEnabled) m_context->enable(GraphicsContext3D::SCISSOR_TEST); else diff --git a/WebCore/platform/graphics/gstreamer/GStreamerGWorld.cpp b/WebCore/platform/graphics/gstreamer/GStreamerGWorld.cpp index 1cb561e..b18bf84 100644 --- a/WebCore/platform/graphics/gstreamer/GStreamerGWorld.cpp +++ b/WebCore/platform/graphics/gstreamer/GStreamerGWorld.cpp @@ -87,6 +87,9 @@ bool GStreamerGWorld::enterFullscreen() GOwnPtr<GstElement> videoSink; g_object_get(m_pipeline, "video-sink", &videoSink.outPtr(), NULL); GstElement* tee = gst_bin_get_by_name(GST_BIN(videoSink.get()), "videoTee"); + GstElement* valve = gst_bin_get_by_name(GST_BIN(videoSink.get()), "videoValve"); + + g_object_set(valve, "drop-probability", 1.0, NULL); // Add and link a queue, ffmpegcolorspace and sink in the bin. gst_bin_add_many(GST_BIN(videoSink.get()), platformVideoSink, videoScale, colorspace, queue, NULL); @@ -158,6 +161,10 @@ void GStreamerGWorld::exitFullscreen() GstElement* colorspace = gst_bin_get_by_name(GST_BIN(videoSink.get()), "colorspace"); GstElement* videoScale = gst_bin_get_by_name(GST_BIN(videoSink.get()), "videoScale"); + GstElement* valve = gst_bin_get_by_name(GST_BIN(videoSink.get()), "videoValve"); + + g_object_set(valve, "drop-probability", 0.0, NULL); + // Get pads to unlink and remove. GstPad* srcPad = gst_element_get_static_pad(tee, m_dynamicPadName); GstPad* sinkPad = gst_element_get_static_pad(queue, "sink"); diff --git a/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp b/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp index 7012c9f..dbef4c9 100644 --- a/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp +++ b/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp @@ -177,6 +177,13 @@ void mediaPlayerPrivateVolumeChangedCallback(GObject *element, GParamSpec *pspec mp->volumeChanged(); } +gboolean mediaPlayerPrivateVolumeChangeTimeoutCallback(MediaPlayerPrivateGStreamer* player) +{ + // This is the callback of the timeout source created in ::volumeChanged. + player->notifyPlayerOfVolumeChange(); + return FALSE; +} + void mediaPlayerPrivateMuteChangedCallback(GObject *element, GParamSpec *pspec, gpointer data) { // This is called when playbin receives the notify::mute signal. @@ -184,6 +191,13 @@ void mediaPlayerPrivateMuteChangedCallback(GObject *element, GParamSpec *pspec, mp->muteChanged(); } +gboolean mediaPlayerPrivateMuteChangeTimeoutCallback(MediaPlayerPrivateGStreamer* player) +{ + // This is the callback of the timeout source created in ::muteChanged. + player->notifyPlayerOfMute(); + return FALSE; +} + static float playbackPosition(GstElement* playbin) { @@ -327,8 +341,18 @@ MediaPlayerPrivateGStreamer::~MediaPlayerPrivateGStreamer() if (m_playBin) { gst_element_set_state(m_playBin, GST_STATE_NULL); gst_object_unref(GST_OBJECT(m_playBin)); + m_playBin = 0; } + m_player = 0; + + if (m_muteTimerHandler) + g_source_remove(m_muteTimerHandler); + m_muteTimerHandler = 0; + + if (m_volumeTimerHandler) + g_source_remove(m_volumeTimerHandler); + m_volumeTimerHandler = 0; } void MediaPlayerPrivateGStreamer::load(const String& url) @@ -584,8 +608,12 @@ void MediaPlayerPrivateGStreamer::setVolume(float volume) g_object_set(m_playBin, "volume", static_cast<double>(volume), NULL); } -void MediaPlayerPrivateGStreamer::volumeChangedTimerFired(Timer<MediaPlayerPrivateGStreamer>*) +void MediaPlayerPrivateGStreamer::notifyPlayerOfVolumeChange() { + m_volumeTimerHandler = 0; + + if (!m_player || !m_playBin) + return; double volume; g_object_get(m_playBin, "volume", &volume, NULL); m_player->volumeChanged(static_cast<float>(volume)); @@ -593,8 +621,9 @@ void MediaPlayerPrivateGStreamer::volumeChangedTimerFired(Timer<MediaPlayerPriva void MediaPlayerPrivateGStreamer::volumeChanged() { - Timer<MediaPlayerPrivateGStreamer> volumeChangedTimer(this, &MediaPlayerPrivateGStreamer::volumeChangedTimerFired); - volumeChangedTimer.startOneShot(0); + if (m_volumeTimerHandler) + g_source_remove(m_volumeTimerHandler); + m_volumeTimerHandler = g_timeout_add(0, reinterpret_cast<GSourceFunc>(mediaPlayerPrivateVolumeChangeTimeoutCallback), this); } void MediaPlayerPrivateGStreamer::setRate(float rate) @@ -1158,8 +1187,13 @@ void MediaPlayerPrivateGStreamer::setMuted(bool muted) g_object_set(m_playBin, "mute", muted, NULL); } -void MediaPlayerPrivateGStreamer::muteChangedTimerFired(Timer<MediaPlayerPrivateGStreamer>*) +void MediaPlayerPrivateGStreamer::notifyPlayerOfMute() { + m_muteTimerHandler = 0; + + if (!m_player || !m_playBin) + return; + gboolean muted; g_object_get(m_playBin, "mute", &muted, NULL); m_player->muteChanged(static_cast<bool>(muted)); @@ -1167,8 +1201,9 @@ void MediaPlayerPrivateGStreamer::muteChangedTimerFired(Timer<MediaPlayerPrivate void MediaPlayerPrivateGStreamer::muteChanged() { - Timer<MediaPlayerPrivateGStreamer> muteChangedTimer(this, &MediaPlayerPrivateGStreamer::muteChangedTimerFired); - muteChangedTimer.startOneShot(0); + if (m_muteTimerHandler) + g_source_remove(m_muteTimerHandler); + m_muteTimerHandler = g_timeout_add(0, reinterpret_cast<GSourceFunc>(mediaPlayerPrivateMuteChangeTimeoutCallback), this); } void MediaPlayerPrivateGStreamer::loadingFailed(MediaPlayer::NetworkState error) @@ -1401,6 +1436,8 @@ void MediaPlayerPrivateGStreamer::createGSTPlayBin() g_signal_connect(bus, "message", G_CALLBACK(mediaPlayerPrivateMessageCallback), this); gst_object_unref(bus); + g_object_set(m_playBin, "mute", m_player->muted(), "volume", m_player->volume(), NULL); + g_signal_connect(m_playBin, "notify::volume", G_CALLBACK(mediaPlayerPrivateVolumeChangedCallback), this); g_signal_connect(m_playBin, "notify::source", G_CALLBACK(mediaPlayerPrivateSourceChangedCallback), this); g_signal_connect(m_playBin, "notify::mute", G_CALLBACK(mediaPlayerPrivateMuteChangedCallback), this); @@ -1412,16 +1449,17 @@ void MediaPlayerPrivateGStreamer::createGSTPlayBin() m_videoSinkBin = gst_bin_new("sink"); GstElement* videoTee = gst_element_factory_make("tee", "videoTee"); GstElement* queue = gst_element_factory_make("queue", 0); + GstElement* identity = gst_element_factory_make("identity", "videoValve"); // Take ownership. - g_object_ref_sink(m_videoSinkBin); + gst_object_ref_sink(m_videoSinkBin); // Build a new video sink consisting of a bin containing a tee // (meant to distribute data to multiple video sinks) and our // internal video sink. For fullscreen we create an autovideosink // and initially block the data flow towards it and configure it - gst_bin_add_many(GST_BIN(m_videoSinkBin), videoTee, queue, NULL); + gst_bin_add_many(GST_BIN(m_videoSinkBin), videoTee, queue, identity, NULL); // Link a new src pad from tee to queue1. GstPad* srcPad = gst_element_get_request_pad(videoTee, "src%d"); @@ -1445,7 +1483,7 @@ void MediaPlayerPrivateGStreamer::createGSTPlayBin() } } else { gst_bin_add(GST_BIN(m_videoSinkBin), m_webkitVideoSink); - gst_element_link(queue, m_webkitVideoSink); + gst_element_link_many(queue, identity, m_webkitVideoSink, NULL); } // Add a ghostpad to the bin so it can proxy to tee. diff --git a/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h b/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h index 800ca6d..23095ec 100644 --- a/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h +++ b/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h @@ -43,11 +43,14 @@ class GraphicsContext; class IntSize; class IntRect; class GStreamerGWorld; +class MediaPlayerPrivateGStreamer; gboolean mediaPlayerPrivateMessageCallback(GstBus* bus, GstMessage* message, gpointer data); void mediaPlayerPrivateVolumeChangedCallback(GObject* element, GParamSpec* pspec, gpointer data); void mediaPlayerPrivateMuteChangedCallback(GObject* element, GParamSpec* pspec, gpointer data); void mediaPlayerPrivateSourceChangedCallback(GObject* element, GParamSpec* pspec, gpointer data); +gboolean mediaPlayerPrivateVolumeChangeTimeoutCallback(MediaPlayerPrivateGStreamer*); +gboolean mediaPlayerPrivateMuteChangeTimeoutCallback(MediaPlayerPrivateGStreamer*); class MediaPlayerPrivateGStreamer : public MediaPlayerPrivateInterface { friend gboolean mediaPlayerPrivateMessageCallback(GstBus* bus, GstMessage* message, gpointer data); @@ -81,12 +84,12 @@ class MediaPlayerPrivateGStreamer : public MediaPlayerPrivateInterface { void setVolume(float); void volumeChanged(); - void volumeChangedTimerFired(Timer<MediaPlayerPrivateGStreamer>*); + void notifyPlayerOfVolumeChange(); bool supportsMuting() const; void setMuted(bool); void muteChanged(); - void muteChangedTimerFired(Timer<MediaPlayerPrivateGStreamer>*); + void notifyPlayerOfMute(); void setPreload(MediaPlayer::Preload); void fillTimerFired(Timer<MediaPlayerPrivateGStreamer>*); @@ -176,6 +179,8 @@ class MediaPlayerPrivateGStreamer : public MediaPlayerPrivateInterface { bool m_delayingLoad; bool m_mediaDurationKnown; RefPtr<GStreamerGWorld> m_gstGWorld; + guint m_volumeTimerHandler; + guint m_muteTimerHandler; }; } diff --git a/WebCore/platform/graphics/haiku/GraphicsContextHaiku.cpp b/WebCore/platform/graphics/haiku/GraphicsContextHaiku.cpp index 6911b31..7dda245 100644 --- a/WebCore/platform/graphics/haiku/GraphicsContextHaiku.cpp +++ b/WebCore/platform/graphics/haiku/GraphicsContextHaiku.cpp @@ -132,7 +132,7 @@ void GraphicsContext::strokeArc(const IntRect& rect, int startAngle, int angleSp m_data->m_view->StrokeArc(rect, startAngle, angleSpan, getHaikuStrokeStyle()); } -void GraphicsContext::strokePath() +void GraphicsContext::strokePath(const Path&) { notImplemented(); } @@ -191,17 +191,7 @@ void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLef // FillRect and FillArc calls are needed. } -void GraphicsContext::fillPath() -{ - notImplemented(); -} - -void GraphicsContext::beginPath() -{ - notImplemented(); -} - -void GraphicsContext::addPath(const Path& path) +void GraphicsContext::fillPath(const Path&) { notImplemented(); } @@ -215,7 +205,7 @@ void GraphicsContext::clip(const FloatRect& rect) m_data->m_view->ConstrainClippingRegion(®ion); } -void GraphicsContext::drawFocusRing(const Vector<Path>& paths, int width, int offset, const Color& color) +void GraphicsContext::drawFocusRing(const Path& path, int width, int offset, const Color& color) { // FIXME: implement } diff --git a/WebCore/platform/graphics/mac/ComplexTextController.cpp b/WebCore/platform/graphics/mac/ComplexTextController.cpp index e6a7bef..d353d55 100644 --- a/WebCore/platform/graphics/mac/ComplexTextController.cpp +++ b/WebCore/platform/graphics/mac/ComplexTextController.cpp @@ -462,7 +462,7 @@ void ComplexTextController::adjustGlyphsAndAdvances() if (ch == '\t' && m_run.allowTabs()) { float tabWidth = m_font.tabWidth(*fontData); advance.width = tabWidth - fmodf(m_run.xPos() + m_totalWidth + widthSinceLastRounding, tabWidth); - } else if (ch == zeroWidthSpace || Font::treatAsZeroWidthSpace(ch) && !treatAsSpace) { + } else if (ch == zeroWidthSpace || (Font::treatAsZeroWidthSpace(ch) && !treatAsSpace)) { advance.width = 0; glyph = fontData->spaceGlyph(); } @@ -518,7 +518,7 @@ void ComplexTextController::adjustGlyphsAndAdvances() // Check to see if the next character is a "rounding hack character", if so, adjust the // width so that the total run width will be on an integer boundary. - if (m_run.applyWordRounding() && !lastGlyph && Font::isRoundingHackCharacter(nextCh) || m_run.applyRunRounding() && lastGlyph) { + if ((m_run.applyWordRounding() && !lastGlyph && Font::isRoundingHackCharacter(nextCh)) || (m_run.applyRunRounding() && lastGlyph)) { CGFloat totalWidth = widthSinceLastRounding + advance.width; widthSinceLastRounding = ceilCGFloat(totalWidth); CGFloat extraWidth = widthSinceLastRounding - totalWidth; diff --git a/WebCore/platform/graphics/mac/ComplexTextControllerATSUI.cpp b/WebCore/platform/graphics/mac/ComplexTextControllerATSUI.cpp index 7ff316c..c24a914 100644 --- a/WebCore/platform/graphics/mac/ComplexTextControllerATSUI.cpp +++ b/WebCore/platform/graphics/mac/ComplexTextControllerATSUI.cpp @@ -280,7 +280,7 @@ static ATSUStyle initializeATSUStyle(const SimpleFontData* fontData, Typesetting if (!addResult.second) return atsuStyle; - ATSUFontID fontID = fontData->platformData().m_atsuFontID; + ATSUFontID fontID = fontData->platformData().ctFont() ? CTFontGetPlatformFont(fontData->platformData().ctFont(), 0) : 0; if (!fontID) { LOG_ERROR("unable to get ATSUFontID for %p", fontData->platformData().font()); fontData->m_ATSUStyleMap.remove(addResult.first); diff --git a/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.cpp b/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.cpp index cbb7610..42e7897 100644 --- a/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.cpp +++ b/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.cpp @@ -138,8 +138,8 @@ void ComplexTextController::collectComplexTextRunsForCharactersCoreText(const UC const short rtlForcedEmbeddingLevelValue = 1; static const void* ltrOptionValues[] = { CFNumberCreate(kCFAllocatorDefault, kCFNumberShortType, <rForcedEmbeddingLevelValue) }; static const void* rtlOptionValues[] = { CFNumberCreate(kCFAllocatorDefault, kCFNumberShortType, &rtlForcedEmbeddingLevelValue) }; - static CFDictionaryRef ltrTypesetterOptions = CFDictionaryCreate(kCFAllocatorDefault, optionKeys, ltrOptionValues, sizeof(optionKeys) / sizeof(*optionKeys), &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); - static CFDictionaryRef rtlTypesetterOptions = CFDictionaryCreate(kCFAllocatorDefault, optionKeys, rtlOptionValues, sizeof(optionKeys) / sizeof(*optionKeys), &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); + static CFDictionaryRef ltrTypesetterOptions = CFDictionaryCreate(kCFAllocatorDefault, optionKeys, ltrOptionValues, WTF_ARRAY_LENGTH(optionKeys), &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); + static CFDictionaryRef rtlTypesetterOptions = CFDictionaryCreate(kCFAllocatorDefault, optionKeys, rtlOptionValues, WTF_ARRAY_LENGTH(optionKeys), &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) ProviderInfo info = { cp, length, fontData->getCFStringAttributes(m_font.typesettingFeatures()) }; diff --git a/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp b/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp index cead71b..d04d0e4 100644 --- a/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp +++ b/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp @@ -40,7 +40,7 @@ FontCustomPlatformData::~FontCustomPlatformData() FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontOrientation orientation, FontRenderingMode) { - return FontPlatformData(m_cgFont, (ATSUFontID)m_atsFont, size, bold, italic, orientation); + return FontPlatformData(m_cgFont, size, bold, italic, orientation); } FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer) @@ -66,7 +66,6 @@ FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer) #endif ATSFontContainerRef containerRef = 0; - ATSFontRef fontRef = 0; RetainPtr<CGFontRef> cgFontRef; @@ -93,6 +92,7 @@ FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer) return 0; } + ATSFontRef fontRef = 0; ATSFontFindFromContainer(containerRef, kATSOptionFlagsDefault, 1, &fontRef, NULL); if (!fontRef) { ATSFontDeactivate(containerRef, NULL, kATSOptionFlagsDefault); @@ -111,7 +111,7 @@ FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer) } #endif // !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) - return new FontCustomPlatformData(containerRef, fontRef, cgFontRef.releaseRef()); + return new FontCustomPlatformData(containerRef, cgFontRef.releaseRef()); } bool FontCustomPlatformData::supportsFormat(const String& format) diff --git a/WebCore/platform/graphics/mac/FontCustomPlatformData.h b/WebCore/platform/graphics/mac/FontCustomPlatformData.h index 7702457..c11858c 100644 --- a/WebCore/platform/graphics/mac/FontCustomPlatformData.h +++ b/WebCore/platform/graphics/mac/FontCustomPlatformData.h @@ -37,9 +37,12 @@ class FontPlatformData; class SharedBuffer; struct FontCustomPlatformData : Noncopyable { - FontCustomPlatformData(ATSFontContainerRef container, ATSFontRef atsFont, CGFontRef cgFont) - : m_atsContainer(container), m_atsFont(atsFont), m_cgFont(cgFont) - {} + FontCustomPlatformData(ATSFontContainerRef container, CGFontRef cgFont) + : m_atsContainer(container) + , m_cgFont(cgFont) + { + } + ~FontCustomPlatformData(); FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontOrientation = Horizontal, FontRenderingMode = NormalRenderingMode); @@ -47,11 +50,10 @@ struct FontCustomPlatformData : Noncopyable { static bool supportsFormat(const String&); ATSFontContainerRef m_atsContainer; - ATSFontRef m_atsFont; CGFontRef m_cgFont; }; -FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer); +FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer*); } diff --git a/WebCore/platform/graphics/mac/GraphicsContextMac.mm b/WebCore/platform/graphics/mac/GraphicsContextMac.mm index 15cae20..c149d70 100644 --- a/WebCore/platform/graphics/mac/GraphicsContextMac.mm +++ b/WebCore/platform/graphics/mac/GraphicsContextMac.mm @@ -57,23 +57,19 @@ static void drawFocusRingToContext(CGContextRef context, CGPathRef focusRingPath #endif } -void GraphicsContext::drawFocusRing(const Vector<Path>& paths, int width, int offset, const Color& color) +void GraphicsContext::drawFocusRing(const Path& path, int width, int /*offset*/, const Color& color) { + // FIXME: Use 'offset' for something? http://webkit.org/b/49909 + if (paintingDisabled()) return; - + int radius = (width - 1) / 2; - offset += radius; CGColorRef colorRef = color.isValid() ? cachedCGColor(color, ColorSpaceDeviceRGB) : 0; - RetainPtr<CGMutablePathRef> focusRingPath(AdoptCF, CGPathCreateMutable()); - unsigned pathCount = paths.size(); - for (unsigned i = 0; i < pathCount; i++) - CGPathAddPath(focusRingPath.get(), 0, paths[i].platformPath()); - - drawFocusRingToContext(platformContext(), focusRingPath.get(), colorRef, radius); -} - + drawFocusRingToContext(platformContext(), path.platformPath(), colorRef, radius); +} + void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int width, int offset, const Color& color) { if (paintingDisabled()) diff --git a/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm b/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm index a2325da..1538e07 100644 --- a/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm +++ b/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm @@ -316,7 +316,7 @@ static void disableComponentsOnce() {'imdc', 'pdf ', 'appl', 0, 0}, }; - for (size_t i = 0; i < sizeof(componentsToDisable)/sizeof(componentsToDisable[0]); ++i) + for (size_t i = 0; i < WTF_ARRAY_LENGTH(componentsToDisable); ++i) wkQTMovieDisableComponent(componentsToDisable[i]); } @@ -896,12 +896,12 @@ void MediaPlayerPrivateQTKit::setPreservesPitch(bool preservesPitch) if ([[m_qtMovie.get() attributeForKey:QTMovieRateChangesPreservePitchAttribute] boolValue] == preservesPitch) return; - NSDictionary *movieAttributes = [[m_qtMovie.get() movieAttributes] mutableCopy]; + RetainPtr<NSDictionary> movieAttributes(AdoptNS, [[m_qtMovie.get() movieAttributes] mutableCopy]); ASSERT(movieAttributes); - [movieAttributes setValue:[NSNumber numberWithBool:preservesPitch] forKey:QTMovieRateChangesPreservePitchAttribute]; + [movieAttributes.get() setValue:[NSNumber numberWithBool:preservesPitch] forKey:QTMovieRateChangesPreservePitchAttribute]; m_timeToRestore = currentTime(); - createQTMovie([movieAttributes valueForKey:QTMovieURLAttribute], movieAttributes); + createQTMovie([movieAttributes.get() valueForKey:QTMovieURLAttribute], movieAttributes.get()); } PassRefPtr<TimeRanges> MediaPlayerPrivateQTKit::buffered() const diff --git a/WebCore/platform/graphics/mac/SimpleFontDataATSUI.mm b/WebCore/platform/graphics/mac/SimpleFontDataATSUI.mm index beea018..4b2e7b2 100644 --- a/WebCore/platform/graphics/mac/SimpleFontDataATSUI.mm +++ b/WebCore/platform/graphics/mac/SimpleFontDataATSUI.mm @@ -48,8 +48,8 @@ void SimpleFontData::checkShapesArabic() const ASSERT(!m_checkedShapesArabic); m_checkedShapesArabic = true; - - ATSUFontID fontID = m_platformData.m_atsuFontID; + + ATSUFontID fontID = m_platformData.ctFont() ? CTFontGetPlatformFont(m_platformData.ctFont(), 0) : 0; if (!fontID) { LOG_ERROR("unable to get ATSUFontID for %@", m_platformData.font()); return; @@ -59,7 +59,7 @@ void SimpleFontData::checkShapesArabic() const // heuristic is that if such a font has a glyph metamorphosis table, then // it includes shaping information for Arabic. FourCharCode tables[] = { 'morx', 'mort' }; - for (unsigned i = 0; i < sizeof(tables) / sizeof(tables[0]); ++i) { + for (size_t i = 0; i < WTF_ARRAY_LENGTH(tables); ++i) { ByteCount tableSize; OSStatus status = ATSFontGetTable(fontID, tables[i], 0, 0, 0, &tableSize); if (status == noErr) { diff --git a/WebCore/platform/graphics/mac/SimpleFontDataCoreText.cpp b/WebCore/platform/graphics/mac/SimpleFontDataCoreText.cpp index db6de49..452bd54 100644 --- a/WebCore/platform/graphics/mac/SimpleFontDataCoreText.cpp +++ b/WebCore/platform/graphics/mac/SimpleFontDataCoreText.cpp @@ -62,15 +62,13 @@ CFDictionaryRef SimpleFontData::getCFStringAttributes(TypesettingFeatures typese const void* valuesWithKerningDisabled[] = { platformData().ctFont(), kerningAdjustment, allowLigatures ? ligaturesAllowed : ligaturesNotAllowed, orientation() == Vertical ? kCFBooleanTrue : kCFBooleanFalse }; attributesDictionary.adoptCF(CFDictionaryCreate(0, keysWithKerningDisabled, valuesWithKerningDisabled, - sizeof(keysWithKerningDisabled) / sizeof(*keysWithKerningDisabled), - &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); + WTF_ARRAY_LENGTH(keysWithKerningDisabled), &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); } else { // By omitting the kCTKernAttributeName attribute, we get Core Text's standard kerning. static const void* keysWithKerningEnabled[] = { kCTFontAttributeName, kCTLigatureAttributeName, kCTVerticalFormsAttributeName }; const void* valuesWithKerningEnabled[] = { platformData().ctFont(), allowLigatures ? ligaturesAllowed : ligaturesNotAllowed, orientation() == Vertical ? kCFBooleanTrue : kCFBooleanFalse }; attributesDictionary.adoptCF(CFDictionaryCreate(0, keysWithKerningEnabled, valuesWithKerningEnabled, - sizeof(keysWithKerningEnabled) / sizeof(*keysWithKerningEnabled), - &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); + WTF_ARRAY_LENGTH(keysWithKerningEnabled), &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); } return attributesDictionary.get(); diff --git a/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp b/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp index 85089a0..d295abb 100644 --- a/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp +++ b/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp @@ -211,20 +211,29 @@ void GraphicsContext3D::reshape(int width, int height) } // Initialize renderbuffers to 0. - GLboolean colorMask[] = {GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE}, depthMask = GL_TRUE, stencilMask = GL_TRUE; + GLfloat clearColor[] = {0, 0, 0, 0}, clearDepth = 0; + GLint clearStencil = 0; + GLboolean colorMask[] = {GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE}, depthMask = GL_TRUE; + GLuint stencilMask = 0xffffffff; GLboolean isScissorEnabled = GL_FALSE; GLboolean isDitherEnabled = GL_FALSE; GLbitfield clearMask = GL_COLOR_BUFFER_BIT; + ::glGetFloatv(GL_COLOR_CLEAR_VALUE, clearColor); + ::glClearColor(0, 0, 0, 0); ::glGetBooleanv(GL_COLOR_WRITEMASK, colorMask); ::glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); if (m_attrs.depth) { + ::glGetFloatv(GL_DEPTH_CLEAR_VALUE, &clearDepth); + ::glClearDepth(1); ::glGetBooleanv(GL_DEPTH_WRITEMASK, &depthMask); ::glDepthMask(GL_TRUE); clearMask |= GL_DEPTH_BUFFER_BIT; } if (m_attrs.stencil) { - ::glGetBooleanv(GL_STENCIL_WRITEMASK, &stencilMask); - ::glStencilMask(GL_TRUE); + ::glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &clearStencil); + ::glClearStencil(0); + ::glGetIntegerv(GL_STENCIL_WRITEMASK, reinterpret_cast<GLint*>(&stencilMask)); + ::glStencilMaskSeparate(GL_FRONT, 0xffffffff); clearMask |= GL_STENCIL_BUFFER_BIT; } isScissorEnabled = ::glIsEnabled(GL_SCISSOR_TEST); @@ -234,11 +243,16 @@ void GraphicsContext3D::reshape(int width, int height) ::glClear(clearMask); + ::glClearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]); ::glColorMask(colorMask[0], colorMask[1], colorMask[2], colorMask[3]); - if (m_attrs.depth) + if (m_attrs.depth) { + ::glClearDepth(clearDepth); ::glDepthMask(depthMask); - if (m_attrs.stencil) - ::glStencilMask(stencilMask); + } + if (m_attrs.stencil) { + ::glClearStencil(clearStencil); + ::glStencilMaskSeparate(GL_FRONT, stencilMask); + } if (isScissorEnabled) ::glEnable(GL_SCISSOR_TEST); else diff --git a/WebCore/platform/graphics/openvg/GraphicsContextOpenVG.cpp b/WebCore/platform/graphics/openvg/GraphicsContextOpenVG.cpp index 0d16d4d..04a5e26 100644 --- a/WebCore/platform/graphics/openvg/GraphicsContextOpenVG.cpp +++ b/WebCore/platform/graphics/openvg/GraphicsContextOpenVG.cpp @@ -139,28 +139,28 @@ void GraphicsContext::drawConvexPolygon(size_t numPoints, const FloatPoint* poin UNUSED_PARAM(shouldAntialias); // FIXME } -void GraphicsContext::fillPath() +void GraphicsContext::fillPath(const Path& path) { if (paintingDisabled()) return; + // FIXME: Be smarter about this. + beginPath(); + addPath(path); + m_data->drawPath(VG_FILL_PATH, m_common->state.fillRule); } -void GraphicsContext::strokePath() +void GraphicsContext::strokePath(const Path& path) { if (paintingDisabled()) return; - m_data->drawPath(VG_STROKE_PATH, m_common->state.fillRule); -} + // FIXME: Be smarter about this. + beginPath(); + addPath(path); -void GraphicsContext::drawPath() -{ - if (paintingDisabled()) - return; - - m_data->drawPath(VG_FILL_PATH | VG_STROKE_PATH, m_common->state.fillRule); + m_data->drawPath(VG_STROKE_PATH, m_common->state.fillRule); } void GraphicsContext::fillRect(const FloatRect& rect) @@ -221,11 +221,15 @@ void GraphicsContext::clip(const FloatRect& rect) m_data->intersectClipRect(rect); } -void GraphicsContext::clipPath(WindRule clipRule) +void GraphicsContext::clipPath(const Path& path, WindRule clipRule) { if (paintingDisabled()) return; + // FIXME: Be smarter about this. + beginPath(); + addPath(path); + m_data->clipPath(*(m_data->currentPath()), PainterOpenVG::IntersectClip, clipRule); } diff --git a/WebCore/platform/graphics/qt/ContextShadowQt.cpp b/WebCore/platform/graphics/qt/ContextShadowQt.cpp index 342e027..f7c70f6 100644 --- a/WebCore/platform/graphics/qt/ContextShadowQt.cpp +++ b/WebCore/platform/graphics/qt/ContextShadowQt.cpp @@ -114,6 +114,7 @@ PlatformContext ContextShadow::beginShadowLayer(PlatformContext p, const FloatRe else clipRect = p->transform().inverted().mapRect(p->window()); + m_unscaledLayerRect = layerArea; calculateLayerBoundingRect(layerArea, IntRect(clipRect.x(), clipRect.y(), clipRect.width(), clipRect.height())); // Don't paint if we are totally outside the clip region. @@ -144,7 +145,9 @@ void ContextShadow::endShadowLayer(PlatformContext p) if (m_type == BlurShadow) { blurLayerImage(m_layerImage.bits(), IntSize(m_layerImage.width(), m_layerImage.height()), m_layerImage.bytesPerLine()); + } + if (m_type != NoShadow) { // "Colorize" with the right shadow color. QPainter p(&m_layerImage); p.setCompositionMode(QPainter::CompositionMode_SourceIn); @@ -152,7 +155,14 @@ void ContextShadow::endShadowLayer(PlatformContext p) p.end(); } - p->drawImage(m_layerRect.topLeft(), m_layerImage); + const QTransform transform = p->transform(); + if (transform.isScaling()) { + qreal x = m_unscaledLayerRect.x() + m_offset.width() / transform.m11() - m_blurDistance; + qreal y = m_unscaledLayerRect.y() + m_offset.height() / transform.m22() - m_blurDistance; + p->drawImage(QPointF(x, y), m_layerImage); + } else + p->drawImage(m_layerRect.topLeft(), m_layerImage); + scratchShadowBuffer()->schedulePurge(); } diff --git a/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp b/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp index 0565deb..35e9e0c 100644 --- a/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp +++ b/WebCore/platform/graphics/qt/FontPlatformDataQt.cpp @@ -26,7 +26,7 @@ namespace WebCore { -static inline bool isEmtpyValue(const float size, const bool bold, const bool oblique) +static inline bool isEmptyValue(const float size, const bool bold, const bool oblique) { // this is the empty value by definition of the trait FontDataCacheKeyTraits return !bold && !oblique && size == 0.f; @@ -34,7 +34,7 @@ static inline bool isEmtpyValue(const float size, const bool bold, const bool ob FontPlatformData::FontPlatformData(float size, bool bold, bool oblique) { - if (isEmtpyValue(size, bold, oblique)) + if (isEmptyValue(size, bold, oblique)) m_data = 0; else m_data = new FontPlatformDataPrivate(size, bold, oblique); diff --git a/WebCore/platform/graphics/qt/FontQt.cpp b/WebCore/platform/graphics/qt/FontQt.cpp index b049181..89dfd00 100644 --- a/WebCore/platform/graphics/qt/FontQt.cpp +++ b/WebCore/platform/graphics/qt/FontQt.cpp @@ -182,32 +182,62 @@ static void drawTextCommon(GraphicsContext* ctx, const TextRun& run, const Float if (!isComplexText && !(ctx->textDrawingMode() & cTextStroke)) flags |= Qt::TextBypassShaping; #endif - if (ctx->contextShadow()->m_type != ContextShadow::NoShadow) { - ContextShadow* ctxShadow = ctx->contextShadow(); - if (ctxShadow->m_type != ContextShadow::BlurShadow) { - p->save(); - p->setPen(ctxShadow->m_color); - p->translate(ctxShadow->offset()); - p->drawText(pt, string, flags, run.padding()); - p->restore(); - } else { - QFontMetrics fm(font); - QRectF boundingRect(point.x(), point.y() - fm.ascent(), fm.width(string), fm.height()); - QPainter* shadowPainter = ctxShadow->beginShadowLayer(p, boundingRect); - if (shadowPainter) { - // Since it will be blurred anyway, we don't care about render hints. - shadowPainter->setFont(p->font()); - shadowPainter->setPen(ctxShadow->m_color); - shadowPainter->drawText(pt, string, flags, run.padding()); - ctxShadow->endShadowLayer(p); + + QPainterPath textStrokePath; + if (ctx->textDrawingMode() & cTextStroke) + textStrokePath.addText(pt, font, string); + + ContextShadow* ctxShadow = ctx->contextShadow(); + if (ctxShadow->m_type != ContextShadow::NoShadow) { + if (ctx->textDrawingMode() & cTextFill) { + if (ctxShadow->m_type != ContextShadow::BlurShadow) { + p->save(); + p->setPen(ctxShadow->m_color); + p->translate(ctxShadow->offset()); + p->drawText(pt, string, flags, run.padding()); + p->restore(); + } else { + QFontMetrics fm(font); +#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) + QRectF boundingRect(pt.x(), point.y() - fm.ascent(), fm.width(string, -1, flags), fm.height()); +#else + QRectF boundingRect(pt.x(), point.y() - fm.ascent(), fm.width(string), fm.height()); +#endif + QPainter* shadowPainter = ctxShadow->beginShadowLayer(p, boundingRect); + if (shadowPainter) { + // Since it will be blurred anyway, we don't care about render hints. + shadowPainter->setFont(p->font()); + shadowPainter->setPen(ctxShadow->m_color); + shadowPainter->drawText(pt, string, flags, run.padding()); + ctxShadow->endShadowLayer(p); + } + } + } else if (ctx->textDrawingMode() & cTextStroke) { + if (ctxShadow->m_type != ContextShadow::BlurShadow) { + p->translate(ctxShadow->offset()); + p->strokePath(textStrokePath, QPen(ctxShadow->m_color)); + p->translate(-ctxShadow->offset()); + } else { + QFontMetrics fm(font); +#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) + QRectF boundingRect(pt.x(), point.y() - fm.ascent(), fm.width(string, -1, flags), fm.height()); +#else + QRectF boundingRect(pt.x(), point.y() - fm.ascent(), fm.width(string), fm.height()); +#endif + QPainter* shadowPainter = ctxShadow->beginShadowLayer(p, boundingRect); + if (shadowPainter) { + // Since it will be blurred anyway, we don't care about render hints. + shadowPainter->setFont(p->font()); + shadowPainter->strokePath(textStrokePath, QPen(ctxShadow->m_color)); + ctxShadow->endShadowLayer(p); + } } } } - if (ctx->textDrawingMode() & cTextStroke) { - QPainterPath path; - path.addText(pt, font, string); - p->strokePath(path, textStrokePen); - } + + if (ctx->textDrawingMode() & cTextStroke) + p->strokePath(textStrokePath, textStrokePen); + if (ctx->textDrawingMode() & cTextFill) { QPen previousPen = p->pen(); p->setPen(textFillPen); @@ -314,7 +344,7 @@ FloatRect Font::selectionRectForSimpleText(const TextRun& run, const FloatPoint& #if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) String sanitized = Font::normalizeSpaces(String(run.characters(), run.length())); QString wholeText = fromRawDataWithoutRef(sanitized); - QString selectedText = fromRawDataWithoutRef(sanitized, from, to - from); + QString selectedText = fromRawDataWithoutRef(sanitized, from, qMin(to - from, wholeText.length() - from)); int startX = QFontMetrics(font()).width(wholeText, from, Qt::TextBypassShaping); int width = QFontMetrics(font()).width(selectedText, -1, Qt::TextBypassShaping); diff --git a/WebCore/platform/graphics/qt/GraphicsContextQt.cpp b/WebCore/platform/graphics/qt/GraphicsContextQt.cpp index 06e1e1c..a840525 100644 --- a/WebCore/platform/graphics/qt/GraphicsContextQt.cpp +++ b/WebCore/platform/graphics/qt/GraphicsContextQt.cpp @@ -51,7 +51,6 @@ #include "NotImplemented.h" #include "Path.h" #include "Pattern.h" -#include "Pen.h" #include "TransparencyLayer.h" #include <QBrush> @@ -104,6 +103,8 @@ QPainter::CompositionMode GraphicsContext::toQtCompositionMode(CompositeOperator return QPainter::CompositionMode_SourceOver; case CompositePlusLighter: return QPainter::CompositionMode_Plus; + default: + ASSERT_NOT_REACHED(); } return QPainter::CompositionMode_SourceOver; @@ -118,6 +119,8 @@ static inline Qt::PenCapStyle toQtLineCap(LineCap lc) return Qt::RoundCap; case SquareCap: return Qt::SquareCap; + default: + ASSERT_NOT_REACHED(); } return Qt::FlatCap; @@ -132,9 +135,11 @@ static inline Qt::PenJoinStyle toQtLineJoin(LineJoin lj) return Qt::RoundJoin; case BevelJoin: return Qt::BevelJoin; + default: + ASSERT_NOT_REACHED(); } - return Qt::MiterJoin; + return Qt::SvgMiterJoin; } static Qt::PenStyle toQPenStyle(StrokeStyle style) @@ -152,8 +157,9 @@ static Qt::PenStyle toQPenStyle(StrokeStyle style) case DashedStroke: return Qt::DashLine; break; + default: + ASSERT_NOT_REACHED(); } - qWarning("couldn't recognize the pen style"); return Qt::NoPen; } @@ -164,8 +170,9 @@ static inline Qt::FillRule toQtFillRule(WindRule rule) return Qt::OddEvenFill; case RULE_NONZERO: return Qt::WindingFill; + default: + ASSERT_NOT_REACHED(); } - qDebug("Qt: unrecognized wind rule!"); return Qt::OddEvenFill; } @@ -193,9 +200,6 @@ public: InterpolationQuality imageInterpolationQuality; - // Only used by SVG for now. - QPainterPath currentPath; - ContextShadow shadow; QStack<ContextShadow> shadowStack; @@ -204,13 +208,6 @@ public: return shadow.m_type != ContextShadow::NoShadow; } - inline void clearCurrentPath() - { - if (!currentPath.elementCount()) - return; - currentPath = QPainterPath(); - } - QRectF clipBoundingRect() const { #if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0) @@ -250,8 +247,8 @@ GraphicsContextPlatformPrivate::~GraphicsContextPlatformPrivate() if (!platformContextIsOwned) return; - painter->end(); QPaintDevice* device = painter->device(); + painter->end(); delete painter; delete device; } @@ -311,11 +308,6 @@ void GraphicsContext::restorePlatformState() m_data->p()->restore(); - if (!m_data->currentPath.isEmpty() && m_common->state.pathTransform.isInvertible()) { - QTransform matrix = m_common->state.pathTransform; - m_data->currentPath = m_data->currentPath * matrix; - } - if (m_data->shadowStack.isEmpty()) m_data->shadow = ContextShadow(); else @@ -444,32 +436,6 @@ void GraphicsContext::drawEllipse(const IntRect& rect) m_data->p()->drawEllipse(rect); } -void GraphicsContext::strokeArc(const IntRect& rect, int startAngle, int angleSpan) -{ - if (paintingDisabled() || strokeStyle() == NoStroke || strokeThickness() <= 0.0f) - return; - - QPainter* p = m_data->p(); - const bool antiAlias = p->testRenderHint(QPainter::Antialiasing); - p->setRenderHint(QPainter::Antialiasing, true); - - startAngle *= 16; - angleSpan *= 16; - - if (m_data->hasShadow()) { - p->save(); - p->translate(m_data->shadow.offset()); - QPen pen(p->pen()); - pen.setColor(m_data->shadow.m_color); - p->setPen(pen); - p->drawArc(rect, startAngle, angleSpan); - p->restore(); - } - p->drawArc(rect, startAngle, angleSpan); - - p->setRenderHint(QPainter::Antialiasing, antiAlias); -} - void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points, bool shouldAntialias) { if (paintingDisabled()) @@ -484,8 +450,10 @@ void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points polygon[i] = points[i]; QPainter* p = m_data->p(); - p->save(); + + const bool antiAlias = p->testRenderHint(QPainter::Antialiasing); p->setRenderHint(QPainter::Antialiasing, shouldAntialias); + if (m_data->hasShadow()) { p->save(); p->translate(m_data->shadow.offset()); @@ -500,7 +468,8 @@ void GraphicsContext::drawConvexPolygon(size_t npoints, const FloatPoint* points p->restore(); } p->drawConvexPolygon(polygon); - p->restore(); + + p->setRenderHint(QPainter::Antialiasing, antiAlias); } void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* points, bool antialiased) @@ -529,64 +498,114 @@ void GraphicsContext::clipConvexPolygon(size_t numPoints, const FloatPoint* poin p->setRenderHint(QPainter::Antialiasing, painterWasAntialiased); } -void GraphicsContext::fillPath() +void GraphicsContext::fillPath(const Path& path) { if (paintingDisabled()) return; QPainter* p = m_data->p(); - QPainterPath& path = m_data->currentPath; // Avoid detaching the QPainterPath - path.setFillRule(toQtFillRule(fillRule())); + QPainterPath platformPath = path.platformPath(); + platformPath.setFillRule(toQtFillRule(fillRule())); if (m_data->hasShadow()) { - p->translate(m_data->shadow.offset()); - p->fillPath(path, QColor(m_data->shadow.m_color)); - p->translate(-m_data->shadow.offset()); + ContextShadow* shadow = contextShadow(); + if (shadow->m_type != ContextShadow::BlurShadow + && !m_common->state.fillPattern && !m_common->state.fillGradient) + { + QPointF offset = shadow->offset(); + const QTransform& transform = p->transform(); + if (transform.isScaling()) { + // If scaling is required, find the new coord for shadow origin, + // so that the relative offset to its shape is kept. + QPointF translatedOffset(offset.x() / transform.m11(), + offset.y() / transform.m22()); + platformPath.translate(translatedOffset); + p->fillPath(platformPath, QColor(shadow->m_color)); + platformPath.translate(-translatedOffset); + } else { + p->translate(offset); + p->fillPath(platformPath, QColor(shadow->m_color)); + p->translate(-offset); + } + } else { + QPainter* shadowPainter = shadow->beginShadowLayer(p, platformPath.controlPointRect()); + if (shadowPainter) { + shadowPainter->setCompositionMode(QPainter::CompositionMode_Source); + shadowPainter->fillPath(platformPath, QColor(m_data->shadow.m_color)); + shadow->endShadowLayer(p); + } + } + } if (m_common->state.fillPattern) { AffineTransform affine; - p->fillPath(path, QBrush(m_common->state.fillPattern->createPlatformPattern(affine))); + p->fillPath(platformPath, QBrush(m_common->state.fillPattern->createPlatformPattern(affine))); } else if (m_common->state.fillGradient) { QBrush brush(*m_common->state.fillGradient->platformGradient()); brush.setTransform(m_common->state.fillGradient->gradientSpaceTransform()); - p->fillPath(path, brush); + p->fillPath(platformPath, brush); } else - p->fillPath(path, p->brush()); - - m_data->clearCurrentPath(); + p->fillPath(platformPath, p->brush()); } -void GraphicsContext::strokePath() +void GraphicsContext::strokePath(const Path& path) { if (paintingDisabled()) return; QPainter* p = m_data->p(); QPen pen(p->pen()); - QPainterPath& path = m_data->currentPath; // Avoid detaching the QPainterPath - path.setFillRule(toQtFillRule(fillRule())); + QPainterPath platformPath = path.platformPath(); + platformPath.setFillRule(toQtFillRule(fillRule())); if (m_data->hasShadow()) { - p->translate(m_data->shadow.offset()); - QPen shadowPen(pen); - shadowPen.setColor(m_data->shadow.m_color); - p->strokePath(path, shadowPen); - p->translate(-m_data->shadow.offset()); + ContextShadow* shadow = contextShadow(); + + if (shadow->m_type != ContextShadow::BlurShadow + && !m_common->state.strokePattern && !m_common->state.strokeGradient) + { + QPen shadowPen(pen); + shadowPen.setColor(m_data->shadow.m_color); + QPointF offset = shadow->offset(); + const QTransform& transform = p->transform(); + if (transform.isScaling()) { + // If scaling is required, find the new coord for shadow origin, + // so that the relative offset to its shape is kept. + QPointF translatedOffset(offset.x() / transform.m11(), + offset.y() / transform.m22()); + platformPath.translate(translatedOffset); + p->strokePath(platformPath, shadowPen); + platformPath.translate(-translatedOffset); + } else { + p->translate(offset); + p->strokePath(platformPath, shadowPen); + p->translate(-offset); + } + } else { + FloatRect boundingRect = platformPath.controlPointRect(); + boundingRect.inflate(pen.miterLimit() + pen.widthF()); + QPainter* shadowPainter = shadow->beginShadowLayer(p, boundingRect); + if (shadowPainter) { + shadowPainter->setOpacity(static_cast<qreal>(m_data->shadow.m_color.alpha()) / 255); + shadowPainter->strokePath(platformPath, pen); + shadow->endShadowLayer(p); + } + } } + if (m_common->state.strokePattern) { AffineTransform affine; pen.setBrush(QBrush(m_common->state.strokePattern->createPlatformPattern(affine))); p->setPen(pen); - p->strokePath(path, pen); + p->strokePath(platformPath, pen); } else if (m_common->state.strokeGradient) { QBrush brush(*m_common->state.strokeGradient->platformGradient()); brush.setTransform(m_common->state.strokeGradient->gradientSpaceTransform()); pen.setBrush(brush); p->setPen(pen); - p->strokePath(path, pen); + p->strokePath(platformPath, pen); } else - p->strokePath(path, pen); - m_data->clearCurrentPath(); + p->strokePath(platformPath, pen); } static inline void drawRepeatPattern(QPainter* p, QPixmap* image, const FloatRect& rect, const bool repeatX, const bool repeatY) @@ -693,6 +712,7 @@ void GraphicsContext::fillRect(const FloatRect& rect) if (shadow->m_type == ContextShadow::BlurShadow) { QPainter* shadowPainter = shadow->beginShadowLayer(p, normalizedRect); if (shadowPainter) { + shadowPainter->setOpacity(static_cast<qreal>(shadow->m_color.alpha()) / 255); shadowPainter->fillRect(normalizedRect, p->brush()); shadow->endShadowLayer(p); } @@ -701,9 +721,16 @@ void GraphicsContext::fillRect(const FloatRect& rect) // without using the shadow layer at all. QColor shadowColor = shadow->m_color; shadowColor.setAlphaF(shadowColor.alphaF() * p->brush().color().alphaF()); - p->fillRect(normalizedRect.translated(shadow->offset()), shadowColor); + const QTransform& transform = p->transform(); + if (transform.isScaling()) { + p->fillRect(normalizedRect.translated(static_cast<qreal>(shadow->offset().x()) / transform.m11(), + static_cast<qreal>(shadow->offset().y() / transform.m22())), + shadowColor); + } else + p->fillRect(normalizedRect.translated(shadow->offset()), shadowColor); } } + p->fillRect(normalizedRect, p->brush()); } } @@ -765,30 +792,11 @@ void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLef p->fillPath(path.platformPath(), QColor(color)); } -void GraphicsContext::beginPath() -{ - m_data->clearCurrentPath(); -} - -void GraphicsContext::addPath(const Path& path) -{ - if (!m_data->currentPath.elementCount()) { - m_data->currentPath = path.platformPath(); - return; - } - m_data->currentPath.addPath(path.platformPath()); -} - bool GraphicsContext::inTransparencyLayer() const { return m_data->layerCount; } -PlatformPath* GraphicsContext::currentPath() -{ - return &m_data->currentPath; -} - ContextShadow* GraphicsContext::contextShadow() { return &m_data->shadow; @@ -802,26 +810,45 @@ void GraphicsContext::clip(const FloatRect& rect) m_data->p()->setClipRect(rect, Qt::IntersectClip); } -void GraphicsContext::clipPath(WindRule clipRule) +void GraphicsContext::clipPath(const Path& path, WindRule clipRule) { if (paintingDisabled()) return; QPainter* p = m_data->p(); - QPainterPath newPath = m_data->currentPath; - newPath.setFillRule(clipRule == RULE_EVENODD ? Qt::OddEvenFill : Qt::WindingFill); - p->setClipPath(newPath, Qt::IntersectClip); + QPainterPath platformPath = path.platformPath(); + platformPath.setFillRule(clipRule == RULE_EVENODD ? Qt::OddEvenFill : Qt::WindingFill); + p->setClipPath(platformPath, Qt::IntersectClip); } -void GraphicsContext::drawFocusRing(const Vector<Path>& paths, int width, int offset, const Color& color) +void GraphicsContext::drawFocusRing(const Path& path, int width, int offset, const Color& color) { - // FIXME: implement + // FIXME: Use 'width' and 'offset' for something? http://webkit.org/b/49909 + + if (paintingDisabled() || !color.isValid()) + return; + + QPainter* p = m_data->p(); + const bool antiAlias = p->testRenderHint(QPainter::Antialiasing); + p->setRenderHint(QPainter::Antialiasing, m_data->antiAliasingForRectsAndLines); + + const QBrush oldBrush = p->brush(); + + QPen nPen = p->pen(); + nPen.setColor(color); + p->setBrush(Qt::NoBrush); + nPen.setStyle(Qt::DotLine); + + p->strokePath(path.platformPath(), nPen); + p->setBrush(oldBrush); + + p->setRenderHint(QPainter::Antialiasing, antiAlias); } /** - * Focus ring handling is not handled here. Qt style in + * Focus ring handling for form controls is not handled here. Qt style in * RenderTheme handles drawing focus on widgets which - * need it. + * need it. It is still handled here for links. */ void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int /* width */, int /* offset */, const Color& color) { @@ -1020,12 +1047,10 @@ void GraphicsContext::strokeRect(const FloatRect& rect, float width) if (paintingDisabled()) return; - QPainterPath path; + Path path; path.addRect(rect); setStrokeThickness(width); - m_data->currentPath = path; - - strokePath(); + strokePath(path); } void GraphicsContext::setLineCap(LineCap lc) @@ -1145,12 +1170,6 @@ void GraphicsContext::translate(float x, float y) return; m_data->p()->translate(x, y); - - if (!m_data->currentPath.isEmpty()) { - QTransform matrix; - m_data->currentPath = m_data->currentPath * matrix.translate(-x, -y); - m_common->state.pathTransform.translate(x, y); - } } void GraphicsContext::rotate(float radians) @@ -1159,12 +1178,6 @@ void GraphicsContext::rotate(float radians) return; m_data->p()->rotate(180 / M_PI*radians); - - if (!m_data->currentPath.isEmpty()) { - QTransform matrix; - m_data->currentPath = m_data->currentPath * matrix.rotate(-180 / M_PI*radians); - m_common->state.pathTransform.rotate(radians); - } } void GraphicsContext::scale(const FloatSize& s) @@ -1173,12 +1186,6 @@ void GraphicsContext::scale(const FloatSize& s) return; m_data->p()->scale(s.width(), s.height()); - - if (!m_data->currentPath.isEmpty()) { - QTransform matrix; - m_data->currentPath = m_data->currentPath * matrix.scale(1 / s.width(), 1 / s.height()); - m_common->state.pathTransform.scaleNonUniform(s.width(), s.height()); - } } void GraphicsContext::clipOut(const IntRect& rect) @@ -1235,15 +1242,6 @@ void GraphicsContext::concatCTM(const AffineTransform& transform) return; m_data->p()->setWorldTransform(transform, true); - - // Transformations to the context shouldn't transform the currentPath. - // We have to undo every change made to the context from the currentPath - // to avoid wrong drawings. - if (!m_data->currentPath.isEmpty() && transform.isInvertible()) { - QTransform matrix = transform.inverse(); - m_data->currentPath = m_data->currentPath * matrix; - m_common->state.pathTransform.multiply(transform.toTransformationMatrix()); - } } void GraphicsContext::setURLForRect(const KURL&, const IntRect&) diff --git a/WebCore/platform/graphics/qt/ImageQt.cpp b/WebCore/platform/graphics/qt/ImageQt.cpp index 7b46b71..3611308 100644 --- a/WebCore/platform/graphics/qt/ImageQt.cpp +++ b/WebCore/platform/graphics/qt/ImageQt.cpp @@ -3,6 +3,7 @@ * Copyright (C) 2006 Zack Rusin <zack@kde.org> * Copyright (C) 2006 Simon Hausmann <hausmann@kde.org> * Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ + * Copyright (C) 2010 Sencha, Inc. * * All rights reserved. * @@ -32,11 +33,12 @@ #include "Image.h" #include "AffineTransform.h" -#include "ImageObserver.h" #include "BitmapImage.h" +#include "ContextShadow.h" #include "FloatRect.h" -#include "PlatformString.h" #include "GraphicsContext.h" +#include "ImageObserver.h" +#include "PlatformString.h" #include "StillImageQt.h" #include "qwebsettings.h" @@ -102,12 +104,13 @@ void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const if (!framePixmap) // If it's too early we won't have an image yet. return; + // Qt interprets 0 width/height as full width/height so just short circuit. QRectF dr = QRectF(destRect).normalized(); - if (!dr.width() || !dr.height()) // Qt interprets 0 width/height as full width/height so just short circuit. + QRect tr = QRectF(tileRect).toRect().normalized(); + if (!dr.width() || !dr.height() || !tr.width() || !tr.height()) return; QPixmap pixmap = *framePixmap; - QRect tr = QRectF(tileRect).toRect().normalized(); if (tr.x() || tr.y() || tr.width() != pixmap.width() || tr.height() != pixmap.height()) pixmap = pixmap.copy(tr); @@ -177,11 +180,14 @@ void BitmapImage::invalidatePlatformData() void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dst, const FloatRect& src, ColorSpace styleColorSpace, CompositeOperator op) { - FloatRect normalizedDst = dst.normalized(); - FloatRect normalizedSrc = src.normalized(); + QRectF normalizedDst = dst.normalized(); + QRectF normalizedSrc = src.normalized(); startAnimation(); + if (normalizedSrc.isEmpty() || normalizedDst.isEmpty()) + return; + QPixmap* image = nativeImageForCurrentFrame(); if (!image) return; @@ -201,21 +207,14 @@ void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dst, QPainter::CompositionMode lastCompositionMode = painter->compositionMode(); painter->setCompositionMode(compositionMode); - FloatSize shadowOffset; - float shadowBlur; - Color shadowColor; - if (ctxt->getShadow(shadowOffset, shadowBlur, shadowColor)) { - FloatRect shadowImageRect(normalizedDst); - shadowImageRect.move(shadowOffset.width(), shadowOffset.height()); - - QImage shadowImage(QSize(static_cast<int>(normalizedSrc.width()), static_cast<int>(normalizedSrc.height())), QImage::Format_ARGB32_Premultiplied); - QPainter p(&shadowImage); - p.setCompositionMode(QPainter::CompositionMode_Source); - p.fillRect(shadowImage.rect(), shadowColor); - p.setCompositionMode(QPainter::CompositionMode_DestinationIn); - p.drawPixmap(QRect(0, 0, normalizedDst.width(), normalizedDst.height()), *image, normalizedSrc); - p.end(); - painter->drawImage(shadowImageRect, shadowImage, normalizedSrc); + ContextShadow* shadow = ctxt->contextShadow(); + if (shadow->m_type != ContextShadow::NoShadow) { + QPainter* shadowPainter = shadow->beginShadowLayer(painter, normalizedDst); + if (shadowPainter) { + shadowPainter->setOpacity(static_cast<qreal>(shadow->m_color.alpha()) / 255); + shadowPainter->drawPixmap(normalizedDst, *image, normalizedSrc); + shadow->endShadowLayer(painter); + } } // Test using example site at diff --git a/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp b/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp index e506e5d..6f6dce8 100644 --- a/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp +++ b/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp @@ -420,11 +420,15 @@ void GraphicsContext::clipOut(const Path& p) platformContext()->canvas()->clipPath(path, SkRegion::kDifference_Op); } -void GraphicsContext::clipPath(WindRule clipRule) +void GraphicsContext::clipPath(const Path& pathToClip, WindRule clipRule) { if (paintingDisabled()) return; + // FIXME: Be smarter about this. + beginPath(); + addPath(pathToClip); + SkPath path = platformContext()->currentPathInLocalCoordinates(); if (!isPathSkiaSafe(getCTM(), path)) return; @@ -513,7 +517,7 @@ void GraphicsContext::drawEllipse(const IntRect& elipseRect) } } -void GraphicsContext::drawFocusRing(const Vector<Path>& paths, int width, int offset, const Color& color) +void GraphicsContext::drawFocusRing(const Path& path, int width, int offset, const Color& color) { // FIXME: implement } @@ -723,11 +727,15 @@ void GraphicsContext::drawRect(const IntRect& rect) platformContext()->drawRect(r); } -void GraphicsContext::fillPath() +void GraphicsContext::fillPath(const Path& pathToFill) { if (paintingDisabled()) return; + // FIXME: Be smarter about this. + beginPath(); + addPath(pathToFill); + SkPath path = platformContext()->currentPathInLocalCoordinates(); if (!isPathSkiaSafe(getCTM(), path)) return; @@ -1177,11 +1185,15 @@ void GraphicsContext::strokeArc(const IntRect& r, int startAngle, int angleSpan) platformContext()->canvas()->drawPath(path, paint); } -void GraphicsContext::strokePath() +void GraphicsContext::strokePath(const Path& pathToStroke) { if (paintingDisabled()) return; + // FIXME: Be smarter about this. + beginPath(); + addPath(pathToStroke); + SkPath path = platformContext()->currentPathInLocalCoordinates(); if (!isPathSkiaSafe(getCTM(), path)) return; diff --git a/WebCore/platform/graphics/skia/ImageBufferSkia.cpp b/WebCore/platform/graphics/skia/ImageBufferSkia.cpp index 0db96cf..adb732b 100644 --- a/WebCore/platform/graphics/skia/ImageBufferSkia.cpp +++ b/WebCore/platform/graphics/skia/ImageBufferSkia.cpp @@ -183,6 +183,9 @@ PassRefPtr<ImageData> getImageData(const IntRect& rect, const SkBitmap& bitmap, endX = size.width(); int numColumns = endX - originX; + if (numColumns <= 0) + return result; + int originY = rect.y(); int destY = 0; if (originY < 0) { @@ -194,6 +197,9 @@ PassRefPtr<ImageData> getImageData(const IntRect& rect, const SkBitmap& bitmap, endY = size.height(); int numRows = endY - originY; + if (numRows <= 0) + return result; + ASSERT(bitmap.config() == SkBitmap::kARGB_8888_Config); SkAutoLockPixels bitmapLock(bitmap); diff --git a/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp b/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp index c9288e5..1ad6bc1 100644 --- a/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp +++ b/WebCore/platform/graphics/win/GraphicsContextCGWin.cpp @@ -124,7 +124,7 @@ void GraphicsContext::drawWindowsBitmap(WindowsBitmap* image, const IntPoint& po CGContextDrawImage(m_data->m_cgContext.get(), CGRectMake(point.x(), point.y(), image->size().width(), image->size().height()), cgImage.get()); } -void GraphicsContext::drawFocusRing(const Vector<Path>& paths, int width, int offset, const Color& color) +void GraphicsContext::drawFocusRing(const Path& path, int width, int offset, const Color& color) { // FIXME: implement } @@ -228,20 +228,17 @@ void GraphicsContext::drawLineForTextChecking(const IntPoint& point, int width, const float lowerOpacity = 0.88f; //Top line - CGContextSetLineDash(context, edge_offset, edge_dash_lengths, - sizeof(edge_dash_lengths) / sizeof(edge_dash_lengths[0])); + CGContextSetLineDash(context, edge_offset, edge_dash_lengths, WTF_ARRAY_LENGTH(edge_dash_lengths)); CGContextSetAlpha(context, upperOpacity); CGContextStrokeLineSegments(context, upperPoints, 2); // Middle line - CGContextSetLineDash(context, middle_offset, middle_dash_lengths, - sizeof(middle_dash_lengths) / sizeof(middle_dash_lengths[0])); + CGContextSetLineDash(context, middle_offset, middle_dash_lengths, WTF_ARRAY_LENGTH(middle_dash_lengths)); CGContextSetAlpha(context, middleOpacity); CGContextStrokeLineSegments(context, middlePoints, 2); // Bottom line - CGContextSetLineDash(context, edge_offset, edge_dash_lengths, - sizeof(edge_dash_lengths) / sizeof(edge_dash_lengths[0])); + CGContextSetLineDash(context, edge_offset, edge_dash_lengths, WTF_ARRAY_LENGTH(edge_dash_lengths)); CGContextSetAlpha(context, lowerOpacity); CGContextStrokeLineSegments(context, lowerPoints, 2); diff --git a/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp b/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp index 34a8817..2b24a24 100644 --- a/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp +++ b/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp @@ -254,7 +254,8 @@ void MediaPlayerPrivateQuickTimeVisualContext::setUpCookiesForQuickTime(const St // WebCore loaded the page with the movie URL with CFNetwork but QuickTime will // use WinINet to download the movie, so we need to copy any cookies needed to // download the movie into WinInet before asking QuickTime to open it. - Frame* frame = m_player->frameView() ? m_player->frameView()->frame() : 0; + Document* document = m_player->mediaPlayerClient()->mediaPlayerOwningDocument(); + Frame* frame = document ? document->frame() : 0; if (!frame || !frame->page() || !frame->page()->cookieEnabled()) return; @@ -315,7 +316,7 @@ static void disableComponentsOnce() {'eat ', 'TEXT', 'tx3g', 0, 0}, }; - for (size_t i = 0; i < sizeof(componentsToDisable) / sizeof(componentsToDisable[0]); ++i) + for (size_t i = 0; i < WTF_ARRAY_LENGTH(componentsToDisable); ++i) QTMovie::disableComponent(componentsToDisable[i]); } diff --git a/WebCore/platform/graphics/win/QTMovie.cpp b/WebCore/platform/graphics/win/QTMovie.cpp index e425bf8..efaf218 100644 --- a/WebCore/platform/graphics/win/QTMovie.cpp +++ b/WebCore/platform/graphics/win/QTMovie.cpp @@ -548,7 +548,7 @@ void QTMovie::load(CFURLRef url, bool preservesPitch) movieProps[moviePropCount].propStatus = 0; moviePropCount++; - ASSERT(moviePropCount <= sizeof(movieProps) / sizeof(movieProps[0])); + ASSERT(moviePropCount <= WTF_ARRAY_LENGTH(movieProps)); m_private->m_loadError = NewMovieFromProperties(moviePropCount, movieProps, 0, 0, &m_private->m_movie); end: diff --git a/WebCore/platform/graphics/win/cairo/FontPlatformData.h b/WebCore/platform/graphics/win/cairo/FontPlatformData.h index 05f9eab..d8f538a 100644 --- a/WebCore/platform/graphics/win/cairo/FontPlatformData.h +++ b/WebCore/platform/graphics/win/cairo/FontPlatformData.h @@ -3,6 +3,7 @@ * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com * Copyright (C) 2007 Holger Hans Peter Freyther * Copyright (C) 2007 Pioneer Research Center USA, Inc. + * Copyright (C) 2010 Brent Fulgham <bfulgham@webkit.org> * All rights reserved. * * This library is free software; you can redistribute it and/or @@ -25,7 +26,7 @@ #ifndef FontPlatformDataCairoWin_h #define FontPlatformDataCairoWin_h -#include "FontDescription.h" +#include "FontOrientation.h" #include "GlyphBuffer.h" #include "RefCountedGDIHandle.h" #include "StringImpl.h" @@ -37,6 +38,8 @@ typedef struct HFONT__* HFONT; namespace WebCore { +class FontDescription; + class FontPlatformData { public: FontPlatformData(WTF::HashTableDeletedValueType) @@ -73,6 +76,9 @@ public: void setSize(float size) { m_size = size; } bool syntheticBold() const { return m_syntheticBold; } bool syntheticOblique() const { return m_syntheticOblique; } + + FontOrientation orientation() const { return Horizontal; } // FIXME: Implement. + cairo_scaled_font_t* scaledFont() const { return m_scaledFont; } unsigned hash() const diff --git a/WebCore/platform/graphics/wince/GraphicsContextWinCE.cpp b/WebCore/platform/graphics/wince/GraphicsContextWinCE.cpp index 8af6ef7..4faa29d 100644 --- a/WebCore/platform/graphics/wince/GraphicsContextWinCE.cpp +++ b/WebCore/platform/graphics/wince/GraphicsContextWinCE.cpp @@ -982,7 +982,7 @@ void GraphicsContext::clipOut(const IntRect& rect) ExcludeClipRect(m_data->m_dc, trRect.x(), trRect.y(), trRect.right(), trRect.bottom()); } -void GraphicsContext::drawFocusRing(const Vector<Path>& paths, int width, int offset, const Color& color) +void GraphicsContext::drawFocusRing(const Path& path, int width, int offset, const Color& color) { // FIXME: implement } @@ -1325,8 +1325,12 @@ Color gradientAverageColor(const Gradient* gradient) , (stop.alpha + lastStop.alpha) * 0.5f); } -void GraphicsContext::fillPath() +void GraphicsContext::fillPath(const Path& path) { + // FIXME: Be smarter about this. + beginPath(); + addPath(path); + Color c = m_common->state.fillGradient ? gradientAverageColor(m_common->state.fillGradient.get()) : fillColor(); @@ -1376,6 +1380,10 @@ void GraphicsContext::strokePath() if (!m_data->m_dc) return; + // FIXME: Be smarter about this. + beginPath(); + addPath(path); + OwnPtr<HPEN> pen = createPen(strokeColor(), strokeThickness(), strokeStyle()); if (m_data->m_opacity < 1.0f || m_data->hasAlpha()) { @@ -1900,7 +1908,7 @@ void GraphicsContext::setLineDash(const DashArray&, float) notImplemented(); } -void GraphicsContext::clipPath(WindRule) +void GraphicsContext::clipPath(const Path&, WindRule) { notImplemented(); } diff --git a/WebCore/platform/graphics/wx/GraphicsContextWx.cpp b/WebCore/platform/graphics/wx/GraphicsContextWx.cpp index 53a9ccd..ba96352 100644 --- a/WebCore/platform/graphics/wx/GraphicsContextWx.cpp +++ b/WebCore/platform/graphics/wx/GraphicsContextWx.cpp @@ -289,7 +289,7 @@ void GraphicsContext::fillRoundedRect(const IntRect& rect, const IntSize& topLef notImplemented(); } -void GraphicsContext::drawFocusRing(const Vector<Path>& paths, int width, int offset, const Color& color) +void GraphicsContext::drawFocusRing(const Path& path, int width, int offset, const Color& color) { // FIXME: implement } @@ -337,7 +337,7 @@ void GraphicsContext::clipOut(const IntRect&) notImplemented(); } -void GraphicsContext::clipPath(WindRule) +void GraphicsContext::clipPath(const Path&, WindRule) { notImplemented(); } @@ -533,30 +533,32 @@ InterpolationQuality GraphicsContext::imageInterpolationQuality() const return InterpolationDefault; } -void GraphicsContext::fillPath() +void GraphicsContext::fillPath(const Path& path) { #if USE(WXGC) + // FIXME: Be smarter about this. + beginPath(); + addPath(path); + wxGraphicsContext* gc = m_data->context->GetGraphicsContext(); if (gc) gc->FillPath(m_data->currentPath); #endif } -void GraphicsContext::strokePath() +void GraphicsContext::strokePath(const Path& path) { #if USE(WXGC) + // FIXME: Be smarter about this. + beginPath(); + addPath(path); + wxGraphicsContext* gc = m_data->context->GetGraphicsContext(); if (gc) gc->StrokePath(m_data->currentPath); #endif } -void GraphicsContext::drawPath() -{ - fillPath(); - strokePath(); -} - void GraphicsContext::fillRect(const FloatRect& rect) { if (paintingDisabled()) diff --git a/WebCore/platform/graphics/wx/ImageBufferWx.cpp b/WebCore/platform/graphics/wx/ImageBufferWx.cpp index 2522cbd..dd45f31 100644 --- a/WebCore/platform/graphics/wx/ImageBufferWx.cpp +++ b/WebCore/platform/graphics/wx/ImageBufferWx.cpp @@ -37,7 +37,7 @@ ImageBufferData::ImageBufferData(const IntSize&) { } -ImageBuffer::ImageBuffer(const IntSize&, ImageColorSpace imageColorSpace, bool& success) : +ImageBuffer::ImageBuffer(const IntSize&, ColorSpace imageColorSpace, bool& success) : m_data(IntSize()) { notImplemented(); diff --git a/WebCore/platform/gtk/FileSystemGtk.cpp b/WebCore/platform/gtk/FileSystemGtk.cpp index 6f3fa19..4424f0a 100644 --- a/WebCore/platform/gtk/FileSystemGtk.cpp +++ b/WebCore/platform/gtk/FileSystemGtk.cpp @@ -257,6 +257,12 @@ void closeFile(PlatformFileHandle& handle) } } +long long seekFile(PlatformFileHandle handle, long long offset, FileSeekOrigin origin) +{ + // FIXME - Awaiting implementation, see https://bugs.webkit.org/show_bug.cgi?id=43878 + return -1; +} + int writeToFile(PlatformFileHandle handle, const char* data, int length) { int totalBytesWritten = 0; diff --git a/WebCore/platform/gtk/GtkVersioning.c b/WebCore/platform/gtk/GtkVersioning.c index 0776c10..c3407ea 100644 --- a/WebCore/platform/gtk/GtkVersioning.c +++ b/WebCore/platform/gtk/GtkVersioning.c @@ -260,4 +260,14 @@ gdk_pixbuf_get_from_surface(cairo_surface_t * surface, cairo_surface_destroy(surface); return dest; } + #endif // GTK_API_VERSION_2 + +#if !GLIB_CHECK_VERSION(2, 27, 1) +gboolean g_signal_accumulator_first_wins(GSignalInvocationHint *invocationHint, GValue *returnAccumulator, const GValue *handlerReturn, gpointer data) +{ + g_value_copy(handlerReturn, returnAccumulator); + return FALSE; +} +#endif + diff --git a/WebCore/platform/gtk/GtkVersioning.h b/WebCore/platform/gtk/GtkVersioning.h index b40e497..ea15a54 100644 --- a/WebCore/platform/gtk/GtkVersioning.h +++ b/WebCore/platform/gtk/GtkVersioning.h @@ -103,6 +103,10 @@ void gtk_adjustment_set_value(GtkAdjustment* adjusment, gdouble value); GdkDevice* getDefaultGDKPointerDevice(GdkWindow* window); GdkCursor* blankCursor(); +#if !GLIB_CHECK_VERSION(2, 27, 1) +gboolean g_signal_accumulator_first_wins(GSignalInvocationHint* invocationHint, GValue* returnAccumulator, const GValue* handlerReturn, gpointer data); +#endif + G_END_DECLS #endif // GtkVersioning_h diff --git a/WebCore/platform/gtk/LocalizedStringsGtk.cpp b/WebCore/platform/gtk/LocalizedStringsGtk.cpp index 68c1598..65e8852 100644 --- a/WebCore/platform/gtk/LocalizedStringsGtk.cpp +++ b/WebCore/platform/gtk/LocalizedStringsGtk.cpp @@ -553,6 +553,36 @@ String validationMessageValueMissingText() return String::fromUTF8(_("value missing")); } +String validationMessageValueMissingForCheckboxText() +{ + notImplemented(); + return validationMessageValueMissingText(); +} + +String validationMessageValueMissingForFileText() +{ + notImplemented(); + return validationMessageValueMissingText(); +} + +String validationMessageValueMissingForMultipleFileText() +{ + notImplemented(); + return validationMessageValueMissingText(); +} + +String validationMessageValueMissingForRadioText() +{ + notImplemented(); + return validationMessageValueMissingText(); +} + +String validationMessageValueMissingForSelectText() +{ + notImplemented(); + return validationMessageValueMissingText(); +} + String validationMessageTypeMismatchText() { notImplemented(); diff --git a/WebCore/platform/gtk/PopupMenuGtk.cpp b/WebCore/platform/gtk/PopupMenuGtk.cpp index e7ff78e..b2466c5 100644 --- a/WebCore/platform/gtk/PopupMenuGtk.cpp +++ b/WebCore/platform/gtk/PopupMenuGtk.cpp @@ -5,6 +5,7 @@ * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com * Copyright (C) 2008 Collabora Ltd. * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). + * Copyright (C) 2010 Igalia S.L. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -27,16 +28,22 @@ #include "PopupMenuGtk.h" #include "FrameView.h" +#include "GOwnPtr.h" #include "GtkVersioning.h" #include "HostWindow.h" #include "PlatformString.h" -#include <wtf/text/CString.h> +#include <gdk/gdk.h> #include <gtk/gtk.h> +#include <wtf/text/CString.h> namespace WebCore { +static const uint32_t gSearchTimeoutMs = 1000; + PopupMenuGtk::PopupMenuGtk(PopupMenuClient* client) : m_popupClient(client) + , m_previousKeyEventCharacter(0) + , m_currentlySelectedMenuItem(0) { } @@ -54,12 +61,16 @@ void PopupMenuGtk::show(const IntRect& rect, FrameView* view, int index) if (!m_popup) { m_popup = GTK_MENU(gtk_menu_new()); - g_signal_connect(m_popup.get(), "unmap", G_CALLBACK(menuUnmapped), this); + g_signal_connect(m_popup.get(), "unmap", G_CALLBACK(PopupMenuGtk::menuUnmapped), this); + g_signal_connect(m_popup.get(), "key-press-event", G_CALLBACK(PopupMenuGtk::keyPressEventCallback), this); } else gtk_container_foreach(GTK_CONTAINER(m_popup.get()), reinterpret_cast<GtkCallback>(menuRemoveItem), this); - int x, y; - gdk_window_get_origin(gtk_widget_get_window(GTK_WIDGET(view->hostWindow()->platformPageClient())), &x, &y); + int x = 0; + int y = 0; + GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(view->hostWindow()->platformPageClient())); + if (window) + gdk_window_get_origin(window, &x, &y); m_menuPosition = view->contentsToWindow(rect.location()); m_menuPosition = IntPoint(m_menuPosition.x() + x, m_menuPosition.y() + y + rect.height()); m_indexMap.clear(); @@ -73,7 +84,8 @@ void PopupMenuGtk::show(const IntRect& rect, FrameView* view, int index) item = gtk_menu_item_new_with_label(client()->itemText(i).utf8().data()); m_indexMap.add(item, i); - g_signal_connect(item, "activate", G_CALLBACK(menuItemActivated), this); + g_signal_connect(item, "activate", G_CALLBACK(PopupMenuGtk::menuItemActivated), this); + g_signal_connect(item, "select", G_CALLBACK(PopupMenuGtk::selectItemCallback), this); // FIXME: Apply the PopupMenuStyle from client()->itemStyle(i) gtk_widget_set_sensitive(item, client()->itemIsEnabled(i)); @@ -138,6 +150,77 @@ void PopupMenuGtk::disconnectClient() m_popupClient = 0; } +bool PopupMenuGtk::typeAheadFind(GdkEventKey* event) +{ + // If we were given a non-printable character just skip it. + gunichar unicodeCharacter = gdk_keyval_to_unicode(event->keyval); + if (!unicodeCharacter) { + resetTypeAheadFindState(); + return false; + } + + glong charactersWritten; + GOwnPtr<gunichar2> utf16String(g_ucs4_to_utf16(&unicodeCharacter, 1, 0, &charactersWritten, 0)); + if (!utf16String) { + resetTypeAheadFindState(); + return false; + } + + // If the character is the same as the last character, the user is probably trying to + // cycle through the menulist entries. This matches the WebCore behavior for collapsed + // menulists. + bool repeatingCharacter = unicodeCharacter != m_previousKeyEventCharacter; + if (event->time - m_previousKeyEventTimestamp > gSearchTimeoutMs) + m_currentSearchString = String(static_cast<UChar*>(utf16String.get()), charactersWritten); + else if (repeatingCharacter) + m_currentSearchString.append(String(static_cast<UChar*>(utf16String.get()), charactersWritten)); + + m_previousKeyEventTimestamp = event->time; + m_previousKeyEventCharacter = unicodeCharacter; + + // Like the Chromium port, we case fold before searching, because + // strncmp does not handle non-ASCII characters. + GOwnPtr<gchar> searchStringWithCaseFolded(g_utf8_casefold(m_currentSearchString.utf8().data(), -1)); + size_t prefixLength = strlen(searchStringWithCaseFolded.get()); + + GList* children = gtk_container_get_children(GTK_CONTAINER(m_popup.get())); + if (!children) + return true; + + // If a menu item has already been selected, start searching from the current + // item down the list. This will make multiple key presses of the same character + // advance the selection. + GList* currentChild = children; + if (m_currentlySelectedMenuItem) { + currentChild = g_list_find(children, m_currentlySelectedMenuItem); + if (!currentChild) { + m_currentlySelectedMenuItem = 0; + currentChild = children; + } + + // Repeating characters should iterate. + if (repeatingCharacter) { + if (GList* nextChild = g_list_next(currentChild)) + currentChild = nextChild; + } + } + + GList* firstChild = currentChild; + do { + currentChild = g_list_next(currentChild); + if (!currentChild) + currentChild = children; + + GOwnPtr<gchar> itemText(g_utf8_casefold(gtk_menu_item_get_label(GTK_MENU_ITEM(currentChild->data)), -1)); + if (!strncmp(searchStringWithCaseFolded.get(), itemText.get(), prefixLength)) { + gtk_menu_shell_select_item(GTK_MENU_SHELL(m_popup.get()), GTK_WIDGET(currentChild->data)); + return true; + } + } while (currentChild != firstChild); + + return true; +} + void PopupMenuGtk::menuItemActivated(GtkMenuItem* item, PopupMenuGtk* that) { ASSERT(that->client()); @@ -148,6 +231,7 @@ void PopupMenuGtk::menuItemActivated(GtkMenuItem* item, PopupMenuGtk* that) void PopupMenuGtk::menuUnmapped(GtkWidget*, PopupMenuGtk* that) { ASSERT(that->client()); + that->resetTypeAheadFindState(); that->client()->popupDidHide(); } @@ -158,11 +242,29 @@ void PopupMenuGtk::menuPositionFunction(GtkMenu*, gint* x, gint* y, gboolean* pu *pushIn = true; } +void PopupMenuGtk::resetTypeAheadFindState() +{ + m_currentlySelectedMenuItem = 0; + m_previousKeyEventCharacter = 0; + m_currentSearchString = ""; +} + void PopupMenuGtk::menuRemoveItem(GtkWidget* widget, PopupMenuGtk* that) { ASSERT(that->m_popup); gtk_container_remove(GTK_CONTAINER(that->m_popup.get()), widget); } +int PopupMenuGtk::selectItemCallback(GtkMenuItem* item, PopupMenuGtk* that) +{ + that->m_currentlySelectedMenuItem = GTK_WIDGET(item); + return FALSE; +} + +int PopupMenuGtk::keyPressEventCallback(GtkWidget* widget, GdkEventKey* event, PopupMenuGtk* that) +{ + return that->typeAheadFind(event); +} + } diff --git a/WebCore/platform/gtk/PopupMenuGtk.h b/WebCore/platform/gtk/PopupMenuGtk.h index 8848e06..e47fda6 100644 --- a/WebCore/platform/gtk/PopupMenuGtk.h +++ b/WebCore/platform/gtk/PopupMenuGtk.h @@ -24,11 +24,12 @@ #include "IntRect.h" #include "PopupMenu.h" #include "PopupMenuClient.h" -#include <glib.h> #include <wtf/HashMap.h> #include <wtf/PassRefPtr.h> #include <wtf/RefCounted.h> +typedef struct _GdkEventKey GdkEventKey; + namespace WebCore { class FrameView; @@ -43,19 +44,27 @@ public: virtual void hide(); virtual void updateFromElement(); virtual void disconnectClient(); + bool typeAheadFind(GdkEventKey*); private: PopupMenuClient* client() const { return m_popupClient; } + void resetTypeAheadFindState(); static void menuItemActivated(GtkMenuItem* item, PopupMenuGtk*); static void menuUnmapped(GtkWidget*, PopupMenuGtk*); static void menuPositionFunction(GtkMenu*, gint*, gint*, gboolean*, PopupMenuGtk*); static void menuRemoveItem(GtkWidget*, PopupMenuGtk*); + static int selectItemCallback(GtkMenuItem*, PopupMenuGtk*); + static int keyPressEventCallback(GtkWidget*, GdkEventKey*, PopupMenuGtk*); PopupMenuClient* m_popupClient; IntPoint m_menuPosition; PlatformRefPtr<GtkMenu> m_popup; HashMap<GtkWidget*, int> m_indexMap; + String m_currentSearchString; + uint32_t m_previousKeyEventTimestamp; + unsigned int m_previousKeyEventCharacter; + GtkWidget* m_currentlySelectedMenuItem; }; } diff --git a/WebCore/platform/haiku/LocalizedStringsHaiku.cpp b/WebCore/platform/haiku/LocalizedStringsHaiku.cpp index e5ca001..5587fa2 100644 --- a/WebCore/platform/haiku/LocalizedStringsHaiku.cpp +++ b/WebCore/platform/haiku/LocalizedStringsHaiku.cpp @@ -409,6 +409,36 @@ String validationMessageValueMissingText() return String(); } +String validationMessageValueMissingForCheckboxText() +{ + notImplemented(); + return validationMessageValueMissingText(); +} + +String validationMessageValueMissingForFileText() +{ + notImplemented(); + return validationMessageValueMissingText(); +} + +String validationMessageValueMissingForMultipleFileText() +{ + notImplemented(); + return validationMessageValueMissingText(); +} + +String validationMessageValueMissingForRadioText() +{ + notImplemented(); + return validationMessageValueMissingText(); +} + +String validationMessageValueMissingForSelectText() +{ + notImplemented(); + return validationMessageValueMissingText(); +} + String validationMessageTypeMismatchText() { notImplemented(); diff --git a/WebCore/platform/image-decoders/ImageDecoder.h b/WebCore/platform/image-decoders/ImageDecoder.h index 4b593f9..dde8550 100644 --- a/WebCore/platform/image-decoders/ImageDecoder.h +++ b/WebCore/platform/image-decoders/ImageDecoder.h @@ -326,6 +326,9 @@ namespace WebCore { // transparency. virtual bool supportsAlpha() const { return true; } + // Whether or not the gamma and color profile are applied. + bool ignoresGammaAndColorProfile() const { return m_ignoreGammaAndColorProfile; } + // Sets the "decode failure" flag. For caller convenience (since so // many callers want to return false after calling this), returns false // to enable easy tailcalling. Subclasses may override this to also diff --git a/WebCore/platform/image-decoders/cg/ImageDecoderCG.cpp b/WebCore/platform/image-decoders/cg/ImageDecoderCG.cpp index 32e94e0..3974f0e 100644 --- a/WebCore/platform/image-decoders/cg/ImageDecoderCG.cpp +++ b/WebCore/platform/image-decoders/cg/ImageDecoderCG.cpp @@ -98,7 +98,7 @@ NativeImagePtr RGBA32Buffer::asNewNativeImage() const CGImageAlphaInfo alphaInfo = m_premultiplyAlpha ? kCGImageAlphaPremultipliedFirst : kCGImageAlphaFirst; return CGImageCreate(width(), height(), 8, 32, width() * sizeof(PixelData), colorSpace.get(), - alphaInfo | kCGBitmapByteOrder32Host, dataProvider.get(), 0, false, kCGRenderingIntentDefault); + alphaInfo | kCGBitmapByteOrder32Host, dataProvider.get(), 0, /*shouldInterpolate=*/true, kCGRenderingIntentDefault); } } // namespace WebCore diff --git a/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp b/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp index d1de2ca..ff1262e 100644 --- a/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp +++ b/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp @@ -241,7 +241,8 @@ public: if (!m_decoder->setSize(m_info.image_width, m_info.image_height)) return false; - m_decoder->setColorProfile(readColorProfile(info())); + if (!m_decoder->ignoresGammaAndColorProfile()) + m_decoder->setColorProfile(readColorProfile(info())); if (m_decodingSizeOnly) { // We can stop here. Reduce our buffer length and available diff --git a/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp b/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp index 8b81896..794a474 100644 --- a/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp +++ b/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp @@ -265,7 +265,7 @@ void PNGImageDecoder::headerAvailable() int bitDepth, colorType, interlaceType, compressionType, filterType, channels; png_get_IHDR(png, info, &width, &height, &bitDepth, &colorType, &interlaceType, &compressionType, &filterType); - if (colorType == PNG_COLOR_TYPE_RGB || colorType == PNG_COLOR_TYPE_RGB_ALPHA) { + if ((colorType == PNG_COLOR_TYPE_RGB || colorType == PNG_COLOR_TYPE_RGB_ALPHA) && !m_ignoreGammaAndColorProfile) { // We currently support color profiles only for RGB and RGBA PNGs. Supporting // color profiles for gray-scale images is slightly tricky, at least using the // CoreGraphics ICC library, because we expand gray-scale images to RGB but we diff --git a/WebCore/platform/mac/ScrollViewMac.mm b/WebCore/platform/mac/ScrollViewMac.mm index 7ef5dc4..93ec971 100644 --- a/WebCore/platform/mac/ScrollViewMac.mm +++ b/WebCore/platform/mac/ScrollViewMac.mm @@ -147,7 +147,8 @@ void ScrollView::platformSetScrollbarsSuppressed(bool repaintOnUnsuppress) void ScrollView::platformSetScrollPosition(const IntPoint& scrollPoint) { BEGIN_BLOCK_OBJC_EXCEPTIONS; - NSPoint tempPoint = { max(0, scrollPoint.x()), max(0, scrollPoint.y()) }; // Don't use NSMakePoint to work around 4213314. + NSPoint floatPoint = scrollPoint; + NSPoint tempPoint = { max(-[scrollView() scrollOrigin].x, floatPoint.x), max(-[scrollView() scrollOrigin].y, floatPoint.y) }; // Don't use NSMakePoint to work around 4213314. [documentView() scrollPoint:tempPoint]; END_BLOCK_OBJC_EXCEPTIONS; } @@ -202,4 +203,11 @@ bool ScrollView::platformIsOffscreen() const return ![platformWidget() window] || ![[platformWidget() window] isVisible]; } +void ScrollView::platformSetScrollOrigin(const IntPoint& origin, bool updatePosition) +{ + BEGIN_BLOCK_OBJC_EXCEPTIONS; + [scrollView() setScrollOrigin:origin updatePosition:updatePosition]; + END_BLOCK_OBJC_EXCEPTIONS; +} + } // namespace WebCore diff --git a/WebCore/platform/mock/GeolocationClientMock.cpp b/WebCore/platform/mock/GeolocationClientMock.cpp new file mode 100644 index 0000000..3c4697f --- /dev/null +++ b/WebCore/platform/mock/GeolocationClientMock.cpp @@ -0,0 +1,135 @@ +/* + * 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. + */ + +#include "config.h" +#include "GeolocationClientMock.h" + +#if ENABLE(CLIENT_BASED_GEOLOCATION) + +#include "GeolocationController.h" +#include "GeolocationError.h" +#include "GeolocationPosition.h" + +namespace WebCore { + +GeolocationClientMock::GeolocationClientMock() + : m_controller(0) + , m_timer(this, &GeolocationClientMock::timerFired) + , m_isActive(false) +{ +} + +GeolocationClientMock::~GeolocationClientMock() +{ + ASSERT(!m_isActive); +} + +void GeolocationClientMock::setController(GeolocationController *controller) +{ + ASSERT(controller && !m_controller); + m_controller = controller; +} + +void GeolocationClientMock::setPosition(PassRefPtr<GeolocationPosition> position) +{ + m_lastPosition = position; + m_lastError = 0; + asyncUpdateController(); +} + +void GeolocationClientMock::setError(PassRefPtr<GeolocationError> error) +{ + m_lastError = error; + m_lastPosition = 0; + asyncUpdateController(); +} + +void GeolocationClientMock::reset() +{ + m_lastPosition = 0; + m_lastError = 0; +} + +void GeolocationClientMock::geolocationDestroyed() +{ + ASSERT(!m_isActive); +} + +void GeolocationClientMock::startUpdating() +{ + ASSERT(!m_isActive); + m_isActive = true; + asyncUpdateController(); +} + +void GeolocationClientMock::stopUpdating() +{ + ASSERT(m_isActive); + m_isActive = false; + m_timer.stop(); +} + +void GeolocationClientMock::setEnableHighAccuracy(bool) +{ + // FIXME: We need to add some tests regarding "high accuracy" mode. + // See https://bugs.webkit.org/show_bug.cgi?id=49438 +} + +GeolocationPosition* GeolocationClientMock::lastPosition() +{ + return m_lastPosition.get(); +} + +void GeolocationClientMock::asyncUpdateController() +{ + ASSERT(m_controller); + if (m_isActive && !m_timer.isActive()) + m_timer.startOneShot(0); +} + +void GeolocationClientMock::timerFired(Timer<GeolocationClientMock>* timer) +{ + ASSERT_UNUSED(timer, timer == &m_timer); + updateController(); +} + +void GeolocationClientMock::updateController() +{ + ASSERT(m_controller); + + if (m_lastPosition.get()) + m_controller->positionChanged(m_lastPosition.get()); + else if (m_lastError.get()) + m_controller->errorOccurred(m_lastError.get()); +} + +} // WebCore + +#endif // ENABLE(CLIENT_BASED_GEOLOCATION) diff --git a/WebCore/platform/mock/GeolocationClientMock.h b/WebCore/platform/mock/GeolocationClientMock.h new file mode 100644 index 0000000..f57afa9 --- /dev/null +++ b/WebCore/platform/mock/GeolocationClientMock.h @@ -0,0 +1,84 @@ +/* + * 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 GeolocationClientMock_h +#define GeolocationClientMock_h + +#if ENABLE(CLIENT_BASED_GEOLOCATION) + +#include "GeolocationClient.h" +#include "PlatformString.h" +#include "Timer.h" + +#include <wtf/PassRefPtr.h> +#include <wtf/RefPtr.h> + +namespace WebCore { + +class GeolocationController; +class GeolocationPosition; +class GeolocationError; + +// Provides a mock object for the geolocation client +class GeolocationClientMock : public GeolocationClient { +public: + GeolocationClientMock(); + virtual ~GeolocationClientMock(); + + void reset(); + void setController(GeolocationController*); + + void setError(PassRefPtr<GeolocationError>); + void setPosition(PassRefPtr<GeolocationPosition>); + + // GeolocationClient + virtual void geolocationDestroyed(); + virtual void startUpdating(); + virtual void stopUpdating(); + virtual void setEnableHighAccuracy(bool); + virtual GeolocationPosition* lastPosition(); + +private: + void timerFired(Timer<GeolocationClientMock>*); + void asyncUpdateController(); + void updateController(); + + GeolocationController* m_controller; + RefPtr<GeolocationPosition> m_lastPosition; + RefPtr<GeolocationError> m_lastError; + Timer<GeolocationClientMock> m_timer; + bool m_isActive; +}; + +} + +#endif // ENABLE(CLIENT_BASED_GEOLOCATION) + +#endif diff --git a/WebCore/platform/mock/SpeechInputClientMock.cpp b/WebCore/platform/mock/SpeechInputClientMock.cpp index 820152c..16f2825 100644 --- a/WebCore/platform/mock/SpeechInputClientMock.cpp +++ b/WebCore/platform/mock/SpeechInputClientMock.cpp @@ -81,18 +81,21 @@ void SpeechInputClientMock::cancelRecognition(int requestId) } } -void SpeechInputClientMock::setRecognitionResult(const String& result, const AtomicString& language) +void SpeechInputClientMock::addRecognitionResult(const String& result, double confidence, const AtomicString& language) { if (language.isEmpty()) - m_resultForEmptyLanguage = result; - else - m_recognitionResult.set(language, result); + m_resultsForEmptyLanguage.append(SpeechInputResult::create(result, confidence)); + else { + if (!m_recognitionResults.contains(language)) + m_recognitionResults.set(language, SpeechInputResultArray()); + m_recognitionResults.find(language)->second.append(SpeechInputResult::create(result, confidence)); + } } void SpeechInputClientMock::clearResults() { - m_resultForEmptyLanguage = String(); - m_recognitionResult.clear(); + m_resultsForEmptyLanguage.clear(); + m_recognitionResults.clear(); } void SpeechInputClientMock::timerFired(WebCore::Timer<SpeechInputClientMock>*) @@ -102,18 +105,17 @@ void SpeechInputClientMock::timerFired(WebCore::Timer<SpeechInputClientMock>*) m_listener->didCompleteRecording(m_requestId); m_timer.startOneShot(0); } else { - SpeechInputResultArray results; bool noResultsFound = false; // Empty language case must be handled separately to avoid problems with HashMap and empty keys. if (m_language.isEmpty()) { - if (!m_resultForEmptyLanguage.isNull()) - results.append(SpeechInputResult::create(m_resultForEmptyLanguage, 1.0)); + if (!m_resultsForEmptyLanguage.isEmpty()) + m_listener->setRecognitionResult(m_requestId, m_resultsForEmptyLanguage); else noResultsFound = true; } else { - if (m_recognitionResult.contains(m_language)) - results.append(SpeechInputResult::create(m_recognitionResult.get(m_language), 1.0)); + if (m_recognitionResults.contains(m_language)) + m_listener->setRecognitionResult(m_requestId, m_recognitionResults.get(m_language)); else noResultsFound = true; } @@ -124,10 +126,11 @@ void SpeechInputClientMock::timerFired(WebCore::Timer<SpeechInputClientMock>*) String error("error: no result found for language '"); error.append(m_language); error.append("'"); + SpeechInputResultArray results; results.append(SpeechInputResult::create(error, 1.0)); + m_listener->setRecognitionResult(m_requestId, results); } - m_listener->setRecognitionResult(m_requestId, results); m_listener->didCompleteRecognition(m_requestId); m_requestId = 0; } diff --git a/WebCore/platform/mock/SpeechInputClientMock.h b/WebCore/platform/mock/SpeechInputClientMock.h index c2219b4..6f72191 100644 --- a/WebCore/platform/mock/SpeechInputClientMock.h +++ b/WebCore/platform/mock/SpeechInputClientMock.h @@ -33,6 +33,7 @@ #include "PlatformString.h" #include "SpeechInputClient.h" +#include "SpeechInputResult.h" #include "Timer.h" #include <wtf/HashMap.h> #include <wtf/text/StringHash.h> @@ -48,7 +49,7 @@ class SpeechInputClientMock : public SpeechInputClient { public: SpeechInputClientMock(); - void setRecognitionResult(const String& result, const AtomicString& language); + void addRecognitionResult(const String& result, double confidence, const AtomicString& language); void clearResults(); // SpeechInputClient methods. @@ -65,9 +66,9 @@ private: SpeechInputListener* m_listener; int m_requestId; - HashMap<String, String> m_recognitionResult; + HashMap<String, SpeechInputResultArray> m_recognitionResults; AtomicString m_language; - String m_resultForEmptyLanguage; + SpeechInputResultArray m_resultsForEmptyLanguage; }; } // namespace WebCore diff --git a/WebCore/platform/network/ResourceRawHeaders.h b/WebCore/platform/network/ResourceLoadInfo.h index e5f8d99..a1b958c 100644 --- a/WebCore/platform/network/ResourceRawHeaders.h +++ b/WebCore/platform/network/ResourceLoadInfo.h @@ -24,14 +24,19 @@ */ -#ifndef ResourceRawHeaders_h -#define ResourceRawHeaders_h +#ifndef ResourceLoadInfo_h +#define ResourceLoadInfo_h #include "HTTPHeaderMap.h" namespace WebCore { -struct ResourceRawHeaders : RefCounted<ResourceRawHeaders> { +struct ResourceLoadInfo : RefCounted<ResourceLoadInfo> { + ResourceLoadInfo() + : httpStatusCode(0) { } + + int httpStatusCode; + String httpStatusText; HTTPHeaderMap requestHeaders; HTTPHeaderMap responseHeaders; }; diff --git a/WebCore/platform/network/ResourceResponseBase.cpp b/WebCore/platform/network/ResourceResponseBase.cpp index a254168..55eac76 100644 --- a/WebCore/platform/network/ResourceResponseBase.cpp +++ b/WebCore/platform/network/ResourceResponseBase.cpp @@ -520,18 +520,18 @@ void ResourceResponseBase::setResourceLoadTiming(PassRefPtr<ResourceLoadTiming> m_resourceLoadTiming = resourceLoadTiming; } -PassRefPtr<ResourceRawHeaders> ResourceResponseBase::resourceRawHeaders() const +PassRefPtr<ResourceLoadInfo> ResourceResponseBase::resourceLoadInfo() const { lazyInit(); - return m_resourceRawHeaders.get(); + return m_resourceLoadInfo.get(); } -void ResourceResponseBase::setResourceRawHeaders(PassRefPtr<ResourceRawHeaders> headers) +void ResourceResponseBase::setResourceLoadInfo(PassRefPtr<ResourceLoadInfo> loadInfo) { lazyInit(); - m_resourceRawHeaders = headers; + m_resourceLoadInfo = loadInfo; } void ResourceResponseBase::lazyInit() const diff --git a/WebCore/platform/network/ResourceResponseBase.h b/WebCore/platform/network/ResourceResponseBase.h index 4da13bb..9c54bab 100644 --- a/WebCore/platform/network/ResourceResponseBase.h +++ b/WebCore/platform/network/ResourceResponseBase.h @@ -29,8 +29,8 @@ #include "HTTPHeaderMap.h" #include "KURL.h" +#include "ResourceLoadInfo.h" #include "ResourceLoadTiming.h" -#include "ResourceRawHeaders.h" #include <wtf/PassOwnPtr.h> #include <wtf/RefPtr.h> @@ -110,8 +110,8 @@ public: ResourceLoadTiming* resourceLoadTiming() const; void setResourceLoadTiming(PassRefPtr<ResourceLoadTiming>); - PassRefPtr<ResourceRawHeaders> resourceRawHeaders() const; - void setResourceRawHeaders(PassRefPtr<ResourceRawHeaders>); + PassRefPtr<ResourceLoadInfo> resourceLoadInfo() const; + void setResourceLoadInfo(PassRefPtr<ResourceLoadInfo>); // The ResourceResponse subclass may "shadow" this method to provide platform-specific memory usage information unsigned memoryUsage() const @@ -147,7 +147,7 @@ protected: unsigned m_connectionID; bool m_connectionReused : 1; RefPtr<ResourceLoadTiming> m_resourceLoadTiming; - RefPtr<ResourceRawHeaders> m_resourceRawHeaders; + RefPtr<ResourceLoadInfo> m_resourceLoadInfo; bool m_isNull : 1; diff --git a/WebCore/platform/network/cf/SocketStreamHandleCFNet.cpp b/WebCore/platform/network/cf/SocketStreamHandleCFNet.cpp index 800301a..24b5835 100644 --- a/WebCore/platform/network/cf/SocketStreamHandleCFNet.cpp +++ b/WebCore/platform/network/cf/SocketStreamHandleCFNet.cpp @@ -332,7 +332,7 @@ void SocketStreamHandle::createStreams() // But SOCKS5 credentials don't work at the time of this writing anyway, see <rdar://6776698>. const void* proxyKeys[] = { kCFStreamPropertySOCKSProxyHost, kCFStreamPropertySOCKSProxyPort }; const void* proxyValues[] = { m_proxyHost.get(), m_proxyPort.get() }; - RetainPtr<CFDictionaryRef> connectDictionary(AdoptCF, CFDictionaryCreate(0, proxyKeys, proxyValues, sizeof(proxyKeys) / sizeof(*proxyKeys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); + RetainPtr<CFDictionaryRef> connectDictionary(AdoptCF, CFDictionaryCreate(0, proxyKeys, proxyValues, WTF_ARRAY_LENGTH(proxyKeys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); CFReadStreamSetProperty(m_readStream.get(), kCFStreamPropertySOCKSProxy, connectDictionary.get()); break; } @@ -344,7 +344,7 @@ void SocketStreamHandle::createStreams() if (shouldUseSSL()) { const void* keys[] = { kCFStreamSSLPeerName, kCFStreamSSLLevel }; const void* values[] = { host.get(), kCFStreamSocketSecurityLevelNegotiatedSSL }; - RetainPtr<CFDictionaryRef> settings(AdoptCF, CFDictionaryCreate(0, keys, values, sizeof(keys) / sizeof(*keys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); + RetainPtr<CFDictionaryRef> settings(AdoptCF, CFDictionaryCreate(0, keys, values, WTF_ARRAY_LENGTH(keys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); CFReadStreamSetProperty(m_readStream.get(), kCFStreamPropertySSLSettings, settings.get()); CFWriteStreamSetProperty(m_writeStream.get(), kCFStreamPropertySSLSettings, settings.get()); } diff --git a/WebCore/platform/network/soup/ResourceHandleSoup.cpp b/WebCore/platform/network/soup/ResourceHandleSoup.cpp index 0f97867..c1933e3 100644 --- a/WebCore/platform/network/soup/ResourceHandleSoup.cpp +++ b/WebCore/platform/network/soup/ResourceHandleSoup.cpp @@ -245,6 +245,8 @@ static void gotHeadersCallback(SoupMessage* msg, gpointer data) if (!client) return; + ASSERT(d->m_response.isNull()); + fillResponseFromMessage(msg, &d->m_response); client->didReceiveResponse(handle.get(), d->m_response); } @@ -272,6 +274,8 @@ static void contentSniffedCallback(SoupMessage* msg, const char* sniffedType, GH if (!client) return; + ASSERT(d->m_response.isNull()); + fillResponseFromMessage(msg, &d->m_response); client->didReceiveResponse(handle.get(), d->m_response); } @@ -291,6 +295,8 @@ static void gotChunkCallback(SoupMessage* msg, SoupBuffer* chunk, gpointer data) if (!client) return; + ASSERT(!d->m_response.isNull()); + client->didReceiveData(handle.get(), chunk->data, chunk->length, false); } @@ -329,14 +335,15 @@ static gboolean parseDataUrl(gpointer callbackData) String mimeType = extractMIMETypeFromMediaType(mediaType); String charset = extractCharsetFromMediaType(mediaType); - ResourceResponse response; - response.setURL(handle->firstRequest().url()); - response.setMimeType(mimeType); + ASSERT(d->m_response.isNull()); + + d->m_response.setURL(handle->firstRequest().url()); + d->m_response.setMimeType(mimeType); // For non base64 encoded data we have to convert to UTF-16 early // due to limitations in KURL - response.setTextEncodingName(isBase64 ? charset : "UTF-16"); - client->didReceiveResponse(handle, response); + d->m_response.setTextEncodingName(isBase64 ? charset : "UTF-16"); + client->didReceiveResponse(handle, d->m_response); // The load may be cancelled, and the client may be destroyed // by any of the client reporting calls, so we check, and bail @@ -496,6 +503,8 @@ static void sendRequestCallback(GObject* source, GAsyncResult* res, gpointer use } if (d->m_soupMessage && statusWillBeHandledBySoup(d->m_soupMessage->status_code)) { + ASSERT(d->m_response.isNull()); + fillResponseFromMessage(soupMsg, &d->m_response); client->didReceiveResponse(handle.get(), d->m_response); @@ -526,18 +535,14 @@ static void sendRequestCallback(GObject* source, GAsyncResult* res, gpointer use // readCallback needs it g_object_set_data(G_OBJECT(d->m_inputStream.get()), "webkit-resource", handle.get()); - // We need to check if it's a file: URL and if it is a regular - // file as it could be a directory. In that case Soup properly - // returns a stream whose content is a HTML with a list of files - // in the directory - if (equalIgnoringCase(handle->firstRequest().url().protocol(), "file") - && G_IS_FILE_INPUT_STREAM(in)) { - ResourceResponse response; - - response.setURL(handle->firstRequest().url()); - response.setMimeType(webkit_soup_request_get_content_type(d->m_soupRequest.get())); - response.setExpectedContentLength(webkit_soup_request_get_content_length(d->m_soupRequest.get())); - client->didReceiveResponse(handle.get(), response); + // Ensure a response is sent for any protocols that don't explicitly support responses + // through got-headers signal or content sniffing. + // (e.g. file and GIO based protocol). + if (!handle->shouldContentSniff() && d->m_response.isNull()) { + d->m_response.setURL(handle->firstRequest().url()); + d->m_response.setMimeType(webkit_soup_request_get_content_type(d->m_soupRequest.get())); + d->m_response.setExpectedContentLength(webkit_soup_request_get_content_length(d->m_soupRequest.get())); + client->didReceiveResponse(handle.get(), d->m_response); if (d->m_cancelled) { cleanupSoupRequestOperation(handle.get()); @@ -581,10 +586,11 @@ static bool startHttp(ResourceHandle* handle) if (!handle->shouldContentSniff()) soup_message_disable_feature(soupMessage, SOUP_TYPE_CONTENT_SNIFFER); + else + g_signal_connect(soupMessage, "content-sniffed", G_CALLBACK(contentSniffedCallback), handle); g_signal_connect(soupMessage, "restarted", G_CALLBACK(restartedCallback), handle); g_signal_connect(soupMessage, "got-headers", G_CALLBACK(gotHeadersCallback), handle); - g_signal_connect(soupMessage, "content-sniffed", G_CALLBACK(contentSniffedCallback), handle); d->m_gotChunkHandler = g_signal_connect(soupMessage, "got-chunk", G_CALLBACK(gotChunkCallback), handle); #ifdef HAVE_LIBSOUP_2_29_90 @@ -813,6 +819,9 @@ static void readCallback(GObject* source, GAsyncResult* asyncResult, gpointer da return; } + // It's mandatory to have sent a response before sending data + ASSERT(!d->m_response.isNull()); + d->m_total += bytesRead; if (G_LIKELY(!convertToUTF16)) client->didReceiveData(handle.get(), d->m_buffer, bytesRead, d->m_total); diff --git a/WebCore/platform/network/soup/cache/soup-http-input-stream.c b/WebCore/platform/network/soup/cache/soup-http-input-stream.c index dc95d6e..195c458 100644 --- a/WebCore/platform/network/soup/cache/soup-http-input-stream.c +++ b/WebCore/platform/network/soup/cache/soup-http-input-stream.c @@ -598,6 +598,7 @@ send_async_finished (GInputStream *stream) g_error_free (error); } g_simple_async_result_complete (result); + g_object_unref (result); } static void diff --git a/WebCore/platform/network/soup/cache/soup-request-http.c b/WebCore/platform/network/soup/cache/soup-request-http.c index f157cfc..f3fe2ec 100644 --- a/WebCore/platform/network/soup/cache/soup-request-http.c +++ b/WebCore/platform/network/soup/cache/soup-request-http.c @@ -151,6 +151,13 @@ conditional_get_ready_cb (SoupSession *session, SoupMessage *msg, gpointer user_ g_simple_async_result_set_op_res_gpointer (simple, httpstream, g_object_unref); soup_message_got_headers (helper->original); + + /* FIXME: Uncomment this when this becomes part of libsoup + * if (!soup_message_disables_feature(helper->original, SOUP_TYPE_CONTENT_SNIFFER)) { + * const gchar *content_type = soup_message_headers_get_content_type (msg->response_headers, NULL); + * soup_message_content_sniffed (helper->original, content_type, NULL); + * } + */ content_type = soup_message_headers_get_content_type (msg->response_headers, NULL); soup_message_content_sniffed (helper->original, content_type, NULL); @@ -215,6 +222,13 @@ send_async_cb (gpointer data) /* Issue signals */ soup_message_got_headers (helper->http->priv->msg); + + /* FIXME: Uncomment this when this becomes part of libsoup + * if (!soup_message_disables_feature(helper->http->priv->msg, SOUP_TYPE_CONTENT_SNIFFER)) { + * const gchar *content_type = soup_message_headers_get_content_type (helper->http->priv->msg->response_headers, NULL); + * soup_message_content_sniffed (helper->http->priv->msg, content_type, NULL); + * } + */ content_type = soup_message_headers_get_content_type (helper->http->priv->msg->response_headers, NULL); soup_message_content_sniffed (helper->http->priv->msg, content_type, NULL); @@ -225,6 +239,7 @@ send_async_cb (gpointer data) g_object_unref (simple); } + g_object_unref (helper->http); g_slice_free (SendAsyncHelper, helper); return FALSE; @@ -256,7 +271,7 @@ webkit_soup_request_http_send_async (WebKitSoupRequest *request, the signals must be also emitted asynchronously */ SendAsyncHelper *helper = g_slice_new (SendAsyncHelper); - helper->http = http; + helper->http = g_object_ref (http); helper->callback = callback; helper->user_data = user_data; g_timeout_add (0, send_async_cb, helper); diff --git a/WebCore/platform/network/soup/cache/webkit/soup-cache.c b/WebCore/platform/network/soup/cache/webkit/soup-cache.c index 73b15ba..b916468 100644 --- a/WebCore/platform/network/soup/cache/webkit/soup-cache.c +++ b/WebCore/platform/network/soup/cache/webkit/soup-cache.c @@ -147,6 +147,8 @@ get_cacheability (WebKitSoupCache *cache, SoupMessage *msg) soup_header_free_param_list (hash); return WEBKIT_SOUP_CACHE_UNCACHEABLE; } + + soup_header_free_param_list (hash); } switch (msg->status_code) { @@ -284,14 +286,12 @@ webkit_soup_cache_entry_set_freshness (WebKitSoupCacheEntry *entry, SoupMessage { const char *cache_control; const char *expires, *date, *last_modified; - GHashTable *hash; - - hash = NULL; cache_control = soup_message_headers_get (entry->headers, "Cache-Control"); if (cache_control) { const char *max_age, *s_maxage; gint64 freshness_lifetime = 0; + GHashTable *hash; WebKitSoupCachePrivate *priv = WEBKIT_SOUP_CACHE_GET_PRIVATE (cache); hash = soup_header_parse_param_list (cache_control); @@ -323,10 +323,9 @@ webkit_soup_cache_entry_set_freshness (WebKitSoupCacheEntry *entry, SoupMessage soup_header_free_param_list (hash); return; } - } - if (hash != NULL) soup_header_free_param_list (hash); + } /* If the 'Expires' response header is present, use its value * minus the value of the 'Date' response header @@ -702,6 +701,7 @@ webkit_soup_cache_entry_remove (WebKitSoupCache *cache, WebKitSoupCacheEntry *en return FALSE; } + g_assert (!entry->dirty); g_assert (g_list_length (cache->priv->lru_start) == g_hash_table_size (cache->priv->cache)); /* Remove from cache */ @@ -965,16 +965,21 @@ msg_got_headers_cb (SoupMessage *msg, gpointer user_data) entry = g_hash_table_lookup (cache->priv->cache, key); g_free (key); - g_return_if_fail (entry); - - entry->being_validated = FALSE; - - /* We update the headers of the existing cache item, - plus its age */ - soup_message_headers_foreach (msg->response_headers, - (SoupMessageHeadersForeachFunc)update_headers, - entry->headers); - webkit_soup_cache_entry_set_freshness (entry, msg, cache); + /* It's possible to get a CACHE_VALIDATES with no + * entry in the hash table. This could happen if for + * example the soup client is the one creating the + * conditional request. + */ + if (entry) { + entry->being_validated = FALSE; + + /* We update the headers of the existing cache item, + plus its age */ + soup_message_headers_foreach (msg->response_headers, + (SoupMessageHeadersForeachFunc)update_headers, + entry->headers); + webkit_soup_cache_entry_set_freshness (entry, msg, cache); + } } } @@ -992,6 +997,7 @@ webkit_soup_cache_send_response (WebKitSoupCache *cache, SoupMessage *msg) key = soup_message_get_cache_key (msg); entry = g_hash_table_lookup (cache->priv->cache, key); + g_free (key); g_return_val_if_fail (entry, NULL); /* If we are told to send a response from cache any validation @@ -1251,7 +1257,6 @@ webkit_soup_cache_has_response (WebKitSoupCache *cache, SoupMessage *msg) char *key; WebKitSoupCacheEntry *entry; const char *cache_control; - GHashTable *hash; gpointer value; gboolean must_revalidate; int max_age, max_stale, min_fresh; @@ -1259,6 +1264,7 @@ webkit_soup_cache_has_response (WebKitSoupCache *cache, SoupMessage *msg) key = soup_message_get_cache_key (msg); entry = g_hash_table_lookup (cache->priv->cache, key); + g_free (key); /* 1. The presented Request-URI and that of stored response * match @@ -1300,7 +1306,13 @@ webkit_soup_cache_has_response (WebKitSoupCache *cache, SoupMessage *msg) /* TODO */ - /* 4. The presented request and stored response are free from + /* 4. The request is a conditional request issued by the client. + */ + if (soup_message_headers_get (msg->request_headers, "If-Modified-Since") || + soup_message_headers_get (msg->request_headers, "If-None-Match")) + return WEBKIT_SOUP_CACHE_RESPONSE_STALE; + + /* 5. The presented request and stored response are free from * directives that would prevent its use. */ @@ -1309,10 +1321,10 @@ webkit_soup_cache_has_response (WebKitSoupCache *cache, SoupMessage *msg) cache_control = soup_message_headers_get (msg->request_headers, "Cache-Control"); if (cache_control) { - hash = soup_header_parse_param_list (cache_control); + GHashTable *hash = soup_header_parse_param_list (cache_control); if (g_hash_table_lookup_extended (hash, "no-store", NULL, NULL)) { - g_hash_table_destroy (hash); + soup_header_free_param_list (hash); return WEBKIT_SOUP_CACHE_RESPONSE_STALE; } @@ -1336,7 +1348,7 @@ webkit_soup_cache_has_response (WebKitSoupCache *cache, SoupMessage *msg) if (value) min_fresh = (int)MIN (g_ascii_strtoll (value, NULL, 10), G_MAXINT32); - g_hash_table_destroy (hash); + soup_header_free_param_list (hash); if (max_age != -1) { guint current_age = webkit_soup_cache_entry_get_current_age (entry); @@ -1349,7 +1361,7 @@ webkit_soup_cache_has_response (WebKitSoupCache *cache, SoupMessage *msg) } } - /* 5. The stored response is either: fresh, allowed to be + /* 6. The stored response is either: fresh, allowed to be * served stale or succesfully validated */ /* TODO consider also proxy-revalidate & s-maxage */ @@ -1597,7 +1609,7 @@ webkit_soup_cache_load (WebKitSoupCache *cache) g_free (filename); variant_format = g_variant_type_new (WEBKIT_SOUP_CACHE_ENTRIES_FORMAT); - cache_variant = g_variant_new_from_data (variant_format, (const gchar *)contents, length, FALSE, NULL, NULL); + cache_variant = g_variant_new_from_data (variant_format, (const gchar *)contents, length, FALSE, g_free, contents); g_variant_type_free (variant_format); g_variant_get (cache_variant, WEBKIT_SOUP_CACHE_ENTRIES_FORMAT, &entries_iter); diff --git a/WebCore/platform/qt/DragImageQt.cpp b/WebCore/platform/qt/DragImageQt.cpp index 3a077e1..90b1bbc 100644 --- a/WebCore/platform/qt/DragImageQt.cpp +++ b/WebCore/platform/qt/DragImageQt.cpp @@ -31,17 +31,28 @@ namespace WebCore { -IntSize dragImageSize(DragImageRef) +IntSize dragImageSize(DragImageRef image) { - return IntSize(0, 0); + if (!image) + return IntSize(); + + return image->size(); } -void deleteDragImage(DragImageRef) +void deleteDragImage(DragImageRef image) { + delete image; } -DragImageRef scaleDragImage(DragImageRef image, FloatSize) +DragImageRef scaleDragImage(DragImageRef image, FloatSize scale) { + if (!image) + return 0; + + int scaledWidth = image->width() * scale.width(); + int scaledHeight = image->height() * scale.height(); + + *image = image->scaled(scaledWidth, scaledHeight); return image; } @@ -50,9 +61,12 @@ DragImageRef dissolveDragImageToFraction(DragImageRef image, float) return image; } -DragImageRef createDragImageFromImage(Image*) +DragImageRef createDragImageFromImage(Image* image) { - return 0; + if (!image) + return 0; + + return new QPixmap(*image->nativeImageForCurrentFrame()); } DragImageRef createDragImageIconForCachedImage(CachedImage*) diff --git a/WebCore/platform/qt/PasteboardQt.cpp b/WebCore/platform/qt/PasteboardQt.cpp index ac54fdb..b98e84e 100644 --- a/WebCore/platform/qt/PasteboardQt.cpp +++ b/WebCore/platform/qt/PasteboardQt.cpp @@ -77,8 +77,10 @@ void Pasteboard::writeSelection(Range* selectedRange, bool canSmartCopyOrDelete, bool Pasteboard::canSmartReplace() { +#ifndef QT_NO_CLIPBOARD if (QApplication::clipboard()->mimeData()->hasFormat((QLatin1String("application/vnd.qtwebkit.smartpaste")))) return true; +#endif return false; } diff --git a/WebCore/platform/qt/ScrollViewQt.cpp b/WebCore/platform/qt/ScrollViewQt.cpp index 17ad253..8fdfd29 100644 --- a/WebCore/platform/qt/ScrollViewQt.cpp +++ b/WebCore/platform/qt/ScrollViewQt.cpp @@ -34,14 +34,6 @@ namespace WebCore { -void ScrollView::platformInit() -{ -} - -void ScrollView::platformDestroy() -{ -} - void ScrollView::platformAddChild(Widget*) { } diff --git a/WebCore/platform/text/TextBoundaries.cpp b/WebCore/platform/text/TextBoundaries.cpp index 8eaffca..fbb261b 100644 --- a/WebCore/platform/text/TextBoundaries.cpp +++ b/WebCore/platform/text/TextBoundaries.cpp @@ -36,6 +36,32 @@ using namespace Unicode; namespace WebCore { +int endOfFirstWordBoundaryContext(const UChar* characters, int length) +{ + for (int i = 0; i < length; ) { + int first = i; + UChar32 ch; + U16_NEXT(characters, i, length, ch); + if (!requiresContextForWordBoundary(ch)) + return first; + } + return length; +} + +int startOfLastWordBoundaryContext(const UChar* characters, int length) +{ + for (int i = length; i > 0; ) { + int last = i; + UChar32 ch; + U16_PREV(characters, 0, i, ch); + if (!requiresContextForWordBoundary(ch)) + return last; + } + return 0; +} + +#if !PLATFORM(BREWMP) && !PLATFORM(MAC) && !PLATFORM(QT) + int findNextWordFromIndex(const UChar* chars, int len, int position, bool forward) { TextBreakIterator* it = wordBreakIterator(chars, len); @@ -76,4 +102,6 @@ void findWordBoundary(const UChar* chars, int len, int position, int* start, int *start = textBreakPrevious(it); } +#endif // !PLATFORM(BREWMP) && !PLATFORM(MAC) && !PLATFORM(QT) + } // namespace WebCore diff --git a/WebCore/platform/text/TextBoundaries.h b/WebCore/platform/text/TextBoundaries.h index 7eb9cab..870ab62 100644 --- a/WebCore/platform/text/TextBoundaries.h +++ b/WebCore/platform/text/TextBoundaries.h @@ -35,6 +35,9 @@ namespace WebCore { return WTF::Unicode::hasLineBreakingPropertyComplexContext(ch); } + int endOfFirstWordBoundaryContext(const UChar* characters, int length); + int startOfLastWordBoundaryContext(const UChar* characters, int length); + void findWordBoundary(const UChar*, int len, int position, int* start, int* end); int findNextWordFromIndex(const UChar*, int len, int position, bool forward); diff --git a/WebCore/platform/text/TextCodecUTF16.cpp b/WebCore/platform/text/TextCodecUTF16.cpp index 95f4dc4..e88e83b 100644 --- a/WebCore/platform/text/TextCodecUTF16.cpp +++ b/WebCore/platform/text/TextCodecUTF16.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2004, 2006, 2008, 2010 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -117,8 +117,13 @@ String TextCodecUTF16::decode(const char* bytes, size_t length, bool, bool, bool CString TextCodecUTF16::encode(const UChar* characters, size_t length, UnencodableHandling) { - if (length > numeric_limits<size_t>::max() / 2) - CRASH(); + // We need to be sure we can double the length without overflowing. + // Since the passed-in length is the length of an actual existing + // character buffer, each character is two bytes, and we know + // the buffer doesn't occupy the entire address space, we can + // assert here that doubling the length does not overflow size_t + // and there's no need for a runtime check. + ASSERT(length <= numeric_limits<size_t>::max() / 2); char* bytes; CString string = CString::newUninitialized(length * 2, bytes); diff --git a/WebCore/platform/text/TextEncodingRegistry.cpp b/WebCore/platform/text/TextEncodingRegistry.cpp index fbe5826..6bf5552 100644 --- a/WebCore/platform/text/TextEncodingRegistry.cpp +++ b/WebCore/platform/text/TextEncodingRegistry.cpp @@ -189,8 +189,7 @@ static void addToTextCodecMap(const char* name, NewTextCodecFunction function, c static void pruneBlacklistedCodecs() { - size_t blacklistedCodecListLength = sizeof(textEncodingNameBlacklist) / sizeof(textEncodingNameBlacklist[0]); - for (size_t i = 0; i < blacklistedCodecListLength; ++i) { + for (size_t i = 0; i < WTF_ARRAY_LENGTH(textEncodingNameBlacklist); ++i) { const char* atomicName = textEncodingNameMap->get(textEncodingNameBlacklist[i]); if (!atomicName) continue; diff --git a/WebCore/platform/text/brew/StringBrew.cpp b/WebCore/platform/text/brew/StringBrew.cpp index 7869e0f..2da81e3 100644 --- a/WebCore/platform/text/brew/StringBrew.cpp +++ b/WebCore/platform/text/brew/StringBrew.cpp @@ -26,7 +26,7 @@ #include "config.h" #include "PlatformString.h" -#include <AEEStdLib.h> +#include <AEEstd.h> namespace WTF { @@ -35,7 +35,7 @@ String::String(const AECHAR* string) { // It is safe to cast AECHAR to UChar as both of them use 16 bits representation. const UChar* str = reinterpret_cast<const UChar*>(string); - const size_t len = WSTRLEN(string); + const size_t len = std_wstrlen(string); m_impl = StringImpl::create(str, len); } diff --git a/WebCore/platform/text/transcoder/FontTranscoder.cpp b/WebCore/platform/text/transcoder/FontTranscoder.cpp index 8e2f33f..68601f9 100644 --- a/WebCore/platform/text/transcoder/FontTranscoder.cpp +++ b/WebCore/platform/text/transcoder/FontTranscoder.cpp @@ -41,23 +41,23 @@ FontTranscoder::FontTranscoder() { m_converterTypes.add("MS PGothic", BackslashToYenSign); UChar unicodeNameMSPGothic[] = {0xFF2D, 0xFF33, 0x0020, 0xFF30, 0x30B4, 0x30B7, 0x30C3, 0x30AF}; - m_converterTypes.add(AtomicString(unicodeNameMSPGothic, sizeof(unicodeNameMSPGothic) / sizeof(UChar)), BackslashToYenSign); + m_converterTypes.add(AtomicString(unicodeNameMSPGothic, WTF_ARRAY_LENGTH(unicodeNameMSPGothic)), BackslashToYenSign); m_converterTypes.add("MS PMincho", BackslashToYenSign); UChar unicodeNameMSPMincho[] = {0xFF2D, 0xFF33, 0x0020, 0xFF30, 0x660E, 0x671D}; - m_converterTypes.add(AtomicString(unicodeNameMSPMincho, sizeof(unicodeNameMSPMincho) / sizeof(UChar)), BackslashToYenSign); + m_converterTypes.add(AtomicString(unicodeNameMSPMincho, WTF_ARRAY_LENGTH(unicodeNameMSPMincho)), BackslashToYenSign); m_converterTypes.add("MS Gothic", BackslashToYenSign); UChar unicodeNameMSGothic[] = {0xFF2D, 0xFF33, 0x0020, 0x30B4, 0x30B7, 0x30C3, 0x30AF}; - m_converterTypes.add(AtomicString(unicodeNameMSGothic, sizeof(unicodeNameMSGothic) / sizeof(UChar)), BackslashToYenSign); + m_converterTypes.add(AtomicString(unicodeNameMSGothic, WTF_ARRAY_LENGTH(unicodeNameMSGothic)), BackslashToYenSign); m_converterTypes.add("MS Mincho", BackslashToYenSign); UChar unicodeNameMSMincho[] = {0xFF2D, 0xFF33, 0x0020, 0x660E, 0x671D}; - m_converterTypes.add(AtomicString(unicodeNameMSMincho, sizeof(unicodeNameMSMincho) / sizeof(UChar)), BackslashToYenSign); + m_converterTypes.add(AtomicString(unicodeNameMSMincho, WTF_ARRAY_LENGTH(unicodeNameMSMincho)), BackslashToYenSign); m_converterTypes.add("Meiryo", BackslashToYenSign); UChar unicodeNameMeiryo[] = {0x30E1, 0x30A4, 0x30EA, 0x30AA}; - m_converterTypes.add(AtomicString(unicodeNameMeiryo, sizeof(unicodeNameMeiryo) / sizeof(UChar)), BackslashToYenSign); + m_converterTypes.add(AtomicString(unicodeNameMeiryo, WTF_ARRAY_LENGTH(unicodeNameMeiryo)), BackslashToYenSign); } FontTranscoder::ConverterType FontTranscoder::converterType(const FontDescription& fontDescription, const TextEncoding* encoding) const diff --git a/WebCore/platform/text/wince/TextBoundariesWinCE.cpp b/WebCore/platform/text/wince/TextBoundariesWinCE.cpp deleted file mode 100644 index f3070a4..0000000 --- a/WebCore/platform/text/wince/TextBoundariesWinCE.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (C) 2006 Zack Rusin <zack@kde.org> - * Copyright (C) 2007-2009 Torch Mobile, 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 "TextBoundaries.h" - -#include "NotImplemented.h" -#include "PlatformString.h" - -using namespace WTF::Unicode; - -namespace WebCore { - -int findNextWordFromIndex(const UChar * buffer, int len, int position, bool forward) -{ - notImplemented(); - return 0; -} - -void findWordBoundary(const UChar * buffer, int len, int position, int* start, int* end) -{ - if (position > len) { - *start = 0; - *end = 0; - return; - } - - String str(buffer, len); - - int currentPosition = position - 1; - String foundWord; - while (currentPosition >= 0 && isLetter(str[currentPosition])) { - UChar c = str[currentPosition]; - foundWord.insert(&c, 1, 0); - --currentPosition; - } - - // currentPosition == 0 means the first char is not letter - // currentPosition == -1 means we reached the beginning - int startPos = (currentPosition < 0) ? 0 : ++currentPosition; - currentPosition = position; - while (isLetter(str[currentPosition])) { - foundWord.append(str[currentPosition]); - ++currentPosition; - } - - *start = startPos; - *end = currentPosition; -} - -} // namespace WebCore diff --git a/WebCore/platform/text/wince/TextBreakIteratorWinCE.cpp b/WebCore/platform/text/wince/TextBreakIteratorWinCE.cpp index 7f46e4f..96488c0 100644 --- a/WebCore/platform/text/wince/TextBreakIteratorWinCE.cpp +++ b/WebCore/platform/text/wince/TextBreakIteratorWinCE.cpp @@ -55,7 +55,16 @@ public: length = len; currentPos = 0; } - virtual int first() = 0; + int first() + { + currentPos = 0; + return currentPos; + } + int last() + { + currentPos = length; + return currentPos; + } virtual int next() = 0; virtual int previous() = 0; int following(int position) @@ -75,35 +84,25 @@ public: }; struct WordBreakIterator: TextBreakIterator { - virtual int first(); virtual int next(); virtual int previous(); }; struct CharBreakIterator: TextBreakIterator { - virtual int first(); virtual int next(); virtual int previous(); }; struct LineBreakIterator: TextBreakIterator { - virtual int first(); virtual int next(); virtual int previous(); }; struct SentenceBreakIterator : TextBreakIterator { - virtual int first(); virtual int next(); virtual int previous(); }; -int WordBreakIterator::first() -{ - currentPos = 0; - return currentPos; -} - int WordBreakIterator::next() { if (currentPos == length) { @@ -138,12 +137,6 @@ int WordBreakIterator::previous() return currentPos; } -int CharBreakIterator::first() -{ - currentPos = 0; - return currentPos; -} - int CharBreakIterator::next() { if (currentPos >= length) @@ -166,12 +159,6 @@ int CharBreakIterator::previous() return currentPos; } -int LineBreakIterator::first() -{ - currentPos = 0; - return currentPos; -} - int LineBreakIterator::next() { if (currentPos == length) { @@ -206,12 +193,6 @@ int LineBreakIterator::previous() return currentPos; } -int SentenceBreakIterator::first() -{ - currentPos = 0; - return currentPos; -} - int SentenceBreakIterator::next() { if (currentPos == length) { @@ -279,11 +260,21 @@ int textBreakFirst(TextBreakIterator* breakIterator) return breakIterator->first(); } +int textBreakLast(TextBreakIterator* breakIterator) +{ + return breakIterator->last(); +} + int textBreakNext(TextBreakIterator* breakIterator) { return breakIterator->next(); } +int textBreakPrevious(TextBreakIterator* breakIterator) +{ + return breakIterator->previous(); +} + int textBreakPreceding(TextBreakIterator* breakIterator, int position) { return breakIterator->preceding(position); diff --git a/WebCore/platform/win/ContextMenuWin.cpp b/WebCore/platform/win/ContextMenuWin.cpp index ad53f7e..10443aa 100644 --- a/WebCore/platform/win/ContextMenuWin.cpp +++ b/WebCore/platform/win/ContextMenuWin.cpp @@ -30,15 +30,25 @@ #include "Frame.h" #include "FrameView.h" #include "Node.h" -#include <wtf/text/CString.h> #include <tchar.h> #include <windows.h> +#include <wtf/text/CString.h> + +#ifndef MIIM_FTYPE +#define MIIM_FTYPE MIIM_TYPE +#endif +#ifndef MIIM_STRING +#define MIIM_STRING MIIM_TYPE +#endif namespace WebCore { ContextMenu::ContextMenu(const HitTestResult& result) : m_hitTestResult(result) , m_platformDescription(0) +#if OS(WINCE) + , m_itemCount(0) +#endif { setPlatformDescription(::CreatePopupMenu()); } @@ -46,6 +56,9 @@ ContextMenu::ContextMenu(const HitTestResult& result) ContextMenu::ContextMenu(const HitTestResult& result, const PlatformMenuDescription menu) : m_hitTestResult(result) , m_platformDescription(0) +#if OS(WINCE) + , m_itemCount(0) +#endif { setPlatformDescription(menu); } @@ -58,11 +71,47 @@ ContextMenu::~ContextMenu() unsigned ContextMenu::itemCount() const { +#if OS(WINCE) + return m_itemCount; +#else if (!m_platformDescription) return 0; return ::GetMenuItemCount(m_platformDescription); +#endif +} + +#if OS(WINCE) +static bool insertMenuItem(PlatformMenuDescription menu, unsigned int position, ContextMenuItem& item) +{ + UINT flags = MF_BYPOSITION; + UINT newItem = 0; + LPCWSTR title = 0; + + if (item.type() == SeparatorType) + flags |= MF_SEPARATOR; + else { + flags |= MF_STRING; + flags |= item.checked() ? MF_CHECKED : MF_UNCHECKED; + flags |= item.enabled() ? MF_ENABLED : MF_GRAYED; + + PlatformMenuItemDescription description = item.releasePlatformDescription(); + title = description->dwTypeData; + description->dwTypeData = 0; + + if (description->hSubMenu) { + flags |= MF_POPUP; + newItem = reinterpret_cast<UINT>(description->hSubMenu); + description->hSubMenu = 0; + } else + newItem = description->wID; + + free(description); + } + + return ::InsertMenuW(menu, position, flags, newItem, title); } +#endif void ContextMenu::insertItem(unsigned int position, ContextMenuItem& item) { @@ -70,7 +119,13 @@ void ContextMenu::insertItem(unsigned int position, ContextMenuItem& item) return; checkOrEnableIfNeeded(item); + +#if OS(WINCE) + if (insertMenuItem(m_platformDescription, position, item)) + ++m_itemCount; +#else ::InsertMenuItem(m_platformDescription, position, TRUE, item.releasePlatformDescription()); +#endif } void ContextMenu::appendItem(ContextMenuItem& item) @@ -82,14 +137,14 @@ static ContextMenuItem* contextMenuItemByIdOrPosition(HMENU menu, unsigned id, B { if (!menu) return 0; - LPMENUITEMINFO info = (LPMENUITEMINFO)malloc(sizeof(MENUITEMINFO)); + LPMENUITEMINFO info = static_cast<LPMENUITEMINFO>(malloc(sizeof(MENUITEMINFO))); if (!info) return 0; memset(info, 0, sizeof(MENUITEMINFO)); info->cbSize = sizeof(MENUITEMINFO); - + // Setting MIIM_DATA which is useful for WebKit clients who store data in this member for their custom menu items. info->fMask = MIIM_FTYPE | MIIM_ID | MIIM_STRING | MIIM_DATA; @@ -98,9 +153,8 @@ static ContextMenuItem* contextMenuItemByIdOrPosition(HMENU menu, unsigned id, B return 0; } - UINT type = info->fType & ~(MFT_MENUBARBREAK | MFT_MENUBREAK | MFT_OWNERDRAW | MFT_RADIOCHECK | MFT_RIGHTORDER | MFT_RIGHTJUSTIFY); - if (type == MFT_STRING) { - LPTSTR buffer = (LPTSTR)malloc(++info->cch * sizeof(TCHAR)); + if (info->fType & MFT_STRING) { + LPTSTR buffer = static_cast<LPTSTR>(malloc(++info->cch * sizeof(TCHAR))); if (!buffer) { free(info); return 0; @@ -108,7 +162,7 @@ static ContextMenuItem* contextMenuItemByIdOrPosition(HMENU menu, unsigned id, B info->dwTypeData = buffer; ::GetMenuItemInfo(menu, id, byPosition, info); } - + return new ContextMenuItem(info); } @@ -134,6 +188,7 @@ void ContextMenu::setPlatformDescription(HMENU menu) if (!m_platformDescription) return; +#if !OS(WINCE) MENUINFO menuInfo = {0}; menuInfo.cbSize = sizeof(MENUINFO); menuInfo.fMask = MIM_STYLE; @@ -141,6 +196,7 @@ void ContextMenu::setPlatformDescription(HMENU menu) menuInfo.fMask = MIM_STYLE; menuInfo.dwStyle |= MNS_NOTIFYBYPOS; ::SetMenuInfo(m_platformDescription, &menuInfo); +#endif } HMENU ContextMenu::platformDescription() const @@ -157,14 +213,14 @@ HMENU ContextMenu::releasePlatformDescription() Vector<ContextMenuItem> contextMenuItemVector(PlatformMenuDescription) { - // FIXME - Implement + // FIXME - Implement return Vector<ContextMenuItem>(); } PlatformMenuDescription platformMenuDescription(Vector<ContextMenuItem>& menuItemVector) { - // FIXME - Implement + // FIXME - Implement return 0; } -} +} // namespace WebCore diff --git a/WebCore/platform/win/FileSystemWin.cpp b/WebCore/platform/win/FileSystemWin.cpp index cef7196..5ee3b8e 100644 --- a/WebCore/platform/win/FileSystemWin.cpp +++ b/WebCore/platform/win/FileSystemWin.cpp @@ -134,10 +134,7 @@ String pathGetFileName(const String& path) String directoryName(const String& path) { - String fileName = pathGetFileName(path); - String dirName = String(path); - dirName.truncate(dirName.length() - pathGetFileName(path).length()); - return dirName; + return path.left(path.length() - pathGetFileName(path).length()); } static String bundleName() diff --git a/WebCore/platform/wince/FileSystemWinCE.cpp b/WebCore/platform/wince/FileSystemWinCE.cpp index 90b278e..49acf12 100644 --- a/WebCore/platform/wince/FileSystemWinCE.cpp +++ b/WebCore/platform/wince/FileSystemWinCE.cpp @@ -33,13 +33,26 @@ #include "NotImplemented.h" #include "PlatformString.h" -#include <wtf/text/CString.h> - -#include <windows.h> #include <wincrypt.h> +#include <windows.h> +#include <wtf/text/CString.h> namespace WebCore { +static size_t reverseFindPathSeparator(const String& path, unsigned start = UINT_MAX) +{ + size_t positionSlash = path.reverseFind('/', start); + size_t positionBackslash = path.reverseFind('\\', start); + + if (positionSlash == notFound) + return positionBackslash; + + if (positionBackslash == notFound) + return positionSlash; + + return std::max(positionSlash, positionBackslash); +} + static bool getFileInfo(const String& path, BY_HANDLE_FILE_INFORMATION& fileInfo) { String filename = path; @@ -133,14 +146,14 @@ CString fileSystemRepresentation(const String&) bool makeAllDirectories(const String& path) { - int lastDivPos = std::max(path.reverseFind('/'), path.reverseFind('\\')); - int endPos = path.length(); - if (lastDivPos == path.length() - 1) { - endPos -= 1; - lastDivPos = std::max(path.reverseFind('/', lastDivPos), path.reverseFind('\\', lastDivPos)); + size_t lastDivPos = reverseFindPathSeparator(path); + unsigned endPos = path.length(); + if (lastDivPos == endPos - 1) { + --endPos; + lastDivPos = reverseFindPathSeparator(path, lastDivPos); } - if (lastDivPos > 0) { + if (lastDivPos != notFound) { if (!makeAllDirectories(path.substring(0, lastDivPos))) return false; } @@ -160,13 +173,18 @@ String homeDirectoryPath() String pathGetFileName(const String& path) { - return path.substring(std::max(path.reverseFind('/'), path.reverseFind('\\')) + 1); + size_t pos = reverseFindPathSeparator(path); + if (pos == notFound) + return path; + return path.substring(pos + 1); } String directoryName(const String& path) { - notImplemented(); - return String(); + size_t pos = reverseFindPathSeparator(path); + if (pos == notFound) + return String(); + return path.left(pos); } CString openTemporaryFile(const char*, PlatformFileHandle& handle) diff --git a/WebCore/platform/wx/LocalizedStringsWx.cpp b/WebCore/platform/wx/LocalizedStringsWx.cpp index 1b46643..4b56394 100644 --- a/WebCore/platform/wx/LocalizedStringsWx.cpp +++ b/WebCore/platform/wx/LocalizedStringsWx.cpp @@ -47,7 +47,7 @@ String resetButtonDefaultLabel() return String("Reset"); } -String defaultLanguage() +String platformDefaultLanguage() { return String("en"); } @@ -390,6 +390,36 @@ String validationMessageValueMissingText() return String(); } +String validationMessageValueMissingForCheckboxText() +{ + notImplemented(); + return validationMessageValueMissingText(); +} + +String validationMessageValueMissingForFileText() +{ + notImplemented(); + return validationMessageValueMissingText(); +} + +String validationMessageValueMissingForMultipleFileText() +{ + notImplemented(); + return validationMessageValueMissingText(); +} + +String validationMessageValueMissingForRadioText() +{ + notImplemented(); + return validationMessageValueMissingText(); +} + +String validationMessageValueMissingForSelectText() +{ + notImplemented(); + return validationMessageValueMissingText(); +} + String validationMessageTypeMismatchText() { notImplemented(); |