Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1388)

Unified Diff: Source/core/testing/Internals.cpp

Issue 23903012: Set up scroll and clip parents (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Make WebLayer additions pure virtual. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/testing/Internals.h ('k') | Source/core/testing/Internals.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/testing/Internals.cpp
diff --git a/Source/core/testing/Internals.cpp b/Source/core/testing/Internals.cpp
index ad961fa8d953f8c7873be042652f90b0bd0faed0..388eb19f856cb48a05ba35a1600a0d121e967f1e 100644
--- a/Source/core/testing/Internals.cpp
+++ b/Source/core/testing/Internals.cpp
@@ -1773,28 +1773,77 @@ String Internals::elementLayerTreeAsText(Element* element, unsigned flags, Excep
return layer->backing()->graphicsLayer()->layerTreeAsText(flags);
}
-void Internals::setNeedsCompositedScrolling(Element* element, unsigned needsCompositedScrolling, ExceptionState& es)
+static RenderLayer* getRenderLayerForElement(Element* element, ExceptionState& es)
{
if (!element) {
es.throwDOMException(InvalidAccessError);
- return;
+ return 0;
}
- element->document().updateLayout();
-
RenderObject* renderer = element->renderer();
if (!renderer || !renderer->isBox()) {
es.throwDOMException(InvalidAccessError);
- return;
+ return 0;
}
RenderLayer* layer = toRenderBox(renderer)->layer();
if (!layer) {
es.throwDOMException(InvalidAccessError);
+ return 0;
+ }
+
+ return layer;
+}
+
+void Internals::setNeedsCompositedScrolling(Element* element, unsigned needsCompositedScrolling, ExceptionState& es)
+{
+ if (!element) {
+ es.throwDOMException(InvalidAccessError);
return;
}
- layer->setForceNeedsCompositedScrolling(static_cast<RenderLayer::ForceNeedsCompositedScrollingMode>(needsCompositedScrolling));
+ element->document().updateLayout();
+
+ if (RenderLayer* layer = getRenderLayerForElement(element, es))
+ layer->setForceNeedsCompositedScrolling(static_cast<RenderLayer::ForceNeedsCompositedScrollingMode>(needsCompositedScrolling));
+}
+
+bool Internals::isScrollParent(Element* child, Element* parent, ExceptionState& es)
+{
+ RenderLayer* childLayer = getRenderLayerForElement(child, es);
+ RenderLayer* parentLayer = getRenderLayerForElement(parent, es);
+ return childLayer && parentLayer && childLayer->scrollParent() == parentLayer;
+}
+
+bool Internals::isClipParent(Element* child, Element* parent, ExceptionState& es)
+{
+ RenderLayer* childLayer = getRenderLayerForElement(child, es);
+ RenderLayer* parentLayer = getRenderLayerForElement(parent, es);
+ return childLayer && parentLayer && childLayer->clipParent() == parentLayer;
+}
+
+PassRefPtr<ClientRect> Internals::scrollClip(Element* element, ExceptionState& es)
+{
+ RenderLayer* layer = getRenderLayerForElement(element, es);
+ if (!layer || !layer->backing() || !layer->backing()->scrollingLayer())
+ return ClientRect::create();
+
+ return ClientRect::create(
+ FloatRect(
+ layer->backing()->scrollingLayer()->boundsOrigin(),
+ layer->backing()->scrollingLayer()->size()));
+}
+
+PassRefPtr<ClientRect> Internals::ancestorScrollClip(Element* element, ExceptionState& es)
+{
+ RenderLayer* layer = getRenderLayerForElement(element, es);
+ if (!layer || !layer->backing() || !layer->backing()->ancestorScrollClippingLayer())
+ return ClientRect::create();
+
+ return ClientRect::create(
+ FloatRect(
+ layer->backing()->ancestorScrollClippingLayer()->boundsOrigin(),
+ layer->backing()->ancestorScrollClippingLayer()->size()));
}
String Internals::repaintRectsAsText(Document* document, ExceptionState& es) const
« no previous file with comments | « Source/core/testing/Internals.h ('k') | Source/core/testing/Internals.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698