summaryrefslogtreecommitdiff
path: root/chromium/third_party/WebKit/Source/core/testing/Internals.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/WebKit/Source/core/testing/Internals.cpp')
-rw-r--r--chromium/third_party/WebKit/Source/core/testing/Internals.cpp159
1 files changed, 41 insertions, 118 deletions
diff --git a/chromium/third_party/WebKit/Source/core/testing/Internals.cpp b/chromium/third_party/WebKit/Source/core/testing/Internals.cpp
index 63285fab580..dba52a6173c 100644
--- a/chromium/third_party/WebKit/Source/core/testing/Internals.cpp
+++ b/chromium/third_party/WebKit/Source/core/testing/Internals.cpp
@@ -41,7 +41,6 @@
#include "bindings/v8/ExceptionState.h"
#include "bindings/v8/SerializedScriptValue.h"
#include "bindings/v8/V8ThrowException.h"
-#include "core/animation/DocumentTimeline.h"
#include "core/css/StyleSheetContents.h"
#include "core/css/resolver/StyleResolver.h"
#include "core/css/resolver/ViewportStyleResolver.h"
@@ -68,8 +67,6 @@
#include "core/editing/Editor.h"
#include "core/editing/SpellChecker.h"
#include "core/editing/TextIterator.h"
-#include "core/fetch/MemoryCache.h"
-#include "core/fetch/ResourceFetcher.h"
#include "core/history/BackForwardController.h"
#include "core/history/HistoryItem.h"
#include "core/html/FormController.h"
@@ -87,6 +84,8 @@
#include "core/inspector/InspectorOverlay.h"
#include "core/inspector/InstrumentingAgents.h"
#include "core/loader/FrameLoader.h"
+#include "core/loader/cache/MemoryCache.h"
+#include "core/loader/cache/ResourceFetcher.h"
#include "core/page/Chrome.h"
#include "core/page/ChromeClient.h"
#include "core/page/DOMPoint.h"
@@ -110,9 +109,7 @@
#include "core/platform/graphics/filters/FilterOperations.h"
#include "core/platform/graphics/gpu/SharedGraphicsContext3D.h"
#include "core/platform/mock/PlatformSpeechSynthesizerMock.h"
-#include "core/rendering/RenderLayer.h"
#include "core/rendering/RenderLayerBacking.h"
-#include "core/rendering/RenderLayerCompositor.h"
#include "core/rendering/RenderMenuList.h"
#include "core/rendering/RenderObject.h"
#include "core/rendering/RenderTreeAsText.h"
@@ -121,7 +118,6 @@
#include "core/workers/WorkerThread.h"
#include "modules/speech/DOMWindowSpeechSynthesis.h"
#include "modules/speech/SpeechSynthesis.h"
-#include "public/platform/WebLayer.h"
#include "weborigin/SchemeRegistry.h"
#include "wtf/dtoa.h"
#include "wtf/text/StringBuffer.h"
@@ -186,6 +182,9 @@ PassRefPtr<Internals> Internals::create(Document* document)
Internals::~Internals()
{
+ if (m_scrollingCoordinator) {
+ m_scrollingCoordinator->removeTouchEventTargetRectsObserver(this);
+ }
}
void Internals::resetToConsistentState(Page* page)
@@ -211,7 +210,11 @@ 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
@@ -411,10 +414,10 @@ unsigned short Internals::compareTreeScopePosition(const Node* node1, const Node
unsigned Internals::numberOfActiveAnimations() const
{
Frame* contextFrame = frame();
- if (RuntimeEnabledFeatures::webAnimationsCSSEnabled())
- return frame()->document()->timeline()->numberOfActiveAnimationsForTesting();
- if (AnimationController* controller = contextFrame->animation())
- return controller->numberOfActiveAnimations(contextFrame->document());
+ if (!RuntimeEnabledFeatures::webAnimationsCSSEnabled()) {
+ if (AnimationController* controller = contextFrame->animation())
+ return controller->numberOfActiveAnimations(contextFrame->document());
+ }
return 0;
}
@@ -457,9 +460,7 @@ void Internals::pauseAnimations(double pauseTime, ExceptionState& es)
return;
}
- if (RuntimeEnabledFeatures::webAnimationsCSSEnabled())
- frame()->document()->timeline()->pauseAnimationsForTesting(pauseTime);
- else
+ if (!RuntimeEnabledFeatures::webAnimationsCSSEnabled())
frame()->animation()->pauseAnimationsForTesting(pauseTime);
}
@@ -1293,126 +1294,48 @@ unsigned Internals::touchEventHandlerCount(Document* document, ExceptionState& e
return count;
}
-static RenderLayer* findRenderLayerForGraphicsLayer(RenderLayer* searchRoot, GraphicsLayer* graphicsLayer, String* layerType)
+LayerRectList* Internals::touchEventTargetLayerRects(Document* document, ExceptionState& es)
{
- if (searchRoot->backing() && graphicsLayer == searchRoot->backing()->graphicsLayer())
- return searchRoot;
-
- if (graphicsLayer == searchRoot->layerForScrolling()) {
- *layerType = "scrolling";
- return searchRoot;
- }
-
- if (graphicsLayer == searchRoot->layerForHorizontalScrollbar()) {
- *layerType = "horizontalScrollbar";
- return searchRoot;
- }
-
- if (graphicsLayer == searchRoot->layerForVerticalScrollbar()) {
- *layerType = "verticalScrollbar";
- return searchRoot;
- }
-
- if (graphicsLayer == searchRoot->layerForScrollCorner()) {
- *layerType = "scrollCorner";
- return searchRoot;
- }
-
- for (RenderLayer* child = searchRoot->firstChild(); child; child = child->nextSibling()) {
- RenderLayer* foundLayer = findRenderLayerForGraphicsLayer(child, graphicsLayer, layerType);
- if (foundLayer)
- return foundLayer;
- }
-
- return 0;
-}
-
-// Given a vector of rects, merge those that are adjacent, leaving empty rects
-// in the place of no longer used slots. This is intended to simplify the list
-// of rects returned by an SkRegion (which have been split apart for sorting
-// purposes). No attempt is made to do this efficiently (eg. by relying on the
-// sort criteria of SkRegion).
-static void mergeRects(WebKit::WebVector<WebKit::WebRect>& rects)
-{
- for (size_t i = 0; i < rects.size(); ++i) {
- if (rects[i].isEmpty())
- continue;
- bool updated;
- do {
- updated = false;
- for (size_t j = i+1; j < rects.size(); ++j) {
- if (rects[j].isEmpty())
- continue;
- // Try to merge rects[j] into rects[i] along the 4 possible edges.
- if (rects[i].y == rects[j].y && rects[i].height == rects[j].height) {
- if (rects[i].x + rects[i].width == rects[j].x) {
- rects[i].width += rects[j].width;
- rects[j] = WebKit::WebRect();
- updated = true;
- } else if (rects[i].x == rects[j].x + rects[j].width) {
- rects[i].x = rects[j].x;
- rects[i].width += rects[j].width;
- rects[j] = WebKit::WebRect();
- updated = true;
- }
- } else if (rects[i].x == rects[j].x && rects[i].width == rects[j].width) {
- if (rects[i].y + rects[i].height == rects[j].y) {
- rects[i].height += rects[j].height;
- rects[j] = WebKit::WebRect();
- updated = true;
- } else if (rects[i].y == rects[j].y + rects[j].height) {
- rects[i].y = rects[j].y;
- rects[i].height += rects[j].height;
- rects[j] = WebKit::WebRect();
- updated = true;
- }
- }
- }
- } while (updated);
- }
-}
-
-static void accumulateLayerRectList(RenderLayerCompositor* compositor, GraphicsLayer* graphicsLayer, LayerRectList* rects)
-{
- WebKit::WebVector<WebKit::WebRect> layerRects = graphicsLayer->platformLayer()->touchEventHandlerRegion();
- if (!layerRects.isEmpty()) {
- mergeRects(layerRects);
- String layerType;
- RenderLayer* renderLayer = findRenderLayerForGraphicsLayer(compositor->rootRenderLayer(), graphicsLayer, &layerType);
- Node* node = renderLayer ? renderLayer->renderer()->node() : 0;
- for (size_t i = 0; i < layerRects.size(); ++i) {
- if (!layerRects[i].isEmpty())
- rects->append(node, layerType, ClientRect::create(layerRects[i]));
- }
+ if (!document || !document->view() || !document->page() || document != contextDocument()) {
+ es.throwDOMException(InvalidAccessError);
+ return 0;
}
- size_t numChildren = graphicsLayer->children().size();
- for (size_t i = 0; i < numChildren; ++i)
- accumulateLayerRectList(compositor, graphicsLayer->children()[i], rects);
+ // Do any pending layouts (which may call touchEventTargetRectsChange) to ensure this
+ // really takes any previous changes into account.
+ document->updateLayout();
+ return m_currentTouchEventRects.get();
}
-PassRefPtr<LayerRectList> Internals::touchEventTargetLayerRects(Document* document, ExceptionState& es)
+unsigned Internals::touchEventTargetLayerRectsUpdateCount(Document* document, ExceptionState& es)
{
if (!document || !document->view() || !document->page() || document != contextDocument()) {
es.throwDOMException(InvalidAccessError);
return 0;
}
- // Do any pending layouts (which may call touchEventTargetRectsChange) to ensure this
- // really takes any previous changes into account.
+ // Do any pending layouts to ensure this really takes any previous changes into account.
document->updateLayout();
- if (RenderView* view = document->renderView()) {
- if (RenderLayerCompositor* compositor = view->compositor()) {
- if (GraphicsLayer* rootLayer = compositor->rootGraphicsLayer()) {
- RefPtr<LayerRectList> rects = LayerRectList::create();
- accumulateLayerRectList(compositor, rootLayer, rects.get());
- return rects;
- }
+ return m_touchEventTargetRectUpdateCount;
+}
+
+void Internals::touchEventTargetRectsChanged(const LayerHitTestRects& rects)
+{
+ // When profiling content_shell, it can be handy to exclude this time (since it's only
+ // present for testing / debugging).
+ TRACE_EVENT0("input", "Internals::touchEventTargetRectsChanged");
+
+ 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])));
}
}
-
- return 0;
}
PassRefPtr<NodeList> Internals::nodesFromRect(Document* document, int centerX, int centerY, unsigned topPadding, unsigned rightPadding,