Changeset 16760 in webkit
- Timestamp:
- Oct 3, 2006 7:31:10 PM (18 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r16759 r16760 1 2006-10-03 Graham Dennis <graham.dennis@gmail.com> 2 3 Reviewed by Timothy. 4 5 <http://bugzilla.opendarwin.org/show_bug.cgi?id=10338> 6 When contentEditable, cursor doesn't change to hand 7 8 Allow the behaviour of editable links to be specified by a WebPreference 9 The preference WebKitEditableLinkBehavior has four options: 10 - AlwaysLive: Safari 2.0 behaviour 11 - OnlyLiveWithShiftKey: Firefox/WinIE behaviour (and prior WebKit-ToT behaviour) 12 - LiveWhenNotFocused: Editable links are live only when their editable block is not 13 focused, or when the shift key is pressed 14 - DefaultBehavior: This is the same as OnlyLiveWithShiftKey. 15 16 No layout tests, just a modification of a manual-test as it isn't possible to test 17 this automatically. 18 19 * bridge/mac/WebCoreSettings.h: 20 * bridge/mac/WebCoreSettings.mm: 21 (-[WebCoreSettings setEditableLinkBehavior:]): 22 (-[WebCoreSettings editableLinkBehavior]): 23 * html/HTMLAnchorElement.cpp: 24 (WebCore::HTMLAnchorElement::HTMLAnchorElement): 25 (WebCore::HTMLAnchorElement::defaultEventHandler): 26 (WebCore::HTMLAnchorElement::setActive): 27 * html/HTMLAnchorElement.h: 28 * manual-tests/contenteditable-link.html: 29 * page/FrameView.cpp: 30 (WebCore::nodeIsNotBeingEdited): 31 (WebCore::selectCursor): 32 * page/Settings.h: 33 (WebCore::Settings::): 34 (WebCore::Settings::Settings): 35 (WebCore::Settings::editableLinkBehavior): 36 (WebCore::Settings::setEditableLinkBehavior): 37 1 38 2006-10-03 Beth Dakin <bdakin@apple.com> 2 39 -
trunk/WebCore/bridge/mac/WebCoreSettings.h
r15438 r16760 119 119 - (NSString *)defaultTextEncoding; 120 120 121 - (void)setEditableLinkBehavior:(int)behavior; 122 - (int)editableLinkBehavior; 123 121 124 - (WebCoreSettingsImpl *)settings; 122 125 -
trunk/WebCore/bridge/mac/WebCoreSettings.mm
r16245 r16760 1 1 /* 2 2 * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved. 3 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 335 336 } 336 337 338 - (void)setEditableLinkBehavior:(int)behavior 339 { 340 Settings::EditableLinkBehavior b = (Settings::EditableLinkBehavior)behavior; 341 if (b != Settings::EditableLinkDefaultBehavior && 342 b != Settings::EditableLinkAlwaysLive && 343 b != Settings::EditableLinkOnlyLiveWithShiftKey && 344 b != Settings::EditableLinkLiveWhenNotFocused) { 345 settings->setEditableLinkBehavior(Settings::EditableLinkDefaultBehavior); 346 } else 347 settings->setEditableLinkBehavior(b); 348 } 349 350 - (int)editableLinkBehavior 351 { 352 return (int)settings->editableLinkBehavior(); 353 } 354 337 355 - (Settings *)settings 338 356 { -
trunk/WebCore/html/HTMLAnchorElement.cpp
r16250 r16760 6 6 * (C) 2000 Simon Hausmann <hausmann@kde.org> 7 7 * Copyright (C) 2003, 2006 Apple Computer, Inc. 8 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) 8 9 * 9 10 * This library is free software; you can redistribute it and/or … … 36 37 #include "RenderFlow.h" 37 38 #include "RenderImage.h" 39 #include "SelectionController.h" 40 #include "Settings.h" 38 41 #include "UIEvent.h" 39 42 #include "csshelper.h" … … 46 49 HTMLAnchorElement::HTMLAnchorElement(Document* doc) 47 50 : HTMLElement(aTag, doc) 51 , m_rootEditableElementForSelectionOnMouseDown(0) 48 52 { 49 53 } … … 51 55 HTMLAnchorElement::HTMLAnchorElement(const QualifiedName& tagName, Document* doc) 52 56 : HTMLElement(tagName, doc) 57 , m_rootEditableElementForSelectionOnMouseDown(0) 53 58 { 54 59 } … … 129 134 } 130 135 131 if (e && !e->shiftKey() && isContentEditable()) { 132 HTMLElement::defaultEventHandler(evt); 133 return; 136 // If the link is editable, then we need to check the settings to see whether or not to follow the link 137 if (isContentEditable()) { 138 Settings::EditableLinkBehavior editableLinkBehavior = Settings::EditableLinkDefaultBehavior; 139 if (document()->frame() && document()->frame()->settings()) 140 editableLinkBehavior = document()->frame()->settings()->editableLinkBehavior(); 141 142 switch(editableLinkBehavior) { 143 // Always follow the link (Safari 2.0 behavior) 144 default: 145 case Settings::EditableLinkDefaultBehavior: 146 case Settings::EditableLinkAlwaysLive: 147 break; 148 149 // If the selection prior to clicking on this link resided in the same editable block as this link, 150 // and the shift key isn't pressed, we don't want to follow the link 151 case Settings::EditableLinkLiveWhenNotFocused: 152 if (e && !e->shiftKey() && m_rootEditableElementForSelectionOnMouseDown == rootEditableElement()) { 153 HTMLElement::defaultEventHandler(evt); 154 return; 155 } 156 break; 157 158 // Only follow the link if the shift key is down (WinIE/Firefox behavior) 159 case Settings::EditableLinkOnlyLiveWithShiftKey: 160 if (e && !e->shiftKey()) { 161 HTMLElement::defaultEventHandler(evt); 162 return; 163 } 164 break; 165 } 134 166 } 135 167 … … 177 209 178 210 evt->setDefaultHandled(); 211 } else if (m_isLink && isContentEditable()) { 212 // This keeps track of the editable block that the selection was in (if it was in one) just before the link was clicked 213 // for the LiveWhenNotFocused editable link behavior 214 if (evt->type() == mousedownEvent && document()->frame() && document()->frame()->selectionController()) 215 m_rootEditableElementForSelectionOnMouseDown = document()->frame()->selectionController()->rootEditableElement(); 216 else if (evt->type() == mouseoutEvent) 217 m_rootEditableElementForSelectionOnMouseDown = 0; 179 218 } 180 219 … … 184 223 void HTMLAnchorElement::setActive(bool down, bool pause) 185 224 { 186 if (isContentEditable()) 187 return; 225 if (isContentEditable()) { 226 Settings::EditableLinkBehavior editableLinkBehavior = Settings::EditableLinkDefaultBehavior; 227 if (document()->frame() && document()->frame()->settings()) 228 editableLinkBehavior = document()->frame()->settings()->editableLinkBehavior(); 229 230 switch(editableLinkBehavior) { 231 default: 232 case Settings::EditableLinkDefaultBehavior: 233 case Settings::EditableLinkAlwaysLive: 234 break; 235 236 // Don't set the link to be active if the current selection is in the same editable block as 237 // this link 238 case Settings::EditableLinkLiveWhenNotFocused: 239 if (down && document()->frame() && document()->frame()->selectionController() && 240 document()->frame()->selectionController()->rootEditableElement() == rootEditableElement()) 241 return; 242 break; 243 244 case Settings::EditableLinkOnlyLiveWithShiftKey: 245 return; 246 } 247 248 } 249 188 250 ContainerNode::setActive(down, pause); 189 251 } -
trunk/WebCore/html/HTMLAnchorElement.h
r15834 r16760 95 95 String search() const; 96 96 String text() const; 97 98 private: 99 Element *m_rootEditableElementForSelectionOnMouseDown; 97 100 }; 98 101 -
trunk/WebCore/manual-tests/contenteditable-link.html
r14346 r16760 16 16 <P>Repro movie for bug <a href="http://bugzilla.opendarwin.org/show_bug.cgi?id=7156">#7156</a></P> 17 17 18 <div>The behaviour of editable links is controlled by the user default WebKitEditableLinkBehavior. This can be set via a private WebPreference. If the preference is OnlyLiveWithShiftKey, then the link will only be active when the shift key is pressed (WinIE/Firefox behaviour). If the preference is WebKitEditableLinkAlwaysLive or WebKitEditableLinkDefaultBehavior, then the link is always active (Safari 2.0 behaviour). Finally, if the preference is WebKitEditableLinkLiveWhenNotFocused, the link will only be live if the selection before clicking on the link is not in the same editable block as the link.</div> 19 18 20 <div id="editable" contentEditable="true"> 19 21 <p>Test content</p> -
trunk/WebCore/page/FrameView.cpp
r16741 r16760 6 6 * 2000 Dirk Mueller <mueller@kde.org> 7 7 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. 8 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) 8 9 * 9 10 * This library is free software; you can redistribute it and/or … … 48 49 #include "RenderView.h" 49 50 #include "SelectionController.h" 51 #include "Settings.h" 50 52 #include "cssstyleselector.h" 51 53 … … 666 668 } 667 669 670 // Returns true if the node's editable block is not current focused for editing 671 static bool nodeIsNotBeingEdited(Node* node, Frame* frame) 672 { 673 return frame->selectionController()->rootEditableElement() != node->rootEditableElement(); 674 } 675 668 676 static Cursor selectCursor(const MouseEventWithHitTestResults& event, Frame* frame, bool mousePressed) 669 677 { … … 704 712 case CURSOR_AUTO: { 705 713 bool editable = (node && node->isContentEditable()); 706 if ((event.isOverLink() || isSubmitImage(node)) && (!editable || event.event().shiftKey())) 714 bool editableLinkEnabled = false; 715 716 // If the link is editable, then we need to check the settings to see whether or not the link should be followed 717 if (editable) { 718 switch(frame->settings()->editableLinkBehavior()) { 719 default: 720 case Settings::EditableLinkDefaultBehavior: 721 case Settings::EditableLinkAlwaysLive: 722 editableLinkEnabled = true; 723 break; 724 725 case Settings::EditableLinkLiveWhenNotFocused: 726 editableLinkEnabled = nodeIsNotBeingEdited(node, frame) || event.event().shiftKey(); 727 break; 728 729 case Settings::EditableLinkOnlyLiveWithShiftKey: 730 editableLinkEnabled = event.event().shiftKey(); 731 break; 732 } 733 } 734 735 if ((event.isOverLink() || isSubmitImage(node)) && (!editable || editableLinkEnabled)) 707 736 return handCursor(); 708 737 RenderLayer* layer = renderer ? renderer->enclosingLayer() : 0; -
trunk/WebCore/page/Settings.h
r16250 r16760 1 1 /* 2 2 * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved. 3 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 35 36 { 36 37 public: 38 enum EditableLinkBehavior { 39 EditableLinkDefaultBehavior = 0, 40 EditableLinkAlwaysLive, 41 EditableLinkOnlyLiveWithShiftKey, 42 EditableLinkLiveWhenNotFocused 43 }; 44 37 45 Settings() 38 46 : m_minimumFontSize(0) … … 48 56 , m_shouldPrintBackgrounds(0) 49 57 , m_textAreasAreResizable(0) 58 , m_editableLinkBehavior(EditableLinkDefaultBehavior) 50 59 { 51 60 } … … 76 85 bool shouldPrintBackgrounds() const { return m_shouldPrintBackgrounds; } 77 86 bool textAreasAreResizable() const { return m_textAreasAreResizable; } 87 EditableLinkBehavior editableLinkBehavior() const { return m_editableLinkBehavior; } 78 88 79 89 void setStdFontName(const AtomicString& s) { m_stdFontName = s; } … … 101 111 void setShouldPrintBackgrounds(bool f) { m_shouldPrintBackgrounds = f; } 102 112 void setTextAreasAreResizable(bool f) { m_textAreasAreResizable = f; } 113 void setEditableLinkBehavior(EditableLinkBehavior e) { m_editableLinkBehavior = e; } 103 114 104 115 private: … … 124 135 bool m_shouldPrintBackgrounds : 1; 125 136 bool m_textAreasAreResizable : 1; 137 EditableLinkBehavior m_editableLinkBehavior; 126 138 }; 127 139 -
trunk/WebKit/ChangeLog
r16752 r16760 1 2006-10-03 Graham Dennis <graham.dennis@gmail.com> 2 3 Reviewed by Timothy. 4 5 <http://bugzilla.opendarwin.org/show_bug.cgi?id=10338> 6 When contentEditable, cursor doesn't change to hand 7 8 Allow the behaviour of editable links to be specified by a WebPreference 9 The preference WebKitEditableLinkBehavior has four options: 10 - AlwaysLive: Safari 2.0 behaviour 11 - OnlyLiveWithShiftKey: Firefox/WinIE behaviour (and prior WebKit-ToT behaviour) 12 - LiveWhenNotFocused: Editable links are live only when their editable block is not 13 focused, or when the shift key is pressed 14 - DefaultBehavior: This is the same as OnlyLiveWithShiftKey. 15 16 No layout tests, just a modification of a manual-test as it isn't possible to test 17 this automatically. 18 19 * WebView/WebPreferenceKeysPrivate.h: 20 * WebView/WebPreferences.m: 21 (+[WebPreferences initialize]): 22 (-[WebPreferences editableLinkBehavior]): 23 (-[WebPreferences setEditableLinkBehavior:]): 24 * WebView/WebPreferencesPrivate.h: 25 * WebView/WebView.m: 26 (-[WebView _updateWebCoreSettingsFromPreferences:]): 27 1 28 2006-10-03 Justin Garcia <justin.garcia@apple.com> 2 29 -
trunk/WebKit/WebView/WebPreferenceKeysPrivate.h
r14480 r16760 65 65 #define WebKitPDFDisplayModePreferenceKey @"WebKitPDFDisplayMode" 66 66 #define WebKitPDFScaleFactorPreferenceKey @"WebKitPDFScaleFactor" 67 #define WebKitEditableLinkBehaviorPreferenceKey @"WebKitEditableLinkBehavior" 67 68 68 69 -
trunk/WebKit/WebView/WebPreferences.m
r16686 r16760 1 1 /* 2 2 * Copyright (C) 2005 Apple Computer, Inc. All rights reserved. 3 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 232 233 @"1", WebKitPDFDisplayModePreferenceKey, 233 234 @"0", WebKitPDFScaleFactorPreferenceKey, 235 [NSNumber numberWithInt:WebKitEditableLinkDefaultBehavior], 236 WebKitEditableLinkBehaviorPreferenceKey, 234 237 nil]; 235 238 … … 658 661 } 659 662 663 - (WebKitEditableLinkBehavior)editableLinkBehavior 664 { 665 WebKitEditableLinkBehavior value = [self _integerValueForKey:WebKitEditableLinkBehaviorPreferenceKey]; 666 if (value != WebKitEditableLinkDefaultBehavior && 667 value != WebKitEditableLinkAlwaysLive && 668 value != WebKitEditableLinkOnlyLiveWithShiftKey && 669 value != WebKitEditableLinkLiveWhenNotFocused) { 670 // ensure that a valid result is returned 671 value = WebKitEditableLinkDefaultBehavior; 672 } 673 return value; 674 } 675 676 - (void)setEditableLinkBehavior:(WebKitEditableLinkBehavior)behavior 677 { 678 [self _setIntegerValue:behavior forKey:WebKitEditableLinkBehaviorPreferenceKey]; 679 } 680 681 660 682 static NSMutableDictionary *webPreferencesInstances = nil; 661 683 -
trunk/WebKit/WebView/WebPreferencesPrivate.h
r12930 r16760 43 43 #endif 44 44 45 46 typedef enum { 47 WebKitEditableLinkDefaultBehavior = 0, 48 WebKitEditableLinkAlwaysLive, 49 WebKitEditableLinkOnlyLiveWithShiftKey, 50 WebKitEditableLinkLiveWhenNotFocused 51 } WebKitEditableLinkBehavior; 52 45 53 @interface WebPreferences (WebPrivate) 46 54 … … 62 70 - (void)setPDFScaleFactor:(float)scale; 63 71 72 - (WebKitEditableLinkBehavior)editableLinkBehavior; 73 - (void)setEditableLinkBehavior:(WebKitEditableLinkBehavior)behavior; 74 64 75 // Other private methods 65 76 - (size_t)_pageCacheSize; -
trunk/WebKit/WebView/WebView.m
r16752 r16760 877 877 [_private->settings setShouldPrintBackgrounds:[preferences shouldPrintBackgrounds]]; 878 878 [_private->settings setTextAreasAreResizable:[preferences textAreasAreResizable]]; 879 [_private->settings setEditableLinkBehavior:[preferences editableLinkBehavior]]; 879 880 } 880 881
Note: See TracChangeset
for help on using the changeset viewer.