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

Document's renderer is always a RenderView.

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

Reviewed by Darin Adler.

Let's enforce this better by storing a RenderView* instead of a plain RenderObject*.
We should switch callers that grab at Document::renderer() to calling renderView()
instead, but that's better done separately.

* dom/Document.cpp:
(WebCore::Document::Document):
(WebCore::Document::~Document):
(WebCore::Document::setRenderView):
(WebCore::Document::createRenderTree):
(WebCore::Document::detach):
(WebCore::Document::setInPageCache):
* dom/Document.h:
(WebCore::Document::renderView):
(WebCore::Document::renderer):
* html/parser/HTMLResourcePreloader.cpp:
* rendering/RenderObject.cpp:
(WebCore::RenderObject::setStyle):
* rendering/RenderView.h:
* svg/SVGSVGElement.cpp:
(WebCore::SVGSVGElement::updateCurrentTranslate):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154676 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d2a110f7
2013-08-26 Andreas Kling <akling@apple.com>
Document's renderer is always a RenderView.
<https://webkit.org/b/120304>
Reviewed by Darin Adler.
Let's enforce this better by storing a RenderView* instead of a plain RenderObject*.
We should switch callers that grab at Document::renderer() to calling renderView()
instead, but that's better done separately.
* dom/Document.cpp:
(WebCore::Document::Document):
(WebCore::Document::~Document):
(WebCore::Document::setRenderView):
(WebCore::Document::createRenderTree):
(WebCore::Document::detach):
(WebCore::Document::setInPageCache):
* dom/Document.h:
(WebCore::Document::renderView):
(WebCore::Document::renderer):
* html/parser/HTMLResourcePreloader.cpp:
* rendering/RenderObject.cpp:
(WebCore::RenderObject::setStyle):
* rendering/RenderView.h:
* svg/SVGSVGElement.cpp:
(WebCore::SVGSVGElement::updateCurrentTranslate):
2013-08-27 Allan Sandfeld Jensen <allan.jensen@digia.com>
 
Font's fast code path doesn't handle partial runs correctly when kerning or ligatures are enabled
......@@ -434,7 +434,7 @@ Document::Document(Frame* frame, const KURL& url, unsigned documentClasses)
, m_xmlVersion(ASCIILiteral("1.0"))
, m_xmlStandalone(StandaloneUnspecified)
, m_hasXMLDeclaration(0)
, m_savedRenderer(0)
, m_savedRenderView(0)
, m_designMode(inherit)
#if ENABLE(DASHBOARD_SUPPORT) || ENABLE(DRAGGABLE_REGION)
, m_hasAnnotatedRegions(false)
......@@ -447,7 +447,7 @@ Document::Document(Frame* frame, const KURL& url, unsigned documentClasses)
, m_isViewSource(false)
, m_sawElementsInKnownNamespaces(false)
, m_isSrcdocDocument(false)
, m_renderer(0)
, m_renderView(0)
, m_eventQueue(DocumentEventQueue::create(this))
, m_weakFactory(this)
, m_idAttributeName(idAttr)
......@@ -545,7 +545,7 @@ Document::~Document()
{
ASSERT(!renderer());
ASSERT(!m_inPageCache);
ASSERT(!m_savedRenderer);
ASSERT(!m_savedRenderView);
ASSERT(m_ranges.isEmpty());
ASSERT(!m_styleRecalcTimer.isActive());
ASSERT(!m_parentTreeScope);
......@@ -1963,6 +1963,12 @@ void Document::clearStyleResolver()
m_styleResolver.clear();
}
void Document::setRenderView(RenderView* renderView)
{
m_renderView = renderView;
Node::setRenderer(renderView);
}
void Document::createRenderTree()
{
ASSERT(!attached());
......@@ -1972,7 +1978,7 @@ void Document::createRenderTree()
if (!m_renderArena)
m_renderArena = RenderArena::create();
setRenderer(new (m_renderArena.get()) RenderView(this));
setRenderView(new (m_renderArena.get()) RenderView(this));
#if USE(ACCELERATED_COMPOSITING)
renderView()->setIsInWindow(true);
#endif
......@@ -2087,9 +2093,9 @@ void Document::detach()
unscheduleStyleRecalc();
if (renderer())
renderer()->destroy();
setRenderer(0);
if (renderView())
renderView()->destroy();
setRenderView(0);
#if ENABLE(TOUCH_EVENTS)
if (m_touchEventTargets && m_touchEventTargets->size() && parentDocument())
......@@ -3985,8 +3991,8 @@ void Document::setInPageCache(bool flag)
Page* page = this->page();
if (flag) {
ASSERT(!m_savedRenderer);
m_savedRenderer = renderer();
ASSERT(!m_savedRenderView);
m_savedRenderView = renderView();
if (v) {
// FIXME: There is some scrolling related work that needs to happen whenever a page goes into the
// page cache and similar work that needs to occur when it comes out. This is where we do the work
......@@ -4005,10 +4011,10 @@ void Document::setInPageCache(bool flag)
}
m_styleRecalcTimer.stop();
} else {
ASSERT(!renderer() || renderer() == m_savedRenderer);
ASSERT(!renderView() || renderView() == m_savedRenderView);
ASSERT(m_renderArena);
setRenderer(m_savedRenderer);
m_savedRenderer = 0;
setRenderView(m_savedRenderView);
m_savedRenderView = 0;
if (childNeedsStyleRecalc())
scheduleStyleRecalc();
......
......@@ -3,7 +3,7 @@
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* (C) 2001 Dirk Mueller (mueller@kde.org)
* (C) 2006 Alexey Proskuryakov (ap@webkit.org)
* Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All rights reserved.
* Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
* Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
* Copyright (C) 2011 Google Inc. All rights reserved.
......@@ -537,15 +537,11 @@ public:
// Implemented in RenderView.h to avoid a cyclic header dependency this just
// returns renderer so callers can avoid verbose casts.
RenderView* renderView() const;
RenderView* renderView() const { return m_renderView; }
// FIXME: Remove this, callers that have a Document* should call renderView().
// Shadow the implementations on Node to provide faster access for documents.
RenderObject* renderer() const { return m_renderer; }
void setRenderer(RenderObject* renderer)
{
m_renderer = renderer;
Node::setRenderer(renderer);
}
RenderView* renderer() const { return m_renderView; }
bool renderTreeBeingDestroyed() const { return m_renderTreeBeingDestroyed; }
......@@ -1199,6 +1195,9 @@ private:
friend class Node;
friend class IgnoreDestructiveWriteCountIncrementer;
void setRenderer(RenderObject*) WTF_DELETED_FUNCTION;
void setRenderView(RenderView*);
virtual void createRenderTree();
virtual void dispose() OVERRIDE;
......@@ -1416,7 +1415,7 @@ private:
String m_contentLanguage;
RenderObject* m_savedRenderer;
RenderView* m_savedRenderView;
RefPtr<TextResourceDecoder> m_decoder;
......@@ -1461,7 +1460,7 @@ private:
bool m_sawElementsInKnownNamespaces;
bool m_isSrcdocDocument;
RenderObject* m_renderer;
RenderView* m_renderView;
RefPtr<DocumentEventQueue> m_eventQueue;
WeakPtrFactory<Document> m_weakFactory;
......
......@@ -32,6 +32,7 @@
#include "MediaList.h"
#include "MediaQueryEvaluator.h"
#include "RenderObject.h"
#include "RenderView.h"
namespace WebCore {
......
......@@ -1853,7 +1853,7 @@ void RenderObject::setStyle(PassRefPtr<RenderStyle> style)
// We need to ensure that view->maximalOutlineSize() is valid for any repaints that happen
// during styleDidChange (it's used by clippedOverflowRectForRepaint()).
if (m_style->outlineWidth() > 0 && m_style->outlineSize() > maximalOutlineSize(PaintPhaseOutline))
toRenderView(document().renderer())->setMaximalOutlineSize(m_style->outlineSize());
view().setMaximalOutlineSize(m_style->outlineSize());
bool doesNotNeedLayout = !m_parent || isText();
......
......@@ -363,11 +363,6 @@ inline const RenderView* toRenderView(const RenderObject* object)
// This will catch anyone doing an unnecessary cast.
void toRenderView(const RenderView*);
ALWAYS_INLINE RenderView* Document::renderView() const
{
return toRenderView(renderer());
}
// Stack-based class to assist with LayoutState push/pop
class LayoutStateMaintainer {
WTF_MAKE_NONCOPYABLE(LayoutStateMaintainer);
......
......@@ -44,6 +44,7 @@
#include "RenderSVGModelObject.h"
#include "RenderSVGRoot.h"
#include "RenderSVGViewportContainer.h"
#include "RenderView.h"
#include "SMILTimeContainer.h"
#include "SVGAngle.h"
#include "SVGElementInstance.h"
......@@ -223,8 +224,8 @@ void SVGSVGElement::updateCurrentTranslate()
if (RenderObject* object = renderer())
object->setNeedsLayout(true);
if (parentNode() == document() && document()->renderer())
document()->renderer()->repaint();
if (parentNode() == document() && document()->renderView())
document()->renderView()->repaint();
}
void SVGSVGElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
......
......@@ -1194,7 +1194,7 @@ static inline WebDataSource *dataSource(DocumentLoader* loader)
if (!_private->coreFrame->view()->documentView())
return [NSArray array];
RenderView* root = toRenderView(_private->coreFrame->document()->renderer());
RenderView* root = _private->coreFrame->document()->renderView();
if (!root)
return [NSArray array];
......
......@@ -62,6 +62,7 @@
#import <WebCore/HistoryItem.h>
#import <WebCore/Page.h>
#import <WebCore/RenderPart.h>
#import <WebCore/RenderView.h>
#import <WebCore/ThreadCheck.h>
#import <WebCore/WebCoreFrameView.h>
#import <WebCore/WebCoreView.h>
......@@ -571,7 +572,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
Document* document = coreFrame->document();
if (!document)
return YES;
RenderObject* renderView = document->renderer();
RenderView* renderView = document->renderView();
if (!renderView)
return YES;
return renderView->style()->isHorizontalWritingMode();
......@@ -585,7 +586,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
Document* document = coreFrame->document();
if (!document)
return NO;
RenderObject* renderView = document->renderer();
RenderView* renderView = document->renderView();
if (!renderView)
return NO;
return renderView->style()->isFlippedBlocksWritingMode();
......
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