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 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 // Take capture on a mouse down on a plugin so we can send it mouse events. | 528 // Take capture on a mouse down on a plugin so we can send it mouse events. |
529 // If the hit node is a plugin but a scrollbar is over it don't start mouse | 529 // If the hit node is a plugin but a scrollbar is over it don't start mouse |
530 // capture because it will interfere with the scrollbar receiving events. | 530 // capture because it will interfere with the scrollbar receiving events. |
531 IntPoint point(event.x, event.y); | 531 IntPoint point(event.x, event.y); |
532 if (event.button == WebMouseEvent::ButtonLeft && m_page->mainFrame()->isLoca
lFrame()) { | 532 if (event.button == WebMouseEvent::ButtonLeft && m_page->mainFrame()->isLoca
lFrame()) { |
533 point = m_page->deprecatedLocalMainFrame()->view()->windowToContents(poi
nt); | 533 point = m_page->deprecatedLocalMainFrame()->view()->windowToContents(poi
nt); |
534 HitTestResult result(m_page->deprecatedLocalMainFrame()->eventHandler().
hitTestResultAtPoint(point)); | 534 HitTestResult result(m_page->deprecatedLocalMainFrame()->eventHandler().
hitTestResultAtPoint(point)); |
535 result.setToShadowHostIfInClosedShadowRoot(); | 535 result.setToShadowHostIfInClosedShadowRoot(); |
536 Node* hitNode = result.innerNonSharedNode(); | 536 Node* hitNode = result.innerNonSharedNode(); |
537 | 537 |
538 if (!result.scrollbar() && hitNode && hitNode->renderer() && hitNode->re
nderer()->isEmbeddedObject()) { | 538 if (!result.scrollbar() && hitNode && hitNode->layoutObject() && hitNode
->layoutObject()->isEmbeddedObject()) { |
539 m_mouseCaptureNode = hitNode; | 539 m_mouseCaptureNode = hitNode; |
540 TRACE_EVENT_ASYNC_BEGIN0("input", "capturing mouse", this); | 540 TRACE_EVENT_ASYNC_BEGIN0("input", "capturing mouse", this); |
541 } | 541 } |
542 } | 542 } |
543 | 543 |
544 PageWidgetEventHandler::handleMouseDown(mainFrame, event); | 544 PageWidgetEventHandler::handleMouseDown(mainFrame, event); |
545 | 545 |
546 if (event.button == WebMouseEvent::ButtonLeft && m_mouseCaptureNode) | 546 if (event.button == WebMouseEvent::ButtonLeft && m_mouseCaptureNode) |
547 m_mouseCaptureGestureToken = mainFrame.eventHandler().takeLastMouseDownG
estureToken(); | 547 m_mouseCaptureGestureToken = mainFrame.eventHandler().takeLastMouseDownG
estureToken(); |
548 | 548 |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1048 | 1048 |
1049 LocalFrame* frame = toLocalFrame(focusedFrame.get()); | 1049 LocalFrame* frame = toLocalFrame(focusedFrame.get()); |
1050 | 1050 |
1051 PlatformKeyboardEventBuilder evt(event); | 1051 PlatformKeyboardEventBuilder evt(event); |
1052 | 1052 |
1053 if (frame->eventHandler().keyEvent(evt)) { | 1053 if (frame->eventHandler().keyEvent(evt)) { |
1054 if (WebInputEvent::RawKeyDown == event.type) { | 1054 if (WebInputEvent::RawKeyDown == event.type) { |
1055 // Suppress the next keypress event unless the focused node is a plu
g-in node. | 1055 // Suppress the next keypress event unless the focused node is a plu
g-in node. |
1056 // (Flash needs these keypress events to handle non-US keyboards.) | 1056 // (Flash needs these keypress events to handle non-US keyboards.) |
1057 Element* element = focusedElement(); | 1057 Element* element = focusedElement(); |
1058 if (!element || !element->renderer() || !element->renderer()->isEmbe
ddedObject()) | 1058 if (!element || !element->layoutObject() || !element->layoutObject()
->isEmbeddedObject()) |
1059 m_suppressNextKeypressEvent = true; | 1059 m_suppressNextKeypressEvent = true; |
1060 } | 1060 } |
1061 return true; | 1061 return true; |
1062 } | 1062 } |
1063 | 1063 |
1064 #if !OS(MACOSX) | 1064 #if !OS(MACOSX) |
1065 const WebInputEvent::Type contextMenuTriggeringEventType = | 1065 const WebInputEvent::Type contextMenuTriggeringEventType = |
1066 #if OS(WIN) | 1066 #if OS(WIN) |
1067 WebInputEvent::KeyUp; | 1067 WebInputEvent::KeyUp; |
1068 #else | 1068 #else |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1136 HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitT
estRequest::Active | (ignoreClipping ? HitTestRequest::IgnoreClipping : 0); | 1136 HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitT
estRequest::Active | (ignoreClipping ? HitTestRequest::IgnoreClipping : 0); |
1137 HitTestResult result = mainFrameImpl()->frame()->eventHandler().hitTestResul
tAtPoint(point, hitType); | 1137 HitTestResult result = mainFrameImpl()->frame()->eventHandler().hitTestResul
tAtPoint(point, hitType); |
1138 result.setToShadowHostIfInClosedShadowRoot(); | 1138 result.setToShadowHostIfInClosedShadowRoot(); |
1139 | 1139 |
1140 Node* node = result.innerNonSharedNode(); | 1140 Node* node = result.innerNonSharedNode(); |
1141 if (!node) | 1141 if (!node) |
1142 return WebRect(); | 1142 return WebRect(); |
1143 | 1143 |
1144 // Find the block type node based on the hit node. | 1144 // Find the block type node based on the hit node. |
1145 // FIXME: This wants to walk composed tree with NodeRenderingTraversal::pare
nt(). | 1145 // FIXME: This wants to walk composed tree with NodeRenderingTraversal::pare
nt(). |
1146 while (node && (!node->renderer() || node->renderer()->isInline())) | 1146 while (node && (!node->layoutObject() || node->layoutObject()->isInline())) |
1147 node = NodeRenderingTraversal::parent(*node); | 1147 node = NodeRenderingTraversal::parent(*node); |
1148 | 1148 |
1149 // Return the bounding box in the window coordinate system. | 1149 // Return the bounding box in the window coordinate system. |
1150 if (node) { | 1150 if (node) { |
1151 IntRect rect = node->Node::pixelSnappedBoundingBox(); | 1151 IntRect rect = node->Node::pixelSnappedBoundingBox(); |
1152 LocalFrame* frame = node->document().frame(); | 1152 LocalFrame* frame = node->document().frame(); |
1153 return frame->view()->contentsToWindow(rect); | 1153 return frame->view()->contentsToWindow(rect); |
1154 } | 1154 } |
1155 return WebRect(); | 1155 return WebRect(); |
1156 } | 1156 } |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1255 | 1255 |
1256 scale = clampPageScaleFactorToLimits(scale); | 1256 scale = clampPageScaleFactorToLimits(scale); |
1257 scroll = mainFrameImpl()->frameView()->windowToContents(scroll); | 1257 scroll = mainFrameImpl()->frameView()->windowToContents(scroll); |
1258 scroll = clampOffsetAtScale(scroll, scale); | 1258 scroll = clampOffsetAtScale(scroll, scale); |
1259 } | 1259 } |
1260 | 1260 |
1261 static Node* findCursorDefiningAncestor(Node* node, LocalFrame* frame) | 1261 static Node* findCursorDefiningAncestor(Node* node, LocalFrame* frame) |
1262 { | 1262 { |
1263 // Go up the tree to find the node that defines a mouse cursor style | 1263 // Go up the tree to find the node that defines a mouse cursor style |
1264 while (node) { | 1264 while (node) { |
1265 if (node->renderer()) { | 1265 if (node->layoutObject()) { |
1266 ECursor cursor = node->renderer()->style()->cursor(); | 1266 ECursor cursor = node->layoutObject()->style()->cursor(); |
1267 if (cursor != CURSOR_AUTO || frame->eventHandler().useHandCursor(nod
e, node->isLink())) | 1267 if (cursor != CURSOR_AUTO || frame->eventHandler().useHandCursor(nod
e, node->isLink())) |
1268 break; | 1268 break; |
1269 } | 1269 } |
1270 node = NodeRenderingTraversal::parent(*node); | 1270 node = NodeRenderingTraversal::parent(*node); |
1271 } | 1271 } |
1272 | 1272 |
1273 return node; | 1273 return node; |
1274 } | 1274 } |
1275 | 1275 |
1276 static bool showsHandCursor(Node* node, LocalFrame* frame) | 1276 static bool showsHandCursor(Node* node, LocalFrame* frame) |
1277 { | 1277 { |
1278 if (!node || !node->renderer()) | 1278 if (!node || !node->layoutObject()) |
1279 return false; | 1279 return false; |
1280 | 1280 |
1281 ECursor cursor = node->renderer()->style()->cursor(); | 1281 ECursor cursor = node->layoutObject()->style()->cursor(); |
1282 return cursor == CURSOR_POINTER | 1282 return cursor == CURSOR_POINTER |
1283 || (cursor == CURSOR_AUTO && frame->eventHandler().useHandCursor(node, n
ode->isLink())); | 1283 || (cursor == CURSOR_AUTO && frame->eventHandler().useHandCursor(node, n
ode->isLink())); |
1284 } | 1284 } |
1285 | 1285 |
1286 Node* WebViewImpl::bestTapNode(const GestureEventWithHitTestResults& targetedTap
Event) | 1286 Node* WebViewImpl::bestTapNode(const GestureEventWithHitTestResults& targetedTap
Event) |
1287 { | 1287 { |
1288 TRACE_EVENT0("input", "WebViewImpl::bestTapNode"); | 1288 TRACE_EVENT0("input", "WebViewImpl::bestTapNode"); |
1289 | 1289 |
1290 if (!m_page || !m_page->mainFrame()) | 1290 if (!m_page || !m_page->mainFrame()) |
1291 return 0; | 1291 return 0; |
1292 | 1292 |
1293 Node* bestTouchNode = targetedTapEvent.hitTestResult().innerNode(); | 1293 Node* bestTouchNode = targetedTapEvent.hitTestResult().innerNode(); |
1294 if (!bestTouchNode) | 1294 if (!bestTouchNode) |
1295 return nullptr; | 1295 return nullptr; |
1296 | 1296 |
1297 // We might hit something like an image map that has no renderer on it | 1297 // We might hit something like an image map that has no renderer on it |
1298 // Walk up the tree until we have a node with an attached renderer | 1298 // Walk up the tree until we have a node with an attached renderer |
1299 while (!bestTouchNode->renderer()) { | 1299 while (!bestTouchNode->layoutObject()) { |
1300 bestTouchNode = NodeRenderingTraversal::parent(*bestTouchNode); | 1300 bestTouchNode = NodeRenderingTraversal::parent(*bestTouchNode); |
1301 if (!bestTouchNode) | 1301 if (!bestTouchNode) |
1302 return nullptr; | 1302 return nullptr; |
1303 } | 1303 } |
1304 | 1304 |
1305 // Editable nodes should not be highlighted (e.g., <input>) | 1305 // Editable nodes should not be highlighted (e.g., <input>) |
1306 if (bestTouchNode->hasEditableStyle()) | 1306 if (bestTouchNode->hasEditableStyle()) |
1307 return nullptr; | 1307 return nullptr; |
1308 | 1308 |
1309 Node* cursorDefiningAncestor = | 1309 Node* cursorDefiningAncestor = |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1344 // Always clear any existing highlight when this is invoked, even if we | 1344 // Always clear any existing highlight when this is invoked, even if we |
1345 // don't get a new target to highlight. | 1345 // don't get a new target to highlight. |
1346 m_linkHighlights.clear(); | 1346 m_linkHighlights.clear(); |
1347 | 1347 |
1348 // LinkHighlight reads out layout and compositing state, so we need to make
sure that's all up to date. | 1348 // LinkHighlight reads out layout and compositing state, so we need to make
sure that's all up to date. |
1349 layout(); | 1349 layout(); |
1350 | 1350 |
1351 for (size_t i = 0; i < highlightNodes.size(); ++i) { | 1351 for (size_t i = 0; i < highlightNodes.size(); ++i) { |
1352 Node* node = highlightNodes[i]; | 1352 Node* node = highlightNodes[i]; |
1353 | 1353 |
1354 if (!node || !node->renderer()) | 1354 if (!node || !node->layoutObject()) |
1355 continue; | 1355 continue; |
1356 | 1356 |
1357 Color highlightColor = node->renderer()->style()->tapHighlightColor(); | 1357 Color highlightColor = node->layoutObject()->style()->tapHighlightColor(
); |
1358 // Safari documentation for -webkit-tap-highlight-color says if the spec
ified color has 0 alpha, | 1358 // Safari documentation for -webkit-tap-highlight-color says if the spec
ified color has 0 alpha, |
1359 // then tap highlighting is disabled. | 1359 // then tap highlighting is disabled. |
1360 // http://developer.apple.com/library/safari/#documentation/appleapplica
tions/reference/safaricssref/articles/standardcssproperties.html | 1360 // http://developer.apple.com/library/safari/#documentation/appleapplica
tions/reference/safaricssref/articles/standardcssproperties.html |
1361 if (!highlightColor.alpha()) | 1361 if (!highlightColor.alpha()) |
1362 continue; | 1362 continue; |
1363 | 1363 |
1364 m_linkHighlights.append(LinkHighlight::create(node, this)); | 1364 m_linkHighlights.append(LinkHighlight::create(node, this)); |
1365 } | 1365 } |
1366 } | 1366 } |
1367 | 1367 |
(...skipping 2192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3560 } | 3560 } |
3561 | 3561 |
3562 void WebViewImpl::performPluginAction(const WebPluginAction& action, | 3562 void WebViewImpl::performPluginAction(const WebPluginAction& action, |
3563 const WebPoint& location) | 3563 const WebPoint& location) |
3564 { | 3564 { |
3565 HitTestResult result = hitTestResultForWindowPos(location); | 3565 HitTestResult result = hitTestResultForWindowPos(location); |
3566 RefPtrWillBeRawPtr<Node> node = result.innerNonSharedNode(); | 3566 RefPtrWillBeRawPtr<Node> node = result.innerNonSharedNode(); |
3567 if (!isHTMLObjectElement(*node) && !isHTMLEmbedElement(*node)) | 3567 if (!isHTMLObjectElement(*node) && !isHTMLEmbedElement(*node)) |
3568 return; | 3568 return; |
3569 | 3569 |
3570 LayoutObject* object = node->renderer(); | 3570 LayoutObject* object = node->layoutObject(); |
3571 if (object && object->isLayoutPart()) { | 3571 if (object && object->isLayoutPart()) { |
3572 Widget* widget = toLayoutPart(object)->widget(); | 3572 Widget* widget = toLayoutPart(object)->widget(); |
3573 if (widget && widget->isPluginContainer()) { | 3573 if (widget && widget->isPluginContainer()) { |
3574 WebPluginContainerImpl* plugin = toWebPluginContainerImpl(widget); | 3574 WebPluginContainerImpl* plugin = toWebPluginContainerImpl(widget); |
3575 switch (action.type) { | 3575 switch (action.type) { |
3576 case WebPluginAction::Rotate90Clockwise: | 3576 case WebPluginAction::Rotate90Clockwise: |
3577 plugin->plugin()->rotateView(WebPlugin::RotationType90Clockwise)
; | 3577 plugin->plugin()->rotateView(WebPlugin::RotationType90Clockwise)
; |
3578 break; | 3578 break; |
3579 case WebPluginAction::Rotate90Counterclockwise: | 3579 case WebPluginAction::Rotate90Counterclockwise: |
3580 plugin->plugin()->rotateView(WebPlugin::RotationType90Counterclo
ckwise); | 3580 plugin->plugin()->rotateView(WebPlugin::RotationType90Counterclo
ckwise); |
(...skipping 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4689 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width | 4689 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width |
4690 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); | 4690 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); |
4691 } | 4691 } |
4692 | 4692 |
4693 void WebViewImpl::forceNextWebGLContextCreationToFail() | 4693 void WebViewImpl::forceNextWebGLContextCreationToFail() |
4694 { | 4694 { |
4695 WebGLRenderingContext::forceNextWebGLContextCreationToFail(); | 4695 WebGLRenderingContext::forceNextWebGLContextCreationToFail(); |
4696 } | 4696 } |
4697 | 4697 |
4698 } // namespace blink | 4698 } // namespace blink |
OLD | NEW |