summaryrefslogtreecommitdiffstats
path: root/webkit/port/platform/ScrollViewWin.cpp
blob: 67610733465ba530e14eb0890653dd541c9fbf71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
/*
 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include "config.h"
#include "ScrollView.h"

#include "Chrome.h"
#include "ChromeClient.h"
#include "FloatRect.h"
#include "FocusController.h"
#include "Frame.h"
#include "FrameView.h"
#include "GraphicsContext.h"
#include "IntRect.h"
#include "NotImplemented.h"
#include "Page.h"
#include "PlatformScrollBar.h"
#include "PlatformMouseEvent.h"
#include "PlatformWheelEvent.h"
#include "Range.h"
#include "RenderTheme.h"
#include "ScrollBar.h"
#include "SkiaUtils.h"
#include "WidgetClientWin.h"
#include <algorithm>
#include <wtf/Assertions.h>
#include <wtf/HashSet.h>

#undef LOG
#include "base/gfx/platform_canvas_win.h"
#include "webkit/glue/webframe_impl.h"
#include "webkit/glue/webview_impl.h"

using namespace std;

namespace WebCore {

class ScrollView::ScrollViewPrivate : public ScrollbarClient {
public:
    ScrollViewPrivate(ScrollView* view)
        : m_view(view)
        , m_hasStaticBackground(false)
        , m_scrollbarsSuppressed(false)
        , m_inUpdateScrollbars(false)
        , m_scrollbarsAvoidingResizer(0)
        , m_vScrollbarMode(ScrollbarAuto)
        , m_hScrollbarMode(ScrollbarAuto)
        , m_visible(false)
        , m_attachedToWindow(false)
    {
    }

    ~ScrollViewPrivate()
    {
        setHasHorizontalScrollbar(false);
        setHasVerticalScrollbar(false);
    }

    void setHasHorizontalScrollbar(bool hasBar);
    void setHasVerticalScrollbar(bool hasBar);

    virtual void valueChanged(Scrollbar*);
    virtual IntRect windowClipRect() const;
    virtual bool isActive() const;

    void scrollBackingStore(const IntSize& scrollDelta);

    // Get the vector containing the result from the FindInPage operation.
    const Vector<RefPtr<Range> >* getTickmarks() const;

    // Retrieves the index of the active tickmark for a given frame.  If the
    // frame does not have an active tickmark (for example if the active
    // tickmark resides in another frame) this function returns kNoTickmark.
    size_t ScrollView::ScrollViewPrivate::getActiveTickmarkIndex() const;

    // This is a helper function for accessing the bitmaps that have been cached
    // in the renderer.
    const SkBitmap* GetPreloadedBitmapFromRenderer(int resource_id) const;

    // Highlight the matches found during FindInPage operation.
    void highlightMatches(GraphicsContext* context) const;

    // Highlights the node selected in the DOM inspector.
    void highlightInspectedNode(GraphicsContext* context, Frame* frame) const;
    
    // Highlight a certain Range on the page.
    void highlightRange(HDC hdc, HDC mem_dc, RefPtr<Range> range) const;

    void setAllowsScrolling(bool);
    bool allowsScrolling() const;

    ScrollView* m_view;
    IntSize m_scrollOffset;
    IntSize m_contentsSize;
    bool m_hasStaticBackground;
    bool m_scrollbarsSuppressed;
    bool m_inUpdateScrollbars;
    int m_scrollbarsAvoidingResizer;
    ScrollbarMode m_vScrollbarMode;
    ScrollbarMode m_hScrollbarMode;
    RefPtr<PlatformScrollbar> m_vBar;
    RefPtr<PlatformScrollbar> m_hBar;
    HRGN m_dirtyRegion;
    HashSet<Widget*> m_children;
    bool m_visible;
    bool m_attachedToWindow;
};

void ScrollView::ScrollViewPrivate::setHasHorizontalScrollbar(bool hasBar)
{
    if (Scrollbar::hasPlatformScrollbars()) {
        if (hasBar && !m_hBar) {
            m_hBar = new PlatformScrollbar(this, HorizontalScrollbar, RegularScrollbar);
            m_view->addChild(m_hBar.get());
        } else if (!hasBar && m_hBar) {
            m_view->removeChild(m_hBar.get());
            m_hBar = 0;
        }
    }
}

void ScrollView::ScrollViewPrivate::setHasVerticalScrollbar(bool hasBar)
{
    if (Scrollbar::hasPlatformScrollbars()) {
        if (hasBar && !m_vBar) {
            m_vBar = new PlatformScrollbar(this, VerticalScrollbar, RegularScrollbar);
            m_view->addChild(m_vBar.get());
        } else if (!hasBar && m_vBar) {
            m_view->removeChild(m_vBar.get());
            m_vBar = 0;
        }
    }
}

void ScrollView::ScrollViewPrivate::valueChanged(Scrollbar* bar)
{
    // Figure out if we really moved.
    IntSize newOffset = m_scrollOffset;
    if (bar) {
        if (bar == m_hBar)
            newOffset.setWidth(bar->value());
        else if (bar == m_vBar)
            newOffset.setHeight(bar->value());
    }
    IntSize scrollDelta = newOffset - m_scrollOffset;
    if (scrollDelta == IntSize())
        return;
    m_scrollOffset = newOffset;

    if (m_scrollbarsSuppressed)
        return;

    scrollBackingStore(scrollDelta);

    if (Frame* frame = static_cast<FrameView*>(m_view)->frame()) {
        frame->sendScrollEvent();

        // Inform the delegate that the scroll position has changed.
        WidgetClientWin* client =
                static_cast<WidgetClientWin*>(m_view->client());
        if (client)
            client->onScrollPositionChanged(m_view);
    }
}

void ScrollView::ScrollViewPrivate::scrollBackingStore(const IntSize& scrollDelta)
{
    // Since scrolling is double buffered, we will be blitting the scroll view's intersection
    // with the clip rect every time to keep it smooth.

    IntRect clipRect = m_view->windowClipRect();
    IntRect scrollViewRect = m_view->convertToContainingWindow(IntRect(0, 0, m_view->visibleWidth(), m_view->visibleHeight()));

    // Negative when our frame is smaller than the min scrollbar width.
    if (scrollViewRect.width() < 0)
        scrollViewRect.setWidth(0);
    if (scrollViewRect.height() < 0)
        scrollViewRect.setHeight(0);

    if (!m_hasStaticBackground) { // The main frame can just blit the WebView window
        // FIXME: Find a way to blit subframes without blitting overlapping content
        m_view->scrollBackingStore(-scrollDelta.width(), -scrollDelta.height(), scrollViewRect, clipRect);
    } else {
        IntRect updateRect = clipRect;
        updateRect.intersect(scrollViewRect);

         // We need to go ahead and repaint the entire backing store.  Do it now before moving the
         // plugins.
        m_view->addToDirtyRegion(updateRect);
        m_view->updateBackingStore();
    }

    // This call will move child HWNDs (plugins) and invalidate them as well.
    m_view->geometryChanged();
}

void ScrollView::ScrollViewPrivate::setAllowsScrolling(bool flag)
{
    if (flag && m_vScrollbarMode == ScrollbarAlwaysOff)
        m_vScrollbarMode = ScrollbarAuto;
    else if (!flag)
        m_vScrollbarMode = ScrollbarAlwaysOff;

    if (flag && m_hScrollbarMode == ScrollbarAlwaysOff)
        m_hScrollbarMode = ScrollbarAuto;
    else if (!flag)
        m_hScrollbarMode = ScrollbarAlwaysOff;

    m_view->updateScrollbars(m_scrollOffset);
}

bool ScrollView::ScrollViewPrivate::allowsScrolling() const
{
    // Return YES if either horizontal or vertical scrolling is allowed.
    return m_hScrollbarMode != ScrollbarAlwaysOff || m_vScrollbarMode != ScrollbarAlwaysOff;
}

IntRect ScrollView::ScrollViewPrivate::windowClipRect() const
{
    // FrameView::windowClipRect() will exclude the scrollbars, but here we
    // want to include them, so we are forced to cast to FrameView in order to
    // call the non-virtual version of windowClipRect :-(
    //
    // The non-frame case exists to support FramelessScrollView.

    const FrameView* frameView = static_cast<const FrameView*>(m_view);
    if (frameView->frame())
        return frameView->windowClipRect(false);

    return m_view->windowClipRect();
}

bool ScrollView::ScrollViewPrivate::isActive() const
{
    Page* page = static_cast<const FrameView*>(m_view)->frame()->page();
    return page && page->focusController()->isActive();
}

const Vector<RefPtr<Range> >* ScrollView::ScrollViewPrivate::getTickmarks() const
{
    FrameView* view = static_cast<FrameView*>(m_view);
    ASSERT(view);
    Frame* frame = view->frame();

    if (!frame)
        return NULL;  // NOTE: Frame can be null for dropdown boxes.

    WidgetClientWin* c = static_cast<WidgetClientWin*>(m_view->client());
    ASSERT(c);
    return c->getTickmarks(view->frame());
}

size_t ScrollView::ScrollViewPrivate::getActiveTickmarkIndex() const
{
  FrameView* view = static_cast<FrameView*>(m_view);
  ASSERT(view);
  Frame* frame = view->frame();

  // NOTE: Frame can be null for dropdown boxes.
  if (!frame)
    return WidgetClientWin::kNoTickmark;

  WidgetClientWin* c = static_cast<WidgetClientWin*>(m_view->client());
  ASSERT(c);
  return c->getActiveTickmarkIndex(view->frame());
}

const SkBitmap* ScrollView::ScrollViewPrivate::GetPreloadedBitmapFromRenderer(
        int resource_id) const
{
    WidgetClientWin* c = static_cast<WidgetClientWin*>(m_view->client());
    if (!c)
      return NULL;

    return c->getPreloadedResourceBitmap(resource_id);
}

void ScrollView::ScrollViewPrivate::highlightMatches(
    GraphicsContext* context) const
{
    if (context->paintingDisabled())
        return;

    const Vector<RefPtr<Range> >* tickmarks = getTickmarks();
    if (!tickmarks || tickmarks->isEmpty())
        return;

    context->save();
    context->translate(m_view->x(), m_view->y());

    // NOTE: We tolerate the platformContext() call here because the scrollbars
    // will not be serialized, i.e. composition is done in the renderer and
    // never in the browser.
    // Prepare for drawing the arrows along the scroll bar.
    gfx::PlatformCanvasWin* canvas = PlatformContextToPlatformContextSkia(
        context->platformContext())->canvas();

    int horz_start = 0;
    int horz_end   = m_view->width();
    int vert_start = 0;
    int vert_end   = m_view->height();

    if (m_vBar) {
        // Account for the amount of scrolling on the vertical scroll bar.
        vert_start += m_scrollOffset.height();
        vert_end   += m_scrollOffset.height();
        // Don't draw atop the vertical scrollbar.
        horz_end   -= PlatformScrollbar::verticalScrollbarWidth() + 1;
    }

    if (m_hBar) {
        // Account for the amount of scrolling on the horizontal scroll bar.
        horz_start += m_scrollOffset.width();
        horz_end   += m_scrollOffset.width();
        // Don't draw atop the horizontal scrollbar.
        vert_end   -= PlatformScrollbar::horizontalScrollbarHeight() + 1;
    }

    HDC hdc = context->getWindowsContext();

    // We create a memory DC, copy the bits we want to highlight to the DC and
    // then MERGE_COPY pieces of it back with a yellow brush selected (which
    // gives them yellow highlighting).
    HDC mem_dc = CreateCompatibleDC(hdc);
    HBITMAP mem_bmp = CreateCompatibleBitmap(hdc, m_view->width(),
                                                  m_view->height());
    HGDIOBJ old_bmp = SelectObject(mem_dc, mem_bmp);

    // Now create a brush for hit highlighting. This is needed for the MERGECOPY
    // to paint a yellow highlight onto the matches found. For more details, see
    // the documentation for BitBlt.
    static const COLORREF kFillColor = RGB(255, 250, 150);  // Light yellow.
    HGDIOBJ inactive_brush = CreateSolidBrush(kFillColor);
    static const COLORREF kFillColorActive = RGB(255, 150, 50);  // Orange.
    HGDIOBJ active_brush = CreateSolidBrush(kFillColorActive);
    HGDIOBJ old_brush = SelectObject(hdc, inactive_brush);

    // Keep a copy of what's on screen, so we can MERGECOPY it back later for
    // the purpose of highlighting the text.
    BitBlt(mem_dc, 0, 0, m_view->width(), m_view->height(),
           hdc, 0, 0, SRCCOPY);

    const size_t active_tickmark = getActiveTickmarkIndex();
    for (Vector<RefPtr<Range> >::const_iterator i = tickmarks->begin();
         i != tickmarks->end(); ++i) {
        const RefPtr<Range> range = (*i);
        const IntRect& bounds = range->boundingBox();
        // To highlight the word, we check if the rectangle boundary is within
        // the bounds vertically as well as horizontally.
        if (bounds.bottomRight().y() > vert_start &&
            bounds.topLeft().y() < vert_end &&
            bounds.bottomRight().x() > horz_start &&
            bounds.topLeft().x() < horz_end &&
            WebFrameImpl::RangeShouldBeHighlighted(range.get())) {
            // We highlight the active tick-mark with a green color instead
            // of the normal yellow color.
            SelectObject(hdc, ((i - tickmarks->begin()) == active_tickmark) ?
                active_brush : inactive_brush);
            highlightRange(hdc, mem_dc, range);
        }
    }

    SelectObject(mem_dc, old_brush);
    DeleteObject(active_brush);
    DeleteObject(inactive_brush);

    SelectObject(mem_dc, old_bmp);
    DeleteObject(mem_bmp);

    DeleteDC(mem_dc);

    context->releaseWindowsContext(hdc);
    context->restore();
}

// TODO(ojan): http://b/1143983 make this work for inline elements as they can
// wrap (use highlightRange instead?)
void ScrollView::ScrollViewPrivate::highlightInspectedNode(
    GraphicsContext* context, Frame* frame) const
{
    WebViewImpl* c = static_cast<WebViewImpl*>(m_view->client());
    const WebCore::Node* inspected_node = c->getInspectedNode(frame);

    if (!inspected_node)
      return;

    SkPaint paint;
    paint.setARGB(122, 255, 225, 0); // Yellow

    // TODO(ojan): http://b/1143991 Once we sync a Skia version that supports 
    // it, use SkPorterDuff::kScreenMode and remove the transparency.
    // Then port highlightMatches/highlightRanges to use this as well.
    // Although, perhaps the web inspector really should be using
    // an alpha overlay? It's less pretty, but more clear what node
    // is being overlayed. In this case, the TODO is to make
    // highlightMatches/Ranges use Skia and to leave this as is.
    //
    // paint.setPorterDuffXfermode(SkPorterDuff::kScreenMode);

    // TODO(ojan): http://b/1143975 Draw the padding/border/margin boxes in
    // different colors.
    SkRect destRect;
    WebCoreRectToSkiaRect(inspected_node->getRect(), &destRect);

    PlatformContextSkia* skia = PlatformContextToPlatformContextSkia(
        context->platformContext());
    skia->paintSkPaint(destRect, paint);
}

void ScrollView::ScrollViewPrivate::highlightRange(HDC hdc, HDC mem_dc,
                                                   RefPtr<Range> range) const {
    // We need to figure out whether the match that we want to
    // highlight is on a single line or on multiple lines.
    IntRect start = VisiblePosition(range->startPosition()).caretRect();
    IntRect end = VisiblePosition(range->endPosition()).caretRect();
    IntRect bounds = range->boundingBox();

    // Multi-line bounds have different y pos for start and end.
    if (start.y() == end.y()) {
        int x = bounds.topLeft().x() - m_scrollOffset.width();
        int y = bounds.topLeft().y() - m_scrollOffset.height();
        int w = bounds.bottomRight().x() - bounds.topLeft().x() + 1;
        int h = bounds.bottomRight().y() - bounds.topLeft().y() + 1;

        // MERGECOPY the relevant bits back, creating a highlight.
        BitBlt(hdc, x, y, w, h, mem_dc, x, y, MERGECOPY);
    } else {
        // Multi line bounds, for example, when we need to highlight
        // all the numbers (and only the numbers) in this block of
        // text:
        //
        // xxxxxxxxxxxxxxxx11111111
        // 222222222222222222222222
        // 222222222222222222222222
        // 333333333333333xxxxxxxxx
        //
        // In this case, the bounding box will contain all the text,
        // (including the exes (x)). We highlight in three steps.
        // First we highlight the segment containing the ones (1)
        // above. Then the whole middle section is highlighted, or the
        // twos (2), and finally the remaining segment consisting of
        // the threes (3) is highlighted.

        const int row_height = start.height();
        int x = 0, y = 0, w = 0, h = 0;

        // The start and end caret can be outside the bounding box, for leading
        // and trailing whitespace and we should not highlight those.
        if (start.intersects(bounds)) {
            // Highlight the first segment.
            x = start.x() - m_scrollOffset.width();
            y = start.y() - m_scrollOffset.height();
            w = bounds.topRight().x() - start.x() + 1;
            h = row_height;

            BitBlt(hdc, x, y, w, h, mem_dc, x, y, MERGECOPY);
        }

        // Figure out how large the middle section is.
        int rows_between = (end.y() - start.y()) / row_height - 1;

        if (rows_between > 0) {
            // Highlight the middle segment.
            x = bounds.x() - m_scrollOffset.width();
            y = bounds.y() - m_scrollOffset.height() + row_height;
            w = bounds.width();
            h = rows_between * row_height;

            BitBlt(hdc, x, y, w, h, mem_dc, x, y, MERGECOPY);
        }

        // The end caret might not intersect the bounding box, for example
        // when highlighting the last letter of a line that wraps. In that
        // case the end caret is set to the beginning of the next line, and
        // since it doesn't intersect with the bounding box we don't need to
        // highlight.
        if (end.intersects(bounds)) {
            // Highlight the remaining segment.
            x = bounds.bottomLeft().x() - m_scrollOffset.width();
            y = bounds.bottomLeft().y() - m_scrollOffset.height() -
                row_height + 1;
            w = end.x() - bounds.bottomLeft().x();
            h = row_height;

            BitBlt(hdc, x, y, w, h, mem_dc, x, y, MERGECOPY);
        }
    }
}

ScrollView::ScrollView()
{
    m_data = new ScrollViewPrivate(this);
}

ScrollView::~ScrollView()
{
    delete m_data;
}

void ScrollView::updateContents(const IntRect& rect, bool now)
{
    if (rect.isEmpty())
        return;

    IntRect containingWindowRect = contentsToWindow(rect);

    if (containingWindowRect.x() < 0)
        containingWindowRect.setX(0);
    if (containingWindowRect.y() < 0)
        containingWindowRect.setY(0);

    // Cache the dirty spot.
    addToDirtyRegion(containingWindowRect);

    // since painting always happens asynchronously, we don't have a way to
    // honor the "now" parameter.  it is unclear if it matters.
    if (now) {
      // TODO(iyengar): Should we force a layout to occur here?
      geometryChanged();
    }
}

void ScrollView::update()
{
    // TODO(iyengar): Should we force a layout to occur here?
    geometryChanged();
}

int ScrollView::visibleWidth() const
{
    return width() - (m_data->m_vBar ? m_data->m_vBar->width() : 0);
}

int ScrollView::visibleHeight() const
{
    return height() - (m_data->m_hBar ? m_data->m_hBar->height() : 0);
}

FloatRect ScrollView::visibleContentRect() const
{
    return FloatRect(contentsX(), contentsY(), visibleWidth(), visibleHeight());
}

FloatRect ScrollView::visibleContentRectConsideringExternalScrollers() const
{
    // external scrollers not supported for now
    return visibleContentRect();
}

void ScrollView::setContentsPos(int newX, int newY)
{
    int dx = newX - contentsX();
    int dy = newY - contentsY();
    scrollBy(dx, dy);
}

void ScrollView::resizeContents(int w, int h)
{
    IntSize newContentsSize(w, h);
    if (m_data->m_contentsSize != newContentsSize) {
        m_data->m_contentsSize = newContentsSize;
        updateScrollbars(m_data->m_scrollOffset);
    }
}

void ScrollView::setFrameGeometry(const IntRect& newGeometry)
{
    IntRect normalizedNewGeometry = newGeometry;

    // Webkit sometimes attempts to set negative sizes due to
    // sloppy calculations of width with margins and such.
    // (RenderPart:updateWidgetPosition is one example.)
    // Safeguard against this and prevent negative heights/widths.
    if (normalizedNewGeometry.width() < 0)
      normalizedNewGeometry.setWidth(0);
    if (normalizedNewGeometry.height() < 0)
      normalizedNewGeometry.setHeight(0);

    IntRect oldGeometry = frameGeometry();
    Widget::setFrameGeometry(normalizedNewGeometry);

    if (normalizedNewGeometry == oldGeometry)
        return;

    if (normalizedNewGeometry.width() != oldGeometry.width() ||
        normalizedNewGeometry.height() != oldGeometry.height()) {
        updateScrollbars(m_data->m_scrollOffset);

        // when used to display a popup menu, we do not have a frame
        FrameView* frameView = static_cast<FrameView*>(this);
        if (frameView->frame())
            frameView->setNeedsLayout();
    }

    geometryChanged();
}

int ScrollView::contentsX() const
{
    return scrollOffset().width();
}

int ScrollView::contentsY() const
{
    return scrollOffset().height();
}

int ScrollView::contentsWidth() const
{
    return m_data->m_contentsSize.width();
}

int ScrollView::contentsHeight() const
{
    return m_data->m_contentsSize.height();
}

IntPoint ScrollView::windowToContents(const IntPoint& windowPoint) const
{
    IntPoint viewPoint = convertFromContainingWindow(windowPoint);
    return viewPoint + scrollOffset();
}

IntPoint ScrollView::contentsToWindow(const IntPoint& contentsPoint) const
{
    IntPoint viewPoint = contentsPoint - scrollOffset();
    return convertToContainingWindow(viewPoint);
}

IntPoint ScrollView::convertChildToSelf(const Widget* child, const IntPoint& point) const
{
    IntPoint newPoint = point;
    if (child != m_data->m_hBar && child != m_data->m_vBar)
        newPoint = point - scrollOffset();
    return Widget::convertChildToSelf(child, newPoint);
}

IntPoint ScrollView::convertSelfToChild(const Widget* child, const IntPoint& point) const
{
    IntPoint newPoint = point;
    if (child != m_data->m_hBar && child != m_data->m_vBar)
        newPoint = point + scrollOffset();
    return Widget::convertSelfToChild(child, newPoint);
}

IntSize ScrollView::scrollOffset() const
{
    return m_data->m_scrollOffset;
}

IntSize ScrollView::maximumScroll() const
{
    // We should not check whether scrolling is allowed for this view before calculating
    // the maximumScroll. Please refer to http://b/issue?id=1164704, where in scrolling
    // would not work on a scrollview created with scrollbars disabled. The current
    // behavior mirrors Safari's webkit implementation. Firefox also behaves similarly.
    IntSize delta = (m_data->m_contentsSize - IntSize(visibleWidth(), visibleHeight())) - scrollOffset();
    delta.clampNegativeToZero();
    return delta;
}

void ScrollView::scrollBy(int dx, int dy)
{
    IntSize scrollOffset = m_data->m_scrollOffset;
    IntSize newScrollOffset = scrollOffset + IntSize(dx, dy).shrunkTo(maximumScroll());
    newScrollOffset.clampNegativeToZero();

    if (newScrollOffset == scrollOffset)
        return;

    updateScrollbars(newScrollOffset);
}

void ScrollView::scrollRectIntoViewRecursively(const IntRect& r)
{
    IntPoint p(max(0, r.x()), max(0, r.y()));
    ScrollView* view = this;
    while (view) {
        view->setContentsPos(p.x(), p.y());
        p.move(view->x() - view->scrollOffset().width(), view->y() - view->scrollOffset().height());
        view = static_cast<ScrollView*>(view->parent());
    }
}

WebCore::ScrollbarMode ScrollView::hScrollbarMode() const
{
    return m_data->m_hScrollbarMode;
}

WebCore::ScrollbarMode ScrollView::vScrollbarMode() const
{
    return m_data->m_vScrollbarMode;
}

void ScrollView::suppressScrollbars(bool suppressed, bool repaintOnSuppress)
{
    m_data->m_scrollbarsSuppressed = suppressed;
    if (repaintOnSuppress && !suppressed) {
        if (m_data->m_hBar)
            m_data->m_hBar->invalidate();
        if (m_data->m_vBar)
            m_data->m_vBar->invalidate();

        // Invalidate the scroll corner too on unsuppress.
        IntRect hCorner;
        if (m_data->m_hBar && width() - m_data->m_hBar->width() > 0) {
            hCorner = IntRect(m_data->m_hBar->width(),
                              height() - m_data->m_hBar->height(),
                              width() - m_data->m_hBar->width(),
                              m_data->m_hBar->height());
            invalidateRect(hCorner);
        }

        if (m_data->m_vBar && height() - m_data->m_vBar->height() > 0) {
            IntRect vCorner(width() - m_data->m_vBar->width(),
                            m_data->m_vBar->height(),
                            m_data->m_vBar->width(),
                            height() - m_data->m_vBar->height());
            if (vCorner != hCorner)
                invalidateRect(vCorner);
        }
    }
}

void ScrollView::setHScrollbarMode(ScrollbarMode newMode)
{
    if (m_data->m_hScrollbarMode != newMode) {
        m_data->m_hScrollbarMode = newMode;
        updateScrollbars(m_data->m_scrollOffset);
    }
}

void ScrollView::setVScrollbarMode(ScrollbarMode newMode)
{
    if (m_data->m_vScrollbarMode != newMode) {
        m_data->m_vScrollbarMode = newMode;
        updateScrollbars(m_data->m_scrollOffset);
    }
}

void ScrollView::setScrollbarsMode(ScrollbarMode newMode)
{
    if (m_data->m_hScrollbarMode != newMode ||
        m_data->m_vScrollbarMode != newMode) {
        m_data->m_hScrollbarMode = m_data->m_vScrollbarMode = newMode;
        updateScrollbars(m_data->m_scrollOffset);
    }
}

void ScrollView::setStaticBackground(bool flag)
{
    m_data->m_hasStaticBackground = flag;
}

void ScrollView::updateScrollbars(const IntSize& desiredOffset)
{
    // Don't allow re-entrancy into this function.
    if (m_data->m_inUpdateScrollbars)
        return;

    m_data->m_inUpdateScrollbars = true;

    bool hasVerticalScrollbar = m_data->m_vBar;
    bool hasHorizontalScrollbar = m_data->m_hBar;
    bool oldHasVertical = hasVerticalScrollbar;
    bool oldHasHorizontal = hasHorizontalScrollbar;
    ScrollbarMode hScroll = m_data->m_hScrollbarMode;
    ScrollbarMode vScroll = m_data->m_vScrollbarMode;

    const int cVerticalWidth = PlatformScrollbar::verticalScrollbarWidth();
    const int cHorizontalHeight = PlatformScrollbar::horizontalScrollbarHeight();

    // we may not be able to support scrollbars due to our frame geometry
    if (width() < cVerticalWidth)
        vScroll = ScrollbarAlwaysOff;
    if (height() < cHorizontalHeight)
        hScroll = ScrollbarAlwaysOff;

    for (int pass = 0; pass < 2; pass++) {
        bool scrollsVertically;
        bool scrollsHorizontally;

        if (!m_data->m_scrollbarsSuppressed && (hScroll == ScrollbarAuto || vScroll == ScrollbarAuto)) {
            // Do a layout if pending before checking if scrollbars are needed.
            if (hasVerticalScrollbar != oldHasVertical || hasHorizontalScrollbar != oldHasHorizontal)
                static_cast<FrameView*>(this)->layout();

            scrollsVertically = (vScroll == ScrollbarAlwaysOn) || (vScroll == ScrollbarAuto && contentsHeight() > height());
            if (scrollsVertically)
                scrollsHorizontally = (hScroll == ScrollbarAlwaysOn) || (hScroll == ScrollbarAuto && contentsWidth() + cVerticalWidth > width());
            else {
                scrollsHorizontally = (hScroll == ScrollbarAlwaysOn) || (hScroll == ScrollbarAuto && contentsWidth() > width());
                if (scrollsHorizontally)
                    scrollsVertically = (vScroll == ScrollbarAlwaysOn) || (vScroll == ScrollbarAuto && contentsHeight() + cHorizontalHeight > height());
            }
        }
        else {
            scrollsHorizontally = (hScroll == ScrollbarAuto) ? hasHorizontalScrollbar : (hScroll == ScrollbarAlwaysOn);
            scrollsVertically = (vScroll == ScrollbarAuto) ? hasVerticalScrollbar : (vScroll == ScrollbarAlwaysOn);
        }

        if (hasVerticalScrollbar != scrollsVertically) {
            m_data->setHasVerticalScrollbar(scrollsVertically);
            hasVerticalScrollbar = scrollsVertically;
        }

        if (hasHorizontalScrollbar != scrollsHorizontally) {
            m_data->setHasHorizontalScrollbar(scrollsHorizontally);
            hasHorizontalScrollbar = scrollsHorizontally;
        }
    }

    // Set up the range (and page step/line step).
    IntSize maxScrollPosition(contentsWidth() - visibleWidth(), contentsHeight() - visibleHeight());
    IntSize scroll = desiredOffset.shrunkTo(maxScrollPosition);
    scroll.clampNegativeToZero();

    if (m_data->m_hBar) {
        int clientWidth = visibleWidth();
        m_data->m_hBar->setEnabled(contentsWidth() > clientWidth);
        int pageStep = (clientWidth - PAGE_KEEP);
        if (pageStep < 0) pageStep = clientWidth;
        IntRect oldRect(m_data->m_hBar->frameGeometry());
        IntRect hBarRect = IntRect(0,
                                   height() - m_data->m_hBar->height(),
                                   width() - (m_data->m_vBar ? m_data->m_vBar->width() : 0),
                                   m_data->m_hBar->height());
        m_data->m_hBar->setRect(hBarRect);
        if (!m_data->m_scrollbarsSuppressed && oldRect != m_data->m_hBar->frameGeometry())
            m_data->m_hBar->invalidate();

        if (m_data->m_scrollbarsSuppressed)
            m_data->m_hBar->setSuppressInvalidation(true);
        m_data->m_hBar->setSteps(LINE_STEP, pageStep);
        m_data->m_hBar->setProportion(clientWidth, contentsWidth());
        m_data->m_hBar->setValue(scroll.width());
        if (m_data->m_scrollbarsSuppressed)
            m_data->m_hBar->setSuppressInvalidation(false);
    }

    if (m_data->m_vBar) {
        int clientHeight = visibleHeight();
        m_data->m_vBar->setEnabled(contentsHeight() > clientHeight);
        int pageStep = (clientHeight - PAGE_KEEP);
        if (pageStep < 0) pageStep = clientHeight;
        IntRect oldRect(m_data->m_vBar->frameGeometry());
        IntRect vBarRect = IntRect(width() - m_data->m_vBar->width(),
                                   0,
                                   m_data->m_vBar->width(),
                                   height() - (m_data->m_hBar ? m_data->m_hBar->height() : 0));
        m_data->m_vBar->setRect(vBarRect);
        if (!m_data->m_scrollbarsSuppressed && oldRect != m_data->m_vBar->frameGeometry())
            m_data->m_vBar->invalidate();

        if (m_data->m_scrollbarsSuppressed)
            m_data->m_vBar->setSuppressInvalidation(true);
        m_data->m_vBar->setSteps(LINE_STEP, pageStep);
        m_data->m_vBar->setProportion(clientHeight, contentsHeight());
        m_data->m_vBar->setValue(scroll.height());
        if (m_data->m_scrollbarsSuppressed)
            m_data->m_vBar->setSuppressInvalidation(false);
    }

    if (oldHasVertical != (m_data->m_vBar != 0) || oldHasHorizontal != (m_data->m_hBar != 0))
        geometryChanged();

    // See if our offset has changed in a situation where we might not have scrollbars.
    // This can happen when editing a body with overflow:hidden and scrolling to reveal selection.
    // It can also happen when maximizing a window that has scrollbars (but the new maximized result
    // does not).
    IntSize scrollDelta = scroll - m_data->m_scrollOffset;
    if (scrollDelta != IntSize()) {
        m_data->m_scrollOffset = scroll;
        m_data->scrollBackingStore(scrollDelta);

        // Inform the delegate that the scroll position has changed.
        WidgetClientWin* c = static_cast<WidgetClientWin*>(client());
        if (c)
            c->onScrollPositionChanged(this);
    }

    m_data->m_inUpdateScrollbars = false;

    ASSERT(visibleWidth() >= 0);
    ASSERT(visibleHeight() >= 0);
}

PlatformScrollbar* ScrollView::scrollbarUnderMouse(const PlatformMouseEvent& mouseEvent)
{
    IntPoint viewPoint = convertFromContainingWindow(mouseEvent.pos());
    if (m_data->m_hBar && m_data->m_hBar->frameGeometry().contains(viewPoint))
        return m_data->m_hBar.get();
    if (m_data->m_vBar && m_data->m_vBar->frameGeometry().contains(viewPoint))
        return m_data->m_vBar.get();
    return 0;
}

void ScrollView::addChild(Widget* child)
{
    child->setParent(this);

    // There is only one global widget client (which should be the WebViewImpl).
    // It is responsible for things like capturing the mouse.
    child->setClient(client());

    m_data->m_children.add(child);
}

void ScrollView::removeChild(Widget* child)
{
    child->setParent(0);
    m_data->m_children.remove(child);
}

void ScrollView::paint(GraphicsContext* context, const IntRect& rect)
{
    // FIXME: This code is here so we don't have to fork FrameView.h/.cpp.
    // In the end, FrameView should just merge with ScrollView.
    ASSERT(isFrameView());

    if (context->paintingDisabled())
        return;

    if (Frame* frame = static_cast<FrameView*>(this)->frame()) {
        IntRect documentDirtyRect = rect;
        documentDirtyRect.intersect(frameGeometry());

        context->save();

        context->translate(x(), y());
        documentDirtyRect.move(-x(), -y());

        context->translate(-contentsX(), -contentsY());
        documentDirtyRect.move(contentsX(), contentsY());

        // do not allow painting outside of the dirty rect
        context->clip(documentDirtyRect);

        frame->paint(context, documentDirtyRect);

        // Highlights the node selected in the DOM inspector.
        m_data->highlightInspectedNode(context, frame);

        context->restore();
    }

    // Highlight the matches found on the page, during a FindInPage operation.
    m_data->highlightMatches(context);

    // Now paint the scrollbars.
    if (!m_data->m_scrollbarsSuppressed && (m_data->m_hBar || m_data->m_vBar)) {
        context->save();
        IntRect scrollViewDirtyRect = rect;
        scrollViewDirtyRect.intersect(frameGeometry());
        context->translate(x(), y());
        scrollViewDirtyRect.move(-x(), -y());
        if (m_data->m_hBar)
            m_data->m_hBar->paint(context, scrollViewDirtyRect);
        if (m_data->m_vBar)
            m_data->m_vBar->paint(context, scrollViewDirtyRect);

        // Fill the scroll corner with white.
        IntRect hCorner;
        if (m_data->m_hBar && width() - m_data->m_hBar->width() > 0) {
            hCorner = IntRect(m_data->m_hBar->width(),
                              height() - m_data->m_hBar->height(),
                              width() - m_data->m_hBar->width(),
                              m_data->m_hBar->height());
            if (hCorner.intersects(scrollViewDirtyRect))
                context->fillRect(hCorner, Color::white);
        }

        if (m_data->m_vBar && height() - m_data->m_vBar->height() > 0) {
            IntRect vCorner(width() - m_data->m_vBar->width(),
                            m_data->m_vBar->height(),
                            m_data->m_vBar->width(),
                            height() - m_data->m_vBar->height());
            if (vCorner != hCorner && vCorner.intersects(scrollViewDirtyRect))
                context->fillRect(vCorner, Color::white);
        }

        context->restore();
    }
}

void ScrollView::themeChanged()
{
    PlatformScrollbar::themeChanged();
    theme()->themeChanged();
    invalidate();
}

void ScrollView::wheelEvent(PlatformWheelEvent& e)
{
    if (!m_data->allowsScrolling())
        return;

    // Determine how much we want to scroll.  If we can move at all, we will accept the event.
    IntSize maxScrollDelta = maximumScroll();
    if ((e.deltaX() < 0 && maxScrollDelta.width() > 0) ||
        (e.deltaX() > 0 && scrollOffset().width() > 0) ||
        (e.deltaY() < 0 && maxScrollDelta.height() > 0) ||
        (e.deltaY() > 0 && scrollOffset().height() > 0)) {
        e.accept();
        scrollBy(-e.deltaX() * LINE_STEP, -e.deltaY() * LINE_STEP);
    }
}

HashSet<Widget*>* ScrollView::children()
{
    return &(m_data->m_children);
}

void ScrollView::geometryChanged() const
{
    HashSet<Widget*>::const_iterator end = m_data->m_children.end();
    for (HashSet<Widget*>::const_iterator current = m_data->m_children.begin(); current != end; ++current)
        (*current)->geometryChanged();
}

bool ScrollView::scroll(ScrollDirection direction, ScrollGranularity granularity)
{
    if  (direction == ScrollUp || direction == ScrollDown) {
        if (m_data->m_vBar)
            return m_data->m_vBar->scroll(direction, granularity);
    } else {
        if (m_data->m_hBar)
            return m_data->m_hBar->scroll(direction, granularity);
    }
    return false;
}

IntRect ScrollView::windowResizerRect()
{
    return IntRect();
}

bool ScrollView::resizerOverlapsContent() const
{
    return !m_data->m_scrollbarsAvoidingResizer;
}

void ScrollView::adjustOverlappingScrollbarCount(int overlapDelta)
{
    int oldCount = m_data->m_scrollbarsAvoidingResizer;
    m_data->m_scrollbarsAvoidingResizer += overlapDelta;
    if (parent() && parent()->isFrameView())
        static_cast<FrameView*>(parent())->adjustOverlappingScrollbarCount(overlapDelta);
    else if (!m_data->m_scrollbarsSuppressed) {
        // If we went from n to 0 or from 0 to n and we're the outermost view,
        // we need to invalidate the windowResizerRect(), since it will now need to paint
        // differently.
        if (oldCount > 0 && m_data->m_scrollbarsAvoidingResizer == 0 ||
            oldCount == 0 && m_data->m_scrollbarsAvoidingResizer > 0)
            invalidateRect(windowResizerRect());
    }
}

void ScrollView::setParent(ScrollView* parentView)
{
    if (!parentView && m_data->m_scrollbarsAvoidingResizer && parent() && parent()->isFrameView())
        static_cast<FrameView*>(parent())->adjustOverlappingScrollbarCount(false);
    Widget::setParent(parentView);
}

void ScrollView::addToDirtyRegion(const IntRect& containingWindowRect)
{
    WidgetClientWin* c = static_cast<WidgetClientWin*>(client());
    if (c)
        c->invalidateRect(containingWindowRect);
}

void ScrollView::scrollBackingStore(int dx, int dy, const IntRect& scrollViewRect, const IntRect& clipRect)
{
    // We don't know how to scroll in two directions at once.
    if (dx && dy) {
        IntRect updateRect = clipRect;
        updateRect.intersect(scrollViewRect);
        addToDirtyRegion(updateRect);
        return;
    }

    WidgetClientWin* c = static_cast<WidgetClientWin*>(client());
    if (c) {
        // TODO(ericroman): would be better to pass both the scroll rect
        // and clip rect up to the client and let them decide how best to
        // scroll the backing store.
        IntRect clippedScrollRect = scrollViewRect;
        clippedScrollRect.intersect(clipRect);
        c->scrollRect(dx, dy, clippedScrollRect);
    }
}

void ScrollView::updateBackingStore()
{
    // nothing to do.  painting happens asynchronously.
}

bool ScrollView::inWindow() const
{
    // Needed for back/forward cache.
    notImplemented();
    return true;
}

void ScrollView::attachToWindow()
{
    if (m_data->m_attachedToWindow)
        return;

    m_data->m_attachedToWindow = true;

    if (m_data->m_visible) {
        HashSet<Widget*>::iterator end = m_data->m_children.end();
        for (HashSet<Widget*>::iterator it = m_data->m_children.begin(); it != end; ++it)
            (*it)->attachToWindow();
    }
}

void ScrollView::detachFromWindow()
{
    if (!m_data->m_attachedToWindow)
        return;

    if (m_data->m_visible) {
        HashSet<Widget*>::iterator end = m_data->m_children.end();
        for (HashSet<Widget*>::iterator it = m_data->m_children.begin(); it != end; ++it)
            (*it)->detachFromWindow();
    }

    m_data->m_attachedToWindow = false;
}

void ScrollView::show()
{
    if (!m_data->m_visible) {
        m_data->m_visible = true;
        if (isAttachedToWindow()) {
            HashSet<Widget*>::iterator end = m_data->m_children.end();
            for (HashSet<Widget*>::iterator it = m_data->m_children.begin(); it != end; ++it)
                (*it)->attachToWindow();
        }
    }

    Widget::show();
}

void ScrollView::hide()
{
    if (m_data->m_visible) {
        if (isAttachedToWindow()) {
            HashSet<Widget*>::iterator end = m_data->m_children.end();
            for (HashSet<Widget*>::iterator it = m_data->m_children.begin(); it != end; ++it)
                (*it)->detachFromWindow();
        }
        m_data->m_visible = false;
    }

    Widget::hide();
}

bool ScrollView::isAttachedToWindow() const
{
    return m_data->m_attachedToWindow;
}

void ScrollView::setAllowsScrolling(bool flag)
{
  m_data->setAllowsScrolling(flag);
}

bool ScrollView::allowsScrolling() const
{
  return m_data->allowsScrolling();
}

} // namespace WebCore