Begin disentangling of scrollbar logic in preparation for engine-implemented
authorhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 Aug 2006 01:50:45 +0000 (01:50 +0000)
committerhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 Aug 2006 01:50:45 +0000 (01:50 +0000)
        scrollbars.  Split ScrollBar into two classes, an abstract base (still named
        ScrollBar) and a new PlatformScrollBar subclass.  This subclass is used only
        by platforms that want to continue to use a platform scrollbar (rather than
        the engine one).

        Reviewed by darin

        * WebCore.xcodeproj/project.pbxproj:
        * html/HTMLCanvasElement.h:
        * page/Frame.cpp:
        * platform/PlatformScrollBar.h: Added.
        (WebCore::PlatformScrollBar::isWidget):
        * platform/ScrollBar.h:
        (WebCore::ScrollBarClient::~ScrollBarClient):
        (WebCore::ScrollBar::~ScrollBar):
        (WebCore::ScrollBar::orientation):
        (WebCore::ScrollBar::value):
        (WebCore::ScrollBar::client):
        * platform/mac/PlatformScrollBarMac.mm: Added.
        (-[WebCoreScrollBar initWithPlatformScrollBar:]):
        (-[WebCoreScrollBar detachPlatformScrollBar]):
        (-[WebCoreScrollBar scroll:]):
        (-[WebCoreScrollBar widget]):
        (-[WebCoreScrollBar mouseDown:]):
        (WebCore::PlatformScrollBar::PlatformScrollBar):
        (WebCore::PlatformScrollBar::~PlatformScrollBar):
        (WebCore::PlatformScrollBar::setScrollBarValue):
        (WebCore::PlatformScrollBar::setKnobProportion):
        (WebCore::PlatformScrollBar::scrollbarHit):
        (WebCore::PlatformScrollBar::width):
        (WebCore::PlatformScrollBar::height):
        (WebCore::PlatformScrollBar::setRect):
        (WebCore::PlatformScrollBar::setEnabled):
        (WebCore::PlatformScrollBar::paint):
        * platform/mac/ScrollBarMac.mm: Removed.
        * platform/mac/WebCoreTextArea.mm:
        * rendering/RenderBlock.cpp:
        (WebCore::RenderBlock::isPointInScrollbar):
        * rendering/RenderFormElement.cpp:
        * rendering/RenderLayer.cpp:
        (WebCore::RenderLayer::horizontalScrollbarWidget):
        (WebCore::RenderLayer::verticalScrollbarWidget):
        (WebCore::RenderLayer::valueChanged):
        (WebCore::RenderLayer::setHasHorizontalScrollbar):
        (WebCore::RenderLayer::setHasVerticalScrollbar):
        (WebCore::RenderLayer::positionScrollbars):
        * rendering/RenderLayer.h:
        * rendering/RenderWidget.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@15721 268f45cc-cd09-0410-ab3c-d52691b4dbfc

13 files changed:
WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/html/HTMLCanvasElement.h
WebCore/page/Frame.cpp
WebCore/platform/PlatformScrollBar.h [new file with mode: 0644]
WebCore/platform/ScrollBar.h
WebCore/platform/mac/PlatformScrollBarMac.mm [moved from WebCore/platform/mac/ScrollBarMac.mm with 64% similarity]
WebCore/platform/mac/WebCoreTextArea.mm
WebCore/rendering/RenderBlock.cpp
WebCore/rendering/RenderFormElement.cpp
WebCore/rendering/RenderLayer.cpp
WebCore/rendering/RenderLayer.h
WebCore/rendering/RenderWidget.h

index 774442860ea65a7862ba29f02cc522ffe252d902..ce3e81d14cbe118964d7a60e7be75dff3afbf021 100644 (file)
@@ -1,3 +1,55 @@
+2006-07-31  David Hyatt  <hyatt@apple.com>
+
+        Begin disentangling of scrollbar logic in preparation for engine-implemented
+        scrollbars.  Split ScrollBar into two classes, an abstract base (still named
+        ScrollBar) and a new PlatformScrollBar subclass.  This subclass is used only
+        by platforms that want to continue to use a platform scrollbar (rather than
+        the engine one).
+
+        Reviewed by darin
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * html/HTMLCanvasElement.h:
+        * page/Frame.cpp:
+        * platform/PlatformScrollBar.h: Added.
+        (WebCore::PlatformScrollBar::isWidget):
+        * platform/ScrollBar.h:
+        (WebCore::ScrollBarClient::~ScrollBarClient):
+        (WebCore::ScrollBar::~ScrollBar):
+        (WebCore::ScrollBar::orientation):
+        (WebCore::ScrollBar::value):
+        (WebCore::ScrollBar::client):
+        * platform/mac/PlatformScrollBarMac.mm: Added.
+        (-[WebCoreScrollBar initWithPlatformScrollBar:]):
+        (-[WebCoreScrollBar detachPlatformScrollBar]):
+        (-[WebCoreScrollBar scroll:]):
+        (-[WebCoreScrollBar widget]):
+        (-[WebCoreScrollBar mouseDown:]):
+        (WebCore::PlatformScrollBar::PlatformScrollBar):
+        (WebCore::PlatformScrollBar::~PlatformScrollBar):
+        (WebCore::PlatformScrollBar::setScrollBarValue):
+        (WebCore::PlatformScrollBar::setKnobProportion):
+        (WebCore::PlatformScrollBar::scrollbarHit):
+        (WebCore::PlatformScrollBar::width):
+        (WebCore::PlatformScrollBar::height):
+        (WebCore::PlatformScrollBar::setRect):
+        (WebCore::PlatformScrollBar::setEnabled):
+        (WebCore::PlatformScrollBar::paint):
+        * platform/mac/ScrollBarMac.mm: Removed.
+        * platform/mac/WebCoreTextArea.mm:
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::isPointInScrollbar):
+        * rendering/RenderFormElement.cpp:
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::horizontalScrollbarWidget):
+        (WebCore::RenderLayer::verticalScrollbarWidget):
+        (WebCore::RenderLayer::valueChanged):
+        (WebCore::RenderLayer::setHasHorizontalScrollbar):
+        (WebCore::RenderLayer::setHasVerticalScrollbar):
+        (WebCore::RenderLayer::positionScrollbars):
+        * rendering/RenderLayer.h:
+        * rendering/RenderWidget.h:
+
 2006-07-31  Adele Peterson  <adele@apple.com>
 
         Reviewed by John and Anders.
index ef719bb1d3f4f4860e2a51c61dc04d7a661d645d..54c2fb8c536f8ec1f67e1aeb297c8ad28952ee7f 100644 (file)
                93F19ACD08245E59001E9ABC /* WebCoreResourceLoaderImp.mm in Sources */ = {isa = PBXBuildFile; fileRef = 93386B91037045B3008635CE /* WebCoreResourceLoaderImp.mm */; };
                93F19AD208245E59001E9ABC /* WebCorePageState.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9394E0A503AA5BBE008635CE /* WebCorePageState.mm */; };
                93F19AD508245E59001E9ABC /* RenderTreeAsText.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93955A4203D72932008635CE /* RenderTreeAsText.cpp */; };
-               93F19ADC08245E59001E9ABC /* ScrollBarMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC7B2AF90450824100A8000F /* ScrollBarMac.mm */; };
+               93F19ADC08245E59001E9ABC /* PlatformScrollBarMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC7B2AF90450824100A8000F /* PlatformScrollBarMac.mm */; };
                93F19ADF08245E59001E9ABC /* WebCoreAXObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 55998A5B052B59CC0017A6C1 /* WebCoreAXObject.mm */; };
                93F19AE008245E59001E9ABC /* AXObjectCacheMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 55998A5D052B59CC0017A6C1 /* AXObjectCacheMac.mm */; };
                93F19AE108245E59001E9ABC /* BlockExceptions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 65F80697054D9F86008BF776 /* BlockExceptions.mm */; };
                BC92F1DD0A40AEA300AC0746 /* DeprecatedSlider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC92F1DB0A40AEA300AC0746 /* DeprecatedSlider.cpp */; };
                BC92F1DE0A40AEA300AC0746 /* DeprecatedSlider.h in Headers */ = {isa = PBXBuildFile; fileRef = BC92F1DC0A40AEA300AC0746 /* DeprecatedSlider.h */; };
                BC9C328B09933A6E001D6924 /* ImageAnimationObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = BC9C328A09933A6D001D6924 /* ImageAnimationObserver.h */; };
+               BCAA90A00A7EB03A008B1229 /* PlatformScrollBar.h in Headers */ = {isa = PBXBuildFile; fileRef = BCAA909F0A7EB03A008B1229 /* PlatformScrollBar.h */; };
+               BCAA90C30A7EBA60008B1229 /* ScrollBar.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCAA90C20A7EBA60008B1229 /* ScrollBar.cpp */; };
                BCB16AF90979A08500467741 /* FloatRect.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCB16AF50979A08500467741 /* FloatRect.cpp */; };
                BCB16AFA0979A08500467741 /* FloatRect.h in Headers */ = {isa = PBXBuildFile; fileRef = BCB16AF60979A08500467741 /* FloatRect.h */; };
                BCB16AFB0979A08500467741 /* IntRect.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCB16AF70979A08500467741 /* IntRect.cpp */; };
                BC73E3900978CED700EDFF8A /* FloatPoint.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = FloatPoint.cpp; sourceTree = "<group>"; };
                BC73E3910978CED700EDFF8A /* FloatPoint.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FloatPoint.h; sourceTree = "<group>"; };
                BC7B2AF80450824100A8000F /* ScrollBar.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = ScrollBar.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
-               BC7B2AF90450824100A8000F /* ScrollBarMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ScrollBarMac.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
+               BC7B2AF90450824100A8000F /* PlatformScrollBarMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PlatformScrollBarMac.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                BC86FB8D061F5C23006BB822 /* Slider.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = Slider.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                BC86FB8E061F5C23006BB822 /* SliderMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SliderMac.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                BC92F1DB0A40AEA300AC0746 /* DeprecatedSlider.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = DeprecatedSlider.cpp; sourceTree = "<group>"; };
                BC92F1DC0A40AEA300AC0746 /* DeprecatedSlider.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DeprecatedSlider.h; sourceTree = "<group>"; };
                BC9C328A09933A6D001D6924 /* ImageAnimationObserver.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ImageAnimationObserver.h; sourceTree = "<group>"; };
+               BCAA909F0A7EB03A008B1229 /* PlatformScrollBar.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PlatformScrollBar.h; sourceTree = "<group>"; };
+               BCAA90C20A7EBA60008B1229 /* ScrollBar.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = ScrollBar.cpp; path = platform/ScrollBar.cpp; sourceTree = SOURCE_ROOT; };
                BCB16AF50979A08500467741 /* FloatRect.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = FloatRect.cpp; sourceTree = "<group>"; };
                BCB16AF60979A08500467741 /* FloatRect.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FloatRect.h; sourceTree = "<group>"; };
                BCB16AF70979A08500467741 /* IntRect.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = IntRect.cpp; sourceTree = "<group>"; };
                                A82398A709B3ACF500B60641 /* PlugInInfoStoreMac.mm */,
                                F58784D202DE375901EA4122 /* PopUpButtonMac.mm */,
                                6582A15409999D6D00BEEB6D /* ScreenMac.mm */,
-                               BC7B2AF90450824100A8000F /* ScrollBarMac.mm */,
+                               BC7B2AF90450824100A8000F /* PlatformScrollBarMac.mm */,
+                               BCAA90C20A7EBA60008B1229 /* ScrollBar.cpp */,
                                9353676A09AED88B00D35CD6 /* ScrollViewMac.mm */,
                                93309E9F099EB78C0056E581 /* SharedTimerMac.cpp */,
                                BC86FB8E061F5C23006BB822 /* SliderMac.mm */,
                                BCC8D1720988301200140BF2 /* Pen.h */,
                                935C476609AC4D4300A6AAB4 /* PlatformKeyboardEvent.h */,
                                935C476709AC4D4300A6AAB4 /* PlatformMouseEvent.h */,
+                               BCAA909F0A7EB03A008B1229 /* PlatformScrollBar.h */,
                                93CD4FEB0995FD2A007ECC97 /* PlatformString.h */,
                                935C476A09AC4D4F00A6AAB4 /* PlatformWheelEvent.h */,
                                A82398A509B3ACDB00B60641 /* PlugInInfoStore.h */,
                                E148432F0A674FC2007E4D39 /* StreamingTextDecoderMac.h in Headers */,
                                1CAF34810A6C405200ABE06E /* WebScriptObject.h in Headers */,
                                1CAF34830A6C405200ABE06E /* WebScriptObjectPrivate.h in Headers */,
+                               BCAA90A00A7EB03A008B1229 /* PlatformScrollBar.h in Headers */,
                                85EC9AFA0A71A2C600EEEAED /* FontData.h in Headers */,
                                85EC9AFB0A71A2C600EEEAED /* Language.h in Headers */,
                        );
                                93F19ACD08245E59001E9ABC /* WebCoreResourceLoaderImp.mm in Sources */,
                                93F19AD208245E59001E9ABC /* WebCorePageState.mm in Sources */,
                                93F19AD508245E59001E9ABC /* RenderTreeAsText.cpp in Sources */,
-                               93F19ADC08245E59001E9ABC /* ScrollBarMac.mm in Sources */,
+                               93F19ADC08245E59001E9ABC /* PlatformScrollBarMac.mm in Sources */,
                                93F19ADF08245E59001E9ABC /* WebCoreAXObject.mm in Sources */,
                                93F19AE008245E59001E9ABC /* AXObjectCacheMac.mm in Sources */,
                                93F19AE108245E59001E9ABC /* BlockExceptions.mm in Sources */,
                                E14842FF0A674A31007E4D39 /* StreamingTextDecoderICU.cpp in Sources */,
                                E14843D60A6754A6007E4D39 /* StreamingTextDecoderMac.cpp in Sources */,
                                1CAF34820A6C405200ABE06E /* WebScriptObject.mm in Sources */,
+                               BCAA90C30A7EBA60008B1229 /* ScrollBar.cpp in Sources */,
                                93B0FD8A0A759BED0080AD44 /* StringImplMac.mm in Sources */,
                                93B0FD8B0A759BED0080AD44 /* StringMac.mm in Sources */,
                        );
index be5f3ca34985c00bd91cbc4095fbe8f5f858d164..3dce2893f2625dab1e01cb9d677efb6825ce08f9 100644 (file)
@@ -40,6 +40,7 @@ namespace WebCore {
 class CanvasRenderingContext2D;
 typedef CanvasRenderingContext2D CanvasRenderingContext;
 class FloatRect;
+class GraphicsContext;
 
 class HTMLCanvasElement : public HTMLElement {
 public:
index 1f00b0e89938c95e786c852f394ef12ae33c3591..abbf48bd25fa798fb691f67d0ccc3426dd615d13 100644 (file)
@@ -58,6 +58,7 @@
 #include "MouseEventWithHitTestResults.h"
 #include "NodeList.h"
 #include "Page.h"
+#include "PlatformScrollBar.h"
 #include "PlugInInfoStore.h"
 #include "Plugin.h"
 #include "PluginDocument.h"
diff --git a/WebCore/platform/PlatformScrollBar.h b/WebCore/platform/PlatformScrollBar.h
new file mode 100644 (file)
index 0000000..dfdf6c8
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2004, 2006 Apple Computer, 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. 
+ */
+
+#ifndef PlatformScrollBar_h
+#define PlatformScrollBar_h
+
+#include "Widget.h"
+#include "ScrollBar.h"
+
+#ifdef __OBJC__
+@class NSScroller;
+#else
+class NSScroller;
+typedef int NSScrollerPart;
+#endif
+
+namespace WebCore {
+
+class PlatformScrollBar : public Widget, public ScrollBar {
+public:
+    PlatformScrollBar(ScrollBarClient*, ScrollBarOrientation);
+    virtual ~PlatformScrollBar();
+
+    virtual bool isWidget() const { return true; }
+
+    virtual void setScrollBarValue(int v);
+    virtual void setKnobProportion(int visibleSize, int totalSize);
+
+    virtual int width() const;
+    virtual int height() const;
+    virtual void setRect(const IntRect&);
+    virtual void setEnabled(bool);
+    virtual void paint(GraphicsContext*, const IntRect& damageRect);
+
+    bool scrollbarHit(NSScrollerPart);
+};
+
+}
+
+#endif // PlatformScrollBar_h
+
index 999ea3361fa94f4642d12a2c0e0ef9629e031d89..a94c02b7e4211842fbb204283c5e495b77d14d7f 100644 (file)
 #ifndef ScrollBar_h
 #define ScrollBar_h
 
-#include "Widget.h"
-
-#ifdef __OBJC__
-@class NSScroller;
-#else
-class NSScroller;
-typedef int NSScrollerPart;
-#endif
-
 namespace WebCore {
 
+class GraphicsContext;
+class IntRect;
+class ScrollBar;
+
 enum ScrollDirection {
     ScrollUp,
     ScrollDown,
@@ -53,25 +48,43 @@ enum ScrollGranularity {
 
 enum ScrollBarOrientation { HorizontalScrollBar, VerticalScrollBar };
 
-class ScrollBar : public Widget {
+class ScrollBarClient {
 public:
-    ScrollBar(ScrollBarOrientation);
-    virtual ~ScrollBar();
+    virtual ~ScrollBarClient() {}
+    virtual void valueChanged(ScrollBar*) = 0;
+};
 
-    ScrollBarOrientation orientation() { return m_orientation; }
+class ScrollBar {
+protected:
+    ScrollBar(ScrollBarClient*, ScrollBarOrientation);
 
-    int value() { return m_currentPos; }
-    bool setValue(int v);
+public:
+    virtual ~ScrollBar() {}
+
+    virtual bool isWidget() const = 0;
+
+    ScrollBarOrientation orientation() const { return m_orientation; }
+    int value() const { return m_currentPos; } 
+    
+    virtual void setScrollBarValue(int) = 0;
+    virtual void setKnobProportion(int visibleSize, int totalSize) = 0;
 
     void setSteps(int lineStep, int pageStep);
-    void setKnobProportion(int visibleSize, int totalSize);
     
-    bool scrollbarHit(NSScrollerPart);
-    void valueChanged();
+    bool setValue(int);
     
     bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1.0);
     
-private:
+    virtual int width() const = 0;
+    virtual int height() const = 0;
+    virtual void setRect(const IntRect&) = 0;
+    virtual void setEnabled(bool) = 0;
+    virtual void paint(GraphicsContext*, const IntRect& damageRect) = 0;
+
+protected:
+    ScrollBarClient* client() const { return m_client; }
+
+    ScrollBarClient* m_client;
     ScrollBarOrientation m_orientation;
     int m_visibleSize;
     int m_totalSize;
similarity index 64%
rename from WebCore/platform/mac/ScrollBarMac.mm
rename to WebCore/platform/mac/PlatformScrollBarMac.mm
index 18da26f703382adec7052c82cf5ec75c1d911d25..2764097e006048b2c7082757fcf9be8e94744384 100644 (file)
@@ -24,7 +24,7 @@
  */
 
 #import "config.h"
-#import "ScrollBar.h"
+#import "PlatformScrollBar.h"
 
 #import "BlockExceptions.h"
 #import "WebCoreWidgetHolder.h"
@@ -34,17 +34,17 @@ using namespace WebCore;
 
 @interface WebCoreScrollBar : NSScroller <WebCoreWidgetHolder>
 {
-    ScrollBar* scrollBar;
+    PlatformScrollBar* scrollBar;
 }
 
-- (id)initWithQScrollBar:(ScrollBar *)s;
-- (void)detachQScrollBar;
+- (id)initWithPlatformScrollBar:(PlatformScrollBar*)s;
+- (void)detachPlatformScrollBar;
 
 @end
 
 @implementation WebCoreScrollBar
 
-- (id)initWithQScrollBar:(ScrollBar *)s
+- (id)initWithPlatformScrollBar:(PlatformScrollBar*)s
 {
     // Cocoa scrollbars just set their orientation by examining their own
     // dimensions, so we have to do this unsavory hack.
@@ -68,7 +68,7 @@ using namespace WebCore;
     return self;
 }
 
-- (void)detachQScrollBar
+- (void)detachPlatformScrollBar
 {
     [self setTarget:nil];
     scrollBar = 0;
@@ -76,9 +76,8 @@ using namespace WebCore;
 
 - (IBAction)scroll:(NSScroller*)sender
 {
-    if (scrollBar) {
+    if (scrollBar)
         scrollBar->scrollbarHit([sender hitPart]);
-    }
 }
 
 - (Widget *)widget
@@ -95,27 +94,25 @@ using namespace WebCore;
 
 @end
 
-ScrollBar::ScrollBar(ScrollBarOrientation orientation)
-    : m_orientation(orientation)
-    , m_visibleSize(0)
-    , m_totalSize(0)
-    , m_currentPos(0)
-    , m_lineStep(0)
-    , m_pageStep(0)
+namespace WebCore
+{
+
+PlatformScrollBar::PlatformScrollBar(ScrollBarClient* client, ScrollBarOrientation orientation)
+    : ScrollBar(client, orientation)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
 
-    WebCoreScrollBar *bar = [[WebCoreScrollBar alloc] initWithQScrollBar:this];
+    WebCoreScrollBar *bar = [[WebCoreScrollBar alloc] initWithPlatformScrollBar:this];
     setView(bar);
     [bar release];
 
     END_BLOCK_OBJC_EXCEPTIONS;
 }
 
-ScrollBar::~ScrollBar()
+PlatformScrollBar::~PlatformScrollBar()
 {
-    WebCoreScrollBar *bar = (WebCoreScrollBar *)getView();
-    [bar detachQScrollBar];
+    WebCoreScrollBar* bar = (WebCoreScrollBar*)getView();
+    [bar detachPlatformScrollBar];
 
     // Widget should probably do this for all widgets.
     // But we don't need it for form elements, and for frames it doesn't work
@@ -124,34 +121,16 @@ ScrollBar::~ScrollBar()
     removeFromSuperview();
 }
 
-bool ScrollBar::setValue(int v)
+void PlatformScrollBar::setScrollBarValue(int v)
 {
-    int maxPos = m_totalSize - m_visibleSize;
-    if (v < 0) v = 0;
-    if (v > maxPos)
-        v = maxPos;
-    if (m_currentPos == v)
-        return false; // Our value stayed the same.
-    m_currentPos = v;
-
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
     WebCoreScrollBar *bar = (WebCoreScrollBar *)getView();
-    [bar setFloatValue:(float)m_currentPos/maxPos
+    [bar setFloatValue:(float)m_currentPos / (m_totalSize - m_visibleSize)
         knobProportion:[bar knobProportion]];
     END_BLOCK_OBJC_EXCEPTIONS;
-
-    valueChanged();
-    
-    return true;
-}
-
-void ScrollBar::setSteps(int lineStep, int pageStep)
-{
-    m_lineStep = lineStep;
-    m_pageStep = pageStep;
 }
 
-void ScrollBar::setKnobProportion(int visibleArea, int totalArea)
+void PlatformScrollBar::setKnobProportion(int visibleArea, int totalArea)
 {
     m_visibleSize = visibleArea;
     m_totalSize = totalArea;
@@ -164,7 +143,7 @@ void ScrollBar::setKnobProportion(int visibleArea, int totalArea)
     END_BLOCK_OBJC_EXCEPTIONS;
 }
 
-bool ScrollBar::scrollbarHit(NSScrollerPart hitPart)
+bool PlatformScrollBar::scrollbarHit(NSScrollerPart hitPart)
 {
     int maxPos = m_totalSize - m_visibleSize;
     if (maxPos <= 0)
@@ -199,37 +178,29 @@ bool ScrollBar::scrollbarHit(NSScrollerPart hitPart)
     return setValue(newPos);
 }
 
-void ScrollBar::valueChanged()
-{
-    if (client())
-        client()->valueChanged(this);
-}
-
-bool ScrollBar::scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier)
-{
-    float delta = 0.0;
-    if ((direction == ScrollUp && m_orientation == VerticalScrollBar) || (direction == ScrollLeft && m_orientation == HorizontalScrollBar)) {
-        if (granularity == ScrollByLine) {
-            delta = -m_lineStep;
-        } else if (granularity == ScrollByPage) {
-            delta = -m_pageStep;
-        } else if (granularity == ScrollByDocument) {
-            delta = -m_currentPos;
-        } else if (granularity == ScrollByWheel) {
-            delta = -m_lineStep;
-        }
-    } else if ((direction == ScrollDown && m_orientation == VerticalScrollBar) || (direction == ScrollRight && m_orientation == HorizontalScrollBar)) {
-        if (granularity == ScrollByLine) {
-            delta = m_lineStep;
-        } else if (granularity == ScrollByPage) {
-            delta = m_pageStep;
-        } else if (granularity == ScrollByDocument) {
-            delta = m_totalSize - m_visibleSize - m_currentPos;
-        } else if (granularity == ScrollByWheel) {
-            delta = m_lineStep;
-        }
-    }
-    int newPos = (int)(m_currentPos + (delta * multiplier));
-    return setValue(newPos);
+int PlatformScrollBar::width() const
+{
+    return Widget::width();
 }
 
+int PlatformScrollBar::height() const
+{
+    return Widget::height();
+}
+
+void PlatformScrollBar::setRect(const IntRect& rect)
+{
+    setFrameGeometry(rect);
+}
+
+void PlatformScrollBar::setEnabled(bool enabled)
+{
+    Widget::setEnabled(enabled);
+}
+
+void PlatformScrollBar::paint(GraphicsContext* graphicsContext, const IntRect& damageRect)
+{
+    Widget::paint(graphicsContext, damageRect);
+}
+
+}
index 98436c2227db0f2fb32dfd224722ea7b914b72d4..eba2af914838aded5572fb8b2bbb88040eafefa5 100644 (file)
@@ -35,6 +35,7 @@
 #import "FrameMac.h"
 #import "WebCoreFrameBridge.h"
 #import "RenderReplaced.h"
+#import "WidgetClient.h"
 #import <wtf/Assertions.h>
 
 using namespace std;
index c7a47ac2513f7936ac32e21af142f03bb18efb56..1c8b16197e2168f9162561f0abb837b1b586cf43 100644 (file)
@@ -2471,7 +2471,7 @@ bool RenderBlock::isPointInScrollbar(int _x, int _y, int _tx, int _ty)
                        m_layer->verticalScrollbarWidth(),
                        height() + borderTopExtra() + borderBottomExtra() - borderTop() - borderBottom() -  m_layer->horizontalScrollbarHeight());
         if (vertRect.contains(_x, _y)) {
-            RenderLayer::gScrollBar = m_layer->verticalScrollbar();
+            RenderLayer::gScrollBar = m_layer->verticalScrollbarWidget();
             return true;
         }
     }
@@ -2482,7 +2482,7 @@ bool RenderBlock::isPointInScrollbar(int _x, int _y, int _tx, int _ty)
                         width() - borderLeft() - borderRight() - m_layer->verticalScrollbarWidth(),
                         m_layer->horizontalScrollbarHeight());
         if (horizRect.contains(_x, _y)) {
-            RenderLayer::gScrollBar = m_layer->horizontalScrollbar();
+            RenderLayer::gScrollBar = m_layer->horizontalScrollbarWidget();
             return true;
         }
     }
index a5c0bf5c2d5e59c8077f19c91bc35e32150aeb4a..29e9957952b28126e93daceac71a044fe1bd3ddc 100644 (file)
@@ -29,6 +29,7 @@
 #include "EventNames.h"
 #include "HTMLGenericFormElement.h"
 #include "PlatformMouseEvent.h"
+#include "Widget.h"
 
 namespace WebCore {
 
index 099ea43840e93440e355340d893554ea8b405a17..daa47d18e8966e43832a754fb6e0702f7f49de36 100644 (file)
@@ -61,6 +61,7 @@
 #include "RenderTheme.h"
 #include "RenderView.h"
 #include "SelectionController.h"
+#include "PlatformScrollBar.h" 
 
 #if SVG_SUPPORT
 #include "SVGNames.h"
@@ -79,7 +80,7 @@ namespace WebCore {
 using namespace EventNames;
 using namespace HTMLNames;
 
-ScrollBar* RenderLayer::gScrollBar = 0;
+PlatformScrollBar* RenderLayer::gScrollBar = 0;
 
 #ifndef NDEBUG
 static bool inRenderLayerDestroy;
@@ -860,7 +861,21 @@ void RenderLayer::resize(const PlatformMouseEvent& evt, const IntSize& offsetFro
     }
 }
 
-void RenderLayer::valueChanged(Widget*)
+PlatformScrollBar* RenderLayer::horizontalScrollbarWidget() const
+{
+    if (m_hBar && m_hBar->isWidget())
+        return static_cast<PlatformScrollBar*>(m_hBar);
+    return 0;
+}
+
+PlatformScrollBar* RenderLayer::verticalScrollbarWidget() const
+{
+    if (m_vBar && m_vBar->isWidget())
+        return static_cast<PlatformScrollBar*>(m_vBar);
+    return 0;
+}
+
+void RenderLayer::valueChanged(ScrollBar*)
 {
     // Update scroll position from scroll bars.
 
@@ -891,12 +906,15 @@ void RenderLayer::setHasHorizontalScrollbar(bool hasScrollbar)
 
     if (hasScrollbar) {
         FrameView* scrollView = m_object->element()->document()->view();
-        m_hBar = new ScrollBar(HorizontalScrollBar);
-        m_hBar->setClient(this);
-        scrollView->addChild(m_hBar);
+        m_hBar = new PlatformScrollBar(this, HorizontalScrollBar); // FIXME: Abstract the creation once we have engine-created scrollbars.
+        if (m_hBar->isWidget())
+            scrollView->addChild(horizontalScrollbarWidget());
     } else {
-        FrameView* scrollView = m_object->element()->document()->view();
-        scrollView->removeChild(m_hBar);
+        if (m_hBar->isWidget()) {
+            FrameView* scrollView = m_object->element()->document()->view();
+            scrollView->removeChild(horizontalScrollbarWidget());
+        }
+        
         delete m_hBar;
         m_hBar = 0;
     }
@@ -916,12 +934,15 @@ void RenderLayer::setHasVerticalScrollbar(bool hasScrollbar)
 
     if (hasScrollbar) {
         FrameView* scrollView = m_object->element()->document()->view();
-        m_vBar = new ScrollBar(VerticalScrollBar);
-        m_vBar->setClient(this);
-        scrollView->addChild(m_vBar);
-    } else {
-        FrameView* scrollView = m_object->element()->document()->view();
-        scrollView->removeChild(m_vBar);
+        m_vBar = new PlatformScrollBar(this, VerticalScrollBar); // FIXME: Abstract the creation once we have engine-created scrollbars.
+        if (m_vBar->isWidget())
+            scrollView->addChild(verticalScrollbarWidget());
+    } else { 
+        if (m_vBar->isWidget()) {
+            FrameView* scrollView = m_object->element()->document()->view();
+            scrollView->removeChild(verticalScrollbarWidget());
+        }
+
         delete m_vBar;
         m_vBar = 0;
     }
@@ -984,18 +1005,18 @@ void
 RenderLayer::positionScrollbars(const IntRect& absBounds)
 {
     int resizeControlSize = max(resizeControlRect().height() - 1, 0);
-    if (m_vBar) {
-        m_vBar->move(absBounds.right() - m_object->borderRight() - m_vBar->width(),
-                     absBounds.y() + m_object->borderTop());
-        m_vBar->resize(m_vBar->width(), absBounds.height() - (m_object->borderTop() + m_object->borderBottom()) - (m_hBar ? m_hBar->height() - 1 : resizeControlSize));
-    }
+    if (m_vBar)
+        m_vBar->setRect(IntRect(absBounds.right() - m_object->borderRight() - m_vBar->width(),
+                                absBounds.y() + m_object->borderTop(),
+                                m_vBar->width(),
+                                absBounds.height() - (m_object->borderTop() + m_object->borderBottom()) - (m_hBar ? m_hBar->height() - 1 : resizeControlSize)));
 
     resizeControlSize = max(resizeControlRect().width() - 1, 0);
-    if (m_hBar) {
-        m_hBar->move(absBounds.x() + m_object->borderLeft(),
-                     absBounds.bottom() - m_object->borderBottom() - m_hBar->height());
-        m_hBar->resize(absBounds.width() - (m_object->borderLeft() + m_object->borderRight()) - (m_vBar ? m_vBar->width() - 1 : resizeControlSize), m_hBar->height());
-    }
+    if (m_hBar)
+        m_hBar->setRect(IntRect(absBounds.x() + m_object->borderLeft(),
+                                absBounds.bottom() - m_object->borderBottom() - m_hBar->height(),
+                                absBounds.width() - (m_object->borderLeft() + m_object->borderRight()) - (m_vBar ? m_vBar->width() - 1 : resizeControlSize),
+                                m_hBar->height()));
 }
 
 int RenderLayer::scrollWidth()
index 634d93adae18148a87a2f6d26d20ed8fe895a44c..a50a48119deb8bf9db421f51e92f270bb777a54d 100644 (file)
@@ -46,7 +46,7 @@
 
 #include "RenderObject.h"
 #include "Timer.h"
-#include "WidgetClient.h"
+#include "ScrollBar.h"
 
 namespace WebCore {
 
@@ -58,6 +58,7 @@ class RenderStyle;
 class RenderTable;
 class RenderText;
 class ScrollBar;
+class PlatformScrollBar;
 
 class ClipRects
 {
@@ -139,7 +140,7 @@ private:
     EMarqueeDirection m_direction : 4;
 };
 
-class RenderLayer : WidgetClient {
+class RenderLayer : public ScrollBarClient {
 public:
     enum ScrollBehavior {
         noScroll,
@@ -167,7 +168,7 @@ public:
     static ScrollBehavior getPartialBehavior(const ScrollAlignment& s) { return s.m_rectPartial; }
     static ScrollBehavior getHiddenBehavior(const ScrollAlignment& s) { return s.m_rectHidden; }
 
-    static ScrollBar* gScrollBar;
+    static PlatformScrollBar* gScrollBar;
     
     RenderLayer(RenderObject*);
     ~RenderLayer();
@@ -235,6 +236,8 @@ public:
     void setHasVerticalScrollbar(bool hasScrollbar);
     ScrollBar* horizontalScrollbar() { return m_hBar; }
     ScrollBar* verticalScrollbar() { return m_vBar; }
+    PlatformScrollBar* horizontalScrollbarWidget() const;
+    PlatformScrollBar* verticalScrollbarWidget() const;
     int verticalScrollbarWidth();
     int horizontalScrollbarHeight();
     void positionScrollbars(const IntRect& absBounds);
@@ -244,7 +247,6 @@ public:
     void paintScrollbars(GraphicsContext*, const IntRect& damageRect);
     void paintResizeControl(GraphicsContext*);
     void updateScrollInfoAfterLayout();
-    void slotValueChanged(int);
     bool scroll(ScrollDirection direction, ScrollGranularity granularity, float multiplier=1.0);
     void autoscroll();
     bool shouldAutoscroll();
@@ -340,7 +342,7 @@ private:
 
     bool shouldBeOverflowOnly() const;
 
-    virtual void valueChanged(Widget*);
+    virtual void valueChanged(ScrollBar*);
 
     void updateOverflowStatus(bool horizontalOverflow, bool verticalOverflow);
 protected:   
index 1336ae97af7ffcd1b192d8d34acb231db962a3a5..40ed7b2e77bf7283be3594e68ca2209a47ab691c 100644 (file)
@@ -25,6 +25,7 @@
 #define RenderWidget_H
 
 #include "RenderReplaced.h"
+#include "WidgetClient.h"
 
 namespace WebCore {