⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 155424 in webkit


Ignore:
Timestamp:
Sep 10, 2013, 12:00:56 AM (13 years ago)
Author:
Darin Adler
Message:

Some refinements in FrameView::layout
https://bugs.webkit.org/show_bug.cgi?id=121076

Reviewed by Andreas Kling.

  • page/FrameView.cpp:

(WebCore::FrameView::layout): Use a reference for the document in
this function since code assumes it's non-null anyway. Change code to
only call styleResolverIfExists once. Rewrite comments about blocks
and the scopes they create for better clarity. Make m_nestedLayoutCount
easier to read. Use HTMLElement* for the pointer to the body element.
Moved the call to calculateScrollbarModesForLayout in so we don't
waste time doing it for subtree layouts. Get rid of the unhelpful
currentHMode and currentVMode local variables. Get rid of an extra
block scope we did not need.

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r155422 r155424  
     12013-09-09  Darin Adler  <darin@apple.com>
     2
     3        Some refinements in FrameView::layout
     4        https://bugs.webkit.org/show_bug.cgi?id=121076
     5
     6        Reviewed by Andreas Kling.
     7
     8        * page/FrameView.cpp:
     9        (WebCore::FrameView::layout): Use a reference for the document in
     10        this function since code assumes it's non-null anyway. Change code to
     11        only call styleResolverIfExists once. Rewrite comments about blocks
     12        and the scopes they create for better clarity. Make m_nestedLayoutCount
     13        easier to read. Use HTMLElement* for the pointer to the body element.
     14        Moved the call to calculateScrollbarModesForLayout in so we don't
     15        waste time doing it for subtree layouts. Get rid of the unhelpful
     16        currentHMode and currentVMode local variables. Get rid of an extra
     17        block scope we did not need.
     18
    1192013-09-09  Santosh Mahto  <santosh.ma@samsung.com>
    220
  • trunk/Source/WebCore/page/FrameView.cpp

    r155344 r155424  
    11301130
    11311131    ASSERT(frame().view() == this);
    1132 
    1133     Document* document = frame().document();
    1134     ASSERT(!document->inPageCache());
     1132    ASSERT(frame().document());
     1133
     1134    Document& document = *frame().document();
     1135    ASSERT(!document.inPageCache());
     1136
    11351137    bool subtree;
    11361138    RenderObject* root;
     
    11481150
    11491151        // Viewport-dependent media queries may cause us to need completely different style information.
    1150         if (!document->styleResolverIfExists() || document->styleResolverIfExists()->affectedByViewportChange()) {
    1151             document->styleResolverChanged(DeferRecalcStyle);
    1152             // FIXME: This instrumentation event is not strictly accurate since cached media query results
    1153             //       do not persist across StyleResolver rebuilds.
    1154             InspectorInstrumentation::mediaQueryResultChanged(document);
     1152        StyleResolver* styleResolver = document.styleResolverIfExists();
     1153        if (!styleResolver || styleResolver->affectedByViewportChange()) {
     1154            document.styleResolverChanged(DeferRecalcStyle);
     1155            // FIXME: This instrumentation event is not strictly accurate since cached media query results do not persist across StyleResolver rebuilds.
     1156            InspectorInstrumentation::mediaQueryResultChanged(&document);
    11551157        } else
    1156             document->evaluateMediaQueryList();
     1158            document.evaluateMediaQueryList();
    11571159
    11581160        // If there is any pagination to apply, it will affect the RenderView's style, so we should
     
    11631165        // the layout beats any sort of style recalc update that needs to occur.
    11641166        TemporaryChange<bool> changeDoingPreLayoutStyleUpdate(m_doingPreLayoutStyleUpdate, true);
    1165         document->updateStyleIfNeeded();
     1167        document.updateStyleIfNeeded();
    11661168
    11671169        subtree = m_layoutRoot;
     
    11721174            return;
    11731175
    1174         root = subtree ? m_layoutRoot : document->renderView();
     1176        root = subtree ? m_layoutRoot : document.renderView();
    11751177        if (!root) {
    11761178            // FIXME: Do we need to set m_size here?
    11771179            return;
    11781180        }
    1179     } // Reset m_layoutSchedulingEnabled to its previous value.
    1180     // The only reason the scoping was closed here is allow fontCachePurgePreventer
    1181     // to outlive the change and reset of m_layoutSchedulingEnabled.
     1181
     1182        // Close block here so we can set up the font cache purge preventer, which we will still
     1183        // want in scope even after we want m_layoutSchedulingEnabled to be restored again.
     1184        // The next block sets m_layoutSchedulingEnabled back to false once again.
     1185    }
    11821186
    11831187    FontCachePurgePreventer fontCachePurgePreventer;
    11841188    RenderLayer* layer;
     1189
     1190    ++m_nestedLayoutCount;
     1191
    11851192    {
    11861193        TemporaryChange<bool> changeSchedulingEnabled(m_layoutSchedulingEnabled, false);
    11871194
    1188         m_nestedLayoutCount++;
    1189 
    11901195        if (!m_layoutRoot) {
    1191             Document* document = frame().document();
    1192             Node* body = document->body();
     1196            HTMLElement* body = document.body();
    11931197            if (body && body->renderer()) {
    11941198                if (body->hasTagName(framesetTag) && !frameFlatteningEnabled()) {
     
    12021206#ifdef INSTRUMENT_LAYOUT_SCHEDULING
    12031207            if (m_firstLayout && !frame().ownerElement())
    1204                 printf("Elapsed time before first layout: %d\n", document->elapsedTime());
     1208                printf("Elapsed time before first layout: %d\n", document.elapsedTime());
    12051209#endif       
    12061210        }
     
    12081212        autoSizeIfEnabled();
    12091213
    1210         ScrollbarMode hMode;
    1211         ScrollbarMode vMode;   
    1212         calculateScrollbarModesForLayout(hMode, vMode);
    1213 
    12141214        m_needsFullRepaint = !subtree && (m_firstLayout || toRenderView(*root).printing());
    12151215
    12161216        if (!subtree) {
    1217             // Now set our scrollbar state for the layout.
    1218             ScrollbarMode currentHMode = horizontalScrollbarMode();
    1219             ScrollbarMode currentVMode = verticalScrollbarMode();
    1220 
    1221             if (m_firstLayout || (hMode != currentHMode || vMode != currentVMode)) {
     1217            ScrollbarMode hMode;
     1218            ScrollbarMode vMode;   
     1219            calculateScrollbarModesForLayout(hMode, vMode);
     1220
     1221            if (m_firstLayout || (hMode != horizontalScrollbarMode() || vMode != verticalScrollbarMode())) {
    12221222                if (m_firstLayout) {
    12231223                    setScrollbarsSuppressed(true);
     
    12511251                m_needsFullRepaint = true;
    12521252                if (!m_firstLayout) {
    1253                     RenderBox* rootRenderer = document->documentElement() ? document->documentElement()->renderBox() : 0;
    1254                     RenderBox* bodyRenderer = rootRenderer && document->body() ? document->body()->renderBox() : 0;
     1253                    RenderBox* rootRenderer = document.documentElement() ? document.documentElement()->renderBox() : 0;
     1254                    RenderBox* bodyRenderer = rootRenderer && document.body() ? document.body()->renderBox() : 0;
    12551255                    if (bodyRenderer && bodyRenderer->stretchesToViewport())
    12561256                        bodyRenderer->setChildNeedsLayout(true);
     
    12651265        pauseScheduledEvents();
    12661266
    1267         {
    1268             bool disableLayoutState = false;
    1269             if (subtree) {
    1270                 disableLayoutState = root->view().shouldDisableLayoutStateForSubtree(root);
    1271                 root->view().pushLayoutState(root);
    1272             }
    1273             LayoutStateDisabler layoutStateDisabler(disableLayoutState ? &root->view() : 0);
    1274 
    1275             m_inLayout = true;
    1276             beginDeferredRepaints();
    1277             forceLayoutParentViewIfNeeded();
     1267        bool disableLayoutState = false;
     1268        if (subtree) {
     1269            disableLayoutState = root->view().shouldDisableLayoutStateForSubtree(root);
     1270            root->view().pushLayoutState(root);
     1271        }
     1272        LayoutStateDisabler layoutStateDisabler(disableLayoutState ? &root->view() : 0);
     1273
     1274        m_inLayout = true;
     1275        beginDeferredRepaints();
     1276        forceLayoutParentViewIfNeeded();
     1277        root->layout();
     1278#if ENABLE(TEXT_AUTOSIZING)
     1279        if (document.textAutosizer()->processSubtree(root) && root->needsLayout())
    12781280            root->layout();
    1279 #if ENABLE(TEXT_AUTOSIZING)
    1280             bool autosized = document->textAutosizer()->processSubtree(root);
    1281             if (autosized && root->needsLayout())
    1282                 root->layout();
    1283 #endif
    1284             endDeferredRepaints();
    1285             m_inLayout = false;
    1286 
    1287             if (subtree)
    1288                 root->view().popLayoutState(root);
    1289         }
     1281#endif
     1282        endDeferredRepaints();
     1283        m_inLayout = false;
     1284
     1285        if (subtree)
     1286            root->view().popLayoutState(root);
     1287
    12901288        m_layoutRoot = 0;
    1291     } // Reset m_layoutSchedulingEnabled to its previous value.
     1289
     1290        // Close block here to end the scope of changeSchedulingEnabled and layoutStateDisabler.
     1291    }
    12921292
    12931293    bool neededFullRepaint = m_needsFullRepaint;
     
    13171317        cache->postNotification(root, AXObjectCache::AXLayoutComplete, true);
    13181318#endif
     1319
    13191320#if ENABLE(DASHBOARD_SUPPORT) || ENABLE(DRAGGABLE_REGION)
    13201321    updateAnnotatedRegions();
     
    13251326    updateCanBlitOnScrollRecursively();
    13261327
    1327     if (document->hasListenerType(Document::OVERFLOWCHANGED_LISTENER))
    1328         updateOverflowStatus(layoutWidth() < contentsWidth(),
    1329                              layoutHeight() < contentsHeight());
     1328    if (document.hasListenerType(Document::OVERFLOWCHANGED_LISTENER))
     1329        updateOverflowStatus(layoutWidth() < contentsWidth(), layoutHeight() < contentsHeight());
    13301330
    13311331    if (m_postLayoutTasksTimer.isActive())
     
    13381338            } else {
    13391339                m_inSynchronousPostLayout = true;
    1340                 // Calls resumeScheduledEvents()
    1341                 performPostLayoutTasks();
     1340                performPostLayoutTasks(); // Calls resumeScheduledEvents().
    13421341                m_inSynchronousPostLayout = false;
    13431342            }
    13441343        }
    1345        
     1344
    13461345        if (!m_postLayoutTasksTimer.isActive() && (needsLayout() || m_inSynchronousPostLayout || inChildFrameLayoutWithFrameFlattening)) {
    13471346            // If we need layout or are already in a synchronous call to postLayoutTasks(),
     
    13591358    InspectorInstrumentation::didLayout(cookie, root);
    13601359
    1361     m_nestedLayoutCount--;
     1360    --m_nestedLayoutCount;
     1361
    13621362    if (m_nestedLayoutCount)
    13631363        return;
Note: See TracChangeset for help on using the changeset viewer.