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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/testing/Internals.h ('k') | Source/core/testing/Internals.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * Copyright (C) 2013 Apple Inc. All rights reserved. 3 * Copyright (C) 2013 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 1755 matching lines...) Expand 10 before | Expand all | Expand 10 after
1766 if (!layer 1766 if (!layer
1767 || !layer->backing() 1767 || !layer->backing()
1768 || !layer->backing()->graphicsLayer()) { 1768 || !layer->backing()->graphicsLayer()) {
1769 // Don't raise exception in these cases which may be normally used in te sts. 1769 // Don't raise exception in these cases which may be normally used in te sts.
1770 return String(); 1770 return String();
1771 } 1771 }
1772 1772
1773 return layer->backing()->graphicsLayer()->layerTreeAsText(flags); 1773 return layer->backing()->graphicsLayer()->layerTreeAsText(flags);
1774 } 1774 }
1775 1775
1776 static RenderLayer* getRenderLayerForElement(Element* element, ExceptionState& e s)
1777 {
1778 if (!element) {
1779 es.throwDOMException(InvalidAccessError);
1780 return 0;
1781 }
1782
1783 RenderObject* renderer = element->renderer();
1784 if (!renderer || !renderer->isBox()) {
1785 es.throwDOMException(InvalidAccessError);
1786 return 0;
1787 }
1788
1789 RenderLayer* layer = toRenderBox(renderer)->layer();
1790 if (!layer) {
1791 es.throwDOMException(InvalidAccessError);
1792 return 0;
1793 }
1794
1795 return layer;
1796 }
1797
1776 void Internals::setNeedsCompositedScrolling(Element* element, unsigned needsComp ositedScrolling, ExceptionState& es) 1798 void Internals::setNeedsCompositedScrolling(Element* element, unsigned needsComp ositedScrolling, ExceptionState& es)
1777 { 1799 {
1778 if (!element) { 1800 if (!element) {
1779 es.throwDOMException(InvalidAccessError); 1801 es.throwDOMException(InvalidAccessError);
1780 return; 1802 return;
1781 } 1803 }
1782 1804
1783 element->document().updateLayout(); 1805 element->document().updateLayout();
1784 1806
1785 RenderObject* renderer = element->renderer(); 1807 if (RenderLayer* layer = getRenderLayerForElement(element, es))
1786 if (!renderer || !renderer->isBox()) { 1808 layer->setForceNeedsCompositedScrolling(static_cast<RenderLayer::ForceNe edsCompositedScrollingMode>(needsCompositedScrolling));
1787 es.throwDOMException(InvalidAccessError); 1809 }
1788 return;
1789 }
1790 1810
1791 RenderLayer* layer = toRenderBox(renderer)->layer(); 1811 bool Internals::isScrollParent(Element* child, Element* parent, ExceptionState& es)
1792 if (!layer) { 1812 {
1793 es.throwDOMException(InvalidAccessError); 1813 RenderLayer* childLayer = getRenderLayerForElement(child, es);
1794 return; 1814 RenderLayer* parentLayer = getRenderLayerForElement(parent, es);
1795 } 1815 return childLayer && parentLayer && childLayer->scrollParent() == parentLaye r;
1816 }
1796 1817
1797 layer->setForceNeedsCompositedScrolling(static_cast<RenderLayer::ForceNeedsC ompositedScrollingMode>(needsCompositedScrolling)); 1818 bool Internals::isClipParent(Element* child, Element* parent, ExceptionState& es )
1819 {
1820 RenderLayer* childLayer = getRenderLayerForElement(child, es);
1821 RenderLayer* parentLayer = getRenderLayerForElement(parent, es);
1822 return childLayer && parentLayer && childLayer->clipParent() == parentLayer;
1823 }
1824
1825 PassRefPtr<ClientRect> Internals::scrollClip(Element* element, ExceptionState& e s)
1826 {
1827 RenderLayer* layer = getRenderLayerForElement(element, es);
1828 if (!layer || !layer->backing() || !layer->backing()->scrollingLayer())
1829 return ClientRect::create();
1830
1831 return ClientRect::create(
1832 FloatRect(
1833 layer->backing()->scrollingLayer()->boundsOrigin(),
1834 layer->backing()->scrollingLayer()->size()));
1835 }
1836
1837 PassRefPtr<ClientRect> Internals::ancestorScrollClip(Element* element, Exception State& es)
1838 {
1839 RenderLayer* layer = getRenderLayerForElement(element, es);
1840 if (!layer || !layer->backing() || !layer->backing()->ancestorScrollClipping Layer())
1841 return ClientRect::create();
1842
1843 return ClientRect::create(
1844 FloatRect(
1845 layer->backing()->ancestorScrollClippingLayer()->boundsOrigin(),
1846 layer->backing()->ancestorScrollClippingLayer()->size()));
1798 } 1847 }
1799 1848
1800 String Internals::repaintRectsAsText(Document* document, ExceptionState& es) con st 1849 String Internals::repaintRectsAsText(Document* document, ExceptionState& es) con st
1801 { 1850 {
1802 if (!document || !document->frame()) { 1851 if (!document || !document->frame()) {
1803 es.throwDOMException(InvalidAccessError); 1852 es.throwDOMException(InvalidAccessError);
1804 return String(); 1853 return String();
1805 } 1854 }
1806 1855
1807 return document->frame()->trackedRepaintRectsAsText(); 1856 return document->frame()->trackedRepaintRectsAsText();
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
2222 return false; 2271 return false;
2223 sharedContext->getExtensions()->loseContextCHROMIUM(Extensions3D::GUILTY_CON TEXT_RESET_ARB, Extensions3D::INNOCENT_CONTEXT_RESET_ARB); 2272 sharedContext->getExtensions()->loseContextCHROMIUM(Extensions3D::GUILTY_CON TEXT_RESET_ARB, Extensions3D::INNOCENT_CONTEXT_RESET_ARB);
2224 // To prevent tests that call loseSharedGraphicsContext3D from being 2273 // To prevent tests that call loseSharedGraphicsContext3D from being
2225 // flaky, we call finish so that the context is guaranteed to be lost 2274 // flaky, we call finish so that the context is guaranteed to be lost
2226 // synchronously (i.e. before returning). 2275 // synchronously (i.e. before returning).
2227 sharedContext->finish(); 2276 sharedContext->finish();
2228 return true; 2277 return true;
2229 } 2278 }
2230 2279
2231 } 2280 }
OLDNEW
« 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