OLD | NEW |
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 Loading... |
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 Loading... |
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 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1231 const TouchEventTargetSet* touchHandlers = document->touchEventTargets(); | 1241 const TouchEventTargetSet* touchHandlers = document->touchEventTargets(); |
1232 if (!touchHandlers) | 1242 if (!touchHandlers) |
1233 return 0; | 1243 return 0; |
1234 | 1244 |
1235 unsigned count = 0; | 1245 unsigned count = 0; |
1236 for (TouchEventTargetSet::const_iterator iter = touchHandlers->begin(); iter
!= touchHandlers->end(); ++iter) | 1246 for (TouchEventTargetSet::const_iterator iter = touchHandlers->begin(); iter
!= touchHandlers->end(); ++iter) |
1237 count += iter->value; | 1247 count += iter->value; |
1238 return count; | 1248 return count; |
1239 } | 1249 } |
1240 | 1250 |
1241 PassRefPtr<ClientRectList> Internals::touchEventTargetClientRects(Document* docu
ment, ExceptionCode& ec) | 1251 PassRefPtr<LayerRectList> Internals::touchEventTargetLayerRects(Document* docume
nt, ExceptionCode& ec) |
1242 { | 1252 { |
1243 if (!document || !document->view() || !document->page()) { | 1253 if (!document || !document->view() || !document->page() || document != conte
xtDocument()) { |
1244 ec = INVALID_ACCESS_ERR; | 1254 ec = INVALID_ACCESS_ERR; |
1245 return 0; | 1255 return 0; |
1246 } | 1256 } |
1247 if (!document->page()->scrollingCoordinator()) | |
1248 return ClientRectList::create(); | |
1249 | 1257 |
1250 document->updateLayoutIgnorePendingStylesheets(); | 1258 // Do any pending layouts to ensure this really takes any previous changes i
nto account. |
| 1259 document->updateLayout(); |
1251 | 1260 |
1252 Vector<IntRect> absoluteRects; | 1261 RefPtr<LayerRectList> rects = LayerRectList::create(); |
1253 document->page()->scrollingCoordinator()->computeAbsoluteTouchEventTargetRec
ts(document, absoluteRects); | |
1254 Vector<FloatQuad> absoluteQuads(absoluteRects.size()); | |
1255 | 1262 |
1256 for (size_t i = 0; i < absoluteRects.size(); ++i) | 1263 for (LayerHitTestRects::const_iterator iter = m_currentTouchEventRects.begin
(); iter != m_currentTouchEventRects.end(); ++iter) { |
1257 absoluteQuads[i] = FloatQuad(absoluteRects[i]); | 1264 for (size_t i = 0; i < iter->value.size(); ++i) { |
| 1265 rects->append(iter->key->renderer()->node(), ClientRect::create(iter
->value[i])); |
| 1266 } |
| 1267 } |
1258 | 1268 |
1259 return ClientRectList::create(absoluteQuads); | 1269 return rects; |
| 1270 } |
| 1271 |
| 1272 unsigned Internals::touchEventTargetLayerRectsUpdateCount(Document* document, Ex
ceptionCode& ec) |
| 1273 { |
| 1274 if (!document || !document->view() || !document->page() || document != conte
xtDocument()) { |
| 1275 ec = INVALID_ACCESS_ERR; |
| 1276 return 0; |
| 1277 } |
| 1278 |
| 1279 // Do any pending layouts to ensure this really takes any previous changes i
nto account. |
| 1280 document->updateLayout(); |
| 1281 |
| 1282 return m_touchEventTargetRectUpdateCount; |
| 1283 } |
| 1284 |
| 1285 void Internals::touchEventTargetRectsChanged(const LayerHitTestRects& rects) |
| 1286 { |
| 1287 m_touchEventTargetRectUpdateCount++; |
| 1288 m_currentTouchEventRects = rects; |
1260 } | 1289 } |
1261 | 1290 |
1262 PassRefPtr<NodeList> Internals::nodesFromRect(Document* document, int centerX, i
nt centerY, unsigned topPadding, unsigned rightPadding, | 1291 PassRefPtr<NodeList> Internals::nodesFromRect(Document* document, int centerX, i
nt centerY, unsigned topPadding, unsigned rightPadding, |
1263 unsigned bottomPadding, unsigned leftPadding, bool ignoreClipping, bool allo
wShadowContent, bool allowChildFrameContent, ExceptionCode& ec) const | 1292 unsigned bottomPadding, unsigned leftPadding, bool ignoreClipping, bool allo
wShadowContent, bool allowChildFrameContent, ExceptionCode& ec) const |
1264 { | 1293 { |
1265 if (!document || !document->frame() || !document->frame()->view()) { | 1294 if (!document || !document->frame() || !document->frame()->view()) { |
1266 ec = INVALID_ACCESS_ERR; | 1295 ec = INVALID_ACCESS_ERR; |
1267 return 0; | 1296 return 0; |
1268 } | 1297 } |
1269 | 1298 |
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1977 | 2006 |
1978 RenderObject* renderer = select->renderer(); | 2007 RenderObject* renderer = select->renderer(); |
1979 if (!renderer->isMenuList()) | 2008 if (!renderer->isMenuList()) |
1980 return false; | 2009 return false; |
1981 | 2010 |
1982 RenderMenuList* menuList = toRenderMenuList(renderer); | 2011 RenderMenuList* menuList = toRenderMenuList(renderer); |
1983 return menuList->popupIsVisible(); | 2012 return menuList->popupIsVisible(); |
1984 } | 2013 } |
1985 | 2014 |
1986 } | 2015 } |
OLD | NEW |