Index: Source/core/testing/Internals.cpp |
diff --git a/Source/core/testing/Internals.cpp b/Source/core/testing/Internals.cpp |
index 15eb7ae86778849b9f6494aeff7b9c13712f97c3..677944c2cbae6f5bbd2303434a0d872d70519722 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 |
@@ -1245,25 +1255,44 @@ unsigned Internals::touchEventHandlerCount(Document* document, ExceptionCode& ec |
return count; |
} |
-PassRefPtr<ClientRectList> Internals::touchEventTargetClientRects(Document* document, ExceptionCode& ec) |
+LayerRectList* Internals::touchEventTargetLayerRects(Document* document, ExceptionCode& ec) |
{ |
- if (!document || !document->view() || !document->page()) { |
+ if (!document || !document->view() || !document->page() || document != contextDocument()) { |
ec = InvalidAccessError; |
return 0; |
} |
- if (!document->page()->scrollingCoordinator()) |
- return ClientRectList::create(); |
- document->updateLayoutIgnorePendingStylesheets(); |
+ // Do any pending layouts (which may call touchEventTargetRectsChange) to ensure this |
+ // really takes any previous changes into account. |
+ document->updateLayout(); |
+ return m_currentTouchEventRects.get(); |
+} |
- Vector<IntRect> absoluteRects; |
- document->page()->scrollingCoordinator()->computeAbsoluteTouchEventTargetRects(document, absoluteRects); |
- Vector<FloatQuad> absoluteQuads(absoluteRects.size()); |
+unsigned Internals::touchEventTargetLayerRectsUpdateCount(Document* document, ExceptionCode& ec) |
+{ |
+ if (!document || !document->view() || !document->page() || document != contextDocument()) { |
+ ec = InvalidAccessError; |
+ return 0; |
+ } |
+ |
+ // Do any pending layouts to ensure this really takes any previous changes into account. |
+ document->updateLayout(); |
- for (size_t i = 0; i < absoluteRects.size(); ++i) |
- absoluteQuads[i] = FloatQuad(absoluteRects[i]); |
+ return m_touchEventTargetRectUpdateCount; |
+} |
- return ClientRectList::create(absoluteQuads); |
+void Internals::touchEventTargetRectsChanged(const LayerHitTestRects& rects) |
+{ |
+ m_touchEventTargetRectUpdateCount++; |
+ |
+ // Since it's not safe to hang onto the pointers in a LayerHitTestRects, we immediately |
+ // copy into a LayerRectList. |
+ m_currentTouchEventRects = LayerRectList::create(); |
+ for (LayerHitTestRects::const_iterator iter = rects.begin(); iter != rects.end(); ++iter) { |
+ for (size_t i = 0; i < iter->value.size(); ++i) { |
+ m_currentTouchEventRects->append(iter->key->renderer()->node(), ClientRect::create(enclosingIntRect(iter->value[i]))); |
+ } |
+ } |
} |
PassRefPtr<NodeList> Internals::nodesFromRect(Document* document, int centerX, int centerY, unsigned topPadding, unsigned rightPadding, |