Changeset 14658 in webkit


Ignore:
Timestamp:
May 31, 2006 10:56:54 PM (18 years ago)
Author:
adele
Message:

Reviewed by Hyatt.

No test possible (no functionality change)

  • dom/Document.cpp: (WebCore::Document::updateLayout): Changed to ensure that pending subtree layouts are performed too.
  • page/Frame.cpp: (WebCore::Frame::forceLayout): Force a full layout.
  • page/FrameView.cpp: (WebCore::FrameViewPrivate::reset): (WebCore::FrameView::layout): Changed to relayout only the subtree rooted at d->layoutRoot if it's non-zero and allowSubtree is true. (WebCore::FrameView::scheduleRelayout): Change pending subtree relayout into normal relayout by clearing d->layoutRoot and propagating needsLayout to the root. (WebCore::FrameView::scheduleRelayoutOfSubtree): Added.
  • page/FrameView.h:
  • rendering/RenderObject.cpp: (WebCore::RenderObject::markContainingBlocksForLayout): Added scheduleRelayout parameter. FrameView passes false to force marking all the way to the root when turning a pending subtree relayout into a full relayout. Otherwise, marking stops at the first textField (or at the root) and relayout of the last object reached is scheduled. (WebCore::RenderObject::scheduleRelayout):
  • rendering/RenderObject.h:
Location:
trunk/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r14657 r14658  
     12006-05-31  Mitz Pettel  <opendarwin.org@mitzpettel.com>
     2
     3        Reviewed by Hyatt.
     4
     5        - fix for http://bugzilla.opendarwin.org/show_bug.cgi?id=8969
     6          REGRESSION: typing in textfield repaints whole web page at gamefaqs.com
     7
     8        No test possible (no functionality change)
     9
     10        * dom/Document.cpp:
     11        (WebCore::Document::updateLayout): Changed to ensure that pending subtree
     12        layouts are performed too.
     13        * page/Frame.cpp:
     14        (WebCore::Frame::forceLayout): Force a full layout.
     15        * page/FrameView.cpp:
     16        (WebCore::FrameViewPrivate::reset):
     17        (WebCore::FrameView::layout): Changed to relayout only the subtree rooted
     18        at d->layoutRoot if it's non-zero and allowSubtree is true.
     19        (WebCore::FrameView::scheduleRelayout): Change pending subtree relayout into
     20        normal relayout by clearing d->layoutRoot and propagating needsLayout to the
     21        root.
     22        (WebCore::FrameView::scheduleRelayoutOfSubtree): Added.
     23        * page/FrameView.h:
     24        * rendering/RenderObject.cpp:
     25        (WebCore::RenderObject::markContainingBlocksForLayout): Added scheduleRelayout
     26        parameter. FrameView passes false to force marking all the way to the root
     27        when turning a pending subtree relayout into a full relayout. Otherwise,
     28        marking stops at the first textField (or at the root) and
     29        relayout of the last object reached is scheduled.
     30        (WebCore::RenderObject::scheduleRelayout):
     31        * rendering/RenderObject.h:
     32
    1332006-05-31  Sam Weinig  <sam.weinig@gmail.com>
    234
  • trunk/WebCore/dom/Document.cpp

    r14646 r14658  
    886886
    887887    // Only do a layout if changes have occurred that make it necessary.     
    888     if (m_view && renderer() && renderer()->needsLayout())
     888    if (m_view && renderer() && (m_view->layoutPending() || renderer()->needsLayout()))
    889889        m_view->layout();
    890890}
  • trunk/WebCore/page/Frame.cpp

    r14646 r14658  
    29892989    FrameView *v = d->m_view.get();
    29902990    if (v) {
    2991         v->layout();
     2991        v->layout(false);
    29922992        // We cannot unschedule a pending relayout, since the force can be called with
    29932993        // a tiny rectangle from a drawRect update.  By unscheduling we in effect
  • trunk/WebCore/page/FrameView.cpp

    r14638 r14658  
    8787        scrollingSelf = false;
    8888        layoutTimer.stop();
     89        layoutRoot = 0;
    8990        delayedLayout = false;
    9091        mousePressed = false;
     
    123124    Timer<FrameView> layoutTimer;
    124125    bool delayedLayout;
     126    RefPtr<Node> layoutRoot;
    125127   
    126128    bool layoutSchedulingEnabled;
     
    299301}
    300302
    301 void FrameView::layout()
     303void FrameView::layout(bool allowSubtree)
    302304{
    303305    if (d->layoutSuppressed)
     
    314316    }
    315317
     318    if (!allowSubtree && d->layoutRoot) {
     319        if (d->layoutRoot->renderer())
     320            d->layoutRoot->renderer()->markContainingBlocksForLayout(false);
     321        d->layoutRoot = 0;
     322    }
     323
     324    bool subtree = d->layoutRoot;
    316325    Document* document = m_frame->document();
    317326    if (!document) {
     
    321330    }
    322331
     332    Node* rootNode = subtree ? d->layoutRoot.get() : document;
    323333    d->layoutSchedulingEnabled = false;
    324334
     
    328338        document->recalcStyle();
    329339
    330     RenderView* root = static_cast<RenderView*>(document->renderer());
     340    RenderObject* root = rootNode->renderer();
    331341    if (!root) {
    332342        // FIXME: Do we need to set m_size here?
     
    338348    ScrollBarMode vMode = d->vmode;
    339349   
    340     RenderObject* rootRenderer = document->documentElement() ? document->documentElement()->renderer() : 0;
    341     if (document->isHTMLDocument()) {
    342         Node *body = static_cast<HTMLDocument*>(document)->body();
    343         if (body && body->renderer()) {
    344             if (body->hasTagName(framesetTag)) {
    345                 body->renderer()->setNeedsLayout(true);
    346                 vMode = ScrollBarAlwaysOff;
    347                 hMode = ScrollBarAlwaysOff;
     350    if (!subtree) {
     351        Document* document = static_cast<Document*>(rootNode);
     352        RenderObject* rootRenderer = document->documentElement() ? document->documentElement()->renderer() : 0;
     353        if (document->isHTMLDocument()) {
     354            Node *body = static_cast<HTMLDocument*>(document)->body();
     355            if (body && body->renderer()) {
     356                if (body->hasTagName(framesetTag)) {
     357                    body->renderer()->setNeedsLayout(true);
     358                    vMode = ScrollBarAlwaysOff;
     359                    hMode = ScrollBarAlwaysOff;
     360                } else if (body->hasTagName(bodyTag)) {
     361                    RenderObject* o = (rootRenderer->style()->overflow() == OVISIBLE) ? body->renderer() : rootRenderer;
     362                    applyOverflowToViewport(o, hMode, vMode); // Only applies to HTML UAs, not to XML/XHTML UAs
     363                }
    348364            }
    349             else if (body->hasTagName(bodyTag)) {
    350                 RenderObject* o = (rootRenderer->style()->overflow() == OVISIBLE) ? body->renderer() : rootRenderer;
    351                 applyOverflowToViewport(o, hMode, vMode); // Only applies to HTML UAs, not to XML/XHTML UAs
    352             }
    353         }
    354     }
    355     else if (rootRenderer)
    356         applyOverflowToViewport(rootRenderer, hMode, vMode); // XML/XHTML UAs use the root element.
    357 
     365        } else if (rootRenderer)
     366            applyOverflowToViewport(rootRenderer, hMode, vMode); // XML/XHTML UAs use the root element.
    358367#if INSTRUMENT_LAYOUT_SCHEDULING
    359     if (d->firstLayout && !document->ownerElement())
    360         printf("Elapsed time before first layout: %d\n", document->elapsedTime());
     368        if (d->firstLayout && !document->ownerElement())
     369            printf("Elapsed time before first layout: %d\n", document->elapsedTime());
    361370#endif
    362 
    363     d->doFullRepaint = d->firstLayout || root->printingMode();
     371    }
     372
     373    d->doFullRepaint = !subtree && (d->firstLayout || static_cast<RenderView*>(root)->printingMode());
    364374    if (d->repaintRects)
    365375        d->repaintRects->clear();
    366376
    367     // Now set our scrollbar state for the layout.
    368     ScrollBarMode currentHMode = hScrollBarMode();
    369     ScrollBarMode currentVMode = vScrollBarMode();
    370 
    371377    bool didFirstLayout = false;
    372     if (d->firstLayout || (hMode != currentHMode || vMode != currentVMode)) {
    373         suppressScrollBars(true);
    374         if (d->firstLayout) {
    375             d->firstLayout = false;
    376             didFirstLayout = true;
     378    if (!subtree) {
     379        // Now set our scrollbar state for the layout.
     380        ScrollBarMode currentHMode = hScrollBarMode();
     381        ScrollBarMode currentVMode = vScrollBarMode();
     382
     383        if (d->firstLayout || (hMode != currentHMode || vMode != currentVMode)) {
     384            suppressScrollBars(true);
     385            if (d->firstLayout) {
     386                d->firstLayout = false;
     387                didFirstLayout = true;
     388               
     389                // Set the initial vMode to AlwaysOn if we're auto.
     390                if (vMode == ScrollBarAuto)
     391                    ScrollView::setVScrollBarMode(ScrollBarAlwaysOn); // This causes a vertical scrollbar to appear.
     392                // Set the initial hMode to AlwaysOff if we're auto.
     393                if (hMode == ScrollBarAuto)
     394                    ScrollView::setHScrollBarMode(ScrollBarAlwaysOff); // This causes a horizontal scrollbar to disappear.
     395            }
    377396           
    378             // Set the initial vMode to AlwaysOn if we're auto.
    379             if (vMode == ScrollBarAuto)
    380                 ScrollView::setVScrollBarMode(ScrollBarAlwaysOn); // This causes a vertical scrollbar to appear.
    381             // Set the initial hMode to AlwaysOff if we're auto.
    382             if (hMode == ScrollBarAuto)
    383                 ScrollView::setHScrollBarMode(ScrollBarAlwaysOff); // This causes a horizontal scrollbar to disappear.
     397            if (hMode == vMode)
     398                ScrollView::setScrollBarsMode(hMode);
     399            else {
     400                ScrollView::setHScrollBarMode(hMode);
     401                ScrollView::setVScrollBarMode(vMode);
     402            }
     403
     404            suppressScrollBars(false, true);
    384405        }
    385        
    386         if (hMode == vMode)
    387             ScrollView::setScrollBarsMode(hMode);
    388         else {
    389             ScrollView::setHScrollBarMode(hMode);
    390             ScrollView::setVScrollBarMode(vMode);
    391         }
    392 
    393         suppressScrollBars(false, true);
    394     }
    395 
    396     IntSize oldSize = m_size;
    397 
    398     m_size = IntSize(visibleWidth(), visibleHeight());
    399 
    400     if (oldSize != m_size)
    401         d->doFullRepaint = true;
    402    
    403     RenderLayer* layer = root->layer();
     406
     407        IntSize oldSize = m_size;
     408
     409        m_size = IntSize(visibleWidth(), visibleHeight());
     410
     411        if (oldSize != m_size)
     412            d->doFullRepaint = true;
     413    }
     414   
     415    RenderLayer* layer = root->enclosingLayer();
    404416     
    405417    if (!d->doFullRepaint) {
     
    408420    }
    409421
     422    if (subtree) {
     423        if (root->recalcMinMax())
     424            root->recalcMinMaxWidths();
     425    }
    410426    root->layout();
     427    d->layoutRoot = 0;
    411428
    412429    m_frame->invalidateSelection();
     
    415432    d->layoutSuppressed = false;
    416433
    417     if (!root->printingMode())
     434    if (!subtree && !static_cast<RenderView*>(root)->printingMode())
    418435        resizeContents(layer->width(), layer->height());
    419436
     
    422439
    423440    // We update our widget positions right after doing a layout.
    424     root->updateWidgetPositions();
     441    if (!subtree)
     442        static_cast<RenderView*>(root)->updateWidgetPositions();
    425443   
    426444    if (d->repaintRects && !d->repaintRects->isEmpty()) {
     
    10661084void FrameView::scheduleRelayout()
    10671085{
     1086    if (d->layoutRoot) {
     1087        if (d->layoutRoot->renderer())
     1088            d->layoutRoot->renderer()->markContainingBlocksForLayout(false);
     1089        d->layoutRoot = 0;
     1090    }
    10681091    if (!d->layoutSchedulingEnabled)
    10691092        return;
     
    10881111}
    10891112
     1113void FrameView::scheduleRelayoutOfSubtree(Node* n)
     1114{
     1115    if (!d->layoutSchedulingEnabled || m_frame->document() && m_frame->document()->renderer() && m_frame->document()->renderer()->needsLayout()) {
     1116        if (n->renderer())
     1117            n->renderer()->markContainingBlocksForLayout(false);
     1118        return;
     1119    }
     1120
     1121    if (layoutPending()) {
     1122        if (d->layoutRoot != n) {
     1123            // Just do a full relayout
     1124            if (d->layoutRoot && d->layoutRoot->renderer())
     1125                d->layoutRoot->renderer()->markContainingBlocksForLayout(false);
     1126            d->layoutRoot = 0;
     1127            if (n->renderer())
     1128                n->renderer()->markContainingBlocksForLayout(false);
     1129        }
     1130    } else {
     1131        int delay = m_frame->document()->minimumLayoutDelay();
     1132        d->layoutRoot = n;
     1133        d->delayedLayout = delay != 0;
     1134        d->layoutTimer.startOneShot(delay * 0.001);
     1135    }
     1136}
     1137
    10901138bool FrameView::layoutPending()
    10911139{
  • trunk/WebCore/page/FrameView.h

    r14638 r14658  
    116116    void print();
    117117
    118     void layout();
     118    void layout(bool allowSubtree = true);
    119119
    120120    bool inLayout() const;
     
    153153   
    154154    void scheduleRelayout();
     155    void scheduleRelayoutOfSubtree(Node*);
    155156    void unscheduleRelayout();
    156157    bool haveDelayedLayoutScheduled();
  • trunk/WebCore/rendering/RenderObject.cpp

    r14650 r14658  
    690690}
    691691
    692 void RenderObject::markContainingBlocksForLayout()
     692void RenderObject::markContainingBlocksForLayout(bool scheduleRelayout)
    693693{
    694694    RenderObject *o = container();
     
    700700                return;
    701701            o->m_posChildNeedsLayout = true;
    702         }
    703         else {
     702        } else {
    704703            if (o->m_normalChildNeedsLayout)
    705704                return;
     
    708707
    709708        last = o;
     709        if (scheduleRelayout && last->isTextField())
     710            break;
    710711        o = o->container();
    711712    }
    712713
    713     last->scheduleRelayout();
     714    if (scheduleRelayout)
     715        last->scheduleRelayout();
    714716}
    715717
     
    25602562void RenderObject::scheduleRelayout()
    25612563{
    2562     if (!isRenderView())
    2563         return;
    2564     FrameView *view = static_cast<RenderView *>(this)->frameView();
    2565     if (view)
    2566         view->scheduleRelayout();
     2564     if (isRenderView()) {
     2565         FrameView* view = static_cast<RenderView*>(this)->frameView();
     2566         if (view)
     2567             view->scheduleRelayout();
     2568     } else {
     2569         FrameView* v = view() ? view()->frameView() : 0;
     2570         if (v)
     2571             v->scheduleRelayoutOfSubtree(node());
     2572     }
    25672573}
    25682574
  • trunk/WebCore/rendering/RenderObject.h

    r14650 r14658  
    340340
    341341    virtual void markAllDescendantsWithFloatsForLayout(RenderObject* floatToRemove = 0);
    342     void markContainingBlocksForLayout();
     342    void markContainingBlocksForLayout(bool scheduleRelayout = true);
    343343    void setNeedsLayout(bool b, bool markParents = true);
    344344    void setChildNeedsLayout(bool b, bool markParents = true);
Note: See TracChangeset for help on using the changeset viewer.