OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |