diff options
author | Ben Murdoch <benm@google.com> | 2011-06-02 12:07:03 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-06-10 10:47:21 +0100 |
commit | 2daae5fd11344eaa88a0d92b0f6d65f8d2255c00 (patch) | |
tree | e4964fbd1cb70599f7718ff03e50ea1dab33890b /Source/WebCore/platform/mac | |
parent | 87bdf0060a247bfbe668342b87e0874182e0ffa9 (diff) | |
download | external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.zip external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.tar.gz external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.tar.bz2 |
Merge WebKit at r84325: Initial merge by git.
Change-Id: Ic1a909300ecc0a13ddc6b4e784371d2ac6e3d59b
Diffstat (limited to 'Source/WebCore/platform/mac')
-rw-r--r-- | Source/WebCore/platform/mac/ClipboardMac.mm | 2 | ||||
-rw-r--r-- | Source/WebCore/platform/mac/DragDataMac.mm | 4 | ||||
-rw-r--r-- | Source/WebCore/platform/mac/HTMLConverter.h | 11 | ||||
-rw-r--r-- | Source/WebCore/platform/mac/HTMLConverter.mm | 168 | ||||
-rw-r--r-- | Source/WebCore/platform/mac/PasteboardMac.mm | 18 | ||||
-rw-r--r-- | Source/WebCore/platform/mac/RuntimeApplicationChecks.h | 40 | ||||
-rw-r--r-- | Source/WebCore/platform/mac/RuntimeApplicationChecks.mm | 68 | ||||
-rw-r--r-- | Source/WebCore/platform/mac/ScrollAnimatorMac.h | 2 | ||||
-rw-r--r-- | Source/WebCore/platform/mac/ScrollAnimatorMac.mm | 90 | ||||
-rw-r--r-- | Source/WebCore/platform/mac/WebCoreSystemInterface.h | 16 | ||||
-rw-r--r-- | Source/WebCore/platform/mac/WebCoreSystemInterface.mm | 6 | ||||
-rw-r--r-- | Source/WebCore/platform/mac/WebNSAttributedStringExtras.h | 30 | ||||
-rw-r--r-- | Source/WebCore/platform/mac/WebNSAttributedStringExtras.mm | 59 | ||||
-rw-r--r-- | Source/WebCore/platform/mac/WheelEventMac.mm | 22 |
14 files changed, 346 insertions, 190 deletions
diff --git a/Source/WebCore/platform/mac/ClipboardMac.mm b/Source/WebCore/platform/mac/ClipboardMac.mm index a41982a..a5005eb 100644 --- a/Source/WebCore/platform/mac/ClipboardMac.mm +++ b/Source/WebCore/platform/mac/ClipboardMac.mm @@ -49,7 +49,7 @@ namespace WebCore { PassRefPtr<Clipboard> Clipboard::create(ClipboardAccessPolicy policy, DragData* dragData, Frame* frame) { - return ClipboardMac::create(DragAndDrop, [dragData->platformData() draggingPasteboard], policy, frame); + return ClipboardMac::create(DragAndDrop, dragData->pasteboard(), policy, frame); } ClipboardMac::ClipboardMac(ClipboardType clipboardType, NSPasteboard *pasteboard, ClipboardAccessPolicy policy, Frame *frame) diff --git a/Source/WebCore/platform/mac/DragDataMac.mm b/Source/WebCore/platform/mac/DragDataMac.mm index 64376b1..41d23db 100644 --- a/Source/WebCore/platform/mac/DragDataMac.mm +++ b/Source/WebCore/platform/mac/DragDataMac.mm @@ -104,7 +104,7 @@ String DragData::asPlainText(Frame *frame) const Color DragData::asColor() const { - NSColor *color = [NSColor colorFromPasteboard:[m_platformDragData draggingPasteboard]]; + NSColor *color = [NSColor colorFromPasteboard:m_pasteboard.get()]; return makeRGBA((int)([color redComponent] * 255.0 + 0.5), (int)([color greenComponent] * 255.0 + 0.5), (int)([color blueComponent] * 255.0 + 0.5), (int)([color alphaComponent] * 255.0 + 0.5)); } @@ -141,7 +141,7 @@ String DragData::asURL(Frame* frame, FilenameConversionPolicy filenamePolicy, St (void)filenamePolicy; if (title) { - if (NSString *URLTitleString = [[m_platformDragData draggingPasteboard] stringForType:WebURLNamePboardType]) + if (NSString *URLTitleString = [m_pasteboard.get() stringForType:WebURLNamePboardType]) *title = URLTitleString; } Pasteboard pasteboard(m_pasteboard.get()); diff --git a/Source/WebCore/platform/mac/HTMLConverter.h b/Source/WebCore/platform/mac/HTMLConverter.h index 645c1d7..3250769 100644 --- a/Source/WebCore/platform/mac/HTMLConverter.h +++ b/Source/WebCore/platform/mac/HTMLConverter.h @@ -23,12 +23,12 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#import "DOM.h" -#import "DOMDocument.h" -#import "DOMRange.h" +@class DOMDocument; +@class DOMRange; namespace WebCore { -class DocumentLoader; + class DocumentLoader; + class Range; } @interface WebHTMLConverter : NSObject { @@ -79,10 +79,13 @@ class DocumentLoader; } _flags; } +#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) - (id)init; - (id)initWithDOMRange:(DOMRange *)domRange; - (NSAttributedString *)attributedString; +#endif ++ (NSAttributedString *)editingAttributedStringFromRange:(WebCore::Range*)range; @end diff --git a/Source/WebCore/platform/mac/HTMLConverter.mm b/Source/WebCore/platform/mac/HTMLConverter.mm index a4864c2..c0b0ba2 100644 --- a/Source/WebCore/platform/mac/HTMLConverter.mm +++ b/Source/WebCore/platform/mac/HTMLConverter.mm @@ -27,26 +27,35 @@ #import "HTMLConverter.h" #import "ArchiveResource.h" +#import "ColorMac.h" #import "Document.h" #import "DocumentLoader.h" #import "DOMDocumentInternal.h" #import "DOMElementInternal.h" #import "DOMHTMLTableCellElement.h" #import "DOMPrivate.h" +#import "DOMRangeInternal.h" #import "Element.h" #import "Frame.h" #import "HTMLNames.h" #import "HTMLParserIdioms.h" +#import "LoaderNSURLExtras.h" +#import "RenderImage.h" +#import "TextIterator.h" #import <wtf/ASCIICType.h> using namespace WebCore; using namespace HTMLNames; +static NSFileWrapper *fileWrapperForURL(DocumentLoader *, NSURL *); +static NSFileWrapper *fileWrapperForElement(Element*); + #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) + // Additional control Unicode characters const unichar WebNextLineCharacter = 0x0085; -@interface NSTextList (TextListPrivate) +@interface NSTextList (WebCoreNSTextListDetails) + (NSDictionary *)_standardMarkerAttributesForAttributes:(NSDictionary *)attrs; @end @@ -55,14 +64,12 @@ const unichar WebNextLineCharacter = 0x0085; - (BOOL)ignoresOrientation; @end -@interface NSURL (WebDataURL) -+ (NSURL *)_web_uniqueWebDataURL; -+ (NSURL *)_web_uniqueWebDataURLWithRelativeString:(NSString *)string; +@interface NSURL (WebCoreNSURLDetails) +// FIXME: What is the reason to use this Foundation method, and not +[NSURL URLWithString:relativeToURL:]? + (NSURL *)_web_URLWithString:(NSString *)string relativeToURL:(NSURL *)baseURL; -- (NSString *)_web_suggestedFilenameWithMIMEType:(NSString *)MIMEType; @end -@interface WebHTMLConverter(WebHTMLConverterPrivate) +@interface WebHTMLConverter(WebHTMLConverterInternal) - (NSString *)_stringForNode:(DOMNode *)node property:(NSString *)key; - (NSColor *)_colorForNode:(DOMNode *)node property:(NSString *)key; @@ -89,8 +96,12 @@ static NSFont *WebDefaultFont() return defaultFont; } +#endif + @implementation WebHTMLConverter +#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) + static NSFont *_fontForNameAndSize(NSString *fontName, CGFloat size, NSMutableDictionary *cache) { NSFontManager *fontManager = [NSFontManager sharedFontManager]; @@ -769,39 +780,6 @@ static inline NSShadow *_shadowForShadowStyle(NSString *shadowStyle) [string release]; _flags.isSoft = YES; } - -static NSFileWrapper *fileWrapperForURL(DocumentLoader *dataSource, NSURL *URL) -{ - if ([URL isFileURL]) { - NSString *path = [[URL path] stringByResolvingSymlinksInPath]; - return [[[NSFileWrapper alloc] initWithPath:path] autorelease]; - } - - RefPtr<ArchiveResource> resource = dataSource->subresource(URL); - if (resource) { - NSFileWrapper *wrapper = [[[NSFileWrapper alloc] initRegularFileWithContents:[resource->data()->createNSData() autorelease]] autorelease]; - NSString *filename = resource->response().suggestedFilename(); - if (!filename || ![filename length]) { - NSURL *URL = resource->url(); - filename = [URL _web_suggestedFilenameWithMIMEType:resource->mimeType()]; - } - [wrapper setPreferredFilename:filename]; - return wrapper; - } - - NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:URL]; - - NSCachedURLResponse *cachedResponse = [[NSURLCache sharedURLCache] cachedResponseForRequest:request]; - [request release]; - - if (cachedResponse) { - NSFileWrapper *wrapper = [[[NSFileWrapper alloc] initRegularFileWithContents:[cachedResponse data]] autorelease]; - [wrapper setPreferredFilename:[[cachedResponse response] suggestedFilename]]; - return wrapper; - } - - return nil; -} - (BOOL)_addAttachmentForElement:(DOMElement *)element URL:(NSURL *)url needsParagraph:(BOOL)needsParagraph usePlaceholder:(BOOL)flag { @@ -823,7 +801,7 @@ static NSFileWrapper *fileWrapperForURL(DocumentLoader *dataSource, NSURL *URL) if (flag && resource && [@"text/html" isEqual:resource->mimeType()]) notFound = YES; if (resource && !notFound) { fileWrapper = [[[NSFileWrapper alloc] initRegularFileWithContents:[resource->data()->createNSData() autorelease]] autorelease]; - [fileWrapper setPreferredFilename:[url _web_suggestedFilenameWithMIMEType:resource->mimeType()]]; + [fileWrapper setPreferredFilename:suggestedFilenameWithMIMEType(url, resource->mimeType())]; } } if (!fileWrapper && !notFound) { @@ -1672,11 +1650,119 @@ static NSInteger _colCompare(id block1, id block2, void *) return self; } +// This function supports more HTML features than the editing variant below, such as tables. - (NSAttributedString *)attributedString { [self _loadFromDOMRange]; return (0 == _errorCode) ? [[_attrStr retain] autorelease] : nil; } +#endif // !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) + +// This function uses TextIterator, which makes offsets in its result compatible with HTML editing. ++ (NSAttributedString *)editingAttributedStringFromRange:(Range*)range +{ + NSMutableAttributedString *string = [[NSMutableAttributedString alloc] init]; + NSUInteger stringLength = 0; + RetainPtr<NSMutableDictionary> attrs(AdoptNS, [[NSMutableDictionary alloc] init]); + + for (TextIterator it(range); !it.atEnd(); it.advance()) { + RefPtr<Range> currentTextRange = it.range(); + ExceptionCode ec = 0; + Node* startContainer = currentTextRange->startContainer(ec); + Node* endContainer = currentTextRange->endContainer(ec); + int startOffset = currentTextRange->startOffset(ec); + int endOffset = currentTextRange->endOffset(ec); + + if (startContainer == endContainer && (startOffset == endOffset - 1)) { + Node* node = startContainer->childNode(startOffset); + if (node && node->hasTagName(imgTag)) { + NSFileWrapper *fileWrapper = fileWrapperForElement(static_cast<Element*>(node)); + NSTextAttachment *attachment = [[NSTextAttachment alloc] initWithFileWrapper:fileWrapper]; + [string appendAttributedString:[NSAttributedString attributedStringWithAttachment:attachment]]; + [attachment release]; + } + } + + int currentTextLength = it.length(); + if (!currentTextLength) + continue; + + RenderObject* renderer = startContainer->renderer(); + ASSERT(renderer); + if (!renderer) + continue; + RenderStyle* style = renderer->style(); + NSFont *font = style->font().primaryFont()->getNSFont(); + [attrs.get() setObject:font forKey:NSFontAttributeName]; + if (style->visitedDependentColor(CSSPropertyColor).alpha()) + [attrs.get() setObject:nsColor(style->visitedDependentColor(CSSPropertyColor)) forKey:NSForegroundColorAttributeName]; + else + [attrs.get() removeObjectForKey:NSForegroundColorAttributeName]; + if (style->visitedDependentColor(CSSPropertyBackgroundColor).alpha()) + [attrs.get() setObject:nsColor(style->visitedDependentColor(CSSPropertyBackgroundColor)) forKey:NSBackgroundColorAttributeName]; + else + [attrs.get() removeObjectForKey:NSBackgroundColorAttributeName]; + + RetainPtr<NSString> substring(AdoptNS, [[NSString alloc] initWithCharactersNoCopy:const_cast<UChar*>(it.characters()) length:currentTextLength freeWhenDone:NO]); + [string replaceCharactersInRange:NSMakeRange(stringLength, 0) withString:substring.get()]; + [string setAttributes:attrs.get() range:NSMakeRange(stringLength, currentTextLength)]; + stringLength += currentTextLength; + } + + return [string autorelease]; +} + @end -#endif + +static NSFileWrapper *fileWrapperForURL(DocumentLoader *dataSource, NSURL *URL) +{ + if ([URL isFileURL]) { + NSString *path = [[URL path] stringByResolvingSymlinksInPath]; + return [[[NSFileWrapper alloc] initWithPath:path] autorelease]; + } + + RefPtr<ArchiveResource> resource = dataSource->subresource(URL); + if (resource) { + NSFileWrapper *wrapper = [[[NSFileWrapper alloc] initRegularFileWithContents:[resource->data()->createNSData() autorelease]] autorelease]; + NSString *filename = resource->response().suggestedFilename(); + if (!filename || ![filename length]) + filename = suggestedFilenameWithMIMEType(resource->url(), resource->mimeType()); + [wrapper setPreferredFilename:filename]; + return wrapper; + } + + NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:URL]; + + NSCachedURLResponse *cachedResponse = [[NSURLCache sharedURLCache] cachedResponseForRequest:request]; + [request release]; + + if (cachedResponse) { + NSFileWrapper *wrapper = [[[NSFileWrapper alloc] initRegularFileWithContents:[cachedResponse data]] autorelease]; + [wrapper setPreferredFilename:[[cachedResponse response] suggestedFilename]]; + return wrapper; + } + + return nil; +} + +static NSFileWrapper *fileWrapperForElement(Element* element) +{ + NSFileWrapper *wrapper = nil; + + const AtomicString& attr = element->getAttribute(srcAttr); + if (!attr.isEmpty()) { + NSURL *URL = element->document()->completeURL(attr); + wrapper = fileWrapperForURL(element->document()->loader(), URL); + } + if (!wrapper) { + RenderImage* renderer = toRenderImage(element->renderer()); + if (renderer->cachedImage() && !renderer->cachedImage()->errorOccurred()) { + wrapper = [[NSFileWrapper alloc] initRegularFileWithContents:(NSData *)(renderer->cachedImage()->image()->getTIFFRepresentation())]; + [wrapper setPreferredFilename:@"image.tiff"]; + [wrapper autorelease]; + } + } + + return wrapper; +} diff --git a/Source/WebCore/platform/mac/PasteboardMac.mm b/Source/WebCore/platform/mac/PasteboardMac.mm index da06606..69782ab 100644 --- a/Source/WebCore/platform/mac/PasteboardMac.mm +++ b/Source/WebCore/platform/mac/PasteboardMac.mm @@ -38,9 +38,7 @@ #import "FrameLoaderClient.h" #import "HitTestResult.h" #import "HTMLAnchorElement.h" -#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) #import "HTMLConverter.h" -#endif #import "htmlediting.h" #import "HTMLNames.h" #import "Image.h" @@ -52,6 +50,7 @@ #import "RenderImage.h" #import "Text.h" #import "WebCoreNSStringExtras.h" +#import "WebNSAttributedStringExtras.h" #import "markup.h" #import <wtf/StdLibExtras.h> #import <wtf/RetainPtr.h> @@ -129,19 +128,6 @@ void Pasteboard::clear() [m_pasteboard.get() declareTypes:[NSArray array] owner:nil]; } -static NSAttributedString *stripAttachmentCharacters(NSAttributedString *string) -{ - const unichar attachmentCharacter = NSAttachmentCharacter; - DEFINE_STATIC_LOCAL(RetainPtr<NSString>, attachmentCharacterString, ([NSString stringWithCharacters:&attachmentCharacter length:1])); - NSMutableAttributedString *result = [[string mutableCopy] autorelease]; - NSRange attachmentRange = [[result string] rangeOfString:attachmentCharacterString.get()]; - while (attachmentRange.location != NSNotFound) { - [result replaceCharactersInRange:attachmentRange withString:@""]; - attachmentRange = [[result string] rangeOfString:attachmentCharacterString.get()]; - } - return result; -} - void Pasteboard::writeSelection(NSPasteboard* pasteboard, NSArray* pasteboardTypes, Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame) { if (!WebArchivePboardType) @@ -207,7 +193,7 @@ void Pasteboard::writeSelection(NSPasteboard* pasteboard, NSArray* pasteboardTyp } if ([types containsObject:NSRTFPboardType]) { if ([attributedString containsAttachments]) - attributedString = stripAttachmentCharacters(attributedString); + attributedString = attributedStringByStrippingAttachmentCharacters(attributedString); NSData *RTFData = [attributedString RTFFromRange:NSMakeRange(0, [attributedString length]) documentAttributes:nil]; [pasteboard setData:RTFData forType:NSRTFPboardType]; } diff --git a/Source/WebCore/platform/mac/RuntimeApplicationChecks.h b/Source/WebCore/platform/mac/RuntimeApplicationChecks.h deleted file mode 100644 index f938048..0000000 --- a/Source/WebCore/platform/mac/RuntimeApplicationChecks.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2009 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef RuntimeApplicationChecks_h -#define RuntimeApplicationChecks_h - -namespace WebCore { - -bool applicationIsAppleMail(); -bool applicationIsSafari(); -bool applicationIsMicrosoftMessenger(); -bool applicationIsAdobeInstaller(); -bool applicationIsAOLInstantMessenger(); -bool applicationIsMicrosoftMyDay(); - -} // namespace WebCore - -#endif // RuntimeApplicationChecks_h diff --git a/Source/WebCore/platform/mac/RuntimeApplicationChecks.mm b/Source/WebCore/platform/mac/RuntimeApplicationChecks.mm deleted file mode 100644 index 7fe8378..0000000 --- a/Source/WebCore/platform/mac/RuntimeApplicationChecks.mm +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2009 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import "config.h" -#import "RuntimeApplicationChecks.h" - - -namespace WebCore { - -bool applicationIsAppleMail() -{ - static const bool isAppleMail = [[[NSBundle mainBundle] bundleIdentifier] isEqualToString:@"com.apple.mail"]; - return isAppleMail; -} - -bool applicationIsSafari() -{ - static const bool isSafari = [[[NSBundle mainBundle] bundleIdentifier] isEqualToString:@"com.apple.Safari"]; - return isSafari; -} - -bool applicationIsMicrosoftMessenger() -{ - static bool isMicrosoftMessenger = [[[NSBundle mainBundle] bundleIdentifier] isEqualToString:@"com.microsoft.Messenger"]; - return isMicrosoftMessenger; -} - -bool applicationIsAdobeInstaller() -{ - static bool isAdobeInstaller = [[[NSBundle mainBundle] bundleIdentifier] isEqualToString:@"com.adobe.Installers.Setup"]; - return isAdobeInstaller; -} - -bool applicationIsAOLInstantMessenger() -{ - static bool isAOLInstantMessenger = [[[NSBundle mainBundle] bundleIdentifier] isEqualToString:@"com.aol.aim.desktop"]; - return isAOLInstantMessenger; -} - -bool applicationIsMicrosoftMyDay() -{ - static bool isMicrosoftMyDay = [[[NSBundle mainBundle] bundleIdentifier] isEqualToString:@"com.microsoft.myday"]; - return isMicrosoftMyDay; -} - -} // namespace WebCore diff --git a/Source/WebCore/platform/mac/ScrollAnimatorMac.h b/Source/WebCore/platform/mac/ScrollAnimatorMac.h index f7b6332..382052e 100644 --- a/Source/WebCore/platform/mac/ScrollAnimatorMac.h +++ b/Source/WebCore/platform/mac/ScrollAnimatorMac.h @@ -106,6 +106,8 @@ private: virtual void willEndLiveResize(); virtual void contentAreaDidShow() const; virtual void contentAreaDidHide() const; + void didBeginScrollGesture() const; + void didEndScrollGesture() const; virtual void didAddVerticalScrollbar(Scrollbar*); virtual void willRemoveVerticalScrollbar(Scrollbar*); diff --git a/Source/WebCore/platform/mac/ScrollAnimatorMac.mm b/Source/WebCore/platform/mac/ScrollAnimatorMac.mm index 5725880..321ef0f 100644 --- a/Source/WebCore/platform/mac/ScrollAnimatorMac.mm +++ b/Source/WebCore/platform/mac/ScrollAnimatorMac.mm @@ -100,6 +100,11 @@ static NSSize abs(NSSize size) _animator->immediateScrollToPoint(newPosition); } +- (NSPoint)_pixelAlignProposedScrollPosition:(NSPoint)newOrigin +{ + return newOrigin; +} + - (NSSize)convertSizeToBase:(NSSize)size { return abs(size); @@ -322,9 +327,9 @@ static NSSize abs(NSSize size) // Invalidate the scrollbars so that they paint the animation if (WebCore::Scrollbar* verticalScrollbar = _animator->scrollableArea()->verticalScrollbar()) - _animator->scrollableArea()->invalidateScrollbarRect(verticalScrollbar, WebCore::IntRect(0, 0, verticalScrollbar->width(), verticalScrollbar->height())); + verticalScrollbar->invalidateRect(WebCore::IntRect(0, 0, verticalScrollbar->width(), verticalScrollbar->height())); if (WebCore::Scrollbar* horizontalScrollbar = _animator->scrollableArea()->horizontalScrollbar()) - _animator->scrollableArea()->invalidateScrollbarRect(horizontalScrollbar, WebCore::IntRect(0, 0, horizontalScrollbar->width(), horizontalScrollbar->height())); + horizontalScrollbar->invalidateRect(WebCore::IntRect(0, 0, horizontalScrollbar->width(), horizontalScrollbar->height())); } - (void)scrollAnimatorDestroyed @@ -575,6 +580,9 @@ void ScrollAnimatorMac::immediateScrollToPoint(const FloatPoint& newPosition) { FloatPoint adjustedPosition = adjustScrollPositionIfNecessary(newPosition); + if (adjustedPosition.x() == m_currentPosX && adjustedPosition.y() == m_currentPosY) + return; + m_currentPosX = adjustedPosition.x(); m_currentPosY = adjustedPosition.y(); notityPositionChanged(); @@ -582,13 +590,23 @@ void ScrollAnimatorMac::immediateScrollToPoint(const FloatPoint& newPosition) void ScrollAnimatorMac::immediateScrollByDeltaX(float deltaX) { - m_currentPosX = adjustScrollXPositionIfNecessary(m_currentPosX + deltaX); + float newPosX = adjustScrollXPositionIfNecessary(m_currentPosX + deltaX); + + if (newPosX == m_currentPosX) + return; + + m_currentPosX = newPosX; notityPositionChanged(); } void ScrollAnimatorMac::immediateScrollByDeltaY(float deltaY) { - m_currentPosY = adjustScrollYPositionIfNecessary(m_currentPosY + deltaY); + float newPosY = adjustScrollYPositionIfNecessary(m_currentPosY + deltaY); + + if (newPosY == m_currentPosY) + return; + + m_currentPosY = newPosY; notityPositionChanged(); } @@ -663,6 +681,20 @@ void ScrollAnimatorMac::contentAreaDidHide() const #endif } +void ScrollAnimatorMac::didBeginScrollGesture() const +{ +#if USE(WK_SCROLLBAR_PAINTER) + wkDidBeginScrollGesture(m_scrollbarPainterController.get()); +#endif +} + +void ScrollAnimatorMac::didEndScrollGesture() const +{ +#if USE(WK_SCROLLBAR_PAINTER) + wkDidEndScrollGesture(m_scrollbarPainterController.get()); +#endif +} + void ScrollAnimatorMac::didAddVerticalScrollbar(Scrollbar* scrollbar) { #if USE(WK_SCROLLBAR_PAINTER) @@ -771,6 +803,22 @@ void ScrollAnimatorMac::handleWheelEvent(PlatformWheelEvent& wheelEvent) return; } + // FIXME: This is somewhat roundabout hack to allow forwarding wheel events + // up to the parent scrollable area. It takes advantage of the fact that + // the base class implemenatation of handleWheelEvent will not accept the + // wheel event if there is nowhere to scroll. + if (fabsf(wheelEvent.deltaY()) >= fabsf(wheelEvent.deltaX())) { + if (!allowsVerticalStretching()) { + ScrollAnimator::handleWheelEvent(wheelEvent); + return; + } + } else { + if (!allowsHorizontalStretching()) { + ScrollAnimator::handleWheelEvent(wheelEvent); + return; + } + } + wheelEvent.accept(); bool isMometumScrollEvent = (wheelEvent.momentumPhase() != PlatformWheelEventPhaseNone); @@ -819,21 +867,37 @@ bool ScrollAnimatorMac::pinnedInDirection(float deltaX, float deltaY) bool ScrollAnimatorMac::allowsVerticalStretching() const { - Scrollbar* hScroller = m_scrollableArea->horizontalScrollbar(); - Scrollbar* vScroller = m_scrollableArea->verticalScrollbar(); - if (((vScroller && vScroller->enabled()) || (!hScroller || !hScroller->enabled()))) + switch (m_scrollableArea->verticalScrollElasticity()) { + case ScrollElasticityAutomatic: { + Scrollbar* hScroller = m_scrollableArea->horizontalScrollbar(); + Scrollbar* vScroller = m_scrollableArea->verticalScrollbar(); + return (((vScroller && vScroller->enabled()) || (!hScroller || !hScroller->enabled()))); + } + case ScrollElasticityNone: + return false; + case ScrollElasticityAllowed: return true; + } + ASSERT_NOT_REACHED(); return false; } bool ScrollAnimatorMac::allowsHorizontalStretching() const { - Scrollbar* hScroller = m_scrollableArea->horizontalScrollbar(); - Scrollbar* vScroller = m_scrollableArea->verticalScrollbar(); - if (((hScroller && hScroller->enabled()) || (!vScroller || !vScroller->enabled()))) + switch (m_scrollableArea->horizontalScrollElasticity()) { + case ScrollElasticityAutomatic: { + Scrollbar* hScroller = m_scrollableArea->horizontalScrollbar(); + Scrollbar* vScroller = m_scrollableArea->verticalScrollbar(); + return (((hScroller && hScroller->enabled()) || (!vScroller || !vScroller->enabled()))); + } + case ScrollElasticityNone: + return false; + case ScrollElasticityAllowed: return true; + } + ASSERT_NOT_REACHED(); return false; } @@ -858,7 +922,7 @@ void ScrollAnimatorMac::smoothScrollWithEvent(PlatformWheelEvent& wheelEvent) deltaX = 0; else deltaY = 0; - + bool isVerticallyStretched = false; bool isHorizontallyStretched = false; bool shouldStretch = false; @@ -993,6 +1057,8 @@ void ScrollAnimatorMac::smoothScrollWithEvent(PlatformWheelEvent& wheelEvent) void ScrollAnimatorMac::beginScrollGesture() { + didBeginScrollGesture(); + m_haveScrolledSincePageLoad = true; m_inScrollGesture = true; m_momentumScrollInProgress = false; @@ -1012,6 +1078,8 @@ void ScrollAnimatorMac::beginScrollGesture() void ScrollAnimatorMac::endScrollGesture() { + didEndScrollGesture(); + snapRubberBand(); } diff --git a/Source/WebCore/platform/mac/WebCoreSystemInterface.h b/Source/WebCore/platform/mac/WebCoreSystemInterface.h index 308a551..3c9850b 100644 --- a/Source/WebCore/platform/mac/WebCoreSystemInterface.h +++ b/Source/WebCore/platform/mac/WebCoreSystemInterface.h @@ -29,7 +29,7 @@ #include <ApplicationServices/ApplicationServices.h> #include <objc/objc.h> -#if PLATFORM(MAC) && PLATFORM(CA) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) +#if PLATFORM(MAC) && USE(CA) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) #include <IOSurface/IOSurface.h> #endif @@ -155,11 +155,12 @@ extern void (*wkSignalCFReadStreamError)(CFReadStreamRef stream, CFStreamError * extern void (*wkSignalCFReadStreamHasBytes)(CFReadStreamRef stream); extern unsigned (*wkInitializeMaximumHTTPConnectionCountPerHost)(unsigned preferredConnectionCount); extern int (*wkGetHTTPPipeliningPriority)(NSURLRequest *); +extern void (*wkSetHTTPPipeliningMaximumPriority)(int maximumPriority); extern void (*wkSetHTTPPipeliningPriority)(NSMutableURLRequest *, int priority); +extern void (*wkSetHTTPPipeliningMinimumFastLanePriority)(int priority); extern void (*wkSetCONNECTProxyForStream)(CFReadStreamRef, CFStringRef proxyHost, CFNumberRef proxyPort); extern void (*wkSetCONNECTProxyAuthorizationForStream)(CFReadStreamRef, CFStringRef proxyAuthorizationString); extern CFHTTPMessageRef (*wkCopyCONNECTProxyResponse)(CFReadStreamRef, CFURLRef responseURL); -extern BOOL (*wkIsLatchingWheelEvent)(NSEvent *); #ifndef BUILDING_ON_TIGER extern void (*wkGetGlyphsForCharacters)(CGFontRef, const UniChar[], CGGlyph[], size_t); @@ -187,6 +188,15 @@ extern BOOL (*wkUseSharedMediaUI)(); extern void* wkGetHyphenationLocationBeforeIndex; #else extern CFIndex (*wkGetHyphenationLocationBeforeIndex)(CFStringRef string, CFIndex index); + +typedef enum { + wkEventPhaseNone = 0, + wkEventPhaseBegan = 1, + wkEventPhaseChanged = 2, + wkEventPhaseEnded = 3, +} wkEventPhase; + +extern int (*wkGetNSEventMomentumPhase)(NSEvent *); #endif extern CTLineRef (*wkCreateCTLineWithUniCharProvider)(const UniChar* (*provide)(CFIndex stringIndex, CFIndex* charCount, CFDictionaryRef* attributes, void*), void (*dispose)(const UniChar* chars, void*), void*); @@ -229,6 +239,8 @@ extern void (*wkContentAreaResized)(WKScrollbarPainterControllerRef); extern void (*wkWillEndLiveResize)(WKScrollbarPainterControllerRef); extern void (*wkContentAreaDidShow)(WKScrollbarPainterControllerRef); extern void (*wkContentAreaDidHide)(WKScrollbarPainterControllerRef); +extern void (*wkDidBeginScrollGesture)(WKScrollbarPainterControllerRef); +extern void (*wkDidEndScrollGesture)(WKScrollbarPainterControllerRef); extern bool (*wkScrollbarPainterUsesOverlayScrollers)(void); #endif diff --git a/Source/WebCore/platform/mac/WebCoreSystemInterface.mm b/Source/WebCore/platform/mac/WebCoreSystemInterface.mm index ab059bd..6a78ff6 100644 --- a/Source/WebCore/platform/mac/WebCoreSystemInterface.mm +++ b/Source/WebCore/platform/mac/WebCoreSystemInterface.mm @@ -91,11 +91,12 @@ void (*wkSetNSURLRequestShouldContentSniff)(NSMutableURLRequest *, BOOL); id (*wkCreateNSURLConnectionDelegateProxy)(void); unsigned (*wkInitializeMaximumHTTPConnectionCountPerHost)(unsigned preferredConnectionCount); int (*wkGetHTTPPipeliningPriority)(NSURLRequest *); +void (*wkSetHTTPPipeliningMaximumPriority)(int priority); void (*wkSetHTTPPipeliningPriority)(NSMutableURLRequest *, int priority); +void (*wkSetHTTPPipeliningMinimumFastLanePriority)(int priority); void (*wkSetCONNECTProxyForStream)(CFReadStreamRef, CFStringRef proxyHost, CFNumberRef proxyPort); void (*wkSetCONNECTProxyAuthorizationForStream)(CFReadStreamRef, CFStringRef proxyAuthorizationString); CFHTTPMessageRef (*wkCopyCONNECTProxyResponse)(CFReadStreamRef, CFURLRef responseURL); -BOOL (*wkIsLatchingWheelEvent)(NSEvent *); #ifndef BUILDING_ON_TIGER void (*wkGetGlyphsForCharacters)(CGFontRef, const UniChar[], CGGlyph[], size_t); @@ -120,6 +121,7 @@ BOOL (*wkSupportsMultipartXMixedReplace)(NSMutableURLRequest *); void* wkGetHyphenationLocationBeforeIndex; #else CFIndex (*wkGetHyphenationLocationBeforeIndex)(CFStringRef string, CFIndex index); +int (*wkGetNSEventMomentumPhase)(NSEvent *); #endif CTLineRef (*wkCreateCTLineWithUniCharProvider)(const UniChar* (*provide)(CFIndex stringIndex, CFIndex* charCount, CFDictionaryRef* attributes, void*), void (*dispose)(const UniChar* chars, void*), void*); @@ -159,6 +161,8 @@ void (*wkContentAreaResized)(WKScrollbarPainterControllerRef); void (*wkWillEndLiveResize)(WKScrollbarPainterControllerRef); void (*wkContentAreaDidShow)(WKScrollbarPainterControllerRef); void (*wkContentAreaDidHide)(WKScrollbarPainterControllerRef); +void (*wkDidBeginScrollGesture)(WKScrollbarPainterControllerRef); +void (*wkDidEndScrollGesture)(WKScrollbarPainterControllerRef); bool (*wkScrollbarPainterUsesOverlayScrollers)(void); #endif diff --git a/Source/WebCore/platform/mac/WebNSAttributedStringExtras.h b/Source/WebCore/platform/mac/WebNSAttributedStringExtras.h new file mode 100644 index 0000000..ce4cfe4 --- /dev/null +++ b/Source/WebCore/platform/mac/WebNSAttributedStringExtras.h @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2005, 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +namespace WebCore { + +NSAttributedString *attributedStringByStrippingAttachmentCharacters(NSAttributedString *); + +} diff --git a/Source/WebCore/platform/mac/WebNSAttributedStringExtras.mm b/Source/WebCore/platform/mac/WebNSAttributedStringExtras.mm new file mode 100644 index 0000000..f64e24d --- /dev/null +++ b/Source/WebCore/platform/mac/WebNSAttributedStringExtras.mm @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2005, 2007, 2008, 2011 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import "WebNSAttributedStringExtras.h" + +namespace WebCore { + +NSAttributedString *attributedStringByStrippingAttachmentCharacters(NSAttributedString *attributedString) +{ + NSRange attachmentRange; + NSString *originalString = [attributedString string]; + static NSString *attachmentCharString = nil; + + if (!attachmentCharString) { + unichar chars[2]; + if (!attachmentCharString) { + chars[0] = NSAttachmentCharacter; + chars[1] = 0; + attachmentCharString = [[NSString alloc] initWithCharacters:chars length:1]; + } + } + + attachmentRange = [originalString rangeOfString:attachmentCharString]; + if (attachmentRange.location != NSNotFound && attachmentRange.length > 0) { + NSMutableAttributedString *newAttributedString = [[attributedString mutableCopyWithZone:NULL] autorelease]; + + while (attachmentRange.location != NSNotFound && attachmentRange.length > 0) { + [newAttributedString replaceCharactersInRange:attachmentRange withString:@""]; + attachmentRange = [[newAttributedString string] rangeOfString:attachmentCharString]; + } + return newAttributedString; + } + + return attributedString; +} + +} diff --git a/Source/WebCore/platform/mac/WheelEventMac.mm b/Source/WebCore/platform/mac/WheelEventMac.mm index 4e9a8b7..2494e69 100644 --- a/Source/WebCore/platform/mac/WheelEventMac.mm +++ b/Source/WebCore/platform/mac/WheelEventMac.mm @@ -35,8 +35,9 @@ namespace WebCore { static PlatformWheelEventPhase momentumPhaseForEvent(NSEvent *event) { + uint32_t phase = PlatformWheelEventPhaseNone; + #if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) - uint32_t phase = PlatformWheelEventPhaseNone; if ([event momentumPhase] & NSEventPhaseBegan) phase |= PlatformWheelEventPhaseBegan; if ([event momentumPhase] & NSEventPhaseStationary) @@ -47,11 +48,24 @@ static PlatformWheelEventPhase momentumPhaseForEvent(NSEvent *event) phase |= PlatformWheelEventPhaseEnded; if ([event momentumPhase] & NSEventPhaseCancelled) phase |= PlatformWheelEventPhaseCancelled; - return static_cast<PlatformWheelEventPhase>(phase); #else - UNUSED_PARAM(event); - return PlatformWheelEventPhaseNone; + switch (wkGetNSEventMomentumPhase(event)) { + case wkEventPhaseNone: + phase = PlatformWheelEventPhaseNone; + break; + case wkEventPhaseBegan: + phase = PlatformWheelEventPhaseBegan; + break; + case wkEventPhaseChanged: + phase = PlatformWheelEventPhaseChanged; + break; + case wkEventPhaseEnded: + phase = PlatformWheelEventPhaseEnded; + break; + } #endif + + return static_cast<PlatformWheelEventPhase>(phase); } static PlatformWheelEventPhase phaseForEvent(NSEvent *event) |