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 20 matching lines...) Expand all Loading... |
31 #include "config.h" | 31 #include "config.h" |
32 #include "web/WebViewImpl.h" | 32 #include "web/WebViewImpl.h" |
33 | 33 |
34 #include "core/CSSValueKeywords.h" | 34 #include "core/CSSValueKeywords.h" |
35 #include "core/HTMLNames.h" | 35 #include "core/HTMLNames.h" |
36 #include "core/InputTypeNames.h" | 36 #include "core/InputTypeNames.h" |
37 #include "core/clipboard/DataObject.h" | 37 #include "core/clipboard/DataObject.h" |
38 #include "core/dom/Document.h" | 38 #include "core/dom/Document.h" |
39 #include "core/dom/DocumentMarkerController.h" | 39 #include "core/dom/DocumentMarkerController.h" |
40 #include "core/dom/Fullscreen.h" | 40 #include "core/dom/Fullscreen.h" |
41 #include "core/dom/NodeRenderingTraversal.h" | 41 #include "core/dom/LayoutTreeBuilderTraversal.h" |
42 #include "core/dom/Text.h" | 42 #include "core/dom/Text.h" |
43 #include "core/editing/Editor.h" | 43 #include "core/editing/Editor.h" |
44 #include "core/editing/FrameSelection.h" | 44 #include "core/editing/FrameSelection.h" |
45 #include "core/editing/HTMLInterchange.h" | 45 #include "core/editing/HTMLInterchange.h" |
46 #include "core/editing/InputMethodController.h" | 46 #include "core/editing/InputMethodController.h" |
47 #include "core/editing/iterators/TextIterator.h" | 47 #include "core/editing/iterators/TextIterator.h" |
48 #include "core/editing/markup.h" | 48 #include "core/editing/markup.h" |
49 #include "core/events/KeyboardEvent.h" | 49 #include "core/events/KeyboardEvent.h" |
50 #include "core/events/UIEventWithKeyState.h" | 50 #include "core/events/UIEventWithKeyState.h" |
51 #include "core/events/WheelEvent.h" | 51 #include "core/events/WheelEvent.h" |
(...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1143 IntPoint point = mainFrameImpl()->frameView()->rootFrameToContents(IntPoint(
pointInRootFrame.x, pointInRootFrame.y)); | 1143 IntPoint point = mainFrameImpl()->frameView()->rootFrameToContents(IntPoint(
pointInRootFrame.x, pointInRootFrame.y)); |
1144 HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitT
estRequest::Active | (ignoreClipping ? HitTestRequest::IgnoreClipping : 0); | 1144 HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitT
estRequest::Active | (ignoreClipping ? HitTestRequest::IgnoreClipping : 0); |
1145 HitTestResult result = mainFrameImpl()->frame()->eventHandler().hitTestResul
tAtPoint(point, hitType); | 1145 HitTestResult result = mainFrameImpl()->frame()->eventHandler().hitTestResul
tAtPoint(point, hitType); |
1146 result.setToShadowHostIfInClosedShadowRoot(); | 1146 result.setToShadowHostIfInClosedShadowRoot(); |
1147 | 1147 |
1148 Node* node = result.innerNonSharedNode(); | 1148 Node* node = result.innerNonSharedNode(); |
1149 if (!node) | 1149 if (!node) |
1150 return WebRect(); | 1150 return WebRect(); |
1151 | 1151 |
1152 // Find the block type node based on the hit node. | 1152 // Find the block type node based on the hit node. |
1153 // FIXME: This wants to walk composed tree with NodeRenderingTraversal::pare
nt(). | 1153 // FIXME: This wants to walk composed tree with LayoutTreeBuilderTraversal::
parent(). |
1154 while (node && (!node->layoutObject() || node->layoutObject()->isInline())) | 1154 while (node && (!node->layoutObject() || node->layoutObject()->isInline())) |
1155 node = NodeRenderingTraversal::parent(*node); | 1155 node = LayoutTreeBuilderTraversal::parent(*node); |
1156 | 1156 |
1157 // Return the bounding box in the root frame's coordinate space. | 1157 // Return the bounding box in the root frame's coordinate space. |
1158 if (node) { | 1158 if (node) { |
1159 IntRect pointInRootFrame = node->Node::pixelSnappedBoundingBox(); | 1159 IntRect pointInRootFrame = node->Node::pixelSnappedBoundingBox(); |
1160 LocalFrame* frame = node->document().frame(); | 1160 LocalFrame* frame = node->document().frame(); |
1161 return frame->view()->contentsToRootFrame(pointInRootFrame); | 1161 return frame->view()->contentsToRootFrame(pointInRootFrame); |
1162 } | 1162 } |
1163 return WebRect(); | 1163 return WebRect(); |
1164 } | 1164 } |
1165 | 1165 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1268 | 1268 |
1269 static Node* findCursorDefiningAncestor(Node* node, LocalFrame* frame) | 1269 static Node* findCursorDefiningAncestor(Node* node, LocalFrame* frame) |
1270 { | 1270 { |
1271 // Go up the tree to find the node that defines a mouse cursor style | 1271 // Go up the tree to find the node that defines a mouse cursor style |
1272 while (node) { | 1272 while (node) { |
1273 if (node->layoutObject()) { | 1273 if (node->layoutObject()) { |
1274 ECursor cursor = node->layoutObject()->style()->cursor(); | 1274 ECursor cursor = node->layoutObject()->style()->cursor(); |
1275 if (cursor != CURSOR_AUTO || frame->eventHandler().useHandCursor(nod
e, node->isLink())) | 1275 if (cursor != CURSOR_AUTO || frame->eventHandler().useHandCursor(nod
e, node->isLink())) |
1276 break; | 1276 break; |
1277 } | 1277 } |
1278 node = NodeRenderingTraversal::parent(*node); | 1278 node = LayoutTreeBuilderTraversal::parent(*node); |
1279 } | 1279 } |
1280 | 1280 |
1281 return node; | 1281 return node; |
1282 } | 1282 } |
1283 | 1283 |
1284 static bool showsHandCursor(Node* node, LocalFrame* frame) | 1284 static bool showsHandCursor(Node* node, LocalFrame* frame) |
1285 { | 1285 { |
1286 if (!node || !node->layoutObject()) | 1286 if (!node || !node->layoutObject()) |
1287 return false; | 1287 return false; |
1288 | 1288 |
1289 ECursor cursor = node->layoutObject()->style()->cursor(); | 1289 ECursor cursor = node->layoutObject()->style()->cursor(); |
1290 return cursor == CURSOR_POINTER | 1290 return cursor == CURSOR_POINTER |
1291 || (cursor == CURSOR_AUTO && frame->eventHandler().useHandCursor(node, n
ode->isLink())); | 1291 || (cursor == CURSOR_AUTO && frame->eventHandler().useHandCursor(node, n
ode->isLink())); |
1292 } | 1292 } |
1293 | 1293 |
1294 Node* WebViewImpl::bestTapNode(const GestureEventWithHitTestResults& targetedTap
Event) | 1294 Node* WebViewImpl::bestTapNode(const GestureEventWithHitTestResults& targetedTap
Event) |
1295 { | 1295 { |
1296 TRACE_EVENT0("input", "WebViewImpl::bestTapNode"); | 1296 TRACE_EVENT0("input", "WebViewImpl::bestTapNode"); |
1297 | 1297 |
1298 if (!m_page || !m_page->mainFrame()) | 1298 if (!m_page || !m_page->mainFrame()) |
1299 return 0; | 1299 return 0; |
1300 | 1300 |
1301 Node* bestTouchNode = targetedTapEvent.hitTestResult().innerNode(); | 1301 Node* bestTouchNode = targetedTapEvent.hitTestResult().innerNode(); |
1302 if (!bestTouchNode) | 1302 if (!bestTouchNode) |
1303 return nullptr; | 1303 return nullptr; |
1304 | 1304 |
1305 // We might hit something like an image map that has no renderer on it | 1305 // We might hit something like an image map that has no renderer on it |
1306 // Walk up the tree until we have a node with an attached renderer | 1306 // Walk up the tree until we have a node with an attached renderer |
1307 while (!bestTouchNode->layoutObject()) { | 1307 while (!bestTouchNode->layoutObject()) { |
1308 bestTouchNode = NodeRenderingTraversal::parent(*bestTouchNode); | 1308 bestTouchNode = LayoutTreeBuilderTraversal::parent(*bestTouchNode); |
1309 if (!bestTouchNode) | 1309 if (!bestTouchNode) |
1310 return nullptr; | 1310 return nullptr; |
1311 } | 1311 } |
1312 | 1312 |
1313 // Editable nodes should not be highlighted (e.g., <input>) | 1313 // Editable nodes should not be highlighted (e.g., <input>) |
1314 if (bestTouchNode->hasEditableStyle()) | 1314 if (bestTouchNode->hasEditableStyle()) |
1315 return nullptr; | 1315 return nullptr; |
1316 | 1316 |
1317 Node* cursorDefiningAncestor = | 1317 Node* cursorDefiningAncestor = |
1318 findCursorDefiningAncestor(bestTouchNode, m_page->deprecatedLocalMainFra
me()); | 1318 findCursorDefiningAncestor(bestTouchNode, m_page->deprecatedLocalMainFra
me()); |
1319 // We show a highlight on tap only when the current node shows a hand cursor | 1319 // We show a highlight on tap only when the current node shows a hand cursor |
1320 if (!cursorDefiningAncestor || !showsHandCursor(cursorDefiningAncestor, m_pa
ge->deprecatedLocalMainFrame())) { | 1320 if (!cursorDefiningAncestor || !showsHandCursor(cursorDefiningAncestor, m_pa
ge->deprecatedLocalMainFrame())) { |
1321 return 0; | 1321 return 0; |
1322 } | 1322 } |
1323 | 1323 |
1324 // We should pick the largest enclosing node with hand cursor set. We do thi
s by first jumping | 1324 // We should pick the largest enclosing node with hand cursor set. We do thi
s by first jumping |
1325 // up to cursorDefiningAncestor (which is already known to have hand cursor
set). Then we locate | 1325 // up to cursorDefiningAncestor (which is already known to have hand cursor
set). Then we locate |
1326 // the next cursor-defining ancestor up in the the tree and repeat the jumps
as long as the node | 1326 // the next cursor-defining ancestor up in the the tree and repeat the jumps
as long as the node |
1327 // has hand cursor set. | 1327 // has hand cursor set. |
1328 do { | 1328 do { |
1329 bestTouchNode = cursorDefiningAncestor; | 1329 bestTouchNode = cursorDefiningAncestor; |
1330 cursorDefiningAncestor = findCursorDefiningAncestor(NodeRenderingTravers
al::parent(*bestTouchNode), | 1330 cursorDefiningAncestor = findCursorDefiningAncestor(LayoutTreeBuilderTra
versal::parent(*bestTouchNode), |
1331 m_page->deprecatedLocalMainFrame()); | 1331 m_page->deprecatedLocalMainFrame()); |
1332 } while (cursorDefiningAncestor && showsHandCursor(cursorDefiningAncestor, m
_page->deprecatedLocalMainFrame())); | 1332 } while (cursorDefiningAncestor && showsHandCursor(cursorDefiningAncestor, m
_page->deprecatedLocalMainFrame())); |
1333 | 1333 |
1334 return bestTouchNode; | 1334 return bestTouchNode; |
1335 } | 1335 } |
1336 | 1336 |
1337 void WebViewImpl::enableTapHighlightAtPoint(const GestureEventWithHitTestResults
& targetedTapEvent) | 1337 void WebViewImpl::enableTapHighlightAtPoint(const GestureEventWithHitTestResults
& targetedTapEvent) |
1338 { | 1338 { |
1339 Node* touchNode = bestTapNode(targetedTapEvent); | 1339 Node* touchNode = bestTapNode(targetedTapEvent); |
1340 | 1340 |
(...skipping 3074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4415 | 4415 |
4416 if (touchHit.isContentEditable()) | 4416 if (touchHit.isContentEditable()) |
4417 return false; | 4417 return false; |
4418 | 4418 |
4419 Node* node = touchHit.innerNode(); | 4419 Node* node = touchHit.innerNode(); |
4420 if (!node || !node->isTextNode()) | 4420 if (!node || !node->isTextNode()) |
4421 return false; | 4421 return false; |
4422 | 4422 |
4423 // Ignore when tapping on links or nodes listening to click events, unless t
he click event is on the | 4423 // Ignore when tapping on links or nodes listening to click events, unless t
he click event is on the |
4424 // body element, in which case it's unlikely that the original node itself w
as intended to be clickable. | 4424 // body element, in which case it's unlikely that the original node itself w
as intended to be clickable. |
4425 for (; node && !isHTMLBodyElement(*node); node = NodeRenderingTraversal::par
ent(*node)) { | 4425 for (; node && !isHTMLBodyElement(*node); node = LayoutTreeBuilderTraversal:
:parent(*node)) { |
4426 if (node->isLink() || node->willRespondToTouchEvents() || node->willResp
ondToMouseClickEvents()) | 4426 if (node->isLink() || node->willRespondToTouchEvents() || node->willResp
ondToMouseClickEvents()) |
4427 return false; | 4427 return false; |
4428 } | 4428 } |
4429 | 4429 |
4430 WebContentDetectionResult content = m_client->detectContentAround(touchHit); | 4430 WebContentDetectionResult content = m_client->detectContentAround(touchHit); |
4431 if (!content.isValid()) | 4431 if (!content.isValid()) |
4432 return false; | 4432 return false; |
4433 | 4433 |
4434 m_client->scheduleContentIntent(content.intent()); | 4434 m_client->scheduleContentIntent(content.intent()); |
4435 return true; | 4435 return true; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4512 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width | 4512 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width |
4513 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); | 4513 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); |
4514 } | 4514 } |
4515 | 4515 |
4516 void WebViewImpl::forceNextWebGLContextCreationToFail() | 4516 void WebViewImpl::forceNextWebGLContextCreationToFail() |
4517 { | 4517 { |
4518 WebGLRenderingContext::forceNextWebGLContextCreationToFail(); | 4518 WebGLRenderingContext::forceNextWebGLContextCreationToFail(); |
4519 } | 4519 } |
4520 | 4520 |
4521 } // namespace blink | 4521 } // namespace blink |
OLD | NEW |