Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(918)

Side by Side Diff: Source/core/page/EventHandler.cpp

Issue 236203005: Remove EditableLinkBehavior, which is always set to NeverLive by Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/page/EventHandler.h ('k') | Source/web/WebSettingsImpl.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed.
3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) 3 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org)
4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies) 4 * Copyright (C) 2012 Digia Plc. and/or its subsidiary(-ies)
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after
1032 if (!hitTestResult.isOverWidget()) 1032 if (!hitTestResult.isOverWidget())
1033 return 0; 1033 return 0;
1034 return subframeForTargetNode(hitTestResult.targetNode()); 1034 return subframeForTargetNode(hitTestResult.targetNode());
1035 } 1035 }
1036 1036
1037 static bool isSubmitImage(Node* node) 1037 static bool isSubmitImage(Node* node)
1038 { 1038 {
1039 return isHTMLInputElement(node) && toHTMLInputElement(node)->isImageButton() ; 1039 return isHTMLInputElement(node) && toHTMLInputElement(node)->isImageButton() ;
1040 } 1040 }
1041 1041
1042 // Returns true if the node's editable block is not current focused for editing 1042 bool EventHandler::useHandCursor(Node* node, bool isOverLink)
1043 static bool nodeIsNotBeingEdited(Node* node, LocalFrame* frame)
1044 {
1045 return frame->selection().rootEditableElement() != node->rootEditableElement ();
1046 }
1047
1048 bool EventHandler::useHandCursor(Node* node, bool isOverLink, bool shiftKey)
1049 { 1043 {
1050 if (!node) 1044 if (!node)
1051 return false; 1045 return false;
1052 1046
1053 bool editable = node->rendererIsEditable(); 1047 return ((isOverLink || isSubmitImage(node)) && !node->rendererIsEditable());
1054 bool editableLinkEnabled = false;
1055
1056 // If the link is editable, then we need to check the settings to see whethe r or not the link should be followed
1057 if (editable) {
1058 ASSERT(m_frame->settings());
1059 switch (m_frame->settings()->editableLinkBehavior()) {
1060 default:
1061 case EditableLinkDefaultBehavior:
1062 case EditableLinkAlwaysLive:
1063 editableLinkEnabled = true;
1064 break;
1065
1066 case EditableLinkNeverLive:
1067 editableLinkEnabled = false;
1068 break;
1069
1070 case EditableLinkLiveWhenNotFocused:
1071 editableLinkEnabled = nodeIsNotBeingEdited(node, m_frame) || shiftKe y;
1072 break;
1073
1074 case EditableLinkOnlyLiveWithShiftKey:
1075 editableLinkEnabled = shiftKey;
1076 break;
1077 }
1078 }
1079
1080 return ((isOverLink || isSubmitImage(node)) && (!editable || editableLinkEna bled));
1081 } 1048 }
1082 1049
1083 void EventHandler::cursorUpdateTimerFired(Timer<EventHandler>*) 1050 void EventHandler::cursorUpdateTimerFired(Timer<EventHandler>*)
1084 { 1051 {
1085 ASSERT(m_frame); 1052 ASSERT(m_frame);
1086 ASSERT(m_frame->document()); 1053 ASSERT(m_frame->document());
1087 1054
1088 updateCursor(); 1055 updateCursor();
1089 } 1056 }
1090 1057
1091 void EventHandler::updateCursor() 1058 void EventHandler::updateCursor()
1092 { 1059 {
1093 if (m_mousePositionIsUnknown) 1060 if (m_mousePositionIsUnknown)
1094 return; 1061 return;
1095 1062
1096 FrameView* view = m_frame->view(); 1063 FrameView* view = m_frame->view();
1097 if (!view || !view->shouldSetCursor()) 1064 if (!view || !view->shouldSetCursor())
1098 return; 1065 return;
1099 1066
1100 RenderView* renderView = view->renderView(); 1067 RenderView* renderView = view->renderView();
1101 if (!renderView) 1068 if (!renderView)
1102 return; 1069 return;
1103 1070
1104 bool shiftKey;
1105 bool ctrlKey;
1106 bool altKey;
1107 bool metaKey;
1108 PlatformKeyboardEvent::getCurrentModifierState(shiftKey, ctrlKey, altKey, me taKey);
1109
1110 m_frame->document()->updateLayout(); 1071 m_frame->document()->updateLayout();
1111 1072
1112 HitTestRequest request(HitTestRequest::ReadOnly); 1073 HitTestRequest request(HitTestRequest::ReadOnly);
1113 HitTestResult result(view->windowToContents(m_lastKnownMousePosition)); 1074 HitTestResult result(view->windowToContents(m_lastKnownMousePosition));
1114 renderView->hitTest(request, result); 1075 renderView->hitTest(request, result);
1115 1076
1116 OptionalCursor optionalCursor = selectCursor(result, shiftKey); 1077 OptionalCursor optionalCursor = selectCursor(result);
1117 if (optionalCursor.isCursorChange()) { 1078 if (optionalCursor.isCursorChange()) {
1118 m_currentMouseCursor = optionalCursor.cursor(); 1079 m_currentMouseCursor = optionalCursor.cursor();
1119 view->setCursor(m_currentMouseCursor); 1080 view->setCursor(m_currentMouseCursor);
1120 } 1081 }
1121 } 1082 }
1122 1083
1123 OptionalCursor EventHandler::selectCursor(const HitTestResult& result, bool shif tKey) 1084 OptionalCursor EventHandler::selectCursor(const HitTestResult& result)
1124 { 1085 {
1125 if (m_resizeScrollableArea && m_resizeScrollableArea->inResizeMode()) 1086 if (m_resizeScrollableArea && m_resizeScrollableArea->inResizeMode())
1126 return NoCursorChange; 1087 return NoCursorChange;
1127 1088
1128 Page* page = m_frame->page(); 1089 Page* page = m_frame->page();
1129 if (!page) 1090 if (!page)
1130 return NoCursorChange; 1091 return NoCursorChange;
1131 #if OS(WIN) 1092 #if OS(WIN)
1132 if (panScrollInProgress()) 1093 if (panScrollInProgress())
1133 return NoCursorChange; 1094 return NoCursorChange;
1134 #endif 1095 #endif
1135 1096
1136 Node* node = result.innerPossiblyPseudoNode(); 1097 Node* node = result.innerPossiblyPseudoNode();
1137 if (!node) 1098 if (!node)
1138 return selectAutoCursor(result, node, iBeamCursor(), shiftKey); 1099 return selectAutoCursor(result, node, iBeamCursor());
1139 1100
1140 RenderObject* renderer = node->renderer(); 1101 RenderObject* renderer = node->renderer();
1141 RenderStyle* style = renderer ? renderer->style() : 0; 1102 RenderStyle* style = renderer ? renderer->style() : 0;
1142 1103
1143 if (renderer) { 1104 if (renderer) {
1144 Cursor overrideCursor; 1105 Cursor overrideCursor;
1145 switch (renderer->getCursor(roundedIntPoint(result.localPoint()), overri deCursor)) { 1106 switch (renderer->getCursor(roundedIntPoint(result.localPoint()), overri deCursor)) {
1146 case SetCursorBasedOnStyle: 1107 case SetCursorBasedOnStyle:
1147 break; 1108 break;
1148 case SetCursor: 1109 case SetCursor:
(...skipping 30 matching lines...) Expand all
1179 if (scale < minimumCursorScale) 1140 if (scale < minimumCursorScale)
1180 continue; 1141 continue;
1181 return Cursor(image, hotSpot, scale); 1142 return Cursor(image, hotSpot, scale);
1182 } 1143 }
1183 } 1144 }
1184 1145
1185 switch (style ? style->cursor() : CURSOR_AUTO) { 1146 switch (style ? style->cursor() : CURSOR_AUTO) {
1186 case CURSOR_AUTO: { 1147 case CURSOR_AUTO: {
1187 bool horizontalText = !style || style->isHorizontalWritingMode(); 1148 bool horizontalText = !style || style->isHorizontalWritingMode();
1188 const Cursor& iBeam = horizontalText ? iBeamCursor() : verticalTextCurso r(); 1149 const Cursor& iBeam = horizontalText ? iBeamCursor() : verticalTextCurso r();
1189 return selectAutoCursor(result, node, iBeam, shiftKey); 1150 return selectAutoCursor(result, node, iBeam);
1190 } 1151 }
1191 case CURSOR_CROSS: 1152 case CURSOR_CROSS:
1192 return crossCursor(); 1153 return crossCursor();
1193 case CURSOR_POINTER: 1154 case CURSOR_POINTER:
1194 return handCursor(); 1155 return handCursor();
1195 case CURSOR_MOVE: 1156 case CURSOR_MOVE:
1196 return moveCursor(); 1157 return moveCursor();
1197 case CURSOR_ALL_SCROLL: 1158 case CURSOR_ALL_SCROLL:
1198 return moveCursor(); 1159 return moveCursor();
1199 case CURSOR_E_RESIZE: 1160 case CURSOR_E_RESIZE:
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1255 case CURSOR_WEBKIT_ZOOM_OUT: 1216 case CURSOR_WEBKIT_ZOOM_OUT:
1256 return zoomOutCursor(); 1217 return zoomOutCursor();
1257 case CURSOR_WEBKIT_GRAB: 1218 case CURSOR_WEBKIT_GRAB:
1258 return grabCursor(); 1219 return grabCursor();
1259 case CURSOR_WEBKIT_GRABBING: 1220 case CURSOR_WEBKIT_GRABBING:
1260 return grabbingCursor(); 1221 return grabbingCursor();
1261 } 1222 }
1262 return pointerCursor(); 1223 return pointerCursor();
1263 } 1224 }
1264 1225
1265 OptionalCursor EventHandler::selectAutoCursor(const HitTestResult& result, Node* node, const Cursor& iBeam, bool shiftKey) 1226 OptionalCursor EventHandler::selectAutoCursor(const HitTestResult& result, Node* node, const Cursor& iBeam)
1266 { 1227 {
1267 bool editable = (node && node->rendererIsEditable()); 1228 bool editable = (node && node->rendererIsEditable());
1268 1229
1269 if (useHandCursor(node, result.isOverLink(), shiftKey)) 1230 if (useHandCursor(node, result.isOverLink()))
1270 return handCursor(); 1231 return handCursor();
1271 1232
1272 bool inResizer = false; 1233 bool inResizer = false;
1273 RenderObject* renderer = node ? node->renderer() : 0; 1234 RenderObject* renderer = node ? node->renderer() : 0;
1274 if (renderer && m_frame->view()) { 1235 if (renderer && m_frame->view()) {
1275 RenderLayer* layer = renderer->enclosingLayer(); 1236 RenderLayer* layer = renderer->enclosingLayer();
1276 inResizer = layer->scrollableArea() && layer->scrollableArea()->isPointI nResizeControl(result.roundedPointInMainFrame(), ResizerForPointer); 1237 inResizer = layer->scrollableArea() && layer->scrollableArea()->isPointI nResizeControl(result.roundedPointInMainFrame(), ResizerForPointer);
1277 } 1238 }
1278 1239
1279 // During selection, use an I-beam no matter what we're over. 1240 // During selection, use an I-beam no matter what we're over.
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1585 updateMouseEventTargetNode(mev.targetNode(), mouseEvent, true); 1546 updateMouseEventTargetNode(mev.targetNode(), mouseEvent, true);
1586 1547
1587 // Event dispatch in updateMouseEventTargetNode may have caused the subf rame of the target 1548 // Event dispatch in updateMouseEventTargetNode may have caused the subf rame of the target
1588 // node to be detached from its FrameView, in which case the event shoul d not be passed. 1549 // node to be detached from its FrameView, in which case the event shoul d not be passed.
1589 if (newSubframe->view()) 1550 if (newSubframe->view())
1590 swallowEvent |= passMouseMoveEventToSubframe(mev, newSubframe.get(), hoveredNode); 1551 swallowEvent |= passMouseMoveEventToSubframe(mev, newSubframe.get(), hoveredNode);
1591 } else { 1552 } else {
1592 if (scrollbar && !m_mousePressed) 1553 if (scrollbar && !m_mousePressed)
1593 scrollbar->mouseMoved(mouseEvent); // Handle hover effects on platfo rms that support visual feedback on scrollbar hovering. 1554 scrollbar->mouseMoved(mouseEvent); // Handle hover effects on platfo rms that support visual feedback on scrollbar hovering.
1594 if (FrameView* view = m_frame->view()) { 1555 if (FrameView* view = m_frame->view()) {
1595 OptionalCursor optionalCursor = selectCursor(mev.hitTestResult(), mo useEvent.shiftKey()); 1556 OptionalCursor optionalCursor = selectCursor(mev.hitTestResult());
1596 if (optionalCursor.isCursorChange()) { 1557 if (optionalCursor.isCursorChange()) {
1597 m_currentMouseCursor = optionalCursor.cursor(); 1558 m_currentMouseCursor = optionalCursor.cursor();
1598 view->setCursor(m_currentMouseCursor); 1559 view->setCursor(m_currentMouseCursor);
1599 } 1560 }
1600 } 1561 }
1601 } 1562 }
1602 1563
1603 m_lastMouseMoveEventSubframe = newSubframe; 1564 m_lastMouseMoveEventSubframe = newSubframe;
1604 1565
1605 if (swallowEvent) 1566 if (swallowEvent)
(...skipping 2429 matching lines...) Expand 10 before | Expand all | Expand 10 after
4035 unsigned EventHandler::accessKeyModifiers() 3996 unsigned EventHandler::accessKeyModifiers()
4036 { 3997 {
4037 #if OS(MACOSX) 3998 #if OS(MACOSX)
4038 return PlatformEvent::CtrlKey | PlatformEvent::AltKey; 3999 return PlatformEvent::CtrlKey | PlatformEvent::AltKey;
4039 #else 4000 #else
4040 return PlatformEvent::AltKey; 4001 return PlatformEvent::AltKey;
4041 #endif 4002 #endif
4042 } 4003 }
4043 4004
4044 } // namespace WebCore 4005 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/page/EventHandler.h ('k') | Source/web/WebSettingsImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698