Commit b70c3c7b authored by akling@apple.com's avatar akling@apple.com
Browse files

RenderView::compositor() should return a reference.

<https://webkit.org/b/120217>

Reviewed by Beth Dakin.

The RenderLayerCompositor is lazily constructed by compositor() and never returns null.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154504 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 299b583a
2013-08-23 Andreas Kling <akling@apple.com>
RenderView::compositor() should return a reference.
<https://webkit.org/b/120217>
Reviewed by Beth Dakin.
The RenderLayerCompositor is lazily constructed by compositor() and never returns null.
2013-08-23 Yoav Weiss <yoav@yoav.ws>
 
Fix srcset's image candidate algorithm when DPR exceeds all candidates
......@@ -570,7 +570,7 @@ static bool transform_3dMediaFeatureEval(CSSValue* value, RenderStyle*, Frame* f
bool threeDEnabled = false;
#if USE(ACCELERATED_COMPOSITING)
if (RenderView* view = frame->contentRenderer())
threeDEnabled = view->compositor()->canRender3DTransforms();
threeDEnabled = view->compositor().canRender3DTransforms();
#endif
returnValueIfNoParameter = threeDEnabled;
......
......@@ -4842,7 +4842,7 @@ void Document::windowScreenDidChange(PlatformDisplayID displayID)
#if USE(ACCELERATED_COMPOSITING)
if (RenderView* view = renderView()) {
if (view->usesCompositing())
view->compositor()->windowScreenDidChange(displayID);
view->compositor().windowScreenDidChange(displayID);
}
#endif
}
......
......@@ -3799,7 +3799,7 @@ bool HTMLMediaElement::mediaPlayerRenderingCanBeAccelerated(MediaPlayer*)
{
if (renderer() && renderer()->isVideo()) {
ASSERT(renderer()->view());
return renderer()->view()->compositor()->canAccelerateVideoRendering(toRenderVideo(renderer()));
return renderer()->view()->compositor().canAccelerateVideoRendering(toRenderVideo(renderer()));
}
return false;
}
......
......@@ -864,7 +864,7 @@ String Frame::layerTreeAsText(LayerTreeFlags flags) const
if (!contentRenderer())
return String();
return contentRenderer()->compositor()->layerTreeAsText(flags);
return contentRenderer()->compositor().layerTreeAsText(flags);
#else
UNUSED_PARAM(flags);
return String();
......@@ -991,9 +991,8 @@ void Frame::deviceOrPageScaleFactorChanged()
for (RefPtr<Frame> child = tree()->firstChild(); child; child = child->tree()->nextSibling())
child->deviceOrPageScaleFactorChanged();
RenderView* root = contentRenderer();
if (root && root->compositor())
root->compositor()->deviceOrPageScaleFactorChanged();
if (RenderView* root = contentRenderer())
root->compositor().deviceOrPageScaleFactorChanged();
}
#endif
void Frame::notifyChromeClientWheelEventHandlerCountChanged() const
......
......@@ -462,7 +462,7 @@ void FrameView::setFrameRect(const IntRect& newRect)
#if USE(ACCELERATED_COMPOSITING)
if (RenderView* renderView = this->renderView()) {
if (renderView->usesCompositing())
renderView->compositor()->frameViewDidChangeSize();
renderView->compositor().frameViewDidChangeSize();
}
#endif
......@@ -749,9 +749,10 @@ void FrameView::updateCompositingLayersAfterStyleChange()
if (m_doingPreLayoutStyleUpdate || layoutPending() || renderView->needsLayout())
return;
RenderLayerCompositor& compositor = renderView->compositor();
// This call will make sure the cached hasAcceleratedCompositing is updated from the pref
renderView->compositor()->cacheAcceleratedCompositingFlags();
renderView->compositor()->updateCompositingLayers(CompositingUpdateAfterStyleChange);
compositor.cacheAcceleratedCompositingFlags();
compositor.updateCompositingLayers(CompositingUpdateAfterStyleChange);
}
void FrameView::updateCompositingLayersAfterLayout()
......@@ -761,8 +762,8 @@ void FrameView::updateCompositingLayersAfterLayout()
return;
// This call will make sure the cached hasAcceleratedCompositing is updated from the pref
renderView->compositor()->cacheAcceleratedCompositingFlags();
renderView->compositor()->updateCompositingLayers(CompositingUpdateAfterLayout);
renderView->compositor().cacheAcceleratedCompositingFlags();
renderView->compositor().updateCompositingLayers(CompositingUpdateAfterLayout);
}
void FrameView::clearBackingStores()
......@@ -771,10 +772,10 @@ void FrameView::clearBackingStores()
if (!renderView)
return;
RenderLayerCompositor* compositor = renderView->compositor();
ASSERT(compositor->inCompositingMode());
compositor->enableCompositingMode(false);
compositor->clearBackingForAllLayers();
RenderLayerCompositor& compositor = renderView->compositor();
ASSERT(compositor.inCompositingMode());
compositor.enableCompositingMode(false);
compositor.clearBackingForAllLayers();
}
void FrameView::restoreBackingStores()
......@@ -783,9 +784,9 @@ void FrameView::restoreBackingStores()
if (!renderView)
return;
RenderLayerCompositor* compositor = renderView->compositor();
compositor->enableCompositingMode(true);
compositor->updateCompositingLayers(CompositingUpdateAfterLayout);
RenderLayerCompositor& compositor = renderView->compositor();
compositor.enableCompositingMode(true);
compositor.updateCompositingLayers(CompositingUpdateAfterLayout);
}
bool FrameView::usesCompositedScrolling() const
......@@ -794,7 +795,7 @@ bool FrameView::usesCompositedScrolling() const
if (!renderView)
return false;
if (frame().settings().compositedScrollingForFramesEnabled())
return renderView->compositor()->inForcedCompositingMode();
return renderView->compositor().inForcedCompositingMode();
return false;
}
......@@ -803,7 +804,7 @@ GraphicsLayer* FrameView::layerForScrolling() const
RenderView* renderView = this->renderView();
if (!renderView)
return 0;
return renderView->compositor()->scrollLayer();
return renderView->compositor().scrollLayer();
}
GraphicsLayer* FrameView::layerForHorizontalScrollbar() const
......@@ -811,7 +812,7 @@ GraphicsLayer* FrameView::layerForHorizontalScrollbar() const
RenderView* renderView = this->renderView();
if (!renderView)
return 0;
return renderView->compositor()->layerForHorizontalScrollbar();
return renderView->compositor().layerForHorizontalScrollbar();
}
GraphicsLayer* FrameView::layerForVerticalScrollbar() const
......@@ -819,7 +820,7 @@ GraphicsLayer* FrameView::layerForVerticalScrollbar() const
RenderView* renderView = this->renderView();
if (!renderView)
return 0;
return renderView->compositor()->layerForVerticalScrollbar();
return renderView->compositor().layerForVerticalScrollbar();
}
GraphicsLayer* FrameView::layerForScrollCorner() const
......@@ -827,7 +828,7 @@ GraphicsLayer* FrameView::layerForScrollCorner() const
RenderView* renderView = this->renderView();
if (!renderView)
return 0;
return renderView->compositor()->layerForScrollCorner();
return renderView->compositor().layerForScrollCorner();
}
TiledBacking* FrameView::tiledBacking()
......@@ -862,7 +863,7 @@ GraphicsLayer* FrameView::layerForOverhangAreas() const
RenderView* renderView = this->renderView();
if (!renderView)
return 0;
return renderView->compositor()->layerForOverhangAreas();
return renderView->compositor().layerForOverhangAreas();
}
GraphicsLayer* FrameView::setWantsLayerForTopOverHangArea(bool wantsLayer) const
......@@ -871,7 +872,7 @@ GraphicsLayer* FrameView::setWantsLayerForTopOverHangArea(bool wantsLayer) const
if (!renderView)
return 0;
return renderView->compositor()->updateLayerForTopOverhangArea(wantsLayer);
return renderView->compositor().updateLayerForTopOverhangArea(wantsLayer);
}
GraphicsLayer* FrameView::setWantsLayerForBottomOverHangArea(bool wantsLayer) const
......@@ -880,7 +881,7 @@ GraphicsLayer* FrameView::setWantsLayerForBottomOverHangArea(bool wantsLayer) co
if (!renderView)
return 0;
return renderView->compositor()->updateLayerForBottomOverhangArea(wantsLayer);
return renderView->compositor().updateLayerForBottomOverhangArea(wantsLayer);
}
#endif // ENABLE(RUBBER_BANDING)
......@@ -909,7 +910,7 @@ bool FrameView::flushCompositingStateForThisFrame(Frame* rootFrameForFlush)
// visible flash to occur. Instead, stop the deferred repaint timer and repaint immediately.
flushDeferredRepaints();
renderView->compositor()->flushPendingLayerChanges(rootFrameForFlush == &frame());
renderView->compositor().flushPendingLayerChanges(rootFrameForFlush == &frame());
return true;
}
......@@ -946,7 +947,7 @@ bool FrameView::hasCompositedContent() const
{
#if USE(ACCELERATED_COMPOSITING)
if (RenderView* renderView = this->renderView())
return renderView->compositor()->inCompositingMode();
return renderView->compositor().inCompositingMode();
#endif
return false;
}
......@@ -956,8 +957,7 @@ bool FrameView::hasCompositedContentIncludingDescendants() const
#if USE(ACCELERATED_COMPOSITING)
for (Frame* frame = m_frame.get(); frame; frame = frame->tree()->traverseNext(m_frame.get())) {
RenderView* renderView = frame->contentRenderer();
RenderLayerCompositor* compositor = renderView ? renderView->compositor() : 0;
if (compositor) {
if (RenderLayerCompositor* compositor = renderView ? &renderView->compositor() : 0) {
if (compositor->inCompositingMode())
return true;
......@@ -987,9 +987,9 @@ void FrameView::enterCompositingMode()
{
#if USE(ACCELERATED_COMPOSITING)
if (RenderView* renderView = this->renderView()) {
renderView->compositor()->enableCompositingMode();
renderView->compositor().enableCompositingMode();
if (!needsLayout())
renderView->compositor()->scheduleCompositingLayerUpdate();
renderView->compositor().scheduleCompositingLayerUpdate();
}
#endif
}
......@@ -1026,7 +1026,7 @@ bool FrameView::isSoftwareRenderable() const
{
#if USE(ACCELERATED_COMPOSITING)
RenderView* renderView = this->renderView();
return !renderView || !renderView->compositor()->has3DContent();
return !renderView || !renderView->compositor().has3DContent();
#else
return true;
#endif
......@@ -1782,9 +1782,9 @@ void FrameView::setIsOverlapped(bool isOverlapped)
// a layer update in the parent document.
if (Frame* parentFrame = frame().tree()->parent()) {
if (RenderView* parentView = parentFrame->contentRenderer()) {
RenderLayerCompositor* compositor = parentView->compositor();
compositor->setCompositingLayersNeedRebuild();
compositor->scheduleCompositingLayerUpdate();
RenderLayerCompositor& compositor = parentView->compositor();
compositor.setCompositingLayersNeedRebuild();
compositor.scheduleCompositingLayerUpdate();
}
}
......@@ -1793,9 +1793,9 @@ void FrameView::setIsOverlapped(bool isOverlapped)
// since a frame uses compositing if any ancestor is compositing.
for (Frame* frame = m_frame.get(); frame; frame = frame->tree()->traverseNext(m_frame.get())) {
if (RenderView* view = frame->contentRenderer()) {
RenderLayerCompositor* compositor = view->compositor();
compositor->setCompositingLayersNeedRebuild();
compositor->scheduleCompositingLayerUpdate();
RenderLayerCompositor& compositor = view->compositor();
compositor.setCompositingLayersNeedRebuild();
compositor.scheduleCompositingLayerUpdate();
}
}
}
......@@ -1986,7 +1986,7 @@ void FrameView::scrollPositionChanged()
#if USE(ACCELERATED_COMPOSITING)
if (RenderView* renderView = this->renderView()) {
if (renderView->usesCompositing())
renderView->compositor()->frameViewDidScroll();
renderView->compositor().frameViewDidScroll();
}
#endif
}
......@@ -2041,7 +2041,7 @@ void FrameView::updateFixedElementsAfterScrolling()
if (m_nestedLayoutCount <= 1 && hasViewportConstrainedObjects()) {
if (RenderView* renderView = this->renderView())
renderView->compositor()->updateCompositingLayers(CompositingUpdateOnScroll);
renderView->compositor().updateCompositingLayers(CompositingUpdateOnScroll);
}
#endif
}
......@@ -2182,7 +2182,7 @@ void FrameView::visibleContentsResized()
#if USE(ACCELERATED_COMPOSITING)
if (RenderView* renderView = this->renderView()) {
if (renderView->usesCompositing())
renderView->compositor()->frameViewDidChangeSize();
renderView->compositor().frameViewDidChangeSize();
}
#endif
}
......@@ -2314,7 +2314,7 @@ void FrameView::resetDeferredRepaintDelay()
}
#if USE(ACCELERATED_COMPOSITING)
if (RenderView* view = renderView())
view->compositor()->disableLayerFlushThrottlingTemporarilyForInteraction();
view->compositor().disableLayerFlushThrottlingTemporarilyForInteraction();
#endif
}
......@@ -2349,7 +2349,7 @@ void FrameView::updateLayerFlushThrottlingInAllFrames()
bool isMainLoadProgressing = frame().page()->progress().isMainLoadProgressing();
for (Frame* frame = m_frame.get(); frame; frame = frame->tree()->traverseNext(m_frame.get())) {
if (RenderView* renderView = frame->contentRenderer())
renderView->compositor()->setLayerFlushThrottlingEnabled(isMainLoadProgressing);
renderView->compositor().setLayerFlushThrottlingEnabled(isMainLoadProgressing);
}
#endif
}
......@@ -2774,7 +2774,7 @@ void FrameView::performPostLayoutTasks()
#if USE(ACCELERATED_COMPOSITING)
if (RenderView* renderView = this->renderView()) {
if (renderView->usesCompositing())
renderView->compositor()->frameViewDidLayout();
renderView->compositor().frameViewDidLayout();
}
#endif
......@@ -4020,7 +4020,7 @@ void FrameView::setTracksRepaints(bool trackRepaints)
#if USE(ACCELERATED_COMPOSITING)
for (Frame* frame = m_frame->tree()->top(); frame; frame = frame->tree()->traverseNext()) {
if (RenderView* renderView = frame->contentRenderer())
renderView->compositor()->setTracksRepaints(trackRepaints);
renderView->compositor().setTracksRepaints(trackRepaints);
}
#endif
......@@ -4033,7 +4033,7 @@ void FrameView::resetTrackedRepaints()
m_trackedRepaintRects.clear();
#if USE(ACCELERATED_COMPOSITING)
if (RenderView* renderView = this->renderView())
renderView->compositor()->resetTrackedRepaintRects();
renderView->compositor().resetTrackedRepaintRects();
#endif
}
......
......@@ -1323,7 +1323,7 @@ void Page::addHeaderWithHeight(int headerHeight)
return;
frameView->setHeaderHeight(m_headerHeight);
renderView->compositor()->updateLayerForHeader(m_headerHeight);
renderView->compositor().updateLayerForHeader(m_headerHeight);
}
void Page::addFooterWithHeight(int footerHeight)
......@@ -1339,7 +1339,7 @@ void Page::addFooterWithHeight(int footerHeight)
return;
frameView->setFooterHeight(m_footerHeight);
renderView->compositor()->updateLayerForFooter(m_footerHeight);
renderView->compositor().updateLayerForFooter(m_footerHeight);
}
#endif
......
......@@ -294,7 +294,7 @@ GraphicsLayer* ScrollingCoordinator::scrollLayerForFrameView(FrameView* frameVie
{
#if USE(ACCELERATED_COMPOSITING)
if (RenderView* renderView = frameView->frame().contentRenderer())
return renderView->compositor()->scrollLayer();
return renderView->compositor().scrollLayer();
return 0;
#else
UNUSED_PARAM(frameView);
......@@ -306,7 +306,7 @@ GraphicsLayer* ScrollingCoordinator::headerLayerForFrameView(FrameView* frameVie
{
#if USE(ACCELERATED_COMPOSITING) && ENABLE(RUBBER_BANDING)
if (RenderView* renderView = frameView->frame().contentRenderer())
renderView->compositor()->headerLayer();
renderView->compositor().headerLayer();
return 0;
#else
UNUSED_PARAM(frameView);
......@@ -318,7 +318,7 @@ GraphicsLayer* ScrollingCoordinator::footerLayerForFrameView(FrameView* frameVie
{
#if USE(ACCELERATED_COMPOSITING) && ENABLE(RUBBER_BANDING)
if (RenderView* renderView = frameView->frame().contentRenderer())
return renderView->compositor()->footerLayer();
return renderView->compositor().footerLayer();
return 0;
#else
UNUSED_PARAM(frameView);
......@@ -330,7 +330,7 @@ GraphicsLayer* ScrollingCoordinator::counterScrollingLayerForFrameView(FrameView
{
#if USE(ACCELERATED_COMPOSITING)
if (RenderView* renderView = frameView->frame().contentRenderer())
return renderView->compositor()->fixedRootBackgroundLayer();
return renderView->compositor().fixedRootBackgroundLayer();
return 0;
#else
UNUSED_PARAM(frameView);
......
......@@ -275,7 +275,7 @@ void RenderBox::styleWillChange(StyleDifference diff, const RenderStyle* newStyl
view()->repaintRootContents();
#if USE(ACCELERATED_COMPOSITING)
if (oldStyle->hasEntirelyFixedBackground() != newStyle->hasEntirelyFixedBackground())
view()->compositor()->rootFixedBackgroundsChanged();
view()->compositor().rootFixedBackgroundsChanged();
#endif
}
......
......@@ -289,7 +289,7 @@ void RenderBoxModelObject::contentChanged(ContentChangeType changeType)
bool RenderBoxModelObject::hasAcceleratedCompositing() const
{
return view()->compositor()->hasAcceleratedCompositing();
return view()->compositor().hasAcceleratedCompositing();
}
bool RenderBoxModelObject::startTransition(double timeOffset, CSSPropertyID propertyId, const RenderStyle* fromStyle, const RenderStyle* toStyle)
......
......@@ -312,7 +312,7 @@ RenderLayerCompositor* RenderLayer::compositor() const
{
if (!renderer()->view())
return 0;
return renderer()->view()->compositor();
return &renderer()->view()->compositor();
}
void RenderLayer::contentChanged(ContentChangeType changeType)
......
......@@ -464,7 +464,7 @@ void RenderLayerCompositor::layerTiledBackingUsageChanged(const GraphicsLayer*,
RenderLayerCompositor* RenderLayerCompositor::enclosingCompositorFlushingLayers() const
{
for (Frame* frame = &m_renderView.frameView().frame(); frame; frame = frame->tree()->parent()) {
RenderLayerCompositor* compositor = frame->contentRenderer() ? frame->contentRenderer()->compositor() : 0;
RenderLayerCompositor* compositor = frame->contentRenderer() ? &frame->contentRenderer()->compositor() : 0;
if (compositor->isFlushingLayers())
return compositor;
}
......@@ -1414,7 +1414,7 @@ RenderLayerCompositor* RenderLayerCompositor::frameContentsCompositor(RenderPart
HTMLFrameOwnerElement* element = toFrameOwnerElement(renderer->node());
if (Document* contentDocument = element->contentDocument()) {
if (RenderView* view = contentDocument->renderView())
return view->compositor();
return &view->compositor();
}
return 0;
}
......
......@@ -1972,7 +1972,7 @@ void RenderObject::styleWillChange(StyleDifference diff, const RenderStyle* newS
#if USE(ACCELERATED_COMPOSITING)
bool drawsRootBackground = isRoot() || (isBody() && !rendererHasBackground(document()->documentElement()->renderer()));
if (drawsRootBackground && repaintFixedBackgroundsOnScroll) {
if (view()->compositor()->supportsFixedRootBackgroundCompositing()) {
if (view()->compositor().supportsFixedRootBackgroundCompositing()) {
if (newStyleSlowScroll && newStyle->hasEntirelyFixedBackground())
newStyleSlowScroll = false;
......
......@@ -584,9 +584,10 @@ void RenderView::repaintRectangleInViewAndCompositedLayers(const LayoutRect& ur,
repaintViewRectangle(ur, immediate);
#if USE(ACCELERATED_COMPOSITING)
if (compositor()->inCompositingMode()) {
RenderLayerCompositor& compositor = this->compositor();
if (compositor.inCompositingMode()) {
IntRect repaintRect = pixelSnappedIntRect(ur);
compositor()->repaintCompositedLayers(&repaintRect);
compositor.repaintCompositedLayers(&repaintRect);
}
#endif
}
......@@ -595,8 +596,9 @@ void RenderView::repaintViewAndCompositedLayers()
{
repaintRootContents();
#if USE(ACCELERATED_COMPOSITING)
if (compositor()->inCompositingMode())
compositor()->repaintCompositedLayers();
RenderLayerCompositor& compositor = this->compositor();
if (compositor.inCompositingMode())
compositor.repaintCompositedLayers();
#endif
}
......@@ -731,7 +733,7 @@ void RenderView::setMaximalOutlineSize(int o)
m_maximalOutlineSize = o;
// maximalOutlineSize affects compositing layer dimensions.
compositor()->setCompositingLayersNeedRebuild(); // FIXME: this really just needs to be a geometry update.
compositor().setCompositingLayersNeedRebuild(); // FIXME: this really just needs to be a geometry update.
}
}
#endif
......@@ -1133,12 +1135,12 @@ bool RenderView::usesCompositing() const
return m_compositor && m_compositor->inCompositingMode();
}
RenderLayerCompositor* RenderView::compositor()
RenderLayerCompositor& RenderView::compositor()
{
if (!m_compositor)
m_compositor = adoptPtr(new RenderLayerCompositor(*this));
return m_compositor.get();
return *m_compositor;
}
#endif
......
......@@ -190,7 +190,7 @@ public:
void setIsInWindow(bool);
#if USE(ACCELERATED_COMPOSITING)
RenderLayerCompositor* compositor();
RenderLayerCompositor& compositor();
bool usesCompositing() const;
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment