Changeset 162962 in webkit


Ignore:
Timestamp:
Jan 28, 2014 2:32:05 PM (10 years ago)
Author:
Antti Koivisto
Message:

Document::topDocument() should return a reference
https://bugs.webkit.org/show_bug.cgi?id=127786

Reviewed by Darin Adler.

  • accessibility/AccessibilityObject.cpp:

(WebCore::AccessibilityObject::mainFrame):
(WebCore::AccessibilityObject::topDocument):

  • accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:

(-[WebAccessibilityObjectWrapper accessibilityContainer]):

  • dom/Document.cpp:

(WebCore::Document::~Document):
(WebCore::Document::createRenderTree):
(WebCore::Document::destroyRenderTree):
(WebCore::Document::clearAXObjectCache):
(WebCore::Document::existingAXObjectCache):
(WebCore::Document::axObjectCache):
(WebCore::Document::implicitClose):
(WebCore::Document::topDocument):
(WebCore::Document::topOrigin):
(WebCore::Document::webkitCancelFullScreen):
(WebCore::Document::webkitDidExitFullScreenForElement):

  • dom/Document.h:
  • page/DOMWindow.cpp:

(WebCore::DOMWindow::incrementScrollEventListenersCount):
(WebCore::DOMWindow::decrementScrollEventListenersCount):

  • rendering/RenderEmbeddedObject.cpp:

(WebCore::RenderEmbeddedObject::isReplacementObscured):

  • rendering/RenderView.cpp:

(WebCore::RenderView::RepaintRegionAccumulator::RepaintRegionAccumulator):

Location:
trunk/Source/WebCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r162960 r162962  
     12014-01-28  Antti Koivisto  <antti@apple.com>
     2
     3        Document::topDocument() should return a reference
     4        https://bugs.webkit.org/show_bug.cgi?id=127786
     5
     6        Reviewed by Darin Adler.
     7
     8        * accessibility/AccessibilityObject.cpp:
     9        (WebCore::AccessibilityObject::mainFrame):
     10        (WebCore::AccessibilityObject::topDocument):
     11        * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
     12        (-[WebAccessibilityObjectWrapper accessibilityContainer]):
     13        * dom/Document.cpp:
     14        (WebCore::Document::~Document):
     15        (WebCore::Document::createRenderTree):
     16        (WebCore::Document::destroyRenderTree):
     17        (WebCore::Document::clearAXObjectCache):
     18        (WebCore::Document::existingAXObjectCache):
     19        (WebCore::Document::axObjectCache):
     20        (WebCore::Document::implicitClose):
     21        (WebCore::Document::topDocument):
     22        (WebCore::Document::topOrigin):
     23        (WebCore::Document::webkitCancelFullScreen):
     24        (WebCore::Document::webkitDidExitFullScreenForElement):
     25        * dom/Document.h:
     26        * page/DOMWindow.cpp:
     27        (WebCore::DOMWindow::incrementScrollEventListenersCount):
     28        (WebCore::DOMWindow::decrementScrollEventListenersCount):
     29        * rendering/RenderEmbeddedObject.cpp:
     30        (WebCore::RenderEmbeddedObject::isReplacementObscured):
     31        * rendering/RenderView.cpp:
     32        (WebCore::RenderView::RepaintRegionAccumulator::RepaintRegionAccumulator):
     33       
    1342014-01-28  Viatcheslav Ostapenko  <sl.ostapenko@samsung.com>
    235
  • trunk/Source/WebCore/accessibility/AccessibilityObject.cpp

    r162663 r162962  
    610610    Document* document = topDocument();
    611611    if (!document)
    612         return 0;
     612        return nullptr;
    613613   
    614614    Frame* frame = document->frame();
    615615    if (!frame)
    616         return 0;
     616        return nullptr;
    617617   
    618618    return &frame->mainFrame();
     
    622622{
    623623    if (!document())
    624         return 0;
    625     return document()->topDocument();
     624        return nullptr;
     625    return &document()->topDocument();
    626626}
    627627
  • trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm

    r162913 r162962  
    11101110    FrameView* frameView = m_object->documentFrameView();
    11111111    Document* document = m_object->document();
    1112     if (document && frameView && document != document->topDocument())
     1112    if (document && frameView && document != &document->topDocument())
    11131113        return frameView->platformWidget();
    11141114   
  • trunk/Source/WebCore/dom/Document.cpp

    r162947 r162962  
    594594    detachParser();
    595595
    596     if (this == topDocument())
     596    if (this == &topDocument())
    597597        clearAXObjectCache();
    598598
     
    19481948    ASSERT(!renderView());
    19491949    ASSERT(!m_inPageCache);
    1950     ASSERT(!m_axObjectCache || this != topDocument());
     1950    ASSERT(!m_axObjectCache || this != &topDocument());
    19511951
    19521952    if (m_isNonRenderedPlaceholder)
     
    20332033    TemporaryChange<bool> change(m_renderTreeBeingDestroyed, true);
    20342034
    2035     if (this == topDocument())
     2035    if (this == &topDocument())
    20362036        clearAXObjectCache();
    20372037
     
    21682168void Document::clearAXObjectCache()
    21692169{
    2170     ASSERT(topDocument() == this);
     2170    ASSERT(&topDocument() == this);
    21712171    // Clear the cache member variable before calling delete because attempts
    21722172    // are made to access it during destruction.
     
    21762176AXObjectCache* Document::existingAXObjectCache() const
    21772177{
    2178     if (!topDocument()->hasLivingRenderTree())
     2178    Document& topDocument = this->topDocument();
     2179    if (!topDocument.hasLivingRenderTree())
    21792180        return nullptr;
    2180 
    2181     return topDocument()->m_axObjectCache.get();
     2181    return topDocument.m_axObjectCache.get();
    21822182}
    21832183
     
    21912191    // to any other WebCoreAXObject on the same page.  Using a single cache allows
    21922192    // lookups across nested webareas (i.e. multiple documents).
    2193     Document* topDocument = this->topDocument();
     2193    Document& topDocument = this->topDocument();
    21942194
    21952195    // If the document has already been detached, do not make a new axObjectCache.
    2196     if (!topDocument->hasLivingRenderTree())
     2196    if (!topDocument.hasLivingRenderTree())
    21972197        return nullptr;
    21982198
    2199     ASSERT(topDocument == this || !m_axObjectCache);
    2200     if (!topDocument->m_axObjectCache)
    2201         topDocument->m_axObjectCache = adoptPtr(new AXObjectCache(*topDocument));
    2202     return topDocument->m_axObjectCache.get();
     2199    ASSERT(&topDocument == this || !m_axObjectCache);
     2200    if (!topDocument.m_axObjectCache)
     2201        topDocument.m_axObjectCache = adoptPtr(new AXObjectCache(topDocument));
     2202    return topDocument.m_axObjectCache.get();
    22032203}
    22042204
     
    24692469        // only safe to call when a layout is not in progress, so it can not be used in postNotification.   
    24702470        axObjectCache()->getOrCreate(renderView());
    2471         if (this == topDocument())
     2471        if (this == &topDocument())
    24722472            axObjectCache()->postNotification(renderView(), AXObjectCache::AXLoadComplete);
    24732473        else {
     
    43124312}
    43134313
    4314 Document* Document::topDocument() const
    4315 {
    4316     return m_frame ? m_frame->mainFrame().document() : const_cast<Document*>(this);
     4314Document& Document::topDocument() const
     4315{
     4316    if (!m_frame)
     4317        return const_cast<Document&>(*this);
     4318    // This should always be non-null.
     4319    Document* mainFrameDocument = m_frame->mainFrame().document();
     4320    return mainFrameDocument ? *mainFrameDocument : const_cast<Document&>(*this);
    43174321}
    43184322
     
    48764880SecurityOrigin* Document::topOrigin() const
    48774881{
    4878     return topDocument()->securityOrigin();
     4882    return topDocument().securityOrigin();
    48794883}
    48804884
     
    52235227    // "To fully exit fullscreen act as if the exitFullscreen() method was invoked on the top-level browsing
    52245228    // context's document and subsequently empty that document's fullscreen element stack."
    5225     if (!topDocument()->webkitFullscreenElement())
     5229    Document& topDocument = this->topDocument();
     5230    if (!topDocument.webkitFullscreenElement())
    52265231        return;
    52275232
     
    52295234    // calling webkitExitFullscreen():
    52305235    Vector<RefPtr<Element>> replacementFullscreenElementStack;
    5231     replacementFullscreenElementStack.append(topDocument()->webkitFullscreenElement());
    5232     topDocument()->m_fullScreenElementStack.swap(replacementFullscreenElementStack);
    5233 
    5234     topDocument()->webkitExitFullscreen();
     5236    replacementFullscreenElementStack.append(topDocument.webkitFullscreenElement());
     5237    topDocument.m_fullScreenElementStack.swap(replacementFullscreenElementStack);
     5238
     5239    topDocument.webkitExitFullscreen();
    52355240}
    52365241
     
    54055410    // means that the events will be queued there. So if we have no events here, start the timer on
    54065411    // the exiting document.
    5407     Document* exitingDocument = this;
    5408     if (m_fullScreenChangeEventTargetQueue.isEmpty() && m_fullScreenErrorEventTargetQueue.isEmpty())
    5409         exitingDocument = topDocument();
    5410     exitingDocument->m_fullScreenChangeDelayTimer.startOneShot(0);
     5412    bool eventTargetQueuesEmpty = m_fullScreenChangeEventTargetQueue.isEmpty() && m_fullScreenErrorEventTargetQueue.isEmpty();
     5413    Document& exitingDocument = eventTargetQueuesEmpty ? topDocument() : *this;
     5414    exitingDocument.m_fullScreenChangeDelayTimer.startOneShot(0);
    54115415}
    54125416   
  • trunk/Source/WebCore/dom/Document.h

    r162795 r162962  
    906906
    907907    Document* parentDocument() const;
    908     Document* topDocument() const;
     908    Document& topDocument() const;
    909909   
    910910    ScriptRunner* scriptRunner() { return m_scriptRunner.get(); }
  • trunk/Source/WebCore/page/DOMWindow.cpp

    r162663 r162962  
    16961696{
    16971697    Document* document = this->document();
    1698     if (++m_scrollEventListenerCount == 1 && document == document->topDocument()) {
     1698    if (++m_scrollEventListenerCount == 1 && document == &document->topDocument()) {
    16991699        Frame* frame = this->frame();
    17001700        if (frame && frame->page())
     
    17061706{
    17071707    Document* document = this->document();
    1708     if (!--m_scrollEventListenerCount && document == document->topDocument()) {
     1708    if (!--m_scrollEventListenerCount && document == &document->topDocument()) {
    17091709        Frame* frame = this->frame();
    17101710        if (frame && frame->page() && !document->inPageCache())
  • trunk/Source/WebCore/rendering/RenderEmbeddedObject.cpp

    r161752 r162962  
    425425        return true;
    426426
    427     RenderView* rootRenderView = document().topDocument()->renderView();
     427    RenderView* rootRenderView = document().topDocument().renderView();
    428428    ASSERT(rootRenderView);
    429429    if (!rootRenderView)
  • trunk/Source/WebCore/rendering/RenderView.cpp

    r162947 r162962  
    12671267
    12681268RenderView::RepaintRegionAccumulator::RepaintRegionAccumulator(RenderView* view)
    1269     : m_rootView(view ? view->document().topDocument()->renderView() : nullptr)
     1269    : m_rootView(view ? view->document().topDocument().renderView() : nullptr)
    12701270{
    12711271    if (!m_rootView)
Note: See TracChangeset for help on using the changeset viewer.