Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(635)

Side by Side Diff: Source/core/page/DragController.cpp

Issue 1032823003: Refactor HitTestResult to store the HitTestRequest (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2009, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Google Inc. 3 * Copyright (C) 2008 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 } 307 }
308 308
309 // This can return null if an empty document is loaded. 309 // This can return null if an empty document is loaded.
310 static Element* elementUnderMouse(Document* documentUnderMouse, const IntPoint& p) 310 static Element* elementUnderMouse(Document* documentUnderMouse, const IntPoint& p)
311 { 311 {
312 LocalFrame* frame = documentUnderMouse->frame(); 312 LocalFrame* frame = documentUnderMouse->frame();
313 float zoomFactor = frame ? frame->pageZoomFactor() : 1; 313 float zoomFactor = frame ? frame->pageZoomFactor() : 1;
314 LayoutPoint point = roundedLayoutPoint(FloatPoint(p.x() * zoomFactor, p.y() * zoomFactor)); 314 LayoutPoint point = roundedLayoutPoint(FloatPoint(p.x() * zoomFactor, p.y() * zoomFactor));
315 315
316 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active); 316 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active);
317 HitTestResult result(point); 317 HitTestResult result(request, point);
318 documentUnderMouse->layoutView()->hitTest(request, result); 318 documentUnderMouse->layoutView()->hitTest(result);
319 319
320 Node* n = result.innerNode(); 320 Node* n = result.innerNode();
321 while (n && !n->isElementNode()) 321 while (n && !n->isElementNode())
322 n = n->parentOrShadowHostNode(); 322 n = n->parentOrShadowHostNode();
323 if (n && n->isInShadowTree()) 323 if (n && n->isInShadowTree())
324 n = n->shadowHost(); 324 n = n->shadowHost();
325 325
326 return toElement(n); 326 return toElement(n);
327 } 327 }
328 328
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 } 534 }
535 535
536 bool DragController::canProcessDrag(DragData* dragData) 536 bool DragController::canProcessDrag(DragData* dragData)
537 { 537 {
538 ASSERT(dragData); 538 ASSERT(dragData);
539 539
540 if (!dragData->containsCompatibleContent()) 540 if (!dragData->containsCompatibleContent())
541 return false; 541 return false;
542 542
543 IntPoint point = m_page->deprecatedLocalMainFrame()->view()->rootFrameToCont ents(dragData->clientPosition()); 543 IntPoint point = m_page->deprecatedLocalMainFrame()->view()->rootFrameToCont ents(dragData->clientPosition());
544 HitTestResult result = HitTestResult(point); 544 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active);
545 HitTestResult result = HitTestResult(request, point);
Rick Byers 2015/03/31 00:51:00 nit: looks like you don't need these initializers
ramya.v 2015/03/31 09:41:36 Done.
545 if (!m_page->deprecatedLocalMainFrame()->contentRenderer()) 546 if (!m_page->deprecatedLocalMainFrame()->contentRenderer())
546 return false; 547 return false;
547 548
548 result = m_page->deprecatedLocalMainFrame()->eventHandler().hitTestResultAtP oint(point); 549 result = m_page->deprecatedLocalMainFrame()->eventHandler().hitTestResultAtP oint(point);
549 550
550 if (!result.innerNonSharedNode()) 551 if (!result.innerNonSharedNode())
551 return false; 552 return false;
552 553
553 if (dragData->containsFiles() && asFileInput(result.innerNonSharedNode())) 554 if (dragData->containsFiles() && asFileInput(result.innerNonSharedNode()))
554 return true; 555 return true;
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
965 966
966 DEFINE_TRACE(DragController) 967 DEFINE_TRACE(DragController)
967 { 968 {
968 visitor->trace(m_page); 969 visitor->trace(m_page);
969 visitor->trace(m_documentUnderMouse); 970 visitor->trace(m_documentUnderMouse);
970 visitor->trace(m_dragInitiator); 971 visitor->trace(m_dragInitiator);
971 visitor->trace(m_fileInputElementUnderMouse); 972 visitor->trace(m_fileInputElementUnderMouse);
972 } 973 }
973 974
974 } // namespace blink 975 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698