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 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1042 IntPoint point = mainFrameImpl()->frameView()->windowToContents(IntPoint(rec
t.x, rect.y)); | 1042 IntPoint point = mainFrameImpl()->frameView()->windowToContents(IntPoint(rec
t.x, rect.y)); |
1043 HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitT
estRequest::Active | (ignoreClipping ? HitTestRequest::IgnoreClipping : 0); | 1043 HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitT
estRequest::Active | (ignoreClipping ? HitTestRequest::IgnoreClipping : 0); |
1044 HitTestResult result = mainFrameImpl()->frame()->eventHandler().hitTestResul
tAtPoint(point, hitType, IntSize(rect.width, rect.height)); | 1044 HitTestResult result = mainFrameImpl()->frame()->eventHandler().hitTestResul
tAtPoint(point, hitType, IntSize(rect.width, rect.height)); |
1045 | 1045 |
1046 Node* node = result.innerNonSharedNode(); | 1046 Node* node = result.innerNonSharedNode(); |
1047 if (!node) | 1047 if (!node) |
1048 return WebRect(); | 1048 return WebRect(); |
1049 | 1049 |
1050 // Find the block type node based on the hit node. | 1050 // Find the block type node based on the hit node. |
1051 while (node && (!node->renderer() || node->renderer()->isInline())) | 1051 while (node && (!node->renderer() || node->renderer()->isInline())) |
1052 node = node->parentNode(); | 1052 node = NodeRenderingTraversal::parent(node); |
1053 | 1053 |
1054 // Return the bounding box in the window coordinate system. | 1054 // Return the bounding box in the window coordinate system. |
1055 if (node) { | 1055 if (node) { |
1056 IntRect rect = node->Node::pixelSnappedBoundingBox(); | 1056 IntRect rect = node->Node::pixelSnappedBoundingBox(); |
1057 LocalFrame* frame = node->document().frame(); | 1057 LocalFrame* frame = node->document().frame(); |
1058 return frame->view()->contentsToWindow(rect); | 1058 return frame->view()->contentsToWindow(rect); |
1059 } | 1059 } |
1060 return WebRect(); | 1060 return WebRect(); |
1061 } | 1061 } |
1062 | 1062 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1166 | 1166 |
1167 static Node* findCursorDefiningAncestor(Node* node, LocalFrame* frame) | 1167 static Node* findCursorDefiningAncestor(Node* node, LocalFrame* frame) |
1168 { | 1168 { |
1169 // Go up the tree to find the node that defines a mouse cursor style | 1169 // Go up the tree to find the node that defines a mouse cursor style |
1170 while (node) { | 1170 while (node) { |
1171 if (node->renderer()) { | 1171 if (node->renderer()) { |
1172 ECursor cursor = node->renderer()->style()->cursor(); | 1172 ECursor cursor = node->renderer()->style()->cursor(); |
1173 if (cursor != CURSOR_AUTO || frame->eventHandler().useHandCursor(nod
e, node->isLink())) | 1173 if (cursor != CURSOR_AUTO || frame->eventHandler().useHandCursor(nod
e, node->isLink())) |
1174 break; | 1174 break; |
1175 } | 1175 } |
1176 node = node->parentNode(); | 1176 node = NodeRenderingTraversal::parent(node); |
1177 } | 1177 } |
1178 | 1178 |
1179 return node; | 1179 return node; |
1180 } | 1180 } |
1181 | 1181 |
1182 static bool showsHandCursor(Node* node, LocalFrame* frame) | 1182 static bool showsHandCursor(Node* node, LocalFrame* frame) |
1183 { | 1183 { |
1184 if (!node || !node->renderer()) | 1184 if (!node || !node->renderer()) |
1185 return false; | 1185 return false; |
1186 | 1186 |
(...skipping 10 matching lines...) Expand all Loading... |
1197 return 0; | 1197 return 0; |
1198 | 1198 |
1199 // FIXME: Rely on earlier hit test instead of hit testing again. | 1199 // FIXME: Rely on earlier hit test instead of hit testing again. |
1200 GestureEventWithHitTestResults targetedEvent = | 1200 GestureEventWithHitTestResults targetedEvent = |
1201 m_page->deprecatedLocalMainFrame()->eventHandler().targetGestureEvent(ta
pEvent, true); | 1201 m_page->deprecatedLocalMainFrame()->eventHandler().targetGestureEvent(ta
pEvent, true); |
1202 Node* bestTouchNode = targetedEvent.hitTestResult().targetNode(); | 1202 Node* bestTouchNode = targetedEvent.hitTestResult().targetNode(); |
1203 | 1203 |
1204 // We might hit something like an image map that has no renderer on it | 1204 // We might hit something like an image map that has no renderer on it |
1205 // Walk up the tree until we have a node with an attached renderer | 1205 // Walk up the tree until we have a node with an attached renderer |
1206 while (bestTouchNode && !bestTouchNode->renderer()) | 1206 while (bestTouchNode && !bestTouchNode->renderer()) |
1207 bestTouchNode = bestTouchNode->parentNode(); | 1207 bestTouchNode = NodeRenderingTraversal::parent(bestTouchNode); |
1208 | 1208 |
1209 Node* cursorDefiningAncestor = | 1209 Node* cursorDefiningAncestor = |
1210 findCursorDefiningAncestor(bestTouchNode, m_page->deprecatedLocalMainFra
me()); | 1210 findCursorDefiningAncestor(bestTouchNode, m_page->deprecatedLocalMainFra
me()); |
1211 // We show a highlight on tap only when the current node shows a hand cursor | 1211 // We show a highlight on tap only when the current node shows a hand cursor |
1212 if (!cursorDefiningAncestor || !showsHandCursor(cursorDefiningAncestor, m_pa
ge->deprecatedLocalMainFrame())) { | 1212 if (!cursorDefiningAncestor || !showsHandCursor(cursorDefiningAncestor, m_pa
ge->deprecatedLocalMainFrame())) { |
1213 return 0; | 1213 return 0; |
1214 } | 1214 } |
1215 | 1215 |
1216 // We should pick the largest enclosing node with hand cursor set. We do thi
s by first jumping | 1216 // We should pick the largest enclosing node with hand cursor set. We do thi
s by first jumping |
1217 // up to cursorDefiningAncestor (which is already known to have hand cursor
set). Then we locate | 1217 // up to cursorDefiningAncestor (which is already known to have hand cursor
set). Then we locate |
(...skipping 3040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4258 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi
nedConstraints(); | 4258 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi
nedConstraints(); |
4259 | 4259 |
4260 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) | 4260 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) |
4261 return false; | 4261 return false; |
4262 | 4262 |
4263 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width | 4263 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width |
4264 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); | 4264 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); |
4265 } | 4265 } |
4266 | 4266 |
4267 } // namespace blink | 4267 } // namespace blink |
OLD | NEW |