summaryrefslogtreecommitdiffstats
path: root/WebKit/mac/WebView
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/mac/WebView')
-rw-r--r--WebKit/mac/WebView/WebDashboardRegion.h51
-rw-r--r--WebKit/mac/WebView/WebDashboardRegion.mm93
-rw-r--r--WebKit/mac/WebView/WebFrame.mm69
-rw-r--r--WebKit/mac/WebView/WebFrameInternal.h2
-rw-r--r--WebKit/mac/WebView/WebHTMLRepresentation.mm65
-rw-r--r--WebKit/mac/WebView/WebHTMLView.mm116
-rw-r--r--WebKit/mac/WebView/WebPreferenceKeysPrivate.h2
-rw-r--r--WebKit/mac/WebView/WebPreferences.mm32
-rw-r--r--WebKit/mac/WebView/WebPreferencesPrivate.h8
-rw-r--r--WebKit/mac/WebView/WebView.mm79
-rw-r--r--WebKit/mac/WebView/WebViewData.h1
-rw-r--r--WebKit/mac/WebView/WebViewData.mm1
12 files changed, 349 insertions, 170 deletions
diff --git a/WebKit/mac/WebView/WebDashboardRegion.h b/WebKit/mac/WebView/WebDashboardRegion.h
new file mode 100644
index 0000000..4963d04
--- /dev/null
+++ b/WebKit/mac/WebView/WebDashboardRegion.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2004 Apple Computer, 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.
+ */
+
+#if !defined(ENABLE_DASHBOARD_SUPPORT)
+#define ENABLE_DASHBOARD_SUPPORT 1
+#endif
+
+#if ENABLE_DASHBOARD_SUPPORT
+
+typedef enum {
+ WebDashboardRegionTypeNone,
+ WebDashboardRegionTypeCircle,
+ WebDashboardRegionTypeRectangle,
+ WebDashboardRegionTypeScrollerRectangle
+} WebDashboardRegionType;
+
+@interface WebDashboardRegion : NSObject <NSCopying>
+{
+ NSRect rect;
+ NSRect clip;
+ WebDashboardRegionType type;
+}
+- initWithRect:(NSRect)rect clip:(NSRect)clip type:(WebDashboardRegionType)type;
+- (NSRect)dashboardRegionClip;
+- (NSRect)dashboardRegionRect;
+- (WebDashboardRegionType)dashboardRegionType;
+@end
+
+#endif
diff --git a/WebKit/mac/WebView/WebDashboardRegion.mm b/WebKit/mac/WebView/WebDashboardRegion.mm
new file mode 100644
index 0000000..c44977a
--- /dev/null
+++ b/WebKit/mac/WebView/WebDashboardRegion.mm
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2004 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 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.
+ */
+
+#import "WebDashboardRegion.h"
+
+#import <wtf/UnusedParam.h>
+
+#if ENABLE(DASHBOARD_SUPPORT)
+
+@implementation WebDashboardRegion
+
+- initWithRect:(NSRect)r clip:(NSRect)c type:(WebDashboardRegionType)t
+{
+ self = [super init];
+ rect = r;
+ clip = c;
+ type = t;
+ return self;
+}
+
+- (id)copyWithZone:(NSZone *)unusedZone
+{
+ UNUSED_PARAM(unusedZone);
+
+ return [self retain];
+}
+
+- (NSRect)dashboardRegionClip
+{
+ return clip;
+}
+
+- (NSRect)dashboardRegionRect
+{
+ return rect;
+}
+
+- (WebDashboardRegionType)dashboardRegionType
+{
+ return type;
+}
+
+static const char* typeName(WebDashboardRegionType type)
+{
+ switch (type) {
+ case WebDashboardRegionTypeNone:
+ return "None";
+ case WebDashboardRegionTypeCircle:
+ return "Circle";
+ case WebDashboardRegionTypeRectangle:
+ return "Rectangle";
+ case WebDashboardRegionTypeScrollerRectangle:
+ return "ScrollerRectangle";
+ }
+ return "Unknown";
+}
+
+- (NSString *)description
+{
+ return [NSString stringWithFormat:@"rect:%@ clip:%@ type:%s", NSStringFromRect(rect), NSStringFromRect(clip), typeName(type)];
+}
+
+// FIXME: Overriding isEqual: without overriding hash will cause trouble if this ever goes into a NSSet or is the key in an NSDictionary.
+- (BOOL)isEqual:(id)other
+{
+ return NSEqualRects(rect, [other dashboardRegionRect]) && NSEqualRects(clip, [other dashboardRegionClip]) && type == [other dashboardRegionType];
+}
+
+@end
+
+#endif
diff --git a/WebKit/mac/WebView/WebFrame.mm b/WebKit/mac/WebView/WebFrame.mm
index 8d564a3..02696f4 100644
--- a/WebKit/mac/WebView/WebFrame.mm
+++ b/WebKit/mac/WebView/WebFrame.mm
@@ -487,21 +487,6 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
return dataSource(_private->coreFrame->loader()->documentLoader());
}
-- (void)_addData:(NSData *)data
-{
- Document* document = _private->coreFrame->document();
-
- // Document may be nil if the part is about to redirect
- // as a result of JS executing during load, i.e. one frame
- // changing another's location before the frame's document
- // has been created.
- if (!document)
- return;
-
- document->setShouldCreateRenderers(_private->shouldCreateRenderers);
- _private->coreFrame->loader()->addData((const char *)[data bytes], [data length]);
-}
-
- (NSString *)_stringWithDocumentTypeStringAndMarkupString:(NSString *)markupString
{
return _private->coreFrame->documentTypeString() + markupString;
@@ -715,7 +700,7 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
- (TextGranularity)_selectionGranularity
{
- return _private->coreFrame->selectionGranularity();
+ return _private->coreFrame->selection()->granularity();
}
- (NSRange)_convertToNSRange:(Range *)range
@@ -859,7 +844,7 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
return;
TypingCommand::insertParagraphSeparatorInQuotedContent(_private->coreFrame->document());
- _private->coreFrame->revealSelection(ScrollAlignment::alignToEdgeIfNeeded);
+ _private->coreFrame->selection()->revealSelection(ScrollAlignment::alignToEdgeIfNeeded);
}
- (VisiblePosition)_visiblePositionForPoint:(NSPoint)point
@@ -895,9 +880,9 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
- (DOMCSSStyleDeclaration *)_typingStyle
{
- if (!_private->coreFrame || !_private->coreFrame->typingStyle())
+ if (!_private->coreFrame || !_private->coreFrame->selection()->typingStyle())
return nil;
- return kit(_private->coreFrame->typingStyle()->copy().get());
+ return kit(_private->coreFrame->selection()->typingStyle()->copy().get());
}
- (void)_setTypingStyle:(DOMCSSStyleDeclaration *)style withUndoAction:(EditAction)undoAction
@@ -942,15 +927,13 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
return [self _canProvideDocumentSource];
}
-- (void)_receivedData:(NSData *)data textEncodingName:(NSString *)textEncodingName
+- (void)_commitData:(NSData *)data
{
- // Set the encoding. This only needs to be done once, but it's harmless to do it again later.
- String encoding = _private->coreFrame->loader()->documentLoader()->overrideEncoding();
- bool userChosen = !encoding.isNull();
- if (encoding.isNull())
- encoding = textEncodingName;
- _private->coreFrame->loader()->writer()->setEncoding(encoding, userChosen);
- [self _addData:data];
+ // FIXME: This really should be a setting.
+ Document* document = _private->coreFrame->document();
+ document->setShouldCreateRenderers(_private->shouldCreateRenderers);
+
+ _private->coreFrame->loader()->documentLoader()->commitData((const char *)[data bytes], [data length]);
}
@end
@@ -1167,7 +1150,7 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
return;
applyCommand(ReplaceSelectionCommand::create(_private->coreFrame->document(), core(fragment), selectReplacement, smartReplace, matchStyle));
- _private->coreFrame->revealSelection(ScrollAlignment::alignToEdgeIfNeeded);
+ _private->coreFrame->selection()->revealSelection(ScrollAlignment::alignToEdgeIfNeeded);
}
- (void)_replaceSelectionWithText:(NSString *)text selectReplacement:(BOOL)selectReplacement smartReplace:(BOOL)smartReplace
@@ -1282,7 +1265,7 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
{
if (!_private->coreFrame)
return YES;
- return SecurityOrigin::canDisplay(URL, String(), _private->coreFrame->document());
+ return _private->coreFrame->document()->securityOrigin()->canDisplay(URL);
}
- (NSString *)_stringByEvaluatingJavaScriptFromString:(NSString *)string withGlobalObject:(JSObjectRef)globalObjectRef inScriptWorld:(WebScriptWorld *)world
@@ -1366,38 +1349,12 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
return coreFrame->layerTreeAsText();
}
-static Node* spellingNode(Frame* coreFrame)
-{
- Node* focusedNode = coreFrame->selection()->start().node();
- if (!focusedNode || !focusedNode->renderer())
- return 0;
-
- for (const RenderObject* renderer = focusedNode->renderer(); renderer; renderer = renderer->childAt(0)) {
- if (renderer->isText())
- return renderer->node();
- }
- return 0;
-}
-
- (BOOL)hasSpellingMarker:(int)from length:(int)length
{
Frame* coreFrame = _private->coreFrame;
if (!coreFrame)
return NO;
-
- Node* node = spellingNode(coreFrame);
- if (!node)
- return NO;
-
- unsigned int startOffset = static_cast<unsigned int>(from);
- unsigned int endOffset = static_cast<unsigned int>(from + length);
- Vector<DocumentMarker> markers = coreFrame->document()->markers()->markersForNode(node);
- for (size_t i = 0; i < markers.size(); ++i) {
- DocumentMarker marker = markers[i];
- if (marker.startOffset <= startOffset && endOffset <= marker.endOffset && marker.type == DocumentMarker::Spelling)
- return YES;
- }
- return NO;
+ return coreFrame->editor()->selectionStartHasSpellingMarkerFor(from, length);
}
@end
diff --git a/WebKit/mac/WebView/WebFrameInternal.h b/WebKit/mac/WebView/WebFrameInternal.h
index dc3de21..8cdc272 100644
--- a/WebKit/mac/WebView/WebFrameInternal.h
+++ b/WebKit/mac/WebView/WebFrameInternal.h
@@ -162,7 +162,7 @@ WebView *getWebView(WebFrame *webFrame);
- (BOOL)_canProvideDocumentSource;
- (BOOL)_canSaveAsWebArchive;
-- (void)_receivedData:(NSData *)data textEncodingName:(NSString *)textEncodingName;
+- (void)_commitData:(NSData *)data;
@end
diff --git a/WebKit/mac/WebView/WebHTMLRepresentation.mm b/WebKit/mac/WebView/WebHTMLRepresentation.mm
index 188747d..2699472 100644
--- a/WebKit/mac/WebView/WebHTMLRepresentation.mm
+++ b/WebKit/mac/WebView/WebHTMLRepresentation.mm
@@ -166,23 +166,24 @@ static NSArray *concatenateArrays(NSArray *first, NSArray *second)
- (void)receivedData:(NSData *)data withDataSource:(WebDataSource *)dataSource
{
WebFrame *webFrame = [dataSource webFrame];
- if (webFrame) {
- if (!_private->pluginView)
- [webFrame _receivedData:data textEncodingName:[[_private->dataSource response] textEncodingName]];
-
- // If the document is a stand-alone media document, now is the right time to cancel the WebKit load
- Frame* coreFrame = core(webFrame);
- if (coreFrame->document() && coreFrame->document()->isMediaDocument())
- coreFrame->loader()->documentLoader()->cancelMainResourceLoad(coreFrame->loader()->client()->pluginWillHandleLoadError(coreFrame->loader()->documentLoader()->response()));
-
- if (_private->pluginView) {
- if (!_private->hasSentResponseToPlugin) {
- [_private->manualLoader pluginView:_private->pluginView receivedResponse:[dataSource response]];
- _private->hasSentResponseToPlugin = YES;
- }
-
- [_private->manualLoader pluginView:_private->pluginView receivedData:data];
+ if (!webFrame)
+ return;
+
+ if (!_private->pluginView)
+ [webFrame _commitData:data];
+
+ // If the document is a stand-alone media document, now is the right time to cancel the WebKit load
+ Frame* coreFrame = core(webFrame);
+ if (coreFrame->document()->isMediaDocument())
+ coreFrame->loader()->documentLoader()->cancelMainResourceLoad(coreFrame->loader()->client()->pluginWillHandleLoadError(coreFrame->loader()->documentLoader()->response()));
+
+ if (_private->pluginView) {
+ if (!_private->hasSentResponseToPlugin) {
+ [_private->manualLoader pluginView:_private->pluginView receivedResponse:[dataSource response]];
+ _private->hasSentResponseToPlugin = YES;
}
+
+ [_private->manualLoader pluginView:_private->pluginView receivedData:data];
}
}
@@ -195,25 +196,26 @@ static NSArray *concatenateArrays(NSArray *first, NSArray *second)
- (void)finishedLoadingWithDataSource:(WebDataSource *)dataSource
{
- WebFrame *frame = [dataSource webFrame];
+ WebFrame* webFrame = [dataSource webFrame];
if (_private->pluginView) {
[_private->manualLoader pluginViewFinishedLoading:_private->pluginView];
return;
}
- if (frame) {
- if (![self _isDisplayingWebArchive]) {
- // Telling the frame we received some data and passing nil as the data is our
- // way to get work done that is normally done when the first bit of data is
- // received, even for the case of a document with no data (like about:blank).
- [frame _receivedData:nil textEncodingName:[[_private->dataSource response] textEncodingName]];
- }
-
- WebView *webView = [frame webView];
- if ([webView isEditable])
- core(frame)->editor()->applyEditingStyleToBodyElement();
+ if (!webFrame)
+ return;
+
+ if (![self _isDisplayingWebArchive]) {
+ // Telling the frame we received some data and passing nil as the data is our
+ // way to get work done that is normally done when the first bit of data is
+ // received, even for the case of a document with no data (like about:blank).
+ [webFrame _commitData:nil];
}
+
+ WebView *webView = [webFrame webView];
+ if ([webView isEditable])
+ core(webFrame)->editor()->applyEditingStyleToBodyElement();
}
- (BOOL)canProvideDocumentSource
@@ -304,15 +306,14 @@ static HTMLInputElement* inputElementFromDOMElement(DOMElement* element)
HTMLInputElement* inputElement = inputElementFromDOMElement(element);
return inputElement
&& inputElement->isTextField()
- && inputElement->inputType() != HTMLInputElement::PASSWORD
+ && !inputElement->isPasswordField()
&& inputElement->autoComplete();
}
- (BOOL)elementIsPassword:(DOMElement *)element
{
HTMLInputElement* inputElement = inputElementFromDOMElement(element);
- return inputElement
- && inputElement->inputType() == HTMLInputElement::PASSWORD;
+ return inputElement && inputElement->isPasswordField();
}
- (DOMElement *)formForElement:(DOMElement *)element
@@ -323,7 +324,7 @@ static HTMLInputElement* inputElementFromDOMElement(DOMElement* element)
- (DOMElement *)currentForm
{
- return kit(core([_private->dataSource webFrame])->currentForm());
+ return kit(core([_private->dataSource webFrame])->selection()->currentForm());
}
- (NSArray *)controlsInForm:(DOMElement *)form
diff --git a/WebKit/mac/WebView/WebHTMLView.mm b/WebKit/mac/WebView/WebHTMLView.mm
index bd71eff..02d32d9 100644
--- a/WebKit/mac/WebView/WebHTMLView.mm
+++ b/WebKit/mac/WebView/WebHTMLView.mm
@@ -1914,12 +1914,11 @@ static void _updateMouseoverTimerCallback(CFRunLoopTimerRef timer, void *info)
- (NSImage *)_selectionDraggingImage
{
- if ([self _hasSelection]) {
- NSImage *dragImage = core([self _frame])->selectionImage();
- [dragImage _web_dissolveToFraction:WebDragImageAlpha];
- return dragImage;
- }
- return nil;
+ if (![self _hasSelection])
+ return nil;
+ NSImage *dragImage = core([self _frame])->selectionImage();
+ [dragImage _web_dissolveToFraction:WebDragImageAlpha];
+ return dragImage;
}
- (NSRect)_selectionDraggingRect
@@ -2303,7 +2302,7 @@ static void _updateMouseoverTimerCallback(CFRunLoopTimerRef timer, void *info)
return bottom;
float newBottom;
- view->adjustPageHeight(&newBottom, top, bottom, bottomLimit);
+ view->adjustPageHeightDeprecated(&newBottom, top, bottom, bottomLimit);
#ifdef __LP64__
// If the new bottom is equal to the old bottom (when both are treated as floats), we just return the original
@@ -2378,10 +2377,6 @@ static bool matchesExtensionOrEquivalent(NSString *filename, NSString *extension
#endif
-@interface NSArray (WebHTMLView)
-- (void)_web_makePluginViewsPerformSelector:(SEL)selector withObject:(id)object;
-@end
-
@implementation WebHTMLView
+ (void)initialize
@@ -2529,6 +2524,7 @@ WEBCORE_COMMAND(alignLeft)
WEBCORE_COMMAND(alignRight)
WEBCORE_COMMAND(copy)
WEBCORE_COMMAND(cut)
+WEBCORE_COMMAND(paste)
WEBCORE_COMMAND(delete)
WEBCORE_COMMAND(deleteBackward)
WEBCORE_COMMAND(deleteBackwardByDecomposingPreviousCharacter)
@@ -2664,7 +2660,7 @@ WEBCORE_COMMAND(yankAndSelect)
COMMAND_PROLOGUE
if (Frame* coreFrame = core([self _frame]))
- coreFrame->revealSelection(ScrollAlignment::alignCenterAlways);
+ coreFrame->selection()->revealSelection(ScrollAlignment::alignCenterAlways);
}
- (NSCellStateValue)selectionHasStyle:(CSSStyleDeclaration*)style
@@ -3080,14 +3076,31 @@ WEBCORE_COMMAND(yankAndSelect)
}
}
+- (void)_web_makePluginSubviewsPerformSelector:(SEL)selector withObject:(id)object
+{
+#if ENABLE(NETSCAPE_PLUGIN_API)
+ // Copy subviews because [self subviews] returns the view's mutable internal array,
+ // and we must avoid mutating the array while enumerating it.
+ NSArray *subviews = [[self subviews] copy];
+
+ NSEnumerator *enumerator = [subviews objectEnumerator];
+ WebNetscapePluginView *view;
+ while ((view = [enumerator nextObject]) != nil)
+ if ([view isKindOfClass:[WebBaseNetscapePluginView class]])
+ [view performSelector:selector withObject:object];
+
+ [subviews release];
+#endif
+}
+
- (void)viewWillMoveToHostWindow:(NSWindow *)hostWindow
{
- [[self subviews] _web_makePluginViewsPerformSelector:@selector(viewWillMoveToHostWindow:) withObject:hostWindow];
+ [self _web_makePluginSubviewsPerformSelector:@selector(viewWillMoveToHostWindow:) withObject:hostWindow];
}
- (void)viewDidMoveToHostWindow
{
- [[self subviews] _web_makePluginViewsPerformSelector:@selector(viewDidMoveToHostWindow) withObject:nil];
+ [self _web_makePluginSubviewsPerformSelector:@selector(viewDidMoveToHostWindow) withObject:nil];
}
@@ -4197,7 +4210,7 @@ static BOOL isInPasswordField(Frame* coreFrame)
COMMAND_PROLOGUE
if (Frame* coreFrame = core([self _frame]))
- coreFrame->revealSelection(ScrollAlignment::alignCenterAlways);
+ coreFrame->selection()->revealSelection(ScrollAlignment::alignCenterAlways);
}
- (NSData *)_selectionStartFontAttributesAsRTF
@@ -5082,21 +5095,6 @@ static BOOL writingDirectionKeyBindingsEnabled()
@end
-@implementation NSArray (WebHTMLView)
-
-- (void)_web_makePluginViewsPerformSelector:(SEL)selector withObject:(id)object
-{
-#if ENABLE(NETSCAPE_PLUGIN_API)
- NSEnumerator *enumerator = [self objectEnumerator];
- WebNetscapePluginView *view;
- while ((view = [enumerator nextObject]) != nil)
- if ([view isKindOfClass:[WebBaseNetscapePluginView class]])
- [view performSelector:selector withObject:object];
-#endif
-}
-
-@end
-
@implementation WebHTMLView (WebInternal)
- (void)_selectionChanged
@@ -5145,7 +5143,7 @@ static BOOL writingDirectionKeyBindingsEnabled()
if (![[self _webView] smartInsertDeleteEnabled])
return NO;
Frame* coreFrame = core([self _frame]);
- return coreFrame && coreFrame->selectionGranularity() == WordGranularity;
+ return coreFrame && coreFrame->selection()->granularity() == WordGranularity;
}
- (NSEvent *)_mouseDownEvent
@@ -5163,24 +5161,6 @@ static BOOL writingDirectionKeyBindingsEnabled()
return [_private->dataSource webFrame];
}
-- (void)paste:(id)sender
-{
- COMMAND_PROLOGUE
-
- RetainPtr<WebHTMLView> selfProtector = self;
- RefPtr<Frame> coreFrame = core([self _frame]);
- if (!coreFrame)
- return;
- if (coreFrame->editor()->tryDHTMLPaste())
- return; // DHTML did the whole operation
- if (!coreFrame->editor()->canPaste())
- return;
- if (coreFrame->selection()->isContentRichlyEditable())
- [self _pasteWithPasteboard:[NSPasteboard generalPasteboard] allowPlainText:YES];
- else
- coreFrame->editor()->pasteAsPlainTextBypassingDHTML();
-}
-
- (void)closeIfNotCurrentView
{
if ([[[self _frame] frameView] documentView] != self)
@@ -5360,7 +5340,7 @@ static CGPoint coreGraphicsScreenPointForAppKitScreenPoint(NSPoint point)
if (!coreFrame)
return;
- NSRect rect = coreFrame->selectionBounds();
+ NSRect rect = coreFrame->selection()->bounds();
#ifndef BUILDING_ON_TIGER
NSDictionary *attributes = [attrString fontAttributesInRange:NSMakeRange(0,1)];
@@ -5582,7 +5562,11 @@ static CGPoint coreGraphicsScreenPointForAppKitScreenPoint(NSPoint point)
[[NSNotificationCenter defaultCenter] postNotificationName:_WebViewDidStartAcceleratedCompositingNotification object:[self _webView] userInfo:nil];
#if defined(BUILDING_ON_LEOPARD)
+ [viewLayer setSublayerTransform:CATransform3DMakeScale(1, -1, 1)]; // setGeometryFlipped: doesn't exist on Leopard.
[self _updateLayerHostingViewPosition];
+#else
+ // Do geometry flipping here, which flips all the compositing layers so they are top-down.
+ [viewLayer setGeometryFlipped:YES];
#endif
}
@@ -6037,25 +6021,27 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde
- (NSRect)selectionRect
{
- if ([self _hasSelection])
- return core([self _frame])->selectionBounds();
- return NSZeroRect;
+ if (![self _hasSelection])
+ return NSZeroRect;
+ return core([self _frame])->selection()->bounds();
}
- (NSArray *)selectionTextRects
{
if (![self _hasSelection])
return nil;
-
+
Vector<FloatRect> list;
if (Frame* coreFrame = core([self _frame]))
- coreFrame->selectionTextRects(list, Frame::RespectTransforms);
+ coreFrame->selection()->getClippedVisibleTextRectangles(list);
+
+ size_t size = list.size();
+
+ NSMutableArray *result = [NSMutableArray arrayWithCapacity:size];
- unsigned size = list.size();
- NSMutableArray *result = [[[NSMutableArray alloc] initWithCapacity:size] autorelease];
- for (unsigned i = 0; i < size; ++i)
+ for (size_t i = 0; i < size; ++i)
[result addObject:[NSValue valueWithRect:list[i]]];
-
+
return result;
}
@@ -6066,16 +6052,16 @@ static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnde
- (NSImage *)selectionImageForcingBlackText:(BOOL)forceBlackText
{
- if ([self _hasSelection])
- return core([self _frame])->selectionImage(forceBlackText);
- return nil;
+ if (![self _hasSelection])
+ return nil;
+ return core([self _frame])->selectionImage(forceBlackText);
}
- (NSRect)selectionImageRect
{
- if ([self _hasSelection])
- return core([self _frame])->selectionBounds();
- return NSZeroRect;
+ if (![self _hasSelection])
+ return NSZeroRect;
+ return core([self _frame])->selection()->bounds();
}
- (NSArray *)pasteboardTypesForSelection
diff --git a/WebKit/mac/WebView/WebPreferenceKeysPrivate.h b/WebKit/mac/WebView/WebPreferenceKeysPrivate.h
index 3b750ff..17c8e4d 100644
--- a/WebKit/mac/WebView/WebPreferenceKeysPrivate.h
+++ b/WebKit/mac/WebView/WebPreferenceKeysPrivate.h
@@ -92,6 +92,7 @@
#define WebKitShowDebugBordersPreferenceKey @"WebKitShowDebugBorders"
#define WebKitShowRepaintCounterPreferenceKey @"WebKitShowRepaintCounter"
#define WebKitWebGLEnabledPreferenceKey @"WebKitWebGLEnabled"
+#define WebKitAccelerated2dCanvasEnabledPreferenceKey @"WebKitAccelerated2dCanvasEnabled"
#define WebKitUsesProxiedOpenPanelPreferenceKey @"WebKitUsesProxiedOpenPanel"
#define WebKitPluginAllowedRunTimePreferenceKey @"WebKitPluginAllowedRunTime"
#define WebKitFrameFlatteningEnabledPreferenceKey @"WebKitFrameFlatteningEnabled"
@@ -111,6 +112,7 @@
#define WebKitCacheModelPreferenceKey @"WebKitCacheModelPreferenceKey"
#define WebKitTextDirectionSubmenuInclusionBehaviorPreferenceKey @"WebKitTextDirectionSubmenuInclusionBehaviorPreferenceKey"
#define WebKitEditingBehaviorPreferenceKey @"WebKitEditingBehavior"
+#define WebKitUsePreHTML5ParserQuirksKey @"WebKitUsePreHTML5ParserQuirks"
// CoreGraphics deferred updates are disabled if WebKitEnableCoalescedUpdatesPreferenceKey is set
// to NO, or has no value. For compatibility with Mac OS X 10.4.6, deferred updates are OFF by
diff --git a/WebKit/mac/WebView/WebPreferences.mm b/WebKit/mac/WebView/WebPreferences.mm
index a4a5383..87284bb 100644
--- a/WebKit/mac/WebView/WebPreferences.mm
+++ b/WebKit/mac/WebView/WebPreferences.mm
@@ -361,12 +361,14 @@ static WebCacheModel cacheModelForMainBundle(void)
[NSNumber numberWithBool:NO], WebKitShowDebugBordersPreferenceKey,
[NSNumber numberWithBool:NO], WebKitShowRepaintCounterPreferenceKey,
[NSNumber numberWithBool:NO], WebKitWebGLEnabledPreferenceKey,
+ [NSNumber numberWithBool:NO], WebKitAccelerated2dCanvasEnabledPreferenceKey,
[NSNumber numberWithBool:NO], WebKitUsesProxiedOpenPanelPreferenceKey,
[NSNumber numberWithUnsignedInt:4], WebKitPluginAllowedRunTimePreferenceKey,
[NSNumber numberWithBool:NO], WebKitFrameFlatteningEnabledPreferenceKey,
[NSNumber numberWithBool:YES], WebKitDNSPrefetchingEnabledPreferenceKey,
[NSNumber numberWithBool:NO], WebKitFullScreenEnabledPreferenceKey,
[NSNumber numberWithBool:NO], WebKitMemoryInfoEnabledPreferenceKey,
+ [NSNumber numberWithBool:NO], WebKitUsePreHTML5ParserQuirksKey,
[NSNumber numberWithLongLong:WebCore::ApplicationCacheStorage::noQuota()], WebKitApplicationCacheTotalQuota,
[NSNumber numberWithLongLong:WebCore::ApplicationCacheStorage::noQuota()], WebKitApplicationCacheDefaultOriginQuota,
nil];
@@ -641,7 +643,10 @@ static WebCacheModel cacheModelForMainBundle(void)
} else {
locationString = [URL _web_originalDataAsString];
}
-
+
+ if (!locationString)
+ locationString = @"";
+
[self _setStringValue:locationString forKey: WebKitUserStyleSheetLocationPreferenceKey];
}
@@ -1267,6 +1272,16 @@ static NSString *classIBCreatorID = nil;
[self _setBoolValue:enabled forKey:WebKitWebGLEnabledPreferenceKey];
}
+- (BOOL)accelerated2dCanvasEnabled
+{
+ return [self _boolValueForKey:WebKitAccelerated2dCanvasEnabledPreferenceKey];
+}
+
+- (void)setAccelerated2dCanvasEnabled:(BOOL)enabled
+{
+ [self _setBoolValue:enabled forKey:WebKitAccelerated2dCanvasEnabledPreferenceKey];
+}
+
- (BOOL)usesProxiedOpenPanel
{
return [self _boolValueForKey:WebKitUsesProxiedOpenPanelPreferenceKey];
@@ -1327,6 +1342,16 @@ static NSString *classIBCreatorID = nil;
[self _setIntegerValue:behavior forKey:WebKitEditingBehaviorPreferenceKey];
}
+- (BOOL)usePreHTML5ParserQuirks
+{
+ return [self _boolValueForKey:WebKitUsePreHTML5ParserQuirksKey];
+}
+
+- (void)setUsePreHTML5ParserQuirks:(BOOL)flag
+{
+ [self _setBoolValue:flag forKey:WebKitUsePreHTML5ParserQuirksKey];
+}
+
- (void)didRemoveFromWebView
{
ASSERT(_private->numWebViews);
@@ -1357,6 +1382,11 @@ static NSString *classIBCreatorID = nil;
return [self _boolValueForKey:WebKitFullScreenEnabledPreferenceKey];
}
++ (void)setWebKitLinkTimeVersion:(int)version
+{
+ setWebKitLinkTimeVersion(version);
+}
+
@end
@implementation WebPreferences (WebInternal)
diff --git a/WebKit/mac/WebView/WebPreferencesPrivate.h b/WebKit/mac/WebView/WebPreferencesPrivate.h
index 783038d..3bd5e24 100644
--- a/WebKit/mac/WebView/WebPreferencesPrivate.h
+++ b/WebKit/mac/WebView/WebPreferencesPrivate.h
@@ -184,6 +184,9 @@ extern NSString *WebPreferencesRemovedNotification;
- (BOOL)webGLEnabled;
- (void)setWebGLEnabled:(BOOL)enabled;
+- (BOOL)accelerated2dCanvasEnabled;
+- (void)setAccelerated2dCanvasEnabled:(BOOL)enabled;
+
- (BOOL)paginateDuringLayoutEnabled;
- (void)setPaginateDuringLayoutEnabled:(BOOL)flag;
@@ -203,6 +206,8 @@ extern NSString *WebPreferencesRemovedNotification;
+ (void)_setInitialDefaultTextEncodingToSystemEncoding;
+ (void)_setIBCreatorID:(NSString *)string;
++ (void)setWebKitLinkTimeVersion:(int)version;
+
// For WebView's use only.
- (void)willAddToWebView;
- (void)didRemoveFromWebView;
@@ -212,4 +217,7 @@ extern NSString *WebPreferencesRemovedNotification;
- (void)setFullScreenEnabled:(BOOL)flag;
- (BOOL)fullScreenEnabled;
+- (void)setUsePreHTML5ParserQuirks:(BOOL)flag;
+- (BOOL)usePreHTML5ParserQuirks;
+
@end
diff --git a/WebKit/mac/WebView/WebView.mm b/WebKit/mac/WebView/WebView.mm
index 0125e1c..20f6e24 100644
--- a/WebKit/mac/WebView/WebView.mm
+++ b/WebKit/mac/WebView/WebView.mm
@@ -174,6 +174,10 @@
#import <wtf/StdLibExtras.h>
#import <wtf/Threading.h>
+#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
+#import <AppKit/NSTextChecker.h>
+#endif
+
#if ENABLE(DASHBOARD_SUPPORT)
#import <WebKit/WebDashboardRegion.h>
#endif
@@ -692,6 +696,7 @@ static bool shouldEnableLoadDeferring()
_private->page->setCanStartMedia([self window]);
_private->page->settings()->setLocalStorageDatabasePath([[self preferences] _localStorageDatabasePath]);
+ _private->page->settings()->setMinDOMTimerInterval(0.004);
[WebFrame _createMainFrameWithPage:_private->page frameName:frameName frameView:frameView];
@@ -1427,7 +1432,6 @@ static bool fastDocumentTeardownEnabled()
settings->setWebArchiveDebugModeEnabled([preferences webArchiveDebugModeEnabled]);
settings->setLocalFileContentSniffingEnabled([preferences localFileContentSniffingEnabled]);
settings->setOfflineWebApplicationCacheEnabled([preferences offlineWebApplicationCacheEnabled]);
- settings->setZoomMode([preferences zoomsTextOnly] ? ZoomTextOnly : ZoomPage);
settings->setJavaScriptCanAccessClipboard([preferences javaScriptCanAccessClipboard]);
settings->setXSSAuditorEnabled([preferences isXSSAuditorEnabled]);
settings->setEnforceCSSMIMETypeInNoQuirksMode(!WKAppVersionCheckLessThan(@"com.apple.iWeb", -1, 2.1));
@@ -1435,11 +1439,13 @@ static bool fastDocumentTeardownEnabled()
// FIXME: Enabling accelerated compositing when WebGL is enabled causes tests to fail on Leopard which expect HW compositing to be disabled.
// Until we fix that, I will comment out the test (CFM)
- settings->setAcceleratedCompositingEnabled((coreVideoHas7228836Fix() || [preferences webGLEnabled]) && [preferences acceleratedCompositingEnabled]);
+ settings->setAcceleratedCompositingEnabled((coreVideoHas7228836Fix() || [preferences webGLEnabled] ||
+ [preferences accelerated2dCanvasEnabled]) && [preferences acceleratedCompositingEnabled]);
settings->setShowDebugBorders([preferences showDebugBorders]);
settings->setShowRepaintCounter([preferences showRepaintCounter]);
settings->setPluginAllowedRunTime([preferences pluginAllowedRunTime]);
settings->setWebGLEnabled([preferences webGLEnabled]);
+ settings->setAccelerated2dCanvasEnabled([preferences accelerated2dCanvasEnabled]);
settings->setLoadDeferringEnabled(shouldEnableLoadDeferring());
settings->setFrameFlatteningEnabled([preferences isFrameFlatteningEnabled]);
settings->setPaginateDuringLayoutEnabled([preferences paginateDuringLayoutEnabled]);
@@ -1447,9 +1453,14 @@ static bool fastDocumentTeardownEnabled()
settings->setFullScreenEnabled([preferences fullScreenEnabled]);
#endif
settings->setMemoryInfoEnabled([preferences memoryInfoEnabled]);
+ settings->setUsePreHTML5ParserQuirks([preferences usePreHTML5ParserQuirks]);
// Application Cache Preferences are stored on the global cache storage manager, not in Settings.
[WebApplicationCache setDefaultOriginQuota:[preferences applicationCacheDefaultOriginQuota]];
+
+ BOOL zoomsTextOnly = [preferences zoomsTextOnly];
+ if (_private->zoomsTextOnly != zoomsTextOnly)
+ [self _setZoomMultiplier:_private->zoomMultiplier isTextOnly:zoomsTextOnly];
}
static inline IMP getMethod(id o, SEL s)
@@ -1908,9 +1919,38 @@ static inline IMP getMethod(id o, SEL s)
Frame* mainFrame = [self _mainCoreFrame];
if (!mainFrame)
return nil;
- NSMutableDictionary *regions = mainFrame->dashboardRegionsDictionary();
- [self _addScrollerDashboardRegions:regions];
- return regions;
+
+ const Vector<DashboardRegionValue>& regions = mainFrame->document()->dashboardRegions();
+ size_t size = regions.size();
+
+ NSMutableDictionary *webRegions = [NSMutableDictionary dictionaryWithCapacity:size];
+ for (size_t i = 0; i < size; i++) {
+ const DashboardRegionValue& region = regions[i];
+
+ if (region.type == StyleDashboardRegion::None)
+ continue;
+
+ NSString *label = region.label;
+ WebDashboardRegionType type = WebDashboardRegionTypeNone;
+ if (region.type == StyleDashboardRegion::Circle)
+ type = WebDashboardRegionTypeCircle;
+ else if (region.type == StyleDashboardRegion::Rectangle)
+ type = WebDashboardRegionTypeRectangle;
+ NSMutableArray *regionValues = [webRegions objectForKey:label];
+ if (!regionValues) {
+ regionValues = [[NSMutableArray alloc] initWithCapacity:1];
+ [webRegions setObject:regionValues forKey:label];
+ [regionValues release];
+ }
+
+ WebDashboardRegion *webRegion = [[WebDashboardRegion alloc] initWithRect:region.bounds clip:region.clip type:type];
+ [regionValues addObject:webRegion];
+ [webRegion release];
+ }
+
+ [self _addScrollerDashboardRegions:webRegions];
+
+ return webRegions;
}
- (void)_setDashboardBehavior:(WebDashboardBehavior)behavior to:(BOOL)flag
@@ -2604,6 +2644,13 @@ static PassOwnPtr<Vector<String> > toStringVector(NSArray* patterns)
automaticTextReplacementEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:WebAutomaticTextReplacementEnabled];
automaticSpellingCorrectionEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:WebAutomaticSpellingCorrectionEnabled];
#endif
+
+#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
+ if (![[NSUserDefaults standardUserDefaults] objectForKey:WebAutomaticTextReplacementEnabled])
+ automaticTextReplacementEnabled = [NSSpellChecker isAutomaticTextReplacementEnabled];
+ if (![[NSUserDefaults standardUserDefaults] objectForKey:WebAutomaticSpellingCorrectionEnabled])
+ automaticTextReplacementEnabled = [NSSpellChecker isAutomaticSpellingCorrectionEnabled];
+#endif
}
+ (void)_applicationWillTerminate
@@ -3272,17 +3319,16 @@ static bool needsWebViewInitThreadWorkaround()
{
// NOTE: This has no visible effect when viewing a PDF (see <rdar://problem/4737380>)
_private->zoomMultiplier = multiplier;
+ _private->zoomsTextOnly = isTextOnly;
- ASSERT(_private->page);
- if (_private->page)
- _private->page->settings()->setZoomMode(isTextOnly ? ZoomTextOnly : ZoomPage);
-
- // FIXME: It would be nice to rework this code so that _private->zoomMultiplier doesn't exist
- // and instead FrameView::zoomFactor is used.
+ // FIXME: It might be nice to rework this code so that _private->zoomMultiplier doesn't exist
+ // and instead the zoom factors stored in Frame are used.
Frame* coreFrame = [self _mainCoreFrame];
if (coreFrame) {
- if (FrameView* view = coreFrame->view())
- view->setZoomFactor(multiplier, isTextOnly ? ZoomTextOnly : ZoomPage);
+ if (_private->zoomsTextOnly)
+ coreFrame->setPageAndTextZoomFactors(1, multiplier);
+ else
+ coreFrame->setPageAndTextZoomFactors(multiplier, 1);
}
}
@@ -3303,7 +3349,7 @@ static bool needsWebViewInitThreadWorkaround()
if (!_private->page)
return NO;
- return _private->page->settings()->zoomMode() == ZoomTextOnly;
+ return _private->zoomsTextOnly;
}
#define MinimumZoomMultiplier 0.5f
@@ -4366,6 +4412,9 @@ static NSAppleEventDescriptor* aeDescFromJSValue(ExecState* exec, JSValue jsValu
- (BOOL)canMarkAllTextMatches
{
+ if (_private->closed)
+ return NO;
+
WebFrame *frame = [self mainFrame];
do {
id <WebDocumentView> view = [[frame frameView] documentView];
@@ -4769,7 +4818,7 @@ static NSAppleEventDescriptor* aeDescFromJSValue(ExecState* exec, JSValue jsValu
mainFrame->editor()->applyEditingStyleToBodyElement();
// If the WebView is made editable and the selection is empty, set it to something.
if (![self selectedDOMRange])
- mainFrame->setSelectionFromNone();
+ mainFrame->selection()->setSelectionFromNone();
}
}
}
diff --git a/WebKit/mac/WebView/WebViewData.h b/WebKit/mac/WebView/WebViewData.h
index 558770e..9aa91dc 100644
--- a/WebKit/mac/WebView/WebViewData.h
+++ b/WebKit/mac/WebView/WebViewData.h
@@ -78,6 +78,7 @@ extern int pluginDatabaseClientCount;
BOOL allowsUndo;
float zoomMultiplier;
+ BOOL zoomsTextOnly;
NSString *applicationNameForUserAgent;
WTF::String userAgent;
diff --git a/WebKit/mac/WebView/WebViewData.mm b/WebKit/mac/WebView/WebViewData.mm
index 06da58f..9794d03 100644
--- a/WebKit/mac/WebView/WebViewData.mm
+++ b/WebKit/mac/WebView/WebViewData.mm
@@ -62,6 +62,7 @@ int pluginDatabaseClientCount = 0;
cssAnimationsSuspended = NO;
zoomMultiplier = 1;
+ zoomsTextOnly = NO;
#if ENABLE(DASHBOARD_SUPPORT)
dashboardBehaviorAllowWheelScrolling = YES;