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

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: Addressing enne's review. 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
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 1749 matching lines...) Expand 10 before | Expand all | Expand 10 after
1760 if (!layer 1760 if (!layer
1761 || !layer->backing() 1761 || !layer->backing()
1762 || !layer->backing()->graphicsLayer()) { 1762 || !layer->backing()->graphicsLayer()) {
1763 // Don't raise exception in these cases which may be normally used in te sts. 1763 // Don't raise exception in these cases which may be normally used in te sts.
1764 return String(); 1764 return String();
1765 } 1765 }
1766 1766
1767 return layer->backing()->graphicsLayer()->layerTreeAsText(flags); 1767 return layer->backing()->graphicsLayer()->layerTreeAsText(flags);
1768 } 1768 }
1769 1769
1770 static RenderLayer* getRenderLayerForElement(Element* element, ExceptionState& e s)
1771 {
1772 if (!element) {
1773 es.throwDOMException(InvalidAccessError);
1774 return 0;
1775 }
1776
1777 RenderObject* renderer = element->renderer();
1778 if (!renderer || !renderer->isBox()) {
1779 es.throwDOMException(InvalidAccessError);
1780 return 0;
1781 }
1782
1783 RenderLayer* layer = toRenderBox(renderer)->layer();
1784 if (!layer) {
1785 es.throwDOMException(InvalidAccessError);
1786 return 0;
1787 }
1788
1789 return layer;
1790 }
1791
1770 void Internals::setNeedsCompositedScrolling(Element* element, unsigned needsComp ositedScrolling, ExceptionState& es) 1792 void Internals::setNeedsCompositedScrolling(Element* element, unsigned needsComp ositedScrolling, ExceptionState& es)
1771 { 1793 {
1772 if (!element) { 1794 if (!element) {
1773 es.throwDOMException(InvalidAccessError); 1795 es.throwDOMException(InvalidAccessError);
1774 return; 1796 return;
1775 } 1797 }
1776 1798
1777 element->document().updateLayout(); 1799 element->document().updateLayout();
1778 1800
1779 RenderObject* renderer = element->renderer(); 1801 if (RenderLayer* layer = getRenderLayerForElement(element, es))
1780 if (!renderer || !renderer->isBox()) { 1802 layer->setForceNeedsCompositedScrolling(static_cast<RenderLayer::ForceNe edsCompositedScrollingMode>(needsCompositedScrolling));
1781 es.throwDOMException(InvalidAccessError); 1803 }
1782 return;
1783 }
1784 1804
1785 RenderLayer* layer = toRenderBox(renderer)->layer(); 1805 bool Internals::isScrollParent(Element* child, Element* parent, ExceptionState& es)
1786 if (!layer) { 1806 {
1787 es.throwDOMException(InvalidAccessError); 1807 RenderLayer* childLayer = getRenderLayerForElement(child, es);
1788 return; 1808 RenderLayer* parentLayer = getRenderLayerForElement(parent, es);
1789 } 1809 return childLayer && parentLayer && childLayer->scrollParent() == parentLaye r;
1810 }
1790 1811
1791 layer->setForceNeedsCompositedScrolling(static_cast<RenderLayer::ForceNeedsC ompositedScrollingMode>(needsCompositedScrolling)); 1812 bool Internals::isClipParent(Element* child, Element* parent, ExceptionState& es )
1813 {
1814 RenderLayer* childLayer = getRenderLayerForElement(child, es);
1815 RenderLayer* parentLayer = getRenderLayerForElement(parent, es);
1816 return childLayer && parentLayer && childLayer->clipParent() == parentLayer;
1817 }
1818
1819 PassRefPtr<ClientRect> Internals::scrollClip(Element* element, ExceptionState& e s)
1820 {
1821 RenderLayer* layer = getRenderLayerForElement(element, es);
1822 if (!layer || !layer->backing() || !layer->backing()->scrollingLayer())
1823 return ClientRect::create();
1824
1825 return ClientRect::create(
1826 FloatRect(
1827 layer->backing()->scrollingLayer()->boundsOrigin(),
1828 layer->backing()->scrollingLayer()->size()));
1829 }
1830
1831 PassRefPtr<ClientRect> Internals::ancestorScrollClip(Element* element, Exception State& es)
1832 {
1833 RenderLayer* layer = getRenderLayerForElement(element, es);
1834 if (!layer || !layer->backing() || !layer->backing()->ancestorScrollClipping Layer())
1835 return ClientRect::create();
1836
1837 return ClientRect::create(
1838 FloatRect(
1839 layer->backing()->ancestorScrollClippingLayer()->boundsOrigin(),
1840 layer->backing()->ancestorScrollClippingLayer()->size()));
1792 } 1841 }
1793 1842
1794 String Internals::repaintRectsAsText(Document* document, ExceptionState& es) con st 1843 String Internals::repaintRectsAsText(Document* document, ExceptionState& es) con st
1795 { 1844 {
1796 if (!document || !document->frame()) { 1845 if (!document || !document->frame()) {
1797 es.throwDOMException(InvalidAccessError); 1846 es.throwDOMException(InvalidAccessError);
1798 return String(); 1847 return String();
1799 } 1848 }
1800 1849
1801 return document->frame()->trackedRepaintRectsAsText(); 1850 return document->frame()->trackedRepaintRectsAsText();
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
2211 return false; 2260 return false;
2212 sharedContext->getExtensions()->loseContextCHROMIUM(Extensions3D::GUILTY_CON TEXT_RESET_ARB, Extensions3D::INNOCENT_CONTEXT_RESET_ARB); 2261 sharedContext->getExtensions()->loseContextCHROMIUM(Extensions3D::GUILTY_CON TEXT_RESET_ARB, Extensions3D::INNOCENT_CONTEXT_RESET_ARB);
2213 // To prevent tests that call loseSharedGraphicsContext3D from being 2262 // To prevent tests that call loseSharedGraphicsContext3D from being
2214 // flaky, we call finish so that the context is guaranteed to be lost 2263 // flaky, we call finish so that the context is guaranteed to be lost
2215 // synchronously (i.e. before returning). 2264 // synchronously (i.e. before returning).
2216 sharedContext->finish(); 2265 sharedContext->finish();
2217 return true; 2266 return true;
2218 } 2267 }
2219 2268
2220 } 2269 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698