Source/WebCore/ChangeLog

 12013-08-30 Simon Fraser <simon.fraser@apple.com>
 2
 3 Video with object-fit: cover can spill outside the box
 4 https://bugs.webkit.org/show_bug.cgi?id=52103
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 object-fit on renderers which use accelerated compositing needs special
 9 treatment.
 10
 11 For directly composited images, and video, GraphicsLayer needs to know
 12 both the size of the content layer, and also a rectangle at which this
 13 should be clipped (because, for the first time, that content layer can be
 14 larger than the renderer's content box).
 15
 16 AVFoundation would always aspect-ratio fit video by default, so plumb
 17 through MediaPlayer a way to override that when object-fit requires it.
 18
 19 Added a LAYER_TREE_INCLUDES_CONTENT_LAYERS enum to the layerTreeAsText()
 20 flags so we can dump content layers for testing.
 21
 22 Tests: compositing/images/direct-image-object-fit.html
 23 compositing/reflections/direct-image-object-fit-reflected.html
 24 compositing/video/video-object-fit.html
 25
 26 * page/Frame.h: New LayerTreeFlagsIncludeContentLayers flag.
 27 * platform/graphics/GraphicsLayer.h: New flag.
 28 * platform/graphics/MediaPlayer.cpp:
 29 (WebCore::MediaPlayer::shouldMaintainAspectRatio):
 30 (WebCore::MediaPlayer::setShouldMaintainAspectRatio):
 31 * platform/graphics/MediaPlayer.h:
 32 * platform/graphics/MediaPlayerPrivate.h:
 33 (WebCore::MediaPlayerPrivateInterface::shouldMaintainAspectRatio):
 34 (WebCore::MediaPlayerPrivateInterface::setShouldMaintainAspectRatio):
 35 * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
 36 (WebCore::MediaPlayerPrivateAVFoundation::MediaPlayerPrivateAVFoundation):
 37 (WebCore::MediaPlayerPrivateAVFoundation::setShouldMaintainAspectRatio):
 38 * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:
 39 * platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:
 40 (WebCore::MediaPlayerPrivateAVFoundationCF::updateVideoLayerGravity):
 41 (WebCore::AVFWrapper::platformLayer):
 42 * platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.h:
 43 * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
 44 * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
 45 (WebCore::MediaPlayerPrivateAVFoundationObjC::createVideoLayer):
 46 (WebCore::MediaPlayerPrivateAVFoundationObjC::updateVideoLayerGravity):
 47 * platform/graphics/ca/GraphicsLayerCA.cpp: We need a new m_contentsClippingLayer to
 48 clip the contents layer, which only gets created when necessary. It has to be cloned
 49 for reflections.
 50 (WebCore::GraphicsLayerCA::willBeDestroyed):
 51 (WebCore::GraphicsLayerCA::setContentsRect):
 52 (WebCore::GraphicsLayerCA::setContentsClippingRect):
 53 (WebCore::GraphicsLayerCA::commitLayerChangesBeforeSublayers):
 54 (WebCore::GraphicsLayerCA::updateSublayerList):
 55 (WebCore::GraphicsLayerCA::updateContentsImage):
 56 (WebCore::GraphicsLayerCA::updateContentsMediaLayer):
 57 (WebCore::GraphicsLayerCA::updateContentsCanvasLayer):
 58 (WebCore::GraphicsLayerCA::updateContentsColorLayer):
 59 (WebCore::GraphicsLayerCA::updateContentsRects):
 60 (WebCore::GraphicsLayerCA::dumpAdditionalProperties):
 61 (WebCore::GraphicsLayerCA::ensureCloneLayers):
 62 (WebCore::GraphicsLayerCA::removeCloneLayers):
 63 (WebCore::GraphicsLayerCA::fetchCloneLayers):
 64 * platform/graphics/ca/GraphicsLayerCA.h:
 65 * rendering/RenderLayerBacking.cpp: Need to push both the contentsRect and
 66 the contentsClippingRect down to the GraphicsLayers. Most of the time they
 67 are the same, unless object-fit makes them different.
 68 (WebCore::RenderLayerBacking::resetContentsRect):
 69 (WebCore::RenderLayerBacking::positionOverflowControlsLayers):
 70 (WebCore::RenderLayerBacking::updateDirectlyCompositedBackgroundColor):
 71 (WebCore::RenderLayerBacking::updateDirectlyCompositedBackgroundImage):
 72 (WebCore::RenderLayerBacking::updateImageContents):
 73 (WebCore::RenderLayerBacking::contentsBox):
 74 * rendering/RenderLayerCompositor.cpp:
 75 (WebCore::RenderLayerCompositor::layerTreeAsText):
 76 * rendering/RenderVideo.cpp:
 77 (WebCore::RenderVideo::updatePlayer):
 78 * testing/Internals.cpp:
 79 (WebCore::Internals::layerTreeAsText):
 80 * testing/Internals.h:
 81 * testing/Internals.idl:
 82
1832013-08-30 Mikhail Pozdnyakov <mikhail.pozdnyakov@intel.com>
284
385 SimpleClassVectorTraits shall be used for RuleData

Source/WebCore/page/Frame.h

@@namespace WebCore {
8282 LayerTreeFlagsIncludeVisibleRects = 1 << 1,
8383 LayerTreeFlagsIncludeTileCaches = 1 << 2,
8484 LayerTreeFlagsIncludeRepaintRects = 1 << 3,
85  LayerTreeFlagsIncludePaintingPhases = 1 << 4
 85 LayerTreeFlagsIncludePaintingPhases = 1 << 4,
 86 LayerTreeFlagsIncludeContentLayers = 1 << 5
8687 };
8788 typedef unsigned LayerTreeFlags;
8889

Source/WebCore/platform/graphics/GraphicsLayer.h

@@enum LayerTreeAsTextBehaviorFlags {
5050 LayerTreeAsTextIncludeVisibleRects = 1 << 1,
5151 LayerTreeAsTextIncludeTileCaches = 1 << 2,
5252 LayerTreeAsTextIncludeRepaintRects = 1 << 3,
53  LayerTreeAsTextIncludePaintingPhases = 1 << 4
 53 LayerTreeAsTextIncludePaintingPhases = 1 << 4,
 54 LayerTreeAsTextIncludeContentLayers = 1 << 5
5455};
5556typedef unsigned LayerTreeAsTextBehavior;
5657

Source/WebCore/platform/graphics/MediaPlayer.cpp

@@bool MediaPlayer::supportsAcceleratedRendering() const
842842}
843843#endif // USE(ACCELERATED_COMPOSITING)
844844
 845bool MediaPlayer::shouldMaintainAspectRatio() const
 846{
 847 return m_private->shouldMaintainAspectRatio();
 848}
 849
 850void MediaPlayer::setShouldMaintainAspectRatio(bool maintainAspectRatio)
 851{
 852 m_private->setShouldMaintainAspectRatio(maintainAspectRatio);
 853}
 854
845855bool MediaPlayer::hasSingleSecurityOrigin() const
846856{
847857 return m_private->hasSingleSecurityOrigin();

Source/WebCore/platform/graphics/MediaPlayer.h

@@public:
414414 void acceleratedRenderingStateChanged();
415415#endif
416416
 417 bool shouldMaintainAspectRatio() const;
 418 void setShouldMaintainAspectRatio(bool);
 419
417420#if PLATFORM(WIN) && USE(AVFOUNDATION)
418421 GraphicsDeviceAdapter* graphicsDeviceAdapter() const;
419422#endif

Source/WebCore/platform/graphics/MediaPlayerPrivate.h

@@public:
149149 virtual void acceleratedRenderingStateChanged() { }
150150#endif
151151
 152 virtual bool shouldMaintainAspectRatio() const { return true; }
 153 virtual void setShouldMaintainAspectRatio(bool) { }
 154
152155 virtual bool hasSingleSecurityOrigin() const { return false; }
153156
154157 virtual bool didPassCORSAccessCheck() const { return false; }

Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp

@@MediaPlayerPrivateAVFoundation::MediaPlayerPrivateAVFoundation(MediaPlayer* play
7777 , m_playWhenFramesAvailable(false)
7878 , m_inbandTrackConfigurationPending(false)
7979 , m_characteristicsChanged(false)
 80 , m_shouldMaintainAspectRatio(true)
8081 , m_seekCount(0)
8182{
8283 LOG(Media, "MediaPlayerPrivateAVFoundation::MediaPlayerPrivateAVFoundation(%p)", this);

@@void MediaPlayerPrivateAVFoundation::acceleratedRenderingStateChanged()
582583 setUpVideoRendering();
583584}
584585
 586void MediaPlayerPrivateAVFoundation::setShouldMaintainAspectRatio(bool maintainAspectRatio)
 587{
 588 if (maintainAspectRatio == m_shouldMaintainAspectRatio)
 589 return;
 590
 591 m_shouldMaintainAspectRatio = maintainAspectRatio;
 592 updateVideoLayerGravity();
 593}
 594
585595void MediaPlayerPrivateAVFoundation::metadataLoaded()
586596{
587597 m_loadingMetadata = false;

Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h

@@protected:
165165 virtual bool supportsAcceleratedRendering() const = 0;
166166 virtual void acceleratedRenderingStateChanged();
167167#endif
 168 virtual bool shouldMaintainAspectRatio() const OVERRIDE { return m_shouldMaintainAspectRatio; }
 169 virtual void setShouldMaintainAspectRatio(bool) OVERRIDE;
 170
168171 virtual MediaPlayer::MovieLoadType movieLoadType() const;
169172 virtual void prepareForRendering();
170173 virtual float mediaTimeForTimeValue(float) const = 0;

@@protected:
228231 virtual bool hasContextRenderer() const = 0;
229232 virtual bool hasLayerRenderer() const = 0;
230233
 234 virtual void updateVideoLayerGravity() = 0;
 235
231236protected:
232237 void updateStates();
233238

@@private:
308313 bool m_playWhenFramesAvailable;
309314 bool m_inbandTrackConfigurationPending;
310315 bool m_characteristicsChanged;
 316 bool m_shouldMaintainAspectRatio;
311317 size_t m_seekCount;
312318};
313319

Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp

@@void MediaPlayerPrivateAVFoundationCF::cancelLoad()
332332 setDelayCallbacks(false);
333333}
334334
 335void MediaPlayerPrivateAVFoundationCF::updateVideoLayerGravity()
 336{
 337 // We should call AVCFPlayerLayerSetVideoGravity() here, but it is not yet implemented.
 338}
 339
335340bool MediaPlayerPrivateAVFoundationCF::hasLayerRenderer() const
336341{
337342 return videoLayer(m_avfWrapper);

@@PlatformLayer* AVFWrapper::platformLayer()
15661571 CACFLayerInsertSublayer(m_videoLayerWrapper->platformLayer(), m_caVideoLayer.get(), 0);
15671572 m_videoLayerWrapper->setAnchorPoint(FloatPoint3D());
15681573 m_videoLayerWrapper->setNeedsLayout();
 1574 updateVideoLayerGravity();
15691575
15701576 return m_videoLayerWrapper->platformLayer();
15711577}

Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.h

@@private:
9797 virtual bool hasContextRenderer() const;
9898 virtual bool hasLayerRenderer() const;
9999
 100 virtual void updateVideoLayerGravity() OVERRIDE;
 101
100102 virtual void contentsNeedsDisplay();
101103
102104 virtual String languageOfPrimaryAudioTrack() const OVERRIDE;

Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h

@@private:
148148 virtual bool hasContextRenderer() const;
149149 virtual bool hasLayerRenderer() const;
150150
 151 virtual void updateVideoLayerGravity() OVERRIDE;
 152
151153 virtual bool hasSingleSecurityOrigin() const;
152154
153155#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1080

Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm

@@SOFT_LINK_POINTER(AVFoundation, AVMediaTypeAudio, NSString *)
9898SOFT_LINK_POINTER(AVFoundation, AVPlayerItemDidPlayToEndTimeNotification, NSString *)
9999SOFT_LINK_POINTER(AVFoundation, AVAssetImageGeneratorApertureModeCleanAperture, NSString *)
100100SOFT_LINK_POINTER(AVFoundation, AVURLAssetReferenceRestrictionsKey, NSString *)
 101SOFT_LINK_POINTER(AVFoundation, AVLayerVideoGravityResizeAspect, NSString *)
 102SOFT_LINK_POINTER(AVFoundation, AVLayerVideoGravityResize, NSString *)
101103
102104SOFT_LINK_CONSTANT(CoreMedia, kCMTimeZero, CMTime)
103105

@@SOFT_LINK_CONSTANT(CoreMedia, kCMTimeZero, CMTime)
116118#define AVPlayerItemDidPlayToEndTimeNotification getAVPlayerItemDidPlayToEndTimeNotification()
117119#define AVAssetImageGeneratorApertureModeCleanAperture getAVAssetImageGeneratorApertureModeCleanAperture()
118120#define AVURLAssetReferenceRestrictionsKey getAVURLAssetReferenceRestrictionsKey()
 121#define AVLayerVideoGravityResizeAspect getAVLayerVideoGravityResizeAspect()
 122#define AVLayerVideoGravityResize getAVLayerVideoGravityResize()
119123
120124#if HAVE(AVFOUNDATION_MEDIA_SELECTION_GROUP)
121125typedef AVMediaSelectionGroup AVMediaSelectionGroupType;

@@void MediaPlayerPrivateAVFoundationObjC::createVideoLayer()
372376#ifndef NDEBUG
373377 [m_videoLayer.get() setName:@"Video layer"];
374378#endif
 379 updateVideoLayerGravity();
375380 LOG(Media, "MediaPlayerPrivateAVFoundationObjC::createVideoLayer(%p) - returning %p", this, m_videoLayer.get());
376381 }
377382}

@@float MediaPlayerPrivateAVFoundationObjC::mediaTimeForTimeValue(float timeValue)
987992 return timeValue;
988993}
989994
 995void MediaPlayerPrivateAVFoundationObjC::updateVideoLayerGravity()
 996{
 997 if (!m_videoLayer)
 998 return;
 999
 1000 [CATransaction begin];
 1001 [CATransaction setDisableActions:YES];
 1002 NSString* gravity = shouldMaintainAspectRatio() ? AVLayerVideoGravityResizeAspect : AVLayerVideoGravityResize;
 1003 [m_videoLayer.get() setVideoGravity:gravity];
 1004 [CATransaction commit];
 1005}
 1006
9901007void MediaPlayerPrivateAVFoundationObjC::tracksChanged()
9911008{
9921009 String primaryAudioTrackLanguage = m_languageOfPrimaryAudioTrack;

Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp

@@void GraphicsLayerCA::willBeDestroyed()
305305
306306 if (m_contentsLayer)
307307 m_contentsLayer->setOwner(0);
 308
 309 if (m_contentsClippingLayer)
 310 m_contentsClippingLayer->setOwner(0);
308311
309312 if (m_structuralLayer)
310313 m_structuralLayer->setOwner(0);

@@void GraphicsLayerCA::setContentsRect(const IntRect& rect)
669672 return;
670673
671674 GraphicsLayer::setContentsRect(rect);
672  noteLayerPropertyChanged(ContentsRectChanged);
 675 noteLayerPropertyChanged(ContentsRectsChanged);
 676}
 677
 678void GraphicsLayerCA::setContentsClippingRect(const IntRect& rect)
 679{
 680 if (rect == m_contentsClippingRect)
 681 return;
 682
 683 GraphicsLayer::setContentsClippingRect(rect);
 684 noteLayerPropertyChanged(ContentsRectsChanged);
673685}
674686
675687bool GraphicsLayerCA::shouldRepaintOnSizeChange() const

@@void GraphicsLayerCA::commitLayerChangesBeforeSublayers(CommitState& commitState
12141226 if (m_uncommittedChanges & DirtyRectsChanged)
12151227 repaintLayerDirtyRects();
12161228
1217  if (m_uncommittedChanges & ContentsRectChanged)
1218  updateContentsRect();
 1229 if (m_uncommittedChanges & ContentsRectsChanged) // Needs to happen before ChildrenChanged
 1230 updateContentsRects();
12191231
12201232 if (m_uncommittedChanges & MaskLayerChanged)
12211233 updateMaskLayer();

@@void GraphicsLayerCA::updateSublayerList(bool maxLayerDepthReached)
12971309 // FIXME: add the contents layer in the correct order with negative z-order children.
12981310 // This does not cause visible rendering issues because currently contents layers are only used
12991311 // for replaced elements that don't have children.
1300  primaryLayerChildren.append(m_contentsLayer);
 1312 primaryLayerChildren.append(m_contentsClippingLayer ? m_contentsClippingLayer : m_contentsLayer);
13011313 }
13021314
13031315 const Vector<GraphicsLayer*>& childLayers = children();

@@void GraphicsLayerCA::updateContentsImage()
17221734 it->value->setContents(m_contentsLayer->contents());
17231735 }
17241736
1725  updateContentsRect();
 1737 updateContentsRects();
17261738 } else {
17271739 // No image.
17281740 // m_contentsLayer will be removed via updateSublayerList.

@@void GraphicsLayerCA::updateContentsMediaLayer()
17371749
17381750 // Video layer was set as m_contentsLayer, and will get parented in updateSublayerList().
17391751 setupContentsLayer(m_contentsLayer.get());
1740  updateContentsRect();
 1752 updateContentsRects();
17411753}
17421754
17431755void GraphicsLayerCA::updateContentsCanvasLayer()

@@void GraphicsLayerCA::updateContentsCanvasLayer()
17481760 // CanvasLayer was set as m_contentsLayer, and will get parented in updateSublayerList().
17491761 setupContentsLayer(m_contentsLayer.get());
17501762 m_contentsLayer->setNeedsDisplay();
1751  updateContentsRect();
 1763 updateContentsRects();
17521764}
17531765
17541766void GraphicsLayerCA::updateContentsColorLayer()

@@void GraphicsLayerCA::updateContentsColorLayer()
17581770 return;
17591771
17601772 setupContentsLayer(m_contentsLayer.get());
1761  updateContentsRect();
 1773 updateContentsRects();
17621774 ASSERT(m_contentsSolidColor.isValid());
17631775 m_contentsLayer->setBackgroundColor(m_contentsSolidColor);
17641776

@@void GraphicsLayerCA::updateContentsColorLayer()
17691781 }
17701782}
17711783
1772 void GraphicsLayerCA::updateContentsRect()
 1784void GraphicsLayerCA::updateContentsRects()
17731785{
17741786 if (!m_contentsLayer)
17751787 return;
17761788
1777  FloatPoint point(m_contentsRect.x(), m_contentsRect.y());
1778  FloatRect rect(0, 0, m_contentsRect.width(), m_contentsRect.height());
 1789 FloatPoint contentOrigin;
 1790 FloatRect contentBounds(0, 0, m_contentsRect.width(), m_contentsRect.height());
 1791
 1792 FloatPoint clippingOrigin;
 1793 FloatRect clippingBounds;
 1794
 1795 bool needContentsClippingLayer = !m_contentsClippingRect.contains(m_contentsRect);
 1796 bool gainedOrLostClippingLayer = false;
 1797 if (needContentsClippingLayer) {
 1798 if (!m_contentsClippingLayer) {
 1799 m_contentsClippingLayer = PlatformCALayer::create(PlatformCALayer::LayerTypeLayer, this);
 1800 m_contentsClippingLayer->setMasksToBounds(true);
 1801 m_contentsClippingLayer->setAnchorPoint(FloatPoint());
 1802#ifndef NDEBUG
 1803 m_contentsClippingLayer->setName("Contents Clipping");
 1804#endif
 1805 m_contentsLayer->removeFromSuperlayer();
 1806 m_contentsClippingLayer->appendSublayer(m_contentsLayer.get());
 1807 gainedOrLostClippingLayer = true;
 1808 }
 1809
 1810 clippingOrigin = m_contentsClippingRect.location();
 1811 clippingBounds.setSize(m_contentsClippingRect.size());
 1812
 1813 contentOrigin = toPoint(m_contentsRect.location() - m_contentsClippingRect.location());
 1814
 1815 m_contentsClippingLayer->setPosition(clippingOrigin);
 1816 m_contentsClippingLayer->setBounds(clippingBounds);
 1817
 1818 m_contentsLayer->setPosition(contentOrigin);
 1819 m_contentsLayer->setBounds(contentBounds);
 1820
 1821 } else {
 1822 if (m_contentsClippingLayer) {
 1823 m_contentsLayer->removeFromSuperlayer();
17791824
1780  m_contentsLayer->setPosition(point);
1781  m_contentsLayer->setBounds(rect);
 1825 m_contentsClippingLayer->removeFromSuperlayer();
 1826 m_contentsClippingLayer->setOwner(0);
 1827 m_contentsClippingLayer = nullptr;
 1828 gainedOrLostClippingLayer = true;
 1829 }
 1830
 1831 contentOrigin = m_contentsRect.location();
 1832 }
 1833
 1834 if (gainedOrLostClippingLayer)
 1835 noteSublayersChanged();
 1836
 1837 m_contentsLayer->setPosition(contentOrigin);
 1838 m_contentsLayer->setBounds(contentBounds);
17821839
17831840 if (m_contentsLayerClones) {
17841841 LayerMap::const_iterator end = m_contentsLayerClones->end();
17851842 for (LayerMap::const_iterator it = m_contentsLayerClones->begin(); it != end; ++it) {
1786  it->value->setPosition(point);
1787  it->value->setBounds(rect);
 1843 it->value->setPosition(contentOrigin);
 1844 it->value->setBounds(contentBounds);
 1845 }
 1846 }
 1847
 1848 if (m_contentsClippingLayerClones) {
 1849 LayerMap::const_iterator end = m_contentsClippingLayerClones->end();
 1850 for (LayerMap::const_iterator it = m_contentsClippingLayerClones->begin(); it != end; ++it) {
 1851 it->value->setPosition(clippingOrigin);
 1852 it->value->setBounds(clippingBounds);
17881853 }
17891854 }
17901855}

@@void GraphicsLayerCA::dumpAdditionalProperties(TextStream& textStream, int inden
26602725 writeIndent(textStream, indent + 1);
26612726 textStream << "(top left tile " << gridExtent.x() << ", " << gridExtent.y() << " tiles grid " << gridExtent.width() << " x " << gridExtent.height() << ")\n";
26622727 }
 2728
 2729 if (behavior & LayerTreeAsTextIncludeContentLayers) {
 2730 if (m_contentsClippingLayer) {
 2731 writeIndent(textStream, indent + 1);
 2732 textStream << "(contents clipping layer " << m_contentsClippingLayer->position().x() << ", " << m_contentsClippingLayer->position().y()
 2733 << " " << m_contentsClippingLayer->bounds().width() << " x " << m_contentsClippingLayer->bounds().height() << ")\n";
 2734 }
 2735
 2736 if (m_contentsLayer) {
 2737 writeIndent(textStream, indent + 1);
 2738 textStream << "(contents layer " << m_contentsLayer->position().x() << ", " << m_contentsLayer->position().y()
 2739 << " " << m_contentsLayer->bounds().width() << " x " << m_contentsLayer->bounds().height() << ")\n";
 2740 }
 2741 }
26632742}
26642743
26652744void GraphicsLayerCA::setDebugBorder(const Color& color, float borderWidth)

@@PassRefPtr<PlatformCALayer> GraphicsLayerCA::findOrMakeClone(CloneID cloneID, Pl
27952874 return resultLayer;
27962875}
27972876
2798 void GraphicsLayerCA::ensureCloneLayers(CloneID cloneID, RefPtr<PlatformCALayer>& primaryLayer, RefPtr<PlatformCALayer>& structuralLayer, RefPtr<PlatformCALayer>& contentsLayer, CloneLevel cloneLevel)
 2877void GraphicsLayerCA::ensureCloneLayers(CloneID cloneID, RefPtr<PlatformCALayer>& primaryLayer, RefPtr<PlatformCALayer>& structuralLayer,
 2878 RefPtr<PlatformCALayer>& contentsLayer, RefPtr<PlatformCALayer>& contentsClippingLayer, CloneLevel cloneLevel)
27992879{
28002880 structuralLayer = 0;
28012881 contentsLayer = 0;

@@void GraphicsLayerCA::ensureCloneLayers(CloneID cloneID, RefPtr<PlatformCALayer>
28092889 if (!m_contentsLayerClones && m_contentsLayer)
28102890 m_contentsLayerClones = adoptPtr(new LayerMap);
28112891
 2892 if (!m_contentsClippingLayerClones && m_contentsClippingLayer)
 2893 m_contentsClippingLayerClones = adoptPtr(new LayerMap);
 2894
28122895 primaryLayer = findOrMakeClone(cloneID, m_layer.get(), m_layerClones.get(), cloneLevel);
28132896 structuralLayer = findOrMakeClone(cloneID, m_structuralLayer.get(), m_structuralLayerClones.get(), cloneLevel);
28142897 contentsLayer = findOrMakeClone(cloneID, m_contentsLayer.get(), m_contentsLayerClones.get(), cloneLevel);
 2898 contentsClippingLayer = findOrMakeClone(cloneID, m_contentsClippingLayer.get(), m_contentsClippingLayerClones.get(), cloneLevel);
28152899}
28162900
28172901void GraphicsLayerCA::removeCloneLayers()

@@void GraphicsLayerCA::removeCloneLayers()
28192903 m_layerClones = nullptr;
28202904 m_structuralLayerClones = nullptr;
28212905 m_contentsLayerClones = nullptr;
 2906 m_contentsClippingLayerClones = nullptr;
28222907}
28232908
28242909FloatPoint GraphicsLayerCA::positionForCloneRootLayer() const

@@PassRefPtr<PlatformCALayer> GraphicsLayerCA::fetchCloneLayers(GraphicsLayer* rep
28492934 RefPtr<PlatformCALayer> primaryLayer;
28502935 RefPtr<PlatformCALayer> structuralLayer;
28512936 RefPtr<PlatformCALayer> contentsLayer;
2852  ensureCloneLayers(replicaState.cloneID(), primaryLayer, structuralLayer, contentsLayer, cloneLevel);
 2937 RefPtr<PlatformCALayer> contentsClippingLayer;
 2938 ensureCloneLayers(replicaState.cloneID(), primaryLayer, structuralLayer, contentsLayer, contentsClippingLayer, cloneLevel);
28532939
28542940 if (m_maskLayer) {
28552941 RefPtr<PlatformCALayer> maskClone = static_cast<GraphicsLayerCA*>(m_maskLayer)->fetchCloneLayers(replicaRoot, replicaState, IntermediateCloneLevel);

@@PassRefPtr<PlatformCALayer> GraphicsLayerCA::fetchCloneLayers(GraphicsLayer* rep
28822968 replicaLayer = static_cast<GraphicsLayerCA*>(m_replicaLayer)->fetchCloneLayers(replicaRoot, replicaState, RootCloneLevel);
28832969 replicaState.setBranchType(ReplicaState::ChildBranch);
28842970 }
 2971
 2972 if (contentsClippingLayer) {
 2973 ASSERT(contentsLayer);
 2974 contentsClippingLayer->appendSublayer(contentsLayer.get());
 2975 }
28852976
2886  if (replicaLayer || structuralLayer || contentsLayer || childLayers.size() > 0) {
 2977 if (replicaLayer || structuralLayer || contentsLayer || contentsClippingLayer || childLayers.size() > 0) {
28872978 if (structuralLayer) {
28882979 // Replicas render behind the actual layer content.
28892980 if (replicaLayer)

@@PassRefPtr<PlatformCALayer> GraphicsLayerCA::fetchCloneLayers(GraphicsLayer* rep
28912982
28922983 // Add the primary layer next. Even if we have negative z-order children, the primary layer always comes behind.
28932984 clonalSublayers.append(primaryLayer);
 2985 } else if (contentsClippingLayer) {
 2986 // FIXME: add the contents layer in the correct order with negative z-order children.
 2987 // This does not cause visible rendering issues because currently contents layers are only used
 2988 // for replaced elements that don't have children.
 2989 clonalSublayers.append(contentsClippingLayer);
28942990 } else if (contentsLayer) {
28952991 // FIXME: add the contents layer in the correct order with negative z-order children.
28962992 // This does not cause visible rendering issues because currently contents layers are only used

@@PassRefPtr<PlatformCALayer> GraphicsLayerCA::fetchCloneLayers(GraphicsLayer* rep
29193015 if (structuralLayer) {
29203016 structuralLayer->setSublayers(clonalSublayers);
29213017
2922  if (contentsLayer) {
 3018 if (contentsClippingLayer || contentsLayer) {
29233019 // If we have a transform layer, then the contents layer is parented in the
29243020 // primary layer (which is itself a child of the transform layer).
29253021 primaryLayer->removeAllSublayers();
2926  primaryLayer->appendSublayer(contentsLayer.get());
 3022 primaryLayer->appendSublayer(contentsClippingLayer ? contentsClippingLayer.get() : contentsLayer.get());
29273023 }
29283024
29293025 result = structuralLayer;

Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h

@@public:
105105 virtual void setContentsNeedsDisplay();
106106
107107 virtual void setContentsRect(const IntRect&);
 108 virtual void setContentsClippingRect(const IntRect&) OVERRIDE;
108109
109110 virtual void suspendAnimations(double time);
110111 virtual void resumeAnimations();

@@private:
314315 PassRefPtr<PlatformCALayer> cloneLayer(PlatformCALayer *, CloneLevel);
315316 PassRefPtr<PlatformCALayer> findOrMakeClone(CloneID, PlatformCALayer *, LayerMap*, CloneLevel);
316317
317  void ensureCloneLayers(CloneID cloneID, RefPtr<PlatformCALayer>& primaryLayer, RefPtr<PlatformCALayer>& structuralLayer, RefPtr<PlatformCALayer>& contentsLayer, CloneLevel cloneLevel);
 318 void ensureCloneLayers(CloneID, RefPtr<PlatformCALayer>& primaryLayer, RefPtr<PlatformCALayer>& structuralLayer,
 319 RefPtr<PlatformCALayer>& contentsLayer, RefPtr<PlatformCALayer>& contentsClippingLayer, CloneLevel);
318320
319321 bool hasCloneLayers() const { return m_layerClones; }
320322 void removeCloneLayers();

@@private:
340342 void updateContentsMediaLayer();
341343 void updateContentsCanvasLayer();
342344 void updateContentsColorLayer();
343  void updateContentsRect();
 345 void updateContentsRects();
344346 void updateMaskLayer();
345347 void updateReplicatedLayers();
346348

@@private:
392394 ContentsMediaLayerChanged = 1 << 16,
393395 ContentsCanvasLayerChanged = 1 << 17,
394396 ContentsColorLayerChanged = 1 << 18,
395  ContentsRectChanged = 1 << 19,
 397 ContentsRectsChanged = 1 << 19,
396398 MaskLayerChanged = 1 << 20,
397399 ReplicatedLayerChanged = 1 << 21,
398400 ContentsNeedsDisplay = 1 << 22,

@@private:
413415
414416 RefPtr<PlatformCALayer> m_layer; // The main layer
415417 RefPtr<PlatformCALayer> m_structuralLayer; // A layer used for structural reasons, like preserves-3d or replica-flattening. Is the parent of m_layer.
 418 RefPtr<PlatformCALayer> m_contentsClippingLayer; // A layer used to clip inner content
416419 RefPtr<PlatformCALayer> m_contentsLayer; // A layer used for inner content, like image and video
417420
418421 // References to clones of our layers, for replicated layers.
419422 OwnPtr<LayerMap> m_layerClones;
420423 OwnPtr<LayerMap> m_structuralLayerClones;
421424 OwnPtr<LayerMap> m_contentsLayerClones;
 425 OwnPtr<LayerMap> m_contentsClippingLayerClones;
422426
423427#ifdef VISIBLE_TILE_WASH
424428 RefPtr<PlatformCALayer> m_visibleTileWashLayer;

Source/WebCore/rendering/RenderLayerBacking.cpp

@@void RenderLayerBacking::updateInternalHierarchy()
925925
926926void RenderLayerBacking::resetContentsRect()
927927{
928  IntRect rect = pixelSnappedIntRect(contentsBox());
929  m_graphicsLayer->setContentsRect(rect);
 928 m_graphicsLayer->setContentsRect(pixelSnappedIntRect(contentsBox()));
 929
 930 LayoutRect contentsClippingRect;
 931 if (renderer().isBox())
 932 contentsClippingRect = toRenderBox(&renderer())->contentBoxRect();
 933
 934 contentsClippingRect.move(contentOffsetInCompostingLayer());
 935 m_graphicsLayer->setContentsClippingRect(pixelSnappedIntRect(contentsClippingRect));
 936
930937 m_graphicsLayer->setContentsTileSize(IntSize());
931938 m_graphicsLayer->setContentsTilePhase(IntPoint());
932939}

@@void RenderLayerBacking::positionOverflowControlsLayers(const IntSize& offsetFro
10781085 if (hBar) {
10791086 layer->setPosition(hBar->frameRect().location() - offsetFromRoot - offsetFromRenderer);
10801087 layer->setSize(hBar->frameRect().size());
1081  if (layer->hasContentsLayer())
1082  layer->setContentsRect(IntRect(IntPoint(), hBar->frameRect().size()));
 1088 if (layer->hasContentsLayer()) {
 1089 IntRect barRect = IntRect(IntPoint(), hBar->frameRect().size());
 1090 layer->setContentsRect(barRect);
 1091 layer->setContentsClippingRect(barRect);
 1092 }
10831093 }
10841094 layer->setDrawsContent(hBar && !layer->hasContentsLayer());
10851095 }

@@void RenderLayerBacking::positionOverflowControlsLayers(const IntSize& offsetFro
10891099 if (vBar) {
10901100 layer->setPosition(vBar->frameRect().location() - offsetFromRoot - offsetFromRenderer);
10911101 layer->setSize(vBar->frameRect().size());
1092  if (layer->hasContentsLayer())
1093  layer->setContentsRect(IntRect(IntPoint(), vBar->frameRect().size()));
 1102 if (layer->hasContentsLayer()) {
 1103 IntRect barRect = IntRect(IntPoint(), vBar->frameRect().size());
 1104 layer->setContentsRect(barRect);
 1105 layer->setContentsClippingRect(barRect);
 1106 }
10941107 }
10951108 layer->setDrawsContent(vBar && !layer->hasContentsLayer());
10961109 }

@@void RenderLayerBacking::updateDirectlyCompositedBackgroundColor(bool isSimpleCo
13831396
13841397 // An unset (invalid) color will remove the solid color.
13851398 m_graphicsLayer->setContentsToSolidColor(backgroundColor);
1386  m_graphicsLayer->setContentsRect(backgroundBox());
 1399 IntRect contentsRect = backgroundBox();
 1400 m_graphicsLayer->setContentsRect(contentsRect);
 1401 m_graphicsLayer->setContentsClippingRect(contentsRect);
13871402 didUpdateContentsRect = true;
13881403}
13891404

@@void RenderLayerBacking::updateDirectlyCompositedBackgroundImage(bool isSimpleCo
14431458 m_graphicsLayer->setContentsTileSize(tileSize);
14441459 m_graphicsLayer->setContentsTilePhase(phase);
14451460 m_graphicsLayer->setContentsRect(destRect);
 1461 m_graphicsLayer->setContentsClippingRect(destRect);
14461462 m_graphicsLayer->setContentsToImage(image.get());
14471463 didUpdateContentsRect = true;
14481464}

@@void RenderLayerBacking::updateImageContents()
17251741
17261742 // This is a no-op if the layer doesn't have an inner layer for the image.
17271743 m_graphicsLayer->setContentsRect(pixelSnappedIntRect(contentsBox()));
 1744
 1745 LayoutRect contentsClippingRect = imageRenderer->contentBoxRect();
 1746 contentsClippingRect.move(contentOffsetInCompostingLayer());
 1747 m_graphicsLayer->setContentsClippingRect(pixelSnappedIntRect(contentsClippingRect));
 1748
17281749 m_graphicsLayer->setContentsToImage(image);
17291750 bool isSimpleContainer = false;
17301751 updateDrawsContent(isSimpleContainer);

@@LayoutRect RenderLayerBacking::contentsBox() const
17721793 if (!renderer().isBox())
17731794 return LayoutRect();
17741795
 1796 RenderBox& renderBox = *toRenderBox(&renderer());
17751797 LayoutRect contentsRect;
17761798#if ENABLE(VIDEO)
1777  if (renderer().isVideo()) {
1778  RenderVideo* videoRenderer = toRenderVideo(&renderer());
 1799 if (renderBox.isVideo()) {
 1800 RenderVideo* videoRenderer = toRenderVideo(&renderBox);
17791801 contentsRect = videoRenderer->videoBox();
17801802 } else
17811803#endif
1782  contentsRect = toRenderBox(&renderer())->contentBoxRect();
 1804 if (renderBox.isRenderReplaced()) {
 1805 RenderReplaced& renderReplaced = *toRenderReplaced(&renderBox);
 1806 contentsRect = renderReplaced.replacedContentRect(renderBox.intrinsicSize());
 1807 } else
 1808 contentsRect = renderBox.contentBoxRect();
17831809
17841810 contentsRect.move(contentOffsetInCompostingLayer());
17851811 return contentsRect;

Source/WebCore/rendering/RenderLayerCompositor.cpp

@@String RenderLayerCompositor::layerTreeAsText(LayerTreeFlags flags)
13901390 layerTreeBehavior |= LayerTreeAsTextIncludeRepaintRects;
13911391 if (flags & LayerTreeFlagsIncludePaintingPhases)
13921392 layerTreeBehavior |= LayerTreeAsTextIncludePaintingPhases;
 1393 if (flags & LayerTreeFlagsIncludeContentLayers)
 1394 layerTreeBehavior |= LayerTreeAsTextIncludeContentLayers;
13931395
13941396 // We skip dumping the scroll and clip layers to keep layerTreeAsText output
13951397 // similar between platforms.

Source/WebCore/rendering/RenderVideo.cpp

@@void RenderVideo::updatePlayer()
246246 mediaPlayer->setFrameView(&view().frameView());
247247 mediaPlayer->setSize(IntSize(videoBounds.width(), videoBounds.height()));
248248 mediaPlayer->setVisible(true);
 249 mediaPlayer->setShouldMaintainAspectRatio(style()->objectFit() != ObjectFitFill);
249250}
250251
251252LayoutUnit RenderVideo::computeReplacedLogicalWidth(ShouldComputePreferred shouldComputePreferred) const

Source/WebCore/testing/Internals.cpp

@@String Internals::layerTreeAsText(Document* document, unsigned flags, ExceptionC
16051605 layerTreeFlags |= LayerTreeFlagsIncludeRepaintRects;
16061606 if (flags & LAYER_TREE_INCLUDES_PAINTING_PHASES)
16071607 layerTreeFlags |= LayerTreeFlagsIncludePaintingPhases;
 1608 if (flags & LAYER_TREE_INCLUDES_CONTENT_LAYERS)
 1609 layerTreeFlags |= LayerTreeFlagsIncludeContentLayers;
16081610
16091611 return document->frame()->layerTreeAsText(layerTreeFlags);
16101612}

Source/WebCore/testing/Internals.h

@@public:
225225 LAYER_TREE_INCLUDES_VISIBLE_RECTS = 1,
226226 LAYER_TREE_INCLUDES_TILE_CACHES = 2,
227227 LAYER_TREE_INCLUDES_REPAINT_RECTS = 4,
228  LAYER_TREE_INCLUDES_PAINTING_PHASES = 8
 228 LAYER_TREE_INCLUDES_PAINTING_PHASES = 8,
 229 LAYER_TREE_INCLUDES_CONTENT_LAYERS = 16
229230 };
230231 String layerTreeAsText(Document*, unsigned flags, ExceptionCode&) const;
231232 String layerTreeAsText(Document*, ExceptionCode&) const;

Source/WebCore/testing/Internals.idl

175175 const unsigned short LAYER_TREE_INCLUDES_TILE_CACHES = 2;
176176 const unsigned short LAYER_TREE_INCLUDES_REPAINT_RECTS = 4;
177177 const unsigned short LAYER_TREE_INCLUDES_PAINTING_PHASES = 8;
 178 const unsigned short LAYER_TREE_INCLUDES_CONTENT_LAYERS = 16;
178179 [RaisesException] DOMString layerTreeAsText(Document document, optional unsigned short flags);
179180
180181 [RaisesException] DOMString scrollingStateTreeAsText(Document document);

LayoutTests/ChangeLog

 12013-08-30 Simon Fraser <simon.fraser@apple.com>
 2
 3 Video with object-fit: cover can spill outside the box
 4 https://bugs.webkit.org/show_bug.cgi?id=52103
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Test cases for directly composited image with object-fit, the same with
 9 reflections, and one with video.
 10
 11 Tests dump content GraphicsLayers, so have platform-specific results.
 12
 13 * compositing/images/direct-image-object-fit-expected.txt: Added.
 14 * compositing/images/direct-image-object-fit.html: Added.
 15 * compositing/reflections/direct-image-object-fit-reflected-expected.txt: Added.
 16 * compositing/reflections/direct-image-object-fit-reflected.html: Added.
 17 * compositing/video/video-object-fit-expected.txt: Added.
 18 * compositing/video/video-object-fit.html: Added.
 19 * media/video-object-fit-change.html: Fixed
 20 * platform/mac/TestExpectations: Unskip two tests.
 21 * platform/mac/compositing/images/direct-image-object-fit-expected.txt: Added.
 22 * platform/mac/compositing/reflections/direct-image-object-fit-reflected-expected.txt: Added.
 23 * platform/mac/compositing/video/video-object-fit-expected.txt: Added.
 24
1252013-08-30 Ádám Kallai <kadam@inf.u-szeged.hu>
226
327 [Qt] Added platform specific expected files after r15470 and r154780.

LayoutTests/compositing/images/direct-image-object-fit-expected.txt

 1
 2(GraphicsLayer
 3 (bounds 800.00 600.00)
 4 (children 1
 5 (GraphicsLayer
 6 (bounds 800.00 600.00)
 7 (contentsOpaque 1)
 8 (children 3
 9 (GraphicsLayer
 10 (position 58.00 20.00)
 11 (bounds 200.00 120.00)
 12 )
 13 (GraphicsLayer
 14 (position 58.00 160.00)
 15 (bounds 200.00 120.00)
 16 )
 17 (GraphicsLayer
 18 (position 58.00 300.00)
 19 (bounds 200.00 120.00)
 20 )
 21 )
 22 )
 23 )
 24)
 25

LayoutTests/compositing/images/direct-image-object-fit.html

 1<!DOCTYPE html>
 2<html>
 3<head>
 4 <style>
 5 img {
 6 display: block;
 7 height: 120px;
 8 width: 200px;
 9 margin: 20px 50px;
 10 }
 11 .composited {
 12 -webkit-transform: translateZ(0);
 13 }
 14 </style>
 15 <script>
 16 if (window.testRunner)
 17 testRunner.dumpAsText();
 18
 19 function doTest()
 20 {
 21 if (window.internals)
 22 document.getElementById('results').innerText = window.internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_CONTENT_LAYERS);
 23 }
 24 window.addEventListener('load', doTest, false);
 25 </script>
 26</head>
 27<body>
 28 <img class="composited" src="../../fast/css/resources/circles-landscape.png" style="object-fit: cover"></div>
 29 <img class="composited" src="../../fast/css/resources/circles-landscape.png" style="object-fit: contain"></div>
 30 <img class="composited" src="../../fast/css/resources/circles-landscape.png" style="object-fit: none"></div>
 31<pre id="results"></pre>
 32</body>
 33</html>

LayoutTests/compositing/reflections/direct-image-object-fit-reflected-expected.txt

 1
 2(GraphicsLayer
 3 (bounds 800.00 600.00)
 4 (children 1
 5 (GraphicsLayer
 6 (bounds 800.00 600.00)
 7 (contentsOpaque 1)
 8 (children 3
 9 (GraphicsLayer
 10 (position 28.00 28.00)
 11 (bounds 200.00 120.00)
 12 (replica layer)
 13 (GraphicsLayer
 14 (bounds 200.00 120.00)
 15 (transform [1.00 0.00 0.00 0.00] [0.00 -1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 140.00 0.00 1.00])
 16 (replicated layer)
 17 )
 18 )
 19 (GraphicsLayer
 20 (position 272.00 28.00)
 21 (bounds 200.00 120.00)
 22 (replica layer)
 23 (GraphicsLayer
 24 (bounds 200.00 120.00)
 25 (transform [1.00 0.00 0.00 0.00] [0.00 -1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 140.00 0.00 1.00])
 26 (replicated layer)
 27 )
 28 )
 29 (GraphicsLayer
 30 (position 516.00 28.00)
 31 (bounds 200.00 120.00)
 32 (replica layer)
 33 (GraphicsLayer
 34 (bounds 200.00 120.00)
 35 (transform [1.00 0.00 0.00 0.00] [0.00 -1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 140.00 0.00 1.00])
 36 (replicated layer)
 37 )
 38 )
 39 )
 40 )
 41 )
 42)
 43

LayoutTests/compositing/reflections/direct-image-object-fit-reflected.html

 1<!DOCTYPE html>
 2<html>
 3<head>
 4 <style>
 5 img {
 6 height: 120px;
 7 width: 200px;
 8 margin: 20px;
 9 -webkit-box-reflect: below 20px;
 10 }
 11
 12 img:hover {
 13 height: 160px;
 14 }
 15
 16 .composited {
 17 -webkit-transform: translateZ(0);
 18 }
 19 </style>
 20 <script>
 21 if (window.testRunner)
 22 testRunner.dumpAsText();
 23
 24 function doTest()
 25 {
 26 if (window.internals)
 27 document.getElementById('results').innerText = window.internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_CONTENT_LAYERS);
 28 }
 29 window.addEventListener('load', doTest, false);
 30 </script>
 31</head>
 32<body>
 33 <img class="composited" src="../../fast/css/resources/circles-landscape.png" style="object-fit: cover"></div>
 34 <img class="composited" src="../../fast/css/resources/circles-landscape.png" style="object-fit: contain"></div>
 35 <img class="composited" src="../../fast/css/resources/circles-landscape.png" style="object-fit: none"></div>
 36<pre id="results"></pre>
 37</body>
 38</html>

LayoutTests/compositing/video/video-object-fit-expected.txt

 1
 2(GraphicsLayer
 3 (bounds 785.00 775.00)
 4 (children 1
 5 (GraphicsLayer
 6 (bounds 785.00 775.00)
 7 (contentsOpaque 1)
 8 (children 6
 9 (GraphicsLayer
 10 (position 13.00 13.00)
 11 (bounds 124.00 204.00)
 12 (contentsOpaque 1)
 13 (drawsContent 1)
 14 )
 15 (GraphicsLayer
 16 (position 151.00 13.00)
 17 (bounds 124.00 204.00)
 18 (contentsOpaque 1)
 19 (drawsContent 1)
 20 )
 21 (GraphicsLayer
 22 (position 289.00 13.00)
 23 (bounds 124.00 204.00)
 24 (contentsOpaque 1)
 25 (drawsContent 1)
 26 )
 27 (GraphicsLayer
 28 (position 13.00 231.00)
 29 (bounds 354.00 304.00)
 30 (contentsOpaque 1)
 31 (drawsContent 1)
 32 )
 33 (GraphicsLayer
 34 (position 13.00 569.00)
 35 (bounds 404.00 184.00)
 36 (contentsOpaque 1)
 37 (drawsContent 1)
 38 )
 39 (GraphicsLayer
 40 (position 431.00 549.00)
 41 (bounds 124.00 204.00)
 42 (contentsOpaque 1)
 43 (drawsContent 1)
 44 )
 45 )
 46 )
 47 )
 48)
 49

LayoutTests/compositing/video/video-object-fit.html

 1<!DOCTYPE html>
 2<html>
 3<head>
 4<style>
 5 video {
 6/* display: block;*/
 7 width: 120px;
 8 height: 200px;
 9 margin: 5px;
 10 border: 2px solid blue;
 11 background-color: gray;
 12 }
 13
 14 .big {
 15 height: 300px;
 16 width: 350px;
 17 }
 18 .smaller {
 19 height: 180px;
 20 width: 400px;
 21 }
 22</style>
 23<script src="../../media/media-file.js"></script>
 24<script>
 25 if (window.testRunner) {
 26 testRunner.waitUntilDone();
 27 testRunner.dumpAsText();
 28 }
 29
 30 function init()
 31 {
 32 setSrcByTagName("video", findMediaFile("video", "../../media/content/test"));
 33
 34 var totalCount = document.getElementsByTagName('video').length;
 35 var count = totalCount;
 36 document.addEventListener("canplaythrough", function () {
 37 if (!--count) {
 38 if (window.testRunner)
 39 setTimeout(function() {
 40 if (window.internals)
 41 document.getElementById('results').innerText = window.internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_CONTENT_LAYERS);
 42 testRunner.notifyDone();
 43 }, totalCount * 150);
 44 }
 45 }, true);
 46
 47 if (window.testRunner) {
 48 setTimeout(function() {
 49 document.body.appendChild(document.createTextNode('FAIL'));
 50 if (window.testRunner)
 51 testRunner.notifyDone();
 52 }, 1500);
 53 }
 54 }
 55</script>
 56
 57</head>
 58<body onload="init();">
 59 <video style="object-fit: fill"></video>
 60 <video style="object-fit: cover"></video>
 61 <video style="object-fit: contain"></video>
 62 <video class="big" style="object-fit: scale-down"></video>
 63 <video class="smaller" style="object-fit: scale-down"></video>
 64 <video style="object-fit: none"></video>
 65<pre id="results"></pre>
 66</body>
 67</html>

LayoutTests/media/video-object-fit-change.html

1818
1919 function init()
2020 {
21  setSrcByTagName("video", findMediaFile("video", "../../media/content/test"));
 21 setSrcByTagName("video", findMediaFile("video", "content/test"));
2222
2323 var totalCount = document.getElementsByTagName('video').length;
2424 var count = totalCount;
2525 document.addEventListener("canplaythrough", function () {
2626 if (!--count)
27  setTimeout(function() { changeStyle(); }, 500);
 27 setTimeout(function() { changeStyle(); }, 250);
2828 }, true);
2929
3030 if (window.testRunner) {

4343 video3.style.objectFit = 'fill';
4444 video4.style.objectFit = 'scale-down';
4545
46  if (window.testRunner) {
47  setTimeout(function() { testRunner.notifyDone(); }, 500);
48  }
 46 if (window.testRunner)
 47 setTimeout(function() { testRunner.notifyDone(); }, 250);
4948 }
5049 </script>
5150

LayoutTests/platform/mac/TestExpectations

@@plugins/reloadplugins-and-pages.html
5252# This test requires ogg codecs
5353media/media-can-play-ogg.html
5454
55 webkit.org/b/52103 media/video-object-fit-change.html
56 webkit.org/b/52103 media/video-object-fit.html
57 
5855# This test requires flac codec
5956media/media-can-play-flac-audio.html
6057

LayoutTests/platform/mac/compositing/images/direct-image-object-fit-expected.txt

 1
 2(GraphicsLayer
 3 (bounds 800.00 600.00)
 4 (children 1
 5 (GraphicsLayer
 6 (bounds 800.00 600.00)
 7 (contentsOpaque 1)
 8 (children 3
 9 (GraphicsLayer
 10 (position 58.00 20.00)
 11 (bounds 200.00 120.00)
 12 (contents clipping layer 0.00, 0.00 200.00 x 120.00)
 13 (contents layer -20.00, 0.00 240.00 x 120.00)
 14 )
 15 (GraphicsLayer
 16 (position 58.00 160.00)
 17 (bounds 200.00 120.00)
 18 (contents layer 0.00, 10.00 200.00 x 100.00)
 19 )
 20 (GraphicsLayer
 21 (position 58.00 300.00)
 22 (bounds 200.00 120.00)
 23 (contents clipping layer 0.00, 0.00 200.00 x 120.00)
 24 (contents layer -44.00, -12.00 288.00 x 144.00)
 25 )
 26 )
 27 )
 28 )
 29)
 30

LayoutTests/platform/mac/compositing/reflections/direct-image-object-fit-reflected-expected.txt

 1
 2(GraphicsLayer
 3 (bounds 800.00 600.00)
 4 (children 1
 5 (GraphicsLayer
 6 (bounds 800.00 600.00)
 7 (contentsOpaque 1)
 8 (children 3
 9 (GraphicsLayer
 10 (position 28.00 28.00)
 11 (bounds 200.00 120.00)
 12 (replica layer)
 13 (GraphicsLayer
 14 (bounds 200.00 120.00)
 15 (transform [1.00 0.00 0.00 0.00] [0.00 -1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 140.00 0.00 1.00])
 16 (replicated layer)
 17 )
 18 (contents clipping layer 0.00, 0.00 200.00 x 120.00)
 19 (contents layer -20.00, 0.00 240.00 x 120.00)
 20 )
 21 (GraphicsLayer
 22 (position 272.00 28.00)
 23 (bounds 200.00 120.00)
 24 (replica layer)
 25 (GraphicsLayer
 26 (bounds 200.00 120.00)
 27 (transform [1.00 0.00 0.00 0.00] [0.00 -1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 140.00 0.00 1.00])
 28 (replicated layer)
 29 )
 30 (contents layer 0.00, 10.00 200.00 x 100.00)
 31 )
 32 (GraphicsLayer
 33 (position 516.00 28.00)
 34 (bounds 200.00 120.00)
 35 (replica layer)
 36 (GraphicsLayer
 37 (bounds 200.00 120.00)
 38 (transform [1.00 0.00 0.00 0.00] [0.00 -1.00 0.00 0.00] [0.00 0.00 1.00 0.00] [0.00 140.00 0.00 1.00])
 39 (replicated layer)
 40 )
 41 (contents clipping layer 0.00, 0.00 200.00 x 120.00)
 42 (contents layer -44.00, -12.00 288.00 x 144.00)
 43 )
 44 )
 45 )
 46 )
 47)
 48

LayoutTests/platform/mac/compositing/video/video-object-fit-expected.txt

 1
 2(GraphicsLayer
 3 (bounds 785.00 775.00)
 4 (children 1
 5 (GraphicsLayer
 6 (bounds 785.00 775.00)
 7 (contentsOpaque 1)
 8 (children 6
 9 (GraphicsLayer
 10 (position 13.00 13.00)
 11 (bounds 124.00 204.00)
 12 (contentsOpaque 1)
 13 (drawsContent 1)
 14 )
 15 (GraphicsLayer
 16 (position 151.00 13.00)
 17 (bounds 124.00 204.00)
 18 (contentsOpaque 1)
 19 (drawsContent 1)
 20 )
 21 (GraphicsLayer
 22 (position 289.00 13.00)
 23 (bounds 124.00 204.00)
 24 (contentsOpaque 1)
 25 (drawsContent 1)
 26 )
 27 (GraphicsLayer
 28 (position 13.00 231.00)
 29 (bounds 354.00 304.00)
 30 (contentsOpaque 1)
 31 (drawsContent 1)
 32 )
 33 (GraphicsLayer
 34 (position 13.00 569.00)
 35 (bounds 404.00 184.00)
 36 (contentsOpaque 1)
 37 (drawsContent 1)
 38 )
 39 (GraphicsLayer
 40 (position 431.00 549.00)
 41 (bounds 124.00 204.00)
 42 (contentsOpaque 1)
 43 (drawsContent 1)
 44 )
 45 )
 46 )
 47 )
 48)
 49