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

Side by Side Diff: Source/core/testing/Internals.cpp

Issue 13824008: Move nodesFromRect from Document to Internals (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/testing/Internals.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * Copyright (C) 2013 Apple Inc. All rights reserved. 3 * Copyright (C) 2013 Apple Inc. All rights reserved.
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 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 #include "PseudoElement.h" 61 #include "PseudoElement.h"
62 #include "Range.h" 62 #include "Range.h"
63 #include "SelectRuleFeatureSet.h" 63 #include "SelectRuleFeatureSet.h"
64 #include "SerializedScriptValue.h" 64 #include "SerializedScriptValue.h"
65 #include "ShadowRoot.h" 65 #include "ShadowRoot.h"
66 #include "StyleSheetContents.h" 66 #include "StyleSheetContents.h"
67 #include "TreeScope.h" 67 #include "TreeScope.h"
68 #include "TypeConversions.h" 68 #include "TypeConversions.h"
69 #include "ViewportArguments.h" 69 #include "ViewportArguments.h"
70 #include "WorkerThread.h" 70 #include "WorkerThread.h"
71 #include "core/dom/StaticNodeList.h"
71 #include "core/editing/Editor.h" 72 #include "core/editing/Editor.h"
72 #include "core/editing/SpellChecker.h" 73 #include "core/editing/SpellChecker.h"
73 #include "core/editing/TextIterator.h" 74 #include "core/editing/TextIterator.h"
74 #include "core/history/BackForwardController.h" 75 #include "core/history/BackForwardController.h"
75 #include "core/history/HistoryItem.h" 76 #include "core/history/HistoryItem.h"
76 #include "core/loader/FrameLoader.h" 77 #include "core/loader/FrameLoader.h"
77 #include "core/loader/cache/CachedResourceLoader.h" 78 #include "core/loader/cache/CachedResourceLoader.h"
78 #include "core/loader/cache/MemoryCache.h" 79 #include "core/loader/cache/MemoryCache.h"
79 #include "core/page/Chrome.h" 80 #include "core/page/Chrome.h"
80 #include "core/page/ChromeClient.h" 81 #include "core/page/ChromeClient.h"
81 #include "core/page/DOMPoint.h" 82 #include "core/page/DOMPoint.h"
82 #include "core/page/DOMWindow.h" 83 #include "core/page/DOMWindow.h"
83 #include "core/page/EventHandler.h" 84 #include "core/page/EventHandler.h"
84 #include "core/page/Frame.h" 85 #include "core/page/Frame.h"
85 #include "core/page/FrameView.h" 86 #include "core/page/FrameView.h"
86 #include "core/page/Page.h" 87 #include "core/page/Page.h"
87 #include "core/page/PrintContext.h" 88 #include "core/page/PrintContext.h"
88 #include "core/page/RuntimeEnabledFeatures.h" 89 #include "core/page/RuntimeEnabledFeatures.h"
89 #include "core/page/Settings.h" 90 #include "core/page/Settings.h"
90 #include "core/page/animation/AnimationController.h" 91 #include "core/page/animation/AnimationController.h"
91 #include "core/page/scrolling/ScrollingCoordinator.h" 92 #include "core/page/scrolling/ScrollingCoordinator.h"
92 #include "core/platform/Cursor.h" 93 #include "core/platform/Cursor.h"
93 #include "core/platform/Language.h" 94 #include "core/platform/Language.h"
94 #include "core/platform/SchemeRegistry.h" 95 #include "core/platform/SchemeRegistry.h"
95 #include "core/platform/graphics/IntRect.h" 96 #include "core/platform/graphics/IntRect.h"
96 #include "core/rendering/RenderMenuList.h" 97 #include "core/rendering/RenderMenuList.h"
97 #include "core/rendering/RenderObject.h" 98 #include "core/rendering/RenderObject.h"
98 #include "core/rendering/RenderTreeAsText.h" 99 #include "core/rendering/RenderTreeAsText.h"
100 #include "core/rendering/RenderView.h"
99 #include <wtf/dtoa.h> 101 #include <wtf/dtoa.h>
100 #include <wtf/text/StringBuffer.h> 102 #include <wtf/text/StringBuffer.h>
101 103
102 #if ENABLE(INPUT_TYPE_COLOR) 104 #if ENABLE(INPUT_TYPE_COLOR)
103 #include "core/platform/ColorChooser.h" 105 #include "core/platform/ColorChooser.h"
104 #endif 106 #endif
105 107
106 #if ENABLE(BATTERY_STATUS) 108 #if ENABLE(BATTERY_STATUS)
107 #include "BatteryController.h" 109 #include "BatteryController.h"
108 #endif 110 #endif
(...skipping 1208 matching lines...) Expand 10 before | Expand all | Expand 10 after
1317 Vector<IntRect> absoluteRects; 1319 Vector<IntRect> absoluteRects;
1318 document->page()->scrollingCoordinator()->computeAbsoluteTouchEventTargetRec ts(document, absoluteRects); 1320 document->page()->scrollingCoordinator()->computeAbsoluteTouchEventTargetRec ts(document, absoluteRects);
1319 Vector<FloatQuad> absoluteQuads(absoluteRects.size()); 1321 Vector<FloatQuad> absoluteQuads(absoluteRects.size());
1320 1322
1321 for (size_t i = 0; i < absoluteRects.size(); ++i) 1323 for (size_t i = 0; i < absoluteRects.size(); ++i)
1322 absoluteQuads[i] = FloatQuad(absoluteRects[i]); 1324 absoluteQuads[i] = FloatQuad(absoluteRects[i]);
1323 1325
1324 return ClientRectList::create(absoluteQuads); 1326 return ClientRectList::create(absoluteQuads);
1325 } 1327 }
1326 1328
1327 PassRefPtr<NodeList> Internals::nodesFromRect(Document* document, int x, int y, unsigned topPadding, unsigned rightPadding, 1329 PassRefPtr<NodeList> Internals::nodesFromRect(Document* document, int centerX, i nt centerY, unsigned topPadding, unsigned rightPadding,
1328 unsigned bottomPadding, unsigned leftPadding, bool ignoreClipping, bool allo wShadowContent, bool allowChildFrameContent, ExceptionCode& ec) const 1330 unsigned bottomPadding, unsigned leftPadding, bool ignoreClipping, bool allo wShadowContent, bool allowChildFrameContent, ExceptionCode& ec) const
1329 { 1331 {
1330 if (!document || !document->frame() || !document->frame()->view()) { 1332 if (!document || !document->frame() || !document->frame()->view()) {
1331 ec = INVALID_ACCESS_ERR; 1333 ec = INVALID_ACCESS_ERR;
1332 return 0; 1334 return 0;
1333 } 1335 }
1334 1336
1337 Frame* frame = document->frame();
1338 FrameView* frameView = document->view();
1339 RenderView* renderView = document->renderView();
1340
1341 if (!renderView)
1342 return 0;
1343
1344 float zoomFactor = frame->pageZoomFactor();
1345 LayoutPoint point = roundedLayoutPoint(FloatPoint(centerX * zoomFactor + fra meView->scrollX(), centerY * zoomFactor + frameView->scrollY()));
1346
1335 HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitT estRequest::Active; 1347 HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitT estRequest::Active;
1336 if (ignoreClipping) 1348 if (ignoreClipping)
1337 hitType |= HitTestRequest::IgnoreClipping; 1349 hitType |= HitTestRequest::IgnoreClipping;
1338 if (!allowShadowContent) 1350 if (!allowShadowContent)
1339 hitType |= HitTestRequest::DisallowShadowContent; 1351 hitType |= HitTestRequest::DisallowShadowContent;
1340 if (allowChildFrameContent) 1352 if (allowChildFrameContent)
1341 hitType |= HitTestRequest::AllowChildFrameContent; 1353 hitType |= HitTestRequest::AllowChildFrameContent;
1342 1354
1343 return document->nodesFromRect(x, y, topPadding, rightPadding, bottomPadding , leftPadding, hitType); 1355 HitTestRequest request(hitType);
1356
1357 // When ignoreClipping is false, this method returns null for coordinates ou tside of the viewport.
1358 if (!request.ignoreClipping() && !frameView->visibleContentRect().intersects (HitTestLocation::rectForPoint(point, topPadding, rightPadding, bottomPadding, l eftPadding)))
1359 return 0;
1360
1361 Vector<RefPtr<Node> > matches;
1362
1363 // Need padding to trigger a rect based hit test, but we want to return a No deList
1364 // so we special case this.
1365 if (!topPadding && !rightPadding && !bottomPadding && !leftPadding) {
1366 HitTestResult result(point);
1367 renderView->hitTest(request, result);
1368 if (result.innerNode())
1369 matches.append(result.innerNode()->deprecatedShadowAncestorNode());
1370 } else {
1371 HitTestResult result(point, topPadding, rightPadding, bottomPadding, lef tPadding);
1372 renderView->hitTest(request, result);
1373 copyToVector(result.rectBasedTestResult(), matches);
1374 }
1375
1376 return StaticNodeList::adopt(matches);
1344 } 1377 }
1345 1378
1346 void Internals::emitInspectorDidBeginFrame() 1379 void Internals::emitInspectorDidBeginFrame()
1347 { 1380 {
1348 InspectorController* inspectorController = contextDocument()->frame()->page( )->inspectorController(); 1381 InspectorController* inspectorController = contextDocument()->frame()->page( )->inspectorController();
1349 inspectorController->didBeginFrame(); 1382 inspectorController->didBeginFrame();
1350 } 1383 }
1351 1384
1352 void Internals::emitInspectorDidCancelFrame() 1385 void Internals::emitInspectorDidCancelFrame()
1353 { 1386 {
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
1962 1995
1963 RenderObject* renderer = select->renderer(); 1996 RenderObject* renderer = select->renderer();
1964 if (!renderer->isMenuList()) 1997 if (!renderer->isMenuList())
1965 return false; 1998 return false;
1966 1999
1967 RenderMenuList* menuList = toRenderMenuList(renderer); 2000 RenderMenuList* menuList = toRenderMenuList(renderer);
1968 return menuList->popupIsVisible(); 2001 return menuList->popupIsVisible();
1969 } 2002 }
1970 2003
1971 } 2004 }
OLDNEW
« no previous file with comments | « Source/core/testing/Internals.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698