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 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1117 else | 1117 else |
1118 rect.x = max<float>(rect.x, hitPoint.x + padding - screenWidth); | 1118 rect.x = max<float>(rect.x, hitPoint.x + padding - screenWidth); |
1119 scroll.x = rect.x; | 1119 scroll.x = rect.x; |
1120 scroll.y = rect.y; | 1120 scroll.y = rect.y; |
1121 | 1121 |
1122 scale = clampPageScaleFactorToLimits(scale); | 1122 scale = clampPageScaleFactorToLimits(scale); |
1123 scroll = mainFrameImpl()->frameView()->windowToContents(scroll); | 1123 scroll = mainFrameImpl()->frameView()->windowToContents(scroll); |
1124 scroll = clampOffsetAtScale(scroll, scale); | 1124 scroll = clampOffsetAtScale(scroll, scale); |
1125 } | 1125 } |
1126 | 1126 |
1127 static bool invokesHandCursor(Node* node, bool shiftKey, LocalFrame* frame) | 1127 static bool invokesHandCursor(Node* node, LocalFrame* frame) |
1128 { | 1128 { |
1129 if (!node || !node->renderer()) | 1129 if (!node || !node->renderer()) |
1130 return false; | 1130 return false; |
1131 | 1131 |
1132 ECursor cursor = node->renderer()->style()->cursor(); | 1132 ECursor cursor = node->renderer()->style()->cursor(); |
1133 return cursor == CURSOR_POINTER | 1133 return cursor == CURSOR_POINTER |
1134 || (cursor == CURSOR_AUTO && frame->eventHandler().useHandCursor(node, n
ode->isLink(), shiftKey)); | 1134 || (cursor == CURSOR_AUTO && frame->eventHandler().useHandCursor(node, n
ode->isLink())); |
1135 } | 1135 } |
1136 | 1136 |
1137 Node* WebViewImpl::bestTapNode(const PlatformGestureEvent& tapEvent) | 1137 Node* WebViewImpl::bestTapNode(const PlatformGestureEvent& tapEvent) |
1138 { | 1138 { |
1139 if (!m_page || !m_page->mainFrame()) | 1139 if (!m_page || !m_page->mainFrame()) |
1140 return 0; | 1140 return 0; |
1141 | 1141 |
1142 Node* bestTouchNode = 0; | 1142 Node* bestTouchNode = 0; |
1143 | 1143 |
1144 IntPoint touchEventLocation(tapEvent.position()); | 1144 IntPoint touchEventLocation(tapEvent.position()); |
1145 m_page->mainFrame()->eventHandler().adjustGesturePosition(tapEvent, touchEve
ntLocation); | 1145 m_page->mainFrame()->eventHandler().adjustGesturePosition(tapEvent, touchEve
ntLocation); |
1146 | 1146 |
1147 IntPoint hitTestPoint = m_page->mainFrame()->view()->windowToContents(touchE
ventLocation); | 1147 IntPoint hitTestPoint = m_page->mainFrame()->view()->windowToContents(touchE
ventLocation); |
1148 HitTestResult result = m_page->mainFrame()->eventHandler().hitTestResultAtPo
int(hitTestPoint, HitTestRequest::TouchEvent | HitTestRequest::ConfusingAndOften
MisusedDisallowShadowContent); | 1148 HitTestResult result = m_page->mainFrame()->eventHandler().hitTestResultAtPo
int(hitTestPoint, HitTestRequest::TouchEvent | HitTestRequest::ConfusingAndOften
MisusedDisallowShadowContent); |
1149 bestTouchNode = result.targetNode(); | 1149 bestTouchNode = result.targetNode(); |
1150 | 1150 |
1151 // We might hit something like an image map that has no renderer on it | 1151 // We might hit something like an image map that has no renderer on it |
1152 // Walk up the tree until we have a node with an attached renderer | 1152 // Walk up the tree until we have a node with an attached renderer |
1153 while (bestTouchNode && !bestTouchNode->renderer()) | 1153 while (bestTouchNode && !bestTouchNode->renderer()) |
1154 bestTouchNode = bestTouchNode->parentNode(); | 1154 bestTouchNode = bestTouchNode->parentNode(); |
1155 | 1155 |
1156 // Check if we're in the subtree of a node with a hand cursor | 1156 // Check if we're in the subtree of a node with a hand cursor |
1157 // this is the heuristic we use to determine if we show a highlight on tap | 1157 // this is the heuristic we use to determine if we show a highlight on tap |
1158 while (bestTouchNode && !invokesHandCursor(bestTouchNode, false, m_page->mai
nFrame())) | 1158 while (bestTouchNode && !invokesHandCursor(bestTouchNode, m_page->mainFrame(
))) |
1159 bestTouchNode = bestTouchNode->parentNode(); | 1159 bestTouchNode = bestTouchNode->parentNode(); |
1160 | 1160 |
1161 if (!bestTouchNode) | 1161 if (!bestTouchNode) |
1162 return 0; | 1162 return 0; |
1163 | 1163 |
1164 // We should pick the largest enclosing node with hand cursor set. | 1164 // We should pick the largest enclosing node with hand cursor set. |
1165 while (bestTouchNode->parentNode() && invokesHandCursor(bestTouchNode->paren
tNode(), false, m_page->mainFrame())) | 1165 while (bestTouchNode->parentNode() && invokesHandCursor(bestTouchNode->paren
tNode(), m_page->mainFrame())) |
1166 bestTouchNode = bestTouchNode->parentNode(); | 1166 bestTouchNode = bestTouchNode->parentNode(); |
1167 | 1167 |
1168 return bestTouchNode; | 1168 return bestTouchNode; |
1169 } | 1169 } |
1170 | 1170 |
1171 void WebViewImpl::enableTapHighlightAtPoint(const PlatformGestureEvent& tapEvent
) | 1171 void WebViewImpl::enableTapHighlightAtPoint(const PlatformGestureEvent& tapEvent
) |
1172 { | 1172 { |
1173 Node* touchNode = bestTapNode(tapEvent); | 1173 Node* touchNode = bestTapNode(tapEvent); |
1174 | 1174 |
1175 Vector<Node*> highlightNodes; | 1175 Vector<Node*> highlightNodes; |
(...skipping 2832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4008 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi
nedConstraints(); | 4008 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi
nedConstraints(); |
4009 | 4009 |
4010 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) | 4010 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) |
4011 return false; | 4011 return false; |
4012 | 4012 |
4013 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width | 4013 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width |
4014 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); | 4014 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); |
4015 } | 4015 } |
4016 | 4016 |
4017 } // namespace blink | 4017 } // namespace blink |
OLD | NEW |