[webkit-changes] cvs commit: WebKit/WebView.subproj WebFrame.m
WebFrameInternal.h WebHTMLView.m WebPDFView.m WebTextView.m
WebView.m WebViewInternal.h
Maciej
mjs at opensource.apple.com
Fri Dec 23 16:54:13 PST 2005
mjs 05/12/23 16:54:13
Modified: . ChangeLog
WebView.subproj WebFrame.m WebFrameInternal.h WebHTMLView.m
WebPDFView.m WebTextView.m WebView.m
WebViewInternal.h
Log:
Reviewed by John.
- move more frame tree traversal code from WebView to WebFrame
* WebView.subproj/WebFrame.m:
(-[WebFrame _atMostOneFrameHasSelection]): Moved this debug
method from WebView, renamed it and changed it to return a boolean
so it is appropriate for use in assertions instead of giving its own
errors.
(-[WebFrame _accumulateFramesWithSelection:]): Helper for the above.
(-[WebFrame _findFrameWithSelection]): Moved from WebView and renamed from
_findSelectedFrame, also removed the skipping variant.
(-[WebFrame _clearSelectionInOtherFrames]): Moved from WebView and
changed how the logic works. Instead of clearing selection in any frame
but the focus frame, it clears selection in all but this one.
* WebView.subproj/WebFrameInternal.h:
* WebView.subproj/WebHTMLView.m:
(-[WebHTMLView becomeFirstResponder]): Call _clearSelectionInOtherFrames
* WebView.subproj/WebPDFView.m:
(-[WebPDFView PDFViewWillClickOnLink:withURL:]): Stop getting WebFrame
in needlessly roundabout way.
(-[WebPDFView becomeFirstResponder]): Call _clearSelectionInOtherFrames
* WebView.subproj/WebTextView.m:
(-[WebTextView _webFrame]): New helper method.
(-[WebTextView _elementAtWindowPoint:]): Use it.
(-[WebTextView becomeFirstResponder]): Call _clearSelectionInOtherFrames
(-[WebTextView resignFirstResponder]): Fix style issue
(-[WebTextView clickedOnLink:atIndex:]): Use new helkper
* WebView.subproj/WebView.m:
(-[WebView selectedFrame]): Call to WebFrame as appropriate
(-[WebView _selectedOrMainFrame]): Fix style issue
* WebView.subproj/WebViewInternal.h:
Revision Changes Path
1.3426 +35 -0 WebKit/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebKit/ChangeLog,v
retrieving revision 1.3425
retrieving revision 1.3426
diff -u -r1.3425 -r1.3426
--- ChangeLog 23 Dec 2005 08:19:29 -0000 1.3425
+++ ChangeLog 24 Dec 2005 00:54:02 -0000 1.3426
@@ -1,3 +1,38 @@
+2005-12-23 Maciej Stachowiak <mjs at apple.com>
+
+ Reviewed by John.
+
+ - move more frame tree traversal code from WebView to WebFrame
+
+ * WebView.subproj/WebFrame.m:
+ (-[WebFrame _atMostOneFrameHasSelection]): Moved this debug
+ method from WebView, renamed it and changed it to return a boolean
+ so it is appropriate for use in assertions instead of giving its own
+ errors.
+ (-[WebFrame _accumulateFramesWithSelection:]): Helper for the above.
+ (-[WebFrame _findFrameWithSelection]): Moved from WebView and renamed from
+ _findSelectedFrame, also removed the skipping variant.
+ (-[WebFrame _clearSelectionInOtherFrames]): Moved from WebView and
+ changed how the logic works. Instead of clearing selection in any frame
+ but the focus frame, it clears selection in all but this one.
+ * WebView.subproj/WebFrameInternal.h:
+ * WebView.subproj/WebHTMLView.m:
+ (-[WebHTMLView becomeFirstResponder]): Call _clearSelectionInOtherFrames
+ * WebView.subproj/WebPDFView.m:
+ (-[WebPDFView PDFViewWillClickOnLink:withURL:]): Stop getting WebFrame
+ in needlessly roundabout way.
+ (-[WebPDFView becomeFirstResponder]): Call _clearSelectionInOtherFrames
+ * WebView.subproj/WebTextView.m:
+ (-[WebTextView _webFrame]): New helper method.
+ (-[WebTextView _elementAtWindowPoint:]): Use it.
+ (-[WebTextView becomeFirstResponder]): Call _clearSelectionInOtherFrames
+ (-[WebTextView resignFirstResponder]): Fix style issue
+ (-[WebTextView clickedOnLink:atIndex:]): Use new helkper
+ * WebView.subproj/WebView.m:
+ (-[WebView selectedFrame]): Call to WebFrame as appropriate
+ (-[WebView _selectedOrMainFrame]): Fix style issue
+ * WebView.subproj/WebViewInternal.h:
+
2005-12-22 Maciej Stachowiak <mjs at apple.com>
Reviewed by Eric.
1.262 +55 -0 WebKit/WebView.subproj/WebFrame.m
Index: WebFrame.m
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebFrame.m,v
retrieving revision 1.261
retrieving revision 1.262
diff -u -r1.261 -r1.262
--- WebFrame.m 23 Dec 2005 08:19:32 -0000 1.261
+++ WebFrame.m 24 Dec 2005 00:54:09 -0000 1.262
@@ -2834,6 +2834,61 @@
}
}
+#ifndef NDEBUG
+- (void)_accumulateFramesWithSelection:(NSMutableArray *)framesWithSelection
+{
+ if ([self _hasSelection])
+ [framesWithSelection addObject:self];
+
+ NSArray *frames = [self _internalChildFrames];
+ int i;
+ int count = [frames count];
+ for (i = 0; i < count; i++) {
+ [[frames objectAtIndex:i] _accumulateFramesWithSelection:framesWithSelection];
+ }
+}
+
+- (BOOL)_atMostOneFrameHasSelection;
+{
+ // FIXME: 4186050 is one known case that makes this debug check fail
+ NSMutableArray *framesWithSelection = [NSMutableArray array];
+ [self _accumulateFramesWithSelection:framesWithSelection];
+ return [framesWithSelection count] <= 1;
+}
+#endif
+
+- (WebFrame *)_findFrameWithSelection
+{
+ ASSERT([self _atMostOneFrameHasSelection]);
+
+ if ([self _hasSelection])
+ return self;
+
+ NSArray *frames = [self _internalChildFrames];
+ int i;
+ int count = [frames count];
+ for (i = 0; i < count; i++) {
+ WebFrame *frameWithSelection = [[frames objectAtIndex:i] _findFrameWithSelection];
+ if (frameWithSelection)
+ return frameWithSelection;
+ }
+
+ return nil;
+}
+
+- (void)_clearSelectionInOtherFrames
+{
+ // We rely on WebDocumentSelection protocol implementors to call this method when they become first
+ // responder. It would be nicer to just notice first responder changes here instead, but there's no
+ // notification sent when the first responder changes in general (Radar 2573089).
+ WebFrame *frameWithSelection = [[[self webView] mainFrame] _findFrameWithSelection];
+ if (frameWithSelection != self)
+ [frameWithSelection _clearSelection];
+
+ // While we're in the general area of selection and frames, check that there is only one now.
+ ASSERT([[[self webView] mainFrame] _atMostOneFrameHasSelection]);
+}
+
@end
@implementation WebFormState : NSObject
1.17 +2 -0 WebKit/WebView.subproj/WebFrameInternal.h
Index: WebFrameInternal.h
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebFrameInternal.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- WebFrameInternal.h 23 Dec 2005 08:19:32 -0000 1.16
+++ WebFrameInternal.h 24 Dec 2005 00:54:09 -0000 1.17
@@ -55,6 +55,8 @@
- (BOOL)_hasSelection;
- (void)_clearSelection;
+- (WebFrame *)_findFrameWithSelection;
+- (void)_clearSelectionInOtherFrames;
@end
1.495 +3 -3 WebKit/WebView.subproj/WebHTMLView.m
Index: WebHTMLView.m
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebHTMLView.m,v
retrieving revision 1.494
retrieving revision 1.495
diff -u -r1.494 -r1.495
--- WebHTMLView.m 21 Dec 2005 02:04:38 -0000 1.494
+++ WebHTMLView.m 24 Dec 2005 00:54:09 -0000 1.495
@@ -41,6 +41,7 @@
#import <WebKit/WebDOMOperationsPrivate.h>
#import <WebKit/WebEditingDelegate.h>
#import <WebKit/WebFramePrivate.h>
+#import <WebKit/WebFrameInternal.h>
#import <WebKit/WebFrameViewInternal.h>
#import <WebKit/WebHTMLViewInternal.h>
#import <WebKit/WebHTMLRepresentationPrivate.h>
@@ -2984,10 +2985,9 @@
break;
}
}
- if (view) {
+ if (view)
[[self window] makeFirstResponder:view];
- }
- [[self _webView] _selectedFrameDidChange];
+ [[[self _web_parentWebFrameView] webFrame] _clearSelectionInOtherFrames];
[self updateFocusState];
[self _updateFontPanel];
_private->startNewKillRingSequence = YES;
1.32 +2 -2 WebKit/WebView.subproj/WebPDFView.m
Index: WebPDFView.m
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebPDFView.m,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- WebPDFView.m 9 Dec 2005 02:12:34 -0000 1.31
+++ WebPDFView.m 24 Dec 2005 00:54:10 -0000 1.32
@@ -533,7 +533,7 @@
- (void)PDFViewWillClickOnLink:(PDFView *)sender withURL:(NSURL *)URL
{
if (URL != nil) {
- WebFrame *frame = [[self _web_parentWebFrameView] webFrame];
+ WebFrame *frame = [dataSource webFrame];
[frame _safeLoadURL:URL];
}
}
@@ -770,7 +770,7 @@
if (![window makeFirstResponder:newFirstResponder])
return NO;
- [[self _webView] _selectedFrameDidChange];
+ [[dataSource webFrame] _clearSelectionInOtherFrames];
// FIXME 4265966: We don't currently have a way to notice when the PDFView (or subview) loses focus,
// so sometimes a secondary selection is left behind in the PDFView when the primary selection moves elsewhere.
1.67 +11 -10 WebKit/WebView.subproj/WebTextView.m
Index: WebTextView.m
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebTextView.m,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -r1.66 -r1.67
--- WebTextView.m 12 Dec 2005 19:42:50 -0000 1.66
+++ WebTextView.m 24 Dec 2005 00:54:10 -0000 1.67
@@ -304,9 +304,14 @@
[[self nextResponder] keyUp:event];
}
+- (WebFrame *)_webFrame
+{
+ return [[self _web_parentWebFrameView] webFrame];
+}
+
- (NSDictionary *)_elementAtWindowPoint:(NSPoint)windowPoint
{
- WebFrame *frame = [[self _web_parentWebFrameView] webFrame];
+ WebFrame *frame = [self _webFrame];
ASSERT(frame);
NSPoint screenPoint = [[self window] convertBaseToScreen:windowPoint];
@@ -350,18 +355,16 @@
- (BOOL)becomeFirstResponder
{
BOOL result = [super becomeFirstResponder];
- if (result) {
- [[self _web_parentWebView] _selectedFrameDidChange];
- }
+ if (result)
+ [[self _webFrame] _clearSelectionInOtherFrames];
return result;
}
- (BOOL)resignFirstResponder
{
BOOL resign = [super resignFirstResponder];
- if (resign && ![[self _web_parentWebView] maintainsInactiveSelection]) {
+ if (resign && ![[self _web_parentWebView] maintainsInactiveSelection])
[self deselectAll];
- }
return resign;
}
@@ -373,10 +376,8 @@
} else if ([link isKindOfClass:[NSString class]]) {
URL = [[self class] _URLForString:(NSString *)link];
}
- if (URL != nil) {
- WebFrame *frame = [[self _web_parentWebFrameView] webFrame];
- [frame _safeLoadURL:URL];
- }
+ if (URL != nil)
+ [[self _webFrame] _safeLoadURL:URL];
}
#pragma mark PRINTING
1.322 +5 -92 WebKit/WebView.subproj/WebView.m
Index: WebView.m
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebView.m,v
retrieving revision 1.321
retrieving revision 1.322
diff -u -r1.321 -r1.322
--- WebView.m 23 Dec 2005 08:19:32 -0000 1.321
+++ WebView.m 24 Dec 2005 00:54:10 -0000 1.322
@@ -288,11 +288,6 @@
@end
@interface WebView (WebFileInternal)
-#ifndef NDEBUG
-- (void)_debugCheckForMultipleSelectedFrames;
-#endif
-- (WebFrame *)_findSelectedFrame;
-- (WebFrame *)_findSelectedFrameSkippingFrame:(WebFrame *)frameToSkip;
- (WebFrame *)_selectedOrMainFrame;
- (WebBridge *)_bridgeForSelectedOrMainFrame;
- (BOOL)_isLoading;
@@ -623,13 +618,10 @@
[frame _checkLoadComplete];
}
-
- (void)_mainReceivedError:(NSError *)error fromDataSource:(WebDataSource *)dataSource complete:(BOOL)isComplete
{
ASSERT(dataSource);
-#ifndef NDEBUG
ASSERT([dataSource webFrame]);
-#endif
[dataSource _setMainDocumentError: error];
@@ -2548,24 +2540,17 @@
// This is faster than searching the frame hierarchy, and will give us a result even in the case
// where the focused frame doesn't actually contain a selection.
WebFrame *focusedFrame = [self _focusedFrame];
- if (focusedFrame != nil) {
+ if (focusedFrame) {
#ifndef NDEBUG
- WebFrame *frameWithSelection = [self _findSelectedFrame];
- ASSERT(frameWithSelection == nil || frameWithSelection == focusedFrame);
- [self _debugCheckForMultipleSelectedFrames];
+ WebFrame *frameWithSelection = [[self mainFrame] _findFrameWithSelection];
#endif
+ ASSERT(frameWithSelection == nil || frameWithSelection == focusedFrame);
return focusedFrame;
}
// If the first responder is outside of our view tree, we search for a frame containing a selection.
// There should be at most only one of these.
- WebFrame *frameWithSelection = [self _findSelectedFrame];
- if (frameWithSelection != nil) {
-#ifndef NDEBUG
- [self _debugCheckForMultipleSelectedFrames];
-#endif
- return frameWithSelection;
- }
+ return [[self mainFrame] _findFrameWithSelection];
return nil;
}
@@ -3019,66 +3004,11 @@
return nil;
}
-- (WebFrame *)_findSelectedFrameStartingFromFrame:(WebFrame *)frame skippingFrame:(WebFrame *)frameToSkip
-{
- if (frame != frameToSkip && [frame _hasSelection]) {
- return frame;
- }
-
- NSArray *frames = [frame _internalChildFrames];
- int i;
- int count = [frames count];
- for (i = 0; i < count; i++) {
- WebFrame *selectedChildFrame = [self _findSelectedFrameStartingFromFrame:[frames objectAtIndex:i] skippingFrame:frameToSkip];
- if (selectedChildFrame != nil) {
- return selectedChildFrame;
- }
- }
-
- return nil;
-}
-
-- (WebFrame *)_findSelectedFrameSkippingFrame:(WebFrame *)frameToSkip
-{
- return [self _findSelectedFrameStartingFromFrame:[self mainFrame] skippingFrame:frameToSkip];
-}
-
-- (WebFrame *)_findSelectedFrame
-{
- return [self _findSelectedFrameSkippingFrame:nil];
-}
-
-#ifndef DEBUG
-- (void)_debugCollectSelectedFramesIntoArray:(NSMutableArray *)selectedFrames startingFromFrame:(WebFrame *)frame
-{
- if ([frame _hasSelection])
- [selectedFrames addObject:frame];
-
- NSArray *frames = [frame _internalChildFrames];
- int i;
- int count = [frames count];
- for (i = 0; i < count; i++) {
- [self _debugCollectSelectedFramesIntoArray:selectedFrames startingFromFrame:[frames objectAtIndex:i]];
- }
-}
-
-- (void)_debugCheckForMultipleSelectedFrames
-{
- NSMutableArray *selectedFrames = [NSMutableArray array];
- [self _debugCollectSelectedFramesIntoArray:selectedFrames startingFromFrame:[self mainFrame]];
- // FIXME: 4186050 is one known case that makes this assertion fire
- if ([selectedFrames count] > 1) {
- ERROR("%d frames have a selection at the same time", [selectedFrames count]);
- }
-}
-#endif
-
- (WebFrame *)_selectedOrMainFrame
{
WebFrame *result = [self selectedFrame];
- if (result == nil) {
+ if (result == nil)
result = [self mainFrame];
- }
return result;
}
@@ -3232,20 +3162,3 @@
}
@end
-
- at implementation WebView (WebDocumentSelectionExtras)
-
-- (void)_selectedFrameDidChange
-{
- // We rely on WebDocumentSelection protocol implementors to call this method when they become first
- // responder. It would be nicer to just notice first responder changes here instead, but there's no
- // notification sent when the first responder changes in general (Radar 2573089).
- [[self _findSelectedFrameSkippingFrame:[self _focusedFrame]] _clearSelection];
-
-#ifndef NDEBUG
- // While we're in the general area of selection and frames, check that there is only one now.
- [self _debugCheckForMultipleSelectedFrames];
-#endif
-}
-
- at end
1.26 +0 -5 WebKit/WebView.subproj/WebViewInternal.h
Index: WebViewInternal.h
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebViewInternal.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- WebViewInternal.h 20 Dec 2005 08:32:56 -0000 1.25
+++ WebViewInternal.h 24 Dec 2005 00:54:11 -0000 1.26
@@ -43,11 +43,6 @@
- (BOOL)_canPaste;
@end
- at interface WebView (WebDocumentSelectionExtras)
-// WebDocumentSelection protocol implementors should call this in becomeFirstResponder
-- (void)_selectedFrameDidChange;
- at end
-
@interface WebView (AllWebViews)
+ (void)_makeAllWebViewsPerformSelector:(SEL)selector;
- (void)_removeFromAllWebViewsSet;
More information about the webkit-changes
mailing list