diff options
Diffstat (limited to 'chromium/third_party/WebKit/Source/core/testing')
12 files changed, 71 insertions, 149 deletions
diff --git a/chromium/third_party/WebKit/Source/core/testing/InspectorFrontendClientLocal.cpp b/chromium/third_party/WebKit/Source/core/testing/InspectorFrontendClientLocal.cpp index cec7a00ebe1..a68a070d155 100644 --- a/chromium/third_party/WebKit/Source/core/testing/InspectorFrontendClientLocal.cpp +++ b/chromium/third_party/WebKit/Source/core/testing/InspectorFrontendClientLocal.cpp @@ -39,8 +39,8 @@ #include "core/platform/Timer.h" #include "public/platform/Platform.h" #include "public/platform/WebThread.h" -#include "wtf/Deque.h" -#include "wtf/text/WTFString.h" +#include <wtf/Deque.h> +#include <wtf/text/WTFString.h> namespace WebCore { diff --git a/chromium/third_party/WebKit/Source/core/testing/InspectorFrontendClientLocal.h b/chromium/third_party/WebKit/Source/core/testing/InspectorFrontendClientLocal.h index e92f6f58e76..ef35ebab8dc 100644 --- a/chromium/third_party/WebKit/Source/core/testing/InspectorFrontendClientLocal.h +++ b/chromium/third_party/WebKit/Source/core/testing/InspectorFrontendClientLocal.h @@ -32,9 +32,9 @@ #define InspectorFrontendClientLocal_h #include "core/inspector/InspectorFrontendClient.h" -#include "wtf/Forward.h" -#include "wtf/Noncopyable.h" -#include "wtf/text/WTFString.h" +#include <wtf/Forward.h> +#include <wtf/Noncopyable.h> +#include <wtf/text/WTFString.h> namespace WebCore { 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, diff --git a/chromium/third_party/WebKit/Source/core/testing/Internals.h b/chromium/third_party/WebKit/Source/core/testing/Internals.h index bbba5ffdde4..bde21e22f4e 100644 --- a/chromium/third_party/WebKit/Source/core/testing/Internals.h +++ b/chromium/third_party/WebKit/Source/core/testing/Internals.h @@ -33,10 +33,10 @@ #include "core/dom/ContextLifecycleObserver.h" #include "core/dom/NodeList.h" #include "core/page/scrolling/ScrollingCoordinator.h" -#include "wtf/ArrayBuffer.h" -#include "wtf/PassRefPtr.h" -#include "wtf/RefCounted.h" -#include "wtf/text/WTFString.h" +#include <wtf/ArrayBuffer.h> +#include <wtf/PassRefPtr.h> +#include <wtf/RefCounted.h> +#include <wtf/text/WTFString.h> namespace WebCore { @@ -67,7 +67,8 @@ class ShadowRoot; class TypeConversions; class Internals : public RefCounted<Internals> - , public ContextLifecycleObserver { + , public ContextLifecycleObserver + , public ScrollingCoordinator::TouchEventTargetRectsObserver { public: static PassRefPtr<Internals> create(Document*); virtual ~Internals(); @@ -181,7 +182,9 @@ public: unsigned wheelEventHandlerCount(Document*, ExceptionState&); unsigned touchEventHandlerCount(Document*, ExceptionState&); - PassRefPtr<LayerRectList> touchEventTargetLayerRects(Document*, ExceptionState&); + LayerRectList* touchEventTargetLayerRects(Document*, ExceptionState&); + unsigned touchEventTargetLayerRectsUpdateCount(Document*, ExceptionState&); + virtual void touchEventTargetRectsChanged(const LayerHitTestRects&); // This is used to test rect based hit testing like what's done on touch screens. PassRefPtr<NodeList> nodesFromRect(Document*, int x, int y, unsigned topPadding, unsigned rightPadding, @@ -304,6 +307,8 @@ private: OwnPtr<InspectorFrontendChannelDummy> m_frontendChannel; RefPtr<InternalRuntimeFlags> m_runtimeFlags; RefPtr<ScrollingCoordinator> m_scrollingCoordinator; + int m_touchEventTargetRectUpdateCount; + RefPtr<LayerRectList> m_currentTouchEventRects; RefPtr<InternalProfilers> m_profilers; }; diff --git a/chromium/third_party/WebKit/Source/core/testing/Internals.idl b/chromium/third_party/WebKit/Source/core/testing/Internals.idl index 65a304e81be..d521c04ebe5 100644 --- a/chromium/third_party/WebKit/Source/core/testing/Internals.idl +++ b/chromium/third_party/WebKit/Source/core/testing/Internals.idl @@ -142,7 +142,7 @@ [RaisesException] unsigned long wheelEventHandlerCount(Document document); [RaisesException] unsigned long touchEventHandlerCount(Document document); [RaisesException] LayerRectList touchEventTargetLayerRects(Document document); - + [RaisesException] unsigned long touchEventTargetLayerRectsUpdateCount(Document document); [RaisesException] NodeList nodesFromRect(Document document, long x, long y, unsigned long topPadding, unsigned long rightPadding, unsigned long bottomPadding, unsigned long leftPadding, diff --git a/chromium/third_party/WebKit/Source/core/testing/LayerRect.h b/chromium/third_party/WebKit/Source/core/testing/LayerRect.h index 4827feee4f2..f945681417f 100644 --- a/chromium/third_party/WebKit/Source/core/testing/LayerRect.h +++ b/chromium/third_party/WebKit/Source/core/testing/LayerRect.h @@ -36,7 +36,6 @@ #include "wtf/PassRefPtr.h" #include "wtf/RefCounted.h" #include "wtf/RefPtr.h" -#include "wtf/text/WTFString.h" namespace WebCore { @@ -44,25 +43,22 @@ class Node; class LayerRect : public RefCounted<LayerRect> { public: - static PassRefPtr<LayerRect> create(PassRefPtr<Node> node, const String& layerType, PassRefPtr<ClientRect> rect) + static PassRefPtr<LayerRect> create(PassRefPtr<Node> node, PassRefPtr<ClientRect> rect) { - return adoptRef(new LayerRect(node, layerType, rect)); + return adoptRef(new LayerRect(node, rect)); } Node* layerRootNode() const { return m_layerRootNode.get(); } - String layerType() const { return m_layerType; } ClientRect* layerRelativeRect() const { return m_rect.get(); } private: - LayerRect(PassRefPtr<Node> node, const String& layerName, PassRefPtr<ClientRect> rect) + LayerRect(PassRefPtr<Node> node, PassRefPtr<ClientRect> rect) : m_layerRootNode(node) - , m_layerType(layerName) , m_rect(rect) { } RefPtr<Node> m_layerRootNode; - String m_layerType; RefPtr<ClientRect> m_rect; }; diff --git a/chromium/third_party/WebKit/Source/core/testing/LayerRect.idl b/chromium/third_party/WebKit/Source/core/testing/LayerRect.idl index 8a4d8e17f18..50994ab58e9 100644 --- a/chromium/third_party/WebKit/Source/core/testing/LayerRect.idl +++ b/chromium/third_party/WebKit/Source/core/testing/LayerRect.idl @@ -31,6 +31,5 @@ [ ] interface LayerRect { readonly attribute Node layerRootNode; - readonly attribute DOMString layerType; readonly attribute ClientRect layerRelativeRect; }; diff --git a/chromium/third_party/WebKit/Source/core/testing/LayerRectList.cpp b/chromium/third_party/WebKit/Source/core/testing/LayerRectList.cpp index 4e8b9911983..578b407a6f4 100644 --- a/chromium/third_party/WebKit/Source/core/testing/LayerRectList.cpp +++ b/chromium/third_party/WebKit/Source/core/testing/LayerRectList.cpp @@ -58,9 +58,9 @@ LayerRect* LayerRectList::item(unsigned index) return m_list[index].get(); } -void LayerRectList::append(PassRefPtr<Node> layerRootNode, const String& layerType, PassRefPtr<ClientRect> layerRelativeRect) +void LayerRectList::append(PassRefPtr<Node> layerRootNode, PassRefPtr<ClientRect> layerRelativeRect) { - m_list.append(LayerRect::create(layerRootNode, layerType, layerRelativeRect)); + m_list.append(LayerRect::create(layerRootNode, layerRelativeRect)); } } // namespace WebCore diff --git a/chromium/third_party/WebKit/Source/core/testing/LayerRectList.h b/chromium/third_party/WebKit/Source/core/testing/LayerRectList.h index ec1582b8b99..d46d1dc78b8 100644 --- a/chromium/third_party/WebKit/Source/core/testing/LayerRectList.h +++ b/chromium/third_party/WebKit/Source/core/testing/LayerRectList.h @@ -35,7 +35,6 @@ #include "wtf/PassRefPtr.h" #include "wtf/RefCounted.h" #include "wtf/Vector.h" -#include "wtf/text/WTFString.h" namespace WebCore { @@ -51,7 +50,7 @@ public: unsigned length() const; LayerRect* item(unsigned index); - void append(PassRefPtr<Node> layerRootNode, const String& layerName, PassRefPtr<ClientRect> layerRelativeRect); + void append(PassRefPtr<Node> layerRootNode, PassRefPtr<ClientRect> layerRelativeRect); private: LayerRectList(); diff --git a/chromium/third_party/WebKit/Source/core/testing/MallocStatistics.h b/chromium/third_party/WebKit/Source/core/testing/MallocStatistics.h index bc4da8562ca..3f07bbd9f71 100644 --- a/chromium/third_party/WebKit/Source/core/testing/MallocStatistics.h +++ b/chromium/third_party/WebKit/Source/core/testing/MallocStatistics.h @@ -26,9 +26,9 @@ #ifndef MallocStatistics_h #define MallocStatistics_h -#include "wtf/FastMalloc.h" -#include "wtf/PassRefPtr.h" -#include "wtf/RefCounted.h" +#include <wtf/FastMalloc.h> +#include <wtf/PassRefPtr.h> +#include <wtf/RefCounted.h> namespace WebCore { diff --git a/chromium/third_party/WebKit/Source/core/testing/MockPagePopupDriver.h b/chromium/third_party/WebKit/Source/core/testing/MockPagePopupDriver.h index e1f90aa54d0..154815be362 100644 --- a/chromium/third_party/WebKit/Source/core/testing/MockPagePopupDriver.h +++ b/chromium/third_party/WebKit/Source/core/testing/MockPagePopupDriver.h @@ -28,7 +28,7 @@ #include "core/page/PagePopupClient.h" #include "core/page/PagePopupDriver.h" -#include "wtf/RefPtr.h" +#include <wtf/RefPtr.h> namespace WebCore { diff --git a/chromium/third_party/WebKit/Source/core/testing/TypeConversions.h b/chromium/third_party/WebKit/Source/core/testing/TypeConversions.h index 10f675f42f4..b8cde7bf27a 100644 --- a/chromium/third_party/WebKit/Source/core/testing/TypeConversions.h +++ b/chromium/third_party/WebKit/Source/core/testing/TypeConversions.h @@ -26,9 +26,9 @@ #ifndef TypeConversions_h #define TypeConversions_h -#include "wtf/FastMalloc.h" -#include "wtf/PassRefPtr.h" -#include "wtf/RefCounted.h" +#include <wtf/FastMalloc.h> +#include <wtf/PassRefPtr.h> +#include <wtf/RefCounted.h> namespace WebCore { |