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
+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.
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 */,
);
class CanvasRenderingContext2D;
typedef CanvasRenderingContext2D CanvasRenderingContext;
class FloatRect;
+class GraphicsContext;
class HTMLCanvasElement : public HTMLElement {
public:
#include "MouseEventWithHitTestResults.h"
#include "NodeList.h"
#include "Page.h"
+#include "PlatformScrollBar.h"
#include "PlugInInfoStore.h"
#include "Plugin.h"
#include "PluginDocument.h"
--- /dev/null
+/*
+ * 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
+
#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,
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;
*/
#import "config.h"
-#import "ScrollBar.h"
+#import "PlatformScrollBar.h"
#import "BlockExceptions.h"
#import "WebCoreWidgetHolder.h"
@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.
return self;
}
-- (void)detachQScrollBar
+- (void)detachPlatformScrollBar
{
[self setTarget:nil];
scrollBar = 0;
- (IBAction)scroll:(NSScroller*)sender
{
- if (scrollBar) {
+ if (scrollBar)
scrollBar->scrollbarHit([sender hitPart]);
- }
}
- (Widget *)widget
@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
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;
END_BLOCK_OBJC_EXCEPTIONS;
}
-bool ScrollBar::scrollbarHit(NSScrollerPart hitPart)
+bool PlatformScrollBar::scrollbarHit(NSScrollerPart hitPart)
{
int maxPos = m_totalSize - m_visibleSize;
if (maxPos <= 0)
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);
+}
+
+}
#import "FrameMac.h"
#import "WebCoreFrameBridge.h"
#import "RenderReplaced.h"
+#import "WidgetClient.h"
#import <wtf/Assertions.h>
using namespace std;
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;
}
}
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;
}
}
#include "EventNames.h"
#include "HTMLGenericFormElement.h"
#include "PlatformMouseEvent.h"
+#include "Widget.h"
namespace WebCore {
#include "RenderTheme.h"
#include "RenderView.h"
#include "SelectionController.h"
+#include "PlatformScrollBar.h"
#if SVG_SUPPORT
#include "SVGNames.h"
using namespace EventNames;
using namespace HTMLNames;
-ScrollBar* RenderLayer::gScrollBar = 0;
+PlatformScrollBar* RenderLayer::gScrollBar = 0;
#ifndef NDEBUG
static bool inRenderLayerDestroy;
}
}
-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.
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;
}
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;
}
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()
#include "RenderObject.h"
#include "Timer.h"
-#include "WidgetClient.h"
+#include "ScrollBar.h"
namespace WebCore {
class RenderTable;
class RenderText;
class ScrollBar;
+class PlatformScrollBar;
class ClipRects
{
EMarqueeDirection m_direction : 4;
};
-class RenderLayer : WidgetClient {
+class RenderLayer : public ScrollBarClient {
public:
enum ScrollBehavior {
noScroll,
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();
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);
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();
bool shouldBeOverflowOnly() const;
- virtual void valueChanged(Widget*);
+ virtual void valueChanged(ScrollBar*);
void updateOverflowStatus(bool horizontalOverflow, bool verticalOverflow);
protected:
#define RenderWidget_H
#include "RenderReplaced.h"
+#include "WidgetClient.h"
namespace WebCore {