diff options
Diffstat (limited to 'Source/WebKit/mac/WebView')
20 files changed, 386 insertions, 195 deletions
diff --git a/Source/WebKit/mac/WebView/WebClipView.mm b/Source/WebKit/mac/WebView/WebClipView.mm index ced5d8d..280695e 100644 --- a/Source/WebKit/mac/WebView/WebClipView.mm +++ b/Source/WebKit/mac/WebView/WebClipView.mm @@ -51,6 +51,13 @@ using namespace WebCore; - (void)_immediateScrollToPoint:(NSPoint)newOrigin; @end +#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) +@interface NSWindow (WebNSWindowDetails) +- (void)_disableDelayedWindowDisplay; +- (void)_enableDelayedWindowDisplay; +@end +#endif + @implementation WebClipView - (id)initWithFrame:(NSRect)frame @@ -96,7 +103,17 @@ using namespace WebCore; - (void)_immediateScrollToPoint:(NSPoint)newOrigin { _isScrolling = YES; + +#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) + [[self window] _disableDelayedWindowDisplay]; +#endif + [super _immediateScrollToPoint:newOrigin]; + +#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) + [[self window] _enableDelayedWindowDisplay]; +#endif + _isScrolling = NO; } #endif diff --git a/Source/WebKit/mac/WebView/WebFrame.mm b/Source/WebKit/mac/WebView/WebFrame.mm index e792539..584b09e 100644 --- a/Source/WebKit/mac/WebView/WebFrame.mm +++ b/Source/WebKit/mac/WebView/WebFrame.mm @@ -579,51 +579,14 @@ static inline WebDataSource *dataSource(DocumentLoader* loader) } if (contentsOnly) - _private->coreFrame->view()->paintContents(&context, enclosingIntRect(rect)); + view->paintContents(&context, enclosingIntRect(rect)); else - _private->coreFrame->view()->paint(&context, enclosingIntRect(rect)); + view->paint(&context, enclosingIntRect(rect)); if (shouldFlatten) view->setPaintBehavior(oldBehavior); } -// Used by pagination code called from AppKit when a standalone web page is printed. -- (NSArray*)_computePageRectsWithPrintScaleFactor:(float)printScaleFactor pageSize:(NSSize)pageSize -{ - NSMutableArray* pages = [NSMutableArray arrayWithCapacity:5]; - if (printScaleFactor <= 0) { - LOG_ERROR("printScaleFactor has bad value %.2f", printScaleFactor); - return pages; - } - - if (!_private->coreFrame || !_private->coreFrame->document() || !_private->coreFrame->view()) return pages; - RenderView* root = toRenderView(_private->coreFrame->document()->renderer()); - if (!root) return pages; - - FrameView* view = _private->coreFrame->view(); - if (!view) - return pages; - - NSView* documentView = view->documentView(); - if (!documentView) - return pages; - - float docWidth = root->docWidth(); - float docHeight = root->docHeight(); - - float printWidth = root->style()->isHorizontalWritingMode() ? docWidth / printScaleFactor : pageSize.width; - float printHeight = root->style()->isHorizontalWritingMode() ? pageSize.height : docHeight / printScaleFactor; - - PrintContext printContext(_private->coreFrame); - printContext.computePageRectsWithPageSize(FloatSize(printWidth, printHeight), true); - - const Vector<IntRect>& pageRects = printContext.pageRects(); - const size_t pageCount = pageRects.size(); - for (size_t pageNumber = 0; pageNumber < pageCount; ++pageNumber) - [pages addObject: [NSValue valueWithRect: NSRect(pageRects[pageNumber])]]; - return pages; -} - - (BOOL)_getVisibleRect:(NSRect*)rect { ASSERT_ARG(rect, rect); @@ -1347,10 +1310,18 @@ static inline WebDataSource *dataSource(DocumentLoader* loader) - (BOOL)hasSpellingMarker:(int)from length:(int)length { - Frame* coreFrame = _private->coreFrame; + Frame* coreFrame = core(self); + if (!coreFrame) + return NO; + return coreFrame->editor()->selectionStartHasMarkerFor(DocumentMarker::Spelling, from, length); +} + +- (BOOL)hasGrammarMarker:(int)from length:(int)length +{ + Frame* coreFrame = core(self); if (!coreFrame) return NO; - return coreFrame->editor()->selectionStartHasSpellingMarkerFor(from, length); + return coreFrame->editor()->selectionStartHasMarkerFor(DocumentMarker::Grammar, from, length); } - (id)accessibilityRoot @@ -1358,8 +1329,7 @@ static inline WebDataSource *dataSource(DocumentLoader* loader) #if HAVE(ACCESSIBILITY) if (!AXObjectCache::accessibilityEnabled()) { AXObjectCache::enableAccessibility(); - if ([[NSApp accessibilityAttributeValue:NSAccessibilityEnhancedUserInterfaceAttribute] boolValue]) - AXObjectCache::enableEnhancedUserInterfaceAccessibility(); + AXObjectCache::setEnhancedUserInterfaceAccessibility([[NSApp accessibilityAttributeValue:NSAccessibilityEnhancedUserInterfaceAttribute] boolValue]); } if (!_private->coreFrame || !_private->coreFrame->document()) @@ -1387,6 +1357,41 @@ static inline WebDataSource *dataSource(DocumentLoader* loader) coreFrame->loader()->setOpener(0); } +// Used by pagination code called from AppKit when a standalone web page is printed. +- (NSArray *)_computePageRectsWithPrintScaleFactor:(float)printScaleFactor pageSize:(NSSize)pageSize +{ + if (printScaleFactor <= 0) { + LOG_ERROR("printScaleFactor has bad value %.2f", printScaleFactor); + return [NSArray array]; + } + + if (!_private->coreFrame) + return [NSArray array]; + if (!_private->coreFrame->document()) + return [NSArray array]; + if (!_private->coreFrame->view()) + return [NSArray array]; + if (!_private->coreFrame->view()->documentView()) + return [NSArray array]; + + RenderView* root = toRenderView(_private->coreFrame->document()->renderer()); + if (!root) + return [NSArray array]; + + float printWidth = root->style()->isHorizontalWritingMode() ? root->docWidth() / printScaleFactor : pageSize.width; + float printHeight = root->style()->isHorizontalWritingMode() ? pageSize.height : root->docHeight() / printScaleFactor; + + PrintContext printContext(_private->coreFrame); + printContext.computePageRectsWithPageSize(FloatSize(printWidth, printHeight), true); + const Vector<IntRect>& pageRects = printContext.pageRects(); + + size_t size = pageRects.size(); + NSMutableArray *pages = [NSMutableArray arrayWithCapacity:size]; + for (size_t i = 0; i < size; ++i) + [pages addObject:[NSValue valueWithRect:NSRect(pageRects[i])]]; + return pages; +} + @end @implementation WebFrame diff --git a/Source/WebKit/mac/WebView/WebFrameInternal.h b/Source/WebKit/mac/WebView/WebFrameInternal.h index 7e8016a..c13b721 100644 --- a/Source/WebKit/mac/WebView/WebFrameInternal.h +++ b/Source/WebKit/mac/WebView/WebFrameInternal.h @@ -125,7 +125,6 @@ WebView *getWebView(WebFrame *webFrame); - (BOOL)_needsLayout; - (void)_drawRect:(NSRect)rect contentsOnly:(BOOL)contentsOnly; - (BOOL)_getVisibleRect:(NSRect*)rect; -- (NSArray*)_computePageRectsWithPrintScaleFactor:(float)printWidthScaleFactor pageSize:(NSSize)pageSize; - (NSString *)_stringByEvaluatingJavaScriptFromString:(NSString *)string; - (NSString *)_stringByEvaluatingJavaScriptFromString:(NSString *)string forceUserGesture:(BOOL)forceUserGesture; diff --git a/Source/WebKit/mac/WebView/WebFramePrivate.h b/Source/WebKit/mac/WebView/WebFramePrivate.h index 75b57c7..82b3c4a 100644 --- a/Source/WebKit/mac/WebView/WebFramePrivate.h +++ b/Source/WebKit/mac/WebView/WebFramePrivate.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 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 @@ -69,8 +69,9 @@ typedef enum { } WebFrameLoadType; @interface WebFrame (WebPrivate) + - (BOOL)_isDescendantOfFrame:(WebFrame *)frame; -- (void)_setShouldCreateRenderers:(BOOL)f; +- (void)_setShouldCreateRenderers:(BOOL)shouldCreateRenderers; - (NSColor *)_bodyBackgroundColor; - (BOOL)_isFrameSet; - (BOOL)_firstLayoutDone; @@ -142,11 +143,15 @@ typedef enum { // Returns whether there is a spelling marker in the specified range of the focused node. - (BOOL)hasSpellingMarker:(int)location length:(int)length; +- (BOOL)hasGrammarMarker:(int)from length:(int)length; + // The top of the accessibility tree. - (id)accessibilityRoot; // Clears frame opener. This is executed between layout tests runs - (void)_clearOpener; +// Printing. +- (NSArray *)_computePageRectsWithPrintScaleFactor:(float)printWidthScaleFactor pageSize:(NSSize)pageSize; @end diff --git a/Source/WebKit/mac/WebView/WebFrameView.mm b/Source/WebKit/mac/WebView/WebFrameView.mm index 801c1f4..c42738c 100644 --- a/Source/WebKit/mac/WebView/WebFrameView.mm +++ b/Source/WebKit/mac/WebView/WebFrameView.mm @@ -308,7 +308,6 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl WebCore::notifyHistoryItemChanged = WKNotifyHistoryItemChanged; [WebViewFactory createSharedFactory]; - [WebKeyGenerator createSharedGenerator]; // FIXME: Remove the NSAppKitVersionNumberWithDeferredWindowDisplaySupport check once // once AppKit's Deferred Window Display support is available. diff --git a/Source/WebKit/mac/WebView/WebFullScreenController.h b/Source/WebKit/mac/WebView/WebFullScreenController.h index f867dc2..0f55bd0 100644 --- a/Source/WebKit/mac/WebView/WebFullScreenController.h +++ b/Source/WebKit/mac/WebView/WebFullScreenController.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010, 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 diff --git a/Source/WebKit/mac/WebView/WebFullScreenController.mm b/Source/WebKit/mac/WebView/WebFullScreenController.mm index 5b8b496..3cc8355 100644 --- a/Source/WebKit/mac/WebView/WebFullScreenController.mm +++ b/Source/WebKit/mac/WebView/WebFullScreenController.mm @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved. + * Copyright (C) 2010, 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 diff --git a/Source/WebKit/mac/WebView/WebHTMLRepresentation.h b/Source/WebKit/mac/WebView/WebHTMLRepresentation.h index 68f9bde..b714bf6 100644 --- a/Source/WebKit/mac/WebView/WebHTMLRepresentation.h +++ b/Source/WebKit/mac/WebView/WebHTMLRepresentation.h @@ -57,6 +57,7 @@ + (NSArray *)supportedMIMETypes; + (NSArray *)supportedNonImageMIMETypes; + (NSArray *)supportedImageMIMETypes; ++ (NSArray *)unsupportedTextMIMETypes; - (NSAttributedString *)attributedStringFrom:(DOMNode *)startNode startOffset:(int)startOffset to:(DOMNode *)endNode endOffset:(int)endOffset; diff --git a/Source/WebKit/mac/WebView/WebHTMLRepresentation.mm b/Source/WebKit/mac/WebView/WebHTMLRepresentation.mm index fad0a4a..03edd5d 100644 --- a/Source/WebKit/mac/WebView/WebHTMLRepresentation.mm +++ b/Source/WebKit/mac/WebView/WebHTMLRepresentation.mm @@ -113,6 +113,12 @@ static NSArray *concatenateArrays(NSArray *first, NSArray *second) return staticSupportedImageMIMETypes.get(); } ++ (NSArray *)unsupportedTextMIMETypes +{ + DEFINE_STATIC_LOCAL(RetainPtr<NSArray>, staticUnsupportedTextMIMETypes, (stringArray(MIMETypeRegistry::getUnsupportedTextMIMETypes()))); + return staticUnsupportedTextMIMETypes.get(); +} + - (id)init { self = [super init]; diff --git a/Source/WebKit/mac/WebView/WebHTMLView.mm b/Source/WebKit/mac/WebView/WebHTMLView.mm index 00f65bd..e611e2b 100644 --- a/Source/WebKit/mac/WebView/WebHTMLView.mm +++ b/Source/WebKit/mac/WebView/WebHTMLView.mm @@ -383,6 +383,7 @@ static CachedResourceClient* promisedDataClient() - (DOMDocumentFragment *)_documentFragmentFromPasteboard:(NSPasteboard *)pasteboard inContext:(DOMRange *)context allowPlainText:(BOOL)allowPlainText; - (NSString *)_plainTextFromPasteboard:(NSPasteboard *)pasteboard; - (void)_pasteWithPasteboard:(NSPasteboard *)pasteboard allowPlainText:(BOOL)allowPlainText; +- (void)_pasteAsPlainTextWithPasteboard:(NSPasteboard *)pasteboard; - (void)_removeMouseMovedObserverUnconditionally; - (void)_removeSuperviewObservers; - (void)_removeWindowObservers; @@ -461,11 +462,9 @@ static CachedResourceClient* promisedDataClient() struct WebHTMLViewInterpretKeyEventsParameters { KeyboardEvent* event; - BOOL eventWasHandled; - BOOL shouldSaveCommand; - // The Input Method may consume an event and not tell us, in - // which case we should not bubble the event up the DOM - BOOL consumedByIM; + bool eventInterpretationHadSideEffects; + bool shouldSaveCommands; + bool consumedByIM; }; @interface WebHTMLViewPrivate : NSObject { @@ -522,7 +521,6 @@ struct WebHTMLViewInterpretKeyEventsParameters { BOOL transparentBackground; WebHTMLViewInterpretKeyEventsParameters* interpretKeyEventsParameters; - BOOL receivedNOOP; WebDataSource *dataSource; WebCore::CachedImage* promisedDragTIFFDataSource; @@ -914,6 +912,32 @@ static NSURL* uniqueURLWithRelativePart(NSString *relativePart) [webView release]; } +- (void)_pasteAsPlainTextWithPasteboard:(NSPasteboard *)pasteboard +{ + WebView *webView = [[self _webView] retain]; + [webView _setInsertionPasteboard:pasteboard]; + + NSString *text = [self _plainTextFromPasteboard:pasteboard]; + if ([self _shouldReplaceSelectionWithText:text givenAction:WebViewInsertActionPasted]) + [[self _frame] _replaceSelectionWithText:text selectReplacement:NO smartReplace:[self _canSmartReplaceWithPasteboard:pasteboard]]; + + [webView _setInsertionPasteboard:nil]; + [webView release]; +} + +// This method is needed to support Mac OS X services. +- (BOOL)readSelectionFromPasteboard:(NSPasteboard *)pasteboard +{ + Frame* coreFrame = core([self _frame]); + if (!coreFrame) + return NO; + if (coreFrame->selection()->isContentRichlyEditable()) + [self _pasteWithPasteboard:pasteboard allowPlainText:YES]; + else + [self _pasteAsPlainTextWithPasteboard:pasteboard]; + return YES; +} + - (void)_removeMouseMovedObserverUnconditionally { if (!_private || !_private->observingMouseMovedNotifications) @@ -1169,21 +1193,7 @@ static NSURL* uniqueURLWithRelativePart(NSString *relativePart) + (NSArray *)unsupportedTextMIMETypes { - return [NSArray arrayWithObjects: - @"text/calendar", // iCal - @"text/x-calendar", - @"text/x-vcalendar", - @"text/vcalendar", - @"text/vcard", // vCard - @"text/x-vcard", - @"text/directory", - @"text/ldif", // Netscape Address Book - @"text/qif", // Quicken - @"text/x-qif", - @"text/x-csv", // CSV (for Address Book and Microsoft Outlook) - @"text/x-vcf", // vCard type used in Sun affinity app - @"text/rtf", // Rich Text Format - nil]; + return [WebHTMLRepresentation unsupportedTextMIMETypes]; } + (void)_postFlagsChangedEvent:(NSEvent *)flagsChangedEvent @@ -1985,10 +1995,6 @@ static void _updateMouseoverTimerCallback(CFRunLoopTimerRef timer, void *info) [self removeAllToolTips]; [_private clear]; - - Page* page = core([self _webView]); - if (page) - page->dragController()->setDraggingImageURL(KURL()); } - (BOOL)_hasHTMLDocument @@ -2608,6 +2614,7 @@ WEBCORE_COMMAND(yankAndSelect) [NSPasteboard _web_setFindPasteboardString:[self selectedString] withOwner:self]; } +// This method is needed to support Mac OS X services. - (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pasteboard types:(NSArray *)types { [pasteboard declareTypes:types owner:[self _topHTMLView]]; @@ -3036,7 +3043,12 @@ WEBCORE_COMMAND(yankAndSelect) // We may have created the layer hosting view while outside the window. Update the scale factor // now that we have a window to get it from. if (_private->layerHostingView) { - CGFloat scaleFactor = [[self window] userSpaceScaleFactor]; + CGFloat scaleFactor; +#if !defined(BUILDING_ON_SNOW_LEOPARD) + scaleFactor = [[self window] backingScaleFactor]; +#else + scaleFactor = [[self window] userSpaceScaleFactor]; +#endif [[_private->layerHostingView layer] setTransform:CATransform3DMakeScale(scaleFactor, scaleFactor, 1)]; } #endif @@ -5416,59 +5428,96 @@ static CGPoint coreGraphicsScreenPointForAppKitScreenPoint(NSPoint point) [self _updateMouseoverWithFakeEvent]; } -- (BOOL)_interceptEditingKeyEvent:(KeyboardEvent*)event shouldSaveCommand:(BOOL)shouldSave +- (void)_executeSavedEditingCommands +{ + WebHTMLViewInterpretKeyEventsParameters* parameters = _private->interpretKeyEventsParameters; + if (!parameters || parameters->event->keypressCommands().isEmpty()) + return; + + // Avoid an infinite loop that would occur if executing a command appended it to event->keypressCommands() again. + bool wasSavingCommands = parameters->shouldSaveCommands; + parameters->shouldSaveCommands = false; + + const Vector<KeypressCommand>& commands = parameters->event->keypressCommands(); + + for (size_t i = 0; i < commands.size(); ++i) { + if (commands[i].commandName == "insertText:") + [self insertText:commands[i].text]; + else + [self doCommandBySelector:NSSelectorFromString(commands[i].commandName)]; + } + parameters->event->keypressCommands().clear(); + parameters->shouldSaveCommands = wasSavingCommands; +} + +- (BOOL)_interpretKeyEvent:(KeyboardEvent*)event savingCommands:(BOOL)savingCommands { - // Ask AppKit to process the key event -- it will call back with either insertText or doCommandBySelector. + ASSERT(core([self _frame]) == event->target()->toNode()->document()->frame()); + ASSERT(!savingCommands || event->keypressCommands().isEmpty()); // Save commands once for each event. + WebHTMLViewInterpretKeyEventsParameters parameters; - parameters.eventWasHandled = false; - parameters.shouldSaveCommand = shouldSave; + parameters.eventInterpretationHadSideEffects = false; + parameters.shouldSaveCommands = savingCommands; // If we're intercepting the initial IM call we assume that the IM has consumed the event, // and only change this assumption if one of the NSTextInput/Responder callbacks is used. // We assume the IM will *not* consume hotkey sequences - parameters.consumedByIM = !event->metaKey() && shouldSave; + parameters.consumedByIM = savingCommands && !event->metaKey(); - if (const PlatformKeyboardEvent* platformEvent = event->keyEvent()) { - NSEvent *macEvent = platformEvent->macEvent(); - if ([macEvent type] == NSKeyDown && [_private->completionController filterKeyDown:macEvent]) - return true; - - if ([macEvent type] == NSFlagsChanged) - return false; - - parameters.event = event; - _private->interpretKeyEventsParameters = ¶meters; - _private->receivedNOOP = NO; - const Vector<KeypressCommand>& commands = event->keypressCommands(); - bool hasKeypressCommand = !commands.isEmpty(); - - // FIXME: interpretKeyEvents doesn't match application key equivalents (such as Cmd+A), - // and sends noop: for those. As a result, we don't handle those from within WebCore, - // but send a full sequence of DOM events, including an unneeded keypress. - if (parameters.shouldSaveCommand || !hasKeypressCommand) - [self interpretKeyEvents:[NSArray arrayWithObject:macEvent]]; - else { - size_t size = commands.size(); - // Are there commands that would just cause text insertion if executed via Editor? - // WebKit doesn't have enough information about mode to decide how they should be treated, so we leave it upon WebCore - // to either handle them immediately (e.g. Tab that changes focus) or let a keypress event be generated - // (e.g. Tab that inserts a Tab character, or Enter). - bool haveTextInsertionCommands = false; - for (size_t i = 0; i < size; ++i) { - if ([self coreCommandBySelector:NSSelectorFromString(commands[i].commandName)].isTextInsertion()) - haveTextInsertionCommands = true; - } - if (!haveTextInsertionCommands || platformEvent->type() == PlatformKeyboardEvent::Char) { - for (size_t i = 0; i < size; ++i) { - if (commands[i].commandName == "insertText:") - [self insertText:commands[i].text]; - else - [self doCommandBySelector:NSSelectorFromString(commands[i].commandName)]; - } - } + const PlatformKeyboardEvent* platformEvent = event->keyEvent(); + if (!platformEvent) + return NO; + + NSEvent *macEvent = platformEvent->macEvent(); + if ([macEvent type] == NSKeyDown && [_private->completionController filterKeyDown:macEvent]) + return YES; + + if ([macEvent type] == NSFlagsChanged) + return NO; + + parameters.event = event; + _private->interpretKeyEventsParameters = ¶meters; + const Vector<KeypressCommand>& commands = event->keypressCommands(); + + if (savingCommands) { + // AppKit will respond with a series of NSTextInput protocol method calls. There are three groups that we heuristically differentiate: + // 1. Key Bindings. Only doCommandBySelector: and insertText: calls will be made, which we save in the event for execution + // after DOM dispatch. This is safe, because neither returns a result, so there is no branching on AppKit side. + // 2. Plain text input. Here as well, we need to dispatch DOM events prior to inserting text, so we save the insertText: command. + // 3. Input method processing. An IM can make any NSTextInput calls, and can base its decisions on results it gets, so we must + // execute the calls immediately. DOM events like keydown are tweaked to have keyCode of 229, and canceling them has no effect. + // Unfortunately, there is no real difference between plain text input and IM processing - for example, AppKit queries hasMarkedText + // when typing with U.S. keyboard, and inserts marked text for dead keys. + [self interpretKeyEvents:[NSArray arrayWithObject:macEvent]]; + } else { + // Are there commands that could just cause text insertion if executed via Editor? + // WebKit doesn't have enough information about mode to decide how they should be treated, so we leave it upon WebCore + // to either handle them immediately (e.g. Tab that changes focus) or let a keypress event be generated + // (e.g. Tab that inserts a Tab character, or Enter). + bool haveTextInsertionCommands = false; + for (size_t i = 0; i < commands.size(); ++i) { + if ([self coreCommandBySelector:NSSelectorFromString(commands[i].commandName)].isTextInsertion()) + haveTextInsertionCommands = true; } - _private->interpretKeyEventsParameters = 0; + // If there are no text insertion commands, default keydown handler is the right time to execute the commands. + // Keypress (Char event) handler is the latest opportunity to execute. + if (!haveTextInsertionCommands || platformEvent->type() == PlatformKeyboardEvent::Char) + [self _executeSavedEditingCommands]; } - return (!_private->receivedNOOP && parameters.eventWasHandled) || parameters.consumedByIM; + _private->interpretKeyEventsParameters = 0; + + // An input method may make several actions per keypress. For example, pressing Return with Korean IM both confirms it and sends a newline. + // IM-like actions are handled immediately (so parameters.eventInterpretationHadSideEffects is true), but there are saved commands that + // should be handled like normal text input after DOM event dispatch. + if (!event->keypressCommands().isEmpty()) + return NO; + + // An input method may consume an event and not tell us (e.g. when displaying a candidate window), + // in which case we should not bubble the event up the DOM. + if (parameters.consumedByIM) + return YES; + + // If we have already executed all commands, don't do it again. + return parameters.eventInterpretationHadSideEffects; } - (WebCore::CachedImage*)promisedDragTIFFDataSource @@ -5551,7 +5600,20 @@ static CGPoint coreGraphicsScreenPointForAppKitScreenPoint(NSPoint point) #if !defined(BUILDING_ON_LEOPARD) // If we aren't in the window yet, we'll use the screen's scale factor now, and reset the scale // via -viewDidMoveToWindow. - CGFloat scaleFactor = [self window] ? [[self window] userSpaceScaleFactor] : [[NSScreen mainScreen] userSpaceScaleFactor]; + NSWindow *window = [self window]; + CGFloat scaleFactor; +#if !defined(BUILDING_ON_SNOW_LEOPARD) + if (window) + scaleFactor = [window backingScaleFactor]; + else + scaleFactor = [[NSScreen mainScreen] backingScaleFactor]; +#else + if (window) + scaleFactor = [window userSpaceScaleFactor]; + else + scaleFactor = [[NSScreen mainScreen] userSpaceScaleFactor]; +#endif + [viewLayer setTransform:CATransform3DMakeScale(scaleFactor, scaleFactor, 1)]; #endif @@ -5684,6 +5746,8 @@ static CGPoint coreGraphicsScreenPointForAppKitScreenPoint(NSPoint point) - (NSUInteger)characterIndexForPoint:(NSPoint)thePoint { + [self _executeSavedEditingCommands]; + NSWindow *window = [self window]; WebFrame *frame = [self _frame]; @@ -5703,7 +5767,9 @@ static CGPoint coreGraphicsScreenPointForAppKitScreenPoint(NSPoint point) } - (NSRect)firstRectForCharacterRange:(NSRange)theRange -{ +{ + [self _executeSavedEditingCommands]; + WebFrame *frame = [self _frame]; // Just to match NSTextView's behavior. Regression tests cannot detect this; @@ -5734,6 +5800,8 @@ static CGPoint coreGraphicsScreenPointForAppKitScreenPoint(NSPoint point) - (NSRange)selectedRange { + [self _executeSavedEditingCommands]; + if (!isTextInput(core([self _frame]))) { LOG(TextInput, "selectedRange -> (NSNotFound, 0)"); return NSMakeRange(NSNotFound, 0); @@ -5746,6 +5814,8 @@ static CGPoint coreGraphicsScreenPointForAppKitScreenPoint(NSPoint point) - (NSRange)markedRange { + [self _executeSavedEditingCommands]; + WebFrame *webFrame = [self _frame]; Frame* coreFrame = core(webFrame); if (!coreFrame) @@ -5758,6 +5828,8 @@ static CGPoint coreGraphicsScreenPointForAppKitScreenPoint(NSPoint point) - (NSAttributedString *)attributedSubstringFromRange:(NSRange)nsRange { + [self _executeSavedEditingCommands]; + WebFrame *frame = [self _frame]; Frame* coreFrame = core(frame); if (!isTextInput(coreFrame) || isInPasswordField(coreFrame)) { @@ -5799,6 +5871,8 @@ static CGPoint coreGraphicsScreenPointForAppKitScreenPoint(NSPoint point) - (BOOL)hasMarkedText { + [self _executeSavedEditingCommands]; + Frame* coreFrame = core([self _frame]); BOOL result = coreFrame && coreFrame->editor()->hasComposition(); LOG(TextInput, "hasMarkedText -> %u", result); @@ -5807,6 +5881,8 @@ static CGPoint coreGraphicsScreenPointForAppKitScreenPoint(NSPoint point) - (void)unmarkText { + [self _executeSavedEditingCommands]; + LOG(TextInput, "unmarkText"); // Use pointer to get parameters passed to us by the caller of interpretKeyEvents. @@ -5814,8 +5890,8 @@ static CGPoint coreGraphicsScreenPointForAppKitScreenPoint(NSPoint point) _private->interpretKeyEventsParameters = 0; if (parameters) { - parameters->eventWasHandled = YES; - parameters->consumedByIM = NO; + parameters->eventInterpretationHadSideEffects = true; + parameters->consumedByIM = false; } if (Frame* coreFrame = core([self _frame])) @@ -5844,6 +5920,8 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde - (void)setMarkedText:(id)string selectedRange:(NSRange)newSelRange { + [self _executeSavedEditingCommands]; + BOOL isAttributedString = [string isKindOfClass:[NSAttributedString class]]; // Otherwise, NSString LOG(TextInput, "setMarkedText:\"%@\" selectedRange:(%u, %u)", isAttributedString ? [string string] : string, newSelRange.location, newSelRange.length); @@ -5853,8 +5931,8 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde _private->interpretKeyEventsParameters = 0; if (parameters) { - parameters->eventWasHandled = YES; - parameters->consumedByIM = NO; + parameters->eventInterpretationHadSideEffects = true; + parameters->consumedByIM = false; } Frame* coreFrame = core([self _frame]); @@ -5869,7 +5947,7 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde if (isAttributedString) { unsigned markedTextLength = [(NSString *)string length]; - NSString *rangeString = [string attribute:NSTextInputReplacementRangeAttributeName atIndex:0 longestEffectiveRange:NULL inRange:NSMakeRange(0, markedTextLength)]; + NSString *rangeString = [string attribute:NSTextInputReplacementRangeAttributeName atIndex:0 longestEffectiveRange:0 inRange:NSMakeRange(0, markedTextLength)]; LOG(TextInput, " ReplacementRange: %@", rangeString); // The AppKit adds a 'secret' property to the string that contains the replacement range. // The replacement range is the range of the the text that should be replaced with the new string. @@ -5891,17 +5969,16 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde // The same call to interpretKeyEvents can do more than one command. WebHTMLViewInterpretKeyEventsParameters* parameters = _private->interpretKeyEventsParameters; if (parameters) - parameters->consumedByIM = NO; - - if (selector == @selector(noop:)) { - _private->receivedNOOP = YES; - return; - } + parameters->consumedByIM = false; KeyboardEvent* event = parameters ? parameters->event : 0; - bool shouldSaveCommand = parameters && parameters->shouldSaveCommand; + bool shouldSaveCommand = parameters && parameters->shouldSaveCommands; + + // As in insertText:, we assume that the call comes from an input method if there is marked text. + RefPtr<Frame> coreFrame = core([self _frame]); + bool isFromInputMethod = coreFrame && coreFrame->editor()->hasComposition(); - if (event && shouldSaveCommand) + if (event && shouldSaveCommand && !isFromInputMethod) event->keypressCommands().append(KeypressCommand(NSStringFromSelector(selector))); else { // Make sure that only direct calls to doCommandBySelector: see the parameters by setting to 0. @@ -5933,10 +6010,8 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde } if (parameters) - parameters->eventWasHandled = eventWasHandled; + parameters->eventInterpretationHadSideEffects |= eventWasHandled; - // Restore the parameters so that other calls to doCommandBySelector: see them, - // and other commands can participate in setting the "eventWasHandled" flag. _private->interpretKeyEventsParameters = parameters; } } @@ -5948,9 +6023,8 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde LOG(TextInput, "insertText:\"%@\"", isAttributedString ? [string string] : string); WebHTMLViewInterpretKeyEventsParameters* parameters = _private->interpretKeyEventsParameters; - _private->interpretKeyEventsParameters = 0; if (parameters) - parameters->consumedByIM = NO; + parameters->consumedByIM = false; // We don't support inserting an attributed string but input methods don't appear to require this. RefPtr<Frame> coreFrame = core([self _frame]); @@ -5960,57 +6034,48 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde text = [string string]; // We deal with the NSTextInputReplacementRangeAttributeName attribute from NSAttributedString here // simply because it is used by at least one Input Method -- it corresonds to the kEventParamTextInputSendReplaceRange - // event in TSM. This behaviour matches that of -[WebHTMLView setMarkedText:selectedRange:] when it receives an + // event in TSM. This behavior matches that of -[WebHTMLView setMarkedText:selectedRange:] when it receives an // NSAttributedString - NSString *rangeString = [string attribute:NSTextInputReplacementRangeAttributeName atIndex:0 longestEffectiveRange:NULL inRange:NSMakeRange(0, [text length])]; + NSString *rangeString = [string attribute:NSTextInputReplacementRangeAttributeName atIndex:0 longestEffectiveRange:0 inRange:NSMakeRange(0, [text length])]; LOG(TextInput, " ReplacementRange: %@", rangeString); if (rangeString) { [[self _frame] _selectNSRange:NSRangeFromString(rangeString)]; - isFromInputMethod = YES; + isFromInputMethod = true; } } else text = string; - bool eventHandled = false; - if ([text length]) { - KeyboardEvent* event = parameters ? parameters->event : 0; - - // insertText can be called from an input method or from normal key event processing - // If its from normal key event processing, we may need to save the action to perform it later. - // If its from an input method, then we should go ahead and insert the text now. - // We assume it's from the input method if we have marked text. - // FIXME: In theory, this could be wrong for some input methods, so we should try to find - // another way to determine if the call is from the input method - bool shouldSaveCommand = parameters && parameters->shouldSaveCommand; - if (event && shouldSaveCommand && !isFromInputMethod) { - event->keypressCommands().append(KeypressCommand("insertText:", text)); - _private->interpretKeyEventsParameters = parameters; - return; - } - - String eventText = text; - eventText.replace(NSBackTabCharacter, NSTabCharacter); // same thing is done in KeyEventMac.mm in WebCore - if (coreFrame && coreFrame->editor()->canEdit()) { - if (!coreFrame->editor()->hasComposition()) - eventHandled = coreFrame->editor()->insertText(eventText, event); - else { - eventHandled = true; - coreFrame->editor()->confirmComposition(eventText); - } - } - } - - if (!parameters) + KeyboardEvent* event = parameters ? parameters->event : 0; + + // insertText can be called for several reasons: + // - If it's from normal key event processing (including key bindings), we may need to save the action to perform it later. + // - If it's from an input method, then we should go ahead and insert the text now. We assume it's from the input method if we have marked text. + // FIXME: In theory, this could be wrong for some input methods, so we should try to find another way to determine if the call is from the input method. + // - If it's sent outside of keyboard event processing (e.g. from Character Viewer, or when confirming an inline input area with a mouse), + // then we also execute it immediately, as there will be no other chance. + bool shouldSaveCommand = parameters && parameters->shouldSaveCommands; + if (event && shouldSaveCommand && !isFromInputMethod) { + event->keypressCommands().append(KeypressCommand("insertText:", text)); return; - - if (isFromInputMethod) { - // Allow doCommandBySelector: to be called after insertText: by resetting interpretKeyEventsParameters - _private->interpretKeyEventsParameters = parameters; - parameters->consumedByIM = YES; + } + + if (!coreFrame || !coreFrame->editor()->canEdit()) return; + + bool eventHandled = false; + String eventText = text; + eventText.replace(NSBackTabCharacter, NSTabCharacter); // same thing is done in KeyEventMac.mm in WebCore + if (!coreFrame->editor()->hasComposition()) { + // An insertText: might be handled by other responders in the chain if we don't handle it. + // One example is space bar that results in scrolling down the page. + eventHandled = coreFrame->editor()->insertText(eventText, event); + } else { + eventHandled = true; + coreFrame->editor()->confirmComposition(eventText); } - parameters->eventWasHandled = eventHandled; + if (parameters) + parameters->eventInterpretationHadSideEffects |= eventHandled; } - (void)_updateSelectionForInputManager diff --git a/Source/WebKit/mac/WebView/WebHTMLViewInternal.h b/Source/WebKit/mac/WebView/WebHTMLViewInternal.h index 07a782a..d38fded 100644 --- a/Source/WebKit/mac/WebView/WebHTMLViewInternal.h +++ b/Source/WebKit/mac/WebView/WebHTMLViewInternal.h @@ -49,7 +49,7 @@ namespace WebCore { - (WebFrame *)_frame; - (void)_lookUpInDictionaryFromMenu:(id)sender; - (void)_hoverFeedbackSuspendedChanged; -- (BOOL)_interceptEditingKeyEvent:(WebCore::KeyboardEvent *)event shouldSaveCommand:(BOOL)shouldSave; +- (BOOL)_interpretKeyEvent:(WebCore::KeyboardEvent *)event savingCommands:(BOOL)savingCommands; - (DOMDocumentFragment *)_documentFragmentFromPasteboard:(NSPasteboard *)pasteboard; - (NSEvent *)_mouseDownEvent; #ifndef BUILDING_ON_TIGER diff --git a/Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h b/Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h index b6ae03f..a2f176a 100644 --- a/Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h +++ b/Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h @@ -89,6 +89,7 @@ #define WebKitJavaScriptCanAccessClipboardPreferenceKey @"WebKitJavaScriptCanAccessClipboard" #define WebKitXSSAuditorEnabledPreferenceKey @"WebKitXSSAuditorEnabled" #define WebKitAcceleratedDrawingEnabledPreferenceKey @"WebKitAcceleratedDrawingEnabled" +#define WebKitCanvasUsesAcceleratedDrawingPreferenceKey @"WebKitCanvasUsesAcceleratedDrawing" #define WebKitAcceleratedCompositingEnabledPreferenceKey @"WebKitAcceleratedCompositingEnabled" #define WebKitShowDebugBordersPreferenceKey @"WebKitShowDebugBorders" #define WebKitShowRepaintCounterPreferenceKey @"WebKitShowRepaintCounter" @@ -104,6 +105,7 @@ #define WebKitAsynchronousSpellCheckingEnabledPreferenceKey @"WebKitAsynchronousSpellCheckingEnabled" #define WebKitMemoryInfoEnabledPreferenceKey @"WebKitMemoryInfoEnabled" #define WebKitHyperlinkAuditingEnabledPreferenceKey @"WebKitHyperlinkAuditingEnabled" +#define WebKitUseQuickLookResourceCachingQuirksPreferenceKey @"WebKitUseQuickLookResourceCachingQuirks" // These are private both because callers should be using the cover methods and because the // cover methods themselves are private. diff --git a/Source/WebKit/mac/WebView/WebPreferences.mm b/Source/WebKit/mac/WebView/WebPreferences.mm index 3fd41f6..a5f24e0 100644 --- a/Source/WebKit/mac/WebView/WebPreferences.mm +++ b/Source/WebKit/mac/WebView/WebPreferences.mm @@ -136,6 +136,22 @@ static WebCacheModel cacheModelForMainBundle(void) return cacheModel; } +static bool useQuickLookQuirks(void) +{ + NSArray* frameworks = [NSBundle allFrameworks]; + + if (!frameworks) + return false; + + for (unsigned int i = 0; i < [frameworks count]; i++) { + NSBundle* bundle = [frameworks objectAtIndex: i]; + const char* bundleID = [[bundle bundleIdentifier] UTF8String]; + if (bundleID && !strcasecmp(bundleID, "com.apple.QuickLookUIFramework")) + return true; + } + return false; +} + @interface WebPreferencesPrivate : NSObject { @public @@ -359,6 +375,7 @@ static WebCacheModel cacheModelForMainBundle(void) [NSNumber numberWithBool:YES], WebKitXSSAuditorEnabledPreferenceKey, [NSNumber numberWithBool:YES], WebKitAcceleratedCompositingEnabledPreferenceKey, [NSNumber numberWithBool:NO], WebKitAcceleratedDrawingEnabledPreferenceKey, + [NSNumber numberWithBool:YES], WebKitCanvasUsesAcceleratedDrawingPreferenceKey, [NSNumber numberWithBool:NO], WebKitShowDebugBordersPreferenceKey, [NSNumber numberWithBool:NO], WebKitShowRepaintCounterPreferenceKey, [NSNumber numberWithBool:NO], WebKitWebGLEnabledPreferenceKey, @@ -367,11 +384,12 @@ static WebCacheModel cacheModelForMainBundle(void) [NSNumber numberWithBool:NO], WebKitFrameFlatteningEnabledPreferenceKey, [NSNumber numberWithBool:NO], WebKitSpatialNavigationEnabledPreferenceKey, [NSNumber numberWithBool:NO], WebKitDNSPrefetchingEnabledPreferenceKey, - [NSNumber numberWithBool:NO], WebKitFullScreenEnabledPreferenceKey, + [NSNumber numberWithBool:YES], WebKitFullScreenEnabledPreferenceKey, [NSNumber numberWithBool:NO], WebKitAsynchronousSpellCheckingEnabledPreferenceKey, [NSNumber numberWithBool:NO], WebKitMemoryInfoEnabledPreferenceKey, [NSNumber numberWithBool:YES], WebKitHyperlinkAuditingEnabledPreferenceKey, [NSNumber numberWithBool:NO], WebKitUsePreHTML5ParserQuirksKey, + [NSNumber numberWithBool:useQuickLookQuirks()], WebKitUseQuickLookResourceCachingQuirksPreferenceKey, [NSNumber numberWithLongLong:WebCore::ApplicationCacheStorage::noQuota()], WebKitApplicationCacheTotalQuota, [NSNumber numberWithLongLong:WebCore::ApplicationCacheStorage::noQuota()], WebKitApplicationCacheDefaultOriginQuota, nil]; @@ -1245,6 +1263,16 @@ static NSString *classIBCreatorID = nil; [self _setBoolValue:enabled forKey:WebKitAcceleratedDrawingEnabledPreferenceKey]; } +- (BOOL)canvasUsesAcceleratedDrawing +{ + return [self _boolValueForKey:WebKitCanvasUsesAcceleratedDrawingPreferenceKey]; +} + +- (void)setCanvasUsesAcceleratedDrawing:(BOOL)enabled +{ + [self _setBoolValue:enabled forKey:WebKitCanvasUsesAcceleratedDrawingPreferenceKey]; +} + - (BOOL)acceleratedCompositingEnabled { return [self _boolValueForKey:WebKitAcceleratedCompositingEnabledPreferenceKey]; @@ -1385,6 +1413,11 @@ static NSString *classIBCreatorID = nil; [self _setBoolValue:flag forKey:WebKitUsePreHTML5ParserQuirksKey]; } +- (BOOL)useQuickLookResourceCachingQuirks +{ + return [self _boolValueForKey:WebKitUseQuickLookResourceCachingQuirksPreferenceKey]; +} + - (void)didRemoveFromWebView { ASSERT(_private->numWebViews); diff --git a/Source/WebKit/mac/WebView/WebPreferencesPrivate.h b/Source/WebKit/mac/WebView/WebPreferencesPrivate.h index 40d4b5b..7e1f6a2 100644 --- a/Source/WebKit/mac/WebView/WebPreferencesPrivate.h +++ b/Source/WebKit/mac/WebView/WebPreferencesPrivate.h @@ -179,6 +179,9 @@ extern NSString *WebPreferencesRemovedNotification; - (BOOL)acceleratedDrawingEnabled; - (void)setAcceleratedDrawingEnabled:(BOOL)enabled; +- (BOOL)canvasUsesAcceleratedDrawing; +- (void)setCanvasUsesAcceleratedDrawing:(BOOL)enabled; + - (BOOL)acceleratedCompositingEnabled; - (void)setAcceleratedCompositingEnabled:(BOOL)enabled; @@ -233,4 +236,6 @@ extern NSString *WebPreferencesRemovedNotification; - (void)setUsePreHTML5ParserQuirks:(BOOL)flag; - (BOOL)usePreHTML5ParserQuirks; +- (BOOL)useQuickLookResourceCachingQuirks; + @end diff --git a/Source/WebKit/mac/WebView/WebScriptDebugDelegate.mm b/Source/WebKit/mac/WebView/WebScriptDebugDelegate.mm index 270266b..738c4df 100644 --- a/Source/WebKit/mac/WebView/WebScriptDebugDelegate.mm +++ b/Source/WebKit/mac/WebView/WebScriptDebugDelegate.mm @@ -239,7 +239,7 @@ NSString * const WebScriptErrorLineNumberKey = @"WebScriptErrorLineNumber"; if (self == _private->debugger->globalCallFrame() && !globalObject->globalData().dynamicGlobalObject) { JSGlobalObject* globalObject = _private->debugger->globalObject(); - DynamicGlobalObjectScope globalObjectScope(globalObject->globalExec(), globalObject); + DynamicGlobalObjectScope globalObjectScope(globalObject->globalData(), globalObject); JSValue exception; JSValue result = evaluateInGlobalCallFrame(stringToUString(script), exception, globalObject); diff --git a/Source/WebKit/mac/WebView/WebView.mm b/Source/WebKit/mac/WebView/WebView.mm index 2f45ca4..3d42be0 100644 --- a/Source/WebKit/mac/WebView/WebView.mm +++ b/Source/WebKit/mac/WebView/WebView.mm @@ -97,6 +97,7 @@ #import "WebPreferencesPrivate.h" #import "WebScriptDebugDelegate.h" #import "WebScriptWorldInternal.h" +#import "WebStorageManagerInternal.h" #import "WebSystemInterface.h" #import "WebTextCompletionController.h" #import "WebTextIterator.h" @@ -687,6 +688,10 @@ static NSString *leakMailQuirksUserScriptPath() #if ENABLE(DATABASE) WebKitInitializeDatabasesIfNecessary(); #endif + +#if ENABLE(DOM_STORAGE) + WebKitInitializeStorageIfNecessary(); +#endif WebKitInitializeApplicationCachePathIfNecessary(); patchMailRemoveAttributesMethod(); @@ -1491,6 +1496,8 @@ static bool fastDocumentTeardownEnabled() // Until we fix that, I will comment out the test (CFM) settings->setAcceleratedCompositingEnabled((coreVideoHas7228836Fix() || [preferences webGLEnabled] || [preferences accelerated2dCanvasEnabled]) && [preferences acceleratedCompositingEnabled]); + settings->setAcceleratedDrawingEnabled([preferences acceleratedDrawingEnabled]); + settings->setCanvasUsesAcceleratedDrawing([preferences canvasUsesAcceleratedDrawing]); settings->setShowDebugBorders([preferences showDebugBorders]); settings->setShowRepaintCounter([preferences showRepaintCounter]); settings->setPluginAllowedRunTime([preferences pluginAllowedRunTime]); @@ -1511,7 +1518,10 @@ static bool fastDocumentTeardownEnabled() settings->setMemoryInfoEnabled([preferences memoryInfoEnabled]); settings->setHyperlinkAuditingEnabled([preferences hyperlinkAuditingEnabled]); settings->setUsePreHTML5ParserQuirks([self _needsPreHTML5ParserQuirks]); + settings->setUseQuickLookResourceCachingQuirks([preferences useQuickLookResourceCachingQuirks]); settings->setCrossOriginCheckInGetMatchedCSSRulesDisabled([self _needsUnrestrictedGetMatchedCSSRules]); + settings->setInteractiveFormValidationEnabled([self interactiveFormValidationEnabled]); + settings->setValidationMessageTimerMagnification([self validationMessageTimerMagnification]); // Application Cache Preferences are stored on the global cache storage manager, not in Settings. [WebApplicationCache setDefaultOriginQuota:[preferences applicationCacheDefaultOriginQuota]]; @@ -2396,6 +2406,26 @@ static inline IMP getMethod(id o, SEL s) return NO; } +- (BOOL)interactiveFormValidationEnabled +{ + return _private->interactiveFormValidationEnabled; +} + +- (void)setInteractiveFormValidationEnabled:(BOOL)enabled +{ + _private->interactiveFormValidationEnabled = enabled; +} + +- (int)validationMessageTimerMagnification +{ + return _private->validationMessageTimerMagnification; +} + +- (void)setValidationMessageTimerMagnification:(int)newValue +{ + _private->validationMessageTimerMagnification = newValue; +} + - (BOOL)_isSoftwareRenderable { #if USE(ACCELERATED_COMPOSITING) @@ -5000,12 +5030,12 @@ static NSAppleEventDescriptor* aeDescFromJSValue(ExecState* exec, JSValue jsValu - (void)setEditable:(BOOL)flag { - if ([self isEditable] != flag) { - if (!_private->tabKeyCyclesThroughElementsChanged && _private->page) + if ([self isEditable] != flag && _private->page) { + _private->page->setEditable(flag); + if (!_private->tabKeyCyclesThroughElementsChanged) _private->page->setTabKeyCyclesThroughElements(!flag); Frame* mainFrame = [self _mainCoreFrame]; if (mainFrame) { - mainFrame->document()->setDesignMode(flag ? WebCore::Document::on : WebCore::Document::off); if (flag) { mainFrame->editor()->applyEditingStyleToBodyElement(); // If the WebView is made editable and the selection is empty, set it to something. @@ -5018,10 +5048,7 @@ static NSAppleEventDescriptor* aeDescFromJSValue(ExecState* exec, JSValue jsValu - (BOOL)isEditable { - Frame* mainFrame = [self _mainCoreFrame]; - if (mainFrame) - return mainFrame->document()->inDesignMode(); - return false; + return _private->page && _private->page->isEditable(); } - (void)setTypingStyle:(DOMCSSStyleDeclaration *)style @@ -5306,6 +5333,16 @@ static NSAppleEventDescriptor* aeDescFromJSValue(ExecState* exec, JSValue jsValu #endif +#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) +- (void)handleCorrectionPanelResult:(NSString*)result +{ + WebFrame *webFrame = [self _selectedOrMainFrame]; + Frame* coreFrame = core(webFrame); + if (coreFrame) + coreFrame->editor()->handleCorrectionPanelResult(result); +} +#endif + @end @implementation WebView (WebViewUndoableEditing) @@ -5415,7 +5452,7 @@ FOR_EACH_RESPONDER_SELECTOR(FORWARD) Frame* coreFrame = core([self _selectedOrMainFrame]); if (!coreFrame) return NO; - return coreFrame->selection()->isAll(MayLeaveEditableContent); + return coreFrame->selection()->isAll(CanCrossEditingBoundary); } @end @@ -5859,7 +5896,7 @@ static inline uint64_t roundUpToPowerOf2(uint64_t num) WebFrameLoadDelegateImplementationCache* cache = &_private->frameLoadDelegateImplementations; if (cache->didReceiveIconForFrameFunc) { - Image* image = iconDatabase().iconForPageURL(core(webFrame)->document()->url().string(), IntSize(16, 16)); + Image* image = iconDatabase().synchronousIconForPageURL(core(webFrame)->document()->url().string(), IntSize(16, 16)); if (NSImage *icon = webGetNSImage(image, NSMakeSize(16, 16))) CallFrameLoadDelegate(cache->didReceiveIconForFrameFunc, self, @selector(webView:didReceiveIcon:forFrame:), icon, webFrame); } @@ -6120,8 +6157,11 @@ static void layerSyncRunLoopObserverCallBack(CFRunLoopObserverRef, CFRunLoopActi #endif #if ENABLE(FULLSCREEN_API) -- (BOOL)_supportsFullScreenForElement:(const WebCore::Element*)element +- (BOOL)_supportsFullScreenForElement:(const WebCore::Element*)element withKeyboard:(BOOL)withKeyboard { + if (withKeyboard) + return NO; + if (![[WebPreferences standardPreferences] fullScreenEnabled]) return NO; diff --git a/Source/WebKit/mac/WebView/WebViewData.h b/Source/WebKit/mac/WebView/WebViewData.h index e8b9188..a6a5a07 100644 --- a/Source/WebKit/mac/WebView/WebViewData.h +++ b/Source/WebKit/mac/WebView/WebViewData.h @@ -186,5 +186,8 @@ extern int pluginDatabaseClientCount; id<WebDeviceOrientationProvider> m_deviceOrientationProvider; RefPtr<WebCore::HistoryItem> _globalHistoryItem; + + BOOL interactiveFormValidationEnabled; + int validationMessageTimerMagnification; } @end diff --git a/Source/WebKit/mac/WebView/WebViewData.mm b/Source/WebKit/mac/WebView/WebViewData.mm index df7563e..e74c7a1 100644 --- a/Source/WebKit/mac/WebView/WebViewData.mm +++ b/Source/WebKit/mac/WebView/WebViewData.mm @@ -65,6 +65,10 @@ int pluginDatabaseClientCount = 0; zoomMultiplier = 1; zoomsTextOnly = NO; + interactiveFormValidationEnabled = NO; + // The default value should be synchronized with WebCore/page/Settings.cpp. + validationMessageTimerMagnification = 50; + #if ENABLE(DASHBOARD_SUPPORT) dashboardBehaviorAllowWheelScrolling = YES; #endif diff --git a/Source/WebKit/mac/WebView/WebViewInternal.h b/Source/WebKit/mac/WebView/WebViewInternal.h index 9517104..65cb4d8 100644 --- a/Source/WebKit/mac/WebView/WebViewInternal.h +++ b/Source/WebKit/mac/WebView/WebViewInternal.h @@ -57,7 +57,6 @@ namespace WebCore { #ifdef __cplusplus @interface WebView (WebViewEditingExtras) -- (BOOL)_interceptEditingKeyEvent:(WebCore::KeyboardEvent*)event shouldSaveCommand:(BOOL)shouldSave; - (BOOL)_shouldChangeSelectedDOMRange:(DOMRange *)currentRange toDOMRange:(DOMRange *)proposedRange affinity:(NSSelectionAffinity)selectionAffinity stillSelecting:(BOOL)flag; @end @@ -190,7 +189,7 @@ namespace WebCore { #endif #if ENABLE(FULLSCREEN_API) && defined(__cplusplus) -- (BOOL)_supportsFullScreenForElement:(WebCore::Element*)element; +- (BOOL)_supportsFullScreenForElement:(WebCore::Element*)element withKeyboard:(BOOL)withKeyboard; - (void)_enterFullScreenForElement:(WebCore::Element*)element; - (void)_exitFullScreenForElement:(WebCore::Element*)element; - (void)_fullScreenRendererChanged:(WebCore::RenderBox*)renderer; diff --git a/Source/WebKit/mac/WebView/WebViewPrivate.h b/Source/WebKit/mac/WebView/WebViewPrivate.h index a4ea809..7d7537e 100644 --- a/Source/WebKit/mac/WebView/WebViewPrivate.h +++ b/Source/WebKit/mac/WebView/WebViewPrivate.h @@ -487,6 +487,12 @@ Could be worth adding to the API. - (void)_setPostsAcceleratedCompositingNotifications:(BOOL)flag; - (BOOL)_isUsingAcceleratedCompositing; +// For DumpRenderTree +- (BOOL)interactiveFormValidationEnabled; +- (void)setInteractiveFormValidationEnabled:(BOOL)enabled; +- (int)validationMessageTimerMagnification; +- (void)setValidationMessageTimerMagnification:(int)newValue; + // Returns YES if NSView -displayRectIgnoringOpacity:inContext: will produce a faithful representation of the content. - (BOOL)_isSoftwareRenderable; // When drawing into a bitmap context, we normally flatten compositing layers (and distort 3D transforms). @@ -644,7 +650,9 @@ Could be worth adding to the API. - (void)setAutomaticSpellingCorrectionEnabled:(BOOL)flag; - (void)toggleAutomaticSpellingCorrection:(id)sender; #endif - +#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) +- (void)handleCorrectionPanelResult:(NSString*)result; +#endif @end @interface WebView (WebViewEditingInMail) |