[webkit-changes] cvs commit: WebKit/WebView.subproj WebView.m
WebViewInternal.h
Darin
darin at opensource.apple.com
Sun Aug 14 02:12:49 PDT 2005
darin 05/08/14 02:12:49
Modified: . ChangeLog
khtml khtml_part.cpp khtml_part.h
kwq KWQKHTMLPart.h KWQKHTMLPart.mm WebCoreBridge.h
. ChangeLog Makefile.am
WebCoreSupport.subproj WebBridge.m
WebView.subproj WebView.m WebViewInternal.h
Log:
WebCore:
Reviewed and landed by Darin.
WebCore part of fix for <http://bugzilla.opendarwin.org/show_bug.cgi?id=4011>:
"Editing delegate selection methods not called when using mouse"
Clicking on editable content would move the cursor or alter the selection without
calling the appropriate editing delegate method
(webView:shouldChangeSelectedDOMRange:toDOMRange:affinity:stillSelecting:). The
core of the patch is in the KHTMLPart::hadnleMousePressEvent* methods, the rest
is glue needed to drill through all the layers.
* khtml/khtml_part.cpp:
* khtml/khtml_part.cpp:
(KHTMLPart::shouldChangeSelection): Glue to call editing delegate.
(KHTMLPart::findTextNext): Call editing delegate before changing selection.
(KHTMLPart::selectClosestWordFromMouseEvent): Ditto.
(KHTMLPart::handleMousePressEventTripleClick): Ditto.
(KHTMLPart::handleMousePressEventSingleClick): Ditto.
(KHTMLPart::handleMouseMoveEventSelection): Ditto.
(KHTMLPart::khtmlMouseReleaseEvent): Ditto.
(KHTMLPart::selectAll): Ditto.
(KHTMLPart::appliedEditing): Ditto.
(KHTMLPart::unappliedEditing): Ditto.
(KHTMLPart::reappliedEditing): Ditto.
(KHTMLPart::selectFrameElementInParentIfFullySelected): Ditto.
* khtml/khtml_part.h: Added shouldChangeSelection glue method.
* kwq/KWQKHTMLPart.h: Ditto.
* kwq/KWQKHTMLPart.mm:
(KWQKHTMLPart::shouldChangeSelection): Glue to call editing delegate.
* kwq/WebCoreBridge.h: Added shouldChangeSelectedDOMRange:toDOMRange:affinity:stillSelecting: glue method.
WebKit:
Reviewed and landed by Darin.
WebKit part of fix for <http://bugzilla.opendarwin.org/show_bug.cgi?id=4011>:
"Editing delegate selection methods not called when using mouse"
Clicking on editable content would move the cursor or alter the selection without
calling the appropriate editing delegate method
(webView:shouldChangeSelectedDOMRange:toDOMRange:affinity:stillSelecting:). The
core of the patch is in the KHTMLPart::handleMousePressEvent* methods, the rest
is glue needed to drill through all the layers.
* WebCoreSupport.subproj/WebBridge.m:
(-[WebBridge shouldChangeSelectedDOMRange:toDOMRange:affinity:stillSelecting:]):
Bridge glue.
* WebView.subproj/WebView.m:
(-[WebView(WebViewEditingExtras) _shouldChangeSelectedDOMRange:toDOMRange:affinity:stillSelecting:]):
Final step in glue, calling editing delegate.
* WebView.subproj/WebViewInternal.h:
Added _shouldChangeSelectedDOMRange:toDOMRange:affinity:stillSelecting: private method to WebViewEditingExtras
category.
Revision Changes Path
1.4570 +36 -0 WebCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebCore/ChangeLog,v
retrieving revision 1.4569
retrieving revision 1.4570
diff -u -r1.4569 -r1.4570
--- ChangeLog 14 Aug 2005 08:47:03 -0000 1.4569
+++ ChangeLog 14 Aug 2005 09:12:39 -0000 1.4570
@@ -1,3 +1,39 @@
+2005-08-14 Duncan Wilcox <duncan at mclink.it>
+
+ Reviewed and landed by Darin.
+
+ WebCore part of fix for <http://bugzilla.opendarwin.org/show_bug.cgi?id=4011>:
+ "Editing delegate selection methods not called when using mouse"
+
+ Clicking on editable content would move the cursor or alter the selection without
+ calling the appropriate editing delegate method
+ (webView:shouldChangeSelectedDOMRange:toDOMRange:affinity:stillSelecting:). The
+ core of the patch is in the KHTMLPart::hadnleMousePressEvent* methods, the rest
+ is glue needed to drill through all the layers.
+
+ * khtml/khtml_part.cpp:
+ * khtml/khtml_part.cpp:
+ (KHTMLPart::shouldChangeSelection): Glue to call editing delegate.
+ (KHTMLPart::findTextNext): Call editing delegate before changing selection.
+ (KHTMLPart::selectClosestWordFromMouseEvent): Ditto.
+ (KHTMLPart::handleMousePressEventTripleClick): Ditto.
+ (KHTMLPart::handleMousePressEventSingleClick): Ditto.
+ (KHTMLPart::handleMouseMoveEventSelection): Ditto.
+ (KHTMLPart::khtmlMouseReleaseEvent): Ditto.
+ (KHTMLPart::selectAll): Ditto.
+ (KHTMLPart::appliedEditing): Ditto.
+ (KHTMLPart::unappliedEditing): Ditto.
+ (KHTMLPart::reappliedEditing): Ditto.
+ (KHTMLPart::selectFrameElementInParentIfFullySelected): Ditto.
+
+ * khtml/khtml_part.h: Added shouldChangeSelection glue method.
+ * kwq/KWQKHTMLPart.h: Ditto.
+
+ * kwq/KWQKHTMLPart.mm:
+ (KWQKHTMLPart::shouldChangeSelection): Glue to call editing delegate.
+
+ * kwq/WebCoreBridge.h: Added shouldChangeSelectedDOMRange:toDOMRange:affinity:stillSelecting: glue method.
+
2005-08-14 Darin Adler <darin at apple.com>
Fixed by Alexey Proskuryakov <ap at nypop.com>.
1.334 +49 -15 WebCore/khtml/khtml_part.cpp
Index: khtml_part.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/khtml_part.cpp,v
retrieving revision 1.333
retrieving revision 1.334
diff -u -r1.333 -r1.334
--- khtml_part.cpp 30 Jul 2005 02:33:11 -0000 1.333
+++ khtml_part.cpp 14 Aug 2005 09:12:43 -0000 1.334
@@ -2395,7 +2395,10 @@
d->m_view->setContentsPos(x-50, y-50);
Position p1(d->m_findNode, d->m_findPos);
Position p2(d->m_findNode, d->m_findPos + matchLen);
- setSelection(Selection(p1, khtml::DOWNSTREAM, p2, khtml::SEL_PREFER_UPSTREAM_AFFINITY));
+ Selection sel = Selection(p1, khtml::DOWNSTREAM, p2, khtml::SEL_PREFER_UPSTREAM_AFFINITY);
+ if (shouldChangeSelection(sel)) {
+ setSelection(sel);
+ }
return true;
}
}
@@ -4601,8 +4604,10 @@
d->m_beganSelectingText = true;
}
- setSelection(selection);
- startAutoScroll();
+ if (shouldChangeSelection(selection)) {
+ setSelection(selection);
+ startAutoScroll();
+ }
}
void KHTMLPart::handleMousePressEventDoubleClick(khtml::MousePressEvent *event)
@@ -4639,8 +4644,10 @@
d->m_beganSelectingText = true;
}
- setSelection(selection);
- startAutoScroll();
+ if (shouldChangeSelection(selection)) {
+ setSelection(selection);
+ startAutoScroll();
+ }
}
}
@@ -4691,8 +4698,10 @@
d->m_selectionGranularity = CHARACTER;
}
- setSelection(sel);
- startAutoScroll();
+ if (shouldChangeSelection(sel)) {
+ setSelection(sel);
+ startAutoScroll();
+ }
}
}
}
@@ -4902,7 +4911,10 @@
if (d->m_selectionGranularity != CHARACTER) {
sel.expandUsingGranularity(d->m_selectionGranularity);
}
- setSelection(sel);
+
+ if (shouldChangeSelection(sel)) {
+ setSelection(sel);
+ }
#endif // KHTML_NO_SELECTION
}
@@ -4973,7 +4985,9 @@
VisiblePosition pos = node->renderer()->positionForCoordinates(event->x(), event->y());
selection.moveTo(pos);
}
- setSelection(selection);
+ if (shouldChangeSelection(selection)) {
+ setSelection(selection);
+ }
}
#ifndef QT_NO_CLIPBOARD
@@ -5139,10 +5153,22 @@
return;
NodeImpl *de = d->m_doc->documentElement();
int n = de ? de->childNodeCount() : 0;
- setSelection(Selection(VisiblePosition(de, 0, khtml::DOWNSTREAM), VisiblePosition(de, n, khtml::DOWNSTREAM)));
+ Selection sel = Selection(VisiblePosition(de, 0, khtml::DOWNSTREAM), VisiblePosition(de, n, khtml::DOWNSTREAM));
+ if (shouldChangeSelection(sel)) {
+ setSelection(sel);
+ }
selectFrameElementInParentIfFullySelected();
}
+bool KHTMLPart::shouldChangeSelection(const Selection &newselection) const
+{
+#if APPLE_CHANGES
+ return KWQ(this)->shouldChangeSelection(d->m_selection, newselection, newselection.startAffinity(), false);
+#else
+ return true;
+#endif
+}
+
bool KHTMLPart::shouldBeginEditing(const RangeImpl *range) const
{
return true;
@@ -5167,7 +5193,9 @@
void KHTMLPart::appliedEditing(EditCommandPtr &cmd)
{
- setSelection(cmd.endingSelection(), false);
+ if (shouldChangeSelection(cmd.endingSelection())) {
+ setSelection(cmd.endingSelection(), false);
+ }
// Now set the typing style from the command. Clear it when done.
// This helps make the case work where you completely delete a piece
@@ -5199,7 +5227,9 @@
void KHTMLPart::unappliedEditing(EditCommandPtr &cmd)
{
- setSelection(cmd.startingSelection(), true);
+ if (shouldChangeSelection(cmd.startingSelection())) {
+ setSelection(cmd.startingSelection(), true);
+ }
#if APPLE_CHANGES
KWQ(this)->registerCommandForRedo(cmd);
KWQ(this)->respondToChangedContents();
@@ -5209,7 +5239,9 @@
void KHTMLPart::reappliedEditing(EditCommandPtr &cmd)
{
- setSelection(cmd.endingSelection(), true);
+ if (shouldChangeSelection(cmd.endingSelection())) {
+ setSelection(cmd.endingSelection(), true);
+ }
#if APPLE_CHANGES
KWQ(this)->registerCommandForUndo(cmd);
KWQ(this)->respondToChangedContents();
@@ -5953,8 +5985,10 @@
VisiblePosition afterOwnerElement(VisiblePosition(ownerElementParent, ownerElementNodeIndex + 1, khtml::SEL_PREFER_UPSTREAM_AFFINITY));
// Focus on the parent frame, and then select from before this element to after.
- parentView->setFocus();
- parent->setSelection(Selection(beforeOwnerElement, afterOwnerElement));
+ if (parent->shouldChangeSelection(Selection(beforeOwnerElement, afterOwnerElement))) {
+ parentView->setFocus();
+ parent->setSelection(Selection(beforeOwnerElement, afterOwnerElement));
+ }
}
void KHTMLPart::handleFallbackContent()
1.136 +5 -0 WebCore/khtml/khtml_part.h
Index: khtml_part.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/khtml_part.h,v
retrieving revision 1.135
retrieving revision 1.136
diff -u -r1.135 -r1.136
--- khtml_part.h 29 Jul 2005 23:02:41 -0000 1.135
+++ khtml_part.h 14 Aug 2005 09:12:43 -0000 1.136
@@ -622,6 +622,11 @@
void setSelection(const khtml::Selection &, bool closeTyping = true, bool keepTypingStyle = false);
/**
+ * Returns whether selection can be changed.
+ */
+ bool shouldChangeSelection(const khtml::Selection &) const;
+
+ /**
* Returns a mark, to be used as emacs uses it.
*/
const khtml::Selection &mark() const;
1.225 +3 -0 WebCore/kwq/KWQKHTMLPart.h
Index: KWQKHTMLPart.h
===================================================================
RCS file: /cvs/root/WebCore/kwq/KWQKHTMLPart.h,v
retrieving revision 1.224
retrieving revision 1.225
diff -u -r1.224 -r1.225
--- KWQKHTMLPart.h 29 Jul 2005 23:02:45 -0000 1.224
+++ KWQKHTMLPart.h 14 Aug 2005 09:12:44 -0000 1.225
@@ -28,6 +28,8 @@
#import "khtml_part.h"
+#import "text_affinity.h"
+
#import "dom_nodeimpl.h"
#import "WebCoreKeyboardAccess.h"
@@ -343,6 +345,7 @@
void respondToChangedSelection(const khtml::Selection &oldSelection, bool closeTyping);
void respondToChangedContents();
virtual bool isContentEditable() const;
+ virtual bool shouldChangeSelection(const khtml::Selection &oldSelection, const khtml::Selection &newSelection, khtml::EAffinity affinity, bool stillSelecting) const;
virtual bool shouldBeginEditing(const DOM::RangeImpl *) const;
virtual bool shouldEndEditing(const DOM::RangeImpl *) const;
1.659 +8 -0 WebCore/kwq/KWQKHTMLPart.mm
Index: KWQKHTMLPart.mm
===================================================================
RCS file: /cvs/root/WebCore/kwq/KWQKHTMLPart.mm,v
retrieving revision 1.658
retrieving revision 1.659
diff -u -r1.658 -r1.659
--- KWQKHTMLPart.mm 8 Aug 2005 04:07:46 -0000 1.658
+++ KWQKHTMLPart.mm 14 Aug 2005 09:12:44 -0000 1.659
@@ -4114,6 +4114,14 @@
[_bridge respondToChangedSelection];
}
+bool KWQKHTMLPart::shouldChangeSelection(const Selection &oldSelection, const Selection &newSelection, khtml::EAffinity affinity, bool stillSelecting) const
+{
+ return [_bridge shouldChangeSelectedDOMRange:[DOMRange _rangeWithImpl:oldSelection.toRange().get()]
+ toDOMRange:[DOMRange _rangeWithImpl:newSelection.toRange().get()]
+ affinity:static_cast<NSSelectionAffinity>(affinity)
+ stillSelecting:stillSelecting];
+}
+
void KWQKHTMLPart::respondToChangedContents()
{
#if APPLE_CHANGES
1.344 +1 -0 WebCore/kwq/WebCoreBridge.h
Index: WebCoreBridge.h
===================================================================
RCS file: /cvs/root/WebCore/kwq/WebCoreBridge.h,v
retrieving revision 1.343
retrieving revision 1.344
diff -u -r1.343 -r1.344
--- WebCoreBridge.h 29 Jul 2005 21:16:51 -0000 1.343
+++ WebCoreBridge.h 14 Aug 2005 09:12:44 -0000 1.344
@@ -621,6 +621,7 @@
- (void)respondToChangedContents;
- (void)setIsSelected:(BOOL)isSelected forView:(NSView *)view;
- (BOOL)isEditable;
+- (BOOL)shouldChangeSelectedDOMRange:(DOMRange *)currentRange toDOMRange:(DOMRange *)proposedRange affinity:(NSSelectionAffinity)selectionAffinity stillSelecting:(BOOL)flag;
- (BOOL)shouldBeginEditing:(DOMRange *)range;
- (BOOL)shouldEndEditing:(DOMRange *)range;
- (BOOL)canPaste;
1.3288 +25 -0 WebKit/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebKit/ChangeLog,v
retrieving revision 1.3287
retrieving revision 1.3288
diff -u -r1.3287 -r1.3288
--- ChangeLog 11 Aug 2005 23:10:54 -0000 1.3287
+++ ChangeLog 14 Aug 2005 09:12:45 -0000 1.3288
@@ -1,3 +1,28 @@
+2005-08-14 Duncan Wilcox <duncan at mclink.it>
+
+ Reviewed and landed by Darin.
+
+ WebKit part of fix for <http://bugzilla.opendarwin.org/show_bug.cgi?id=4011>:
+ "Editing delegate selection methods not called when using mouse"
+
+ Clicking on editable content would move the cursor or alter the selection without
+ calling the appropriate editing delegate method
+ (webView:shouldChangeSelectedDOMRange:toDOMRange:affinity:stillSelecting:). The
+ core of the patch is in the KHTMLPart::handleMousePressEvent* methods, the rest
+ is glue needed to drill through all the layers.
+
+ * WebCoreSupport.subproj/WebBridge.m:
+ (-[WebBridge shouldChangeSelectedDOMRange:toDOMRange:affinity:stillSelecting:]):
+ Bridge glue.
+
+ * WebView.subproj/WebView.m:
+ (-[WebView(WebViewEditingExtras) _shouldChangeSelectedDOMRange:toDOMRange:affinity:stillSelecting:]):
+ Final step in glue, calling editing delegate.
+
+ * WebView.subproj/WebViewInternal.h:
+ Added _shouldChangeSelectedDOMRange:toDOMRange:affinity:stillSelecting: private method to WebViewEditingExtras
+ category.
+
2005-08-11 Beth Dakin <bdakin at apple.com>
Reviewed by Vicki
1.29 +3 -1 WebKit/Makefile.am
Index: Makefile.am
===================================================================
RCS file: /cvs/root/WebKit/Makefile.am,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- Makefile.am 26 Jul 2005 17:28:58 -0000 1.28
+++ Makefile.am 14 Aug 2005 09:12:46 -0000 1.29
@@ -1,10 +1,12 @@
all-am:
defaults write com.apple.Xcode PBXProductDirectory "$(SYMROOTS)"
defaults write com.apple.Xcode PBXIntermediatesDirectory "$(SYMROOTS)"
+ ../WebKitTools/Scripts/set-webkit-configuration --$(BUILDSTYLE)
xcodebuild -configuration $(BUILDSTYLE)
clean-am:
defaults write com.apple.Xcode PBXProductDirectory "$(SYMROOTS)"
defaults write com.apple.Xcode PBXIntermediatesDirectory "$(SYMROOTS)"
- xcodebuild clean -configuration ${BUILDSTYLE}
+ ../WebKitTools/Scripts/set-webkit-configuration --$(BUILDSTYLE)
+ xcodebuild clean -configuration $(BUILDSTYLE)
doc: all
../Tools/Scripts/make-docs $(SYMROOTS)/Documentation/WebKit $(SYMROOTS)/WebKit.framework/Headers
1.367 +5 -0 WebKit/WebCoreSupport.subproj/WebBridge.m
Index: WebBridge.m
===================================================================
RCS file: /cvs/root/WebKit/WebCoreSupport.subproj/WebBridge.m,v
retrieving revision 1.366
retrieving revision 1.367
diff -u -r1.366 -r1.367
--- WebBridge.m 2 Aug 2005 00:51:29 -0000 1.366
+++ WebBridge.m 14 Aug 2005 09:12:48 -0000 1.367
@@ -1464,6 +1464,11 @@
return [[_frame webView] isEditable];
}
+- (BOOL)shouldChangeSelectedDOMRange:(DOMRange *)currentRange toDOMRange:(DOMRange *)proposedRange affinity:(NSSelectionAffinity)selectionAffinity stillSelecting:(BOOL)flag
+{
+ return [[_frame webView] _shouldChangeSelectedDOMRange:currentRange toDOMRange:proposedRange affinity:selectionAffinity stillSelecting:flag];
+}
+
- (BOOL)shouldBeginEditing:(DOMRange *)range
{
return [[_frame webView] _shouldBeginEditingInDOMRange:range];
1.301 +5 -0 WebKit/WebView.subproj/WebView.m
Index: WebView.m
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebView.m,v
retrieving revision 1.300
retrieving revision 1.301
diff -u -r1.300 -r1.301
--- WebView.m 30 Jul 2005 03:00:28 -0000 1.300
+++ WebView.m 14 Aug 2005 09:12:48 -0000 1.301
@@ -2710,6 +2710,11 @@
return [bridge editableDOMRangeForPoint:[self convertPoint:point toView:[[[bridge webFrame] frameView] documentView]]];
}
+- (BOOL)_shouldChangeSelectedDOMRange:(DOMRange *)currentRange toDOMRange:(DOMRange *)proposedRange affinity:(NSSelectionAffinity)selectionAffinity stillSelecting:(BOOL)flag;
+{
+ return [[self _editingDelegateForwarder] webView:self shouldChangeSelectedDOMRange:currentRange toDOMRange:proposedRange affinity:selectionAffinity stillSelecting:flag];
+}
+
- (BOOL)_shouldBeginEditingInDOMRange:(DOMRange *)range
{
return [[self _editingDelegateForwarder] webView:self shouldBeginEditingInDOMRange:range];
1.21 +1 -0 WebKit/WebView.subproj/WebViewInternal.h
Index: WebViewInternal.h
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebViewInternal.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- WebViewInternal.h 30 Jul 2005 03:00:29 -0000 1.20
+++ WebViewInternal.h 14 Aug 2005 09:12:48 -0000 1.21
@@ -122,6 +122,7 @@
@interface WebView (WebViewEditingExtras)
- (BOOL)_interceptEditingKeyEvent:(NSEvent *)event;
+- (BOOL)_shouldChangeSelectedDOMRange:(DOMRange *)currentRange toDOMRange:(DOMRange *)proposedRange affinity:(NSSelectionAffinity)selectionAffinity stillSelecting:(BOOL)flag;
- (BOOL)_shouldBeginEditingInDOMRange:(DOMRange *)range;
- (BOOL)_shouldEndEditingInDOMRange:(DOMRange *)range;
- (BOOL)_canPaste;
More information about the webkit-changes
mailing list