OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
487 | 487 |
488 m_lastMouseDownPoint = WebPoint(event.x, event.y); | 488 m_lastMouseDownPoint = WebPoint(event.x, event.y); |
489 | 489 |
490 // Take capture on a mouse down on a plugin so we can send it mouse events. | 490 // Take capture on a mouse down on a plugin so we can send it mouse events. |
491 // If the hit node is a plugin but a scrollbar is over it don't start mouse | 491 // If the hit node is a plugin but a scrollbar is over it don't start mouse |
492 // capture because it will interfere with the scrollbar receiving events. | 492 // capture because it will interfere with the scrollbar receiving events. |
493 IntPoint point(event.x, event.y); | 493 IntPoint point(event.x, event.y); |
494 if (event.button == WebMouseEvent::ButtonLeft && m_page->mainFrame()->isLoca lFrame() && !m_page->deprecatedLocalMainFrame()->view()->scrollbarAtPoint(point) ) { | 494 if (event.button == WebMouseEvent::ButtonLeft && m_page->mainFrame()->isLoca lFrame() && !m_page->deprecatedLocalMainFrame()->view()->scrollbarAtPoint(point) ) { |
495 point = m_page->deprecatedLocalMainFrame()->view()->windowToContents(poi nt); | 495 point = m_page->deprecatedLocalMainFrame()->view()->windowToContents(poi nt); |
496 HitTestResult result(m_page->deprecatedLocalMainFrame()->eventHandler(). hitTestResultAtPoint(point)); | 496 HitTestResult result(m_page->deprecatedLocalMainFrame()->eventHandler(). hitTestResultAtPoint(point)); |
497 result.setToShadowHostIfInUserAgentShadowRoot(); | |
497 Node* hitNode = result.innerNonSharedNode(); | 498 Node* hitNode = result.innerNonSharedNode(); |
498 | 499 |
499 if (!result.scrollbar() && hitNode && hitNode->renderer() && hitNode->re nderer()->isEmbeddedObject()) { | 500 if (!result.scrollbar() && hitNode && hitNode->renderer() && hitNode->re nderer()->isEmbeddedObject()) { |
500 m_mouseCaptureNode = hitNode; | 501 m_mouseCaptureNode = hitNode; |
501 TRACE_EVENT_ASYNC_BEGIN0("input", "capturing mouse", this); | 502 TRACE_EVENT_ASYNC_BEGIN0("input", "capturing mouse", this); |
502 } | 503 } |
503 } | 504 } |
504 | 505 |
505 PageWidgetEventHandler::handleMouseDown(mainFrame, event); | 506 PageWidgetEventHandler::handleMouseDown(mainFrame, event); |
506 | 507 |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1037 | 1038 |
1038 WebRect WebViewImpl::computeBlockBounds(const WebRect& rect, bool ignoreClipping ) | 1039 WebRect WebViewImpl::computeBlockBounds(const WebRect& rect, bool ignoreClipping ) |
1039 { | 1040 { |
1040 if (!mainFrameImpl()) | 1041 if (!mainFrameImpl()) |
1041 return WebRect(); | 1042 return WebRect(); |
1042 | 1043 |
1043 // Use the rect-based hit test to find the node. | 1044 // Use the rect-based hit test to find the node. |
1044 IntPoint point = mainFrameImpl()->frameView()->windowToContents(IntPoint(rec t.x, rect.y)); | 1045 IntPoint point = mainFrameImpl()->frameView()->windowToContents(IntPoint(rec t.x, rect.y)); |
1045 HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitT estRequest::Active | (ignoreClipping ? HitTestRequest::IgnoreClipping : 0); | 1046 HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitT estRequest::Active | (ignoreClipping ? HitTestRequest::IgnoreClipping : 0); |
1046 HitTestResult result = mainFrameImpl()->frame()->eventHandler().hitTestResul tAtPoint(point, hitType, IntSize(rect.width, rect.height)); | 1047 HitTestResult result = mainFrameImpl()->frame()->eventHandler().hitTestResul tAtPoint(point, hitType, IntSize(rect.width, rect.height)); |
1048 result.setToShadowHostIfInUserAgentShadowRoot(); | |
1047 | 1049 |
1048 Node* node = result.innerNonSharedNode(); | 1050 Node* node = result.innerNonSharedNode(); |
1049 if (!node) | 1051 if (!node) |
1050 return WebRect(); | 1052 return WebRect(); |
1051 | 1053 |
1052 // Find the block type node based on the hit node. | 1054 // Find the block type node based on the hit node. |
1055 // FIXME: This wants to walk composed tree with NodeRenderingTraversal::pare nt(). | |
1053 while (node && (!node->renderer() || node->renderer()->isInline())) | 1056 while (node && (!node->renderer() || node->renderer()->isInline())) |
1054 node = node->parentNode(); | 1057 node = node->parentNode(); |
1055 | 1058 |
1056 // Return the bounding box in the window coordinate system. | 1059 // Return the bounding box in the window coordinate system. |
1057 if (node) { | 1060 if (node) { |
1058 IntRect rect = node->Node::pixelSnappedBoundingBox(); | 1061 IntRect rect = node->Node::pixelSnappedBoundingBox(); |
1059 LocalFrame* frame = node->document().frame(); | 1062 LocalFrame* frame = node->document().frame(); |
1060 return frame->view()->contentsToWindow(rect); | 1063 return frame->view()->contentsToWindow(rect); |
1061 } | 1064 } |
1062 return WebRect(); | 1065 return WebRect(); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1168 | 1171 |
1169 static Node* findCursorDefiningAncestor(Node* node, LocalFrame* frame) | 1172 static Node* findCursorDefiningAncestor(Node* node, LocalFrame* frame) |
1170 { | 1173 { |
1171 // Go up the tree to find the node that defines a mouse cursor style | 1174 // Go up the tree to find the node that defines a mouse cursor style |
1172 while (node) { | 1175 while (node) { |
1173 if (node->renderer()) { | 1176 if (node->renderer()) { |
1174 ECursor cursor = node->renderer()->style()->cursor(); | 1177 ECursor cursor = node->renderer()->style()->cursor(); |
1175 if (cursor != CURSOR_AUTO || frame->eventHandler().useHandCursor(nod e, node->isLink())) | 1178 if (cursor != CURSOR_AUTO || frame->eventHandler().useHandCursor(nod e, node->isLink())) |
1176 break; | 1179 break; |
1177 } | 1180 } |
1181 // FIXME: This wants to walk composed tree with NodeRenderingTraversal:: parent(). | |
Rick Byers
2014/08/15 18:10:57
Sorry about this - I just asked for it to be fixed
Rick Byers
2014/08/27 20:35:10
You'll need to merge with trunk and remove this co
| |
1178 node = node->parentNode(); | 1182 node = node->parentNode(); |
1179 } | 1183 } |
1180 | 1184 |
1181 return node; | 1185 return node; |
1182 } | 1186 } |
1183 | 1187 |
1184 static bool showsHandCursor(Node* node, LocalFrame* frame) | 1188 static bool showsHandCursor(Node* node, LocalFrame* frame) |
1185 { | 1189 { |
1186 if (!node || !node->renderer()) | 1190 if (!node || !node->renderer()) |
1187 return false; | 1191 return false; |
(...skipping 10 matching lines...) Expand all Loading... | |
1198 if (!m_page || !m_page->mainFrame()) | 1202 if (!m_page || !m_page->mainFrame()) |
1199 return 0; | 1203 return 0; |
1200 | 1204 |
1201 // FIXME: Rely on earlier hit test instead of hit testing again. | 1205 // FIXME: Rely on earlier hit test instead of hit testing again. |
1202 GestureEventWithHitTestResults targetedEvent = | 1206 GestureEventWithHitTestResults targetedEvent = |
1203 m_page->deprecatedLocalMainFrame()->eventHandler().targetGestureEvent(ta pEvent, true); | 1207 m_page->deprecatedLocalMainFrame()->eventHandler().targetGestureEvent(ta pEvent, true); |
1204 Node* bestTouchNode = targetedEvent.hitTestResult().targetNode(); | 1208 Node* bestTouchNode = targetedEvent.hitTestResult().targetNode(); |
1205 | 1209 |
1206 // We might hit something like an image map that has no renderer on it | 1210 // We might hit something like an image map that has no renderer on it |
1207 // Walk up the tree until we have a node with an attached renderer | 1211 // Walk up the tree until we have a node with an attached renderer |
1212 // FIXME: This wants to walk composed tree with NodeRenderingTraversal::pare nt(). | |
Rick Byers
2014/08/27 20:35:10
ditto
| |
1208 while (bestTouchNode && !bestTouchNode->renderer()) | 1213 while (bestTouchNode && !bestTouchNode->renderer()) |
1209 bestTouchNode = bestTouchNode->parentNode(); | 1214 bestTouchNode = bestTouchNode->parentNode(); |
1210 | 1215 |
1211 Node* cursorDefiningAncestor = | 1216 Node* cursorDefiningAncestor = |
1212 findCursorDefiningAncestor(bestTouchNode, m_page->deprecatedLocalMainFra me()); | 1217 findCursorDefiningAncestor(bestTouchNode, m_page->deprecatedLocalMainFra me()); |
1213 // We show a highlight on tap only when the current node shows a hand cursor | 1218 // We show a highlight on tap only when the current node shows a hand cursor |
1214 if (!cursorDefiningAncestor || !showsHandCursor(cursorDefiningAncestor, m_pa ge->deprecatedLocalMainFrame())) { | 1219 if (!cursorDefiningAncestor || !showsHandCursor(cursorDefiningAncestor, m_pa ge->deprecatedLocalMainFrame())) { |
1215 return 0; | 1220 return 0; |
1216 } | 1221 } |
1217 | 1222 |
1218 // We should pick the largest enclosing node with hand cursor set. We do thi s by first jumping | 1223 // We should pick the largest enclosing node with hand cursor set. We do thi s by first jumping |
1219 // up to cursorDefiningAncestor (which is already known to have hand cursor set). Then we locate | 1224 // up to cursorDefiningAncestor (which is already known to have hand cursor set). Then we locate |
1220 // the next cursor-defining ancestor up in the the tree and repeat the jumps as long as the node | 1225 // the next cursor-defining ancestor up in the the tree and repeat the jumps as long as the node |
1221 // has hand cursor set. | 1226 // has hand cursor set. |
1222 do { | 1227 do { |
1223 bestTouchNode = cursorDefiningAncestor; | 1228 bestTouchNode = cursorDefiningAncestor; |
1229 // FIXME: This wants to walk composed tree with NodeRenderingTraversal:: parent(). | |
Rick Byers
2014/08/27 20:35:10
ditto
| |
1224 cursorDefiningAncestor = findCursorDefiningAncestor(bestTouchNode->paren tNode(), m_page->deprecatedLocalMainFrame()); | 1230 cursorDefiningAncestor = findCursorDefiningAncestor(bestTouchNode->paren tNode(), m_page->deprecatedLocalMainFrame()); |
1225 } while (cursorDefiningAncestor && showsHandCursor(cursorDefiningAncestor, m _page->deprecatedLocalMainFrame())); | 1231 } while (cursorDefiningAncestor && showsHandCursor(cursorDefiningAncestor, m _page->deprecatedLocalMainFrame())); |
1226 | 1232 |
1227 return bestTouchNode; | 1233 return bestTouchNode; |
1228 } | 1234 } |
1229 | 1235 |
1230 void WebViewImpl::enableTapHighlightAtPoint(const PlatformGestureEvent& tapEvent ) | 1236 void WebViewImpl::enableTapHighlightAtPoint(const PlatformGestureEvent& tapEvent ) |
1231 { | 1237 { |
1232 Node* touchNode = bestTapNode(tapEvent); | 1238 Node* touchNode = bestTapNode(tapEvent); |
1233 | 1239 |
(...skipping 2626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3860 return 0; | 3866 return 0; |
3861 | 3867 |
3862 return document->focusedElement(); | 3868 return document->focusedElement(); |
3863 } | 3869 } |
3864 | 3870 |
3865 HitTestResult WebViewImpl::hitTestResultForWindowPos(const IntPoint& pos) | 3871 HitTestResult WebViewImpl::hitTestResultForWindowPos(const IntPoint& pos) |
3866 { | 3872 { |
3867 if (!m_page->mainFrame()->isLocalFrame()) | 3873 if (!m_page->mainFrame()->isLocalFrame()) |
3868 return HitTestResult(); | 3874 return HitTestResult(); |
3869 IntPoint docPoint(m_page->deprecatedLocalMainFrame()->view()->windowToConten ts(pos)); | 3875 IntPoint docPoint(m_page->deprecatedLocalMainFrame()->view()->windowToConten ts(pos)); |
3870 return m_page->deprecatedLocalMainFrame()->eventHandler().hitTestResultAtPoi nt(docPoint, HitTestRequest::ReadOnly | HitTestRequest::Active); | 3876 HitTestResult result = m_page->deprecatedLocalMainFrame()->eventHandler().hi tTestResultAtPoint(docPoint, HitTestRequest::ReadOnly | HitTestRequest::Active); |
3877 result.setToShadowHostIfInUserAgentShadowRoot(); | |
Rick Byers
2014/08/15 18:10:57
Are you sure we want this for all callers of this
esprehn
2014/08/16 04:14:58
Looking at the callers of this method, and their t
| |
3878 return result; | |
3871 } | 3879 } |
3872 | 3880 |
3873 void WebViewImpl::setTabsToLinks(bool enable) | 3881 void WebViewImpl::setTabsToLinks(bool enable) |
3874 { | 3882 { |
3875 m_tabsToLinks = enable; | 3883 m_tabsToLinks = enable; |
3876 } | 3884 } |
3877 | 3885 |
3878 bool WebViewImpl::tabsToLinks() const | 3886 bool WebViewImpl::tabsToLinks() const |
3879 { | 3887 { |
3880 return m_tabsToLinks; | 3888 return m_tabsToLinks; |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4259 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); | 4267 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); |
4260 | 4268 |
4261 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) | 4269 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) |
4262 return false; | 4270 return false; |
4263 | 4271 |
4264 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width | 4272 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width |
4265 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); | 4273 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); |
4266 } | 4274 } |
4267 | 4275 |
4268 } // namespace blink | 4276 } // namespace blink |
OLD | NEW |