Index: Source/core/testing/Internals.cpp |
diff --git a/Source/core/testing/Internals.cpp b/Source/core/testing/Internals.cpp |
index 9546de13f18c9556a60d84612285e53efc3bb139..19dbde763a5b4f71997a0ab8397684a95deafb61 100644 |
--- a/Source/core/testing/Internals.cpp |
+++ b/Source/core/testing/Internals.cpp |
@@ -32,6 +32,8 @@ |
#include "InternalProfilers.h" |
#include "InternalRuntimeFlags.h" |
#include "InternalSettings.h" |
+#include "LayerRect.h" |
+#include "LayerRectList.h" |
#include "MallocStatistics.h" |
#include "MockPagePopupDriver.h" |
#include "RuntimeEnabledFeatures.h" |
@@ -174,6 +176,9 @@ PassRefPtr<Internals> Internals::create(Document* document) |
Internals::~Internals() |
{ |
+ if (m_scrollingCoordinator) { |
+ m_scrollingCoordinator->removeTouchEventTargetRectsObserver(this); |
+ } |
} |
void Internals::resetToConsistentState(Page* page) |
@@ -198,7 +203,12 @@ void Internals::resetToConsistentState(Page* page) |
Internals::Internals(Document* document) |
: ContextLifecycleObserver(document) |
, m_runtimeFlags(InternalRuntimeFlags::create()) |
+ , m_scrollingCoordinator(document->page()->scrollingCoordinator()) |
+ , m_touchEventTargetRectUpdateCount(0) |
{ |
+ if (m_scrollingCoordinator) { |
+ m_scrollingCoordinator->addTouchEventTargetRectsObserver(this); |
+ } |
} |
Document* Internals::contextDocument() const |
@@ -1238,25 +1248,44 @@ unsigned Internals::touchEventHandlerCount(Document* document, ExceptionCode& ec |
return count; |
} |
-PassRefPtr<ClientRectList> Internals::touchEventTargetClientRects(Document* document, ExceptionCode& ec) |
+PassRefPtr<LayerRectList> Internals::touchEventTargetLayerRects(Document* document, ExceptionCode& ec) |
{ |
- if (!document || !document->view() || !document->page()) { |
+ if (!document || !document->view() || !document->page() || document != contextDocument()) { |
ec = INVALID_ACCESS_ERR; |
return 0; |
} |
- if (!document->page()->scrollingCoordinator()) |
- return ClientRectList::create(); |
- document->updateLayoutIgnorePendingStylesheets(); |
+ // Do any pending layouts to ensure this really takes any previous changes into account. |
+ document->updateLayout(); |
- Vector<IntRect> absoluteRects; |
- document->page()->scrollingCoordinator()->computeAbsoluteTouchEventTargetRects(document, absoluteRects); |
- Vector<FloatQuad> absoluteQuads(absoluteRects.size()); |
+ RefPtr<LayerRectList> rects = LayerRectList::create(); |
- for (size_t i = 0; i < absoluteRects.size(); ++i) |
- absoluteQuads[i] = FloatQuad(absoluteRects[i]); |
+ for (LayerHitTestRects::const_iterator iter = m_currentTouchEventRects.begin(); iter != m_currentTouchEventRects.end(); ++iter) { |
+ for (size_t i = 0; i < iter->value.size(); ++i) { |
+ rects->append(iter->key->renderer()->node(), ClientRect::create(iter->value[i])); |
+ } |
+ } |
- return ClientRectList::create(absoluteQuads); |
+ return rects; |
+} |
+ |
+unsigned Internals::touchEventTargetLayerRectsUpdateCount(Document* document, ExceptionCode& ec) |
+{ |
+ if (!document || !document->view() || !document->page() || document != contextDocument()) { |
+ ec = INVALID_ACCESS_ERR; |
+ return 0; |
+ } |
+ |
+ // Do any pending layouts to ensure this really takes any previous changes into account. |
+ document->updateLayout(); |
+ |
+ return m_touchEventTargetRectUpdateCount; |
+} |
+ |
+void Internals::touchEventTargetRectsChanged(const LayerHitTestRects& rects) |
+{ |
+ m_touchEventTargetRectUpdateCount++; |
+ m_currentTouchEventRects = rects; |
} |
PassRefPtr<NodeList> Internals::nodesFromRect(Document* document, int centerX, int centerY, unsigned topPadding, unsigned rightPadding, |