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

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

Issue 17471008: Rework compositor touch hit testing (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: CR feedback - accumulate LayoutRects instead of IntRects, disable when page isn't composited. Also… Created 7 years, 5 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
« no previous file with comments | « Source/core/testing/Internals.h ('k') | Source/core/testing/Internals.idl » ('j') | 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 14 matching lines...) Expand all
25 */ 25 */
26 26
27 #include "config.h" 27 #include "config.h"
28 #include "Internals.h" 28 #include "Internals.h"
29 29
30 #include "HTMLNames.h" 30 #include "HTMLNames.h"
31 #include "InspectorFrontendClientLocal.h" 31 #include "InspectorFrontendClientLocal.h"
32 #include "InternalProfilers.h" 32 #include "InternalProfilers.h"
33 #include "InternalRuntimeFlags.h" 33 #include "InternalRuntimeFlags.h"
34 #include "InternalSettings.h" 34 #include "InternalSettings.h"
35 #include "LayerRect.h"
36 #include "LayerRectList.h"
35 #include "MallocStatistics.h" 37 #include "MallocStatistics.h"
36 #include "MockPagePopupDriver.h" 38 #include "MockPagePopupDriver.h"
37 #include "RuntimeEnabledFeatures.h" 39 #include "RuntimeEnabledFeatures.h"
38 #include "TypeConversions.h" 40 #include "TypeConversions.h"
39 #include "bindings/v8/SerializedScriptValue.h" 41 #include "bindings/v8/SerializedScriptValue.h"
40 #include "core/css/StyleSheetContents.h" 42 #include "core/css/StyleSheetContents.h"
41 #include "core/dom/ClientRect.h" 43 #include "core/dom/ClientRect.h"
42 #include "core/dom/ClientRectList.h" 44 #include "core/dom/ClientRectList.h"
43 #include "core/dom/DOMStringList.h" 45 #include "core/dom/DOMStringList.h"
44 #include "core/dom/Document.h" 46 #include "core/dom/Document.h"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 169
168 const char* Internals::internalsId = "internals"; 170 const char* Internals::internalsId = "internals";
169 171
170 PassRefPtr<Internals> Internals::create(Document* document) 172 PassRefPtr<Internals> Internals::create(Document* document)
171 { 173 {
172 return adoptRef(new Internals(document)); 174 return adoptRef(new Internals(document));
173 } 175 }
174 176
175 Internals::~Internals() 177 Internals::~Internals()
176 { 178 {
179 if (m_scrollingCoordinator) {
180 m_scrollingCoordinator->removeTouchEventTargetRectsObserver(this);
181 }
177 } 182 }
178 183
179 void Internals::resetToConsistentState(Page* page) 184 void Internals::resetToConsistentState(Page* page)
180 { 185 {
181 ASSERT(page); 186 ASSERT(page);
182 187
183 page->setDeviceScaleFactor(1); 188 page->setDeviceScaleFactor(1);
184 page->setPageScaleFactor(1, IntPoint(0, 0)); 189 page->setPageScaleFactor(1, IntPoint(0, 0));
185 page->setPagination(Pagination()); 190 page->setPagination(Pagination());
186 TextRun::setAllowsRoundingHacks(false); 191 TextRun::setAllowsRoundingHacks(false);
187 WebCore::overrideUserPreferredLanguages(Vector<String>()); 192 WebCore::overrideUserPreferredLanguages(Vector<String>());
188 WebCore::Settings::setUsesOverlayScrollbars(false); 193 WebCore::Settings::setUsesOverlayScrollbars(false);
189 delete s_pagePopupDriver; 194 delete s_pagePopupDriver;
190 s_pagePopupDriver = 0; 195 s_pagePopupDriver = 0;
191 page->chrome().client()->resetPagePopupDriver(); 196 page->chrome().client()->resetPagePopupDriver();
192 if (!page->mainFrame()->editor()->isContinuousSpellCheckingEnabled()) 197 if (!page->mainFrame()->editor()->isContinuousSpellCheckingEnabled())
193 page->mainFrame()->editor()->toggleContinuousSpellChecking(); 198 page->mainFrame()->editor()->toggleContinuousSpellChecking();
194 if (page->mainFrame()->editor()->isOverwriteModeEnabled()) 199 if (page->mainFrame()->editor()->isOverwriteModeEnabled())
195 page->mainFrame()->editor()->toggleOverwriteModeEnabled(); 200 page->mainFrame()->editor()->toggleOverwriteModeEnabled();
196 } 201 }
197 202
198 Internals::Internals(Document* document) 203 Internals::Internals(Document* document)
199 : ContextLifecycleObserver(document) 204 : ContextLifecycleObserver(document)
200 , m_runtimeFlags(InternalRuntimeFlags::create()) 205 , m_runtimeFlags(InternalRuntimeFlags::create())
206 , m_scrollingCoordinator(document->page()->scrollingCoordinator())
207 , m_touchEventTargetRectUpdateCount(0)
201 { 208 {
209 if (m_scrollingCoordinator) {
210 m_scrollingCoordinator->addTouchEventTargetRectsObserver(this);
211 }
202 } 212 }
203 213
204 Document* Internals::contextDocument() const 214 Document* Internals::contextDocument() const
205 { 215 {
206 return toDocument(scriptExecutionContext()); 216 return toDocument(scriptExecutionContext());
207 } 217 }
208 218
209 Frame* Internals::frame() const 219 Frame* Internals::frame() const
210 { 220 {
211 if (!contextDocument()) 221 if (!contextDocument())
(...skipping 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after
1238 const TouchEventTargetSet* touchHandlers = document->touchEventTargets(); 1248 const TouchEventTargetSet* touchHandlers = document->touchEventTargets();
1239 if (!touchHandlers) 1249 if (!touchHandlers)
1240 return 0; 1250 return 0;
1241 1251
1242 unsigned count = 0; 1252 unsigned count = 0;
1243 for (TouchEventTargetSet::const_iterator iter = touchHandlers->begin(); iter != touchHandlers->end(); ++iter) 1253 for (TouchEventTargetSet::const_iterator iter = touchHandlers->begin(); iter != touchHandlers->end(); ++iter)
1244 count += iter->value; 1254 count += iter->value;
1245 return count; 1255 return count;
1246 } 1256 }
1247 1257
1248 PassRefPtr<ClientRectList> Internals::touchEventTargetClientRects(Document* docu ment, ExceptionCode& ec) 1258 LayerRectList* Internals::touchEventTargetLayerRects(Document* document, Excepti onCode& ec)
1249 { 1259 {
1250 if (!document || !document->view() || !document->page()) { 1260 if (!document || !document->view() || !document->page() || document != conte xtDocument()) {
1251 ec = InvalidAccessError; 1261 ec = InvalidAccessError;
1252 return 0; 1262 return 0;
1253 } 1263 }
1254 if (!document->page()->scrollingCoordinator())
1255 return ClientRectList::create();
1256 1264
1257 document->updateLayoutIgnorePendingStylesheets(); 1265 // Do any pending layouts (which may call touchEventTargetRectsChange) to en sure this
1266 // really takes any previous changes into account.
1267 document->updateLayout();
1268 return m_currentTouchEventRects.get();
1269 }
1258 1270
1259 Vector<IntRect> absoluteRects; 1271 unsigned Internals::touchEventTargetLayerRectsUpdateCount(Document* document, Ex ceptionCode& ec)
1260 document->page()->scrollingCoordinator()->computeAbsoluteTouchEventTargetRec ts(document, absoluteRects); 1272 {
1261 Vector<FloatQuad> absoluteQuads(absoluteRects.size()); 1273 if (!document || !document->view() || !document->page() || document != conte xtDocument()) {
1274 ec = InvalidAccessError;
1275 return 0;
1276 }
1262 1277
1263 for (size_t i = 0; i < absoluteRects.size(); ++i) 1278 // Do any pending layouts to ensure this really takes any previous changes i nto account.
1264 absoluteQuads[i] = FloatQuad(absoluteRects[i]); 1279 document->updateLayout();
1265 1280
1266 return ClientRectList::create(absoluteQuads); 1281 return m_touchEventTargetRectUpdateCount;
1282 }
1283
1284 void Internals::touchEventTargetRectsChanged(const LayerHitTestRects& rects)
1285 {
1286 m_touchEventTargetRectUpdateCount++;
1287
1288 // Since it's not safe to hang onto the pointers in a LayerHitTestRects, we immediately
1289 // copy into a LayerRectList.
1290 m_currentTouchEventRects = LayerRectList::create();
1291 for (LayerHitTestRects::const_iterator iter = rects.begin(); iter != rects.e nd(); ++iter) {
1292 for (size_t i = 0; i < iter->value.size(); ++i) {
1293 m_currentTouchEventRects->append(iter->key->renderer()->node(), Clie ntRect::create(enclosingIntRect(iter->value[i])));
1294 }
1295 }
1267 } 1296 }
1268 1297
1269 PassRefPtr<NodeList> Internals::nodesFromRect(Document* document, int centerX, i nt centerY, unsigned topPadding, unsigned rightPadding, 1298 PassRefPtr<NodeList> Internals::nodesFromRect(Document* document, int centerX, i nt centerY, unsigned topPadding, unsigned rightPadding,
1270 unsigned bottomPadding, unsigned leftPadding, bool ignoreClipping, bool allo wShadowContent, bool allowChildFrameContent, ExceptionCode& ec) const 1299 unsigned bottomPadding, unsigned leftPadding, bool ignoreClipping, bool allo wShadowContent, bool allowChildFrameContent, ExceptionCode& ec) const
1271 { 1300 {
1272 if (!document || !document->frame() || !document->frame()->view()) { 1301 if (!document || !document->frame() || !document->frame()->view()) {
1273 ec = InvalidAccessError; 1302 ec = InvalidAccessError;
1274 return 0; 1303 return 0;
1275 } 1304 }
1276 1305
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after
1999 2028
2000 RenderObject* renderer = select->renderer(); 2029 RenderObject* renderer = select->renderer();
2001 if (!renderer->isMenuList()) 2030 if (!renderer->isMenuList())
2002 return false; 2031 return false;
2003 2032
2004 RenderMenuList* menuList = toRenderMenuList(renderer); 2033 RenderMenuList* menuList = toRenderMenuList(renderer);
2005 return menuList->popupIsVisible(); 2034 return menuList->popupIsVisible();
2006 } 2035 }
2007 2036
2008 } 2037 }
OLDNEW
« no previous file with comments | « Source/core/testing/Internals.h ('k') | Source/core/testing/Internals.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698