~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/3rdparty/webkit/WebCore/platform/ScrollView.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2009-11-02 18:30:08 UTC
  • mfrom: (1.2.2 upstream)
  • mto: (15.2.5 experimental)
  • mto: This revision was merged to the branch mainline in revision 88.
  • Revision ID: james.westby@ubuntu.com-20091102183008-b6a4gcs128mvfb3m
Tags: upstream-4.6.0~beta1
ImportĀ upstreamĀ versionĀ 4.6.0~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
    , m_scrollbarsAvoidingResizer(0)
47
47
    , m_scrollbarsSuppressed(false)
48
48
    , m_inUpdateScrollbars(false)
 
49
    , m_updateScrollbarsPass(0)
49
50
    , m_drawPanScrollIcon(false)
50
51
    , m_useFixedLayout(false)
51
52
{
52
53
    platformInit();
53
 
    if (platformWidget())
54
 
        platformSetCanBlitOnScroll(true);
55
54
}
56
55
 
57
56
ScrollView::~ScrollView()
59
58
    platformDestroy();
60
59
}
61
60
 
62
 
void ScrollView::addChild(Widget* child) 
 
61
void ScrollView::addChild(PassRefPtr<Widget> prpChild) 
63
62
{
 
63
    Widget* child = prpChild.get();
64
64
    ASSERT(child != this && !child->parent());
65
65
    child->setParent(this);
66
 
    m_children.add(child);
 
66
    m_children.add(prpChild);
67
67
    if (child->platformWidget())
68
68
        platformAddChild(child);
69
69
}
79
79
 
80
80
void ScrollView::setHasHorizontalScrollbar(bool hasBar)
81
81
{
82
 
    if (hasBar && !m_horizontalScrollbar && !platformHasHorizontalAdjustment()) {
 
82
    if (hasBar && !m_horizontalScrollbar) {
83
83
        m_horizontalScrollbar = createScrollbar(HorizontalScrollbar);
84
84
        addChild(m_horizontalScrollbar.get());
 
85
        m_horizontalScrollbar->styleChanged();
85
86
    } else if (!hasBar && m_horizontalScrollbar) {
86
87
        removeChild(m_horizontalScrollbar.get());
87
88
        m_horizontalScrollbar = 0;
90
91
 
91
92
void ScrollView::setHasVerticalScrollbar(bool hasBar)
92
93
{
93
 
    if (hasBar && !m_verticalScrollbar && !platformHasVerticalAdjustment()) {
 
94
    if (hasBar && !m_verticalScrollbar) {
94
95
        m_verticalScrollbar = createScrollbar(VerticalScrollbar);
95
96
        addChild(m_verticalScrollbar.get());
 
97
        m_verticalScrollbar->styleChanged();
96
98
    } else if (!hasBar && m_verticalScrollbar) {
97
99
        removeChild(m_verticalScrollbar.get());
98
100
        m_verticalScrollbar = 0;
99
101
    }
100
102
}
101
103
 
 
104
#if !PLATFORM(GTK)
102
105
PassRefPtr<Scrollbar> ScrollView::createScrollbar(ScrollbarOrientation orientation)
103
106
{
104
107
    return Scrollbar::createNativeScrollbar(this, orientation, RegularScrollbar);
115
118
    else
116
119
        updateScrollbars(scrollOffset());
117
120
}
 
121
#endif
118
122
 
119
123
void ScrollView::scrollbarModes(ScrollbarMode& horizontalMode, ScrollbarMode& verticalMode) const
120
124
{
164
168
    return m_canBlitOnScroll;
165
169
}
166
170
 
 
171
#if !PLATFORM(GTK)
167
172
IntRect ScrollView::visibleContentRect(bool includeScrollbars) const
168
173
{
169
174
    if (platformWidget())
172
177
                   IntSize(max(0, width() - (verticalScrollbar() && !includeScrollbars ? verticalScrollbar()->width() : 0)), 
173
178
                           max(0, height() - (horizontalScrollbar() && !includeScrollbars ? horizontalScrollbar()->height() : 0))));
174
179
}
 
180
#endif
175
181
 
176
182
int ScrollView::layoutWidth() const
177
183
{
239
245
    // Figure out if we really moved.
240
246
    IntSize newOffset = m_scrollOffset;
241
247
    if (scrollbar) {
242
 
        if (scrollbar == m_horizontalScrollbar)
 
248
        if (scrollbar->orientation() == HorizontalScrollbar)
243
249
            newOffset.setWidth(scrollbar->value());
244
 
        else if (scrollbar == m_verticalScrollbar)
 
250
        else if (scrollbar->orientation() == VerticalScrollbar)
245
251
            newOffset.setHeight(scrollbar->value());
246
252
    }
247
253
 
278
284
    // on up the view chain.
279
285
    // This rect is not clamped, since Mail actually relies on receiving an unclamped rect with negative coordinates in order to
280
286
    // expose the headers.
281
 
    hostWindow()->scrollRectIntoView(rect, this);
 
287
    if (hostWindow())
 
288
        hostWindow()->scrollRectIntoView(rect, this);
282
289
}
283
290
 
284
291
void ScrollView::setScrollPosition(const IntPoint& scrollPoint)
315
322
    return false;
316
323
}
317
324
 
 
325
static const unsigned cMaxUpdateScrollbarsPass = 2;
 
326
 
318
327
void ScrollView::updateScrollbars(const IntSize& desiredOffset)
319
328
{
320
 
    // Don't allow re-entrancy into this function.
321
329
    if (m_inUpdateScrollbars || prohibitsScrolling() || platformWidget())
322
330
        return;
323
331
 
324
 
    m_inUpdateScrollbars = true;
 
332
    // If we came in here with the view already needing a layout, then go ahead and do that
 
333
    // first.  (This will be the common case, e.g., when the page changes due to window resizing for example).
 
334
    // This layout will not re-enter updateScrollbars and does not count towards our max layout pass total.
 
335
    if (!m_scrollbarsSuppressed) {
 
336
        m_inUpdateScrollbars = true;
 
337
        visibleContentsResized();
 
338
        m_inUpdateScrollbars = false;
 
339
    }
325
340
 
 
341
    bool hasHorizontalScrollbar = m_horizontalScrollbar;
326
342
    bool hasVerticalScrollbar = m_verticalScrollbar;
327
 
    bool hasHorizontalScrollbar = m_horizontalScrollbar;
328
 
    bool oldHasVertical = hasVerticalScrollbar;
329
 
    bool oldHasHorizontal = hasHorizontalScrollbar;
 
343
    
 
344
    bool newHasHorizontalScrollbar = hasHorizontalScrollbar;
 
345
    bool newHasVerticalScrollbar = hasVerticalScrollbar;
 
346
   
330
347
    ScrollbarMode hScroll = m_horizontalScrollbarMode;
331
348
    ScrollbarMode vScroll = m_verticalScrollbarMode;
332
349
 
333
 
    const int scrollbarThickness = ScrollbarTheme::nativeTheme()->scrollbarThickness();
334
 
 
335
 
    for (int pass = 0; pass < 2; pass++) {
336
 
        bool scrollsVertically;
337
 
        bool scrollsHorizontally;
338
 
 
339
 
        if (!m_scrollbarsSuppressed && (hScroll == ScrollbarAuto || vScroll == ScrollbarAuto)) {
340
 
            // Do a layout if pending before checking if scrollbars are needed.
341
 
            if (hasVerticalScrollbar != oldHasVertical || hasHorizontalScrollbar != oldHasHorizontal)
342
 
                visibleContentsResized();
343
 
 
344
 
            scrollsVertically = (vScroll == ScrollbarAlwaysOn) || (vScroll == ScrollbarAuto && contentsHeight() > height());
345
 
            if (scrollsVertically)
346
 
                scrollsHorizontally = (hScroll == ScrollbarAlwaysOn) || (hScroll == ScrollbarAuto && contentsWidth() + scrollbarThickness > width());
347
 
            else {
348
 
                scrollsHorizontally = (hScroll == ScrollbarAlwaysOn) || (hScroll == ScrollbarAuto && contentsWidth() > width());
349
 
                if (scrollsHorizontally)
350
 
                    scrollsVertically = (vScroll == ScrollbarAlwaysOn) || (vScroll == ScrollbarAuto && contentsHeight() + scrollbarThickness > height());
 
350
    if (hScroll != ScrollbarAuto)
 
351
        newHasHorizontalScrollbar = (hScroll == ScrollbarAlwaysOn);
 
352
    if (vScroll != ScrollbarAuto)
 
353
        newHasVerticalScrollbar = (vScroll == ScrollbarAlwaysOn);
 
354
 
 
355
    if (m_scrollbarsSuppressed || (hScroll != ScrollbarAuto && vScroll != ScrollbarAuto)) {
 
356
        if (hasHorizontalScrollbar != newHasHorizontalScrollbar)
 
357
            setHasHorizontalScrollbar(newHasHorizontalScrollbar);
 
358
        if (hasVerticalScrollbar != newHasVerticalScrollbar)
 
359
            setHasVerticalScrollbar(newHasVerticalScrollbar);
 
360
    } else {
 
361
        bool sendContentResizedNotification = false;
 
362
        
 
363
        IntSize docSize = contentsSize();
 
364
        IntSize frameSize = frameRect().size();
 
365
 
 
366
        if (hScroll == ScrollbarAuto) {
 
367
            newHasHorizontalScrollbar = docSize.width() > visibleWidth();
 
368
            if (newHasHorizontalScrollbar && !m_updateScrollbarsPass && docSize.width() <= frameSize.width() && docSize.height() <= frameSize.height())
 
369
                newHasHorizontalScrollbar = false;
 
370
        }
 
371
        if (vScroll == ScrollbarAuto) {
 
372
            newHasVerticalScrollbar = docSize.height() > visibleHeight();
 
373
            if (newHasVerticalScrollbar && !m_updateScrollbarsPass && docSize.width() <= frameSize.width() && docSize.height() <= frameSize.height())
 
374
                newHasVerticalScrollbar = false;
 
375
        }
 
376
 
 
377
        // If we ever turn one scrollbar off, always turn the other one off too.  Never ever
 
378
        // try to both gain/lose a scrollbar in the same pass.
 
379
        if (!newHasHorizontalScrollbar && hasHorizontalScrollbar && vScroll != ScrollbarAlwaysOn)
 
380
            newHasVerticalScrollbar = false;
 
381
        if (!newHasVerticalScrollbar && hasVerticalScrollbar && hScroll != ScrollbarAlwaysOn)
 
382
            newHasHorizontalScrollbar = false;
 
383
 
 
384
        if (hasHorizontalScrollbar != newHasHorizontalScrollbar) {
 
385
            setHasHorizontalScrollbar(newHasHorizontalScrollbar);
 
386
            sendContentResizedNotification = true;
 
387
        }
 
388
 
 
389
        if (hasVerticalScrollbar != newHasVerticalScrollbar) {
 
390
            setHasVerticalScrollbar(newHasVerticalScrollbar);
 
391
            sendContentResizedNotification = true;
 
392
        }
 
393
 
 
394
        if (sendContentResizedNotification && m_updateScrollbarsPass < cMaxUpdateScrollbarsPass) {
 
395
            m_updateScrollbarsPass++;
 
396
            contentsResized();
 
397
            visibleContentsResized();
 
398
            IntSize newDocSize = contentsSize();
 
399
            if (newDocSize == docSize) {
 
400
                // The layout with the new scroll state had no impact on
 
401
                // the document's overall size, so updateScrollbars didn't get called.
 
402
                // Recur manually.
 
403
                updateScrollbars(desiredOffset);
351
404
            }
352
 
        } else {
353
 
            scrollsHorizontally = (hScroll == ScrollbarAuto) ? hasHorizontalScrollbar : (hScroll == ScrollbarAlwaysOn);
354
 
            scrollsVertically = (vScroll == ScrollbarAuto) ? hasVerticalScrollbar : (vScroll == ScrollbarAlwaysOn);
355
 
        }
356
 
        
357
 
        if (hasVerticalScrollbar != scrollsVertically) {
358
 
            setHasVerticalScrollbar(scrollsVertically);
359
 
            hasVerticalScrollbar = scrollsVertically;
360
 
        }
361
 
 
362
 
        if (hasHorizontalScrollbar != scrollsHorizontally) {
363
 
            setHasHorizontalScrollbar(scrollsHorizontally);
364
 
            hasHorizontalScrollbar = scrollsHorizontally;
 
405
            m_updateScrollbarsPass--;
365
406
        }
366
407
    }
367
408
    
368
 
    // Set up the range (and page step/line step).
 
409
    // Set up the range (and page step/line step), but only do this if we're not in a nested call (to avoid
 
410
    // doing it multiple times).
 
411
    if (m_updateScrollbarsPass)
 
412
        return;
 
413
 
 
414
    m_inUpdateScrollbars = true;
369
415
    IntSize maxScrollPosition(contentsWidth() - visibleWidth(), contentsHeight() - visibleHeight());
370
416
    IntSize scroll = desiredOffset.shrunkTo(maxScrollPosition);
371
417
    scroll.clampNegativeToZero();
372
418
 
373
 
    if (!platformHandleHorizontalAdjustment(scroll) && m_horizontalScrollbar) {
 
419
    if (m_horizontalScrollbar) {
374
420
        int clientWidth = visibleWidth();
375
421
        m_horizontalScrollbar->setEnabled(contentsWidth() > clientWidth);
376
422
        int pageStep = (clientWidth - cAmountToKeepWhenPaging);
394
440
            m_horizontalScrollbar->setSuppressInvalidation(false); 
395
441
    } 
396
442
 
397
 
    if (!platformHandleVerticalAdjustment(scroll) && m_verticalScrollbar) {
 
443
    if (m_verticalScrollbar) {
398
444
        int clientHeight = visibleHeight();
399
445
        m_verticalScrollbar->setEnabled(contentsHeight() > clientHeight);
400
446
        int pageStep = (clientHeight - cAmountToKeepWhenPaging);
418
464
            m_verticalScrollbar->setSuppressInvalidation(false);
419
465
    }
420
466
 
421
 
    if (oldHasVertical != (m_verticalScrollbar != 0) || oldHasHorizontal != (m_horizontalScrollbar != 0))
 
467
    if (hasHorizontalScrollbar != (m_horizontalScrollbar != 0) || hasVerticalScrollbar != (m_verticalScrollbar != 0)) {
422
468
        frameRectsChanged();
 
469
        updateScrollCorner();
 
470
    }
423
471
 
424
472
    // See if our offset has changed in a situation where we might not have scrollbars.
425
473
    // This can happen when editing a body with overflow:hidden and scrolling to reveal selection.
434
482
    m_inUpdateScrollbars = false;
435
483
}
436
484
 
437
 
const int panIconSizeLength = 20;
 
485
const int panIconSizeLength = 16;
438
486
 
439
487
void ScrollView::scrollContents(const IntSize& scrollDelta)
440
488
{
 
489
    if (!hostWindow())
 
490
        return;
 
491
 
441
492
    // Since scrolling is double buffered, we will be blitting the scroll view's intersection
442
493
    // with the clip rect every time to keep it smooth.
443
494
    IntRect clipRect = windowClipRect();
453
504
        IntPoint panIconDirtySquareLocation = IntPoint(m_panScrollIconPoint.x() - (panIconDirtySquareSizeLength / 2), m_panScrollIconPoint.y() - (panIconDirtySquareSizeLength / 2));
454
505
        IntRect panScrollIconDirtyRect = IntRect(panIconDirtySquareLocation , IntSize(panIconDirtySquareSizeLength, panIconDirtySquareSizeLength));
455
506
        panScrollIconDirtyRect.intersect(clipRect);
456
 
        hostWindow()->repaint(panScrollIconDirtyRect, true, true);
 
507
        hostWindow()->repaint(panScrollIconDirtyRect, true);
457
508
    }
458
509
 
459
510
    if (canBlitOnScroll() && !rootPreventsBlitting()) { // The main frame can just blit the WebView window
461
512
       hostWindow()->scroll(-scrollDelta, scrollViewRect, clipRect);
462
513
    } else { 
463
514
       // We need to go ahead and repaint the entire backing store.  Do it now before moving the
464
 
       // plugins.
 
515
       // windowed plugins.
465
516
       hostWindow()->repaint(updateRect, true, false, true); // Invalidate the backing store and repaint it synchronously
466
517
    }
467
518
 
503
554
{
504
555
    if (platformWidget())
505
556
        return platformContentsToScreen(rect);
 
557
    if (!hostWindow())
 
558
        return IntRect();
506
559
    return hostWindow()->windowToScreen(contentsToWindow(rect));
507
560
}
508
561
 
510
563
{
511
564
    if (platformWidget())
512
565
        return platformScreenToContents(point);
 
566
    if (!hostWindow())
 
567
        return IntPoint();
513
568
    return windowToContents(hostWindow()->screenToWindow(point));
514
569
}
515
570
 
528
583
        // If we went from n to 0 or from 0 to n and we're the outermost view,
529
584
        // we need to invalidate the windowResizerRect(), since it will now need to paint
530
585
        // differently.
531
 
        if (oldCount > 0 && m_scrollbarsAvoidingResizer == 0 ||
532
 
            oldCount == 0 && m_scrollbarsAvoidingResizer > 0)
 
586
        if ((oldCount > 0 && m_scrollbarsAvoidingResizer == 0) ||
 
587
            (oldCount == 0 && m_scrollbarsAvoidingResizer > 0))
533
588
            invalidateRect(windowResizerRect());
534
589
    }
535
590
}
542
597
    if (m_scrollbarsAvoidingResizer && parent())
543
598
        parent()->adjustScrollbarsAvoidingResizerCount(-m_scrollbarsAvoidingResizer);
544
599
 
 
600
#if PLATFORM(QT)
 
601
    if (m_widgetsPreventingBlitting && parent())
 
602
        parent()->adjustWidgetsPreventingBlittingCount(-m_widgetsPreventingBlitting);
 
603
 
 
604
    if (m_widgetsPreventingBlitting && parentView)
 
605
        parentView->adjustWidgetsPreventingBlittingCount(m_widgetsPreventingBlitting);
 
606
#endif
 
607
 
545
608
    Widget::setParent(parentView);
546
 
    
 
609
 
547
610
    if (m_scrollbarsAvoidingResizer && parent())
548
611
        parent()->adjustScrollbarsAvoidingResizerCount(m_scrollbarsAvoidingResizer);
549
612
}
564
627
            m_verticalScrollbar->invalidate();
565
628
 
566
629
        // Invalidate the scroll corner too on unsuppress.
567
 
        IntRect hCorner;
568
 
        if (m_horizontalScrollbar && width() - m_horizontalScrollbar->width() > 0) {
569
 
            hCorner = IntRect(m_horizontalScrollbar->width(),
570
 
                              height() - m_horizontalScrollbar->height(),
571
 
                              width() - m_horizontalScrollbar->width(),
572
 
                              m_horizontalScrollbar->height());
573
 
            invalidateRect(hCorner);
574
 
        }
575
 
 
576
 
        if (m_verticalScrollbar && height() - m_verticalScrollbar->height() > 0) {
577
 
            IntRect vCorner(width() - m_verticalScrollbar->width(),
578
 
                            m_verticalScrollbar->height(),
579
 
                            m_verticalScrollbar->width(),
580
 
                            height() - m_verticalScrollbar->height());
581
 
            if (vCorner != hCorner)
582
 
                invalidateRect(vCorner);
583
 
        }
 
630
        invalidateRect(scrollCornerRect());
584
631
    }
585
632
}
586
633
 
587
 
Scrollbar* ScrollView::scrollbarUnderMouse(const PlatformMouseEvent& mouseEvent)
 
634
Scrollbar* ScrollView::scrollbarAtPoint(const IntPoint& windowPoint)
588
635
{
589
636
    if (platformWidget())
590
637
        return 0;
591
638
 
592
 
    IntPoint viewPoint = convertFromContainingWindow(mouseEvent.pos());
 
639
    IntPoint viewPoint = convertFromContainingWindow(windowPoint);
593
640
    if (m_horizontalScrollbar && m_horizontalScrollbar->frameRect().contains(viewPoint))
594
641
        return m_horizontalScrollbar.get();
595
642
    if (m_verticalScrollbar && m_verticalScrollbar->frameRect().contains(viewPoint))
600
647
void ScrollView::wheelEvent(PlatformWheelEvent& e)
601
648
{
602
649
    // We don't allow mouse wheeling to happen in a ScrollView that has had its scrollbars explicitly disabled.
603
 
    if (!canHaveScrollbars() || platformWidget())
 
650
#if PLATFORM(WX)
 
651
    if (!canHaveScrollbars()) {
 
652
#else
 
653
    if (!canHaveScrollbars() || platformWidget()) {
 
654
#endif
604
655
        return;
 
656
    }
605
657
 
606
658
    // Determine how much we want to scroll.  If we can move at all, we will accept the event.
607
659
    IntSize maxScrollDelta = maximumScrollPosition() - scrollPosition();
612
664
        e.accept();
613
665
        float deltaX = e.deltaX();
614
666
        float deltaY = e.deltaY();
615
 
        if (e.granularity() == ScrollByLineWheelEvent) {
616
 
            deltaX *= cMouseWheelPixelsPerLineStep;
617
 
            deltaY *= cMouseWheelPixelsPerLineStep;
618
 
        } else if (e.granularity() == ScrollByPageWheelEvent) {
 
667
        if (e.granularity() == ScrollByPageWheelEvent) {
619
668
            ASSERT(deltaX == 0);
620
669
            bool negative = deltaY < 0;
621
670
            deltaY = max(0, visibleHeight() - cAmountToKeepWhenPaging);
651
700
    if (platformWidget())
652
701
        return;
653
702
 
654
 
    HashSet<Widget*>::const_iterator end = m_children.end();
655
 
    for (HashSet<Widget*>::const_iterator current = m_children.begin(); current != end; ++current)
 
703
    HashSet<RefPtr<Widget> >::const_iterator end = m_children.end();
 
704
    for (HashSet<RefPtr<Widget> >::const_iterator current = m_children.begin(); current != end; ++current)
656
705
        (*current)->frameRectsChanged();
657
706
}
658
707
 
659
708
void ScrollView::repaintContentRectangle(const IntRect& rect, bool now)
660
709
{
661
 
    if (rect.isEmpty())
 
710
    IntRect visibleContent = visibleContentRect();
 
711
    visibleContent.intersect(rect);
 
712
    if (visibleContent.isEmpty())
662
713
        return;
663
714
 
664
715
    if (platformWidget()) {
665
 
        platformRepaintContentRectangle(rect, now);
 
716
        platformRepaintContentRectangle(visibleContent, now);
666
717
        return;
667
718
    }
668
719
 
669
 
    hostWindow()->repaint(contentsToWindow(rect), true, now);
 
720
    if (hostWindow())
 
721
        hostWindow()->repaint(contentsToWindow(visibleContent), true, now);
 
722
}
 
723
 
 
724
IntRect ScrollView::scrollCornerRect() const
 
725
{
 
726
    IntRect cornerRect;
 
727
    
 
728
    if (m_horizontalScrollbar && width() - m_horizontalScrollbar->width() > 0) {
 
729
        cornerRect.unite(IntRect(m_horizontalScrollbar->width(),
 
730
                                 height() - m_horizontalScrollbar->height(),
 
731
                                 width() - m_horizontalScrollbar->width(),
 
732
                                 m_horizontalScrollbar->height()));
 
733
    }
 
734
 
 
735
    if (m_verticalScrollbar && height() - m_verticalScrollbar->height() > 0) {
 
736
        cornerRect.unite(IntRect(width() - m_verticalScrollbar->width(),
 
737
                                 m_verticalScrollbar->height(),
 
738
                                 m_verticalScrollbar->width(),
 
739
                                 height() - m_verticalScrollbar->height()));
 
740
    }
 
741
    
 
742
    return cornerRect;
 
743
}
 
744
 
 
745
void ScrollView::updateScrollCorner()
 
746
{
 
747
}
 
748
 
 
749
void ScrollView::paintScrollCorner(GraphicsContext* context, const IntRect& cornerRect)
 
750
{
 
751
    ScrollbarTheme::nativeTheme()->paintScrollCorner(this, context, cornerRect);
670
752
}
671
753
 
672
754
void ScrollView::paint(GraphicsContext* context, const IntRect& rect)
708
790
        if (m_verticalScrollbar)
709
791
            m_verticalScrollbar->paint(context, scrollViewDirtyRect);
710
792
 
711
 
        IntRect hCorner;
712
 
        if (m_horizontalScrollbar && width() - m_horizontalScrollbar->width() > 0) {
713
 
            hCorner = IntRect(m_horizontalScrollbar->width(),
714
 
                              height() - m_horizontalScrollbar->height(),
715
 
                              width() - m_horizontalScrollbar->width(),
716
 
                              m_horizontalScrollbar->height());
717
 
            if (hCorner.intersects(scrollViewDirtyRect))
718
 
                ScrollbarTheme::nativeTheme()->paintScrollCorner(this, context, hCorner);
719
 
        }
720
 
 
721
 
        if (m_verticalScrollbar && height() - m_verticalScrollbar->height() > 0) {
722
 
            IntRect vCorner(width() - m_verticalScrollbar->width(),
723
 
                            m_verticalScrollbar->height(),
724
 
                            m_verticalScrollbar->width(),
725
 
                            height() - m_verticalScrollbar->height());
726
 
            if (vCorner != hCorner && vCorner.intersects(scrollViewDirtyRect))
727
 
                ScrollbarTheme::nativeTheme()->paintScrollCorner(this, context, vCorner);
728
 
        }
729
 
 
 
793
        paintScrollCorner(context, scrollCornerRect());
730
794
        context->restore();
731
795
    }
732
796
 
737
801
    }
738
802
}
739
803
 
 
804
bool ScrollView::isPointInScrollbarCorner(const IntPoint& windowPoint)
 
805
{
 
806
    if (!scrollbarCornerPresent())
 
807
        return false;
 
808
 
 
809
    IntPoint viewPoint = convertFromContainingWindow(windowPoint);
 
810
 
 
811
    if (m_horizontalScrollbar) {
 
812
        int horizontalScrollbarYMin = m_horizontalScrollbar->frameRect().y();
 
813
        int horizontalScrollbarYMax = m_horizontalScrollbar->frameRect().y() + m_horizontalScrollbar->frameRect().height();
 
814
        int horizontalScrollbarXMin = m_horizontalScrollbar->frameRect().x() + m_horizontalScrollbar->frameRect().width();
 
815
 
 
816
        return viewPoint.y() > horizontalScrollbarYMin && viewPoint.y() < horizontalScrollbarYMax && viewPoint.x() > horizontalScrollbarXMin;
 
817
    }
 
818
 
 
819
    int verticalScrollbarXMin = m_verticalScrollbar->frameRect().x();
 
820
    int verticalScrollbarXMax = m_verticalScrollbar->frameRect().x() + m_verticalScrollbar->frameRect().width();
 
821
    int verticalScrollbarYMin = m_verticalScrollbar->frameRect().y() + m_verticalScrollbar->frameRect().height();
 
822
    
 
823
    return viewPoint.x() > verticalScrollbarXMin && viewPoint.x() < verticalScrollbarXMax && viewPoint.y() > verticalScrollbarYMin;
 
824
}
 
825
 
740
826
bool ScrollView::scrollbarCornerPresent() const
741
827
{
742
828
    return (m_horizontalScrollbar && width() - m_horizontalScrollbar->width() > 0) ||
743
829
           (m_verticalScrollbar && height() - m_verticalScrollbar->height() > 0);
744
830
}
745
831
 
 
832
IntRect ScrollView::convertFromScrollbarToContainingView(const Scrollbar* scrollbar, const IntRect& localRect) const
 
833
{
 
834
    // Scrollbars won't be transformed within us
 
835
    IntRect newRect = localRect;
 
836
    newRect.move(scrollbar->x(), scrollbar->y());
 
837
    return newRect;
 
838
}
 
839
 
 
840
IntRect ScrollView::convertFromContainingViewToScrollbar(const Scrollbar* scrollbar, const IntRect& parentRect) const
 
841
{
 
842
    IntRect newRect = parentRect;
 
843
    // Scrollbars won't be transformed within us
 
844
    newRect.move(-scrollbar->x(), -scrollbar->y());
 
845
    return newRect;
 
846
}
 
847
 
 
848
// FIXME: test these on windows
 
849
IntPoint ScrollView::convertFromScrollbarToContainingView(const Scrollbar* scrollbar, const IntPoint& localPoint) const
 
850
{
 
851
    // Scrollbars won't be transformed within us
 
852
    IntPoint newPoint = localPoint;
 
853
    newPoint.move(scrollbar->x(), scrollbar->y());
 
854
    return newPoint;
 
855
}
 
856
 
 
857
IntPoint ScrollView::convertFromContainingViewToScrollbar(const Scrollbar* scrollbar, const IntPoint& parentPoint) const
 
858
{
 
859
    IntPoint newPoint = parentPoint;
 
860
    // Scrollbars won't be transformed within us
 
861
    newPoint.move(-scrollbar->x(), -scrollbar->y());
 
862
    return newPoint;
 
863
}
 
864
 
746
865
void ScrollView::setParentVisible(bool visible)
747
866
{
748
867
    if (isParentVisible() == visible)
753
872
    if (!isSelfVisible())
754
873
        return;
755
874
        
756
 
    HashSet<Widget*>::iterator end = m_children.end();
757
 
    for (HashSet<Widget*>::iterator it = m_children.begin(); it != end; ++it)
 
875
    HashSet<RefPtr<Widget> >::iterator end = m_children.end();
 
876
    for (HashSet<RefPtr<Widget> >::iterator it = m_children.begin(); it != end; ++it)
758
877
        (*it)->setParentVisible(visible);
759
878
}
760
879
 
763
882
    if (!isSelfVisible()) {
764
883
        setSelfVisible(true);
765
884
        if (isParentVisible()) {
766
 
            HashSet<Widget*>::iterator end = m_children.end();
767
 
            for (HashSet<Widget*>::iterator it = m_children.begin(); it != end; ++it)
 
885
            HashSet<RefPtr<Widget> >::iterator end = m_children.end();
 
886
            for (HashSet<RefPtr<Widget> >::iterator it = m_children.begin(); it != end; ++it)
768
887
                (*it)->setParentVisible(true);
769
888
        }
770
889
    }
776
895
{
777
896
    if (isSelfVisible()) {
778
897
        if (isParentVisible()) {
779
 
            HashSet<Widget*>::iterator end = m_children.end();
780
 
            for (HashSet<Widget*>::iterator it = m_children.begin(); it != end; ++it)
 
898
            HashSet<RefPtr<Widget> >::iterator end = m_children.end();
 
899
            for (HashSet<RefPtr<Widget> >::iterator it = m_children.begin(); it != end; ++it)
781
900
                (*it)->setParentVisible(false);
782
901
        }
783
902
        setSelfVisible(false);
802
921
 
803
922
void ScrollView::addPanScrollIcon(const IntPoint& iconPosition)
804
923
{
 
924
    if (!hostWindow())
 
925
        return;
805
926
    m_drawPanScrollIcon = true;    
806
927
    m_panScrollIconPoint = IntPoint(iconPosition.x() - panIconSizeLength / 2 , iconPosition.y() - panIconSizeLength / 2) ;
807
928
    hostWindow()->repaint(IntRect(m_panScrollIconPoint, IntSize(panIconSizeLength,panIconSizeLength)), true, true);    
809
930
 
810
931
void ScrollView::removePanScrollIcon()
811
932
{
 
933
    if (!hostWindow())
 
934
        return;
812
935
    m_drawPanScrollIcon = false; 
813
936
    hostWindow()->repaint(IntRect(m_panScrollIconPoint, IntSize(panIconSizeLength, panIconSizeLength)), true, true);
814
937
}
815
938
 
816
939
#if !PLATFORM(WX) && !PLATFORM(GTK) && !PLATFORM(QT)
 
940
 
817
941
void ScrollView::platformInit()
818
942
{
819
943
}
821
945
void ScrollView::platformDestroy()
822
946
{
823
947
}
 
948
 
824
949
#endif
825
950
 
826
951
#if !PLATFORM(WX) && !PLATFORM(GTK) && !PLATFORM(QT) && !PLATFORM(MAC)
 
952
 
827
953
void ScrollView::platformAddChild(Widget*)
828
954
{
829
955
}
831
957
void ScrollView::platformRemoveChild(Widget*)
832
958
{
833
959
}
 
960
 
834
961
#endif
835
962
 
836
963
#if !PLATFORM(MAC)
 
964
 
837
965
void ScrollView::platformSetScrollbarsSuppressed(bool repaintOnUnsuppress)
838
966
{
839
967
}
 
968
 
840
969
#endif
841
970
 
842
971
#if !PLATFORM(MAC) && !PLATFORM(WX)
 
972
 
843
973
void ScrollView::platformSetScrollbarModes()
844
974
{
845
975
}
846
976
 
847
977
void ScrollView::platformScrollbarModes(ScrollbarMode& horizontal, ScrollbarMode& vertical) const
848
978
{
 
979
    horizontal = ScrollbarAuto;
 
980
    vertical = ScrollbarAuto;
849
981
}
850
982
 
851
983
void ScrollView::platformSetCanBlitOnScroll(bool)
898
1030
{
899
1031
    return false;
900
1032
}
901
 
#endif
902
 
 
903
 
#if !PLATFORM(GTK)
904
 
bool ScrollView::platformHandleHorizontalAdjustment(const IntSize&)
905
 
{
906
 
    return false;
907
 
}
908
 
 
909
 
bool ScrollView::platformHandleVerticalAdjustment(const IntSize&)
910
 
{
911
 
    return false;
912
 
}
913
 
 
914
 
bool ScrollView::platformHasHorizontalAdjustment() const
915
 
{
916
 
    return false;
917
 
}
918
 
 
919
 
bool ScrollView::platformHasVerticalAdjustment() const
920
 
{
921
 
    return false;
922
 
}
923
1033
 
924
1034
#endif
925
1035